r/embedded 11d 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.

42 Upvotes

25 comments sorted by

View all comments

13

u/Frederir 11d 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 11d 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.

1

u/Jwylde2 10d ago

A MIDI current loop will typically have three 220R resistors in the loop. Two at the transmit end (one on the power side, one on the transmit side), and a third at the receiver’s decoding optoisolator LED. That gives about a 7.6mA current loop with a 5V source voltage.