3
\$\begingroup\$

Question from a SW Engineer again.

I've got a device which is mains powered and outputs a 4-20mA current depending on the flow rate in a pipe. I'd like to measure that flow rate with a microcontroller.

On the face of it it's easy. My microcontroller is 3v3 so max current should produce max voltage of 3v3. So R = 3v3/20mA = 165 Ohm. If I pass the current through 165R and measure the voltage across the resistor it's all good.

My problem is I'm unsure if I can actually do that. The uC will measure a voltage relative to it's ground connection so I have to connect the uC Gnd to the negative side of the 165 ohm Resistor. Is that safe?

I was then looking at current mirror circuits but they all share a Gnd plane between the two sides of the mirror so it's no better then the simple 165R.

Is there a "correct" way to isolate this sensor or is it a case of just connecting the ground. My uC will be powered by a Mains - 12v DC power converter so maybe ground will be the same on both sides?

\$\endgroup\$
3
\$\begingroup\$

Yes, just connect the negative end of the resistor to the microcontroller analog ground. This is one advantage of a current signal. Since the microcontroller supply and the flow meter supply are isolated from each other, you get to pick one point on each where you can connect them together.

While your calculation of 165 Ω is correct, I would use just a little less to be able to sense some overrange. 150 Ω might be a good value.

\$\endgroup\$
6
\$\begingroup\$

I've forgotten where I found this, likely as part of an isolated switchmode power supply, but with a little cleverness, you can make a linear current sensor with optoisolators. Here's the basic idea:

schematic

simulate this circuit – Schematic created using CircuitLab

R1=R2. The current through R3 will be the same as the original current being measured. The advantage of this circuit over a single isolator and R1 is to cancel the non-linearity that optoisolators are famous for.

The optoisolators should be identical so that their non-linearities match. If you're not dealing with particularly high voltages, this is best done with a dual or more package. Otherwise, two singles from the same batch should be used instead to allow the isolated circuits to remain separated by the required minimum distance.

\$\endgroup\$
  • \$\begingroup\$ It would be tough to maintain proper creepage distance between the two halves of an optoisolated circuit while using a dual optoisolator like this. \$\endgroup\$ – Nick Johnson Apr 24 '15 at 3:51
  • 1
    \$\begingroup\$ @NickJohnson: For a power supply, that would be a good reason to use two singles from the same batch, but the OP's situation is probably okay. I'll edit my answer to mention that. \$\endgroup\$ – AaronD Apr 24 '15 at 4:30
4
\$\begingroup\$

4-20mA loops can be troublesome if you don't know exactly how they are fed. Your best bet would be to use a complete isolator, and while you are at it, get an isolator that can also convert the 4-20mA to a 0-3VDC signal. Most common isolators have outputs of 0-10VDC, or 0-5VDC, but are widely adjustable.

That being said, if you KNOW that the sensing resistor is going between the devices output and the negative supply for the device, and that there are no wildly high voltages present (AC or DC) between the common of the transmitter and your uC, then you can directly connect them, common to common and high side of the sense resistor to your input.

Caveat on either approach... Some instruments will generate either a 0mA or up to 30mA signal in the event of an instrument fault; so I wouldn't try to make 20mA represent exactly your maximum voltage to your uC unless you clamp the input to protect it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.