0
\$\begingroup\$

I want to drive an 40 mA LED on a single I/O-Port:

possible ways?

I've forgot to draw the LED in the right version but i hope you get the idea. So my actual question: Since my PIC 12F isn't able to drive currents above 20 mA I may use the right circuit for supplying that current. But by using voltage/current directly from my source it may also be possible to achive the same with fewer parts - at least i think it is...

So what's my error in reasoning? is it possible to use the left circuit without problems?

Thanks in advance.

EDIT: Additional (maybe dumb) Question - what's wrong about the following:

solution 2

I could manage to make a second port available...

2nd and Last Edit:

It's possible as mentioned here (german) - since I/O Ports are rare i may try using a FET anyway, thanks for all the answers

\$\endgroup\$

4 Answers 4

0
\$\begingroup\$

There's no error in your logic, you can't safely supply a directly attached LED with more current than the IO pin can safely sink or source.

End of story. Full stop.

Using a FET instead of a BJT would mean one fewer parts (base current limiter not needed).

\$\endgroup\$
1
  • \$\begingroup\$ Yeah i see...25 mA sink current at the PIC 12F (of course it's in the datasheet, i've should have looked harder) thank you for your answer and the hint about the FET - didn't think about that \$\endgroup\$
    – user36107
    Commented Jan 25, 2014 at 9:55
1
\$\begingroup\$

The issue with using a microcontroller's GPIO pin directly, to operate an LED brightly, is that the current that passes through the LED to light it up, also has to pass through the GPIO pin and out through the microcontroller's ground pin, for the circuit to be completed. This is called sinking of current.

While many microcontrollers are rated for sinking 20 mA or more through an individual GPIO pin, some are not. More of concern, when one has multiple such current sinking connections, these currents add up at the MCU's ground pin - which itself has a limit, differs from MCU to MCU.

Solution: Drive your LED with very low current if you absolutely must save on the transistor. A typical indicator LED will light up pretty brightly even with 3 or 5 mA of current - try it for yourself.

\$\endgroup\$
1
  • \$\begingroup\$ unfortunately 40 mA is required ... whats about tieing two output pins together, providing 40 mA current combined? (As mentioned in my edited post) \$\endgroup\$
    – user36107
    Commented Jan 25, 2014 at 10:58
0
\$\begingroup\$

The left circuit has a single port pin sinking current. The absolute maximum sink current on any port pin is 25mA for (say) a PIC12F1501. It may be different for the one you're using. Something like 20mA would be a reasonable limit, since you never want to get close to the absolute maximum.

enter image description here

A good solution for this sort of thing (if you really need 40mA) is to use a pre-biased transistor or a MOSFET with a logic level gate.

enter image description here

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ As already mentioned by RedGrittyBrick using a FET seems like the better idea. I take a look about the MOSFETs too, very nice, thanks \$\endgroup\$
    – user36107
    Commented Jan 25, 2014 at 10:05
  • \$\begingroup\$ Either BJT or MOSFET (FET) will work fine. There might be some slight advantage in price for the BJT and some advantage in voltage drop for the FET. \$\endgroup\$ Commented Jan 25, 2014 at 10:20
0
\$\begingroup\$

When driving the LED from 5V and you want to use a BJT, you can save the base resistor when using a emitter follower configuration. The emitter resistor together with the LED will double as base resistor.

schematic

simulate this circuit – Schematic created using CircuitLab

Where \$R_1 = \dfrac{V_{PIC,OUT} - V_{Q1,BE} - V_{D1,forward}}{I_{D1}} \approx \dfrac{4.7 - 0.7 - 2}{0.04} = 50 \Omega\$

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.