cancel
Showing results for 
Search instead for 
Did you mean: 

Driving 7 segment Display with STM8 - enough current?

SLasn.1
Associate II

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:

0693W000003OygRQAS.png

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

13 REPLIES 13
prain
Senior III

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.

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:

0693W000003P9JnQAK.png

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.

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.

It is Total current. even if you have 10 vdd pins you are limited to 80 ma.

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 😉

henry.dick
Senior II

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.

SLasn.1
Associate II

Exactly my thoughts henry 🙂

I made a test with the same 7 seg display:

  1. lit from a TM1620 IC without resistors (I guess it runs at 20-25 mA per segment)
  2. lit with a 100 ohm resistor (I measured 10mA per segment)
  3. lit with a 200 ohm resistor (I measured 6mA per segment)
  4. lit with a 330 ohm resistor (I measured 3.9mA per segment)
  5. lit with a 500ohm resistor (I measured 2.7mA per segment)

They are all multiplexed at a 1/3 duty (since I have a 3 digit display)

The result from my eyes:

  • Indoors (not particularly dark): 1 is way too bright, 2 & 3 look pretty much identical (and look ok), 4 & 5 also look very similar but start to look weak (the display is quite big - digits are 38mm tall).
  • Sunny outdoors - in the shade: 1 is ok, 2 & 3 are readable but look very dim, 4 & 5 are pretty much impossible to read
  • Sunny outdoors - in direct sunlight: they are all (including 1) nearly impossible to read, I can barely tell which segments are lit and which are not

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).

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:

  1. -
  2. 10mA -> 2.3V
  3. 6mA -> 2.1V
  4. 3.9mA -> 2.01V
  5. 2.7mA -> 1.95V

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 🙂

see Vce(sat) parameter in the transistor datasheet. Also MCU pin output voltages are not ideally 0 , VDD:

0693W000003POkUQAW.jpg