PLC Analog Input Scaling: Convert Raw Counts to Engineering Units
PLC analog input scaling explained — how to convert raw ADC counts to engineering units with the linear formula, SCL/SCP instructions, and worked examples.
When a pressure transmitter sends a 4-20mA signal into a PLC, the input card does not hand the program a pressure value. It hands the program a raw integer — a dimensionless number that represents where the current sits inside the card's analog-to-digital converter range. Before that integer is useful for display, alarming, or control, it must be converted into the physical unit the operator understands: PSI, °C, m³/h, or whatever the process demands. That conversion is called analog input scaling, and it is one of the most routine tasks in PLC programming.
This guide covers everything you need to perform that conversion correctly: what raw counts are, how resolution affects them, the linear scaling formula, a fully worked example, built-in scaling instructions in Allen-Bradley and Siemens PLCs, offset and filter considerations, and how to handle out-of-range conditions safely.
Try it: the free 4-20mA Scaling Calculator converts between mA, engineering units, and raw counts in any direction.
What Analog Scaling Is and Why It Is Needed
An analog input module contains an analog-to-digital converter (ADC). The ADC samples the incoming voltage or current signal many times per second and outputs a binary integer that represents the signal level. The PLC stores that integer in a memory location — often called a raw count, raw value, or ADC count.
The raw count has no physical meaning by itself. A value of 16383 does not tell an operator anything unless they know what signal range it represents and what process variable that signal corresponds to. Scaling applies a mathematical relationship to translate the raw count into an engineering unit value that does reflect physical reality.
Raw Counts vs Engineering Units
| What the PLC sees | What the operator needs |
|---|---|
| 6400 (raw integer) | 0 PSI |
| 19200 (raw integer) | 50 PSI |
| 32000 (raw integer) | 100 PSI |
| 16383 (raw integer) | 12.5 mA on the loop |
Without scaling, control logic would have to compare raw integers against raw-count setpoints — a maintenance nightmare and a source of commissioning errors. With scaling, every tag in the program speaks the same language as the P&ID and the operator's expectations.
This concept connects directly to the underlying signal standard. If you are unfamiliar with how a 4-20mA loop produces that raw count in the first place, the 4-20mA current loop explained article covers the physics and wiring before you apply the formula here.
Resolution and Raw Count Ranges
The number of bits in the ADC determines how finely the input signal is divided. A 12-bit ADC produces 2¹² = 4096 discrete steps; a 16-bit ADC produces 65536 steps.
Common Raw Count Ranges by Module Type
| Module / Format | Full Electrical Range | Typical Raw Count Range |
|---|---|---|
| Allen-Bradley 1769-IF4 (voltage) | 0–10 V | 0–32767 |
| Allen-Bradley 1769-IF4 (current) | 4–20 mA | 6208–31208 |
| Allen-Bradley 1769-IF8 (current, scaled) | 4–20 mA | 3277–16383 |
| Siemens S7-1200 analog input | 4–20 mA | 5530–27648 |
| Siemens S7-300/400 standard | 4–20 mA | 0–27648 |
| Generic 12-bit module | 4–20 mA | 819–4095 |
Two ranges appear repeatedly in practice and deserve memorising.
0–32767 range — Used by Allen-Bradley modules that map the full input card range (including under- and over-range headroom) to a 16-bit signed integer. The 4mA live-zero point typically falls at approximately 6208 and the 20mA full-scale point at approximately 31208, leaving headroom below and above for fault detection.
0–27648 range — Siemens S7 standard. The 4mA point maps to 5530 and 20mA maps to 27648. Values above 27648 indicate over-range; values below 1382 indicate under-range or wire break.
Always consult your specific module's hardware manual for the exact count range. Using a neighboring model's counts produces a calibration error that shifts every reading across the full span.
The Linear Scaling Formula
Analog signals and engineering units have a linear relationship. The scaling formula is a straight-line interpolation between two known points: the raw minimum/maximum and the engineering unit minimum/maximum.
EU = (Raw - RawMin) × (EUMax - EUMin) / (RawMax - RawMin) + EUMin
Where:
- EU — the calculated engineering unit value (e.g. PSI, °C)
- Raw — the current raw count from the analog input
- RawMin — the raw count corresponding to the low end of the signal (e.g. 4mA)
- RawMax — the raw count corresponding to the high end of the signal (e.g. 20mA)
- EUMin — the engineering unit value at the low end of the signal (e.g. 0 PSI)
- EUMax — the engineering unit value at the high end of the signal (e.g. 100 PSI)
The fraction (EUMax - EUMin) / (RawMax - RawMin) is the slope — how many engineering units each raw count represents. Multiply the slope by how far the raw value has traveled above RawMin, then add EUMin as an offset.
Structured Text Implementation
// Analog Input Scaling — IEC 61131-3 Structured Text
// Tags:
// AI_RawCount : INT — raw value from analog input channel
// AI_Pressure : REAL — scaled pressure in PSI
// c_RawMin : INT := 6208; — raw count at 4 mA
// c_RawMax : INT := 31208; — raw count at 20 mA
// c_EUMin : REAL := 0.0; — engineering unit at 4 mA
// c_EUMax : REAL := 100.0; — engineering unit at 20 mA
AI_Pressure := (REAL(AI_RawCount) - REAL(c_RawMin))
* (c_EUMax - c_EUMin)
/ (REAL(c_RawMax) - REAL(c_RawMin))
+ c_EUMin;
Two important implementation details in this code:
- Cast to REAL before dividing. Integer division truncates toward zero. A raw span of 25000 divided by an integer midpoint produces the wrong quotient. Always cast to floating-point first.
- Use named constants, not magic numbers. Hard-coding
6208and31208inside a formula makes future re-ranging or sensor changes error-prone. Named constants are changed in one place and self-documenting.
Ladder Logic Equivalent
In Ladder Logic the same calculation uses a Compute (CPT) instruction or a sequence of arithmetic blocks (SUB, MUL, DIV, ADD):
|--[CPT]--------------------------------------------------|
| Dest: AI_Pressure |
| Expr: (REAL(AI_RawCount) - 6208.0) |
| * 100.0 / 25000.0 |
| + 0.0 |
|---------------------------------------------------------|
Most modern Studio 5000 / RSLogix 5000 projects use the CPT instruction because the full formula fits in a single rung, making audits straightforward. Older RSLogix 500 projects (MicroLogix, SLC 500) typically chain multiple math instructions because those platforms lack a CPT block.
For a broader introduction to the PLC instructions used around these calculations, the PLC programming basics fundamentals guide walks through arithmetic and data-handling instructions in context.
Worked Example: 4-20mA Pressure Transmitter, 0-100 PSI
Scenario: A pressure transmitter with a 0–100 PSI range is wired to an Allen-Bradley CompactLogix 1769-IF4 module configured for current input. The module documentation states the raw count range for 4–20mA is 6208 to 31208.
Given values:
| Parameter | Value |
|---|---|
| RawMin (4 mA) | 6208 |
| RawMax (20 mA) | 31208 |
| EUMin | 0 PSI |
| EUMax | 100 PSI |
| Current raw count | 18708 |
Step 1 — Subtract RawMin: 18708 − 6208 = 12500
Step 2 — Calculate the span: 31208 − 6208 = 25000
Step 3 — Divide (raw position / raw span): 12500 / 25000 = 0.5
Step 4 — Multiply by EU span: 0.5 × (100 − 0) = 50.0
Step 5 — Add EUMin: 50.0 + 0 = 50.0 PSI
A raw count of 18708 correctly resolves to 50 PSI — exactly the midpoint of the transmitter range, as expected for a count at the midpoint of the raw span.
Spot-check with 4mA (live zero): (6208 − 6208) / 25000 × 100 + 0 = 0.0 PSI ✓
Spot-check with 20mA (full scale): (31208 − 6208) / 25000 × 100 + 0 = 100.0 PSI ✓
The live-zero diagnostic is a practical benefit of the 4-20mA standard: if your scaled value reads below 0 PSI while the process is known to be at ambient (or if the raw count drops below RawMin), the 4mA offset is missing — a wire break or transmitter power fault. A raw count of 0 on a 4-20mA channel is a fault, not a valid reading. This is explored in more depth in the 4-20ma current loop explained article.
Instruction-Based Scaling
Most PLC platforms provide built-in instructions that implement the scaling formula without requiring you to write the arithmetic manually. These instructions are safer for maintenance technicians because the structure is recognizable and the parameters are labeled.
Allen-Bradley: SCP and SCL
SCP (Scale with Parameters) is the preferred instruction in RSLogix 5000 / Studio 5000.
| SCP Parameter | Description | Example Value |
|---|---|---|
| Input | Source tag (raw count) | Local:0:I.Ch0Data |
| Input Min | Raw count at low end | 6208 |
| Input Max | Raw count at high end | 31208 |
| Scaled Min | EU value at low end | 0.0 |
| Scaled Max | EU value at high end | 100.0 |
| Output | Destination tag | AI_Pressure |
SCP performs the linear interpolation and writes the result to the Output tag every scan. It supports extrapolation — if the raw count exceeds Input Max, the output will exceed Scaled Max proportionally. Whether that is desirable depends on the application (see clamping, below).
SCL (Scale) is the legacy instruction found in RSLogix 500 for SLC 500 and MicroLogix platforms:
SCL
Source: N7:0 (raw count integer)
Rate: 4000 (slope × 10000, where slope = EUspan/Rawspan)
Offset: 0 (EUMin, integer)
Destination: F8:0 (scaled REAL or float)
The Rate parameter in SCL is expressed as (EUMax − EUMin) / (RawMax − RawMin) × 10000, rounded to an integer. For the 0–100 PSI example: (100 / 25000) × 10000 = 40. SCL is less intuitive than SCP but remains common in legacy systems.
Siemens: NORM_X and SCALE_X
Siemens S7-1200 and S7-1500 PLCs use a two-step approach that separates normalization from scaling, which provides more flexibility when re-using a normalized value for multiple engineering unit ranges.
NORM_X normalizes a raw integer to a 0.0–1.0 REAL:
NORM_X
MIN: 5530 // raw count at 4 mA (S7-1200 standard)
VALUE: %IW64 // analog input word
MAX: 27648 // raw count at 20 mA
OUT: #Normalized_Value // REAL, 0.0 to 1.0
SCALE_X maps the normalized 0.0–1.0 value to the engineering unit range:
SCALE_X
MIN: 0.0 // EUMin in REAL
VALUE: #Normalized_Value
MAX: 100.0 // EUMax in REAL
OUT: #AI_Pressure // REAL, engineering units
Combining NORM_X and SCALE_X in series produces the same result as the linear formula.
Offset, Zero Trim, and Signal Filtering
Zero and Span Trim
Transmitters drift over time and may not produce exactly 4.000 mA at the process zero point after years in service. Most programs implement a zero trim and span trim as adjustable parameters rather than hard-coding EUMin and EUMax. An instrument technician can then correct small calibration errors from the HMI without modifying the PLC program.
// Trimmable scaling with zero and span correction
AI_Pressure := (REAL(AI_RawCount) - REAL(c_RawMin))
* (AI_SpanTrim / REAL(c_RawMax - c_RawMin))
+ AI_ZeroTrim;
AI_ZeroTrim defaults to EUMin (e.g. 0.0) and AI_SpanTrim defaults to EUMax (e.g. 100.0). The instrument technician adjusts these tags at the HMI after field calibration.
First-Order Low-Pass Filter
Analog signals in plant environments carry electrical noise that produces jitter in the scaled value. A first-order low-pass filter (exponential moving average) smooths the reading without introducing significant lag at typical process speeds:
// First-order filter — run every PLC scan
// Filter coefficient Alpha: 0.0 (no filtering) to 1.0 (no update)
// Typical starting value: 0.05 to 0.20
AI_Pressure_Filtered := AI_Pressure_Filtered
+ Alpha * (AI_Pressure - AI_Pressure_Filtered);
Choose Alpha based on the sensor's expected rate of change relative to the PLC scan time. A fast-changing pressure in a hydraulic circuit needs a smaller Alpha (less filtering, faster response) than a temperature in a large tank (more filtering, slow process). This filter executes once per PLC scan — understanding the PLC scan cycle is essential for tuning filter coefficients correctly.
Out-of-Range Detection and Clamping
When a transmitter fails, a wire breaks, or the process exceeds the sensor's measurement range, the raw count will fall outside the expected RawMin–RawMax window. Applying the scaling formula to an out-of-range raw value produces a scaled value that is also out of range — which is actually useful for diagnostics.
Detecting Wire Break (Live-Zero)
// Wire-break detection for 4-20mA channel
// Raw count below the 3.6 mA threshold (~5100 on a 0-32767 scale)
IF AI_RawCount < c_WireBreakThreshold THEN
AI_WireBreakFault := TRUE;
AI_Pressure := c_EUMin; // force to safe value
ELSE
AI_WireBreakFault := FALSE;
END_IF;
Set c_WireBreakThreshold slightly below RawMin to give hysteresis and avoid false faults from momentary noise.
Clamping Scaled Output
When the process is expected to remain within the transmitter's range, clamping prevents downstream logic from acting on physically impossible values:
// Clamp scaled value to valid engineering unit range
IF AI_Pressure > c_EUMax THEN
AI_Pressure := c_EUMax;
AI_OverRange := TRUE;
ELSIF AI_Pressure < c_EUMin THEN
AI_Pressure := c_EUMin;
AI_UnderRange := TRUE;
ELSE
AI_OverRange := FALSE;
AI_UnderRange := FALSE;
END_IF;
Do not clamp blindly. If the process can legitimately exceed the transmitter span (e.g. during startup or upset conditions), clamping hides the over-range rather than alarming on it. Decide deliberately: clamp for control stability, alarm on out-of-range, or both.
Module-Level Fault Bits
Most modern analog input modules set a hardware fault bit in the input data when the signal falls outside the acceptable range. In Allen-Bradley CompactLogix, Local:0:I.Ch0Fault goes high on a wire break or power fault. In Siemens S7 modules, the diagnostic buffer records the fault and a status bit in the module's I/O data area is set. Reading these hardware bits is more reliable than software threshold checks because the module's ADC detects true electrical faults that software thresholds may miss during fast transients.
The same fault-handling principles that apply to analog inputs apply to digital inputs and counter inputs. The counter programming article demonstrates similar defensive programming patterns for high-speed counting channels.
Frequently Asked Questions
How do you scale an analog input in a PLC?
Apply the linear formula: EU = (Raw − RawMin) × (EUMax − EUMin) / (RawMax − RawMin) + EUMin. Identify the raw count range for your specific module and signal type (e.g. 6208–31208 for a 4-20mA Allen-Bradley module), enter your engineering unit range (EUMin and EUMax), then substitute the live raw count to produce the scaled value. Most platforms offer built-in instructions — SCP/SCL in Allen-Bradley, NORM_X/SCALE_X in Siemens — that implement the same formula without manual arithmetic.
What is the analog scaling formula?
EU = (Raw − RawMin) × (EUMax − EUMin) / (RawMax − RawMin) + EUMin. This is a straight-line interpolation that maps a raw ADC count onto a physical engineering unit range. The fraction (EUMax − EUMin) / (RawMax − RawMin) is the slope in engineering units per raw count; multiply by (Raw − RawMin) to get the EU offset from zero, then add EUMin.
What is the raw count range for 4-20mA?
It depends on the module. Common ranges: Allen-Bradley 1769-IF4 uses approximately 6208–31208; Siemens S7-1200 uses 5530–27648; Siemens S7-300/400 uses 0–27648 (where 0 = 0 mA and 27648 = 20 mA). Always verify in the hardware manual for your specific module, because different firmware versions and configuration modes shift the count boundaries.
What is SCP in Allen-Bradley PLCs?
SCP (Scale with Parameters) is a ladder logic instruction in Studio 5000 / RSLogix 5000 that performs linear scaling between a defined Input Min/Max and a Scaled Min/Max. It replaces the manual CPT formula for analog scaling, making the parameters visible and editable in the instruction block rather than embedded in an expression. SCP supports extrapolation beyond the defined range, so pairing it with clamping logic is good practice.
What is SCL in Allen-Bradley PLCs?
SCL (Scale) is the legacy scaling instruction for SLC 500 and MicroLogix processors in RSLogix 500. It takes a Rate parameter (slope × 10000) and an Offset parameter (EUMin as an integer) to compute the scaled output. SCL is functionally equivalent to SCP but uses an older parameter format still found in many installed systems.
Why use NORM_X and SCALE_X instead of a single instruction in Siemens?
Separating normalization (0.0–1.0) from scaling (engineering units) lets you reuse the normalized value. One NORM_X output can feed multiple SCALE_X blocks — for example, scaling the same raw count into PSI for control logic and bar for an HMI display — without re-reading the raw input or duplicating the raw-count arithmetic. It also aligns with how Siemens PID and closed-loop function blocks accept normalized inputs.
Summary
Analog input scaling converts a dimensionless raw ADC integer into an engineering unit value that reflects physical reality. The process follows four steps: identify the raw count range for your module and signal type, define the engineering unit range for your sensor, apply the linear scaling formula (or a built-in instruction), and add out-of-range detection to handle fault conditions safely.
Key points to retain:
- Raw counts are module-specific. Never assume a count range — always check the hardware manual.
- Cast to floating-point before dividing. Integer arithmetic truncates and produces calibration errors.
- Use named constants. Hard-coded magic numbers make re-ranging error-prone.
- The live zero at 4mA is diagnostic. A raw count below the 4mA threshold is a fault, not a valid zero reading.
- Built-in instructions (SCP, NORM_X/SCALE_X) are preferred over manual formulas for maintainability.
- Clamping is a deliberate choice, not a default safety net — decide whether to clamp, alarm, or both for each channel.
For the broader context of where analog inputs fit in a complete control system — including sensor types, signal conditioning, and I/O module selection — the types of industrial sensors guide and the structured text programming guide are natural next reads.


