Back to examples

Program notes

Position Sensor Check

XOR detects disagreement between two sensors and activates a diagnostic output.

1. What the Program Does

This example checks two position sensors for agreement. When Position_A and Position_B differ, XOR activates the diagnostic output Sensor_Mismatch.

The diagram illustrates checking a pair of sensors that should normally report the same value.

Position_A XOR Position_B → Sensor_Mismatch

2. Example Signals

SignalTypePurpose
Position_AInputFirst position sensor
Position_BInputSecond position sensor
XORBlockDetects differing Boolean values
Sensor_MismatchOutputMismatch diagnostic

3. Main Logic

XOR produces TRUE when its inputs differ:

Sensor_Mismatch = Position_A XOR Position_B

Both FALSE or both TRUE produce no mismatch. One TRUE and one FALSE produce a mismatch.

4. Truth Table

Position_APosition_BSensor_Mismatch
FALSEFALSEFALSE
TRUEFALSETRUE
FALSETRUETRUE
TRUETRUEFALSE

5. Testing in the Simulator

  • Leave both inputs FALSE: no mismatch.
  • Activate only Position_A: Sensor_Mismatch becomes TRUE.
  • Activate both inputs: the mismatch clears.
  • Clear Position_A while Position_B stays TRUE: the mismatch returns.

6. What to Watch For

XOR detects a difference but does not explain its cause. Real diagnostics often add messages identifying each sensor's state and the duration of the mismatch.

Add a TON timer if brief transitions should not immediately activate an alarm.

Check in editor

Open the ready-made FBD diagram, toggle inputs, and compare the simulation behavior with the program notes. The JSON is also available as a direct download.