Using D Flip-Flop and Decoder
This way of multiplexing uses Octal (8 – Bit) D Flip-Flop 74574 and 3-to-8 Decoder 74138. The D Flip-Flop serve as a memory to store a bit of data. So to control 64 LED we need 64 D Flip-Flops, that is eight 74574 chips. We give same data to D0 t0 D7 of all chips and each chip is enabled at different times. Thus we can individually set Logic LOW or HIGH to outputs of each chip.
The 74574 D Flip-Flop has the following pins.
Eight Inputs (D0 – D7)
Eight Outputs (Q0 – Q7)
Common Clock (CP)
Output Enable (OE – Active Low)
When the Output Enable (OE) pin is high all the output pin of 74574 will be in Logic LOW. When it is LOW the output follows the input when a LOW to HIGH pulse occurs at Common Clock (CP) pin. In other cases the output follows the previous output, ie latched. We connect 8 output pins of pic microcontroller to the eight inputs (D0 – D7) of each chip. The Clock for each chip is given at different times.
Next problem is that, we need 8 Output Pins to enable each chip. This can be solved by using a 3-to-8 decoder ( IC 74138). It converts 3 lines to 8 (Y0 – Y7). When the input is 000 the output Y0 will be activated (Y0- LOW, Other Outputs – HIGH), when it is 001 the output Y1 will be activated (LOW)
The 74138 has following pins
Three Inputs (A, B, C)
Eight Outputs (Y0 – Y1, active Low)
Three Enables (2 – active low and 1 – active high)
We use the three output lines of PIC Microcontroller to select one of the 8 outputs. The chip will be enable only when its two active low enable inputs are at Logic LOW and the active high enable input is at Logic HIGH. All the output pins will be high when the chip is disabled.
Circuit Diagram
The following example MikroC Code works the above circuit as a Chaser.
MikroC Code
Code: Select all
void main()
{
int i,c;
CMCON = 0x07; // To turn off comparators
ADCON1 = 0x06; // To turn off analog to digital converters
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
PORTD = 0x00;
do
{
PORTB = 1;
for(c = 0;c<=7;c++)
{
for(i=0;i<=7;i++)
{
PORTC = i; //To Select a particular chip
PORTD.F0 = 1; // Enable 74138
Delay_ms(20); // To give a pulse with of 20ms
PORTD.F0 = 0; // Disable 74138
}
PORTB = PORTB<<1; // Left Shift
}
}while(1);
}
Using Serial-in-Parallel Out Shift Register
Here we use the IC 74164 an Eight Bit Serial-in-Parallel Out Shift register. The Data is given serially through one pin. To connect 64 LEDs we need eight 74164 chips. We are giving same clock to eight chips and different data input lines. Thus we need 8 Output pin for Data and 1 Output pin for Clock of the PIC Microcontroller. We can see that the pin number is reduced than in the previous method, but this method is a bit slower compared to the previous. The IC 74164 has the following pins.
Data (A and B, these two pins are ANDed internally)
Clock (CP)
Chip Enable (MR – Here we don’t use this pin)
Here we connect the data input pin A of each chip to an Output pin of PIC Microcontroller and B is tied to Vcc (LOGIC HIGH). The Clock pin (CP) of each chip is tied together and connected to another output pin of PIC Microcontroller. Thus we can easily control the 64 LEDs very easily.
Circuit Diagram
The following example MikroC Code works the above circuit as a Chaser.
MikroC Code
Code: Select all
void main()
{
int j;
CMCON = 0x07; // To turn off comparators
ADCON1 = 0x06; // To turn off analog to digital converters
TRISB = 0x00;
TRISD = 0x00;
PORTD = 0x00;
do
{
PORTB = 0xFF;
for(j=0;j<8;j++)
{
PORTD.F7 = 1;
Delay_ms(50);
PORTD.F7 = 0;
PORTB = 0;
Delay_ms(200);
}
}while(1);
}
Article courtesy of electrosome.com