Loop Counter
Increment a count value based on dual-stage counter logic (MicroCount and MacroCount) while enabled.
beginner
Parameters
| Name | Type | Usage | Description |
|---|
| In_EnableCount | BOOL | Input | 1 to enable counting, 0 to hold count. |
| Out_CountValue | DINT | Output | The total accumulated value representing MacroCount * 10 + MicroCount. |
Behavior
- When In_EnableCount is 1, increment local tag MicroCount by 1 per scan.
- If MicroCount reaches 10, reset MicroCount to 0 and increment local tag MacroCount by 1.
- Output Out_CountValue is calculated as (MacroCount * 10) + MicroCount.
- When In_EnableCount is 0, local tags shall maintain their current values.
Edge Cases
- MicroCount will reset correctly from 10 to 0.
- DINT overflow on MacroCount or Out_CountValue if left running for an extended duration.
Constraints
- The scan rate of the PLC determines the frequency of MicroCount increments.
- DINT capacity limits the maximum value of Out_CountValue.
Ready to start?
Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.