Designing, Testing, Soldering and Programming Through-hole PCB Devices: ESP32, 788BS LED Matrix and 74HC595 Shift Registers

by mymcpr0j in Circuits > Electronics

366 Views, 2 Favorites, 0 Comments

Designing, Testing, Soldering and Programming Through-hole PCB Devices: ESP32, 788BS LED Matrix and 74HC595 Shift Registers

DIY LED Matrix

I worked through the exercises from Freenove's ESP32 C tutorial and found an interesting project: 788BS Matrix. They did a great tutorial, everything worked as intended, but my protoboard looks extremely messy. The matrix was barely visible. You could make it a little tidier by using jumper wires instead of flexible wires, but I wanted to make something useful and easy to use. Plus, it was interesting for me to practise some things while working on a real project. Here are those things:

  •  Designing my own devices from scratch.
  •  Soldering.
  •  C programming.

So I decided to build my own PCB with an LED matrix and 2 shift registers. When I finished the project, it seemed to me that the sequence of actions I had found might be useful to someone.

If you just want to make the 788BS work, you can simply use a MAX7219 module and a corresponding library. And if you want to do everything yourself, then I invite you down the rabbit hole :-).

Supplies

6.jpg
3.jpg

The device

  • Common Anode Dot Matrix Module 788BS.
  • 2x 74HC595 8-Bit Shift Registers in DIP-16 package.
  • 8x 220 ohm Resistors 0.25 watt.
  • 5x7 cm Through Hole PCB Board.
  • 24AWG solid wires (I took them from an Ethernet cable).
  • 5x Pins from Pin Header Strip (90 Degrees Angle).

Tools and supplies

  • Soldering Iron.
  • Sn 63 Pb 37 Solder Wire.
  • Rosin Soldering Flux.
  • Precise Side-cutting Pliers.
  • Flat Nosed Pliers.
  • Utility Knife.
  • Wooden Board.
  • Silicone Soldering Mat.
  • Multimeter.
  • Third Hand Soldering Tool.
  • Tweezers For Electronics.
  • Permanent Marker.

Testing and using the device

  • ESP32 WROOM Development Board.
  • 830 Point Prototype Board.
  • Flexible Wires M/M.
  • Flexible Dupont Wires F/F.

Software

Initial Research

I want to create a PCB with a 788BS matrix and 2 74HC595 shift registers. I want to connect this thing to the ESP32 board, which will give it +3.3V and GND as power supply and some GND or +3.3V control signals.

Is this possible?

The short answer is yes.

The long answer involves some research. But the results of the research are only approximate. I only analyze the most important things. And it's hard to find accurate information about components. For example, I don't know the manufacturer or exact model number of the 788BS matrix I've, so I used a spec sheet for the matrix that looks similar to mine.

The ESP32 WROOM's power supply lines can reliably deliver about 600 mA (someone says it's about 1 A), which is more than enough for our purpose since we're limited by the 74HC595's capabilities.

74HC595 supports a wide input voltage range (up to 6 V), so 3.3 V from the ESP32 is fine. The datasheet says "Continuous current through VCC or GND is 70 mA", so we can draw less than 10 mA (70 / 8 = 8.75 mA) from each pin (each pin supports about 20 mA, but under certain conditions we can turn them all on).

The forward voltage of the 788BS is about 2 V, the forward current is about 20 mA per point.

So, 3.3 - 2 = 1.3 V.

Which resistors should I use? That is indeed the most important question here.

Let us remember Ohm's law: R = U / I. We have to limit the current to 8.75 mA, so R = 1.3 / 0.00875 = 148 Ohm. Maybe this is not safe. If something is changed, we can exceed this 8.75 mA. But anyway, something like a standard resistor of 150 Ohms would be OK. We should remember the tolerance in electronic components. It can be up to 20% for different resistors. So it is worth checking the resistors with a multimeter.

At the time of assembling the device, I only had 220 Ohm resistors at hand, so I decided to use them. They can give us approximately (I = U / R, 1.3 / 220 = 0.0059 A) 6 mA per pin.

Will 6 mA (or even less if the resistors have +20% of the specified resistance, 1.3 / (220 + 20%) = 0.0049 A) per pin be enough to light up the matrix? It is possible, but maybe it will not be very bright.

Will 48 mA (6 mA * 8 pins) or (if all resistors are -20% of the specified resistance - even 1.3 / (220 - 20%) = 0.0073 A) 58 mA (7.3 * 8) burn up the device? Assuming that the 74HC595 can handle 70 mA, I do not think this is possible.

