Shop OBEX P1 Docs P2 Docs Learn Events
Using multiple pins to supply enough current — Parallax Forums

Using multiple pins to supply enough current

W9GFOW9GFO Posts: 4,010
edited 2010-02-04 19:46 in General Discussion
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.
«1

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-02 03:47
    It's not the best design practice, certainly. But there's nothing inherently wrong with it as long as you're absolutely sure the two pins will never get programmed to opposite output states. [noparse][[/noparse]Ahem!] Also, you will want to check that the overall load limit for all the output pins is not being exceeded. My inclination would be to include a transistor in the design to take the load off the PIC.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2010-02-02 03:56
    Phil has a good point. There is also the problem that two paralleled pins do not always split the current equally. Small differences in positioning and manufacturing can cause one pin to carry much more of the load than another. That can cause both pins to burn out. Probably not a problem in this case, but as Phil says, not the best design practice.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-02 04:00
    Phil Pilgrim (PhiPi) said...
    It's not the best design practice, certainly. But there's nothing inherently wrong with it...

    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. mad.gif

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-02 04:07
    kwinn said...
    Phil has a good point. There is also the problem that two paralleled pins do not always split the current equally. Small differences in positioning and manufacturing can cause one pin to carry much more of the load than another. That can cause both pins to burn out. Probably not a problem in this case, but as Phil says, not the best design practice.

    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.
  • mctriviamctrivia Posts: 3,772
    edited 2010-02-02 04:44
    In the case of diodes I have seen 90% current on 1 of 6 parallel diodes

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-02 05:08
    mctrivia, the diode example may be a red herring here, since it depends on the various forward voltages of multiple PN junctions. The PIC outputs are CMOS, which are basically resistive, so the differential loading is less of an issue. Still, though, I wouldn't do it that way.

    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
  • TubularTubular Posts: 4,718
    edited 2010-02-02 05:14
    Rich, how are you measuring the 28mA current? Is that the DC steady state? How often are you switching?

    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-02 06:12
    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
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-02 06:16
    The coil resistance is listed as 178 ohms, at 5 volts that is 28 mA.

    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.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-02-02 06:28
    W9GFO,

    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.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-02 06:48
    Beau Schwabe (Parallax) said...
    I would avoid paralleling the pins if at all possible.

    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.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-02 07:05
    W9GFO said...
    Aside from the issue of setting the pins to opposite output states, what is the risk?
    "Aside from that, Mrs. Lincoln, how was the play?" smile.gif

    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
  • MikeKMikeK Posts: 118
    edited 2010-02-03 00:09
    Also, the 25ma is probably the Absolute Maximum Rating for the current, rather than a nominal safe value.
  • HulkHulk Posts: 68
    edited 2010-02-03 00:15
    I'll hijack a bit since the original·question has been answered.

    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?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    ·
  • ercoerco Posts: 20,260
    edited 2010-02-03 00:50
    Rich:

    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."
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-03 02:42
    erco said...

    And don't forget that flyback diode across your coil, too!

    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 Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-03 03:20
    W9GFO said...
    Diode shmiode, are you sure they are necessary?
    Yes.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2010-02-03 04:18
    Use a diode across the coil for protection and put a small resistor (~10 ohms) in series with each pin and you should be OK.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-03 04:26
    I've tried and tried but I cannot detect any spikes using my oscilloscope. Any ideas on why the spike doesn't show up on the scope? How likely is it that the relay has a diode built in, but not mentioned in the datasheet?

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-03 04:32
    The spikes may be shorter than your scope's response. What is the bandwidth of your scope?

    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
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-03 04:51
    It is 20 mhz.

    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.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-03 04:59
    Yes, a 1N4148 diode should do fine.
  • ercoerco Posts: 20,260
    edited 2010-02-03 05:15
    Rich: You need the flyback diodes even if you add transistor drivers.

    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
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-03 05:53
    erco said...
    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?
    The pin voltage drops to 3.7 volts (3.0V to the relay), with VDD at 4.9V. I just tried again and it will sometimes trip the relay but not usually.
    erco said...
    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.
    The Pic 12f683 can source or sink 25 mA.
    erco said...
    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.
    I'm using N14148s - and no offense taken. smile.gif
    erco said...
    The voltage-dropping diode Phil 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.
    The TX2-5Vs are polarized also.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • ercoerco Posts: 20,260
    edited 2010-02-03 06:08
    XLNT, love those Aromat/NAIS relays. If your pin voltage is dropping down to 3.7 V (internal series resistor or current limiting ?) then you're in no danger of pulling more than 20 mA through that relay anyway, even without a diode or resistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-03 06:34
    The "input protection diode" I was referring to is the one internal to the PIC, not something in series with the pin. Also, it's virtually a rule that the voltage on a pin sourcing its maximum rated current will be well below Vdd, and the the voltage on a pin sinking its maximum rated current will be well above Vss, just due to the driver's internal resistance (RDS).

    Here's an illustration of the recommended relay driver, being fed by a typical CMOS output structure with its internal protection diodes:

    attachment.php?attachmentid=67387

    -Phil

    _
    347 x 314 - 3K
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-04 19:18
    Here is a schematic, I am trying to save as much board space as possible in an effort to make enough room for both relays - still not sure it will all fit. Three of the resistors perform two functions. What design rules am I breaking now? smile.gif

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 2/4/2010 7:48:39 PM GMT
    1115 x 632 - 112K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-04 19:24
    Your LEDs will not come on, since their forward voltage is greater than that of the base-emitter junctions of the transistors, which they parallel. You will need to go series resistor -> LED to ground -> series resistor to get them to light. Or ... you could put them in series with the transistor bases, assuming they're not blue or white. (Use something with a low forward voltage.)

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 2/4/2010 7:29:34 PM GMT
  • W9GFOW9GFO Posts: 4,010
    edited 2010-02-04 19:30
    Ahh, I see.

    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:

    attachment.php?attachmentid=67433

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 2/4/2010 7:50:28 PM GMT
    907 x 532 - 84K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-04 19:46
    Yes, that's what I meant by "in series with the transistor bases." But use low Vfwd LEDs, not blue or white ones, else you might not have enough drive left over for the transistors.

    -Phil
Sign In or Register to comment.