Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

4-20mA to 0-3V3

bojangleelec

Newbie
Newbie level 4
Joined
Jun 4, 2024
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
39
Just started my analog circuits journey today.

I want to convert 4-20mA to 0-3.3V (current source is from a 24v powered transducer).

I've been trying to understand transimpedance amplifiers and ran an LTSpice simulation from a circuit I found here

Attached are the results from the simulation. I've tried playing around with the resistor values to get a better understanding of how the circuit operates but I'm having trouble wrapping my head around it.

I know for my sake that I would want 4-20mA to sit somewhere in between 0-3.3V in order to be able to detect a broken sensor wire. When I adjust the resistor values to expand the range, the signal isn't linear over the sweep.

I know that I could achieve linearity using a simple voltage divider, what is the purpose of a transimpedance amplifier if you can just do this? Less noise / greater resolution?

Looking to better understand I-V conversions so I can have a better understanding of what is best for my application

Thanks

4-20to0-3.png
 
Required voltage span for specified current span of (20mA - 4mA = 16mA) = 3.3V - 0V = 3.3V.

Voltage-to-current ratio = 3.3V/16mA = 206.25V/A.

Required voltage offset for the 4mA live zero = 206.25V/A * 4mA = 0.825V.

Required voltage range for the 0mA to 20mA (i.e. 4mA live zero + 16mA span) = 0.825V + 3.3V = 4.125V.

Required resistor value for the conversion = voltage-to-current ratio.

Since 206.25 ohm is not a standard resistor value, then a standard resistor value can be selected (e.g. 100 ohm, 120 ohm, 150 ohm, etc, but lesser than 206.25 ohm) and the voltage drop across it can be scaled to 3.3V with a gain as follows:

16mA * Resistor_value * Gain = 3.3V;
Therefore, Gain = 3.3V/(16mA * Resistor_value). This is same as using 20mA * Resistor_value * Gain = 4.125V; so that Gain = 4.125V/(20mA * Resistor_value).
 
I know that I could achieve linearity using a simple voltage divider, what is the purpose of a transimpedance amplifier if you can just do this?
A transimpedance amp can linearly convert the current from a low impedance source (not stiff) to a voltage (e.g. a photo diode).
For a high impedance (stiff) current-source, you can just use a resistor.
 
In the good old days, the 0-20mA went straight through an opto-coupler diode and the output was pulled to ground through a pull-up resistor (or pulled to supply through a pull-down resistor) and there wasn't an amplifier in sight!

Brian.
 
I've been trying to understand transimpedance amplifiers and ran an LTSpice simulation from a circuit I found here
THIS is NO transimpedance amplifier at all.
(Nowhere here in this thread nor in the other thread)

It´s just a low ohmic burden .. followed by a basic noninverting amplifier.

Klaus
 
A transimpedance amp can linearly convert the current from a low impedance source (not stiff) to a voltage (e.g. a photo diode).
For a high impedance (stiff) current-source, you can just use a resistor.
Since the purpose of the I-V conversion is to be used by an ADC (0-3.3v), I thought using an op-amp would make the most sense for protection since the output would saturate at 3.3v.

Is this correct or is there an easier way to do this?
 
Hi,

Is this correct or is there an easier way to do this?
There is an ADC involved?
Then the most easy way is to convert 0..24mA to let´s say 0...95% of the ADC input range... with a single 130 Ohms resistor.
Then simply subtract the equivalent of "4mA" in software. No drift. Least erros. Done.

In software it´s rather simple to adjust gain and offset.

Klaus
 
Hi,


There is an ADC involved?
Then the most easy way is to convert 0..24mA to let´s say 0...95% of the ADC input range... with a single 130 Ohms resistor.
Then simply subtract the equivalent of "4mA" in software. No drift. Least erros. Done.

In software it´s rather simple to adjust gain and offset.

Klaus
My worry with using just a resistor was that if the transducer were to output, for example, 40ma (someone plugs the wrong transducer in to the PCB) it would destroy the MCU.

I would also hope to protect against transient spikes, however, I'm not sure what I would need to add to this circuit to prevent that.
 
Your circuit works fine for I to V using a low side sense R with voltage supplied by 3.30V with the non-inverting for input Av+ = 1+ |Av-| is pretty simple.

The other link was for a high-side current sense resistor using the inverting input for gain.
 
