??? 12/26/08 04:37 Read: times |
#161133 - add up the forward voltages, adjust the resistors ... Responding to: ???'s previous message |
Cuenta Chocula said:
The display is from an alarm clock and the IC that drove it was a complete alarm clock on a chip. I just want to use the display on its own with an 8051 driving it. I decoded it so I could use a lookup table, but in the end even to use a single segment I have a fundamental question.
Let's say you've got a board with two LED's on it but the LEDs have separate anodes and a common cathode. In order to control each LED separately you'll need to use the micro-controller to supply current to the correct anode. This is my first problem because I'm a beginner at this, I've only used the micro-controller ports to connect ground, not voltage to a device. Usually I have the voltage connected to the anode on an LED and then just have a port on the 8051 connect to ground and that's how I control it. You'll find that the MCU generally can't supply enough current to drive the segment to full brightness. Depending on the LED, it can require anywhere from 4mA to about 20 mA for typical-size LED. Now, I don't know what sort of LED's these are, so I wouldn't hazard a guess. If you start with a decent current mirror, e.g. a pair of NPN transistors with their bases connected together and to the collector of one of the two, and a pretty large-value (a current mirror is intended to be a high-impedance device) fixed resistor to GND from the emitter of the one the collector of which is connected to the two bases, a pot connected as a variable resistor to Vcc will set the current in that diode-connected transistor. Since the current is (Vb-Vbe)/R, and since Vb is the same for both transistors, you can then limit the current in the second transistor by means of an emitter resistor to GND, or following any other path so long as it's constant. If that path happens to be through an LED, and from there through another transistor or open-collector driver, it won't matter so long as the open-collector driver can sink the combined current from as many as seven segments. Another set of transistors can control whether the current flows or not, as it will switch each control transistor on or off in accordance with a port bit driving its base through a resistor, the function of which is simply to protect the base-emitter junction. If that seems complicated to you, and it is, a bit, then perhaps you should consider a high-side driver or a resistor to Vcc pulled down with a low-side driver, e.g. ULN2003A, which has seven darlingtons. Then, assuming the above is possible and I can supply voltage to at least two pins via software, I already know how to connect the other pins to ground and can get it to work.
Eric's suggestion that I use a high side driver is probably a little over my head. But since he mentioned transistors I was also thinking that I could use a transistor as a relay to turn on voltage to each anode. Then I could use a port/pin on the micro to control the voltage to the correct anode via a transistor and use other ports to connect the correct cathode pin to ground. I've never used a transistor before except when plugging it into someone else's design, but maybe I could figure it out. No ... you can't use a transistor as a relay. You can, however, use it as a switch. If you prepare a wiring diagram of the display and the configuration in which you intend to use it, perhaps I can be of some help. A bipolar transistor, e.g. 2N2222A or even 2N3904, might serve but it has a forward voltage of about what a silicon diode has, typically ~0.68 volts. The MCU can't source enough to drive just any LED individual anode, nor can the MCU sink enough to drive most common cathodes, as they often have 8x the current of a single segment (consider '8' with decimal point or colon). A current sink on a common cathode isn't appropriate because the amount of current required is dependent on the number of segments driven. A current mirror will give you a well-controlled current. A simple switch, e.g. ULN2003A to GND will serve to sink however many segments it has to sink. Likewise, you can use a ULN2003A to sink the current to each anode, knowing that it will "light up" only when you turn the current sink at the anode OFF. Your switch to GND, on the "common" (meaning common to all segments) cathode, can be a bipolar transistor, which will then inject a voltage loss of about 0.68 volts, or a MOSFET, which will behave as, in many cases, a VERY small value resistor, e.g. 0.03 ohms or less. You probably ought to think about the voltages and currents you need to control, and empirically determine what the appropriate current per segment for your device is. Ohm's law is your friend. RE |