Author Topic: Need Advise on Driving an LED Display  (Read 7431 times)

0 Members and 1 Guest are viewing this topic.

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Need Advise on Driving an LED Display
« on: March 01, 2014, 09:35:04 pm »
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.
"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #1 on: March 01, 2014, 09:47:42 pm »
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...
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #2 on: March 01, 2014, 10:03:52 pm »
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.

 

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Re: Need Advise on Driving an LED Display
« Reply #3 on: March 01, 2014, 10:17:43 pm »
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.


Ah-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,
"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Need Advise on Driving an LED Display
« Reply #4 on: March 02, 2014, 01:35:46 am »
Quote
The issue how to interface MCU to LED.

The 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline JoeN

  • Frequent Contributor
  • **
  • Posts: 991
  • Country: us
  • We Buy Trannies By The Truckload
Re: Need Advise on Driving an LED Display
« Reply #5 on: March 02, 2014, 08:12:16 am »
The I2C driver chips are expensive ($10)

How 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
Have You Been Triggered Today?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9930
  • Country: nz
Re: Need Advise on Driving an LED Display
« Reply #6 on: March 02, 2014, 09:24:45 am »
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.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #7 on: March 02, 2014, 01:37:16 pm »
The display has common cathodes. Anyhow the ATMega328 has plenty of pins for this.

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

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Re: Need Advise on Driving an LED Display
« Reply #8 on: March 02, 2014, 04:10:30 pm »
The I2C driver chips are expensive ($10)

How 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

You'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.
"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #9 on: March 02, 2014, 05:30:48 pm »
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 to http://www.maximintegrated.com/datasheet/index.mvp/id/1339

ATmega328 in 2k quantities: USD 1.85 at http://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)
 

Offline Arp

  • Supporter
  • ****
  • Posts: 107
  • Country: se
    • Henriks bits n pieces
Re: Need Advise on Driving an LED Display
« Reply #10 on: March 02, 2014, 05:49:40 pm »
You'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.

I 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  :)
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Need Advise on Driving an LED Display
« Reply #11 on: March 02, 2014, 05:55:46 pm »
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.

https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Re: Need Advise on Driving an LED Display
« Reply #12 on: March 02, 2014, 09:41:13 pm »
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 to http://www.maximintegrated.com/datasheet/index.mvp/id/1339

ATmega328 in 2k quantities: USD 1.85 at http://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)

Yes, 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.
"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Re: Need Advise on Driving an LED Display
« Reply #13 on: March 02, 2014, 09:44:00 pm »
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.

Any advice on using 2N7002 MOSFETs verses NPN 2N2222As ? Why use one or the other, any thoughts on that?
"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #14 on: March 02, 2014, 10:09:30 pm »
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.

Any advice on using 2N7002 MOSFETs verses NPN 2N2222As ? Why use one or the other, any thoughts on that?

For 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) allows
  • 40 mA per port pin
  • 100-150 mA per port
  • 200 mA max into (Vcc) and out of (Gnd) the chip

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

Online mariush

  • Super Contributor
  • ***
  • Posts: 5017
  • Country: ro
  • .
Re: Need Advise on Driving an LED Display
« Reply #15 on: March 02, 2014, 10:21:01 pm »
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 pcs at 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.
 

Offline TheRuler8510Topic starter

  • Regular Contributor
  • *
  • Posts: 179
  • Country: us
  • RF Engineer
Re: Need Advise on Driving an LED Display
« Reply #16 on: March 03, 2014, 01:17:29 am »
For simplicity/reducing number of components, you could go with a ULN2803A instead of individual npn transistors.

As for microcontrollers, a pic16f1827 is only $1.26 at 100 pcs


Yes, 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!


"There are no facts, only interpretations."
--Friederich Nietzsche
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Need Advise on Driving an LED Display
« Reply #17 on: March 03, 2014, 02:16:22 am »
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.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5017
  • Country: ro
  • .
Re: Need Advise on Driving an LED Display
« Reply #18 on: March 03, 2014, 07:44:10 am »
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. 
 

Offline uwezi

  • Supporter
  • ****
  • Posts: 272
  • Country: se
    • GreenPhotons
Re: Need Advise on Driving an LED Display
« Reply #19 on: March 03, 2014, 08:45:55 am »
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.

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.

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

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Need Advise on Driving an LED Display
« Reply #20 on: March 03, 2014, 12:12:24 pm »
+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.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Need Advise on Driving an LED Display
« Reply #21 on: March 03, 2014, 12:25:55 pm »
-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.
================================
https://dannyelectronics.wordpress.com/
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5017
  • Country: ro
  • .
Re: Need Advise on Driving an LED Display
« Reply #22 on: March 03, 2014, 12:47:20 pm »
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.   
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf