Searching \ for 'Relay problem..' 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/io/motors.htm?key=relay
Search entire site for: 'Relay problem..'.

Truncated match.
PICList Thread
'Relay problem..'
1999\04\04@111128 by Andreas Nyholm

flavicon
face
Hi!
I'm going to have my PIC16F84 to pull a relay.
My relay is 55 ohm and I'm wondering if I just can put a 220 ohm
resistor in serial to the relay and then straight up to Vdd. But
certainly I must have a diode over the relay, but should it work
otherwise?

1999\04\04@115613 by Harold Hallikainen

picon face
On Sun, 4 Apr 1999 18:11:16 +0300 Andreas Nyholm <spam_OUTa.nyholmTakeThisOuTspamAGROLINK.FI>
writes:
>Hi!
>I'm going to have my PIC16F84 to pull a relay.
>My relay is 55 ohm and I'm wondering if I just can put a 220 ohm
>resistor in serial to the relay and then straight up to Vdd. But
>certainly I must have a diode over the relay, but should it work
>otherwise?
>


       What is the rated coil voltage of the relay?  With the circuit you
propose, the relay coil will get about 20% of the 5 volts available on
Vdd, or 1 volt.  I doubt this is enough to pull in the relay.

Harold

___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1999\04\04@122309 by Wagner Lipnharski

picon face
... remember that the power required to create the magnetic field to
"attract" the relay armature is much higher than the required to "keep"
it attracted.  When low power consume is required using relays, you have
two alternatives:

1) Use a latch relay (it consumes power only during few milliseconds to
close or release, no power at all while closed or released).

2) Use a resistor in series with the relay, and a electrolytic capacitor
in parallel to the resistor.  The capacitor allow a current peak, enough
to supply the required high power to close the relay. Once charged the
capacitor current stops, allowing only the smaller current through the
resistor to keep the relay closed.  To find out about the resistor
value, start with a resistor with the same relay coil in ohms, install a
wire jumper across the resistor and energize it, the relay closes, then
remove the jumper, if the resistor holds the relay closed, it is enough.
Then you can increase the resistor value from 20 to 50%, until it can't
holds the relay closed, then use a resistor half value from that failing
point, so you would have a nice error margin.  Now start to play with
the capacitor, start with a value in between 10 and 100uF and goes
increasing until the relay closes, when it happens, use a capacitor's
value at least 50% bigger.  There are formulas to calculate all of this,
but the experiment is nice and teach us something more than simple
formulas.

Wagner

Harold Hallikainen wrote:
{Quote hidden}

1999\04\04@124418 by Reginald Neale

flavicon
face
>Hi!
>I'm going to have my PIC16F84 to pull a relay.
>My relay is 55 ohm and I'm wondering if I just can put a 220 ohm
>resistor in serial to the relay and then straight up to Vdd. But
>certainly I must have a diode over the relay, but should it work
>otherwise?

You didn't say what the design voltage of the relay is. In any case, there
is no way you can drive this relay directly from a PIC pin. Use - for
example - the collector of a 2N2222 transistor to switch it. No series
resistor necessary. Drive the transistor base with a 1K resistor from the
PIC pin. The diode goes in parallel with the relay, anode towards the (+)
relay supply voltage.

Good luck,
Reg Neale

1999\04\04@130743 by D. F. Welch

picon face
At 11:43 AM 4/4/99 -0500, you wrote:
>>Hi!
>>I'm going to have my PIC16F84 to pull a relay.
>>My relay is 55 ohm and I'm wondering if I just can put a 220 ohm ....
> Use - for
>example - the collector of a 2N2222 transistor to switch it. No series
>resistor necessary. Drive the transistor base with a 1K resistor from the
>PIC pin. The diode goes in parallel with the relay, anode towards the (+)
>relay supply voltage.

NO!   The cathode goes to the + Supply voltage.  If the
Anode were connected to the + supply the diode would
conduct as soon as the transistor turned on.  This would
limit relay coil voltage to .6V ( Silicon Diode) and
instantly fry the transistor.  The object of the diode is to limit reverse
polarity transients when the relay is
de-energized.



Daniel F. Welch

Director
Research and Development
American Scientific Associates
Email: amerscispamKILLspamflash.net

1999\04\04@134518 by Reginald Neale

flavicon
face
>>resistor necessary. Drive the transistor base with a 1K resistor from the
>>PIC pin. The diode goes in parallel with the relay, anode towards the (+)
>>relay supply voltage.
>
>NO!   The cathode goes to the + Supply voltage.  If the
>Anode were connected to the + supply the diode would
>conduct as soon as the transistor turned on.  This would
>limit relay coil voltage to .6V ( Silicon Diode) and
>instantly fry the transistor.  The object of the diode is to limit reverse
>polarity transients when the relay is
>de-energized.
>

OOPS!

Don't know how I typed anode when I meant cathode. Thanks Dan, for catching
that. Sorry for the confusion.

Reg Neale

1999\04\04@134936 by Dave VanHorn

flavicon
face
>2) Use a resistor in series with the relay, and a electrolytic
capacitor
>in parallel to the resistor.

You could activate the relay momentarily with a wide pulse, allowing
it to pull in, then PWM the output to keep it held.  There is an
energy advantage in that energy stored in the coil winding is returned
to VCC (or whichever) when the field begins to collapse, rather than
being blown as heat in the resistor.

1999\04\04@152933 by Andreas Nyholm

flavicon
face
Yeah you're right.. I didn't notice the volts over the resistor.. ;)
I have been thinking of a 7406 too, it's a hex inverter with open collector.
If I use that can I take the 5V directly from my PIC to the hex inverter and
put the relay after the 7406 without some resistors or anything else than the
diode?
I started to think about the reset circuit too. Is that needed or can I leave
MCLR empty? And must the 100nF conductor between the power supply and ground
be there?
Thanks
Andreas

>        What is the rated coil voltage of the relay?  With the circuit you
> propose, the relay coil will get about 20% of the 5 volts available on
> Vdd, or 1 volt.  I doubt this is enough to pull in the relay.

1999\04\04@180309 by paulb

flavicon
face
Andreas Nyholm wrote:

> I have been thinking of a 7406 too, it's a hex inverter with open
> collector.

 You're not winning over the PIC in terms of its *current* rating.  The
problem with this relay is that at 5V, presumably its rated voltage, it
draws just under 100mA.  Even the 7406 is rated at only 50mA.

> If I use that can I take the 5V directly from my PIC to the hex
> inverter and put the relay after the 7406 without some resistors or
> anything else than the diode?

 Now if you start to be clever, you use an Allegro or equivalent
ULN4003 which is *designed* for this application and includes the
diodes.  Of course with the 7406 you had 5 spare drivers and with the
4003 you have 6 spare.

 OK, so you *can* parallel all six gates in the 7406 and arguably get
enough drive current, which might have been clever but you still need
the extra diode and ... it *chews current*, at least thirty milliamps(!)
quiescent.

> I started to think about the reset circuit too. Is that needed or can
> I leave MCLR empty?

 Never leave it "empty" (unconnected).  At least tie it to VCC with a
resistor (10k).  Why not fix it to Vcc?  Well, for testing you often
want to reset it, and who knows what later re-design might involve
a watchdog or something added to pull it low?  In fact, to be specific,
the brownout circuit in the app notes (1 transistor and three resistors
should *always* be used.

> And must the 100nF conductor between the power supply and ground be
> there?

 *Most* important component in the whole circuit ;-)

 Wagner spoke of using a resistor and capacitor for providing a "pulse"
source to actuate the relay.  He didn't mention that is only applicable
as the supply to the relay *and switch* (e.g., the ULN2004).  Your
switch must be in a position to, and capable of switching the full pulse
current.
--
 Cheers,
       Paul B.

1999\04\04@185819 by Wagner Lipnharski

picon face
Paul B. wrote:
>  You're not winning over the PIC in terms of its *current* rating.  The
> problem with this relay is that at 5V, presumably its rated voltage, it
> draws just under 100mA.  Even the 7406 is rated at only 50mA.

... a 5V/ 500 Ohms relay would consume only 10mA... isn't a PIC able to
drain 10mA?

>   Wagner spoke of using a resistor and capacitor for providing a "pulse"
> source to actuate the relay.  He didn't mention that is only applicable
> as the supply to the relay *and switch* (e.g., the ULN2004).  Your
> switch must be in a position to, and capable of switching the full pulse
> current.
> Paul B.

Yes, well, the capacitor in parallel to the resistor is just to create a
"timed" short circuit to the resistor, if you don't do it, it would be
just a wire there, right?
... using the right relay to the right VCC...


