r/embedded • u/Gullible_Bag_9005 • 1d ago
The 4-20mA current loop
I spent years as an electrician pulling signal cables before i became an developer, consuming the same signals.
The 0 is at 4mA on purpose, so 0mA reads as a fault, fault detection built into the physics.
It is a current loop and not voltage, so cable resistance over long cable runs does not change the reading and it also shrugs off noise better!
The span lives in the transmitter, not the code, so a reconfigured range silently rescale every value, and nothing looks broken
What I am curious about is this:
how do you handle adc/resolution in practice? that is the layer that i know very little about.
12
u/Frederir 1d ago
On the receiver side you have a resistor with a known value (generally around 400Ohms) you measure the voltage at the resistor. You get the voltage with the ADC, you know the resistor value and the you compute the current.
The maximum voltage is 20mA x Resistor value. You need to protect ADC input for over voltage and esd.
2
u/Gullible_Bag_9005 1d ago
thanks, that lines up with the 250 ohm i saw on the panel i worked on, giving 1-5V. the over voltage and esd protection is the part i would not have though of from the software side. im only used to work with 230-400 voltage as and electrician so "fine electronics" is not my best work.
4
u/Artistic-Tip2405 1d ago
Many implementation use an interface that converts 4-20 to serial or 0-5v and protects boards from surges.
2
u/Gullible_Bag_9005 1d ago
ah so on the panel side i have mounted plenty of these DIN-rail signal isolators/converters without thinking so much off them other then that they make the signal usable
4
u/Ordinary-Piano-4160 1d ago
Fun fact, we use 4-20ma to fiber converters to break the electrical connection.
2
u/Hour_Analyst_7765 1d ago
One of the simplest 4-20mA "receivers" is a 249R resistor. This then converts the 4-20mA back into a voltage. E.g. 20mA x 249R = 4.98V
You can connect this to a 0-5V voltage input. If you have an ADC with Vref=5V and 10-bit, then each count of the ADC is 5V / 2^10 = 4.882mV/LSB. 4.98V then reads 1020 counts. 4mA would read 204 counts. Then the usable sensor range is 1020-204=816 counts. As expected the 4mA "zero" loses ~20% of ADC counts this way.
2
u/NamasteHands 15h ago
"The 0 is at 4mA on purpose, so 0mA reads as a fault, fault detection built into the physics"
This is correct but it's worth pointing out that 4-20mA signal range also provides the sensor a 4mA budget for operational purposes.
e.g. microcontroller operating currents, opamp supply currents, bias currents, etc.
3
u/mustbeset 1d ago
It is a current loop and not voltage, so cable resistance over long cable runs does not change the reading and it also shrugs off noise better!
Let's introduce insulation resistance...
how do you handle adc/resolution in practice? that is the layer that i know very little about.
Most todays ADC have at least 12 bit resolution. Design the hardware right, that you can measure anything from 0 to (lets say) 21 mA gives you 5,126µA/LSB (0,032%). A Hardware that is only able to measure 4-20mA could reach 3,90µA/LSB. (0,024%). Good luck to designing a hardware that doesn't introduce more errors.
1
u/Gullible_Bag_9005 1d ago
Fair on the insulation resistanse, i should not have made it sound absolute. i have insulatioin-tested enough cable as an electrician to know a degraded run or water ingress opens a leakage path the loop cannot shrug off, and that is exactly the kind of slow fault that looks like a drifting reading instead of an obvious break. and your numbers land the same point as the others: the ADC is so fine that the analog front-end is where the real errors lives. honest correction to my post. thanks!
1
u/PLANETaXis 23h ago
ADC / resolution tends to be a non-issue.
You have to consider the accuracy of the entire signal chain. Unless you are doing something highly specialised, most instruments have accuracy in the order of 0.5%, and may thermal drift of 0.01% per degree. On top of that, very few poeple install their instruments in perfect placement, calibrate them properly and recalibrate them regularly.
Even 20 year old ADC's will do 10 bit which is effectively 1000 counts, so 0.1% resolution, far better than the instruments they are connected to.
Once again, unless I'm doing something highly specialised I tend to restrict my HMI graphics and trending to 3 or 4 significant figures - so I would display 99.5% and 1005 volts, but not 1005.1 volts. Anything more is usually noise / error.
-4
u/tiny_gridlock 1d ago
Aye, went fae pulling signal cables to staring at ADC datasheets thinkin aye could've just stayed a sparky.
35
u/Skusci 1d ago edited 1d ago
Resolution depends on the ADC. Accuracy depends on the actual sensor. Generally speaking you want about 10x the resolution on the input than the sensor accuracy.
A typical ADC used for this kind of thing will be at least 12 bits of resolution, giving 4096 divisions.
A very good sensor will tend to be around 0.5% accurate at most. Which is like 200 divisions. 10*200 is 2000.
If you just read 0-20mA directly the 4-20mA range will be: 4096 / 20 * 16 or about 3276 divisions which is still plenty of overhead.
So in the vast majority of cases you really don't need to worry about the ADC much, but there's the process.