0
\$\begingroup\$

I have a industrial sensor with 4-20mA output and I want to read that output from Stm32 ADC pin but I need suggestions to do that work in a nice way.

Can you guys suggest me the best way to do it? It is very important for me.

Thanks.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ What's the ADC input voltage range? \$\endgroup\$ – Transistor Mar 26 at 18:05
  • 2
    \$\begingroup\$ Best according to whom - this will trigger opinion-based answers. And you have not told any requirements or specs about accuracy or precision. Best will also mean the most expensive, will an adequate solution that simply fits your specs be enough? Would a 150 ohm resistor work for your purposes? \$\endgroup\$ – Justme Mar 26 at 18:18
  • 1
    \$\begingroup\$ Do you mind at all if the STM32 is destroyed every time the sensor goes overrange? \$\endgroup\$ – Spehro Pefhany Mar 26 at 18:33
  • \$\begingroup\$ I got Stm32 which has 3.3V level pins. Actually, I said best because I need a system that can last long time without any damage for Stm32. So, 150 ohm resistor can not be sufficent for me. Also, I have sensor which has 12-24v range. \$\endgroup\$ – vision34 Mar 26 at 19:06
  • \$\begingroup\$ I have a industrial sensor with 4-20mA and I have sensor which has 12-24v range? Please post the schematic or datasheet of this sensor. \$\endgroup\$ – vangelo Mar 26 at 19:11
2
\$\begingroup\$

You'll need a linear current to voltage converter.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Full schematic of a linear current to voltage converter.

If the ADC is 0 to 5 V then set R1 to 250 Ω. Your 4 - 20 mA will give an input of 1 to 5 V so you'll lose 20% of your useful range but this is a small price for the simplicity.

0.1% resistors and even 0.01% are available in a few key values for standard conversion voltages but may be a bit pricey for you.


From the comments:

I said best because I need a system that can last long time without any damage for Stm32. So, 150 ohm resistor can not be sufficent for me.

That should have been a specification in the question. (It still is not there.)

A resistor solution can last forever if the system is not abused. Again, this is a missing specification requirement and you need to specify in your question what abuse and fault conditions you need to protect against.

Also, I have sensor which has 12-24v range.

No, you said you have a 4 - 20 mA sensor. It most likely can be powered by a 12 to 24 V (capital 'V') power supply. The maximum output voltage will be determined by the output current and the shunt resistor, R1 in this case.


Link to ad page supplied in comments:

enter image description here

Figure 2. The 2-wire transmitter.

You have selected a 2-wire transmitter. The circuit of Figure 1 is perfectly suited for this. As a precaution you can test the worst case current from the transmitter by replacing "Instruments" with your multimeter in mA mode. Then pressurise the switch to the maximum pressure it will ever see in service and read the current. If it goes a bit over 20 mA then reduce the value of R1 accordingly.

Note that you have chosen a device with no datasheet and that the illustration says "current dutput". That may be an indication of product quality. "No datasheet? No sale!" is a good motto.

\$\endgroup\$
7
  • \$\begingroup\$ About right, but an STM32 would not accept 5V on ADC pins due to it being a nominally 3.3V MCU. But unfortunately, we don't know the exact MCU type is, nor the supply voltage, or even ADC reference voltage at this point. \$\endgroup\$ – Justme Mar 26 at 18:35
  • \$\begingroup\$ I got Stm32 which has 3.3V level pins. Actually, I said best because I need a system that can last long time without any damage for Stm32. So, 150 ohm resistor can not be sufficent for me. Also, I have sensor which has 12-24v range. \$\endgroup\$ – vision34 Mar 26 at 19:09
  • \$\begingroup\$ "Best" is not an engineering specification. See the update. \$\endgroup\$ – Transistor Mar 26 at 19:28
  • \$\begingroup\$ Sorry, I was not able to express the problem in a good way. I will use the sensor which is like the link below. \$\endgroup\$ – vision34 Mar 26 at 19:54
  • \$\begingroup\$ shorturl.at/axELO \$\endgroup\$ – vision34 Mar 26 at 19:59
0
\$\begingroup\$

I do not know how your sensor output is, you do not give many information, but I would suggest you either a high or low side current sensing Op-amp. High side (more complex, but essential if you cannot place the Resistor for sensing (Shunt resistor) to the GND side: High side Op-amp current sensing.

Low side op-amp current sensing is easier and pimplier, look it up, also needs a shunt resistor.

\$\endgroup\$
0

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.