CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Possible to create 4-20 mA signal using a PIC?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jseidmann



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

Possible to create 4-20 mA signal using a PIC?
PostPosted: Mon Jul 18, 2005 2:47 pm     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Jul 18, 2005 3:32 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Jul 18, 2005 3:33 pm     Reply with 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.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Jul 18, 2005 4:05 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 18, 2005 7:51 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Jul 19, 2005 6:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 19, 2005 6:27 am     Reply with quote

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







PostPosted: Tue Jul 19, 2005 7:35 am     Reply with quote

jseidmann



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

PostPosted: Tue Jul 19, 2005 7:40 am     Reply with quote

Ttelmah
Guest







PostPosted: Tue Jul 19, 2005 8:50 am     Reply with quote

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

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Tue Jul 19, 2005 9:29 am     Reply with quote

Don't know if this helps, but look at the article "Single Transistor Constant-Current Generator" from Electronics Design magazine...

http://www.elecdesign.com/Articles/ArticleID/6268/6268.html#
EY
Guest







PostPosted: Fri Sep 16, 2005 4:28 pm     Reply with quote

This Circuit can be your wants...

EY
Guest







PostPosted: Fri Sep 16, 2005 4:30 pm     Reply with quote

or http://img382.imageshack.us/img382/3020/pccs9rb.jpg
TimMoody
Guest







20mA Current Loop
PostPosted: Mon Sep 19, 2005 11:32 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group