• Channels
Part Inventory
Go
 
powered by:

 
  • Quick Poll
What Social Networking site do you use the most?



VOTE VIEW RESULTS
Previous Polls

Premium Content

New Signal Chain Technical Papers from Texas Instruments:

 

 

 

Simple Technique Drives Multiple LEDs From One Processor Pin


May 07, 2009

Print
Reprints Comment Subscribe

Driving multiple LEDs with one microprocessor GPIO pin is a well-known technique. Typically, designs perform this task by issuing pulse widths and clocks of differing durations and employing multiple RC networks to distinguish between them. The design described here is much simpler.

The microprocessor pin is connected to the clock of a multiple-output sequential counter (see the figure). In its simplest form, this state machine consists of two D flip-flops cascaded to form a two-bit ripple counter. The counter’s most significant bit (MSB) is also connected to the pin through resistor R1.

Consider when the counter changes state on the rising edge of the pin transition. With the pin configured as an output, the counter can be clocked by the pin to reach all of the counter’s distinct states. But it’s not clear how the processor ever knows what state the counter is in. If the processor can recognize one counter state, though, it will know how to clock the counter to reach any other desired state.

The processor can begin to determine the initial counter state by issuing a HighClockRead. A HighClockRead consists of setting the pin sequentially as an output high, output low, output high, and then as an input, waiting on the order of a microsecond for the pin capacitance to be driven to a stable state through the resistor. Then, the counter’s MSB state is read through the pin.

If the read is high, the processor issues another HighClockRead. If it’s low, the device issues a LowClockRead. This consists of the pin configured sequentially as an output low, output high, and as an input, and then waiting and reading the MSB as with a High- ClockRead. (Issuing a LowClockRead or a HighClockRead as appropriate ensures that only one clock transition (low-to-high) occurs per ClockRead and that the counter advances by only one state.) The processor continues to issue either HighClockReads or LowClockReads. It halts when it detects successive counter MSB states consisting of a low followed by a high.

Because the counter is designed so that the MSB transitions from low to high only a single time in the sequence of all possible counter states, the processor now knows the exact counter state. It is possible, then, to issue the number of low-high transitions (without intervening reads) that are required to put the counter in the desired state.

This scheme works because the microprocessor is able to read and advance the counter too quickly for the eye to see any intermediate LED states. The only timing requirements are that the delay of the counter and the settling time of the R-C are accommodated by the processor. This requirement is easily met.

Once the counter state is known and needs to be changed, it isn’t necessary to read after every clock pulse. It may instead be preferable to read only the two states in which a low is expected to be followed by a high to ensure that the counter remains in sync.

To minimize power dissipation through the resistor when the counter is un-clocked in order to perceive a particular LED state, set the processor pin as an input or as an output with the same state as the MSB.

Average (0 Ratings):

Subscribe
Subscribe to Electronic Design and start receiving more articles like this one
Filed Under:

Check for price and availability on Source ESB:

Go
powered by  
  • Jay Miller
    2 years ago
    Sep 24, 2010

    Having been 'down that road', I've found it cheaper,faster,easier to just buy the 'next size bigger' micro.The cost of the flipflop,increase in board size,etc. outweighs the benefit.While it's a nice idea, the implementation(R&D,layout,etc) costs more than a bigger micro.

  • Rick Collins
    2 years ago
    Sep 23, 2010

    This may seem like a lame idea, but there are different reasons for only using a single MCU pin. The LEDs might be on a different board and there might only be one available pin in the connector. Often you have to jump connector sizes by a significant number of pins and can jump the cost up considerably, not to mention the board space. Although this is shown as two HC74 FFs, it could be extended to any size counter short of a size that makes visible blinking when it does the sync function.

    I see this as a potentially useful idea. It beats the heck out of using a 1-wire device to get one or two I/Os.

  • KGround
    3 years ago
    May 11, 2009

    One microprocessor pin and a bunch of other parts and code ... Not meaning to demean the author's work here - it is a solution that will work, and apparently solves a problem the author has experienced, but not efficient of parts or code in my opinion.
    I thought one of the reasons we use microprocessors is to reduce the count of support parts. Why not just buy a processor with a few more I/O ?

  • KGround
    3 years ago
    May 11, 2009

    One microprocessor pin and a bunch of other parts and code ... Not meaning to demean the author's work here - it is a solution that will work, and apparently solves a problem the author has experienced, but not efficient of parts or code in my opinion.
    I thought one of the reasons we use microprocessors is to reduce the count of support parts. Why not just buy a processor with a few more I/O ?

You must log on before posting a comment.

Are you a new visitor? Register Here
Acceptable Use Policy

Sponsored Links