4-20ma to 0-3.3V conversion using Rail to rail Opamp

Thread Starter

Saina Biswas

Joined Jun 5, 2023
11
I am trying to convert 4-20 mA current loop signal to 0-3.3/0-3 V output for my 10 bit ADC IC that is connected to a Raspberry pi 3B+.

Schematic:

4-20ma to 0-3.3v

The input sensor is a 12 V loop powered 4-20 mA output humidity sensor. The op-amp is an MCP6002 rail-to-rail. The output of the op-amp is connected to a 10 bit ADC-MCP3008 (SPI enabled connected to RPi.)

The output voltage only varies from 0.6 to 2 V and I don't know where exactly the voltage drops.

The circuit works fine if I read the voltage using only a 150 Ω resistor (0-3 V.)

I can't understand what's wrong in this circuit.

Prior answers related to this question didn't give the solution. Please help me to find a reliable solution.
 

Ian0

Joined Aug 7, 2020
9,816
Connect the A/D to the 150Ω resistor, and subtract the 4mA offset (which is now 0.6V) using software.
 

Irving

Joined Jan 30, 2016
3,886
I tried the MCP6002 lib file but it didn't work, complained about too small a time step at U1:21

But any R2R I/O 1.8 - 6v opamp should work.
 

Thread Starter

Saina Biswas

Joined Jun 5, 2023
11
I tried the MCP6002 lib file but it didn't work, complained about too small a time step at U1:21

But any R2R I/O 1.8 - 6v opamp should work.
But a simple voltage follower circuit will not give 0V out at 4mA. It will deliver 0V at 0mA. For the full span, you will get your 3.3VDC out.
 

Thread Starter

Saina Biswas

Joined Jun 5, 2023
11
A 150Ω source impedance is plenty low enough to drive an A/D input on its own. I‘d suggest a series resistor and perhaps some Schottky diodes to 3.3V and 0V for input protection, but I see no need for the op-amp. All it can do is add some offset voltage.
Driving the ADc is my 2d concern, My first concern is that I can't even get a 0-3v linear out put when the input current varies.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
552
By way of further clarification, 4 - 20mA is a technique which has been around for many years and is a brilliant way to take sensor inputs over quite long distances. If the current drops below 4mA that's a way of knowing the circuit has broken.

If the curent is made to pass through a 165 ohm resistor then the voltage across it at 20mA will be 3.3V and the voltage across it a 4mA will be 0.66V. With a 150 ohm resistor which is a standard value 4 to 20mA becomes 0.6V to 3.0V which, although you are losing some more resolution it's less than 1 bit and you can more than win that back with a 12 bit ADC. But adding extra components will simply increase non-linearity - even rail to rail op amps run out of linearity close to the rails.

Have you checked the linearity of your ADC converter? That probably gives a greater error than the small loss of resolution using a 150 ohm resistor
 

Irving

Joined Jan 30, 2016
3,886
But a simple voltage follower circuit will not give 0V out at 4mA. It will deliver 0V at 0mA. For the full span, you will get your 3.3VDC out.
True, but as already said, if you want linearity you need to avoid 0v. Without a -ve rail, a R2R opamp is only an approximation of 0v at the lower end. Look at the spec:

1685984831209.png

Its only within 25mV when the input is driven 0.5v over, ie -0.5v and +3.8V on a 3.3v supply. Much better to accept the 600mV offset and remove it in software. Anyway, your opamp gain is 1+2k/(13.3k||20k) = 1.25

It would be much better to read the voltage over the 150ohm resistor direct into the ADC as said above, calibrate by getting the reading for 4mA into a variable 'offset' which you hold in NVRAM then applying the formula (ADCReading - offset)*1.25. Your result will be as linear as your ADC, will have no artefacts due to opamp R2R or gain linearity issues, will remove any inaccuracies due to resistor tolerances, temperature variation or noise, and save 4 components as well...
 

Ian0

Joined Aug 7, 2020
9,816
A further bonus is that you can actually detect an error in the 4-20mA current source. If the current drops to zero, you will know. If you preprocess the signal to remove the offset, you will not be able to tell if the current is 4mA or it is zero.
 

Thread Starter

Saina Biswas

Joined Jun 5, 2023
11
True, but as already said, if you want linearity you need to avoid 0v. Without a -ve rail, a R2R opamp is only an approximation of 0v at the lower end. Look at the spec:

View attachment 295791

Its only within 25mV when the input is driven 0.5v over, ie -0.5v and +3.8V on a 3.3v supply. Much better to accept the 600mV offset and remove it in software. Anyway, your opamp gain is 1+2k/(13.3k||20k) = 1.25

It would be much better to read the voltage over the 150ohm resistor direct into the ADC as said above, calibrate by getting the reading for 4mA into a variable 'offset' which you hold in NVRAM then applying the formula (ADCReading - offset)*1.25. Your result will be as linear as your ADC, will have no artefacts due to opamp R2R or gain linearity issues, will remove any inaccuracies due to resistor tolerances, temperature variation or noise, and save 4 components as well...
please add a rough schematic with adc input surge protection.
Thank you
 

Irving

Joined Jan 30, 2016
3,886
Something like:

1686052830931.png

This assumes your current source is actually grounded as you previously drew, if not then we need to revise. R1 is your burden resistor to convert current to voltage as discussed above. R2 is to limit current in the event of surge. Ideally it should be as large as possible, dependent on the requirements of your ADC which will tell you what the recommended maximum input resistor v conversion time is. D1 & D2 are TVS diodes or a purpose-made 2-diode ESD protection package, eg Nexperia PESD5V0X1BT,215 or similar
 
Top