Pin multiplexing on microcontrollers

When using microcontrollers there is a lot of benefit to be gained by using the smaller ones in 8-pin-20-pin packages due to lower cost and availability in easy to use DIP packages rather than surface mount, so there is a constant striving for more efficient use of the I/O pins to minimise the need to go to a larger package.

A popular technique when driving LEDs for instance is to multiplex the outputs into columns and rows which can be very effective for a large array (for example an 8×8 array of 64 LEDs only needs 16 pins) and is well understood and easy to implement, but for a smaller array such as 2×4, the reduction in I/O from 8 pins to 6 pins is not usually worth the effort. With a bit of extra programming (which is free once you have done it) you can operate a 2×4 array of LEDs with only 5 I/O pins, which might get you out of a sticky situation and enable you to use an 8-pin device rather than have to go up to a 14-pin device.

The trick involves wiring half of the LEDs in inverse parallel with the other half and driving each set of LEDs on alternate phases of a single strobe line. This can be extended still further by driving the outputs by switching the microcontroller’s tristate output buffers on and off, allowing the I/O pins to be read when the buffers (and the LEDs) are off so that each of the LEDs can have an associated momentary switch to Vss or Vdd (which makes the LED light when pressed). With 5 I/O pins this gives 8 LEDs and 8 switches.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: