'11-11-08 testlptport.bas. Derived from controltest rev 103 'This program will allow the user to command the LPT printer port bits to any value 'It will also read the levels on the Status Pins 'when run, a window will open and you can click each box 'to make the LPT printer port pins go "high", or to "low" port = hexdec("&H378") 'printer port data address for specific computer status = hexdec("&H379") 'printer port status address for specific computer control = hexdec("&H37A") 'printer port command address for specific computer 'above variables need to be changed if your computer has different LPT1 registers '------do not change anything below this line 'Bit Position Connector Pin Names 'control word Bit 0 LPT pin 1* Strobe, Strb, Fqud 'control word Bit 1 LPT pin 14* Data Stn, Auto Feed, Auto, Wclk 'control word Bit 2 LPT pin 16 Init Printer, Init, Enat 'control word Bit 3 LPT pin 17* Add Stb, Select In, Selt, Sel Inp, Enap 'port word Bit 0 LPT pin 2 Data 0, D0, DB0 'port word Bit 1 LPT pin 3 Data 1, D1, DB1 'port word Bit 2 LPT pin 4 Data 2, D2, DB2 'port word Bit 3 LPT pin 5 Data 3, D3, DB3 'port word Bit 4 LPT pin 6 Data 4, D4, DB4 'port word Bit 5 LPT pin 7 Data 5, D5, DB5 'port word Bit 6 LPT pin 8 Data 6, D6, DB6 'port word Bit 7 LPT pin 9 Data 7, D7, DB7 'status word Bit 3 LPT pin 15 Error (without input, this Bit will read "1") 'status word Bit 4 LPT pin 13 Select (without input, this Bit will read "1") 'status word Bit 5 LPT pin 12 Paper Empty, PE (without input, this Bit will read "1") 'status word Bit 6 LPT pin 10 Interrupt, ACK (without input, this Bit will read "1") 'status word Bit 7 LPT pin 11# Busy, WAIT (without input, this Bit will read "0") ' The * signifies inversion. To set the pin to a "1" the Bit is set to "0" ' The # signifies that the computer reads a "1", but sets the status bit to "0" 'This software takes this into accout and indicates the actual high or low level nomainwin BackgroundColor$ = "darkblue" ForegroundColor$ = "white" TextboxColor$ = "blue" statictext #main.message1, "Click Right Box to preset to 1", 5, 32, 160, 15 statictext #main.message2, "Click Left Box to preset to 0", 5, 57, 150, 15 statictext #main.message3, "Click, Send Data, to Latch Pins", 5, 82, 150, 15 button #main.button2down, "0", [Pin2down], UL, 5, 105, 20, 20 button #main.button2, "Pin 2, D0", [Pin2], UL, 30, 105, 55, 20 button #main.button3down, "0", [Pin3down], UL, 5, 130, 20, 20 button #main.button3, "Pin 3, D1", [Pin3], UL, 30, 130, 55, 20 button #main.button4down, "0", [Pin4down], UL, 5, 155, 20, 20 button #main.button4, "Pin 4, D2", [Pin4], UL, 30, 155, 55, 20 button #main.button5down, "0", [Pin5down], UL, 5, 180, 20, 20 button #main.button5, "Pin 5, D3", [Pin5], UL, 30, 180, 55, 20 button #main.button6down, "0", [Pin6down], UL, 5, 205, 20, 20 button #main.button6, "Pin 6, D4", [Pin6], UL, 30, 205, 55, 20 button #main.button7down, "0", [Pin7down], UL, 5, 230, 20, 20 button #main.button7, "Pin 7, D5", [Pin7], UL, 30, 230, 55, 20 button #main.button8down, "0", [Pin8down], UL, 5, 255, 20, 20 button #main.button8, "Pin 8, D6", [Pin8], UL, 30, 255, 55, 20 button #main.button9down, "0", [Pin9down], UL, 5, 280, 20, 20 button #main.button9, "Pin 9, D7", [Pin9], UL, 30, 280, 55, 20 button #main.button1down, "0", [Pin1down], UL, 150, 205, 20, 20 button #main.button1, "Pin 1, Strobe", [Pin1], UL, 175, 205, 130, 20 button #main.button14down, "0", [Pin14down], UL, 150, 230, 20, 20 button #main.button14, "Pin 14, Auto Feed", [Pin14], UL, 175, 230, 130, 20 button #main.button16down, "0", [Pin16down], UL, 150, 255, 20, 20 button #main.button16, "Pin 16, Init Print", [Pin16], UL, 175, 255, 130, 20 button #main.button17down, "0", [Pin17down], UL, 150, 280, 20, 20 button #main.button17, "Pin 17, Select In", [Pin17], UL, 175, 280, 130, 20 button #main.status, "Click to Read Status Pins", [Status], UL, 175, 30, 130, 20 button #main.status, "SEND PORT DATA", [SendPort], UL, 5, 305, 130, 20 button #main.status, "SEND CONTROL DATA", [SendControl], UL, 150, 305, 130, 20 textbox #main.waitbox, 175, 55, 20, 20 textbox #main.ackbox, 175, 80, 20, 20 textbox #main.pebox, 175, 105, 20, 20 textbox #main.selbox, 175, 130, 20, 20 textbox #main.errbox, 175, 155, 20, 20 statictext #main.message11, "WAIT, pin 11", 200, 57, 80, 15 statictext #main.message10, "ACK, pin 10", 200, 82, 80, 15 statictext #main.message12, "PE, pin 12", 200, 107, 80, 15 statictext #main.message13, "SELECT, pin 13", 200, 132, 80, 15 statictext #main.message15, "ERROR, pin 15", 200, 157, 80, 15 open "LPT Parallel Printer Port Test" for dialog as #main print #main.button1, "!setfocus" print #main, "trapclose [finished]" fqud = 1:wclk = 1:enat = 0:enap = 1 wait [Pin1down] fqud = 1 print #main.button1down, "0" wait [Pin2down] D0 = 0 print #main.button2down, "0" wait [Pin3down] D1 = 0 print #main.button3down, "0" wait [Pin4down] D2 = 0 print #main.button4down, "0" wait [Pin5down] D3 = 0 print #main.button5down, "0" wait [Pin6down] D4 = 0 print #main.button6down, "0" wait [Pin7down] D5 = 0 print #main.button7down, "0" wait [Pin8down] D6 = 0 print #main.button8down, "0" wait [Pin9down] D7 = 0 print #main.button9down, "0" wait [Pin14down] wclk = 1 print #main.button14down, "0" wait [Pin16down] enat = 0 print #main.button16down, "0" wait [Pin17down] enap = 1 print #main.button17down, "0" wait [Pin1] fqud = 0 print #main.button1down, "1" wait [Pin2] D0 = 1 print #main.button2down, "1" wait [Pin3] D1 = 1 print #main.button3down, "1" wait [Pin4] D2 = 1 print #main.button4down, "1" wait [Pin5] D3 = 1 print #main.button5down, "1" wait [Pin6] D4 = 1 print #main.button6down, "1" wait [Pin7] D5 = 1 print #main.button7down, "1" wait [Pin8] D6 = 1 print #main.button8down, "1" wait [Pin9] D7 = 1 print #main.button9down, "1" wait [Pin14] wclk = 0 print #main.button14down, "1" wait [Pin16] enat = 1 print #main.button16down, "1" wait [Pin17] enap = 0 print #main.button17down, "1" wait [SendPort] portdata = D0+(D1*2)+(D2*4)+(D3*8)+(D4*16)+(D5*32)+(D6*64)+(D7*128) out port, portdata wait [SendControl] controldata = fqud+(wclk*2)+(enat*4)+(enap*8) out control, controldata wait [Status] waitbit=1:ackbit=0:pebit=0:selbit=0:errorbit=0 read7 = inp(status) if read7 > 127 then waitbit = 0:read7 = read7 - 128 print #main.waitbox, waitbit if read7 > 63 then ackbit = 1:read7 = read7 - 64 print #main.ackbox, ackbit if read7 >31 then pebit = 1:read7 = read7 - 32 print #main.pebox, pebit if read7 > 15 then selbit = 1:read7 = read7 - 16 print #main.selbox, selbit if read7 > 7 then errorbit = 1 print #main.errbox, errorbit wait [finished] close #main end