Scale (Configurable)
medium
Linearly scale a raw input to engineering units between two tunable endpoints.
What it teaches
The configurable cousin of Scale. Instead of hardcoded 4-20 to 0-100, the endpoints are inputs — same straight-line idea, but the engineer can tune any sensor to any output range.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Raw | REAL | — | Raw input value to scale |
| Cfg_RawMin | REAL | — | Raw value at the minimum endpoint |
| Cfg_RawMax | REAL | — | Raw value at the maximum endpoint |
| Cfg_EUMin | REAL | — | Engineering unit value at the minimum endpoint |
| Cfg_EUMax | REAL | — | Engineering unit value at the maximum endpoint |
| Out_Scaled | REAL | — | 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.