Searching \ for 'Interfacing PIC to industrial automation' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Interfacing PIC to industrial automation'.

Truncated match.
PICList Thread
'Interfacing PIC to industrial automation'
1998\10\26@171400 by Andrew Yalowitz

flavicon
face
I'm trying to interface a PIC to an industrial lighting dimmer that is
expecting a variable current sink of 4 to 20 mA.
What I would like to do is be able to sink current (4 to 20 mA) proportional
to an 8 bit value. The device (a lighting dimmer) is fully on at 4 mA and
fully off at 20 mA. I have been able to handle the user interface portion
and the processing of the data, but I have no clue how to get a pic to sink
a variable amount of current.

Any advice?

TIA


Andrew Yalowitz

1998\10\27@065245 by Dr. Imre Bartfai

flavicon
face
Hi,
use either some (bigger) PIC having built-in PWM, or write it in software
(Scott has an excellent solution). The PIC is capable to generate voltage
from 0 to 5 V. If the dimmer has the voltage without load also 5V, you are
lucky. The total series resistor should be 250 ohms in this case. Are you
sure the dimmer GENERATES current to be sunk?

Imre


On Mon, 26 Oct 1998, Andrew Yalowitz wrote:

{Quote hidden}

1998\10\27@111707 by Peter L. Peres

picon face
On Mon, 26 Oct 1998, Andrew Yalowitz wrote:

> I'm trying to interface a PIC to an industrial lighting dimmer that is
> expecting a variable current sink of 4 to 20 mA.
> What I would like to do is be able to sink current (4 to 20 mA) proportional
> to an 8 bit value. The device (a lighting dimmer) is fully on at 4 mA and
> fully off at 20 mA. I have been able to handle the user interface portion
> and the processing of the data, but I have no clue how to get a pic to sink
> a variable amount of current.

If you don't care about parts count and cost, use a dedicated chip. This
will still require an A/D. For your application, the PWM A/D method seems
to be what is desired. This relies on a software loop to generate a
variable duty cycle square wave on an output pin that is integrated and
used as analog output. If you use a double op-amp you can use one half to
integrate and the other as current sink. There are also commercial
applications for this. If the controlled device has an integrator or a low
pass filter at the input then sometimes you can cheat and feed the raw PWM
directly from the PIC to the 20 mA loop. In this particular case, a R/C/R
'T' subber is used, with one end steered by the PIC and the other
connected to the 20 mA loop. The PIC output is programmed as a '0' and its
tristate control is used to actually output the waveform.

Peter

1998\10\28@084224 by Andrew Yalowitz

flavicon
face
The fact that the dimmer generates the current to be sunk totally threw me
for a loop. Until now, **every** dimmer system that I have seen or read
about (admittedly theatrical and architectural)  has looked for a voltage,
usually 0 - 10v
When I went out to take a look at the dimmer in question, I measured the
voltage and it looked like it was 0 to 24v. When my interface box (which
generates 0 - 24v) didn't work, I did more research and discovered that the
dimmer was actually generating the current which was being sunk by the
controller.   A friend told me about a Programmable Logic Controller that
could sink the 4 to 20 mA that I need, and I was wondering how it did this
so I could replicate it with my pic.

Thanks for your advice!

> {Original Message removed}

1998\10\28@170526 by Thomas McGahee

flavicon
face
Andrew,

One method you could use to control the dimmer that requires a current
sink is to let the PIC control a voltage to current converter. Let's
assume you want an output of +4 volts to generate a current sink of
20 ma. The basic current sink looks like this:


                     Current varies between 4 ma and 20 ma.
                    |Collector connects to wire from dimmer
                    |
                    |
             base  |/
1.5 to +4.7v >------|    NPN with gain greater than 100
                   |\
                     V (emitter)
                     |
                     /
                     \
                     /  200 ohms
                     \
                     |
                   ----- Ground MUST be common with dimmer ground
                    ---
                     -

I have arbitrarily chosen the emitter resistor to be 200 ohms. When
4 ma is flowing through it, the voltage across the resistor will be
.8 volts. When 20 ma is flowing through it the voltage across the
resistor will be 4.0 volts

We have to add the .7 volts base-emitter diode drop to each of these
voltages. That gives us an input to the base of 1.5 to 4.7 volts.

OK, but what is a good, cheap way to produce that voltage that has to
vary between 1.5 and 4.7 volts? Well, you could use a PWM
technique.

1.5 volts corresponds to 30% of 5.0 volts, and 4.7 volts corresponds to
94% of 5.0 volts. So, if we produce a pulse that goes from 0 to +5
volts and varies from 30% to 94%, we will have the average voltages
we are interested in of 1.5 to 4.7 volts.

The frequency of the PWM waveform should be significantly higher than the
60 Hz waveform that is ultimately being supplied to the lamp by the
dimmer circuit.

You will note that from 30% to 94% there is a difference of 64. We will
let 100%=100 counts.

With a 4 Mhz clock we can get 1 million instruction cycles per second.
If we allow ourselves a comfortable 100 instruction cycles per
interrupt, that means we can service 10,000 interrupts every second.
It will take 100 interrupts to acquire 100 counts, so we will be
providing 10,000/100=100 completed 100% cycles every second.

So, what goes on in this interrupt that occurs 10,000 times per second?

Let's assume that you have the timer producing interrupts
once every .1 millisecond. We will further assume that a register(s) called
INTENSITY(#) contains a value between 0 and 99 (although it is further
restricted to being between 30 and 94, to match the 30% and 94% points
mentioned earlier).

A register named PERCENT will contain a value between 0 and 99 that
represents the current percent value. On each interrupt this value is
incremented and compared with 100. (When it reaches 100 it is reset to
ZERO, and all PWM outputs are set to LOW). The PERCENT value is then
compared with the INTENSITY(#) value, and when it is equal (or greater),
then the respective PWM output is set HIGH. This allows several PWM outputs
to operate from a single PIC.

Once all PWM outputs have been adjusted, then the interrupt service routine
is exited.

Other routines can be used to receive the data from an external device and
load the appropriate values into the respective INTENSITY# register(s).

Note that the incoming data can be in the form of 0-100, but it has to be
converted then to a value from 30 to 94 to match the needs of the dimmer
module. In addition, the value 30 represents 4 ma, and 94 represents
20 ma. But 4 ma=full ON, and 20 ma=full OFF. This means a little bit
of manipulation/conversion has to be done before the correct INTENSITY
value can be calculated.

If you need greater resolution, then consider letting full-scale values
be 200 or 400 or 800 instead of 100. In other words, try to keep the
data related in a binary fashion, as this keeps the calculations
relatively simple. Greater resolution means that the time allocated for the
interrupt routine is also lessened. This might require that much of
the program be moved out of the interrupt service routine and allocated to
a loop.

Hope these ideas help
Fr. Tom McGahee
----------
{Quote hidden}

1998\10\28@221812 by Justin Grimm

flavicon
face
If what youre looking for is a 0-5v to 4-20mA converter why dont you try a
dedicated
chip?
xtr110 from burr brown fits the bill.
http://www.bbrown.com/Products/DataSheets/XTR110.html

Justin Grimm




Thomas McGahee wrote:

{Quote hidden}

1998\10\29@083910 by Steve Becker

picon face
Justin,

The XTR110 will be fine for a normal 0-10V DC input converting to an
output current loop of 4-20mA.  In fact, the chip can drive up to like
26mA or so without problem should input exceeds 10V.  The chip is so
good that we never have to use the trim terminals.  Never fails in the
field, a great chip from BB.

But the problem is what he wants is to sink 4-20mA, not a sourcing
deal!!  May be he should look back to this uncommon approach because I
have not seen an application in the fiels like that.

Regards,

Steve Becker

Justin Grimm wrote:
{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...