Hi,

My worry with using just a resistor was that if the transducer were to output, for example, 40ma (someone plugs the wrong transducer in to the PCB) it would destroy the MCU.

I would also hope to protect against transient spikes, however, I'm not sure what I would need to add to this circuit to prevent that.
Why not writing this in the first post? And: an OPAMP is no "protection device" at all.
Spikes on the input of an transimpedance circuit may kill the OPAMP.
*****

If you expect noise and overcurrent:
I´d still use the 130 Ohms burden, then followed by a 10k/100nF LPF and a dual diode overvoltage protection.
(the 10k/100nF on the one side suppresses noise (could be adjusted to your sampling rate) and also limits the current)

This is all passive, cheap, precise, rugged.
Still it can´t protect against every abuse, like connecting it to 230V AC mains.

Klaus
 
Why do you think that a 20mA transducer would output 40mA?Standard transducers have current limiting. @KLAUS has mentioned 0-24mA as the range for the 0-3.3V reference, which is what it should be and I didn't mention it in my previous contribution because you didn't mention that the 3.3V was your reference voltage. With 0-24mA you can also implement NAMUR alarms and limits.

For circuit protection, you would have to provide some schematic of what you have. Circuit protection would have to come after functionality. So consider designing the circuit to be functional first before adding protection.
 
Why do you think that a 20mA transducer would output 40mA?Standard transducers have current limiting. @KLAUS has mentioned 0-24mA as the range for the 0-3.3V reference, which is what it should be and I didn't mention it in my previous contribution because you didn't mention that the 3.3V was your reference voltage. With 0-24mA you can also implement NAMUR alarms and limits.

For circuit protection, you would have to provide some schematic of what you have. Circuit protection would have to come after functionality. So consider designing the circuit to be functional first before adding protection.
First of thank you to all you have replied, I am learning alot as I go.

1) I figured out how the circuit functions and ended up choosing these values (see attached) so that I can detect a broken sensor wire or overflow.

The current transducer has an update rate of "<25ms" so I'm assuming the signal frequency is somewhere between 40-50hz.

I'm planning to connect vo to an STM32 ADC (SAR type I believe?). Does the voltage need to be buffered in this case?

What action can I take to prevent EMI in this circuit? (I know I probably need some filtering caps, but where and why?)

Edit: Maybe a low pass filter on the input?

Thanks!


4-20-upd.png
 
Last edited:
First of thank you to all you have replied, I am learning alot as I go.

1) I figured out how the circuit functions and ended up choosing these values (see attached) so that I can detect a broken sensor wire or overflow.

The current transducer has an update rate of "<25ms" so I'm assuming the signal frequency is somewhere between 40-50hz.

I'm planning to connect vo to an STM32 ADC (SAR type I believe?). Does the voltage need to be buffered in this case?

What action can I take to prevent EMI in this circuit? (I know I probably need some filtering caps, but where and why?)

Edit: Maybe a low pass filter on the input?

Thanks!
the update rate is the rate at which the output is, you know, updated, it has nothing to do with the signal frequency. The signal is a DC current.
 
Hi,

update rate of "<25ms" so I'm assuming the signal frequency is somewhere between 40-50hz.
if the update rate is 25ms, then this equals to 40Hz. According Nyquist the maximal detectable signal frequency is LOWER than half of the sampling frequency.
--> less than 40Hz/2 = less than 20Hz

Example: 20Hz is impossible. So let´s use 19Hz.
If you want to precisely detect 19 Hz then it takes 1 second, or 40 samples.
18Hz --> 20 samples = 500ms
19.5Hz --> 80 samples = 2 seconds

Does the voltage need to be buffered in this case?
I´m not sure about the STM32 input conditions. If I had to design it, I needed to look up the datasheet.
If you have to design it .. you have to ...
Additionally it´s a question of YOUR application. What requirements are there according precision, linearity, accuracy, noise, signal frequency range. ... and so on. We can not know this.

What action can I take to prevent EMI in this circuit? (I know I probably need some filtering caps, but where and why?)
It´s unlikely that your sensor signal contains high frequency (you should know). So regarding EMI you just need to care that eventually used amplifiers don´t oscillate.
In most circuits the analog path is not likely to send out high frequency signals.
It´s more a problem of a digital circuit. We don´t have any informations about your digital circuit. (just STM32...., but there are so many different ones).
My first recommendation: Use one layer of your PCB as solid GND layer. Really solid, no other signals.

