PDA

View Full Version : Can I combine outputs for more current?



jswayze
- 28th May 2005, 03:51
I'm trying to power an "ultrabright" LED with a PIC12F629. Each PIC output is rated at 25ma, and the LED lights up just fine. However, I have an LED that requires about 45ma, and it's fairly dim on just one output. To solve this, I figured I could take another PIC output and tie it together with the first one. You get 5v out and twice the current.

Here's what happens:
With the first output connected to the LED and powering it, I attached a lead from the second output to the LED. The brightness increased and all was well.
Next, my program shut off the LED then turned it back on again. This time, nothing. I measured 0 volts at the combined output. If I took one output away I'd get my 5v again and the LED would light.

It seems that while the LED is on, if you add the additional output everything is OK, but if you turn it off and back on again, something happens to wipe out the voltage.

With my feeble brain and minimal experience I thought that maybe the current from one output was being diverted into the other output and somehow canceling them. I thought that a diode might do the trick, but I don't have one (will go to Radio Shack tomorrow and try)

Is it obvious what's happening here? I'm sure I'm violating some basic rule of electrical design, I just don't know what it is.

Thanks!

Jeff

Ron Marcus
- 28th May 2005, 13:44
I have used multiple outputs to run small motors up to 200mA(The maximum chip rating) with little problem. Let's see your code for turning the LED on, and, how are you limiting the current through the LED?

You do know that it would be better to run the LED with a transistor capable of the total current than a couple of pins from the PIC.

Try turning the port pins on as a whole. As in... PORTA = %000011, as opposed to individual pin switching. Also keep in mind, the PIC would rather pull to ground, than to B+.

Hope this helps,
Ron

jswayze
- 28th May 2005, 16:04
Here is my code for the whole program. Basically it switches two outputs based on the pulse width of two incoming signals.



' ---------------------------------------------
' Define aliases to the LED ports
' ---------------------------------------------
PWM1 var GPIO.0
PWM2 var GPIO.1
IO1A var GPIO.2
IO1B var GPIO.5
IO2 var GPIO.4


PwmCount1 var byte ' Count number of cycles for PWM1
PwmCount2 var byte ' Count number of cycles for PWM2

INTCON.6=0 ' Disable all unmasked Interrupts
INTCON.7=0 ' Disable Global Interrupts
CMCON = 7

'------------------------------
' Main program starts here
'------------------------------

input PWM1
input pwm2
output IO1A
output IO1B
output IO2

pwmcount1 = 0 ' Initialize PWM counter variables
pwmcount2 = 0

MAIN:

pulsin pwm1,1,PwmCount1
PULSin pwm2,1,PwmCount2
if Pwmcount1 > 140 then
IO1A = 1
IO1B = 1
else
IO1A = 0
IO1B = 0
endif

if Pwmcount2 > 140 then
IO2 = 1
else
IO2 = 0
endif

goto MAIN 'endless loop

END

I will try switching IOA and IOB simultaneously and see if that works.

Thanks,

Jeff

jswayze
- 28th May 2005, 16:52
Actuating the two output simultaneously seems to have done the trick. I used "GPIO = GPIO and %00100100" to turn them on and everything works as expected now.

I have another general question regarding power switching, but I'll open a new thread. Thanks for the help!

Jeff