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_Complete2. Example Signals
| Signal | Type | Purpose |
|---|---|---|
| Part_Sensor | Input | Part passage sensor |
| Conveyor_Run | Input | Conveyor running |
| Batch_Reset | Input | Batch counter reset |
| Part_Pulse | Block | One pulse on the sensor's rising edge |
| Count_Allowed | Block | Counting enabled while conveyor runs |
| Batch_Counter | Block | CTU counter with PV = 10 |
| Batch_Complete | Output | Batch 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 >= PVCTU 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.