Need Advise on Driving an LED Display - Page 1
Forum section: electronics / general

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 01, 2014, 09:35:04 pm
content: Using an ATMega, I'm trying to run a 4-digit, 7 segment LED display. The issue how to interface MCU to LED. If my main objective is low BOM cost, what is the best path to choose?The I2C driver chips are expensive ($10), so I was thinking a cheap alternative would be to use a cheap 8-bit shift register with open drain outputs, and use four 2N2222 to multiplex the 4 digits. I was thinking I have to write my own interface library to talk to the shift register, meaning constructing my own clock and data signals, etc.Am I off in the weeds, or is there a better way? The SPI libraries seem too complex for this simple job.Thanks in advance.

author: uwezi
author_rank: Unknown
timestamp: March 01, 2014, 09:47:42 pm
content: If the number of used pins is not a concern than you could wire up the segments to a port pin each (7 + an optional dot) and then use another 4 pins which drive the digits using transistors. You write about 2N2222 so I assume that your display comes with common cathodes.Otherwise you would need to shift the bits with a clock signal and an additional latch-signal (3 port pins) - using e.g. an 74xx595 you should find plenty of code examples on the net...

author: uwezi
author_rank: Unknown
timestamp: March 01, 2014, 10:03:52 pm
content: Stretching the specs of the ATmega slightly you can even leave out the transistors, but you should include current-limiting resistors in series with each segment. This is something which I ask my students to do in the third practical lab exercise - see the attached schematics.

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 01, 2014, 10:17:43 pm
content: Quote from: uwezi on March 01, 2014, 09:47:42 pmAh-Ha...Excellent! It seems so simple, but I did not think of driving direct with MCU. I could not see the forest 'for the trees.The display has common cathodes. Anyhow the ATMega328 has plenty of pins for this.Thanks and Regards,

author: dannyf
author_rank: Super Contributor
timestamp: March 02, 2014, 01:35:46 am
content: QuoteThe trade-off is between the number of pins needed and complexity.The simplest would be using a driver (7219 for example). It is expensive and requires 5v drive. But needs just a few pins from the mcu.The next would be some sorts of shift registers, hc164 or hc595 (slightly better). either 1 shift register + 8 pins or 2 shift registers (2 - 3 pins). More complex to drive.The most complex is to use all pins and no other parts. It takes up lots of pins and you have to drive it via interrupt to be flicker free. The least expensive but most complex (and maybe simplest at the same time) solution.

author: JoeN
author_rank: Frequent Contributor
timestamp: March 02, 2014, 08:12:16 am
content: Quote from: TheRuler8510 on March 01, 2014, 09:35:04 pmHow professional of a project is this? 7219s are downright cheap if you go with the Chinese it-probably-fell-off-the-back-of-a-truck vendors. I've bought lots of these and they always work. Of course, this is coming from the perspective of a hobbyist rather than someone who is designing a system that gets flown on an aircraft or in space. How bad is it if a few of these fail in the field anyway?http://www.ebay.com/itm/100PCS-IC-MAX7219EWG-MAX7219-SOP24-DRIVER-LED-DISPLAY-NEW-DATE-CODE-12-/300745730061

author: Psi
author_rank: Super Contributor
timestamp: March 02, 2014, 09:24:45 am
content: I've driven a 7 column 25 row led array from a ATmega directly with no problems.Obviously you can't get more than 40mA for each column so your limited to around 2mA per led. If you use efficient leds that is enough to be quite bright and visible inside.If you push it too far you will notice the leds in each row get dim/brighter depending how many others in the row are on.Adding 7 mosfets would obviously fix that issue by providing lots of current per row at a cost of extra parts.

