All exercises

Loop Counter

Increment a dual-stage counter (MicroCount + MacroCount) every scan while enabled in rungs.dev, and report the combined total as a single DINT output.

beginner

Parameters

NameTypeUsageDescription
In_EnableCountBOOLInput1 to enable counting, 0 to hold count.
Out_CountValueDINTOutputThe total accumulated value representing MacroCount * 10 + MicroCount.

Behavior

  1. When In_EnableCount is 1, increment local tag MicroCount by 1 per scan.
  2. If MicroCount reaches 10, reset MicroCount to 0 and increment local tag MacroCount by 1.
  3. Output Out_CountValue is calculated as (MacroCount * 10) + MicroCount.
  4. When In_EnableCount is 0, local tags shall maintain their current values.
  5. The count progression follows the PLC scan rate, and any DINT overflow follows standard PLC numeric behavior.

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.