'Lawson Labs, Inc. '3217 Phoenixville Pike 'Malvern, PA 19355 '610 725-8800 or 800 321-5355 'www.lawsonlabs.com ' ' 'Sample driver for controling a DO16 relay board from an LPT1 or LPT2 port ' 'Common parallel port addresses are &H278, &H378, or &H3BC ' If you don't know your LPT base address, it is normally displayed ' during the beginning of the boot process. For Windows, you may ' need to press Esc to see the text screen. Press Pause if the ' information does not stay long enough on the screen. CLS : KEY OFF LPTADDR = &H3BC: 'put your LPT base address here LOCATE 24, 20: PRINT "Press Enter to exit"; LOCATE 1, 1 ' ReEnter: 'get the number of the relay to change INPUT "Enter relay number (1-16) "; Rly$ IF Rly$ = "" THEN PRINT " Done": END Rly% = VAL(Rly$) IF Rly% > 16 OR Rly% < 1 THEN GOTO ReEnter ReEnter1: 'get the new state for the relay INPUT "Enter 1 for ON or 0 for OFF"; State$ IF State$ = "" THEN PRINT " Done": END State% = VAL(State$) IF State% > 1 OR State% < 0 THEN GOTO ReEnter1 PRINT "setting relay"; Rly%; " to "; IF State% = 1 THEN PRINT "ON" ELSE PRINT "OFF" CODE% = State% * 32 + (Rly% - 1) XOR 207 OUT LPTADDR, CODE% OUT LPTADDR, CODE% - 64 OUT LPTADDR, CODE% PRINT GOTO ReEnter ' 'DO16 relay contacts: Max voltage= 140 volts ' Max current= 0.5 amps ' Max power= 8 watts (volts * amps) ' ' Interconnections: ' LPT1 or LPT2 connector pin# DO16 terminal ' 2 ------------------ A (address) ' 3 ------------------ B (address) ' 4 ------------------ C (address) ' 5 ------------------ D (address) ' 7 ------------------ F (on or off) ' 8 ------------------ G (strobe) ' 25 ------------*-----GND (ground) ' | +5 (+5 VDC) ' | | ' | | ' | | ' 5 Volt DC Power Supply: GND +5 ' 'Power supply must provide at least 60 MA per active relay 'NOTE: Fast languages on fast computers may require a short ' pause after each OUT instruction. 10 microseconds should ' be long enough.