← All exercises

Count Up Down with Bounds

medium

Bidirectional counter with upper and lower bounds, and flag outputs when the limits are hit.

What it teaches

A bidirectional counter that respects a Min and Max. Hit the top — the count pins to Max and the at-max flag turns on. Hit the bottom — pins to Min and the at-min flag turns on. Useful when a tracked balance needs both directions and known boundaries.

Inputs and outputs

TagTypeDefaultDescription
In_CountUpBOOLCount up pulse
In_CountDownBOOLCount down pulse
Cfg_MinDINT0Lower limit for the count
Cfg_MaxDINT3Upper limit for the count
Out_CountDINTCurrent bounded count
Sts_AtMaxBOOLAt maximum limit flag
Sts_AtMinBOOLAt minimum limit flag

Required behavior