## 7-segment LCD transistor calculations

21 posts / 0 new
Author
Message

Hello guys!

I recently started learning electronics on my own, never really had a chance to learn that at school. So I need some advice :)

I wanted to use Atmega16 to do some 7-segment LCD multiplexing. I will try to mutiplex 26 LCDs at the same time, not to use too much microcontrollers. I will only use 7 segments of the LCDs (no dot). To reduce number of pins needed, I decided to drive them in a 14pins x 13lcds configuration. This means each segment will be driven only 1/13th of the total time. I intend to use LCDs which have a maximum peak current of 80mA and a voltage drop of standard 2V. Because of the current limit, I thought I will drive each segment with an average of 5mA, thus peak current will reach a maximum of 5mA * 13 = 65mA (I want to increase the peak current so that LCDs won't look so dim). Because of the 14 pins that can be used at the same time, total current can become up to 65mA * 14 segments = 910mA. Because of this, the Atmega can neither source nor sink such current. Nor can it withstand a 65mA current if connected to the cathodes. So transistors is the obvious choice.

I decided to use an ULN2003 chip for cathodes (datasheet says it's Vce = 0.9V) and a PNP transistor for anode switching (SS8550, because of it's maximum current of 1.5A; Vce = -0.28V, hfe = 40 in worst case, Vbe = -1V). Everything is powered from a 5V power supply. My schematic for a single 'frame' of multiplexing looks like this (there will be 13 of these, connected to common ULN2003 chips):

I would like to ask you guys, if my calculations for current limiting resistors for segments and for that of transistor base are correct.

Because ULN2003 already have a 2.7k resistor on base input, we can connect the inputs directly to Atmega's pins. The outputs will work as low-side switches. Thus we first begin calculation for resistors R40-R53:

voltage drop on these resistors will be: 5V - 0.28V (T1.Vce) - 2V (led) - 0.9V (ULN.Vce) = 1.82V

resistor value: R = U / I = 1.82V / 65mA (current we want) = 28om

but let's select a 27om from the available values, so a current will be: I = U / R = 1.82V / 27om = ~67mA

total collector current we need will be 67mA * 14 segments = 938 mA

taking the worst case scenario for upper transistor hfe we get a base current: 938mA / 40 = 23.45mA       - for worst case let's select 24mA

voltage drop on R39: 5V - 1V = 4V

thus value of R39: R = U / I = 4V / 24mA = 166.6om       - for worst case let's take 160om

And here's my question for you: are my calculations right? Did I choose the right values from the datasheets to account for? Did I change the values for worst case scenarios right, so that all transistors will enter saturation without problems?

Atmega will have to sink a current of 24mA to run T1, and source some current into ULN2003. I am not sure though if it can handle both? Should I add some bigger resistor on input pins of ULN2003?

A strange circuit!  26 7-seg LED digits on a single display.   Very 20th century.   I assume that you will be using very bright modern 7-segment displays.

And you wish to do two digits lighted at a time with a multiplex of 13 LED sets.   And that you will be using 5 mA to light each digit (no decimal point).

At any time, the maximum current could be 70 mA (5 mA per segment * 14 segments).  But this condition would be unusual.  Most of the time only half of the segments will be lighted, so your average current is 35 mA for two digit displays.

The multiplexing doesn't increase the current use; it only dims the displays.  But modern high-bright 7-segment displays will retain a persistence-of-vision data display with a 1:13 duty cycle.   Note that the AVR will not be supplying the @35 mA to its port pins to drive the LEDs: the ULN2003 IC will.  The current used by the I/O ports of the AVR will be neglectable.  Also you will need 26 transistors and 26 logic pins to switch them.  Each transistor turns off /on an individual LED digit.

Excuse me for saying so, but unless you are needing to see 26 digits simultaneously in a very dark environment, then this is an ill-advised way to organize a display.   Your brain is not going to be absorbing 26 digits worth of LED digit data all at the same time, and the final result will have too many numbers displayed for you to focus on the numbers that you are actually working with at the moment.   Plus this is HUGE amount of physical wiring work to do by hand (or requiring an expensive custom Printed-Circuit Board).

I recommend instead a modern TFT screen, for example an inexpensive 240x320 2.4" display with a touch screen included.  You'll need to do some rework to get the MCUFRIEND_kbv library to work with the Mega16 (why the obsolete processor?), but it is not exceptionally difficult.  With a TFT you can put current data in large easy-to-read format and have the other 20+ numbers in small chars on the side of the display.  Plus they are cheap and easy to wire.  And you have the touch-screen interface that will replace all the buttons and potentiometers that you also need to wire into your Mega16 (and to program).

Is this a "fantasy" (i.e. cool if I could actually do it, one-of-a-kind) project?  Or, a piece of old equipment from the 1980s that has to be maintained and you can't find the original parts of the elaborate display?   I can't think of any other reason why someone would be futzing with a 28-digit multiplexed LED display in the modern age.

Hi and thanks for the response!

Starting from the end - it indeed is a one-of-a-kind project as I am trying to build a 737 MCP panel (something like this: http://img02.taobaocdn.com/imgex...). So the 7-segments are here to make it look like it does in original, replacing it with a more modern LCD display would not 'feel right'. And the project is indeed going to have it's own custom printed PCB. I do know having all segments lit at the same time will be rare, but I wanted to account for the worst case scenario.

Your first post mentions LCD (liquid crystal display) many times.  Are you trying to confuse us?

Change your title to LED and there references. I was confused as well.
I'd suggest you run a smaller number of digits in each chain. If you use devices like this: http://www.ti.com/lit/ds/symlink/tpic6c595.pdf
You'll decrease the amount of i/o required.
P channel mosfets might be a better choice for the anode drive.
Actually, after thinking a little more about the problem - there are specific ics that do all the work for you - that means less wiring. Google tm1637.
http://www.ebay.com.au/itm/LED-display-tube-module-TM1637-driver-4-Digit-7-segments-Yellow-Robotdyn-/222282398050?hash=item33c1103962:g:F8QAAOSwTA9X1~KB

Last Edited: Sat. Jan 28, 2017 - 11:52 PM

The display you show is an LED display, not LCD. It takes MUCH more current than any LCD. And, LCDs take "special" driving waveforms. Methinks you are confused about your display.

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

Interesting project!

I'll share a thought or two, (all untested!).

Driving large LED displays is very cool.

The ULN driver for the low side is fine, each channel is spec'd at 500 mA maximum, (you will be far below this).

You do, however, need to "fully turn on" the ULN driver channels, and the internal 2.7K base resistor is designed to do that.  Do NOT add another external current limiting resistor to the channel drivers.

The fine print / foot notes, for the electrical spec's for the micro tell how much current both each pin can source/sink, and the limits for the ports, some port and pin combinations, and the Vcc and ground pins to the micro.  You need to add everything up and make sure the design will be in spec.  If not, you need to possibly re-distribute your loads amongst more ports, or select a different micro with "better" spec's, or change the design to lighten the micro's load.

Next option, of course, is to break the project into a multi-micro design, with one Master driving data to one or more Slave micros.  At common intra-micro communications speeds with the small amount of data being transferred one is not even likely to need a "synch" signal, the human eye won't notice any delays, if it is coded well.

Next, why are you using a PNP for the high side driver?  Certainly doable, but these days I'd select a PFet instead of a PNP transistor.  The Source-Drain voltage drop is much smaller, as the RDSon is typically mOhms.  That leaves more voltage for more current to drive your LEDs, and more importantly dissipates less power in the transistor, so they run cooler.

Next, regardless of PFet or PNP you really must insure that they are FULLY turned "on", you don't want to have them running in a linear mode, or they will dissipate tons of energy as heat.

I'm not good at thermal design, others can chime in, but with PNP's running > 1 A you will very likely need a decent heat sink on them.  PFet's, perhaps not.

Finally, you might look at something like a Complementary Pair Enhancement Mode MosFet package, such as the DMC2038LVT.  This little 6-Pin device is specifically designed to be a micro to high side driver.  The micro drives the NFet, which then drives the PFet, which powers the load.

As the NFet draws a trivial gate current, for this project, you can ignore the current drawn by the NFet from the micro.  Example is shown in photo below, it was part of an Xmega project, so the Vcc is listed as 3V, for your project it will be 5V, and the Bluetooth Module Load will be replaced by your 7-Seg LED digit.

Don't omit the pull down resistor on the NFet's gate, it holds the two FET's off during the power up sequence for the micro, and keeps them out of their linear range.

Good luck with your project, do post a photo of your finished design!

JC

Last Edited: Sun. Jan 29, 2017 - 09:19 PM

You have got 26 7-seg displays.   4 MAX7219 will drive 32 7-seg.   All controlled with 3 or 4 wires from the AVR.   And you can program the brightness.

1/13 duty cycle is pushing it for multiplexing.   1/8 duty cycle is a reasonable limit.   And you need to look after the switching of high currents.  Using MAX7219 or similar LED driver ensures that this is done for you.

Incidentally,  if you are not experienced with software,  remember that if your program hangs in one place,  you have a massive steady current in the active digit.

David.

Last Edited: Sun. Jan 29, 2017 - 10:07 PM

The tm1637 driver was already suggested, let me add that its manufacturer Titan Micro also has other products that may be useful for your project:

http://www.titanmec.com/index.php/en/product/lists/typeid/59/p/1.html

For example, with the TM1629, which is a 16 segment x 8 character driver, you can have 2 digits on per multiplexing pulse (2x7 = 14, 2 lines will not be used) so you can lit 16 characters with one of these chips. The unused lines can be connected to status LEDs for example.

You can get these chips from AliExpress, biggest problem is figuring out the chinese datasheets.

I've been using one of these modules to test this chip family and they seem pretty fine. You can find an english version of the datasheet for the TM1638 here, they all have a similar SPI type interface.

edit: IMO, the (genuine) max7219 is way overpriced. You can buy chinese fakes, but they may be crap, I had one die on me after a month or so of continuous use. If you are going to buy chinese, better buy genuine chinese products like the TM16XX series.

Last Edited: Sun. Jan 29, 2017 - 11:38 PM

El Tangas wrote:

I've been using one of these modules to test this chip family and they seem pretty fine. You can find an english version of the datasheet for the TM1638 here, they all have a similar SPI type interface.

... and it is worth noting that the seller has zero idea of what he is selling, as witnessed by these product details supplied...

The rated speed: 9500 R.P.M
Temperature range:-10-70C
Txpect life: 25C L10 when expected life 50000 hours
Bearing structure: free maintenance dual ball bearings
Rotation direction: the wind from stents place eduction, facing the rotor counter-clockwise
The wiring way: + red-black signal: blue (blue line, the alarm line speed, it is necessary to pay attention to). Line about 20 cm long
The biggest air volume: 26.8 m / h
The electric motor protection : overload protection, wrong level protection and stall lock current protection
Minimum wind pressure : 0.. 120 Pa
Noise index : 41.9 dB (A)
Material qualitative material: glass fiber reinforced plastic, PBT shell, PA blades
Function explain: electronic reversing the rotor dc fans, complete electronic directional control components

Ross McKenzie ValuSoft Melbourne Australia

El Tangas wrote:

I've been using one of these modules to test this chip family and they seem pretty fine.

The eBay description says "common cathode".

This source of code... https://github.com/rjbatista/tm1... says "common anode".

Yours is which?

Ross McKenzie ValuSoft Melbourne Australia

valusoft wrote:

El Tangas wrote:

I've been using one of these modules to test this chip family and they seem pretty fine.

The eBay description says "common cathode".

This source of code... https://github.com/rjbatista/tm1... says "common anode".

Yours is which?

Mine (the Ebay one) is common cathode, it uses 8 segments for the characters, plus one segment for the corresponding LED (TM1638 can drive a max. of 10 segments). I just linked that page because the guy has a good translation of the datasheet, not because of his code, I wrote my own. There are at least 2 different english translations of the datasheet, but that one is better IMO.

The chip is designed to be used with common cathode (8 chars x 10 segments), you can see that by the current capabilities of the SEG (-50 mA, i.e. source) and GRID pins (+200 mA, i.e. sink). However, you can connect it to common anode too, it's also in the datasheet (8 segments x 10 chars), but since they will be "in reverse", I suppose the LEDs will be dimmer.

Thanks.

At A\$2.79 including postage, I just could not resist. Don't know what I will use it for yet, but a bargain is a bargain.

Ross McKenzie ValuSoft Melbourne Australia

I thought I should suggest that "All Electronics" has constant current LED drivers (16 per chip(!)) for \$1 each.   Serial interface.

They're tiny little things, so you'll have to be pretty fine with a soldering iron to use them.

Not employed nor paid by them, just a happy customer.

http://www.allelectronics.com/it...

Have fun,

S.

Scroungre wrote:

I thought I should suggest that "All Electronics" has constant current LED drivers (16 per chip(!)) for \$1 each.   Serial interface.

They're tiny little things, so you'll have to be pretty fine with a soldering iron to use them.

Not employed nor paid by them, just a happy customer.

http://www.allelectronics.com/it...

Have fun,

S.

No part/maker details. A "lucky dip" if ever I saw one.

Ross McKenzie ValuSoft Melbourne Australia

valusoft wrote:

No part/maker details. A "lucky dip" if ever I saw one.

http://www.allelectronics.com/ma...

The manufacturer appears to be ON Semiconductor, and the part a CAT4016.

Have fun,

S.

Edit:  PS - Like you, I've bought some but not used them yet.  S.

Last Edited: Tue. Jan 31, 2017 - 07:01 AM

Ahhh... my spam protection dohicky blocked the tech details bit.

Ross McKenzie ValuSoft Melbourne Australia

Fair enough.  It also struck me that I don't know how to tell a real On Semi device from a knockoff just by looking at it.  Even under heavy magnification.  If you do know how, let me know...

S.

My price for 5x CAT4016Y-T2 is €3.71 at RS Components, looks like an interesting device. From what I read in the datasheet, this chip will drive common anode LEDs with constant current, so it would fit nicely in the OP's project, replacing lots of components.

Digikey has them for \$1.76

http://www.digikey.com/product-detail/en/on-semiconductor/CAT4016Y-T2/CAT4016Y-T2CT-ND/1687228

They come in 4 different packages

http://www.digikey.com/products/en?keywords=CAT4016

Personally I'd get the QFN.  Chips with legs make my skin crawl.

Last Edited: Tue. Jan 31, 2017 - 12:53 PM

Scroungre wrote:
Fair enough. It also struck me that I don't know how to tell a real On Semi device from a knockoff just by looking at it. Even under heavy magnification. If you do know how, let me know... S.

Hackaday has a few decap posts / descriptions

(Decapping = removing plastic cover of IC's with some heavy duty acid).

And then look at the silicon really close with a microscope

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com