James Yi 73327,1653 Feb. 20, 1987 Here are some known INP/OUT ports. Their values X can be read by: X=INP AND (b) where b=2^ bit number and outted by OUT,# statement. Input port: INP(187) bit 2 - Printer port BUSY line (pin #25) status: 1 = not busy, 0 = busy bit 3 - Barcode reader port (pin #2) condition: 1 = not grounded, 0 = grounded bit 5 - If the phone line is connected: 0 = carrier or data on the phone line, 1 = no carrier Out ports: OUT184,# (Reset button will reset any of these) bit 1 - disable all keys accept for BREAK and PAUSE. bit 2 - freeze the computer. bits 1 & 2 - power off, then resume when turned back on. OUT184,195 - resets the frequency of tone generator. OUT185,# bits 0 through 7 is a data byte for the printer. OUT186,# (its status can be read) bit 4 - power off. bit 5 - buzzer toggle (1 = enable tone generator). bit 7 - send a pulse to the phone line. OUT186,47 - turns tone generator off. OUT188,a OUT189,b (a = 0 to 255, b = 64 to 128) Sends frequency values to the tone generator. To use the tone generator execute the following: OUT186,32:OUT188,a:OUT189,b:OUT184,195 OUT232,# (to send any character to the printer, strobe an ACK signal through this port after a character is latched to port 185) bit 0 - ACK signal of the printer port: 1 = low, 0 = high bit 1 - cassette motor on/off: 1 = MOTORON, 0 = MOTOROFF bit 2 - phone line relay for TELCOM: 1 = on, 0 = off Using the printer port to interface to the real world: The BUSY line of the printer port and Barcode reader port can detect a low/high signal. By combining these two inputs with the DATA lines of the printer port 16 independent inputs are possible. This can be done by having the DATA lines 'select' which inputs are to be read by port 185. Since each DATA line can have either a 1 or 0 depending on what value was sent to the port they can be tied to the BUSY line (pin #25) and give different inputs. For example if DATA line 0 (pin #3) is connected to BUSY line, sending a value of 254 (1xor255) which pulls bit 0 low and the others high will give a not busy signal, and sending 255 will give a busy signal. In this way the status of a switch connected between a DATA line and BUSY line can be read, and 8 switches can be connected to one input line and read one at a time. To demonstrate this run the following: 10 CLEAR512:X$=SPACE$(255):X=-65536+PEEK(VARPTR(X$)+1)+PEEK(VARPTR(X$)+2)*256:M=X-1 11 M=M+1:READK:IFK<>-8THENPOKEM,ABS(K):IFK<0THENREADK:K=K+X:POKEM+1,(K-INT(K/256)*256)MOD256:POKEM+2,256+INT(K/256):M=M+2:GOTO11ELSE11 100 DATA 14,127,121,211,185,219,187,230,4,15,15,15,122,63,23,87,121,15,79,-218,3,35,126,35,102,111,114,201,-8 200 J$=SPACE$(1):CLS:PRINT@0,"Bits :" 220 CALLX,,VARPTR(J$) 230 J=ASC(J$) 240 FORL=7TO0STEP-1 250 V=2^L:IFJ-V>=0THENJ=J-V:PRINTCHR$(27)+"p" 260 PRINT@(7-L)*2+10,CHR$(L+48);:PRINTCHR$(27)+"q" 270 NEXT 280 GOTO220 After running it, if a jumper wire is placed between BUSY line and a DATA line (pins 3,5,7,9,11,13,15,17) the corresponding bit will show in inverse graphics. Machine code is used to read the port, it can be done in Basic but the value latched to port 185 drifts and only machine code can read it before it escapes. Note: the machine code is stored in a character string so it is safe to run on either the 100 or 200. Edited by Robert Benson