REM Digital Setting Circles test program by David Ek for his interface REM design. Uses his proprietary command set for testing. REM Open the com port. Change if you're not using COM1. CLS OPEN "COM1:9600,N,8,1,BIN,CD0,CS0,DS0,OP0,RS,TB16,RB16" FOR RANDOM AS #1 REM Get the encoder resolutions from the user. INPUT "Enter azimuth encoder resolution: ", ra% INPUT "Enter altitude encoder resolution: ", dec% REM convert the resolutions to lo byte/hi byte format decLo% = dec% MOD 256 decHi% = (dec% - decLo%) / 256 raLo% = ra% MOD 256 raHi% = (ra% - raLo%) / 256 REM send initialization command to interface cmd$ = "zabcd" MID$(cmd$, 2, 1) = CHR$(decLo%) MID$(cmd$, 3, 1) = CHR$(decHi%) MID$(cmd$, 4, 1) = CHR$(raLo%) MID$(cmd$, 5, 1) = CHR$(raHi%) PRINT #1, cmd$; REM reply should be "r" PRINT "Reply from command: "; reply$ = INPUT$(1, 1) PRINT reply$ REM Send the h command to see if the interface was initialized successfully. PRINT #1, "h"; reply$ = INPUT$(4, 1) decLim% = ASC(MID$(reply$, 1, 1)) + 256 * ASC(MID$(reply$, 2, 1)) raLim% = ASC(MID$(reply$, 3, 1)) + 256 * ASC(MID$(reply$, 4, 1)) PRINT "Az encoder resolution from interface: ", raLim% PRINT "Alt encoder resolution from interface: ", decLim% REM Loop, getting and displaying encoder positions until ESC is pressed. PRINT PRINT "Positions (move mount to see them change, ESC to quit): " DO PRINT #1, "y"; reply$ = INPUT$(4, 1) decPos% = ASC(MID$(reply$, 1, 1)) + 256 * ASC(MID$(reply$, 2, 1)) raPos% = ASC(MID$(reply$, 3, 1)) + 256 * ASC(MID$(reply$, 4, 1)) LOCATE 8, 1 PRINT USING "Alt: ##### Az: ##### "; decPos%; raPos% LOOP UNTIL INKEY$ = CHR$(27) REM ESC was pressed. Show errors and quit. PRINT #1, "p"; reply$ = INPUT$(1, 1) LOCATE 10, 1 PRINT "Errors: "; PRINT ASC(reply$) REM Don't forget to close the com port! CLOSE #1 END