For a linear 4–20 mA input mapped to 0–250 kPa, subtract the 4 mA live-zero, divide by the 16 mA input span, then multiply by the 250 kPa engineering span. At 13.6 mA, the normalized input is (13.6 - 4) / 16 = 0.60, so the pressure is 0.60 × 250 = 150 kPa. Calculate and preserve the input-range status before limiting a display value; otherwise a low or high current can look like a valid endpoint.
Scope and terms before the formula
IEC 61131-3:2025 Edition 4 identifies Function Block Diagram (FBD) as one of the graphical languages in the current programmable-controller language suite. The standard establishes the language; it does not make every controller's analog representation, tag names, diagnostic thresholds, execution order, or scaling instruction identical.
This worked example begins after a fictional analog input has provided a REAL value in milliamps. That assumption is important. A real module may instead provide signed counts, unsigned counts, percent of range, or engineering units already scaled in module configuration. Rockwell's September 2025 SCL documentation, for example, describes both floating-point inputs and a case where a module supplies unscaled integer values. Use the endpoints that correspond to the configured data representation—not 4.0 and 20.0 merely because the field loop is labeled 4–20 mA.
The four endpoint terms are:
| Term | Value here | Meaning |
|---|---|---|
InputMin | 4.0 mA | input corresponding to the low engineering endpoint |
InputMax | 20.0 mA | input corresponding to the high engineering endpoint |
EUMin | 0 kPa | low engineering-unit endpoint |
EUMax | 250 kPa | high engineering-unit endpoint |
"Scaling" is the linear conversion. "Limiting" or "clamping" forces a result into a chosen range. "Diagnostics" decides whether the source should be trusted or flagged. They can share endpoints, but they are not the same operation.
The endpoint formula
Rockwell's current SCL reference uses the general endpoint form below for conversion to engineering units:
EU = EUMin
+ (Input - InputMin)
× (EUMax - EUMin) / (InputMax - InputMin)
Written as normalize, span, and offset steps:
InputSpan = InputMax - InputMin
EUSpan = EUMax - EUMin
Normalized = (Input - InputMin) / InputSpan
EU = EUMin + Normalized × EUSpan
The required invariant is InputMax > InputMin; otherwise InputSpan is zero or negative and the configuration is invalid. Rockwell's SCL instruction reports an invalid raw range rather than silently treating equal endpoints as a useful scale. The exact fault or status mechanism remains controller-specific.
For this example, EUMin is zero, so the final addition disappears:
Pressure_kPa = (Current_mA - 4.0 mA)
/ (20.0 mA - 4.0 mA)
× (250 kPa - 0 kPa)
= (Current_mA - 4.0 mA)
/ 16.0 mA
× 250 kPa
The units expose a common mistake: (mA / mA) is dimensionless, leaving kilopascals. Subtracting 4 without knowing whether the tag holds milliamps or device counts breaks that unit check.
Worked value: 13.6 mA
Use these explicit inputs and assumptions:
| Input | Value |
|---|---|
| current value | 13.6 mA |
| current endpoints | 4.0–20.0 mA |
| pressure endpoints | 0–250 kPa |
| relationship | linear between the configured endpoints |
| arithmetic type | floating point |
| calibration and uncertainty | not modeled |
First remove the live-zero offset:
13.6 mA - 4.0 mA = 9.6 mA
Then normalize by the 16 mA span:
9.6 mA / 16.0 mA = 0.60
Finally apply the 250 kPa engineering span:
0.60 × 250 kPa = 150 kPa
An inverse calculation catches swapped endpoints and misplaced offsets:
Current_mA = 4.0 mA + (150 kPa / 250 kPa) × 16.0 mA
= 4.0 mA + 9.6 mA
= 13.6 mA
The forward and inverse results agree. This proves the arithmetic under the stated linear model; it does not prove that a transmitter actually produced 13.6 mA or that the input channel measured it accurately.
Reproducible Schematex source
fbd "4-20 mA to 0-250 kPa"
var Current_mA: real
var Scaled_kPa: real
var Display_kPa: real
var UnderRange: bool
var OverRange: bool
network 0 "Linear engineering-unit scaling":
Scaled_kPa = MUL(DIV(SUB(Current_mA, 4.0), 16.0), 250.0)
network 1 "Bound the display only":
Display_kPa = LIMIT(MN: 0.0, IN: Scaled_kPa, MX: 250.0)
network 2 "Preserve input-range diagnostics":
UnderRange = LT(IN1: Current_mA, IN2: 4.0)
OverRange = GT(IN1: Current_mA, IN2: 20.0)
Schematex 1.0.13 strictly parsed and rendered this source on September 1, 2026. The SVG contains three networks; one each of SUB, DIV, MUL, and LIMIT; two comparison blocks; REAL signal paths; BOOL diagnostic outputs; and no parser or renderer diagnostics. The current Schematex FBD syntax reference documents nested math calls, inline constants, declared types, LIMIT, and comparison blocks.
The renderer makes the data flow reviewable, but it does not execute the networks or guarantee a target PLC's scan behavior. The two range comparisons also use the nominal scaling endpoints only to demonstrate separation of concerns. A real project may define different diagnostic limits, delay or debounce a condition, read module status bits, or reject the measurement by another validated rule.
Anchor checks and out-of-range behavior
Three anchor points should pass before testing an arbitrary value:
| Current | Calculation | Expected pressure |
|---|---|---|
4.0 mA | (4 - 4) / 16 × 250 | 0 kPa |
12.0 mA | (12 - 4) / 16 × 250 | 125 kPa |
20.0 mA | (20 - 4) / 16 × 250 | 250 kPa |
The midpoint check is especially useful: 12 mA is halfway between 4 and 20 mA, so it must map halfway between 0 and 250 kPa.
Now challenge the range. With the same linear equation, 3.8 mA produces:
(3.8 - 4.0) / 16.0 × 250 = -3.125 kPa
The diagram's LIMIT network would show 0 kPa, while UnderRange remains true because it compares the original current with 4.0 mA. At 20.4 mA, the unrestricted result is 256.25 kPa; the display becomes 250 kPa, and OverRange remains true. This is why downstream logic should not infer measurement health from the clamped display alone.
Rockwell documents the same conceptual separation in its SCL instruction: limiting can bound the output while minimum and maximum input alarms report that the input crossed its configured raw endpoints. Do not copy those exact status names into another platform without its manual.
Checks and invariants
- Endpoint order:
InputMax > InputMin; the input span is16.0 mA, not zero. - Low endpoint:
4.0 mAmaps exactly to0 kPa. - High endpoint:
20.0 mAmaps exactly to250 kPa. - Midpoint:
12.0 mAmaps to125 kPa. - Worked value:
13.6 mAmaps to150 kPa, and the inverse formula returns13.6 mA. - Monotonicity: because both spans are positive, increasing current cannot reduce the calculated pressure.
- Representation: the tag's actual units match the configured scaling endpoints. If the tag contains counts, both input endpoints must be counts.
- Status preservation: an out-of-range input remains visible to diagnostics after any display limiting.
- Precision: intermediate operations use sufficient numeric precision; integer division must not truncate the normalized fraction to zero.
Failure modes and review boundary
Common failures are treating 4 mA as zero before subtracting it, dividing by 20 instead of the 16 mA span, applying a pressure range that differs from the transmitter configuration, using milliamp endpoints against a raw-count tag, performing integer division, swapping low and high endpoints, and clamping before checking the original input. Another failure is assuming every current below 4 mA has one universal meaning. The module manual, transmitter manual, configured diagnostic limits, and project alarm philosophy control that interpretation.
Scaling also does not remove measurement uncertainty. Transmitter accuracy, input-module accuracy, quantization, loop resistance, supply voltage, grounding, shielding, calibration, environmental conditions, and wiring faults can all affect a real value. A mathematically correct 150 kPa is still only as trustworthy as the measurement chain and its diagnostics.
Paste the source into the Schematex playground. Change the engineering endpoints to the real transmitter range, then calculate and test the low endpoint, midpoint, high endpoint, one normal operating value, and at least one value on each side of the accepted input range. In the target PLC, confirm the actual module data representation and observe both the unrestricted result and the independent diagnostic state before accepting the implementation.