Clamp with Overflow
medium
Constrain a numeric input between Min and Max bounds and raise flags when limits are hit.
What it teaches
A clamp that also reports when its limits engage. Pin the value to Max (and raise a 'too high' flag) or to Min (and raise a 'too low' flag); inside the range, the value passes through with both flags off. Useful when downstream logic needs to know the rail was hit.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Value | REAL | — | Input value to clamp |
| Cfg_Min | REAL | 10 | Lower bound limit |
| Cfg_Max | REAL | 90 | Upper bound limit |
| Out_Clamped | REAL | — | Constrained output value |
| Sts_TooHigh | BOOL | — | Too high flag |
| Sts_TooLow | BOOL | — | Too low flag |
Required behavior
- Out_Clamped equals In_Value when it is between Cfg_Min and Cfg_Max inclusive.
- Out_Clamped is pinned to Cfg_Max and Sts_TooHigh is 1 when In_Value is greater than Cfg_Max.
- Out_Clamped is pinned to Cfg_Min and Sts_TooLow is 1 when In_Value is less than Cfg_Min.
- Sts_TooHigh and Sts_TooLow are 0 when In_Value is within limits.