Author Topic: Driving 40 led's with MCU  (Read 1754 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.takniki

  • Frequent Contributor
  • **
  • Posts: 368
Driving 40 led's with MCU
« on: April 09, 2015, 10:43:30 am »
I have 40 led's connected to each pin of MCU. M
Now MCU can't drive each led. So waht I am thinking of right now is to drive 2n7002 gate with each pin which will drive the led. In this I have to connect 40 2n7002.

Any other better solution for this.

1. MCU is 3.3V powered.
2. Have to individually control each led.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 7367
  • Country: nz
Re: Driving 40 led's with MCU
« Reply #1 on: April 09, 2015, 11:03:15 am »
Do you have 40 leds on each pin or 1 led on 40 pins?

If you want to drive lots of LEDs google "led multiplexing"

 
« Last Edit: April 09, 2015, 11:05:02 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline mcinque

  • Supporter
  • ****
  • Posts: 1034
  • Country: it
  • I know one thing: that I know nothing
Re: Driving 40 led's with MCU
« Reply #2 on: April 09, 2015, 11:16:47 am »
if you would have 40 MCU free pins and the matter is only about the current that the MCU can't provide, you could use small fets (like ZVN) to drive each single led, otherwise if it's a matter of free pins you could use shift registers.
I'm basically still a rookie and because of this, even with the best intentions, I often say bullshits
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 3833
  • Country: ro
  • .
Re: Driving 40 led's with MCU
« Reply #3 on: April 09, 2015, 11:20:41 am »
The microcontroller can't provide enough power to light up 40 leds at the same time.

There are some limits in regards to how much power can be provided on each pin, and how much power can be provided through all pins - for example, each pin could output 10-20mA but the microcontroller may only be able to do 100-150mA through all pins.

You can use transistors or mosfets to turn on or off leds... mosfets would be better because with transistors you'd still use a bit of power (under 1mA for each transistor) to turn the transistor on and off. Note that normally you'd still have to use at least one resistor to limit the current going through the leds, you don't want to limit the current using the transistor.

If you don't want to use additional parts, you can do multiplexing ... for example see tip 2 in this collection of tips and tricks from microchip: http://ww1.microchip.com/downloads/en/DeviceDoc/01146B.pdf 
You can easily expand this trick to 40 leds and to work around the limitations of the power, you can add code to turn on and off leds very fast so that at any time, only 10 or 20 out of those 40 leds are turned on.
 
A proper way to do it would be to use led drivers, there are chips that can control up to 16 leds.. the microcontroller simply sends a series of bits to the chip and the chip takes care of limiting current to each led and turning them on and off according to the bits you send.
Other solutions, cheaper and without complexity, that are normally used are shift registers (send stream of bits to shift register, shift register then turns on or off 8 pins to which you can connect leds) or darlington arrays like uln2003a for example (google it and read datasheet).
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 13171
  • Country: gb
  • 0999
Re: Driving 40 led's with MCU
« Reply #4 on: April 09, 2015, 02:14:25 pm »
How much current do the LEDs need to be bright enough?

Modern LEDs are often bright enough with 1mA so you might be able to connect them to the MCU outputs via resistors alone.
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 1978
  • Country: ca
Re: Driving 40 led's with MCU
« Reply #5 on: April 09, 2015, 02:24:38 pm »
I agree about using a low current. Many modern LEDs are very bright at just 1 or 2 mA.

If you need more current and don't want to mess around with 40 FETs and 40 current limiting resistors, then you can try an LED driver IC like the TLC5940. These can be had for roughly $1.50 each and drive 16 LEDs each, without needing per-LED series resistors. They use an SPI serial input and can be cascaded, so you can drive 40 (or many more) LEDs with just 3 pins of your micro.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf