Author Topic: Powering 90 LEDs at once  (Read 1495 times)

0 Members and 2 Guests are viewing this topic.

Offline FearTecTopic starter

  • Regular Contributor
  • *
  • Posts: 74
  • Country: au
  • Coding Arduinos etc, 90% electronics newbie.
    • Personal Blog
Powering 90 LEDs at once
« on: November 06, 2021, 07:56:26 am »
Hello

I am wanting to power 90 LEDs at once from a Raspberry Pi. I have written an API to read data from 20x Wemos mini and now it's time to output data via leds.

I have 6x MCP23017 - I2C 16 INPUT/OUTPUT PORT EXPANDER

From: https://core-electronics.com.au/mcp23017-i2c-16-input-output-port-expander.html

Datasheet: https://cdn-shop.adafruit.com/datasheets/mcp23017.pdf

The problem is they cannot drive many 20mA leds.

What is the best way to drive higher voltage to the leds seperate to the Pi and MCP23017?

Should I use a shift register, transistor or mosfet? Any suggestions
Coder and electronics newbie.
 

Offline Capernicus

  • Frequent Contributor
  • **
  • !
  • Posts: 483
  • Country: au
Re: Powering 90 LEDs at once
« Reply #1 on: November 06, 2021, 08:01:03 am »
What type of LED is it?

If they are just the normal variety,    put them in parallel,  then its 20mA * LEDS amps required at 2 volt.  (1.8 amps.)

If you put them in series, then its 2VOLTS*LEDS, requirement. (voltage.)

Yes, sounds like u need transistor, cause an arduino cant put out that much volts or amps (but its close 2 amps?  maybe u can??),  and u want to switch it from the arduino.
« Last Edit: November 06, 2021, 08:04:45 am by Capernicus »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8724
  • Country: fi
Re: Powering 90 LEDs at once
« Reply #2 on: November 06, 2021, 08:01:46 am »
90 LEDs controlled as one single group? Or control them separately?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13034
Re: Powering 90 LEDs at once
« Reply #3 on: November 06, 2021, 08:39:06 am »
I'm assuming from the "6x MCP23017 - I2C 16 INPUT/OUTPUT PORT EXPANDER" which would give 96 expander I/O pins, that individual LED control is required.

Do the LEDs *really* require 20mA for adequate brightness or is that just their nominal IF_max current rating?

Modern indicator LEDs typically have plenty of brightness at a small fraction of their IF_max rating, so if you design for an IF of 8mA, you can connect 15 LEDs per MCP23017, cathode to the expander output so they are sinking not sourcing, and you wont exceed 80% of its 150mA abs. max Vss current limit.

N.B. the MCP23017 needs to run at 5V Vdd so its low side output MOSFETs turn on hard enough to sink 8mA without excessive voltage drop, so you'll need to level shift the I2C bus to them.

If you hadn't already bought the MCP23017 chips (or have another use for them), it would be preferable to use dedicated serial (SPI or I2C) interface constant current LED drivers that use a single resistor to set all their output currents rather than GPIO expanders, which would need a current limiting resistor for each LED.
« Last Edit: November 07, 2021, 09:16:42 pm by Ian.M »
 

Offline jbeng

  • Regular Contributor
  • *
  • Posts: 52
  • Country: us
Re: Powering 90 LEDs at once
« Reply #4 on: November 07, 2021, 05:44:45 am »
If a multiplexed display is acceptable, you might consider using MAX7219 LED driver chips.
Each chip can drive 64 LEDs and they are cascadable, so you'd need 2 (for a maximum of 128 LEDs total).

Datasheet:
https://www.mouser.com/datasheet/2/256/MAX7219_MAX7221-1513157.pdf
"It's such a fine line between stupid and clever" - David St. Hubbins
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5134
  • Country: ro
  • .
Re: Powering 90 LEDs at once
« Reply #5 on: November 07, 2021, 06:48:35 am »
There are various combinations of chemicals used to make different color LEDs, which results in LEDs having different forward voltages (minimum voltage from which led starts to light up) and at the same time depending on chemistry and color, the LEDs will have the same brightness at different current amounts.
Human eyes are also more sensitive to some colors, red and green mostly ... hence why we use red on semaphores because it's most easy to notice.

