Current consumption is always an important consideration when designing battery-powered devices. This circuit shows how a seven-segment display can be driven by a microcontroller in a way ideally suited for such applications. Furthermore, we even economize on component count! In a conventional circuit where a single digit is displayed each individual segment is provided with its own current-limiting resistor through which it can be continuously driven. If the current consumption is 5 mA per segment then the total current draw when displaying an ‘8’ will be 35 mA. If multiple digits are to be displayed, they are normally multiplexed in a sequential fashion so that only one digit is driven at a time. In this case, the total maximum current draw remains at 35 mA per digit.
The circuit described here uses only one series current-limiting resistor per seven-segment display, and it is possible to reduce the total current consumption to 5 mA per displayed digit. The trick is to use multiplexing at the segment level, realized in software in a microcontroller (in this example an ATtiny24). In the software, each digit to be displayed is represented by a seven-bit string. Each position in the string corresponds to a segment to be driven and can take on the value 0 (for ‘off’) or 1 (for ‘on’). For example, the digit 6 could be represented by the string ‘0111111’, with all segments except the first being illuminated. The software examines the elements in the string one by one in sequence and turns the corresponding segment on or off (see listing). The time period allotted to each segment is about 2 ms and so the digit is refreshed at about 70 Hz, giving a flicker-free display.
As an example application of this technique, the author has designed a digital die (see the circuit diagram). As long as input pin PB2 is held low by the user holding down button S1, a counter counts through the digits from 1 to 6 at a 1 kHz rate. When S1 is released the counter’s current value is shown on the seven-segment display. There are only a few components in the circuit and so the whole thing can easily be constructed on a piece of prototyping board or on the ELEX-1 (UPBS-1) experimental printed circuit board. The microcontroller is available ready-programmed from Elektor. A type CR2032 battery provides the circuit with a 3 V power supply, which is smoothed by capacitor C1. The output ports of the ATtiny24 are capable of switching currents of 5 mA without difficulty and so they can be connected directly to the corresponding inputs of the seven-segment display module. Only one segment is ever active at any one time and so R1 acts as a current-limiting resistor for the entire display. Be careful when selecting a display that it only includes one LED in each segment, as otherwise, the supply voltage of 3 V will not be high enough.
In the interests of reducing power consumption button S1 has a further function: if it is held for more than two seconds, a minus sign flashes on the display for a few seconds and then the microcontroller switches into sleep mode. Current consumption in this mode is less than 1 µA. A further press of S1 will wake the microcontroller up again. If the user forgets to put the microcontroller to sleep, it will automatically switch to this mode two minutes after the last roll of the die. These functions obviate the need for an extra switch to interrupt the power supply.