In many applications it is necessary to store the status of an event that has previously happened. As we've seen in past chapters this is a simple process. But what do we do if we must store many previous events and act upon them later.
Answer: we call upon the shift register instruction.
We use a register or group of registers to form a train of bits (cars) to store the previous on/off status. Each new change in status gets stored in the first bit and the remaining bits get shifted down the train. Huh? Read on.
The shift register goes by many names. SFT (ShiFT), BSL (Bit Shift Left), SFR (Shift Forward Register) are some of the common names. These registers shift the bits to the left. BSR (Bit Shift Right) and SFRN (Shift Forward Register Not) are some examples of instructions that shift bits to the right. We should note that not all manufacturers have shift registers that shift data to the right but most all do have left shifting registers.
A typical shift register instruction has a symbol like that shown above. Notice that the symbol needs 3 inputs and has some data inside the symbol.
The reasons for each input are as follows:
Data- The data input gathers the true/false statuses that will be shifted down the train. When the data input is true the first bit (car) in the register (train) will be a 1. This data is only entered into the register (train) on the rising edge of the clock input.
Clock- The clock input tells the shift register to "do its thing". On the rising edge of this input, the shift register shifts the data one location over inside the register and enters the status of the data input into the first bit. On each rising edge of this input the process will repeat.
Reset- The reset input does just what it says. It clears all the bits inside the register we're using to 0.
The 1000 inside the shift register symbol is the location of the first bit of our shift register. If we think of the shift register as a train (a choo-choo train that is) then this bit is the locomotive. The 1003 inside the symbol above is the last bit of our shift register. It is the caboose. Therefore, we can say that 1001 and 1002 are cars in between the locomotive and the caboose. They are intermediate bits. So, this shift register has 4 bits.(i.e. 1000,1001,1002,1003)
Let's now follow the shift register as the operation takes place. Here's what the 1000 series register (the register we're shifting) looks like initially:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
0
|
0
|
0
|
0
|
The register now looks like:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
0
|
0
|
0
|
1
|
The register now looks like:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
0
|
0
|
1
|
0
|
As the conveying system continues to move on, another cone comes in front of the sensor. This time it's a good cone and the sensor turns on. Now the encoder generates another pulse. The old status of bit 1000 is transferred to bit 1001. The old status of 1001 shifts to 1002. The old status of 1002 shifts to 1003. And the new status of the data input (cone sensor) is transferred to bit 1000.
The register now looks like:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
0
|
1
|
0
|
1
|
The register now looks like:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
1
|
0
|
1
|
1
|
As the conveying system continues to move on, another cone comes in front of the sensor. This time it's another broken cone and the sensor turns off. Now the encoder generates another pulse. The old status of bit 1000 is transferred to bit 1001. The old status of 1001 shifts to 1002. The old status of 1002 shifts to 1003. And the new status of the data input (cone sensor) is transferred to bit 1000.
The register now looks like:
10xx Register
| |||||||||||||||
15
|
14
|
13
|
12
|
11
|
10
|
09
|
08
|
07
|
06
|
05
|
04
|
03
|
02
|
01
|
00
|
0
|
1
|
1
|
0
|
In the example above, we can see the operation as it makes ice cream cones. Follow the first cone through the animation to better understand the shift register instruction.
The shift register is most commonly used in conveyor systems, labeling or bottling applications, etc. Sometimes it's also conveniently used when the operation must be delayed in a fast moving bottling line.
For example, a solenoid can't immediately kick out a bad can of beer when the sensor says its bad. By the time the solenoid would react the can would have already passed by. So typically the solenoid is located further down the conveyor line and a shift register tracks the can to be kicked out later when it's more convenient.
0 comments:
Post a Comment