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.
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.
You'll need a linear current to voltage converter.
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:
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.
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.