Hello everyone,
I am doing one arduino base project in which I have to read 4-20 mA signal from two different potentiometers which is power from 24 vdc supply, compare them and send a signal to 2 channels relay board. If first signal from potentiometer is greater by 0.16 mA or more than second then 1st realy will energize if second signal from potentiometer is greater than first signal by 0.16 mA or more then second relay will energize.
Now I am facing issue to read 4-20 mA on arduino without any external module. I don't know issue is in coding or circuit. Can you help me
when i am selecting 1200 ohm resistance in variable resister then i am getting 16.48 mA on display but i should get 20 mA and when i am selecting 6000 ohm resistance in variable resister then i am getting 3.83 mA on display but i should get 4 mA. please check up my below code and attached circuit diagram and correct me, where i wrong
Thank you so much for your correct suggestion. i am beginner in electronics, can you suggest me what i have to change in our circuit and code to read 4-20 mA.
I hope you are not expecting the 4-20ma circuit to be exactly 4 or 20ma! Those are the maximums and you will need to calibrate your circuit to match whatever is controlling the 4-20ma signal.
Paul
This is the formula that you is used to determine the voltage over the shunt resistor; use it if the power supply and the pot are the real source (and not a simulation of a real source 4-20mA source).
Vshunt = 24 * Rshunt / (Rpot + Rshunt)
You can shuffle it around to calculate Rpot based on Vshunt and from there calculate the current.
I think that part of the problem is that a voltage source with a resistor in series is not a current source. The amount of current that flows will depend on the load on the line.
To read a 4 to 20 mA input you need a resistor that has a voltage drop of 5V at 20 mA. I think that's a 250 Ohm resistor.
That would read 5V at 20ma and 1V at 4mA. Unfortunately, 250 Ohms is higher that 0 Ohms so using a 24V supply and 1200 to 6000 Ohms of series resistance will give you 4.13V to 0.96V since your "20 mA" won't be 20 mA and your "4 mA" won't be 4 mA.
You have a very good chance of killing your Arduino by putting more than 5.5V on A0, put a 910Ω resistor between 24V+ and the pot. 910Ω + 250Ω = 1160Ω, 24V / 1160Ω = 20.7mA, voltage across 250Ω resistor will be 5.17V.