Dave Vanhorn wrote:
> You could activate the relay momentarily with a wide pulse, allowing
> it to pull in, then PWM the output to keep it held.  There is an
> energy advantage in that energy stored in the coil winding is returned
> to VCC (or whichever) when the field begins to collapse, rather than
> being blown as heat in the resistor.

Dave, how the energy stored in the coil would return to VCC? How this is
an advantage? You mean when the field collapse? The voltage generated
across the coil has an inverted polarity, so I don't see how it would be
an advantage...  The resistor function is not to blown this energy, but
to increase the relay resistance and reduce the current consumption...
nothing else.

Wagner.

1999\04\04@191029 by Byron A Jeff

face picon face
>
> Paul B. wrote:
> >  You're not winning over the PIC in terms of its *current* rating.  The
> > problem with this relay is that at 5V, presumably its rated voltage, it
> > draws just under 100mA.  Even the 7406 is rated at only 50mA.
>
> ... a 5V/ 500 Ohms relay would consume only 10mA... isn't a PIC able to
> drain 10mA?

Yes. But the original author stated he had a 5V/55 Ohm relay. That's where
the 90 and change milliamp rating comes in.

{Quote hidden}

I'm not sure that's relavent. If the application only calls for one relay
there are two or three quick ways to handle it:

1) As stated before a 2N2222 will do a fine job.
2) Lately I've been using optoisolators. The two relay projects I have use
a 6N138 Darlington optoisolator to drive the relay. I used them because I had
them in my junkbox. I believe they can sink up to 250ma at 5V.
3) Another idea is to use a true blue 555 timer with a short delay. The timer
can source/sink up to 200ma.

{Quote hidden}

That's correct. I think Dave may be pointing out that with PWM the relay
never actually disengages if the pulse rate is fast enough. The decaying
magnetic field is sufficient to keep the relay engaged until the next pulse.

The nickle transistor is the easiest and cheapest way to drive the relay.

BAJ

1999\04\04@200052 by Wagner Lipnharski

picon face
This is the possible problem for using junkbox parts, sometimes the
project goes bigger and expensive just to use some part that is not well
dimensioned.

There are some MOS and Opto Relays that consume less than 5mA (1.2V) at
the driver side and are pretty good to drive 2.5A at 20Vdc, or other
120mA at 400Vac/dc (drive 6mA at 1.2V), cost less than $6.00 at digikey,
check p/n PVN012-ND or PVO402P-ND.

For sure junkbox parts are pretty good to generate solutions to use a
particular part, but not always the best part to be used.  Even that
several times parts from a junkbox are pretty useful and solve some
problems, they are just what the first 4 lettes of the box says, just
"junk"... :)

I have several junkboxes with pounds of brand new and used material.
Those parts were nice and useful, not anymore.  There are dozens of
relays that consume more power itself than a whole microcontroler
board... high power transistors to control several amps... doesn't make
sense to use them anymore... technology changed to a new power platform.
20 years ago power economy was a board consuming 3 to 5 Amps, today a
whole microcontroller board consuming more than 50mA is an absurd.
Today we fight to reduce one milliamp.

Wagner.

1999\04\04@205501 by paulb

flavicon
face
Wagner Lipnharski wrote:

> ... a 5V/ 500 Ohms relay would consume only 10mA... isn't a PIC able
> to drain 10mA?

 BAJ answered for me!

> Yes, well, the capacitor in parallel to the resistor is just to create
> a "timed" short circuit to the resistor, if you don't do it, it would
> be just a wire there, right?  ... using the right relay to the right
> VCC...

 Not sure what you're saying, but your original post was a little
unclear on the resistor/ capacitor matter and could be taken to suggest
a resistor/ capacitor *after* the switch which would of course be worse
than useless.

> Dave, how the energy stored in the coil would return to VCC?  How this
> is an advantage?  You mean when the field collapse?  The voltage
> generated across the coil has an inverted polarity, so I don't see how
> it would be an advantage...  The resistor function is not to blown
> this energy, but to increase the relay resistance and reduce the
> current consumption... nothing else.

 Gee whiz, I think you got out of the wrong side of the bed! :)  I'm
*sure* you must understand how a switchmode voltage converter works.
The commutation diode maintains the *current flow* when the switch
(transistor) turns off.

 By choosing suitable pulse timings, in the "off" time, the current in
