Clamp with Overflow
medium
Constrains a numeric input between Min and Max bounds and raises 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.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Value | Input | REAL | 0 | Input value to clamp |
| Cfg_Min | Input | REAL | 10 | Lower bound limit |
| Cfg_Max | Input | REAL | 90 | Upper bound limit |
| Out_Clamped | Output | REAL | 0 | Constrained output value |
| Sts_TooHigh | Output | BOOL | 0 | Too high flag |
| Sts_TooLow | Output | BOOL | 0 | 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.