BASICs FOR developing a
PC LAP counter:
This
is the DB-25 pin-out configuration of the Line printer(LPT1):

Here
is the wiring schematic from this connector to the track's magnetic reed
switches:
.
(use any pin18,19,20,21,22,23,24 or 25 to create a ground path)
The following basic code was used to
determine the automatically set the address of LPT1:
DEF SEG = 0
prnt% = PEEK(&H408) + PEEK(&H409) *
256
CLS
PRINT "LPT1";
IF prnt% = 0 THEN
PRINT " LPT1 is
not found"
ELSE
PRINT " LPT1
hex address is &H"; HEX$(prnt%)
END IF
This code will write a HEX F0 to output
LPT1 port to set pins 5,6,7 & 8 to hi:
OUT prnt%, &HF0
pstatus% = prnt % + 1
This code reads the port and if it is
"ON" then a lap is added to the appropriate driver(CALL DRIVER)
I% = INP(pstatus%) 'READ PORT
IF I% <> 120 THEN 'I% = 120 when switches are
all “OPEN”
c% = I% AND 16
IF c% = 0 THEN
lane = 1
CALL DRIVER 'ACTIVITY
PIN 13
END IF
c% = I% AND 32
IF c% = 0 THEN
lane = 2
CALL DRIVER 'ACTIVITY PIN
12
END IF
c% = I% AND 128
IF c% = 128 THEN
lane = 3
CALL DRIVER 'ACTIVITY PIN 11
END IF
c% = I% AND 64
IF c% = 0 THEN
lane = 4
CALL DRIVER 'ACTIVITY PIN 10
END IF
END IF
For a 6-lane version I added this code:
write a hex F8 to output port [378] to set
pins 5,6,7 ,8 & 9 to ‘HI’
(wire pin 9 to a 10K resistor and to Pin 15
as with the other pins(5,6,7, and 8)
as illustrated in the above schematic)
OUT pdata%, &HF8
C% = i% AND 8 'activity pin 15
IF C% = 0 THEN
lane
= 5
CALL
DRIVER 'ACTIVITY PIN 15
END IF
Wire PIN 14 directly to a reed switch and
back to Ground
{NOTE: Pin 14 doesn’t need a voltage
reference}
PCNTRL% = prnt% + 2
OUT PCNTRL%, &H0 ‘Set pin 14 to ‘Zero’ to begin
JC% = INP(PCNTRL%) 'READ PORT for pin 14
IF JC% = 226 THEN
lane
= 6
CALL
DRIVER 'ACTIVITY PIN 14
END IF
OUT prnt% , &H4 ‘applies 5vdc to on pin 4 of the print port which is wired to
pin 2 of the ULN2001A to activate the “computer control logic bit” (as shown in
the schematic shown below) which removes power directly from the power supply
or from all lanes(with a four contact relay).

OUT prnt% , &HF8 ‘applies power to the
voltage references
(pins 5,6,7,8
& 9) and removes the power to
pin 4 and thus
deactivates the ULN2001A control of the
Relay.
4 and 6 lane Qbasic Source code Files: