CTU with Auto-Reset
Counter that automatically resets after reaching preset, creating repeating count cycles.
The CTU with Auto-Reset is a common programming pattern that combines the standard CTU (Counter Up) with automatic reset logic. When the counter reaches its preset value, it triggers an action and immediately resets itself to begin counting again. This pattern is used for repeating batch operations, periodic maintenance triggers, and cyclic event generation. While not a separate IEC 61131-3 standard block, it is one of the most frequently implemented counter patterns in production PLC code.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| CU | BOOL | Count up input |
| R | BOOL | Manual reset input |
| PV | INT | Preset value (cycle count) |
Outputs
| Name | Type | Description |
|---|---|---|
| Q | BOOL | Pulse output - TRUE for one scan when CV = PV |
| CV | INT | Current counter value |
Ladder Logic Example
// Ladder Logic - CTU with Auto-Reset // // |----[ Part_Sensor ]------[CTU Batch_Ctr]--------| // | CU: Part_Sensor | // | R: Auto_Reset | // | PV: 12 | // | Q: Batch_Done | // // |----[ Batch_Done ]-------( Auto_Reset )---------| // |----[ Batch_Done ]-------( Box_Eject )----------|
Structured Text Example
VAR
Batch_Ctr : CTU;
Part_Sensor : BOOL;
Batch_Done : BOOL;
END_VAR
Batch_Ctr(CU := Part_Sensor, R := Batch_Done, PV := 12);
Batch_Done := Batch_Ctr.Q;
// Counter resets automatically each time 12 parts are counted20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Implement using CTU with Q output fed back to R input. Use one-shot for the done action.
Allen-Bradley (Studio 5000)
Use CTU with .DN bit driving RES instruction. Common pattern in packaging applications.
CODESYS
Use standard CTU with Q connected back to R through action logic.
Common Applications
- Repeating batch counting
- Periodic lubrication triggers
- Cyclic quality checks
- Packing line box counts
Common Mistakes to Avoid
- Auto-reset happening too fast and missing the done pulse
- Race condition between done output and reset
Frequently Asked Questions
What is CTU with Auto-Reset in PLC programming?
Counter that automatically resets after reaching preset, creating repeating count cycles. The CTU with Auto-Reset is a common programming pattern that combines the standard CTU (Counter Up) with automatic reset logic. When the counter reaches its preset value, it triggers an action and immediately resets itself to begin counting again.
What are common applications of CTU with Auto-Reset?
CTU with Auto-Reset is commonly used for: Repeating batch counting, Periodic lubrication triggers, Cyclic quality checks, Packing line box counts.
How do I use CTU with Auto-Reset in different PLC platforms?
Siemens: Implement using CTU with Q output fed back to R input. Use one-shot for the done action. Allen-Bradley: Use CTU with .DN bit driving RES instruction. Common pattern in packaging applications. CODESYS: Use standard CTU with Q connected back to R through action logic.
Related Function Blocks
CTU (Counter Up)
Counts up on each rising edge; output activates when count reaches preset.
View Reference →CTD (Counter Down)
Counts down from preset value; output activates when count reaches zero.
View Reference →R_TRIG (Rising Edge Detection)
Detects FALSE-to-TRUE transition, outputs single-scan pulse on rising edge.
View Reference →CTUD (Counter Up/Down)
Counts both up and down with separate done outputs for each direction.
View Reference →HSC (High-Speed Counter)
Hardware-accelerated counter for high-frequency pulse inputs beyond normal scan rate.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects