Shop OBEX P1 Docs P2 Docs Learn Events
Using ShiftOut and the 74HC595 Shift Register — Parallax Forums

Using ShiftOut and the 74HC595 Shift Register

AJ ScottAJ Scott Posts: 9
edited 2009-10-17 18:13 in BASIC Stamp
In this program you can control 8 outputs of a 74HC595 via a text terminal. This text terminal can either be the Debug terminal or a TTY terminal such as Hilgreave's Hyperterminal.

Attached is the source file and an Adobe file containing the connection schematic for the 74HC595.

I useed a programming technique called bitmasking so that ech bit's function could be reassigned in the declarations section of the source file.

'Operation of 8 relays via use of the DEBUG terminaland the SHIFTOUT commands.
'Constants used:
·K1 CON %00000001
·K2 CON %00000010
·K3 CON %00000100
·K4 CON %00001000
·K5 CON %00010000
·K6 CON %00100000
·K7 CON %01000000
·K8 CON %10000000
'Relay Functions:
'··· K1: Motor 1 Speed
'··· K2: Motor 2 Speed
'··· K3: Motor 3 Speed
'··· K4: Motor 4 Speed
'··· K5: Motor 1 Forward
'··· K6: Motor 1 Reverse
'··· K7: Motor 2 Forward
'··· K8: Motor 2 Reverse
'··· Motors 3 & 4 run continuously in the forward direction
'····· at Low speed unless K3 or K4 are energized.

Bits 4, and 5, and Bits 6, and 7 are exclusively linked. This means that only one bit in the pairs can be '1',· while the exception of both '0' is allowable for braking.

In my paticular application K1 and K2 are used to select between power supply taps for relay bridges K5/K6 (Motor 1) and K7/K8 (Motor 2)·respectively. K3 and K4 provide tap selection for single ended always on outputs Motor 3 and Motor 4. Motors 1 and 2 could be used for X-Y axis drives on a micro mill, Motor 3 fror spindle control and Motor 4 for chip collection vaccum or cooling oil control.

Bits 4-7 could be altered to allow for both '1' if driving a bidirectional motor control IC such as a MB3763, where '00' would be coast, and '11' would be braking.

As always logic ic's should not drive relays directly. Use a ULN2803 or discrete transistors and resistor networks to drive your relay coils. always use supression diodes, the ULN2803 provides these, the discrete approach will require you to provide these, oriented cathode toward the positive source.
Sign In or Register to comment.