Zonnestroompanelen in Nederland

duurzaamheid achter de meter

(21) Three sided, 31-led Arduino pyramid- part one: the four shift register engine

Summary

This is the first part of a two-part paper. We discuss here the construction of an Arduino Nano powered ‘engine’ that stands at the base of its companion project in part two: the construction of a three-sided pyramid that features 31 leds. In the present paper we discuss the design of the engine that implements four 74HC595 shift registers in daisy chain configuration. The advantage of such a design is that only three output pins of the Arduino are involved. A challenge was to construct the engine as compact as possible on a 80×60 mm mounting board, with the Arduino Nano mounted on a 60 x 40 mm satellite board.

Introduction

Series of leds that, in programmable sequences, can be individually instructed to light up are an endless source of creativity and fun. Instructing leds to blink is easy to program with the Arduino family of microcontroller boards. The only drawback with the Arduino is that there are only 14 digital output pins which, together with the six additional analog pins (A0 through A5), form the limiting factor in the number of directly programmable leds. Tricks are necessary to program larger numbers of leds. There are several ways to achieve that, for instance by constructing led matrices, charlieplexing or by the application of shift registers. In this respect the 8-bit 74HC595 shift register chip is an ideal extension of the Arduino. One 74HC595 needs on the input side only three wires, while on its output interface it has 8 pins available to attach leds to. One very attractive feature of the 74HC595 is that it has one pin to which a next 74HC595 can be connected. A large number of these chips can in tbis way be lined up in a daisy chain to control a sheer endless number of leds. No matter the length of a daisy chain, only three pins on the Arduino will be required.

Figure 1. A 74HC595 shift register chip showing the manufacturer’s pin designation and application in an Arduino environment to control 8 leds.

There are, of course, limitations. The most important of these are shift, power and noise.

  • Shift means that data destined to the last chip in a daisy chain has to travel the entire chain to reach its destination chip. This slows down the process.
  • Power means that the manufacturer warns that output power of one 74HC595 may not exceed 70 mA. With all eight pins connected to leds firing simultaneously this means that in this ‘full action’ scenario each pin may not draw more current than 70/8 = approximately 9 mA. One single pin firing solitarily may not draw more current than 35 mA. We need therefore for each output each pin a current limiting resistor to reduce the power load of a 74HC595 to a safe range.
  • Noise means that in shift registers a lot of switching is involved. This switching is done by setting the clock pin on the chip ‘high’ and ‘low’. A 74HC595 has eight registers that each hold one bit (a ‘0’ or a ‘1’). Each time the clock ‘ticks’, the bit in each register is moved to the next register. While the process is basiaclly very simple, another thing is that shifting needs to run smoothly. This depends on fast and tight clocking. The more shift registers are lined up in a chain, the more critical accurate timing becomes. Switching noise can be reduced by adding decoupling capacitors in the design between the 5V and GND pins, preferably one capacitor for each shift register chip.

The popularity of the 74HC595 shift register chip is caused by its simplicity, and also by its low price. These chips can be bought in bulk for approximately 10 eurocents a piece which makes them very affordable. It also permits the hobbyist to discard one, for instance if one has made a mistake in the soldering process.

Figure 2. Wiring between an Arduino Nano and a single 74HC595 shift register chip

Basics and schematic wiring

How a 74HC595 is connected to an Arduino is illustrated in figures 1 and 2. In this project a Nano is used because of its small form factor. The design of the ‘engine’ involves four 74HC595 shift registers. Only three of the Nano’s output pins are necessary to do the work: data, clock and latch. Note that the ‘data’ connection is from the Nano to pin SI (Serial In) of the first shift register (here designated ‘A’) and next from pin QH’ of this chip to pin SI of the next-in-line shift register (here designated B), next from pin QH’ of this chip to pin SI of shift register C, and so on. This type of linking is called ‘daisy chaining’ and it is only done for the serial data line. Wires for ‘latch’ and ‘clock’, the two other connections involved, are distributed parallel to all shift registers (pin RCK receives latch and pin SCK receives clock). On the last-in-line shift register (‘D’) a terminator of some kind (on pin QH’) is not necessary, which renders this pin available for further expansion. As said earlier, on each shift register eight pins are available to drive an equal amount of leds.

In the design presented here shift register A controls leds A1 through A8, register B controls leds B1 through B8, and so forth. Thus, there are in fact four similar building blocks where each block consists of a shift register and 8 corresponding leds.

Figure 3. Top view of the wiring diagram of the ‘engine ‘ board: four 74HC595 chips, four groups of eight current limiting 560Ω resistors, and the four series of 8 pin headers ready to connect with their leds. A 1 μF decoupling capacitor is positioned between the 5V supply to the engine and GND. Color codes in this scheme for the wires from the Nano to the engine: red: 5V, black: GND, yellow: clock, green: serial data, magenta: latch.

Necessary parts

1 x Arduino Nano
1 x soldering board 80×60 mm (for the engine)
1 x soldering board 60×40 mm
4 x 16 pin chip socket
4 x 74HC595 shift register
32 x 560 Ω resistor
2 x 15 pin female pin header (for the Nano)
4 x 8 pin female pin header
1 x 2 pin female pin header (GND))
1 x 1 μF capacitor
wire (24 AVG gauge) in various colors
4 x nylon spacers 25 mm long
4 x nylon spacers 15 mm long

Soldering procedure

The engine was assembled starting at the center of the board and working towards the edges. In this way a neat and clean print board was made while unpleasant surprises were avoided such as pins that need to be soldered while they are covered with wires soldered earlier to other pins.

Figure 4. Bottom up view of the wiring diagram section dealing with the pin headers, resistors and connections from the sockets to the pin headers. The pin headers form the connectors to the led anodes. A bottom view at hand is extremely helpful during the soldering of components, when most work is done on the back of a mounting board

1. Pin headers and resistors

With a pyramid planned to be mounted on top of the engine the wires coming from the pyramid will project to the center of the engine. The most logical arrangement of the pin headers is therefore in the center of the engine board (figure 4). The pyramid will be constructed of thick yellow copper wire and will consist of edges and horizontal bars soldered together (see part two of this paper). These edges and bars will not only support the leds but will also act as their common cathode. The cathode of each individual led will be soldered onto the pyramid’s copper frame and the anode will project inwards.

The pins of the 560 Ω resistors were stuck through the engine board. On the back of the board one pin of each resistor was soldered immediately onto the corresponding pin of its pin header. Having a ‘bottom up view’ diagram such as in figure 4 at hand at this point is very handy because it helps to avoid soldering errors.

The final design included shift registers arranged clockwise (in top view). As can be seen in figure 3, shift registers A and B are notch-oriented differently than chips C and D, a configuration that produces a wrung arrangement of the wires connecting pin headers A and B with the output pins of their associated shift registers A and B. This particular construction was designed to keep in the completed engine the final numbering of the pin headers neatly parallel: A1 next to C1, A2 next to C2, and so forth. This arrangement makes it much easier in the final assemblage stage where the pyramid is connected to the engine to properly connect wires from the leds on the pyramid with their corresponding pin headers on the engine board.

Because all the wires connecting components of the engine were planned to be soldered on the back of the mounting board the wiring diagrams in figures 4 through 8 are left-right mirrored (‘bottom up views’). This was done for very practical reasons. Soldering 16 wires per chip on the back of a mounting board is much easier when the wiring diagrams are straightforward and do not leave any room for confusion.

2. Serial data wires

Figure 5 was in the next step of the soldering process used to continue the manufacturing of the board by adding the serial data wiring. Please note that I used 16-pin chip sockets while I stuck the precious shift registers in their sockets at the very end of the manufacturing process. Pin SI of shift register A receives a data wire from pin 11 of the Nano. Pin QH’ of the same shift register is wired to pin SI of shift register B. Pin QH’ of shift register B is wired to pin SI of shift register C, and pin QH’ of shift register C to pin SI of shift register D. Pin QH’ of shift register D is unused.

Figure 5. Bottom up view of the wiring diagram section dealing with the connection of the data wire from the Nano to the first shift register, and the subsequent daisy chaining of the next shift registers.

3. Latch and  clock wires

Figure 6 presents the diagram for the wiring of the latch (purple) and clock (yellow) wires. The wire supporting latch is soldered to pin 8 of the Nano and distributed to pin RCK of all four shift register sockets. The wire supporting clock is soldered to pin 12 of the Nano and distributed to pin SCK of all four shift register sockets. Note here that pin designation of the Nano is in software, so there is much freedom of choice here. The pin designations used in this paper are pins used conventionally with the 74HC595 in Arduino designs. Data, latch and clock pin designations can be found in the declaration section of the Arduino sketch.

Figure 6. Bottom up view of a selected part of the wiring diagram. Clock and latch wiring highlighted.

4. 5V and GND wires

After all the data, latch and clock wires had been soldered the work was completed by wiring the power (red) and ground (black) wires. Note that each shift register receives two 5V connections and two wires connected to GND.  An additional 2-pin female pin header was mounted in between the AC and BD pin headers to provide a means of connecting GND of the pyramid to the engine while the second pin of this GND header was planned to connect led nr 32 to pin 8 of shift register D (see part two of this paper wherein the construction of the pyramid is discussed),

Figure 7. Bottom up view of the wiring diagram. Wiring of 5V and GND. Note the common 1 μF capacitor.

Complete wiring, bottom up view

During all the soldering work testing was done to be sure that all connections were functional. Most testing was done with a digital multimeter. 

