Multiplexing Four 7-Segmen LED Displays With PIC16C71

Sunday, June 23rd 2013. | Display, Microcontroller

Hardware for Multiplexing Four 7-Segmen LED Displays With PIC16C71

The PIC16C71′s I/O ports have an improved sink/source specification. Each I/O pin can sink up to 25 mA and source 20 mA, in addition total PORTB source current is 100 mA and sink current is 150 mA. PORTA is rated for 50 mA source current and 80 mA sink current. This makes the PIC16C71 ideal for driving 7-segment LEDs. Since the total number of I/O pins is limited to 13, the 8-bit PORTB is used to drive the 4 LEDs, while external sink transistors or MOSFETs are used to sink the digit current. Another alternative is to use ULN2003 open collector sink current drivers, which are available in 16-pin DIP or very small SO-16 packages. Each transistor on the ULN2003 can sink a maximum of 500 mA and the base drive can be directly driven from the PORTA pins.

Multiplexing Four 7-Segmen,7-Segmen LED Displays,7-Segmen LED Displays With PIC16C71

Software for Multiplexing Four 7-Segmen LED Displays With PIC16C71

The multiplexing is achieved by turning on each LED for a 5 us duration every 20 us. This gives an update rate of 50 Hz, which is quite acceptable to the human eye as a steady display. The 5 us time-base is generated by dividing the 4.096 MHz oscillator clock. The internal prescaler is configured to be a divide by 32 and assigned to Timer0. TMR0 is pre-loaded with a value = 96. TMR0 will increment to FFh and then roll over to 00h after a period = (256-96)·(32 ·4/4096000) = 5 us. When TMR0 rolls over, flag bit T0IF flag is set, and because bits T0IE and GIE are enabled, an interrupt is generated. The software implements a simple timer which increments at a 1 second rate. Every second, the 4 nibble (two 8-bit registers MsdTime and LsdTime) are incremented in a BCD format. The lower 4 bits of LsdTime correspond to the least significant digit (LSD) on the display. The high 4 bits of LsdTime correspond to the second significant digit of the display and so on. Depending on which display is turned on, the corresponding 4-bit BCD value is extracted from either MsdTime or LsdTime, and decoded to a 7-segment display. The TMR0 interrupt is generated at a steady rate of 5 us and given an instruction time of 1 us. The entire display update program can reside in the interrupt service routine with no chance of getting an interrupt within an interrupt.

Comments are closed.