Back to examples

Program notes

Conveyor Part Counter

CTU counts sensor pulses and activates a batch-complete signal at the preset count.

1. What the Program Does

This example counts conveyor parts. Part_Sensor passes through R_TRIG so one part produces one counting pulse. CTU increments the count until the batch preset is reached and activates Batch_Complete.

Counting is enabled only while Conveyor_Run is active. Batch_Reset clears the counter for a new batch.

Part_Sensor → R_TRIG → AND → CTU → Batch_Complete

2. Example Signals

SignalTypePurpose
Part_SensorInputPart passage sensor
Conveyor_RunInputConveyor running
Batch_ResetInputBatch counter reset
Part_PulseBlockOne pulse on the sensor's rising edge
Count_AllowedBlockCounting enabled while conveyor runs
Batch_CounterBlockCTU counter with PV = 10
Batch_CompleteOutputBatch target reached

3. Main Logic

R_TRIG turns a held sensor signal into TRUE for one scan on its rising edge. This prevents repeated counting while a part remains in front of the sensor.

Count_Allowed = Part_Pulse AND Conveyor_Run
Batch_Complete = Count >= PV

CTU counts Count_Allowed pulses. Q becomes TRUE when the accumulated count reaches PV.

4. Testing in the Simulator

  • Activate Conveyor_Run.
  • Switch Part_Sensor FALSE → TRUE → FALSE: each new rising edge adds one count.
  • Hold Part_Sensor TRUE: the count must not increase without another edge.
  • Clear Conveyor_Run: sensor pulses must not reach the counter.
  • Activate Batch_Reset to begin a new batch.

5. What to Watch For

PV is 10 in this example. For a manual check, advance the simulation and toggle the sensor repeatedly. Once the preset is reached, Batch_Complete remains TRUE until reset.

A real project often adds a conveyor-stop output, current-count indication, and sensor debounce logic.

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.