(you are viewing a thread; or go back to
list of threads)
Interfacing PIC Micro with 4-20mA (by Samukelo Shezi)
Hi Jonathan!
Please help my curiosity! What would be the best and appropriate way to interface a PIC micro's 0 to 5V, to the industrial standard, 4-20mA. Is it practical to put a 250 ohm resistor and get 1-5V to the leg?
Thanks, and highly appreciated!
Regards
Samukelo Shezi
(no subject) (by David R)
Hi,
This worked well for me
but you must put A resistor in series and diode to vcc to stop over voltage from geting to the analog input pin because if you short the 4-20 sensor it will send 24v up the pic.
Regards
David.
(no subject) (by Jonathan Westhues)
Like David said. You might consider using a Schottky diode (like a BAT54 or equivalent) instead of a normal silicon diode. Its lower forward voltage guarantees that the PIC's ESD protection diode won't conduct even a little bit.
The cathode of the Schottky goes to Vdd, and the anode goes to the ADC pin. A large-ish resistor (~5k) goes from the ADC pin to the top of the 250 ohm sense resistor. So when the voltage at the ADC pin tries to exceed Vdd + 0.3 V, the diode conducts and clamps the voltage, and the 5k resistor limits the current, and nothing blows up.
A few tens of nanofarads from the I/O pin wouldn't hurt either, decrease high frequency noise and maybe get things a bit more robust against ESD (static electricity).
(no subject) (by Samukelo Shezi)
Wow! Thank you very much, gents. I tell you the truth, this website is the best thing that ever happened to me! God bless!
(no subject) (by David R)
Thanks for helping, I had not used schottky in the past
but I will now.
Regards
David
unused I/O's (by Samukelo Shezi)
Cmos rules stipulate that the unused I/O have to be tied to either Vdd or Vcc. Does the same apply to these Micros (AVR, Pic Micro, 8051)?
(no subject) (by Jonathan Westhues)
It is good practice to tie unused I/O pins high or low, either in the circuit (by connecting them to Vdd or ground) or, better, by driving them as outputs in the program.
But if you don't, then nothing very bad happens. The biggest consequence is that the input stages might draw some class A current (where both the n- and p-FETs conduct, and current flows from Vdd to ground). That increases the total power consumed, but will not lead to damage.
A big silicon diode will have a lower forward voltage (at a given current) than the PIC's internal protection diode, so even with a non-Schottky diode, very little current flows into the PIC's protection diode. And a small amount of current into that protection diode is unlikely to cause real problems. You could omit the extra diode entirely (but keep the resistor), and everything would seem to work fine, although it's not good practice. But the Schottky turns on well before the PIC's protection diode will, so it's the nicest solution.
(no subject) (by Samukelo Shezi)
Thank you very much!
(no subject) (by Samukelo Shezi)
But LDmicro will automatically set them (unused I/Os) as outputs when compiling, I purpose?
(no subject) (by Jonathan Westhues)
Unused I/Os will be left as inputs, on the theory that it's better to accidentally have a floating input than an output shorted to a different logic level.
(no subject) (by Samukelo Shezi)
Sorry, I meant: "I SUPPOSE!"
(no subject) (by Samukelo Shezi)
Ok. Thank you very much, Jon.
Schematics (by Boris)
Can somebody make schematics for this
Thanks!
(no subject) (by Jonathan Westhues)
As attached. The capacitor can be omitted, but decreases noise (by acting as a low-pass filter in combination with the 4.7k resistor) and helps protect against ESD (by decreasing the voltage that a given amount of energy from an ESD event will develop) if it's present.
The diode should be small, like a BAT54; that can easily handle the worst-case fault current of (24 5 - 5 V)/4.7k ~ 4 mA if the sensor gets shorted, and its leakage current of a couple uA adds negligible error.
If the sensor gets shorted, then the 250-ohm resistor will dissipate (24 V)^2/(250 ohms) ~ 2.3 W; make sure it's rated for the power.
(no subject) (by Boris)
Thanks Jonathan
(no subject) (by Rox)
is it Ok or safe to use 1N5819 schottky diode 1amp on this? I can't find A BAT 54 or other small signal diode in my area.
Thanks - Rox
(no subject) (by Jonathan Westhues)
The 1N5819 will work, but its reverse leakage current may contribute non-negligible error, especially at high temperature. Consider Vishay's datasheet:
http://www.vishay.com/docs/94614/1n5819.pdf
That leakage current is rated at 6 mA max, at Vr = 40 V and 100 degrees C. Of course, we should never in practice have more than (5 V - (250 ohms)*(4 mA)) = 4 V across the diode, which Fig 2 would suggest adds less than a microamp typical at room temperature, though a ~milliamp at 125 degrees C.
The 1N5819 also adds lots of capacitance, a couple hundred pF. The circuit above already has 100 nF to ground at the input, though, so that's negligible.
(no subject) (by rox)
Ok, thanks jonathan for making it clear to me. u'r great.
Rox
Post a reply to this comment:
|