Driving a 3 digit 7 segment LED with MCP23017

Thread Starter

ilium007

Joined Aug 24, 2013
139
I need to drive a common anode 3 digit 7 segment LED from a microcontroller. The device has one common anode per digit. I will be writing the multiplexing code to control.

I don't want to consume 11 pins on the microcontroller so the obvious choice is some sort of IO expander. I see products using shift registers but I'd like try and use the I2C interface available on the microcontroller.

I'm considering using a single MCP23017 to drive 3 small PNP MOSFETs for the common anode pins and then directly drive the 8 LED segments via current limiting resistors.

I don't see any other way around using the PNP MOSFETs as the MCP23017 has a max 25mA rating per I/O pin sinking or sourcing.

If I ran the LED segments at 5mA each I would be sourcing 45mA on the anode pins (12,9,8 below). I'm not even sure if I could source current from one MCP23017 pin and then sink it into another.

If I used a shift registers such as the 8-bit TPIC6B595 I would need 2 for 11 pins on the display.

I realise there may be LED driver IC's also but liked the idea of I2C control of these little displays.


ECBD292D-975A-4393-B72A-9CBAEF1ACA92.jpeg
 

MrChips

Joined Oct 2, 2009
30,701
You can use a 74LS47 BCD to 7-segment decoder/driver (5V operation) to take 4-bit BCD from your MCU.
This reduces the number of output pins from 10 to 7 (sans decimal point).

Or you can use a serial communication interface which can potentially reduce the number of I/O pins to one.
 

Ian0

Joined Aug 7, 2020
9,667
Do you have time for the software overhead required for multiplexing? If not try the Texas TLC5952. Only 3 GPIO required. Even easier if you have a spare SPI port. Constant current outputs, so no limiting resistors required.
 

djsfantasi

Joined Apr 11, 2010
9,156
What was your reasoning for not using a 74HC595? Only that you want to use I2C?

Because an I2C solution is more complicated device count-wise, power-wise, software-wise (albeit the complexity is hidden and may only affect resources available for the remainder of the functions)…
 

dendad

Joined Feb 20, 2016
4,451
Why do you want to use LEDs?
My choice would be an I2C LCD or OLED display. Way more versatile.
But using the 74LS47 as @MrChips mentioned as the segment driver is a good idea.
The display multiplexing will take a fair bit of your processing time. It could be a good learning project to get it all going well.
 

MrSalts

Joined Apr 2, 2020
2,767
If you're going the I/O expander route with l2C, you may as well use an LED driver chip that woks the same way but allows current control (and possibly switch scanning).
one example is below but shortages limit options.
https://www.mouser.com/ProductDetail/Maxim-Integrated/MAX6955AAX+?qs=1THa7WoU59HHiplILEoAzQ==

alternatively, adafruit makes a feather board that is all setup for you if 4+digits are ok. Pricy at $10 but simple and fast if you only need a few.
 

Thread Starter

ilium007

Joined Aug 24, 2013
139
How many pins are you willing to use?
2 - 3 preferred

What was your reasoning for not using a 74HC595? Only that you want to use I2C?
No real reason. I have micropython libraries for the shift registers and the MCP23017. Initially I thought I might be able to use the MCP23017 outputs to source current for the digit select pins rather than using three discrete PNP devices.

Why do you want to use LEDs?
My choice would be an I2C LCD or OLED display. Way more versatile.
I the past few weeks I’ve had two OLED displays fail (screen so dim they’re unusable) and thought an LED segment display may be more robust. Also the project is running micropython and I’m not sure how big the oled display libraries are.

If you're going the I/O expander route with l2C, you may as well use an LED driver chip that woks the same way but allows current control (and possibly switch scanning).
one example is below but shortages limit options.
https://www.mouser.com/ProductDetail/Maxim-Integrated/MAX6955AAX+?qs=1THa7WoU59HHiplILEoAzQ==

alternatively, adafruit makes a feather board that is all setup for you if 4+digits are ok. Pricy at $10 but simple and fast if you only need a few.
That MAX6955 ic is $30.77 AUD !!!! With no stock in Australia.
 

MrSalts

Joined Apr 2, 2020
2,767
That MAX6955 ic is $30.77 AUD !!!! With no stock in Australia.
There are similar chips, that was just one I've used before and it was about 3 USD at the time. LEDs are an expensive display option these days. As mentioned above, LCD with back light can be cheaper and easier to mount for a hidden until lit effect behind tinted glass or plastic.
 

Ya’akov

Joined Jan 27, 2019
9,068
I saw that you said you weren’t interested in an LED driver, but just in case you decide to take an alternate route, the MAX7219 handles 7 segment displays and there is a MicroPython library available.

Just one thing: The price is high if you buy from ”reputable” dealers. Adafruit has them for ~$13 a piece! But, I recently bought 5 8 digit 7-segment display boards with both a MAX7219 and the LEDs for ~13. They work perfectly. The chip is in an SOP so desoldering it wouldn’t be very difficult. You also get bonus display parts if you need or want them.

So not as a suggestion to replace your learning project but as a data point should you decide to go a different way, there it is.
 

Thread Starter

ilium007

Joined Aug 24, 2013
139
There are similar chips, that was just one I've used before and it was about 3 USD at the time. LEDs are an expensive display option these days. As mentioned above, LCD with back light can be cheaper and easier to mount for a hidden until lit effect behind tinted glass or plastic.
I’ll look into LCDs. Hadn’t considered them until now.
 

Thread Starter

ilium007

Joined Aug 24, 2013
139
I saw that you said you weren’t interested in an LED driver, but just in case you decide to take an alternate route, the MAX7219 handles 7 segment displays and there is a MicroPython library available.

Just one thing: The price is high if you buy from ”reputable” dealers. Adafruit has them for ~$13 a piece! But, I recently bought 5 8 digit 7-segment display boards with both a MAX7219 and the LEDs for ~13. They work perfectly. The chip is in an SOP so desoldering it wouldn’t be very difficult. You also get bonus display parts if you need or want them.

So not as a suggestion to replace your learning project but as a data point should you decide to go a different way, there it is.
Excellent, I hadn’t thought of reclaiming components from other products like this. The MAX7219 looks perfect.
 

dendad

Joined Feb 20, 2016
4,451
I the past few weeks I’ve had two OLED displays fail (screen so dim they’re unusable) and thought an LED segment display may be more robust. Also the project is running micropython and I’m not sure how big the oled display libraries are.
I wonder why they failed. Did they overheat? If it is a hot environment, LEDs may be bet to stick with.
Just a note, I have had LED displays fail too. (but no OLEDs as yet, other than the 3.3V displays I tried on 5V !!)

You can buy a completely assembled display module.
TM1637 4-digit LED display module
6x4LED_.jpg
6 off these for $24AU is not too bad.
 

Thread Starter

ilium007

Joined Aug 24, 2013
139
I wonder why they failed. Did they overheat? If it is a hot environment, LEDs may be bet to stick with.
They were both in my office on the western side of the house and the room got very hot in the afternoon sun. I've had both devices in other houses and never had an issue before over the 3 years that I've owned them.
 
Top