Four Digit Seven Segment Display Circuit Issues - Page 1
Forum section: electronics / beginners

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 16, 2013, 11:49:13 am
content: Hello Everyone,I have just gotten in my 4 digit 7 segment display from adafruit for my alarm clock project so I want to experiment around with it a little bit to get an understanding of how I am going to drive the display from one of my AVR chips. My main issues lie in the circuit design as the display is common cathode, and multiplexed to limit the amount of pins you need to use on the actual AVR. If the Decimal points are ignored you can use 8 pins 7 for the digits and 1 for the colon. Being it is common cathode there is 1 cathode for each digit and 1 for the colon.Here is my real issue now. If I understand this correctly I need to run each anode through say a 330 ohm resistor to the appropriate port pin on the controller. Next each cathode needs to be connected to ground through a 330 ohm resistor and a npn transistor to control the current.This seems to make sense until I start to think about the operation. If the cathodes are grounded through transistors how exactly am I suppose to control which digit gets which number? What I am thinking is that controlling which digit gets updated would require the cathodes to also be connected to an additional 5 micro pins so I can control the gate switch of the transistors. which leaves me with using 13 micro pins instead of just 8. Or am I thinking about this all wrong?As usual all help is appreciated as this is one of my first real circuits.EDIT:Forgot to add link to datasheethttp://www.adafruit.com/datasheets/BL-Q56C-43.pdf

author: Chris.M
author_rank: Contributor
timestamp: May 16, 2013, 12:07:33 pm
content: Quote from: blewisjr on May 16, 2013, 11:49:13 amQuote from: blewisjr on May 16, 2013, 11:49:13 amYou may want to double check that your micro-controller can source enough current when all segments are light. Otherwise a transistor may be needed for each segment.Quote from: blewisjr on May 16, 2013, 11:49:13 amYes, each transistor is connected to a pin, which is turned on briefly, together with the appropriate segments to give the desired number. Then that transistor is turned off, and the next transistor is turned on and its appropriate segments are turned on. You cycle through each digit, one by one continuously. When its done fast enough, all four digits will appear to be on at the same time.Here is a link that may help:http://electronics.stackexchange.com/a/34818

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 16, 2013, 12:32:00 pm
content: Ok good to know I am thinking about this correctly. Now with the transistors. The base would go through a resistor to the pin on the micro. Then I would assume the collector goes to ground and the emitter goes to the cathode. This way when you drive the pin high it would feed the cathode the current and thus activating that digit. When it is driven low it would ground it thus turning off the digit. I think I got that right if not let me know so I don't fry my $6 display

author: mariush
author_rank: Super Contributor
timestamp: May 16, 2013, 01:10:01 pm
content: Yeah, pretty much.One minor observation... according to datasheet, the segments can do 25mA each but if you'd run them at such high current they'd be super bright. You'd want to run them at 5-10mA tops, this will be bright enough and the on-off effect will make them seem brighter anyway.Some pics can source a maximum of about 15 mA per pin or per whole chip, I don't remember exactly which one was now, so you should use npn transistors to turn on theYou have the voltage drop on the diode, 2.1v min , 2.5v max so just assume 2.3v ... then you have ohm's laws v=IxR ... so you can figure out how to limit the current to what you want.. for example if you use 5v and want 10mA (0.01A) on segments , you need to drop 5v (input) - 2.3 (vdrop on segment) = 2.7v on the resistor so 2.7v = 0.01 x R therefore R = 2.7 / 0.01 = 270mABut keep in mind there's some voltage drop on the transistors at both anode and cathode, so you'll have to take out those drops from the formula. Basically, 330ohm is reasonable for 5-10mA on each segment.You could use a ULN2003A or ULN2803A, these are DIP chips that have 7 (first) or 8 (the second) Darlington transistors rated for 500mA each so a bit overkill but makes it easy to connect the seven segment display, because these particular numbers have a built in resistor at the base of each darlington transistor (note that there are similar chips like ULN2801 or 2803 without A at the end which don't have the base resistors or like ULN2804/A which is the cmos version and needs at least 6v to work)The ULN2803A has a 2.7kOhm base resistor so it only needs 1/10 of mA or so from the microcontroller to turn the segment on and as a bonus, you can run the leds at something like 12v while your microcontroller sends 5v at the base.So with such dip IC you only need the ic and resistors at each output, sized so as to keep in consideration the 1-1.2v drop on the darlington.

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 16, 2013, 01:51:00 pm
content: To my knowledge from what I gathered from the adafruit page I should only need the NPN's on the cathodes to sink the right amount of current and I should be able to run the anodes with just a current limiting resistor. Yes I chose 330 ohms based off that fact as I don't want to blind myself. I figure with the NPN's on the cathodes at 15mA I would be getting about 120mA per digit and at 5mA I would get 40mA per digit but with the 330 ohm I will probably be sitting around 15mA. But again I should not need NPN's on the Anodes that would over current the display I think.

author: hlavac
author_rank: Frequent Contributor
timestamp: May 16, 2013, 04:36:57 pm
content: No need to guess the current, there is math behind it all.Your 330 resistors will see your supply voltage (5V?) minus voltage drop on the segment LED (2.1V?) minus voltage drop on the switched on transistor (Vcesat in datasheet, ~0.2V) .Whatever is left will determine the current (~8.1mA).Seems that 330 is too much unless your LED voltage drop is lower (datasheet is for multiple different dislpays and I don't see which one you have).There is also some resistance in the micro output pins that shows as a few ohms that causes a small voltage drop for higher currents.Micros generally have relatively high current on I/O pins (40mA ish) but they have limits on power supply pins that ruin your day when you try to max out too many pins...

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 16, 2013, 05:55:12 pm
content: Not seeing the voltage drop in the display datasheet. I am running the BL-Q56C-43B-XX. The transistors on the cathode are NPN PN-2222A's can sink up to 500mA Drop is 0.3V.Emitter -> gnd, base -> 1K ohm -> I/O pin, Collector -> Display. The Anodes go through a 330 Ohm resistor to the I/O pins.Wish I can give a schematic but I don't have parts designed for the display or the uC in diptrace yet. The micro is operating at 5V correct. The micro puts out 40mA per IO pin. The anodes are running straight through resistors not through any transistors.This is the general layout of how it is wired up. With the : on the display I also run the cathode straight to ground and the anode is running through a 330 ohm resistor straight to 5V as it will always be active no need to control it. I might need to up the resistor as it may be too bright.

author: hlavac
author_rank: Frequent Contributor
timestamp: May 16, 2013, 10:10:22 pm
content: It's there, Vf (forward voltage) BL-Q56C-43B-XX being blue has 2.7V typical, 4.2V max. Thats quite high, only 2V left across the resistor, 6mA current. You may want to lower it a bit (220 Ohm perhaps). Maybe check the real voltage drop measuring voltage across one of the LEDs to be sure.

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 17, 2013, 12:14:02 am
content: Yea I think you are right I might have to drop to 220 Ohm I will tinker around with it once I get this thing operational as I have everything all wired up on the breadboard. Do you think the 330 ohm is big enough for the non uC driven ":" on the display. I think it is large enough since it is being driven directly off the 5V rail at 1 amp. I read 1k resistors off the NPN's in a tutorial somewhere I think they will be ok but I am not sure how to calculate the current gain from a NPN to check any info on calculating that? What I am not sure if is if the current coming from the anode and cathode are additive or not.

author: mariush
author_rank: Super Contributor
timestamp: May 17, 2013, 12:26:00 am
content: Here's a very good video about npn transistors and how to size it, it's really worth the time watching it:

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 17, 2013, 01:08:57 am
content: Thanks for this very awesome video. My main issue is understanding what the gain would be. He is using my transistor in the video and he says it is 100 but the data sheet lists a crap load of different gains at 10V. I am running 5V from both ends. Through the calculation he gave the display is.120 watts / 5 volts = 24mA. So if I just say gain of 100 like he said that is I need 0.24mA to switch the transistor. Which would mean...IB = (5 - 0.3) / RB = (5 - 0.3) / 1mA = RB = 4700 which means a 1K resistor I am using is too small I should instead use a 4.7K. Can someone please check that calculation for me.So I need 220 ohm resistors on the anode to get 10mA on the display, however, 120 ohm resistors will get me 19mA which is much closer to the 20mA max brightness and 4.7K resistors on the transistor to get it to switch even though 1K resistors would get it to switch but by overkill. The question is will it be bright enough if all 7 segments are lit for the number 8 or should I just go the standard route and fly through 1 LED at a time per segment?

author: mariush
author_rank: Super Contributor
timestamp: May 17, 2013, 01:55:38 am
content: IB = (5 - 0.3) / RB = (5 - 0.3) / 1mA = RB = 4700 which means a 1K resistor I am using is too small I should instead use a 4.7K. Can someone please check that calculation for me.Where did you come up with that 1mA? The minimum is 0.24 mA. I assume you picked it as something higher than 0.24 mAThe result is probably correct (it's 4am and i'm not in the mood for math). Anyway, the point is you only do this exact math if you want to get the npn to PARTIALLY open and let just that amount of current.What you normally want to do with npn transistors is to open them completely or more than you think you need, because the hFe factor can vary between transistors of the same code within some range, so it's not a good idea to calculate exactly the minimum amount of current. You will limit the current going through the lcd segment by the resistors, not the transistor.My suggestion is to just pick a value, let's say 0.5 mA or 1 mA, maybe even more - with a hFe of 100, you will get at least 50-100 mA of current going through the npn transistor, which will always be more than what the 7-8 segments will have going through them (limited by the resistors) so it's not going to be a problem.A 1kOhm may also be just fine, it will just allow more current to through the base but it's unlikely to damage it... it's still a on-off switch which is just what you need.The only thing you also have to be careful is about the npn's power dissipation (I think he says in the video), if not google about it... basically, in your case there shouldn't be any problem.

author: Ghydda
author_rank: Regular Contributor
timestamp: May 17, 2013, 09:58:37 am
content: Quote from: blewisjr on May 17, 2013, 01:08:57 amThis doesn't matter. The gain curves you are refering to matters only when you are utilizing the transistor in its unsaturated state (partial on). Your application needs the trasistor in its saturated state (fully on).Quote from: blewisjr on May 17, 2013, 01:08:57 amThat is a bogus calculation although you accidentally arrive at a more or less useful base resistor value.Quote from: blewisjr on May 17, 2013, 01:08:57 amIf your target current in each segment is 20mA then each of the 7 segments should have a resistor with the following value(5V - led drop - transistor saturation voltage) / led current = (5-2.7-0.2)/0.02 = 105 ohm --> choose 100 ohmLighting all 7 segments gives 7*20mA = 140mA collector current in the transistor.Assuming a beta of 100 for the transistor puts forward a requirement of 1.4mA of base current.(Drive voltage - Vbe) / base current = (5V-0.7)/0.0014 = 3071 ohm --> choose any close and lower value, say 2k2 ohm.This insures you deliver enough base current into the transistor to enable it to stay in saturated mode regardless of how many segments you turn on at a time. You can with no perceivable change to the function of the circuit choose 1k or even 470R for the base transistor. The only change is that you drive the transistor a bit harder into saturation, which will allow it to pass more current from collector to emitter before it enters the unsaturated mode and it starts to limit your led drive current. Also any excess base current is power being wasted - usually it's no biggie, but if you're running from batteries then optimizing the base current could become an important design parameter.

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 17, 2013, 12:20:29 pm
content: Quote from: Ghydda on May 17, 2013, 09:58:37 amOk so a few question firstly why is my calculation bogus the numbers were taken from both datasheets and calculated from there according to the equations in the video. Except the voltage drop on the transistor is actually 0.3 not 0.7 according to the datasheet.Secondly when you calculated the resistance value for the anodes you included the transistor voltage drop why?As the anodes are being driven directly from uC pins and are not going through transistors. The current is exiting the cathode through the transistor. What I am seeing then is the current going into the display with 100ohm resistors being too high which can cause a burn out. When I calculated the 120 ohm resistors I did not take into the account of the transistor drop. which gave [(5 - 2.7) / .02] = 115 ohms nearest is 120 ohm resistor.Edit: Ah I see why the collector is drawing current from the cathode so the VCE(sat) drop of 0.3 will actually effect the resistor value I calculate on the anode so [(5 - 2.7 - 0.3) / .02] = 2 / .02 = 100 ohm right on the button. for 20mA sounds good will give that a try. I am going to keep the 1k resistors on the base of the transistor because if anything it will help guarantee a full saturated switch and there is no way it is going to cause the transistor to over current so it is still a safe value.

author: mariush
author_rank: Super Contributor
timestamp: May 17, 2013, 12:50:30 pm
content: He probably assumed you have a common anode led digit, and that you drive all segments through the npn transistor, so he makes sure he can deliver 7x20mA to the digit.If yours is common cathode, then you just have to get the npn transistor is saturation mode, to act as a switch with minimal resistance. The npn transistor will then have only about 0.2v voltage drop between collector and emitter, which you can basically ignore as it doesn't do that much difference in the calculation.So if you don't restrict the current by keeping the npn transistor in active-linear mode, you have to limit each segment with a resistor or a second npn transistor+base resistor, npn being kept in active-linear mode to restrict current.

author: Mr Smiley
author_rank: Frequent Contributor
timestamp: May 17, 2013, 01:06:14 pm
content: For using a transistor as a switch i use the old ' base current 1/10 of the collector current ' so for 20mA collector current I’d use 2mA base current to make sure the transistor saturates.Also, the faster you multiplex, the dimmer your display will become, and the lower your series resistors need to be.It would come down to how bright you want it visually.Start off with say 330 ohm's, light each digit for about a second, and then the next and then the next and so on, then start increasing the multiplexing rate till you don't see flicker and have the brightness you want. That way you can check all your timing for display off - change seg data - display on works visually

author: blewisjr
author_rank: Frequent Contributor
timestamp: May 17, 2013, 02:24:16 pm
content: Edit:Never mind to those who read I got the display to work properly just updating too slow I think because I am seeing the changes.I was ultimately updating the display wrong which was not giving the transistors enough time to saturate causing the display to be super dim.