Using multiple pins to supply enough current
![W9GFO](https://forums.parallax.com/uploads/userpics/060/nOMKNXA98BY9Q.jpg)
I'm working on a circuit that uses an 8 pin PIC that will operate two relays. Each relay draws 28 mA but each pin is only good for 25 mA. Plus, I want to also have an LED turn on along with the relay.
My solution is to just use two pins. It is working just fine but I want to ask if this is an acceptable practice.
Pin 0 and Pin 1 are shorted together, the relay is connected to Pin 1, as is a 1K resistor then LED. Total current draw ~ 33 mA.
Anything wrong with that?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
My solution is to just use two pins. It is working just fine but I want to ask if this is an acceptable practice.
Pin 0 and Pin 1 are shorted together, the relay is connected to Pin 1, as is a 1K resistor then LED. Total current draw ~ 33 mA.
Anything wrong with that?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Comments
-Phil
Thanks, I really want to avoid putting in a pair of transistors if they are not needed and it seems they aren't. It's a super simple program - which doesn't mean that I didn't spend hours trying to get it to work! I really wish Parallax would come out with a 8 or 10 pin Propeller chip.
Stupid PICs, grumble grumble.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
That makes sense, in my case one pin could take up to 75% of the load without exceeding the limit. How likely would it be that the load is that unbalanced?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
24 bit LCD Breakout Board now in. $24.99 has backlight driver and touch sensitive decoder.
If you have not already. Add yourself to the prophead map
Rich, there are dual transistor arrays available, with included resistors, that are very cheap and very small. I would much sooner use one of those than risk the consequences of a bus conflict on your PIC, regardless of how "super simple" the program is.
-Phil
I ask this because relay coils can be quite inductive, and you would expect to see some inrush at the time of switching the coil. You can address this somewhat with a snubber circuit. I don't see 28mA as being a big problem, but it would be worth checking what you really have with a scope to make sure there's no sharp spike.
cheers
tubular
Are you sure you don't have that backward? High inrush current is more a property of caps than inductors. In fact, inductors tend to block current inrush. Remember:
dI/dt = V / L
The higher the inductance, the lower the current build-up rate.
-Phil
With one probe on VDD of the Pic and the other on the output pins;
VDD remains unchanged at 5V
The output drops from 5V to 4.2 V within 1 mS, tiny bit of wiggle for about .5mS then is steady at 4.2V. It does not drop below 4.2V at all.
Is there something else (or another way) I should check for?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
If 28mA is indeed too much for a single I/O pin, I would be tempted to use a diode in series with the relay to drop the 5V down to 4.4V ... 4.4V / 178 ohms = 24.7 mA
I would avoid paralleling the pins if at all possible.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Aside from the issue of setting the pins to opposite output states, what is the risk?
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
It's a well-worn adage of system design that no amount of software malfunctioning should ever cause harm to the hardware. (It's probably something that Toyota engineers are reviewing as we discuss this.) If at all possible, I would avoid parallelling microcontroller outputs. You'd probably get by with it, but it's just a bad design habit to get into.
-Phil
I have a quad LM324 wired as a voltage follower.· Can I wire all inputs and outputs together and use the sum of outputs to get 4 times the output of a single op amp?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
I'm also a fan of·driving relays directly from an I/O pin·without a driver transistor if possible.·Beau's idea of using one pin and dropping the current with a diode is excellent. Or you could·use a small fixed resistor, same effect. Most 5V relays will operate perfectly fine from ~4V. I have some TF2-5V·relays (coil current 17 mA) that operate well·as low as·~2V, being driven directly by a Stamp Homework board or Project board with those ever-lovin' inline 220-ohm protection resistors.
LED indicators in parallel with each relay are quite useful.·Check out·these 2 mA units from Junun, use them with a series 1500 ohm resistor. Nice & bright, they are available in red & green. They'll save you a few milliamps.
http://www.junun.org/MarkIII/Info.jsp?item=62· red
http://www.junun.org/MarkIII/Info.jsp?item=63· green
And don't forget that flyback diode across your coil, too!
erco
Here's a pic of this exact setup, driven by a BS-2E: http://forums.parallax.com/attachment.php?attachmentid=66365
Except I'm using 1K resistors here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Diode shmiode, are you sure they are necessary? It's something that I wondered about but I cannot detect any spikes with the scope.
If I'm going to add a component I might as well make it a transistor - which I am strongly considering now because I think I want to add some more features and I need those pins. I tried using a 1N4148 diode on just one pin but the relay would not trip.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
-Phil
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Also, if you're driving the coil directly from a micro, the input protection diode may be shunting the spikes to Vdd — and becoming gradually destroyed in the process.
-Phil
BTW, when it comes to suppression diodes on coils, it's best to heed the old Nike ads.
Post Edited (Phil Pilgrim (PhiPi)) : 2/3/2010 4:37:23 AM GMT
Would a 1N4148 diode be appropriate? 100V reverse voltage, 400 mA repetitive peak current.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
I'm surprised to hear that the relay won't work with one series diode. That's still ~4.3 volts. Sure the diode polarity was right?
Some micro's (like the Stamp) I/O pins can sink more than they can source. Sink 25 mA, source 20. Use that to best advantage.
Just checking here, please don't take offense if I'm stating the obvious. Diode polarity is critical, and we've been talking about two different uses for these diodes. 1N914s probably work fine here, but I use 1N4001 recifier diodes for everything and I know they work.
The voltage-dropping diode·Beau mentioned will connect the I/O pin to the relay. If you're connecting one side of your coil to ground, then the dropping diode will have its banded end (cathode) connected to the other relay coil contact, unbanded end to the I/O pin. Won't work backwards. In a related story, some relay coils are polarized; my TF2-5V coil has a + and - coil conection. Won't work backwards.
If you use a resistor instead of a diode, polarity doesn't matter.
The flyback diodes are connected in parallel with the relay coil, in the opposite polarity to conduct. If one side of your relay coil goes to ground, that side gets the unbanded (anode) end of the diode., banded side to the other coil connection then through the diode or resistor to the I/O pin.
BTW, it looks dicey runing an LED. If your LED takes even 5 mA, that leaves only 20 mA to drive the relay. I calculate a series resistor of 72 ohms with your coil resistance of 178 ohms to keep it at 20 mA total. That means your relay needs to pull in with only 3.56 V. Without an LED, the relay gets the full 25 mA, your series resistor is 22 ohms and your relay gets 4.45 V.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Post Edited (erco) : 2/3/2010 7:34:55 AM GMT
The Pic 12f683 can source or sink 25 mA.
I'm using N14148s - and no offense taken.
The TX2-5Vs are polarized also.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Here's an illustration of the recommended relay driver, being fed by a typical CMOS output structure with its internal protection diodes:
-Phil
_
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 2/4/2010 7:48:39 PM GMT
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 2/4/2010 7:29:34 PM GMT
Could I not just put the LED (green) between the resistor and the transistor?
Rich H
edit - I see you just answered that part. Thanks!
Updated schematic:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 2/4/2010 7:50:28 PM GMT
-Phil