Connecting the 74HC595 Shift Register to PICAXE Micro-Controller
by Lewis Loflin
This is very similar to the earlier demo using to 74HC165 with one important difference in that the 74HC595 has an internal 8-bit latch. The output to the LEDs remains stable until new data is "latched" by the PICAXE micro-controller. This provides a smoother and flicker-free output than the 74HC164. For more information see Using the 74HC165 Shift Register with the PICAXE Micro-Controller.
Using a row of eight LEDs the circuit will count in binary (right to left) 0 to 255. To see a wiring diagram of the board I built and used in the demo see Exploring the PICAXE Micro-Controller.
Fig. 2 above shows the pinout and connections to the PICAXE micro-controller and the eight LEDs of Fig. 3 which is a common cathode configuration. Pin connections are as follows:
SER (pin 14) is for data bit input. Connect to pin 17 (C.0) on PICAXE.
The 74H565 consists of three main sections: 8-bit shift register, 8-bit latch, 8-bit output enable.
This device contains an 8-bit serial-in, parallel-out shift register that feeds an 8-bit D-type storage register. The storage register has 8 3-STATE outputs. Separate clocks are provided for both the shift register and the 8-bit storage register.
The shift register has a direct-overriding clear, serial input, and serial output (standard) pins for cascading. Both the shift register and storage register use positive-edge triggered clocks. If both clocks are connected together, the shift register state will always be one clock pulse ahead of the storage register.
The Program Code
#picaxe 18m2 ; type chip used ; set internal clock to 4 mHz setfreq m4 ; All M2 partsinternalk31, k250, k500, m1, m2, m4, m8,m16,m32 symbol SER = C.0 ; SER (pin 14) is for data bit to SR. symbol SDCK = C.1 ; SDCK (pin 11) data clock symbol SDCLR = C.2 ; SDCLR (pin 10) clear data register on LOW. symbol LATCH = C.6 ; LATCH (pin 12 RCK) HIGH latches SR data symbol ENABLE= C.7 ; ENABLE output for latch data (pin 13 or G-NOT) ; user variables symbol val = b0 symbol temp1 = b1 symbol j =b2 symbol i = b3 LOW ENABLE HIGH SDCLR main: for j = 0 to 255 val = j for i = 1 to 8 temp1 = val & %00000001 if temp1 = 1 then HIGH SER else LOW SER endif pulsout SDCK,1 val = val / 2 ; shift bits one place right next i pulsout LATCH,1 ; data retained until next cycle pause 400 next j goto main
Picaxe Micro-controller Projects!
The PICAXE series of micro-controllers rank as the easiest and most cost effective way to use Microchip processors. I wanted an easier and less expensive way to introduce my students to the "PIC" micro-controller. Here I hope to get those starting out past poorly written literature and lack of simple working code examples.
Other Main Sections of this Website
If using this material on another site, please provide a link back to my site.