Pico LED Matrix Shield – Theory

Published by frenoy on

This post aims to give you an overview of how the LED shield operates. We briefly talk about the matrix circuit, shift registers and MOSFET inverters that make up the shield.

The LED Matrix:

The LED matrix consists of 8 rows (R1,R2,…,R7,R8) and 3 columns (C1,C2,C3). Here’s an illustration of how the LEDs are connected within the shield.

As can be seen, LEDs 1,2,…,7,8 make up column 1, while 9,10,…,15,16 make up column 2 and 17,18,…,23,24 make up column 3. The anodes of each of the LEDs are individually connected to a current limiting resistor and they are then tied up together to form the three-column signals C1_5, C2_5, C3_5. This is illustrated below:

The cathodes of the LEDs are grouped horizontally to form the 8 rows. LEDs 1,9,17 make up row 1, LEDs 2,10,18 make up row 2 and this continues for the rest as shown below.

Basic electronics teaches us that an LED will glow (turn ON) when the anode is at a higher potential compared to the cathode. The exact value of this potential difference depends on the LEDs in question, but let’s just consider that we need to apply a positive voltage (say 5V) to the anode and 0V to the cathode to turn ON the individual LEDs present in the shield.

If we want to turn ON LED 1, then we need to apply 5V to the C1_5 column pin and we need to apply 0V (ground) to the R1 row pin. This way, there will be a positive voltage applied to LED 1 and it will start glowing.

Similarly, if we want to turn ON LED 13, then we need to apply a positive voltage to the C2_5 column pin and we need to ground the R5 pin.

In conclusion, by applying the correct voltages to the column and row pins, we can control the individual LEDs. This allows us to interface several LEDs (24 in this case) by using very few pins.

The Shift Registers:

The matrix above requires 8 row and 3 column pins. We could go ahead and use a total of 11 pins to control the LEDs and it would work (to an extent) but that would mean sacrificing 11 pins just for this purpose, which is a bit wasteful. That’s precisely why we’ve used shift registers for the shield.

NOTE: If you do interface a LED matrix directly to a microcontroller then please pay attention to the amount of current that the microcontroller can source or sink. In almost all the cases, you will need external circuitry (transistors, MOSFETs or drivers) to properly interface the matrix.

We have used two 74HC595 shift registers to control LEDs. One 74HC595 controls the rows while the other one controls the columns. Another interesting thing about these particular shift registers is that they can be linked (daisy-chained) to extend the total number of shift registers that can be controlled as can be seen below:

Shift register U1 controls the 3 column pins while U2 controls the row pins. U1 receives the data-stream from the microcontroller at pin 14 (DS) and outputs the stream to pin 9 which is tied to the input pin of U2. This means that we can use a single data stream pin to control the outputs of the two shift registers.

The way the two shift registers are wired means that we need to send the byte corresponding to the row values first (let’s call it the row-byte), followed by the byte corresponding to the column (let’s call it the column-byte).

Shift registers can be considered to be storage elements, which means that they can be used to store data (a 0 or 1). The 74HC595 has 8 such locations each corresponding to a particular pin. Data is sent to the shift register using the DS pin and all data is sent serially, 1 bit at a time. A clock pulse (SH pin) is needed to allow the shift register to sample the data at the correct time, without which, there would not be a reliable way to sample and store the data. The shift register also needs to know when the microcontroller is sending data to it (there could be multiple shift-registers connected in parallel for instance), which means that we need another pin for this and we call this the latch-pin or ST.

In conclusion, we need 3 pins to communicate with the shift registers:

  • DS: Data stream
  • SH: Clock pulse
  • ST: Latch pin

Using these 3 pins, we can shift data into the shift registers and the values would then appear on the output pins (rows and columns).

The Column MOSFETs:

If you’ve been looking at the images carefully, you would have noticed that the outputs from the column shift-register (U1) are C1, C2, C3 while the LED matrix uses signals C1_5, C2_5, C3_5 – which are not the same. If you’ve been wondering how they are linked together then the answer is column MOSFETs.

The need for column MOSFETs is a bit subjective here as you could run the matrix without them. We decided to include them for two main reasons:

If all the 24 LEDs are turned ON simultaneously then the column shift register (U1) would have to source the current for all the LEDs, which is not ideal. Having MOSFETs would mean that U1 only needs to switch ON the appropriate MOSFET and not have to supply the higher LED current.

The row shift-register pins are directly connected to the cathodes of the LEDs, which means that the bits need to be 0 to turn on the LEDs. If the column shift-register pins were directly connected to the anodes of the LEDs then the bits would need to be 1 to turn on the LEDs. This results in a bit of a mismatch in our opinion. By using the inverters, we not only take care of point 1 above but we can also state that the LED matrix works in an active-low configuration. This means that if we want to turn a particular LED ON, the corresponding row and column values need to be 0.

Here’s a simplified schematic of the inverters:

C1, C2, C3 feed the GATE of the MOSFETs while the DRAIN is connected to 5V using a current limiting, pull-up resistor.  C1_5, C2_5, C3_5 denote the 5V pull up signals for the column bits respectively and are connected to the anode section of the LEDs as seen earlier.

This configuration is the most basic MOSFET inverter. A logic HIGH (5V) at the input (GATE) will provide a logic LOW (0V) at the output (DRAIN) and a logic LOW at the input will provide a logic HIGH at the output. In other words, the circuit inverts the input logic level.

This is illustrated below:

This covers all the important that you need to know about the LED matrix shield. Check the other posts on the product page to learn ho wto interface the shield and create patterns.

Categories: Piksey Pico