Figure 8. Bottom up view of the complete wiring diagram.

Assembly of the engine

Because the shift registers and pin headers were mounted on a board separate from the one that supports the Nano, wires had to be run from the shift register board to the Nano board (see figure 9). Two boards connected with five thin wires is a very fragile and therefore unstable construction. Nylon spacers were used to mount the boards side by side on a temporary platform, i.e., a 120×120 mm piece of 3 mm plywood supplied with holes. The transparent plastic platform supporting the pyramid was later attached with extra nylon spacers on top of the engine-Nano boards, while after final assembly the temporary plywood base was removed.

Figure 9. Assembled ‘engine’ board with the four 74HC595 chips in their sockets, the battery of current limiting 560 Ω resistors, and the four series of 8 pin headers ready to connect with their leds. The Arduino Nano is positioned on two 15-pin pin header sockets on the satellite board. A. Top view, B Bottom up view.  A 1 μF capacitor is soldered between the 5V supply to the engine and GND. This appeared sufficient to suppress noise. Color codes for the wires from the Nano to the engine: red: 5V, black: GND, yellow: clock, green: serial data, pale blue: latch.

Testing the engine with leds

After the completion of the Nano-shift register engine the moment had arrived to test the assembly. For this purpose, four 400-hole breadboards were each supplied with 8 leds. Wire connections with the engine were established with jumper wires (figure 10). A test sketch was written based on a ‘knight rider’ example to test whether all shift registers were functioning. Another test sketch was a simple ‘on-off’ blinking sketch to test proper functioning of all leds simultaneously.

Figure 10. ‘Engine’ in a full test configuration: four breadboards with each 8 leds.

Discussion

The first goal of this two-tier project was to construct an Arduino Nano-powered engine that features four 74HC595 shift registers in daisy chain configuration with the purpose to control the blinking of 32 leds. This engine was constructed on a 80×60 mm multipurpose soldering board with an auxiliary 80×40 board supporting the Nano. The footprint of the complete engine-Nano assembly is a modest 100 x 80 mm.

The output of the engine goes to pin headers. These form the connection interface with the next module: a 32 led-studded contraption of imaginary shape and dimensions.

After the construction of the engine work was started on a three-sided pyramid laced with 32 leds (see part two of this paper). This pyramid uses Dupont jumper wires to connect the leds to the A-D pin headers on the Arduino engine. Because all connectivity of the engine runs via pin headers, any module featuring 32 leds can be created, ranging from Christmas gadgets and model railway homes to led-circles or -spheres. In fact my previous ‘Arduino Cyclotron’ is a circular, 24 led design connected to a board with three daisy chained 74HC595 shift registers in a small footprint.

Various publications and forum discussions focus on the value of the resistor in the anode wire running to each led. This has to do with the allowed current load of the 74HC595 shift register. Reported resistor values vary between 220 and 560 Ω. Obviously, at a ‘standard’ 220 Ω the current drawn from the shift register’s pin is about 18 mA. This current is not a big problem for the chip since it can handle 70 mA, and each pin is allowed 35 mA. Problems may arise when for instance all eight leds connected to the chip are lighted simultaneously which would cause 8×18 mA to be drawn (144 mA) which would overload the shift register with a factor 2. Conversely, a resistor in the 400-500 Ω range may be sufficient, and the 560 Ω applied in the current design is considered to keep currents well within the safety limit.

Another issue often raised in discussions in forums about shift registers is whether and where to solder one or more decoupling capacitors. Capacitors effectively reduce noise in DC wires. It is preferred by many to use one 100 nF capacitor for each shift register and to mount the component between the 5V and GND pins. In the original design of the present engine I did not include capacitors. This decision was based on the previous, three-shift register design of my ‘Arduino Cyclotron’. However, in the testing phase of the final assembly, with real leds attached (figure 10) the engine behaved erratically. This was immediately and effectively suppressed by mounting one capacitor with a capacity of 1 μF between 5V and GND of the Nano. This instant success removed the necessity to try to find space on the already crowded engine board to mount four separate capacitors. While the use of one big single capacitor worked in the present design, addition of more, smaller decoupling capacitors may be necessary when larger numbers of 74HC595s are daisy chained.

While the 74HC595 can be considered a good and cheap companion to an Arduino a disadvantage of this chip remains its limited load. If higher current loads are desired, a heavier chip like the high-current 595 driver chip such as the TPIC6C595 may be useful. These chips are less cheap than the 74HC595, while they are available in DIP16 version.

Sketches

There are three sketches, packed in a zipped file named ‘four_74HC595_arduino_pyramid‘ – please extract before opening with the Arduino IDE:

  • four_74HC595_daisy_test.ino
  • blink_32_led_test.ino
  • randomblink_four_94HC595.ino