How To Add And Shift Register
How to Cascade Shift Registers
In this project, we are going to cascade 2 shift registers together using the 74HC595 shift register.
This means that we pretty connect them together, and so that instead of controlling 8 outputs, the cascaded shift registers can at present control sixteen outputs.
You tin pour equally many shift registers as yous want. If you lot want to cascade a 3rd 1, it can control 24 outputs. If y'all pour a fourth shift annals, information technology tin control 32 outputs.
Merely in this excursion, we will cascade an additional shift register, having 2 in total.
Cascading shift registers is very unproblematic once y'all know how to practice it, because the 74HC595 is purposely designed to be able to add together additional shift registers. And then once you simply how to connect it, it'southward very simple.
Equally stated, the advantage is that we tin control many more than outputs. We will add ii, then nosotros can control 16 outputs. This means we can simultaneously shift 16 $.25.
Be prepared to a have a lot of resistors and LEDs for this projection, because yous'll demand xvi of each.
Components
- 74HC595 Shift Register
- 16 LEDs
- 16 220Ω resistors
- Arduino
The 74HC595 shift register is one of the most popular and widely used ones in the electronics industry. Ane private 74HC595 tin can control 8 outputs. This means information technology tin control, for example, 8 LEDs.
The shift register, in full, has 16 pins.
The pinout for the shift register is shown below.
The table below summarizes these pivot connections.
| Pivot | Description | Function |
| QA-QH | Output pins | Outputs of the shift register |
| 5CC (Pin 16) | Power | Positive voltage for the shift annals |
| GND (Pivot 8) | Power | Ground for the shift register |
| QH' (Pivot 9) | Serial Out | Serial out is used to shift data to another 74HC595 shift register |
| | Master Reclear, active low | This sets all the bits in the shift register to 0 or off if pulled Depression. |
| Shift Clock (Pin 11) | Shift Annals Clock Pivot | If pulled HIGH, this shifts all the values in the shift register forrad one. |
| Latch Clock (Pin 12) | Stroage Register Lock Pin | When pulled HIGH, it outputs the new shift register values. |
| | Output enable, agile low | This enables the output when grounded and disables it when loftier. |
| Serial Data Input (Pivot 14) | Input for New Serial Information | This is the input pin for the new serial data. |
The 74HC595 shift register has 8 outputs. This means you can connect up to 8 output devices, such as LEDs or buzzers, to the shift register. The output pins are QA-QH, eight in total. QA, pin xv, is the beginning output pin. Adjacent are QB-QH, which are pins one-7. These output pins do non connect to the arduino microcontroller. Instead, the outputs, which in this instance are LEDs, are connected to them.
To provide power to the 74HC595 shift register, we requite +5V to VCC and we connect GND to ground on the arduino microcontroller.
When connecting shift registers to microcontrollers, the serial data input line (pivot 14) gets continued to digital pin 11 on the arduino. Through this connection, through our code, we will write the information that we want to be displayed at the output. For example, we may write 11111111 to the serial data line. If this done while the clock is Loftier, and so the 1s will be shifted into the storage annals. Now the storage register will read 11111111. In one case we practice the next step, latch it, which means nosotros transfer the data from the storage register into the outputs, it will testify up at the output. This means the LEDs volition all plough on.
The clock pivot (pin 11), is the clock for the shift register. The 74HC595 is clock-driven on the rising edge. This ways that in order to shift bits into the storage register of the shift register, the clock must be high. And bits are transferred in on the ascension edge of the clock. So the clock must exist HIGH when new data is existence driven into the storage register.
The latch pin (pin 12) is a very important pin. This pin takes the data that is stored in the storage register and when driven High, transfers the information to the output. So when we initially transfer in data, it goes into the storage register but does not evidence up at the output. It only shows up at the output when the latch pivot is High. This is when we and so we run across the LEDs plough on. And so the latch pin can exist seen as like the concluding step in the procedure to seeing our results at the output, which in this case are LEDs.
The Articulate pin is an agile low pin. This means that when it is grounded, all information in the storage register is cleared to 0. In order for this not to happen, nosotros keep information technology at HIGH, so we connect it to VCC.
The Output Enable pin allows united states to turn on or off all the outputs. Ordinarily, we want this enabled so that there can changes on the output side. If this is disabled, then no output can be turned on. This pin is an active low pin, which means when it is grounded, all output pins are disabled. So normally we keep this pin HIGH, and then it's tied to VCC.
The QH' pivot is the series information output pin. This is the pin we use to cascade an additional shift register. So instead of being able to switch on 8 outputs, we tin can and so switch on 16 outputs. How this works is we will have the series data output pin of the first shift annals and connect to the serial information input on the 2nd shift register. This way, the data from the first shift register feeds directly into the second shift register. This is how the data cascades into the next.
Cascaded Shift Annals Circuit
The cascaded shift register excursion we volition build with an Arduino is shown below.
This shift register circuit has pretty basic connections.
Commencement we connect power. So we connect both VCCs of the shift registers to the 5V arduino final. Nosotros connect the grounds of the shift registers to the GND arduino terminal. This establishes sufficient power for both shift registers.
Next we connect both clock pins (pin 11) to digital pin 12 of the arduino.
We connect the latch pins (pin 12) to digital pin eight on the arduino.
For the start shift annals, we connect the serial information input pin to digital pivot eleven on the arduino. The data input on the second shift register will take the serial data output line connected to it. More than will be explained below.
Since the Output Enable pin is active low, nosotros connect it to be ground, because we commonly want outputs to be enabled. If outputs are disabled, nosotros can't write anything to outputs. Outputs are permanently disabled unless enabled. Since we do non want them disabled ever in this excursion, we simply connect to ground permanently.
Since the Articulate pin is active low, nosotros connect to VCC, because nosotros don't want the storage annals to be cleared normally.
Since nosotros are cascading an additional shift annals, for the shift register, nosotros connect the serial data output line to the serial data input line on the second shift annals. This allows the data to period seamlessly from the shift register to the 2d one.
Lastly, we connect the LEDs to the output pins, QA - QH. To each of the LEDs, we connect a current-limiting 220Ω resistor.
Lawmaking
This is the code necessary to run this shift register circuit.
const int latchPin= 8;
const int clockPin=12;
const int dataPin= 11;
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
Serial.begin(9600);
Serial.println("Enter the number of LEDs you want to turn on from 0-15:"); }
void loop(){
if (Serial.bachelor() > 0) {
//so if a user types in a number from 0 to 9 in ASCII
//simply decrease 48 to get the actual value
int bitDesired= Serial.read() - 48;
registerWrite(bitDesired, HIGH);
}
}
void registerWrite (int PinToSetHigh, int PinState) {
byte bitsToSend= 0;
digitalWrite (latchPin, LOW);
bitWrite(bitsToSend, PinToSetHigh, PinState);
shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);
digitalWrite(latchPin, HIGH);
}
In the get-go block of code, we show the connections of the latchPin, clockPin, and dataPin to the arduino board. These all connect to digital pins.
In the 2nd block of lawmaking, nosotros gear up the latchPin, clockPin, and dataPin every bit outputs. This considering the arduino writes to them. If they were inputs, the arduino would read them. We too create a Series Monitor so that the user can enter from numbers 0-xv the amount of LEDs desired to be turned on.
The next block, our loop() role, reads the value that was entered and writes into the storage register. We then, as the final line, plough the latch Pivot High so that the information in the storage register then gets transferred to the output pins. And this is when we see the LEDs turn on. We initially run into the numbers low-cal upward that we entered into the Serial Monitor. Each the time the loop() function is executed, the bits then shift to the right. The Near Pregnant Bit (MSB), gets shifted out showtime. It's a left shift till all the LEDs are shifted out. We and then can reset the microcontroller and put in a new value. If you lot want to left shift, you can alter the shiftOut office from MSBFIRST to LSBFIRST. This volition shift out the Least Significant Chip (LSB) first.
So this is an example of a cascaded shift annals circuit.
Related Resources
How To Add And Shift Register,
Source: http://www.learningaboutelectronics.com/Articles/Cascade-shift-registers.php
Posted by: holmesourne1943.blogspot.com

0 Response to "How To Add And Shift Register"
Post a Comment