Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?

[Ideas For Design]

Circuit Controls Two LEDs With One Microcontroller Port Pin



Spehro Pefhany  |   ED Online ID #1683  |   April 01, 2002

Article Rating: Not Rated

Microcontroller port pins can typically be driven either high or low, or else be put into an "input" or high-impedance state. This circuit uses the three states to drive two separate LEDs with one port pin. This can be very useful when there are no port pins to spare—something that usually happens.

The simple way to drive two LEDs is via two port pins (Fig. 1a). The improved version requires only one additional resistor (Fig. 1b). It can be designed for most reasonable LED voltages and supply voltages, as well as to yield the desired "on" currents in each LED, which may be different if desired. The design parameters are:

V1 = off voltage for D1 (worst case maximum voltage for no visible light from D1)

V2 = off voltage for D2 (worst case maximum voltage for no visible light from D2)

V3 = on voltage for D1 (forward voltage of D1 at design current plus port voltage drop)

V4 = on voltage for D2 (forward voltage of D2 at design current plus port voltage drop)

Ion1 = desired on current for D1

Ion2 = desired on current for D2

Vcc = supply voltage

The design equations are:

Ion1 = [(Vcc − V3)/R1] − [V3/(R2 + R3)]

Ion2 = [(Vcc− V4)/R2] − [V4/(R1 + R3)]

(V1 + V2)/R3 = (Vcc − V1 − V2)/(R1 + R2)

To minimize current consumption, R3 is made as large as possible, without the LEDs turning on with the port pin in the high-impedance state.

These equations can be solved by using an Excel spreadsheet (Fig. 2). This minimizes the sum of the squares of the errors of each LED's on current, as compared to the design values. Inserting typical values as follows, assume one yellow and one red LED for D1 and D2, respectively:

V1 = 1.2 V

V2 = 1.1 V

V3 = 2.2 V (inclusive of port-pin voltage drop when sourcing current)

V4 = 1.9 V (inclusive of port-pin voltage drop when sinking current)

Ion1 = 0.008 A

Ion2 = 0.008 A

Vcc = 5.0 V

The solver tool comes up with values that can be rounded to the closest 5% standard resistance values as follows:

R1 = 300 Ω

R2 = 330 Ω

R3 = 1.2 kΩ

Then, the practical resistor values can be plugged into the same cells that the solver modified, to read the resulting currents and quiescent current, Iq. In this case, the circuit draws a quiescent current of 2.7 mA when both LEDs are off. When it's on, the circuit supplies almost exactly 8 mA to each LED. If it's desired to have both LEDs appear on, the port pin can be rapidly cycled between 0 V and Vcc. If the rate is somewhere around 100 Hz or higher, both LEDs will appear steadily illuminated.

This circuit works best with microcontrollers that have Schmitt-trigger or analog inputs. Other types may draw unnecessary supply current if the input is biased close to the center of the supply voltage.




Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


  • Network-On-Chip Tools Arrive for The Masses
  • Tackling System Design Challenges Through Early Verification
  • ESL Tools Take Center Stage As Designers Move Up
  • Parasitic Extraction Tool Targets Next-Generation Custom ICs
  • Synopsys Jumps Into ESL-Synthesis Pool
  • Verify Control Systems Before Committing To Hardware
  • You're Using How Many FPGAs?
  • Tool Up For The FPGA Blitz
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (188 views today)
    2) Hot Hands For Some Cool Rock: Motion Sensing Meets Audio Engineering
    (169 views today)
    3) GPS-Derived Grandmaster Clock Delivers Ultra-Precise Time And Frequency Sync
    (70 views today)
    4) What's All This Transimpedance Amplifier Stuff, Anyhow? (Part 1)
    (68 views today)
    5) Bidirectional H-Bridge DC-Motor Motion Controller
    (62 views today)
    ALL TOP 20







    POST YOUR COMMENTS HERE

    Name:

    Email:
    Rate this article:

     less useful more useful 
    1
    2
    3
    4
    5
    Your Comments:

    Enter the text from the image below




    Please refresh the page if you have trouble reading this text.
    (Acceptable Use Policy)
     
     

    PartFinder

    Find real-time pricing, stock status, same-day/next-day shipping options and more. Brought to you by Digi-Key. Go to PartFinder.    
    GlobalSpec

    PART SEARCH :
    Powered by: GlobalSpec - The Engineering Search Engine
    Sponsored Links

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources