7Seg LED's and Biasing Transistor from What is a Microcontroller?
Macore
Posts: 41
Hi,
I am currently building a simple little digital thermometer. I have a couple questions relating to how pieces of my project are used in the WIAM kit.
The project takes 3 green 7seg displays and ties the anodes for all of the segment lines from each display to each other display and then to a Basic Stamp I/O pin (8 - 15). The common cathode lines (3, 8) for each device are wired together and then to a separate I/O pin (7, 6, 5). In this way I can place the digit of a number to be displayed with the appropriate OUTH statement to set the correct segments and then cause it to be displayed by raising high one of the pins 7, 6 or 5. By alternating 7 6 and 5 every 5 milliseconds and doing a new OUTH for another digit in between I can multiplex a 3 digit number to the 7 segment displays basically one at a time and due to "visual persistence" it appears to be a steady 3 digit number.
Now when I first had this idea it occurred to me that 8 segments all lit at once being sunk through a single BS I/O pin would be too much current, so I placed a 2N3904 transistor in between the LED cathodes and VSS on my Homework board.
Question 1: in the chapter on using the 2N3904 to control a simple LED, 2 100k resistors in series where used on the base to bias it. Why 2 100k? If I remember my old electronics is this not the same 1 50k resistor? Furthermore, since it is being used a simple on/off switch with current gain why use a resistor at all? How was the value of this resistor determined? (There already a 220 ohm resistor on the homework board on every pin of the BS). Are we trying to protect the transistor from being overdriven or accounting for the fact that Zero on a BS I/O pin is actually a little more than 1 volt?
Question 2: when I go to check the actual current running through the LED segments the book showed a 1k resistor in series with each anode and the appropriate BS I/O pin which I did. When I take a Voltage drop across this resistor its about 4 volts meaning the LED is only being driven by 4ma? Why so low? Where is the Datasheet for this display chip (couldn't find it here or online)? With such a low current the displays comes out very dim when I multiplex them and they are only on for 5ms at a time, how much higher can I run the current up to without damaging the display segments? Where did the value of 1k come from (there already a 220 ohm resistor on the homework board on every pin of the BS)?
If I am overlooking something or doing anything horribly wrong I would appreciate any feedback and or correction.
My thanks to anybody caring to answer and take their time. Its been over 30 years since I did any real electronics work. I am having a lot of fun trying to remember this stuff and using a BS sure makes it easy and fun to create simple projects like this. FYI, I am by profession a computer programmer for over 30 years, haven't done much hardware since then.
Thanks again,
David
I am currently building a simple little digital thermometer. I have a couple questions relating to how pieces of my project are used in the WIAM kit.
The project takes 3 green 7seg displays and ties the anodes for all of the segment lines from each display to each other display and then to a Basic Stamp I/O pin (8 - 15). The common cathode lines (3, 8) for each device are wired together and then to a separate I/O pin (7, 6, 5). In this way I can place the digit of a number to be displayed with the appropriate OUTH statement to set the correct segments and then cause it to be displayed by raising high one of the pins 7, 6 or 5. By alternating 7 6 and 5 every 5 milliseconds and doing a new OUTH for another digit in between I can multiplex a 3 digit number to the 7 segment displays basically one at a time and due to "visual persistence" it appears to be a steady 3 digit number.
Now when I first had this idea it occurred to me that 8 segments all lit at once being sunk through a single BS I/O pin would be too much current, so I placed a 2N3904 transistor in between the LED cathodes and VSS on my Homework board.
Question 1: in the chapter on using the 2N3904 to control a simple LED, 2 100k resistors in series where used on the base to bias it. Why 2 100k? If I remember my old electronics is this not the same 1 50k resistor? Furthermore, since it is being used a simple on/off switch with current gain why use a resistor at all? How was the value of this resistor determined? (There already a 220 ohm resistor on the homework board on every pin of the BS). Are we trying to protect the transistor from being overdriven or accounting for the fact that Zero on a BS I/O pin is actually a little more than 1 volt?
Question 2: when I go to check the actual current running through the LED segments the book showed a 1k resistor in series with each anode and the appropriate BS I/O pin which I did. When I take a Voltage drop across this resistor its about 4 volts meaning the LED is only being driven by 4ma? Why so low? Where is the Datasheet for this display chip (couldn't find it here or online)? With such a low current the displays comes out very dim when I multiplex them and they are only on for 5ms at a time, how much higher can I run the current up to without damaging the display segments? Where did the value of 1k come from (there already a 220 ohm resistor on the homework board on every pin of the BS)?
If I am overlooking something or doing anything horribly wrong I would appreciate any feedback and or correction.
My thanks to anybody caring to answer and take their time. Its been over 30 years since I did any real electronics work. I am having a lot of fun trying to remember this stuff and using a BS sure makes it easy and fun to create simple projects like this. FYI, I am by profession a computer programmer for over 30 years, haven't done much hardware since then.
Thanks again,
David
Comments
2) The I/O pins of the Stamp can handle roughly 20mA without damage. There's a limit of around 70mA for each block of 8 I/O pins though and a limit of around 150mA for the entire Stamp. If all of the segments for a digit are on at the same time, that's less than 10mA per segment. The 1K resistor limits the current to well under that.
In "real life", multiplexed arrays are run at fairly high peak currents with an average current on the order of 10-20mA per segment. If you have 9 digits (3 groups of 3), you'd have 7 segments plus a decimal point = 8 LEDs with a peak current of 9 x 15mA each = 135mA x 8 = roughly 1A. You would need transistors to switch the segments (anodes) and transistors to switch the digits (cathodes) with the Stamp driving the transistors. You'd also have to never make a programming error because, if your program ever stopped multiplexing, you'd burn up some LEDs. The complexity of all these switching transistors and the intolerance for errors is not appropriate for an introductory text. Better to keep things simple and maybe dimmer.
Question 1: "Why 2 100k?..is this not the same 1 50k resistor?" - Yes it is, take a look at this thread...
http://forums.parallax.com/showthread.php?p=575027
"..why use a resistor at all?...How was the value of this resistor determined?...Are we trying to protect the transistor from being overdriven?" - All excellent questions. Transistors are current controlled devices and can only take a small amount of voltage difference between the B-E (Base-Emitter) junction (typically about 0.6V). Refer to this thread...
http://forums.parallax.com/attachment.php?attachmentid=37701
"...Zero on a BS I/O pin is actually a little more than 1 volt?" - Zero should range from 0V to 0.6V depending on the load influenced by other circuit components. The input Threshold of the I/O is about 1.4V, maybe that's what your thinking. This is the voltage level at which the I/O can determine if the input voltage is a 1 or a 0
Question 2: "...the LED is only being driven by 4ma? Why so low?" - This is a typical value and can vary widely from just a few mA to several mA.
"Where is the Datasheet for this display chip? - that I'm not sure, but 4mA is typical.
"With such a low current the displays comes out very dim when I multiplex them and they are only on for 5ms at a time, how much higher can I run the current up to without damaging the display segments?" - There are 1000ms in one second and your time slicing the amount of "On-time" by 1/200th of a sec. Typically you calculate for the average current over time, which would mean that your 4mA drive needs to be 800mA now for 5ms. Generally this is true, but our perception on how we see the LED brightness and how the LED responds to higher currents is not linear, so this value can vary. You need to also make sure that the LED can also handle a current burst like that, there are also limitations there as well that are usually given in the datasheet... some LED's just can't be driven that high. Also, very important!!! you want to make absolute certain that this section of your code works properly. If it stalls and spends too much time driving the LEDs at high current, they will burn out rather quickly.
"Where did the value of 1k come from? - the P-N junction in an LED isn't that much different than a P-N junction in a transistor. i.e. the B-E junction. The difference is, that the operating voltage or 'band-gap' voltage is usually higher. Typically for LED's this ranges from 1.2V to 3V and it is often color dependent. For a typical red LED, this voltage is about 1.6V ... So the formula is used to determine the resistor takes into account the Voltage supply to the LED, and the amount of current to the LED....
R = ( Vsource - Vled ) / Iled
R = 5V - 1.6V / 4mA
R = 850 Ohms , which rounded to the next most common resistor equals 1000 Ohms or 1K
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 8/25/2009 3:39:43 PM GMT
Thanks for your replies, appreciate the help.
Guess I will give up the multiplexed LED's and just go with one of the LCD displays or else just work with the dimness.
You shouldn't need the circuitry used in my project.·
I don't know which approach you're taking with your MUXing.· The program might give you some ideas (??).
·
I was originally just gonna use a couple 7seg LED's cause I only needed 3 digits for a simple digital thermometer. Since the Basic Stamp only has 16 I/O pins and each LED uses at least 8 I was gonna try to mux them and save the cost of using say one of the LCD displays. What I put together works fine except the LED's are somewhat dim since they are being switched on and off at high speed of course. Now however due to the points made by Mike and Beau and the fact I am lazy to solder all those resistors and transistors and such into the final project, I changed my mind on that approach. I have also since decided to add a couple more things to the project and so am gonna use the 112 x 16 Serial Graphic VFD Display module from the Parallax store and fancy up the display output a little just for fun. So, the mux idea is for the moment put on the shelf. Thanks for sharing your project with the SX I will keep the link with my notes if I delve back into the idea for any future project. I have not used the SX yet myself although I do like assembly programming better than high level languages and it is on my list of things to look into in the future. FYI, I am also switching streams from the Basic Stamp to the Propeller chip. I am doing my proof of concept on the Propeller demo board and will probably take a shot at the Shcmartboard for the final project. I am as I say lazy about doing a lot of soldering but I have always wanted to try my hand at some surface mount stuff, go figure... LOL
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Often the joy is not so much in the having, its in the building...