Configurable Scaling
medium
Linearly scales a raw input to engineering units between two configurable endpoints.
What it teaches
Generalize Scale into range mapping, also called remapping. Instead of hardcoded 4-20 to 0-100, the endpoints are inputs, so the engineer can tune any sensor to any output range.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Raw | Input | REAL | 0 | Raw input value to scale |
| Cfg_RawMin | Input | REAL | 0 | Raw value at the minimum endpoint |
| Cfg_RawMax | Input | REAL | 0 | Raw value at the maximum endpoint |
| Cfg_EUMin | Input | REAL | 0 | Engineering unit value at the minimum endpoint |
| Cfg_EUMax | Input | REAL | 0 | Engineering unit value at the maximum endpoint |
| Out_Scaled | Output | REAL | 0 | Scaled engineering unit value |
Required behavior
- Scales the raw input proportionally from the raw range to the engineering unit range.
- Output follows the formula: Out_Scaled = Cfg_EUMin + (In_Raw - Cfg_RawMin) * (Cfg_EUMax - Cfg_EUMin) / (Cfg_RawMax - Cfg_RawMin).
- Inputs outside the raw range extrapolate along the same line — the output is not clamped.
- If the raw range is zero (Cfg_RawMin equals Cfg_RawMax), the output defaults to Cfg_EUMin.