Author Topic: Simple Datasheet Question (7 segment display)  (Read 7649 times)

0 Members and 1 Guest are viewing this topic.

Offline corrado33Topic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: us
Simple Datasheet Question (7 segment display)
« on: May 25, 2014, 02:42:21 am »
I have a quick question on how to read a datasheet.

Here is a link to the datasheet in question.

http://www.lumex.com/specs/LDQ-M512RI.pdf

Anyway, I'm trying to determine how much current these LEDs want. The datasheet says 25mA constant current. But does that mean per digit, per LED, or total (for all 4 digits)? I'm not sure how to test how much current a particular LED wants. I mean, I guess I could stick 5V with a pot in series across the LED, then measure brightness, but that's a PITA. Or, I could assume normal green LED specs. My current thinking is that the 25mA is PER LED. Which  means I should choose resistors for my PNPs to provide 200 mA per digit. Hm, that'd be .8A total running through that little display, seems excessive. My revised thinking says that it's 25 mA per digit.

Next question. If I choose appropriate resistors for PNPs to provide 25mA per digit, what happens when I only light one segment? All 25mA are going to run through that one LED. That can't be good for it. Although in the terms of a green LED, 25mA isn't much.

Next to final question. When building a circuit for said display, when using PNPs that connect to the common anode pins, do I need a resistor on the collector of the transistor? I think no, because the collector current is proportional to the base current. Therefore the collector current can be controlled by the base current.

Final question (unless I think of more): Using a microcontroller to control this, I would also want to use NPNs between the actual segments and the micro, correct? I mean, the micro can sink that much current, it isn't much (considering only one digit is lit at a time with multiplexing, assuming my assumptions are correct above of only 25mA per digit, then the micro would only sink well... 25 mA at a time with some error). BUT, I don't think that's the right way to build the circuit, or is it ok to get away with?