Maybe you meant EMC:
Careful PCB design. We already talked about an ESD filter at the signal input. It´s also a good idea to use an RC at the ADC input.

Filtering.
You said sampling rate is 40Hz.
And maybe you have an mains frequency of 50Hz.
So it´s likely that your measurement signal gets contaminated by this 50Hz.
Since this 50Hz is higher than f_sample/2 it results in an alias frequency of 10Hz.
But maybe 10Hz is also in your "frequency range of interest" .. then you must not suppress it on the digital side.
A dilemma. Once you get this alias frequency ... you can´t get rid of it.

Solution: You need to suppress the 50Hz signal on the analog side.
Suppress it, in a way that the amplitude gets lower than YOUR "specified applications precision requirement".
Now it depends where you defined your "frequency range of interest".
The fillter needs to pass your signal frequency ... with low attenuation , but it needs to suppress mains frequency with high attenuation.
Again an almost impossible task for an analog filter, because both frequencies are close together.

Every one has these problems: How I usually solve it:
-- > I use a much higher sampling frequency, let´s say 1kSmpl/s
(thus f_sample/2 is much higher), thus the antiAliasingFilter is way more relaxed. A simple Rc will do.
Still you have the 50Hz problem. It´s in the analog filter´s pass band, but since it´s lower than f_Sample/2 it does not get aliased.
It´s still 50Hz at the digital side.
But now you can use digital filters. In this case you may simply average each 20 samples (1kSmpl/s / 20 = 50 Smpl/s)
With this you get rid of mains frequency while getting higher resolution digital values.

If I´m not mistaken you can configure (via STM CUBE) the STM32 ADC to perform the sampling in background by pushing the conversion results into a DMA buffer ... and generate an interrupt every 20 samples. Until here no processing power is involved.
In the ISR just do the averaging, which should be done within less than 5us. So all in all this costs 5us/20ms = 0.025% processing power (sampling, filtering, and ISR overhead).

Klaus
--- Updated ---

The signal is a DC current.
Is it? How do you know?
 
Hi,


if the update rate is 25ms, then this equals to 40Hz. According Nyquist the maximal detectable signal frequency is LOWER than half of the sampling frequency.
--> less than 40Hz/2 = less than 20Hz

Example: 20Hz is impossible. So let´s use 19Hz.
If you want to precisely detect 19 Hz then it takes 1 second, or 40 samples.
18Hz --> 20 samples = 500ms
19.5Hz --> 80 samples = 2 seconds


I´m not sure about the STM32 input conditions. If I had to design it, I needed to look up the datasheet.
If you have to design it .. you have to ...
Additionally it´s a question of YOUR application. What requirements are there according precision, linearity, accuracy, noise, signal frequency range. ... and so on. We can not know this.


It´s unlikely that your sensor signal contains high frequency (you should know). So regarding EMI you just need to care that eventually used amplifiers don´t oscillate.
In most circuits the analog path is not likely to send out high frequency signals.
It´s more a problem of a digital circuit. We don´t have any informations about your digital circuit. (just STM32...., but there are so many different ones).
My first recommendation: Use one layer of your PCB as solid GND layer. Really solid, no other signals.

Maybe you meant EMC:
Careful PCB design. We already talked about an ESD filter at the signal input. It´s also a good idea to use an RC at the ADC input.

Filtering.
You said sampling rate is 40Hz.
And maybe you have an mains frequency of 50Hz.
So it´s likely that your measurement signal gets contaminated by this 50Hz.
Since this 50Hz is higher than f_sample/2 it results in an alias frequency of 10Hz.
But maybe 10Hz is also in your "frequency range of interest" .. then you must not suppress it on the digital side.
A dilemma. Once you get this alias frequency ... you can´t get rid of it.

Solution: You need to suppress the 50Hz signal on the analog side.
Suppress it, in a way that the amplitude gets lower than YOUR "specified applications precision requirement".
Now it depends where you defined your "frequency range of interest".
The fillter needs to pass your signal frequency ... with low attenuation , but it needs to suppress mains frequency with high attenuation.
Again an almost impossible task for an analog filter, because both frequencies are close together.

