' PPCTERM.BAS ' ' Sample Terminal Emulator to talk to the PPC-1000 ' ' Check the following - you should include this in your code... ' OPEN "COM2:9600,N,8,1,RS,CS,DS" FOR RANDOM AS #1 ' ' first you should send a CR-LF to the PPC - you must send this ' after it has completed its power-on self test. We won't do it ' here, since this is an interactive terminal and we want the user ' to learn the power-on, CR-LF requirement. ' ' PRINT #1, CHR$(13) ' ' now clear the screen, display a small terminal window and ' show the valid commands at the top portion of the screen ' CLS COLOR 15, 1 PRINT " " PRINT " PPC-1000 Interactive Terminal " PRINT " " COLOR 15, 4 PRINT "----------------------Valid PPC-1000 Commands---------------------------------" PRINT " RS.....Reset System CS.....Check limit sitches " PRINT " CL.....Perform system leak check CP.....Perform strip char cal " PRINT " ED.....Enable Drive System DD.....Disable Drive System " PRINT " ELsxx..Set Low Pressure Limit EHxx...Set High Pressure Limit " PRINT " CE.....Clear Error Flag GPsxx..Goto Pressure - mmHg " PRINT " GTsxx..Goto Pressure on Trigger - mmHg CB.....move bellows to center " PRINT " MP.....Move bellows to Positive limit MN.....Move bellows to Neg. limit " PRINT " MZ.....Move bellows to Zero position TA.....Track Analog setpoint " PRINT " ?......list active commands SP.....Send current Pressure mmHg " PRINT " LV.....List software Version SE.....Send last Error code " PRINT " DP.....Display bellows Position V1O....Open Vent valve to ambient " PRINT " V1C....close vent valve V2O....Open output valve " PRINT " V2C....close output valve *......terminal command " COLOR 7, 0 LOCATE 18, 1 PRINT "-----Enter a command.....Press [q] to quit------------------------------------" VIEW PRINT 19 TO 23 ' ' now just let the user type in commands and send each character ' exactly as typed. This will let the user see the various error ' codes that can occur (and should be trapped in any application). ' ' display all responses from the PPC - note that since the PPC echo's ' all input, we will strip incoming CR-LF's. ' DO IF NOT (EOF(1)) THEN ' check the receive buffer A$ = INPUT$(1, 1) ' got a char from PPC IF LEN(A$) <> 0 THEN ' is it a vaild char ? SELECT CASE A$ CASE IS = CHR$(13) ' strip CR CASE IS = CHR$(11) ' strip LF CASE ELSE PRINT A$; END SELECT END IF END IF A$ = INKEY$ ' check for user pressed key IF LEN(A$) <> 0 THEN PRINT #1, A$; ' got one, so xmit to PCC END IF LOOP WHILE A$ <> "q" ' q == quit CLOSE #1 END