I plan to use 24AWG wires for some connections. They can handle about 0.5A current, which is more than enough for the device.

The ESP32 control pins give GND or 3.3V signals to the device, which is fine for the shift registers.

So we have a chance that the device will work and not burn up.

In any case, we need to check this before soldering by assembling the device on a prototyping board.

P.S. I measured the current that the assembled device draws when all LEDs are on. It's 38 mA.

Making Circuit Diagram

Schematic_Soldering_1_LED_8x8_1_2024-01-28.png
3.jpg

I tried out various programs for drawing electronic circuits and decided on EasyEDA. The editor can be used online or offline, there is a huge library of components and it is easy to use. And it has additional features (like designing PCBs) that I might need in the future. So, this is my schematic. The components are arranged in the order in which they will be soldered to the board. The only drawback I have found when working with EasyEDA is that it is difficult to change the sizes of the components.

I decided that one of the ICs should only be responsible for processing rows and the other only for processing columns.

So the output pins of the U1 IC on the schematic are all connected to the column pins of the LED matrix, and the output pins of the U2 IC are connected to the row pins.

Then I placed all the components on the board to see how they connect to each other. I tried to make sure that whenever possible, contacts that are next to each other are connected together.

On the front of the matrix we have more "rows" connections and on the back we have more "columns" connections, leaving the "column" shift registers on the back of the matrix and the "row" registers on the front of the matrix.

Assembling the Circuit on a Protoboard

1.jpg

Now we need an ESP32 board, a prototyping board, all the components of our device and some wires. Everything looks a bit messy here, but if the thing works on a protoboard, then it'll work after soldering.

Once the device is assembled on a protoboard, it's time to write a program for it. I wrote a minimal program in this step. My main goal was to check if I've correctly figured out how to work with the whole display (all LEDS on), with individual rows and columns and with individual LEDs.

When I run a series of tests, I realized that something was terribly wrong. I could turn on all the LEDs, but 2 of the rows didn't work individually. As it turned out, this was because some resistors were touching the legs of the others. So when I tried to turn everything on, the matrix worked, and when I tried to turn on a single line, strange things happened.

Programming

You can find the code in the attached file or in my GitHub repository.

I am using Arduino IDE 2.2.1.

The most important things in the code are:

  •  Byte arrays cols and rows. We work with a common anode matrix. For example, to turn on the LED located at the intersection of row #1 and column #1, we need to write 1 to the pin designated for row #1 and 0 to the pin designated for column 1. In our case, the byte for switching on the first column looks like 0b11110111 and it is located at index 0 in the cols array. Where did I get this byte? Look at the schematic in the previous step - IC1 pin QE is connected to column 1. We need to write 0 to this pin to turn on column 1. This is how the pins are named: abcdEfg. Compare this to 0b11110111. the 0 represents the QE pin. For the sake of simplicity, I have placed this byte at the 0th element of an array. The byte for turning on the first row looks like 0b00010000 and we can find it in the 0 element of the rows array. The pin for switching on the first row is IC2 QD. So the names of the pins are abcDefgh, and the byte is 0b00010000.
  •  Function send_data_to_ICs(byte rws, byte cls). It is used to send data to the registers.
  •  Function disp_one_led(int row, int col, int del). It is very simple. It receives the row and column coordinates of the LED and the delay - the time the LED should be lit. Then it switches the LED on and waits.
  • Function disp_8x8(byte symbol [8], int del). It decodes 8-byte arrays and displays them using afterglow efffect.

If you want to create your own font for the matrix, you can use old 8x8 fonts such as this.

Soldering

4.jpg
5.jpg

That is the most important thing when soldering: attention. Keep the diagram before your eyes. Retrace your steps and check everything twice. Do not rush. Be careful: the soldering iron is very hot and the utility knife is very sharp.

If you are using wires from an Ethernet cable, you can make them straight with 2 pieces of wood. The wire can be rolled between the pieces of wood and it will be straight.

Possible Improvements and Further Work

2.jpg
  • 5-pin output (VCC, GND, NEXT pin of the 2nd register, pin 2, pin 4). This enables the modules to be daisy-chained.
  • Designing and ordering a PCB for the project (EasyEDA offers this function).
  • Use of pin headers for the LED matrix to be able to reuse them in another project.
  • Programming: support for linked modules, scrolling, fonts, symbols, etc.

Thanks for reading!