View this week's entry ad »
Part Inventory
powered by:
Part Finder
Go
powered by:
  • Quick Poll
What Social Networking site do you use the most?



VOTE VIEW RESULTS
Previous Polls
Hotspots » Analog & Mixed SignalPowerEmbedded

Premium Content

Editors' Picks

Featured Industry Resources

Simple Technique Drives Multiple LEDs From One Processor Pin

Highlights

  • Technique uses a multiple-output sequential timer
  • Two D flip-flops are cascaded to form a two-bit ripple counter.

By Staff

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 ( Ratings):
Filed Under:

Check for price and availability on Source ESB:

Go
powered by  

Related Products

comments
Add A Comment\(Log in or create an account\)
  • May 11, 2009 07:20 AM

    by KGround

    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 Now

Acceptable Use Policy

Sponsored Links