author: uwezi
author_rank: Unknown
timestamp: March 02, 2014, 01:37:16 pm
content: Quote from: TheRuler8510 on March 01, 2014, 10:17:43 pmFor the direct-drive method it does not matter whether your display has common cathodes or common anodes. The pin drives of the ATmega are powerful enough.And yes, driving directly coupled displays from software is preferably done in an interrupt - but I don't see that as a disadvantage.

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 02, 2014, 04:10:30 pm
content: Quote from: JoeN on March 02, 2014, 08:12:16 amYou're right, that is cheap. I suppose they are counterfeit Maxim parts. With counterfeits, you can't depend on the supply chain being there in two years, but then again--with undercutting that bad--you can't depend on Maxim being there in two years!Thanks for the link.

author: uwezi
author_rank: Unknown
timestamp: March 02, 2014, 05:30:48 pm
content: Just as a side note: when sticking to official sources for these chips even using another ATmega is significantly cheaper than using a dedicated display driver.MAX7219 in 1k quantites: USD 4.18 according tohttp://www.maximintegrated.com/datasheet/index.mvp/id/1339ATmega328 in 2k quantities: USD 1.85 athttp://www.digikey.com/product-detail/en/ATMEGA328-AUR/ATMEGA328-AURDKR-ND/3441266(and you would not even need an ATmega328 to drive a display like this, an ATtimy2313 would be more than enough: USD 0.74 in 1k quantites from Digikey)

author: Arp
author_rank: Unknown
timestamp: March 02, 2014, 05:49:40 pm
content: Quote from: TheRuler8510 on March 02, 2014, 04:10:30 pmI have 10 China MAX7221 soic:s that looks just like the ones on that ebay picture. They also have a tiny circle to mark pin 1. On my original MAX7221:s there's a half circle on one of the sides, as can be seen in the data-sheets. Not sure if that's a tell-tell sign but could be.I think most IC:s from China are fake

author: fcb
author_rank: Super Contributor
timestamp: March 02, 2014, 05:55:46 pm
content: If you've got a spare 11/12 i/o, then you can i'd do it with 7/8x 2N7002's (+8 dropper resistors) and 4xPNP's (BC556 etc..).If your strapped for i/o then use a couple of SIPO's (such as the CD4094) to drive the 2N7002's.

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 02, 2014, 09:41:13 pm
content: Quote from: uwezi on March 02, 2014, 05:30:48 pmYes, it seems like MCU only approach is the best, so I am going in that direction. I may also wire up a SIPO version for fun and compare power drain and ease of programming.

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 02, 2014, 09:44:00 pm
content: Quote from: fcb on March 02, 2014, 05:55:46 pmAny advice on using 2N7002 MOSFETs verses NPN 2N2222As ? Why use one or the other, any thoughts on that?

author: uwezi
author_rank: Unknown
timestamp: March 02, 2014, 10:09:30 pm
content: Quote from: TheRuler8510 on March 02, 2014, 09:44:00 pmFor this particular application? There is none but personal taste. And normally you will not need any additional driver transistors on the segments - the datasheet of the ATmega328(P) allows40 mA per port pin100-150 mA per port200 mA max into (Vcc) and out of (Gnd) the chipIf you can run the LEDs at 10 mA each, worst case would be 80 mA for the segments and the same 80 mA back from the commons. For a modern display 10 mA - even multiplexed - gives quite an ok brightness.

author: mariush
author_rank: Super Contributor
timestamp: March 02, 2014, 10:21:01 pm
content: For simplicity/reducing number of components, you could go with a ULN2803A instead of individual npn transistors. With mosfets, you'd want to be careful about the minimum voltage required to start and you'd have to put a resistor from gate to ground to close the mosfet when you want which just complicates design.. You also need a resistor with npn transistors between mcu pins and npn base to limit the current, but a chip like uln2803 has base resistors built in, so you save pcb space.As for microcontrollers, a pic16f1827 is only $1.26 at 100 pcsat digikey(1826 with half the flash memory is $1.18), with 16 io pins there's plenty of pins for the led digits and for connectivity to other chips through i2c or spi or whatever you want. But since you have an avr programmer, it may not make sense to invest in microchip mcus.

author: TheRuler8510
author_rank: Regular Contributor
timestamp: March 03, 2014, 01:17:29 am
content: Quote from: mariush on March 02, 2014, 10:21:01 pmYes, good idea...the ULN2803A looks like a good way to simplify, reduce parts count, and probably cheaper too. It looks like the ULN2804 may work even better since it has a 10K base resistor.As for the PIC, I am in a learning mode, so I need to stick with AVR for now.Thanks!

author: fcb
author_rank: Super Contributor
timestamp: March 03, 2014, 02:16:22 am
content: I would avoid the ULN2803A - I've done multiplexing with them and if you have to keep the mpx speed down or they will create a 'smearing' or ghost effect. They don't switch that fast.8x 2N7002's are probably a bit cheaper than a ULN2803A.

author: mariush
author_rank: Super Contributor
timestamp: March 03, 2014, 07:44:10 am
content: Unless his 7segment display needs to show different values more than several times a second, that smearing or ghost effect won't matter. It should actually be a positive thing, like persistance of vision.You're right, it can be slower at turning off and on compared to plain transistors, but after all it's an array of darlington transistors, so it makes sense.It does save space on a prototyping board/breadboard/pcb because instead of 8 x 3 pins (base, collector, emitter) you now have only 8-10 traces for the uln2803a (or 4) , it saves 8 resistors (the ones between io pins and base of transistors because they're integrated), and it can also handle more power compared to tiny transistors.

author: uwezi
author_rank: Unknown
timestamp: March 03, 2014, 08:45:55 am
content: Quote from: mariush on March 03, 2014, 07:44:10 amThe smearing would show up between digits, i.e. the contents of the first digit would smear out to the next digit, because both digits would be powered at the same time during the transition period.Apart from that the 2803 (or any other from that family) would be an overkill, because the original post was on a 4-digit display with common cathodes. To drive the cathodes he only needs 4 transistors (if any!) and for driving the 7 anodes you cannot use the 2803 anyway...

author: fcb
author_rank: Super Contributor
timestamp: March 03, 2014, 12:12:24 pm
content: +1 for uwezi.To explain the smearing more. If you had a sequence such as COLUMN 1/2/3/4/1/2/3/4/etc... and you wrote 1811 on your display, then you would notice that the COLUMN 3 unlit segments would be glowing a little. How much would depend on on how fast you multiplex the display.If this bothers you (it may not) - you can counter act this by inserting a dead-time (allowing the COLUMN drivers to switch off properly) between column drive events, but this will lead top a reduction in brightness (again, how much is dependent on your scheme).This problem is very annoying with moving characters (such as timecode clocks), so much so that I've abandoned multiplexing on timecode in-favour M5450 drivers running each segment.

author: dannyf
author_rank: Super Contributor
timestamp: March 03, 2014, 12:25:55 pm
content: -The smearing would show up between digits, i.e. the contents of the first digit would smear out to the next digit, because both digits would be powered at the same time during the transition period. -are you sure that it is not a coding issue? Those chips may be slow but likely much faster than human vision. What you described sounds like switching the digits too fast for the eyes.

author: mariush
author_rank: Super Contributor
timestamp: March 03, 2014, 12:47:20 pm
content: No, uwezi is right, I simply forgot about that issue.So yes, it's possible to get some bleeding into the other digits because it takes more time for the darlington elements to turn off compared to the time it would take to turn off one digit and turn on next digit.Like fcb says, it would be possible to just put a pause between turning off a digit and turning on next digit, which would allow the darlington arrays to fully turn off. The brightness would be lower, but if you're using darlington array, you could afford higher currents into each element of the seven segment display in the first play.A microcontroller is capable usually of 20-25 mA per pin (for pics), maybe more for avr , and if i remember correctly about 300-400mA in total through all pins chip and this is already a lot of current available to light up on digit at a time. If you have seven segments that need more power or if you want to run them from higher voltage than what the pic can handle, then it makes sense to use those uln2803/4/5a arrays.