View previous topic :: View next topic |
Author |
Message |
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
Possible to create 4-20 mA signal using a PIC? |
Posted: Mon Jul 18, 2005 2:47 pm |
|
|
I'm sure some of you are familiar with 4-20 mA signals. Essentially, I was wondering if there was any way to create a 4-20 mA signal using some pins on the PIC? I'm not tied to a particular PIC, so I'm really open to suggestions. I would really like to use only the PIC and possibly a resistor or so, but no external components (no IC's anyway if possible!). Let me know if you know any means of doing this. I know the pins can sink/supply up to 25 mA, is it possible to use that? |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Mon Jul 18, 2005 3:32 pm |
|
|
Can't you just put a series 250ohm resistor onto the PIC's pin? This way, you are guaranteed that the current sourced will not exceed 20mA. |
|
|
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
|
Posted: Mon Jul 18, 2005 3:33 pm |
|
|
What I would like to do is to be able to produce a current from 4-20 mA that I could change in software. I'd like to be able to supply a current anywhere in between 4 and 20 mA. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Jul 18, 2005 4:05 pm |
|
|
Quote: |
What I would like to do is to be able to produce a current from 4-20 mA that I could change in software. I'd like to be able to supply a current anywhere in between 4 and 20 mA.
|
Yes, it is very easy to implement. Just need an R2R resistor array (look at Bourns catalog)
connected across an entire port configured as outputs. This way you will get an 8 bit DAC.
To output a 4-20 mA generator, it´s a matter of defining the steps and the lower and upper limits and little code.
Hope you understand the idea.
best wishes,
Humberto |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Jul 18, 2005 7:51 pm |
|
|
What do you want to use this 4-20mA signal for? You can easily generate a 4-20mA signal into a low impedance output, either with PWM or with a ladder of resistors, but it won't be able to drive any overhead voltage for the load. Generally a 4-20mA source will supply the prescribed curent into a load that has an overhead of from 0V to at least 12V. That is going to require an op amp at a minimum. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
|
Posted: Tue Jul 19, 2005 6:17 am |
|
|
SherpaDoug wrote: | What do you want to use this 4-20mA signal for? . |
In industrial applications, a 4-20 mA signal is a pretty standard means of displaying information. 4 mA usually represents a value of '0', and 20 mA can represent any value (lets say 100 ºC if displaying temp.) Then any temperature in between 0-100 is displayed as a current in the range of 4-20 (scaled linearly). |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Jul 19, 2005 6:27 am |
|
|
If you are using this 4-20mA transmitter on the bench for calibrating 4-20mA displays you may be able to measure the voltage overhead of the display and compensate for it.
But if you are making a product to ship to a customer in god-only-knows-where and they will expect it to work like an industry standard 4-20mA transmitter, you are going to need some analog circuitry to make a current source that can accomodate an unknown voltage overhead. There is only so much than can be done in the 5V digital domain. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Graham2 Guest
|
|
Posted: Tue Jul 19, 2005 7:35 am |
|
|
|
|
|
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
|
Posted: Tue Jul 19, 2005 7:40 am |
|
|
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jul 19, 2005 8:50 am |
|
|
The key (which has been touched upon, but not really emphasised), is that a 4-20mA driver should normally be able to handle a wide range of possible loads. Remember that wiring itself will impose variable loads, and given that targets themselves may have different resistors used as a sensor, it is normal for a 4-20mA source to be able to handle between perhap 50R, and 500R. This ability, really implies an op-amp is needed, and a supply of 12v.
You can form a very simple 4-20mA source, by using one of the PWM outputs of the PIC to feed an integrator, to generate a controlable voltage. A simple op-amp, like a TL072, with a transistor, can then form a current source. All you do is compare the voltage being developed across a sense resistor, feeding into the loop connections, with the voltage being developed by the PWM, and adjust the base drive to the transistor to keep the two matched. Choose a suitable value of sense resistor, and you have a controllable current source, for the cost of a few cents. The downside here, is that the source will not be a floating supply (it is common for industrial 4-20mA drives to float the source, so that the sense resistor at the other end can be referenced to ground). Using PWM like this, it is relatively easy to make a floating source, by using an opto-coupler in the PWM signal (obviously requires a floating supply for the op-amp).
Best Wishes |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
|
EY Guest
|
|
Posted: Fri Sep 16, 2005 4:28 pm |
|
|
This Circuit can be your wants...
|
|
|
EY Guest
|
|
|
TimMoody Guest
|
20mA Current Loop |
Posted: Mon Sep 19, 2005 11:32 am |
|
|
I wonder if you are just looking for the old 20mA current loop interface. It was used back in the "day" for a lot of communications equipment like teletypes. Basically 20mA represents a 1 and no current represents a 0 and is a very simple dollar ciruit. If you want an analog 4-20mA control loop(0 mA being a alarm, 4mA being a true 0 and up to 20mA indicating control), you're best bet is to buy an off the self part like a RCV420JP(receiver), about 3.00 and a XTR116U(transmitter) about 1.50. |
|
|
|