Keywords: LED driver, LED driving, push-pull, push pull, totem pole, GPIO, port expander
Driving LEDs with Push-Pull Port Expander Outputs
R1 or R2 = (V+ - VPORT - VLED) / IPORT ohms
where V+ is the I/O expander and LED supply voltage
VLED is the voltage drop across the LED(s) at the required load current (usually in the range 1.8V to 2.4V for red LEDs, and 3V to 4.2V for blue, white, and high efficiency green LEDs)
VPORT is the voltage drop across the output port when sinking the required load current (for example 0.25V at 20mA for MAX7310)
Figure 1. Standard LED connection.
The LED current will vary with supply voltage and LED forward voltage. Resistor initial accuracy and temperature coefficient, plus any variance in port output voltage with temperature and supply voltage, will also play a part. If consistent LED current is important, make sure that the voltage drop across resistor R1 is high compared with the total voltage variances in supply and LED. For example, consider a situation where we need to drive a nominal 20mA through a red LED whose forward voltage is 2V ±0.2V. We have a choice of 3.3V ±5% or 5V ±5% supplies, and a 5V I²C bus. A MAX7310 will work on either supply with a 5V I²C bus, because its I²C interface is overvoltage protected. The MAX7310 port will drop 0.2V ±0.1V when sinking 20mA.
Using the typical values, the value for R1 calculates to be (5 - 2 - 0.2) / 0.02 = 140Ω for the 5V supply case, and (3.3 - 2 - 0.2) /0.02 = 55Ω for the 3.3V case. Using these exact values for R1, then the actual current variation at the tolerance extremes would be ±3.9mA (a 19.5% variation) for the 5V case, and ±8.5mA (a ±42% variation) for the 3.3V case. Clearly the 3.3V solution has a much wider current variation than the 5V solution. However, the 5V solution dissipates more power in the current limiting resistor. If this current variation is too high, consider using a port expander with constant-current (internally current limited) outputs such as MAX6956 and MAX6957, or use techniques such as shown in Figures 7 to 12 which use an external transistor to control the current more accurately.
An alternative standard LED connection is shown in Figure 2, and in this case the port is sourcing current instead of sinking it. As a rule, the Figure 1 'sink' drive is preferred to the Figure 2 'source' drive because most ports (and logic outputs for that matter) can sink more current than they can source. Also, the driver voltage drop is usually higher across the current sourcing PFET than the current sinking NFET for the same current. The Figure 2 circuit does have the advantage that the LED cold end is grounded, usually simplifying PCB layout slightly. Also, the true logic operation (a high output lights the LED) may ease the software implementation.
Figure 2. Alternative LED connection.
Note that cold ends of the LEDs in the circuits of Figure 1 and Figure 2 are connected to one of the port expander supply pins, V+ or GND. The protection diodes within the push-pull output structure of a CMOS driver disallows connection of a load referred to a voltage outside the supply range. However, it is possible to connect the LED in the Figure 1 circuit to a lower voltage such as 3.3V instead of the 5V port expander supply. This would save some power dissipated in resistor R1, but increase the LED current variation due to supply and other tolerances as discussed earlier.
Figure 3. Driving multiple LEDs from one output.
Figure 4. Paralleling outputs - the safe way.
An alternative approach is to guarantee that the paralleled ports are switched together. Many port expanders (MAX7300, MAX7301, MAX7310 and MAX7311 included) use a register structure that allows multiple outputs to be switched simultaneously with the same software command. If this is the case, it becomes a software issue to ensure that the ports will always be set to the same level, and the circuit of Figure 5 can be used. Remember that programming the ports to opposite logic levels will directly short the outputs...
Figure 5. Paralleling outputs - the lower cost way.
The first two circuits uses a single transistor switch which essentially replaces the port expander's output driver (Figures 6 and 7). The transistor ratings alone determine how much LED current and voltage can be handled. Advantages of this circuit compared with the circuits discussed next are low wasted voltage across the transistor switch because it is turned on hard, and the LED current will not vary with port expander supply voltage. Disadvantages are that LED current will vary with the VEXT supply voltage, and that the circuit uses two resistors.
Figure 6. Driving LEDs with higher current and a positive voltage.
The circuit of Figure 6 allows any positive voltage to be used for VEXT. The circuit of Figure 7 allows any negative voltage to be used, and has the advantage that the LED current flows from the port expander supply to the negative supply, making the sum of the two supplies available to drive the LEDs.
Figure 7. Driving LEDs with higher current and a negative voltage.
IPORT = (V+ - VPORT - VBE) / R12 Amps
The port current Iport (also Q3's emitter current) will flow through Q3's collector and the LED loads, less a small base current taken by Q3. The current error due to Q3's base current can be kept below 1% by choosing a reasonably high gain (ß > 100) transistor for Q3. If supply voltage V+ doesn't vary much (VPORT and VBE won't), then this circuit works as a pretty good constant current sink, dependent on the port expander supply voltage, but independent of the LED supply voltage VLED.
Figure 8. Active-low, constant current sink LED drive.
One disadvantage of the Figure 8 circuit is that the LED load current flows through the port expander active low output, thereby limiting the maximum LED current to that of the port expander. The Figure 9 circuit avoids this problem, and allows the current as well as the voltage rating to be determined by the transistor ratings. Q4's emitter current ILED can be calculated using the formula:
ILED = (V+ - VBE) / R13 Amps
In the Figure 9 circuit the port expander active high output is supplying Q4's base current only, which is small enough that the port output voltage drop is negligible and is ignored.
Figure 9. Active-high, constant current sink LED drive.
Figures 10 and 11 show mirror topologies of the Figures 8 and 9 circuits with PNP pass transistors replacing the NPNs. Now the LEDs are referred to a negative supply instead of a higher voltage positive supply. LED current is supplied from the port expander's positive supply and returned into the negative supply.
Figure 10. Active-high, constant current source LED drive.
Figure 11. Active-low, constant current source LED drive.
A limitation of the Figure 8 circuit is that the collector of the external transistor Q3 can go no lower than (V+ - VBE + VCE(sat)), which is only a little below V+. If V+ is high, for example 5V, then not only is the output expander dissipating a high power due to this high voltage drop forced across its output, but also the voltage headroom available for the LEDs is reduced to almost (VEXT - V+). A simple solution is to bias the pass transistor's base to a lower voltage using a series zener diode. Only one zener diode is needed to serve multiple pass transistors, as shown in the Figure 12 circuit. With this circuit Q7's and Q8's emitter voltage sit at about 1.6V when the supply voltage V+ is 5V. The mirror circuit of Figure 10 can be modified in the same way also, but the Figure 9 and Figure 11 circuits will need a separate zener in series with the base of each transistor.
Figure 12. Using a zener diode to minimize driver headroom.
|MAX7300||2-Wire-Interfaced, 2.5V to 5.5V, 20-Port or 28-Port I/O Expander||Samples|
|MAX7301||4-Wire-Interfaced, 2.5V to 5.5V, 20-Port and 28-Port I/O Expander||Samples|
|MAX7310||2-Wire-Interfaced 8-Bit I/O Port Expander with Reset||Samples|
|MAX7311||2-Wire-Interfaced 16-Bit I/O Port Expander with Interrupt and Hot-Insertion Protection||Samples|
|MAX7312||2-Wire-Interfaced 16-Bit I/O Port Expander with Interrupt and Hot-Insertion Protection||Samples|
|MAX7318||2-Wire-Interfaced, 16-Bit, I/O Port Expander with Interrupt and Hot-Insertion Protection||Samples|
|EE-Mail||Subscribe to EE-Mail and receive automatic notice of new documents in your areas of interest.|
|Download||Download, PDF Format (80kB)|
|© Sep 22, 2003, Maxim Integrated Products, Inc.|
APP 2199: Sep 22, 2003
APPLICATION NOTE 2199, AN2199, AN 2199, APP2199, Appnote2199, Appnote 2199