This Rocky Mountain Basic example does the following:
Takes a sweep, and reads the formatted data trace into an array. The trace is read as a definite length block.
Instructs you to remove DUT
Downloads the trace back to the analyzer as an definite length block.
See Other SCPI Example Programs
100 DIM A$[10],Data1(1:51)
110 INTEGER Digits,Bytes
120 !
130 COM /Sys_state/ @Hp87xx,Scode
140 ! Identify I/O Port
150 CALL Iden_port
160 !
170 !
180 OUTPUT @Hp87xx;"SYST:PRES"
190 !
200 OUTPUT @Hp87xx;"CALC:PAR:SEL 'CH1_S11_1'"
210 !
220 ! Set up the analyzer to measure 51 data points.
230 OUTPUT @Hp87xx;"SENS1:SWE:POIN 51;*OPC?"
240 ENTER @Hp87xx;Opc
250 !
260 ! Take a single sweep, leaving the analyzer
270 ! in trigger hold mode.
280 OUTPUT @Hp87xx;"ABOR;:INIT1:CONT OFF;:INIT1;*WAI"
290 !
300 ! Select binary block transfer
310 OUTPUT @Hp87xx;"FORM:DATA REAL,64"
320 !
330 ! Request the channel 1 formatted data array
340 ! from the analyzer.
350 OUTPUT @Hp87xx;"CALC:DATA? FDATA"
360 !
370 ! Turn on ASCII formatting on the I/O path.
380 ! It is needed for reading the header
390 ! information.
400 ASSIGN @Hp87xx;FORMAT ON
410 !
420 ! Get the data header. "A$" will contain the
430 ! "#" character indicating a block data transfer.
440 ! "Digits" will contain the number of characters
450 ! for the number of bytes value which follows.
460 ENTER @Hp87xx USING "%,A,D";A$,Digits
470 !
480 ! Get the rest of the header. The number of
490 ! bytes to capture in the data array will be
500 ! placed in "Bytes". Note the use of "Digits"
510 ! in the IMAGE string.
515 !
520 ENTER @Hp87xx USING "%,"&VAL$(Digits)&"D";Bytes
525 PRINT "HEADER",A$,Digits,Bytes
530 !
540 ! Turn off ASCII formatting on the I/O path;
550 ! it is not needed for transferring binary
560 ! formatted data.
570 ASSIGN @Hp87xx;FORMAT OFF
580 !
590 ! Get the data.
600 ENTER @Hp87xx;Data1(*)
610 !
620 ! Turn on ASCII formatting again.
630 ASSIGN @Hp87xx;FORMAT ON
640 !
650 ! Get the "end of data" character.
660 ENTER @Hp87xx;A$
670 !
680 ! Display the first three numbers in the array.
690 DISP "Trace: ";Data1(1);Data1(2);Data1(3);"..."
700 !
710 ! Use this time to visually compare the
720 ! numbers to the visible data trace.
730 WAIT 5
740 !
750 ! Prompt the operator to disconnect the test
760 ! device and how to continue the program.
770 DISP "Disconnect the test device -- Press Continue"
780 PAUSE
790 !
800 ! Update the display line.
810 DISP "Taking a new sweep...";
820 !
830 ! Take a sweep so the display shows new data.
840 OUTPUT @Hp87xx;":INIT1;*WAI"
850 DISP " Done."
860 WAIT 5
870 !
880 ! Send the header for an indefinite block length
890 ! data transfer.
900 DISP "Downloading saved trace...";
915 ! The first byte '3' indicates the next three digits equal number of transfer bytes
916 ! The number of transfer bytes equals 8x the number of tracepoints.
920 OUTPUT @Hp87xx;"CALC:DATA FDATA, #3408";
930 !
940 ! Turn off ASCII formatting.
950 ASSIGN @Hp87xx;FORMAT OFF
960 !
970 ! Send the data array back to the analyzer.
980 OUTPUT @Hp87xx;Data1(*),END
990 !
1000 ! Turn on ASCII formatting again.
1010 ASSIGN @Hp87xx;FORMAT ON
1020 DISP " Done!"
1030 END
1040 !
1050 !**************************************************************
1060 ! Iden_port: Identify io port to use
1070 ! Description: This routines sets up the I/O port address for
1080 ! the SCPI interface. For "HP 87xx" instruments,
1090 ! the address assigned to @Hp87xx = 800 otherwise,
1100 ! 716.
1110 !**************************************************************
1120 SUB Iden_port
1130 COM /Sys_state/ @Hp87xx,Scode
1140 !
1150 IF POS(SYSTEM$("SYSTEM ID"),"HP 87")<>0 THEN
1160 ASSIGN @Hp87xx TO 800
1170 Scode=8
1180 ELSE
1190 ASSIGN @Hp87xx TO 716
1200 Scode=7
1210 END IF
1220 !
1230 SUBEND !Iden_port
1240 !