DECLARE SUB init () DECLARE SUB get.wave () DECLARE SUB save.wave () DECLARE SUB measure () DECLARE SUB enter (number!) DIM SHARED motorv(1000) DIM SHARED servofreq(1000) DIM SHARED lf$ lf$ = CHR$(10) CALL init CALL measure CALL save.wave END SUB enter (number!) quit = 0 msg$ = "" DO DO ch$ = INPUT$(1, #1) IF ch$ <> lf$ AND ch$ <> "," THEN msg$ = msg$ + ch$ ELSE quit = 1 END IF LOOP UNTIL quit = 1 LOOP UNTIL LEN(msg$) <> 0 number = VAL(msg$) END SUB SUB init lf$ = CHR$(10) OPEN "com2:2400,n,8,1,ASC,CD1000,CS1000,DS1000" FOR RANDOM AS #1 LEN = 2 PRINT #1, ":acquire:type normal"; lf$; PRINT #1, ":acquire:complete 1"; lf$; REM SLEEP 1 REM PRINT #1, "*RST"; lf$; REM SLEEP 1 REM PRINT #1, ":autoscale"; lf$; REM SLEEP 1 REM PRINT #1, ":channel1:probe x10"; lf$; REM SLEEP 1 END SUB SUB measure FOR count% = 1 TO 6 PRINT #1, ":digitize channel1"; lf$; REM channel 1 is to measure the motor voltage PRINT #1, ":measure:freq?"; lf$; 'query scope for average voltage REM PRINT "Calling enter() to get motor voltage." CALL enter(servofreq(count%)) 'input vav motorv(count%) = TIMER REM PRINT #1, ":measure:source channel2" 'set channel 2 to be measured REM channel 2 is to measure the servo frequency REM PRINT #1, ":measure:freq?" 'query scope for average voltage REM CALL enter(servofreq!(count%)) 'input vavg NEXT count% END SUB SUB save.wave OPEN "A:\12forwd1.dat" FOR OUTPUT AS #2 PRINT #2, "The Data:" PRINT #2, "time servo frequency" PRINT #2, "" FOR count% = 1 TO 10 PRINT #2, motorv(count%), " ", servofreq(count%) NEXT count% CLOSE #2 END SUB