Just for the record, I'm just learning this stuff, so I probably got a lot of the above wrong. I chose PNPs to "source" the current because that's what the internet told me. (And my electronic's books didn't say anything about the difference between the two other than that the biases are reversed for PNPs as compared to NPNs. And if I stated THAT incorrectly, the "diodes" are pointing the other way is the way I think of it. I know that most circuits (unless you're using matched transistors or something similar) can be built with either PNPs or NPNs, but there is a correct way to do things. I should stop typing now.
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Simple Datasheet Question (7 segment display)
« Reply #1 on: May 25, 2014, 03:57:18 am »

25mA will be per LED, but, remember that is the maximum safe current. How much current you need depends on how bright you want the display. Also if you multiplex the average current will be 1/4.

The resistors need to go in series with each LED so in the cathodes. The web says use PNP transistors because to drive the anodes to the +ve supply NPNs would need a base drive voltage higher than the supply. You could also use P channel logic level MOSFETs.

Driving the anodes directly from processor pins is possible but you need to study and understand the processor datasheet to know how much current a pin and multiple pins can sink and remember multiplexed the LED average current is 1/4 of the pin current.

 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Simple Datasheet Question (7 segment display)
« Reply #2 on: May 25, 2014, 04:06:08 am »
That 25mA is the absolute max current per segment before damage, not the typical operating current. You probably want to run at 10mA or less per segment (LED).

You do not want to control the current using the base current of the transistor. The current gain of bipolar transistors is not well controlled or consistent. You want to design the transistors to run into saturation, and have the resistor in series with each segment LED.

Connect the common anodes to VCC through a PNP to mux the digits, and connect each cathode to a resistor in series with an non. If you're going to mux the anodes, then the cathodes of digits can be paralleled through a resistor/NPN per segment.

And of course, put a current limit resistor in series between the base of each transistor and the uC pin that's driving it.
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline corrado33Topic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: us
Re: Simple Datasheet Question (7 segment display)
« Reply #3 on: May 25, 2014, 04:43:13 am »
You do not want to control the current using the base current of the transistor. The current gain of bipolar transistors is not well controlled or consistent.

Thanks, both of you. I forgot that you shouldn't design circuits based on the current gain of a transistor since it changes with temperature, among other things.
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Simple Datasheet Question (7 segment display)
« Reply #4 on: May 25, 2014, 04:53:30 am »
If they are bright enough at 10ma, those could be driven directly from a micro, if you've got enough pins.  Just never light up more than one segment at a time.  One can easily light all the right segments one at a time so that no flicker is observable.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1443
Re: Simple Datasheet Question (7 segment display)
« Reply #5 on: May 25, 2014, 10:17:36 am »
You should always light up as many segments as needed at a time if the current for each segment is limited by a resistor.
Time-multiplexing of each digit limits the power delivered to each segment/digit as well.

I often make simple 7-Seg displays with my MCU projects using only one resistor at the common anode or on the common cathode and you will get quite good viewing results(although a quite noticeable difference in brightness between a "8" and a "1" being displayed..but does this really matter?). Very efficient new 7-Seg LED's usually require much less than 25 mA to be easily seen except in bright sunlight without a color filter.  For most applications, with a 5V VDD, a single 220-ohm resistor is all that is required to protect your MCU and the LED display.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5331
  • Country: ro
  • .
Re: Simple Datasheet Question (7 segment display)
« Reply #6 on: May 25, 2014, 10:36:11 am »
If you want to save some real estate on your pcb, get a ULN2803A .. it's a 18 pin DIP with 8 darlington transistors inside and all emitters connected to a common pin.  Instead of soldering 8 npn transistors and their base resistors for each one ( 40 pins) you just have 18pins and a more condensed chip.  You'll still need individual current limit resistors for each led segment, and you'll have to keep in mind the voltage drop inside each darlington (about 1v) when selecting the resistor ...  v = i x r , r =  (v - vdrop led - vdrop npn ) / i =  (5 - 2.5 - 1) / 0.01 = 150 ohm  for 5v in, 10mA

The only other thing that may be worth mentioning is that unlike regular npn transistors, the darlington turns on and off slower compared to a npn (datasheet says about 120 ns to turn on) but for led digits that's not really a problem.

There's also cheaper ULN2003A that has only 7 transistors inside, if you don't care about the dot after each digit.  There's other with very similar names but some don't have built in resistors for each transistor, or the built in transistor is too large to make them good for use with 5v or less ( for example uln2002a needs at least 7v at input)

ps There's also a chip similar to ULN2803A but that sinks current instead. I forget the name now unfortunately.
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Simple Datasheet Question (7 segment display)
« Reply #7 on: May 25, 2014, 10:56:23 am »
You should always light up as many segments as needed at a time if the current for each segment is limited by a resistor.
Time-multiplexing of each digit limits the power delivered to each segment/digit as well.

That 'always' part... You sure about that?

Given a budget per character/digit of 50ma, and given a typical segment current draw of 10ma, I would need a very good reason to split that 50ma up between the 7 segments of the digit '8'.  I would want my '8' to be just as bright as my '1'.  If I only light one segment at a time, I can guarantee a uniform brightness.

Now I want to dig out my high speed camera, to see how the various LED displays in my house approach the situation.

Maybe it is just a matter of approach preference?  I would rather use as few parts as required to get the job done.  For a bank of 7 segment digits that would be one resistor per digit, and limiting illumination to one segment per digit at any given time.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1443
Re: Simple Datasheet Question (7 segment display)
« Reply #8 on: May 25, 2014, 11:12:50 am »
Yes, the "always" is always.
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Simple Datasheet Question (7 segment display)
« Reply #9 on: May 25, 2014, 12:53:11 pm »
Meh. Use of the words "always" or "never" is a red flag to me.  I don't believe you.

If you don't mind, can you please explain with some detail so I can comprehend why the 'always' is appropriate, here?
 

Offline jamesglanville

  • Contributor
  • Posts: 49
Re: Simple Datasheet Question (7 segment display)
« Reply #10 on: May 25, 2014, 01:09:24 pm »
My recommendation is to light up whole digits at a time. You don't need to worry about the different brightnesses of 8 and 1, you can easily solve that in code (just give the numbers larger ON times if they have more digits lit.)
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16394
  • Country: za
Re: Simple Datasheet Question (7 segment display)
« Reply #11 on: May 25, 2014, 01:21:16 pm »
Just do a digit at a time, have resistors in the non common lead of the package and drive them with a multiplexing system that gives each digit equal on time, and a small blanking time between digits to allow for slow drivers and other capacitances to discharge. That way you have the least amount of flicker, and equal brightness for each segment. If you want constant brightness irrespective of character the display will look very uneven.

The problem with multiplexing comes at around 8 digits, where the average current is getting low, and the refresh rate is getting close to being visible as flicker. The solution in many cases is to split the display into 2 or more smaller multiplex sections and have a common row driver and a second or multiple column driver so many different digits are driven at each time, each with separate data. If you are getting to that many displays though the common solution is to have a LCD panel and drive it graphically or in text mode.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1443
Re: Simple Datasheet Question (7 segment display)
« Reply #12 on: May 25, 2014, 03:04:21 pm »
I use the word always here because:

(1) Addressing each segment takes too much code
(2) the resulting code can be too complicated code
(3) Unnecessary MCU processing time being wasted on a single digit to light it up
(4) Single segment addressing can create flicker if many digits, takes 7(or 8 if decimal pt used) times as long to update display.
(5) Regulating digit brightness can be achieved by adjusting the On-Time of each digit relative to number displayed
(6) A single resistor can be used at the common anode or common cathode connection for each digit, no driver transistors required
(7) K.I.S.S.
« Last Edit: May 25, 2014, 04:27:06 pm by Paul Price »
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Simple Datasheet Question (7 segment display)
« Reply #13 on: May 25, 2014, 03:39:59 pm »
Thanks for calling me stupid with that KISS.  Appreciated.

It seems more difficult to count lit segments and multiply delay by that than it is to just turn each segment on for however many microseconds. If you are using straight C and not Arduino macros, the micros I use are PLENTY fast enough to light 8-10 digits without visible flicker.

Doesn't seem right to share one resistor across multiple simultaneously lit segments, somehow. I've seen instruction to not do this in many places, I'm pretty sure.

I don't know.  I am going to keep doing it the way I've been doing it though.  It works great for me and is easy to code. 

If I have an ample current budget, I am 100% for simultaneously lighting them all.
 

Offline corrado33Topic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: us
Re: Simple Datasheet Question (7 segment display)
« Reply #14 on: May 25, 2014, 04:18:10 pm »
Interesting ideas from everyone. I had never thought of lighting one segment at a time. I've always done my projects by lighting one digit at a time. In all honesty, if I wanted to keep it really simple, I could just have the uC source and sink all of the current. I HAVE done this before, when I was young. It works, although I can't speak for it's longevity.

As for fixing brightness in software... I've always been told that fixing a potential problem in hardware is much preferable to fixing an actual problem in software. Sure, this project will never be seen by anybody else, as it's a simple debugging display for other projects, but I still feel cheap not building it the "right" way. (Or one of the "right" ways.) In all honesty, I don't think I could distinguish the brightness difference between a 1 and an 8 with this display anyway (assuming constant current). Case in point: I had forgotten to properly ground one of the base pins of one of the PNPs and it was running through a relatively high impedance path. I didn't even notice until I measured the current and got weird readings. (I'm actually not using the uC right now, just simply moving wires to and from ground to turn the PNPs on or off.) I think when you get in the current range of 10-25mA per LED, the brightness curve flattens off and shouldn't be distinguishable by a human eye. That's my guess at least.

I think the "proper" ways to do it are to use both PNPs and NPNs, with resistors on the cathodes of the LEDs. (Although this way is definitely not "simple".) Because of this thread, I'll try both ways of lighting. One digit at a time and one segment at a time, and see which I prefer. One digit at a time is pretty simple. A single timer in software and a function to set the registers for each digit. One segment at a time will require two timers. One to cycle between segments, and one to cycle between digits. I wonder if instead of doing math to determine how long to light up each segment, it'd be easier to simply give each digit a certain amount of time to light up (say the length of time required to get through all 8 segments normally.) That way for a "1" for example, it'd cycle through each each segment 4 times where as for an 8 it'd cycle through each segment once (including decimal point.) Programming in this manner would be relatively simple because I wouldn't have to change the parameters of the timers around depending on the digit displayed. Alternatively, I could simply change the frequency of the timer depending on the digit displayed. I'll try both and see what happens.

They'll probably look the same, but I'll measure a few parameters and see which is preferable. It'd be really interesting to use a photodiode and measure a brightness vs time curve for say the bottom right segment when the display runs through 1-8. Maybe I'll do that. Maybe I'll go 1-7-4-5-6-8 so it should decrease in brightness every time.

As for the micro being fast enough (post above me), I'm simply using an atmega8 running at 1MHz and it should still be plenty fast. I think I'll use a prescaler to slow the frequency down to a few hundred Hz. I don't know if there is an advantage to running it slower or faster. I have a feeling that running it too fast will dim the display due to the LEDs not being able to turn on completely? (Or any hysteresis in the system somewhere actually.) Ok I'm done editing this now, let's try to make this thing work.
« Last Edit: May 25, 2014, 04:36:52 pm by corrado33 »
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1443
Re: Simple Datasheet Question (7 segment display)
« Reply #15 on: May 25, 2014, 04:21:46 pm »
Give the single resistor solution a try. The proof of the pudding is in it's tasting. The only limitation on this Digit Drive method is the Isink Max rating of the MCU. If any segment drive pin can handle 15-20mA, you are in business. Only if the MCU has a 12-bit A2D/D2A feature that is being used would this relatively high drive for multiplexing current cause a concern in creating multiplexing noise or ground loops.

I wouldn't recommend it unless I have already spent umpteen hours each trying the other ways to do it and found what works best.

K.I.S.S. is a message to the world in general, not aimed at you.

« Last Edit: May 25, 2014, 07:40:16 pm by Paul Price »
 

Offline corrado33Topic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: us
Re: Simple Datasheet Question (7 segment display)
« Reply #16 on: May 25, 2014, 05:29:05 pm »
Give the single resistor solution a try. The proof of the pudding is in it's tasting.

I wouldn't recommend it unless I have already spent umpteen hours each trying the other ways to do it and found what works best.

K.I.S.S. is a message to the world in general, not aimed at you.

I will give it a try, and I know it wasn't aimed at me.  :) The simplicity is enticing.
« Last Edit: May 25, 2014, 05:43:15 pm by corrado33 »
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Re: Simple Datasheet Question (7 segment display)
« Reply #17 on: May 26, 2014, 01:23:47 am »
Maybe it is because I have an extensive history in software that I find software fixes much easier.

Just the other day I wired up something wrong, noticed it, and fixed it in software in about 2 seconds.  It would have taken several minutes to resolder things to match the code, so I changed the code to match the wiring I messed up.
 

Offline corrado33Topic starter

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: us
Re: Simple Datasheet Question (7 segment display)
« Reply #18 on: May 26, 2014, 03:34:07 am »
I'm much better at software than hardware as well, however I'm attempting to become better at hardware. Sure, changing pins around in software is easy, however I think relying on "software fixes" is a bad habit to get into. (Changing a pin or a value is not a software fix. When you have to change how your program fundamentally works to fix a hardware problem, then THAT'S a software fix.) I wrote a test program for this circuit in probably 5 minutes, but I've been doing math for and testing the circuit for a few days now (off and on of course).

I eventually ended up going with 4 PNPs connected to the common anodes then resistors going from the cathodes to the uC pins. Individually the pins are only sinking 10mA or so, and even with an 8 lit up it's well below the max limit for the uC. I tried your one resistor way, it works, but things do dim as you light up more characters. My way doesn't dim (that I can tell.) While your way may be much more simple, in terms of cost, it's not that big of a deal. (How much is the cost of 4 tiny transistors and 8 resistors? A few cents? A dollar maybe?) Depending on the resistor chosen for your way, you could possibly lessen the longevity of the segments lit when displaying a 1. Or if you ever choose to use other display methods that use possibly only one segment, it'd lessen longevity of that segment even further.

EDIT: I did make a mistake along the way where I got the LEDs to glow orange (they're supposed to be green). I'm not sure how I did that. I think I hooked the LEDs up directly to the collector? of the PNP when it was specced to provide 100mA with the cathodes hooked straight to ground.

Besides, the changing brightness does drive me nuts. I may be a bit OCD. For me it'd be more of a reminder of my own laziness, especially if I put this on a board and kept on my bench to use with many projects down the line.

I know there is a downside to the way I wired it up, but I can't think of it. The only thing I can think of is that when say a 1 is lit up, Ic of the transistor is only 20ish mA. I'm not sure what that does to the transistor since It's wired up to provide 100ish mA. (Max of 80mA draw with an 8 and decimal point + a bit of leeway.)
(If anyone could enlighten me on the downside that'd be great!)
« Last Edit: May 26, 2014, 03:41:21 am by corrado33 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf