2020-08-11 12:16 PM
Hi again =)
I have a small project with an STM8 and I was thinking driving my 3-digit 7 segment display directly with the MCU in order to reduce the manufacturing price (I know some of these chips cost only a few cents but if I *can* do it directly from the MCU then is there a reason not to?).
This is my setup:
The display is common anode, and the transistors are PNP. Each blue label is directly connected to a pin on the MCU.
The MCU is a STM8L151G6U6.
The display datasheet says about 1.8V to 2.2V forward voltage and max 20mA current.
The datasheet of my STM8 says max 25mA per pin - so far so good. But it also says only 80mA on the VCC & VSS pins, and I only have one of each - if all 7 segments are on, the display will draw itself about 70mA of current which will all go through the VSS pin.
Then I also have 2 small LED's connected to the MCU, which will draw about 10mA of current, but this time from the VCC pin.
And clearly the MCU itself will draw a bit of current + a bit of current here and there on the other pins - my guess is that the limit of 80mA will probably be reached.
My questions:
1) Is it just overall a bad idea to drive the display directly from the/an MCU? (the code of the project is simple so CPU usage does not matter)
2) My first idea was to use 100 Ohm resistors - which will make it about 15mA per pin - and 107mA through VSS when all segments are on. What happens then - does the MCU simply limits the current or will it stop working correctly?
3) The display will be multiplexed, so the "peak" current will only be short and the average current will probably be lower than the maximum, does this change anything?
Thank you!!
Cheers
Simon
2020-08-11 07:58 PM
The MCU may damage permanently when you draw over rated current. Reliability is a key factor for a project, so spending a few cents worth. If it is a hobby project, go and test and inform us about results but otherwise don't do that.
2020-08-12 03:00 AM
Thanks for the answer and yes ok that's fair.
What if I upgrade the MCU to a STM8L151C8T6? Its datasheet shows the same values:
But this time there are two VSS pins. Should I understand the datasheet as 80mA per VSS pin or for the whole MCU?
And will the current will be spread between the two (knowing all my SegmentX signals are on the same Port)?
Because overall I should stay way below 160mA.
2020-08-12 03:14 AM
Or I could just change the resistors to 220 Ohm, reducing it to 6mA per segment, making it a 42mA maximum?
I have read online that 2mA (with a 1/3 duty) is still very bright on a 7-segment LED.
2020-08-12 03:23 AM
It is Total current. even if you have 10 vdd pins you are limited to 80 ma.
2020-08-12 11:04 AM
Ok thanks for the info. Then I guess the 220 Ohms is the way to go. That will make it both low cost and low power :)
I think I'll make a prototype with that and see if the display is too dark I will get a separate IC to handle it ;)
2020-08-13 08:32 AM
I'm looking at a 4-digit 7-segment display consuming a total of 6ma. Clearly visible under sun light and blindingly bright at dark.
You should try to light up yours and it wouldn't surprise me if it works well even at 1ma/digit. Unless you are using some really dim displays.
2020-08-14 07:58 AM
Exactly my thoughts henry :)
I made a test with the same 7 seg display:
They are all multiplexed at a 1/3 duty (since I have a 3 digit display)
The result from my eyes:
The first one is clearly the brightest, but actually indoors (not even in a dark environment), the first one is way too bright.
So my thoughts are that I should take into account that there will be a "filter" (like a reflective film) in front of the display only showing the lit segments? The final product is meant to be used both inside and outside (it should be possible to put it in the shade when using it on a sunny day).
2020-08-14 08:06 AM
Another thought regarding the calculated current:
I measured the voltage drop of the segments at 1.6V using a multimeter, the datasheet says "nominal" value is 2V at 20mA, max 2.5V (there is not min). But calculating the voltage drop from the measured current gives me much larger drops:
My guess is the NPN transistor also adds to the voltage drop a little - otherwise it is already at 2.3V @10mA, clearly way above the 2V of the datasheet at 20mA...
What do you guys think?
Thank you :)
2020-08-14 10:30 PM
see Vce(sat) parameter in the transistor datasheet. Also MCU pin output voltages are not ideally 0 , VDD: