Analog scaling: turning 4-20 mA into something you can read
The arithmetic is two lines. The part that catches people is what the raw counts actually are on your controller, and what happens below 4 mA.
Short answer
Scaling is a straight-line map: subtract the raw minimum, multiply by the engineering span, divide by the raw span, then add the engineering minimum. The part that goes wrong is the raw range, which differs by platform: 4 mA is 3277 counts on a 1769-IF4 and 5530 on a Siemens analog input, not zero.
A pressure transmitter sends 4 mA at zero bar and 20 mA at ten bar. Your analog card turns that current into an integer. Your program needs bar. That conversion is the most common piece of arithmetic in industrial automation, and it goes wrong in the same three ways every time.
The arithmetic
It is a straight-line map from one range to another:
scaled = (raw - raw_min) * (eng_max - eng_min) / (raw_max - raw_min) + eng_min
That is all. Everything difficult is in the four numbers you feed it.
Know your raw range
This is where most of the errors live, because it is different on every platform and nobody tells you.
- Allen-Bradley 1769-IF4 in 4-20 mA mode: 4 mA is 3277, 20 mA is 16384.
- Siemens S7 analog input: 4 mA is 5530, 20 mA is 27648.
- Many third-party cards: 0 to 4095 for a 12-bit converter, with 4 mA landing at 819.
Using 0 as your raw_min on a 4-20 mA loop is the classic mistake. It puts zero bar at 0 mA, which the transmitter never sends, so every reading is offset by a fifth of full scale and the error is largest at the bottom of the range, where you are least likely to notice it and most likely to care.
Use the platform's instruction where there is one
Rockwell has SCP, Scale with Parameters. Siemens has NORM_X followed by SCALE_X. Both do exactly the arithmetic above, and both are better than writing it yourself because the intermediate maths happens in a wide enough type.
If you do write it by hand, do the multiply before the divide. (raw - 3277) / 13107 * 10 in integer maths gives you zero for almost every input.
Decide what a broken wire means
A 4-20 mA loop has one genuinely useful property: zero is not a valid reading. A healthy transmitter at the bottom of its range still sends 4 mA, so a reading below about 3.5 mA means the loop is broken, not that the pressure is low.
That distinction is worth an explicit branch. A scaled value that quietly reports -2.5 bar because the wire fell off is worse than an alarm, because somebody will believe it.
Underrange should raise a fault. It should not clamp silently to zero, and it should certainly not be fed to a PID loop that will then open a valve.
Common questions
- What raw value does 4 mA give on an Allen-Bradley analog card?
- On a 1769-IF4 in 4-20 mA mode, 4 mA reads 3277 counts and 20 mA reads 16384. Using zero as the raw minimum is the classic error: it places zero engineering units at 0 mA, which the transmitter never sends, so every reading is offset.
- What should happen when a 4-20mA loop breaks?
- It should raise a fault. A healthy transmitter at the bottom of its range still sends 4 mA, so a reading below about 3.5 mA means the loop is broken rather than the process being low. Clamping silently to zero produces a plausible reading that somebody will believe.
Keep reading
- Safety
SIL or PL: which one does your machine need?
Two standards, two scales, and one machine. Which one applies, how they map to each other, and why the answer is usually ISO 13849.
- Safety
Categories B, 1, 2, 3 and 4, in plain terms
Five architectures, what a single fault does to each, and the practical wiring that goes with them.
- Safety
Safety relay or safety PLC: how to decide
One is a wiring decision, the other is a programming one. The count of safety functions, not the size of the machine, is what settles it.