Shop OBEX P1 Docs P2 Docs Learn Events
Can I use 2 IO pins to increase current to a load? — Parallax Forums

Can I use 2 IO pins to increase current to a load?

william chanwilliam chan Posts: 1,326
edited 2008-12-21 04:22 in Propeller 1
Hi,

Let's say I need to drive a IR LED directly from a IO pin using Counter A.

Since the IO pin can only source about 30mA, which is a bit weak, can Counter A be configured to create the 38Khz carrier wave on 2 IO pins simultaneously, to drive the IRED?

Should I use IO pins that are not adjacent to each other?

Thanks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-12-20 03:30
    william chan,

    It's not a good a good idea or practice to parallel I/O pins... A much better solution is to use a transistor to buffer the signal and provide more current drive.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • william chanwilliam chan Posts: 1,326
    edited 2008-12-20 03:47
    If it works well, why not?
    As you know, I am always looking for ways to save costs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-12-20 04:06
    Like Beau said, it's not a good idea or practice, he didn't say you can't do it, but there are problems with this approach. The problem is that if your software stuffs up (which it will) then you may have one output high and one output low and that ain't gonna make the prop happy and it's going to cost $$. Also since you are driving an IR LED you really want to pulse them hard so why wouldn't you use a 5 cent NPN?

    Willy,are you sure you're not a bean counter wink.gif or is this an exercise in absolute frugality at the expense of good engineering?

    *Peter*
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-20 04:30
    William, using the counters you can typically only specify one pin for output anyway. There are modes (differential) that allow a second pin using the B output, but they are opposite state.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-20 07:53
    Paralleling two output pins (or two transistors, etc.) is generally unwise, for several reasons.· Among them:

    (1)· Unequal current sharing.· Each pin sources current through a transistor when high, and sinks current through another transistor when low.· Unless these transistors are perfectly matched (nearly impossible), the one on one of the pins will have a slightly lower saturation voltage than the one on the other pin, and the result will be that one pin sources most of the current, or sinks most of the current.· You can avoid this by using separate resistors to each pin.· If, for example, your calculations show that using 100 ohms will give the desired 60 ma (this depends upon the drop at the LED and you must calculate it yourself) -- if, I say,·you calculate 100 ohms total, then use 200 ohms at each pin, both connected to the LED but separately connected to each pin.· Each pin will then supply half the needed total current.

    (2) Unequal·transition timing.· If the pins are connected directly together, and one switches more slowly than the other, or later than the other (very possible, perhaps even certain), there will·a time·when one is high and the other is low, or when one is high or low and the other is transitioning.· This will cause an amazingly large current through both pins (into one and out of the other) for a brief time.· Don't be lulled by the brevity of this current·pulse.· Transistor structures on an IC are so small that local heating of this nature can cause damage within nanoseconds -- especially when it occurs repeatedly.

    Bottom line:· don't connect the pins together, ever.· However, if you use separate resistors as suggested under (1) above, these resistors will not only assure against unequal current in the two pins, but·also protect against the problem described in (2).· You mustn't connect the two pins together, but you can feed a single load (your LED) from two pins simultaneously, as long as you use separate current-limiting resistors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net

    Post Edited (Carl Hayes) : 12/20/2008 8:02:29 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-20 08:33
    Carl,

    I think your idea of using separate current-limiting resistors satisfies every objection to paralleling outputs mentioned here, including software errors. (The typical Propeller video DAC is a perfect example of this, although the outputs are "paralleled" for a different reason.) My only issue — and it's a small quibble — is with your assertion (1) as it applies to CMOS outputs. Since a MOS transistor's output characteristic is largely resistive in nature, load sharing among multiple outputs tends to be self-balancing. Hard-wired paralleling is a definite no-no with bipolar transistor outputs since, as you rightly point out, the saturation voltages can differ, resulting in wildly uneven load sharing.

    William,

    Pursuant to Chris's observation, you'd have to use (and synchronize) two counters to pull this off.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Just a few PropSTICK Kit bare PCBs left!

    Post Edited (Phil Pilgrim (PhiPi)) : 12/20/2008 8:44:04 AM GMT
  • william chanwilliam chan Posts: 1,326
    edited 2008-12-20 10:20
    Is it possible to set DIRA[noparse][[/noparse]x] and DIRA[noparse][[/noparse]y] simultaneously in SPIN?
    and also the 2 counter phases simultaneously?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.fd.com.my
    www.mercedes.com.my
  • PraxisPraxis Posts: 333
    edited 2008-12-20 13:43
    William kawan saya, satu transistor tidak lagi mahal dan prop chip lagi selamat.

    Pendapat saya.

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Adequatio Rei Et Intellectus
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-20 14:53
    William,
    You can set any combination of bits of DIRA (or OUTA or anything) simultaneously by using the bit logical operations on the whole value like:

    DIRA |= (|< x) | (|< y)

    or

    DIRA |= %0000_0101_0000_1010

    Similarly, you can reset any combination of bits with:

    OUTA &= !((|< x) | (|< y))

    or

    OUTA &= ! %0000_0101_0000_1010

    or the equivalent (but not as understandable)

    OUTA &= %1111_1010_1111_0101


    You can't set the two phase counters (or any two longs) simultaneously.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-12-20 15:24
    As Mike said, you can't set two PHS(X) registers simultaneously, but you can offset one of them to compensate for the execution lag as you set them one at a time. This would probably only work in PASM.

    I agree with the others. If you need higher current, add a transistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-20 15:53
    Phil Pilgrim (PhiPi) said...
    Carl,

    My only issue — and it's a small quibble — is with your assertion (1) as it applies to CMOS outputs. Since a MOS transistor's output characteristic is largely resistive in nature, load sharing among multiple outputs tends to be self-balancing.
    That's true, Phil, as long as the FETs are well matched.··It's truer in the linear region than it is at saturation, though, and it may be truer with enhancement-mode FETs than with depletion-mode FETs, or vice versa; I'm uncertain.· Any imbalance will certainly be exacerbated by unequal heating resulting from initially unequal current.· Do we know what flavor of FETs are in the Propeller's outputs?· I didn't even know they were FETs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-20 18:03
    William,

    If it were me, I'd use a transistor, too. The price adder for a single bipolar transistor isn't going to matter that much. Depending on what else your circuit uses, you might be able to combine functions (i.e. dual NPN) to save pick-and-place costs, at least. Plus, there'd be less stress on the Propeller.

    On a theoretical level, this has been an interesting discussion and, with two resistors and the appropriate PASM code, you could probably get by without the transistor. But just to save a couple pennies, compared to the cost of the Propeller itself?

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Just a few PropSTICK Kit bare PCBs left!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-12-20 18:22
    Carl,

    The output transistors in the Propeller should be well-matched, since they're on the same substrate, use identical features, are are subject to the same environmental conditions during manufacture and (between adjacent pins) nearly identical thermal conditions during operation. Moreover, because the RDS(on) transfer characteristic of a MOSFET has a positive temperature coefficient, load imbalances tend to be self-limiting, rather than exacerbated. Nonetheless, it's still bad practice to parallel the outputs directly, for the other reasons cited.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Just a few PropSTICK Kit bare PCBs left!
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2008-12-20 20:50
    "Don't cross the streams."
    Your asking for the type of weird trouble that shows up unexpectedly late one night after you've long forgotten about the paralleled ports.
    Jim-

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Signature space for rent, only $1.
    Send cash and signature to CannibalRobotics.
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-12-21 04:22
    Phil Pilgrim (PhiPi) said...
    Carl,

    The output transistors in the Propeller should be well-matched, since they're on the same substrate, use identical features, are are subject to the same environmental conditions during manufacture and (between adjacent pins) nearly identical thermal conditions during operation. Moreover, because the RDS(on) transfer characteristic of a MOSFET has a positive temperature coefficient, load imbalances tend to be self-limiting, rather than exacerbated. Nonetheless, it's still bad practice to parallel the outputs directly, for the other reasons cited.

    -Phil

    Interesting.· I hadn't known that MOSFETs had that positive coefficient.· I tried to check up on you, but all of my data books are old, and none mention that parameter at all.· I had made an assumption, without even realizing it was an assumption.

    The output transistors should be well matched, but I never trust things like that.· I've been burned.· Still, like you, I would never parallel the outputs, but through separate resistors into a single load I would have no qualms at all.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
Sign In or Register to comment.