Every one has these problems: How I usually solve it:
-- > I use a much higher sampling frequency, let´s say 1kSmpl/s
(thus f_sample/2 is much higher), thus the antiAliasingFilter is way more relaxed. A simple Rc will do.
Still you have the 50Hz problem. It´s in the analog filter´s pass band, but since it´s lower than f_Sample/2 it does not get aliased.
It´s still 50Hz at the digital side.
But now you can use digital filters. In this case you may simply average each 20 samples (1kSmpl/s / 20 = 50 Smpl/s)
With this you get rid of mains frequency while getting higher resolution digital values.

If I´m not mistaken you can configure (via STM CUBE) the STM32 ADC to perform the sampling in background by pushing the conversion results into a DMA buffer ... and generate an interrupt every 20 samples. Until here no processing power is involved.
In the ISR just do the averaging, which should be done within less than 5us. So all in all this costs 5us/20ms = 0.025% processing power (sampling, filtering, and ISR overhead).

Klaus
--- Updated ---


Is it? How do you know?
Because that’s standard sensor operation. The device has an internal ADC, and perhaps a microprocessor, which in this case apparently sample at 25mS. There could be some averaging which yields the 25mS rate, but OP has not shared the specific device, so, who knows? Once a new value is acquired, the DC current output is updated. I’ve yet to see a 4-20mA AC current loop.
 
Hi,
I’ve yet to see a 4-20mA AC current loop.
Just because a 4..20 mA loop has a DC offset (never going negative) does not mean it has 0Hz bandwidth.

For example there are acceleration sensors that transmit signal frequencies of several kHz over the 4..20mA current loop.
It does not matter if the sensor output is analog controlled, or sequentially updated by a DAC ...

And for sure you need to fulfil Nyquist if you want to read in the acceleration curve. Means you need to sample with more than twice the signal_frequency_of_interest.

For Nyquist not the lowest frequency of interest (DC) counts, but the highest frequency.

Klaus
 
Hi,

Just because a 4..20 mA loop has a DC offset (never going negative) does not mean it has 0Hz bandwidth.

For example there are acceleration sensors that transmit signal frequencies of several kHz over the 4..20mA current loop.
It does not matter if the sensor output is analog controlled, or sequentially updated by a DAC ...

And for sure you need to fulfil Nyquist if you want to read in the acceleration curve. Means you need to sample with more than twice the signal_frequency_of_interest.

For Nyquist not the lowest frequency of interest (DC) counts, but the highest frequency.

Klaus
I stand corrected. My experience has been with very slow transducers (pressure, flow, etc.) And it was early in the morning.
 
Please give more detail about your circuit. What you have presented is not sufficient to determine the necessary protection.

--What system is it?
--How is the transducer intended to be connected to the controller?
--What environment is it intended to be used?
--etc
 
Please give more detail about your circuit. What you have presented is not sufficient to determine the necessary protection.

--What system is it?
--How is the transducer intended to be connected to the controller?
--What environment is it intended to be used?
--etc

The system is an industrial PCB. It's enclosure will be mounted via DIN rail.

The PCB is powered via 24VDC and may exist near (but not connected to) 480V 3-phase servo drives (near meaning inside the same panel).

System Architecture: Transducer -> PCB -> STM32f765bg (Processes transducer data) -> +24V Digital Output or Ethernet for Status Information

The transducer is excited via +24VDC and outputs a 4-20mA signal. The transducer is plugged directly into the PCB (clamping terminal connectors)

The goal is to design an amplifier circuit that will not be affected by any of the nearby A/C, will not fry the MCU, and will not be affected by 100mbit/s ethernet on the same PCB.
 
The system is an industrial PCB. It's enclosure will be mounted via DIN rail.

The PCB is powered via 24VDC and may exist near (but not connected to) 480V 3-phase servo drives (near meaning inside the same panel).

System Architecture: Transducer -> PCB -> STM32f765bg (Processes transducer data) -> +24V Digital Output or Ethernet for Status Information

The transducer is excited via +24VDC and outputs a 4-20mA signal. The transducer is plugged directly into the PCB (clamping terminal connectors)

The goal is to design an amplifier circuit that will not be affected by any of the nearby A/C, will not fry the MCU, and will not be affected by 100mbit/s ethernet on the same PCB.
Take a look at instrumentation amplifiers.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top