The 10-20mA on leds is mostly a default value, you will find that there's lots of modern leds that will be quite bright even at 5mA. Some "high brightness" red leds will be quite bright even at 1-2 mA.
The amount of brightness you will perceive will also depend on the lens of the led .. there's leds designed to have a big spread (ex 120 degree spread) and there's leds that focus the light coming out in a narrower angle, like a flashlight.
These narrow angle leds will be much brighter at lower currents, but if you lay flat your device with the leds on the desk and you sit on a chair, you may have difficulty viewing which leds are bright because your eyes are at a too wide angle to see the color.

Port expanders are overkill for this. Those would be useful if you have to mix leds with buttons, if you need inputs, lots of things.

There are simpler options like led drivers for example. Some led drivers are super simple, behaving like shift registers... for example you simply shift 8 bits into the chip using a data and a clock wire, and then you enable the chip to switch the 8 leds to the state of those bits. The current of the 8 leds is set using a single resistor and these led drivers can also be chained together, so for example, you could chain 12 such 8 channel led drivers to have maximum 96 leds - you would send  5 0 bits because 6 channels on a chip won't be used, and then you'd shift the 90 bits into the chained led drivers and hit the enable/latch to switch the state of all 96 channels in one shot, then repeat the process to get as much updates per second as you wish.

There are also such led drivers with 16 led channels, here's for example this STP16CPC26 led driver : https://www.digikey.com/en/products/detail/stmicroelectronics/STP16CPC26MTR/2772228
If you look at the datasheet, you will see it has a data in and clock to shift bits in, a black to reset all leds to 0, a latch to update all leds according to the bits shifted in and and even an output enabled pin should you wish to use it.
You can chain multiple such chips by connecting SO pin to the next pins, data pin and connecting the clock pins together.
You can also see that you can control the current down to at least 5mA on this chip through a single resistor.

There's other examples like CAT4016 for example but it's a bit harder to solder : https://www.digikey.com/en/products/detail/onsemi/CAT4016HV6-GT2/2193932
It can however output as little as 2mA on each channel and would use less space on a circuit board.


There's also drivers which can drive more leds and use i2c, like for example this 36 led channel IS31FL3236 : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS31FL3236A-TQLS4-TR/14308337
You can have 3 of these on the same i2c and you set each chips address through resistors because each device on a i2c bus needs a unique address, and then you can simply send 36 bits to each led driver through i2c

You should also consider multiplexing ... you don't necessarily need to have  12 x 8 bit led drivers, or 8 16 bit port expanders.

You could have for example only 2 x 16 bit led drivers  and connect 3 leds on each channel. Depending on which led receives power, only that led  lights up when the channel is enabled .
You will turn on power to sets of 32 leds through a transistor or mosfet.

So in your code, you could set the 32 bits to the state of the first 32 leds, send power to the first 32 leds and you'll get the first 32 leds working.  Wait a few milliseconds,  then turn off power going to the first 32 leds, send the 32 bits for the next set of 32 leds and turn on power to 2nd set, wait a few milliseconds and continue with next set of 32, and then loop back to the first set of 32 leds.
Because of retention you will see all 3 x 32 leds working.
 

 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12496
  • Country: ch
Re: Powering 90 LEDs at once
« Reply #6 on: November 07, 2021, 08:28:21 pm »
The 10-20mA on leds is mostly a default value, you will find that there's lots of modern leds that will be quite bright even at 5mA. Some "high brightness" red leds will be quite bright even at 1-2 mA.
Many modern green, blue and white LEDs are so efficient that they are plainly visible at 0.1mA. (Not a typo.) I’ve driven internal diagnostic LEDs at just 10μA.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12496
  • Country: ch
Re: Powering 90 LEDs at once
« Reply #7 on: November 07, 2021, 08:36:56 pm »
Hello

I am wanting to power 90 LEDs at once from a Raspberry Pi. I have written an API to read data from 20x Wemos mini and now it's time to output data via leds.

I have 6x MCP23017 - I2C 16 INPUT/OUTPUT PORT EXPANDER