the relay coil decays, but to a value which is still sufficient to hold
in the armature.  In the "on" time, the current builds up, but it is
only necessary (except for inititl closure) to let it build up to say,
twice the "hold" current.  This represents a significant overall saving
in current even over the series resistor case.
--
 Cheers,
       Paul B.

1999\04\04@232758 by Byron A Jeff

face picon face
{Quote hidden}

I don't beleve that power budget was an issue in the original poster's
problem. Nor did it seem like he was designing a million unit project.
In those cases I agree in searching for the best part for the job.

However if this is a one off hobby project, and I suspect it is, then checking
the junkbox is always a useful thing to do. It gets the job done without having
to wait for Digikey to ship or even driving to the RatShack to pick up a part.

And remember that one project's junk is another project's treasure ;-)

BAJ

1999\04\05@054424 by Andreas Nyholm

flavicon
face
>  Now if you start to be clever, you use an Allegro or equivalent
> ULN4003 which is *designed* for this application and includes the
> diodes.  Of course with the 7406 you had 5 spare drivers and with the
> 4003 you have 6 spare.

Actually what is ULN4003? The only component I found with 4003 was a
thyristor. Is it that?

>
>
>   OK, so you *can* parallel all six gates in the 7406 and arguably get
> enough drive current, which might have been clever but you still need
> the extra diode and ... it *chews current*, at least thirty milliamps(!)
> quiescent.
>

The reason why I should use the 7406 is that I already have one...
If I parallel 3 gates don't I get about 150 mA minus the thirty... but it
should be enough to get 90mA, or??
But if you tell me what the 4003 actually is so there shouldn't be any
problems to use that either.. ;)
Andreas

1999\04\05@055912 by Andreas Nyholm

flavicon
face
damn...
I just found the circuit you meant... ;)
But the name was ULN2003 and not ULN4003...
So, is it just to put my PIC before the ULN2003 and the relay after??

Andreas

1999\04\05@071843 by paulb

flavicon
face
Andreas Nyholm wrote:

> Actually what is ULN4003? The only component I found with 4003 was a
> thyristor. Is it that?

 Sorry!  Memory parity error!  (Squaawk!  Pieces of Seven!  Pieces of
seven!)

> I just found the circuit you meant... ;)
> But the name was ULN2003 and not ULN4003...

 Yep.  100% correct.

> So, is it just to put my PIC before the ULN2003 and the relay after??

 Yep.  You connect ground, the PIC to the 2003 input, the relay coil to
the output and the Vcc line of the 2003 to the relay supply (not
necessarily the regulated 5V from which the PIC runs and in fact, if you
have an unregulated (usually 12V) supply, do use that instead.

 If you then need to use a resistor to drop the 12V to a lesser voltage
such as 5V or 6V for the relay, that's fine too, you are transferring
current draw and heat dissipation from the regulator across to the
resistor.  And if you then want to use the capacitor to provide a
closing impulse to the relay but limit the "hold" current, that will be
fine too.

12V Unreg o-+---------------------------------------+
            |    R             Coil       __________|____
            +---VVVVV---+-----UUUUU------| Out      V+   |
                        | +              |               |
                        = Cap            | 1/7 ULN2003 In|------o PIC
                        | (if wanted)    |               |
                        |                |______G________|
       V- o-------------+-----------------------+

> The reason why I should use the 7406 is that I already have one...

 As was said, the "junkbox approach"!  Fine if you want one or two and
you have one or two.  1N4004 (or generic) diodes are almost certainly in
there too!

> If I parallel 3 gates don't I get about 150 mA minus the thirty... but
> it should be enough to get 90mA, or??

 It's not "minus the thirty", the 30mA is what the 7406 draws from its
supply no matter what.  It feeds the logic.  Closer examination of the
specs (T-I) indicates the rating is only 40mA per output.  Total draw
isn't specified, so you can make your own conclusions.

> But if you tell me what the 4003 actually is so there shouldn't be any
> problems to use that either.. ;)

 The ULN4003 is an array of seven darlington pairs with the base
resistors integrated so you just feed a straight 0-5V voltage level, and
commutation diodes are provided to the V+ terminal so you just connect
that to your relay supply.  Unlike the 7406, the V+ terminal is not
necessary to power internal logic, it connects *only* to those diodes.
--
 Cheers,
       Paul B.

1999\04\05@074114 by Russell McMahon

picon face
>I just found the circuit you meant... ;)
>But the name was ULN2003 and not ULN4003...
>So, is it just to put my PIC before the ULN2003 and the relay
after??


Andreas

Butting in on the other guy's answer :-)

Yes. But note that the "catch" diodes have a common pin for their
cathodes (pin 10 from memory).
This goes either straight to relay supply or via a resistor. If you
take it straight to supply the relays will release more slowly (which
may not be a problem). if you use a resistor there will be a voltage
spike but the relay will release more quickly.

The voltage spike will be V = Irelay x R initially, above V supply.
As long as Ispike + Vrelay supply is rather less than the rated
voltage of the ULN2003 it should work OK.

If relay release speed is not an issue then just short this pin to
relay V+ supply - its easier :-)

Note:  The ULN2003 has internal input resistors (about 3K AFAIR)
which means you can drive them directly with the PIC. Some other
similar members of the family DONT HAVE THESE RESISTORS. Be sure
which part you are using.



     Russell McMahon




>
>Andreas
>

1999\04\05@093113 by Lawrence Lile

flavicon
face
You need to consider a couple of things with your relay.

1. yes you will always need a reverse diode across the relay to deal with
spikes.

2. You may need to pay attention to your PIC's output current requirements.
I don't have the spec handy, but most PIC pins can only drive 20 or 25 mA.
I have always needed to drive a relay through a small to-92 transistor.  If
you are using a 5 volt, 55 ohm relay it will need 90 mA or so to drive it.
This is beyond the capacity of a PIC pin.  A 2n2222A will do the job nicely
though.



-----Original Message-----
From: Andreas Nyholm <.....a.nyholmKILLspamspam.....AGROLINK.FI>
To: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU <PICLISTspamspam_OUTMITVMA.MIT.EDU>
Date: Sunday, April 04, 1999 10:11 AM
Subject: Relay problem..


>Hi!
>I'm going to have my PIC16F84 to pull a relay.
>My relay is 55 ohm and I'm wondering if I just can put a 220 ohm
>resistor in serial to the relay and then straight up to Vdd. But
>certainly I must have a diode over the relay, but should it work
>otherwise?

1999\04\05@123615 by Wagner Lipnharski

picon face
PaulB wrote:
> Gee whiz, I think you got out of the wrong side of the bed! :)  I'm
> *sure* you must understand how a switchmode voltage converter works.
> The commutation diode maintains the *current flow* when the switch
> (transistor) turns off.

This was not the original message. Without the use of the catch diode
(here merelly the protective diode) there was no use for the energy from
the collapse field since the switching element is open, so that energy
would never "return to VCC", as described in his original message as the
"advantage of the PWM". This was what I asked him to explain.

Aromat produces some relays that still attracted with only 10% of the
original attracting voltage. For example the DSP1-DC5V, a 5Vdc coil
relay, 83 Ohms (60 ma) can handle contact current of 5 Amps (125 Vac),
attracts above 4V (0.192W) and holds attracted down to 0.5V (0.003W).
You can hold it attracted with 0.6V (7.2mA) during hours, consuming only
2.2% of the attracting power using a 600 Ohms resistor in series (plus
the capacitor), with a minimum EMI interference, no software (PWM)
overhead and long life to the relay coil. I guess, but not sure, using
the PWM it is also possible to achieve the same power savings, with the
same reliability.  But all of this are eliminated just using a latching
relay by the same price, not disconsidering the use of solid state
relays.

Of course, as I said before, junkbox projects are interesting for the
creativity, but just for that.  People need to be aware that new
components and best solutions are being released in daily basis, it
means more savings and practicity. The fact of using a PIC and not a
4004 microprocessor to activate the relay is a proof of that, and yes,
sometimes you need to wait the new parts delivery, you can not live only
in the past.

Ah, by the way, this "resistor+capacitor" current saver is being used
since the tubes age, transistors emitter polarization and solenoids
power savings, so I thought it wasn't needing too much explanations.
Sorry if I was not clear enough.

Wagner

1999\04\05@125943 by engelec

picon face
Andreas,

you definitely need to use a transistor to drive your
relay.

Andre



Andreas Nyholm wrote:

> Hi!
> I'm going to have my PIC16F84 to pull a relay.
> My relay is 55 ohm and I'm wondering if I just can put a 220 ohm
> resistor in serial to the relay and then straight up to Vdd. But
> certainly I must have a diode over the relay, but should it work
> otherwise?

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