From: https://core-electronics.com.au/mcp23017-i2c-16-input-output-port-expander.html

Datasheet: https://cdn-shop.adafruit.com/datasheets/mcp23017.pdf

The problem is they cannot drive many 20mA leds.

What is the best way to drive higher voltage to the leds seperate to the Pi and MCP23017?

Should I use a shift register, transistor or mosfet? Any suggestions
None of the above. Use an LED driver. If you want to stay with I2C, look at the NXP PCA9634. It’s a bit more expensive than the MCP23017, but you don’t need anything else since it’s purpose-built for LEDs, and adds the ability to dim them individually too.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3806
  • Country: nl
Re: Powering 90 LEDs at once
« Reply #8 on: November 08, 2021, 12:40:45 am »
If you're willing to use series resistors for each led (as you do now) then why not use a 50ct 74hc595 shift register?

Or instead of the MCP23017, just use any microcontroller you're comfortable with and write a small program for it.
This also allows you to add custom functions.
The first time you're writing a program to use a custom microcontroller as an "advanced I/O expander" takes some work, but if you've done it a few times it's easy to make variations of it.

There are also many dedicated LED driver chips. With or without built in multiplexing. TI has some. the HT16k33 is another one, and it can be combined with keyboard scanning.
 

Offline FearTecTopic starter

  • Regular Contributor
  • *
  • Posts: 74
  • Country: au
  • Coding Arduinos etc, 90% electronics newbie.
    • Personal Blog
Re: Powering 90 LEDs at once
« Reply #9 on: November 09, 2021, 09:40:55 pm »
OMG, many good replies there.

They are standard 5mm LEDS

I am using a Raspberry Pi 4 8GB and am writing a Node JS API to receive data from 20x sensor (WeMos Mini D1 Pro).

Depending on activity I will have these leds (+ Power LEDS)

- 20x GREEN LEDs will be (Sensor is OK and Reporting or has reported in 5 mins)
- 20x ORANGE LEDs will be Sensor is Reporting Now)
- 20x RED LEDs will be Sensor is Not Reporting (Login and Check Values or reboot)

I have some MCP23017, Shift Registers (SN74HC595) and NPN 2N2222A Transistors to try.

fyi: Project log is here with all code https://fearby.com/article/homepi-raspberry-pi-powered-touch-screen-showing-information-from-house-wide-sensors/

Coder and electronics newbie.
 

Offline FearTecTopic starter

  • Regular Contributor
  • *
  • Posts: 74
  • Country: au
  • Coding Arduinos etc, 90% electronics newbie.
    • Personal Blog
Re: Powering 90 LEDs at once
« Reply #10 on: November 09, 2021, 09:41:40 pm »
P.S I don't mine using many resistors (1 per LED)
Coder and electronics newbie.
 

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 8199
  • Country: us
  • Retired, now restoring antique test equipment
Re: Powering 90 LEDs at once
« Reply #11 on: November 09, 2021, 09:54:52 pm »
In general, never put diodes of any kind (rectifier, Zener, or LED) directly in parallel.  If there be a series resistor for each LED, then you may put the series combinations (one resistor, one LED) in parallel with each other.  It is acceptable to wire LEDs in series (even different colors) if equal currents are desired (the brightnesses will be different for different colors).
Diode current is approximately exponential in the applied voltage, so a small difference in the co-efficient will make a larger difference in the current (without balancing resistors) and one device will “hog” the available current.
 
The following users thanked this post: tooki

Offline TimFox

  • Super Contributor
  • ***
  • Posts: 8199
  • Country: us
  • Retired, now restoring antique test equipment
Re: Powering 90 LEDs at once
« Reply #12 on: November 09, 2021, 09:56:02 pm »
What type of LED is it?

If they are just the normal variety,    put them in parallel,  then its 20mA * LEDS amps required at 2 volt.  (1.8 amps.)

If you put them in series, then its 2VOLTS*LEDS, requirement. (voltage.)

Yes, sounds like u need transistor, cause an arduino cant put out that much volts or amps (but its close 2 amps?  maybe u can??),  and u want to switch it from the arduino.

No.  Do not wire LEDs directly in parallel (see above).
 
The following users thanked this post: tooki


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf