

10 '  **************************************************************
20 '  *  Program example EXAM2.BAS                                 *
30 '  *  Readout of measured values of a sweep via bus             *
40 '  *  1-channel frequency sweep level versus frequency          *
50 '  *  Setup for this example: EXAM2.SAC (Actual Setup Mode)     *
60 '  **************************************************************
70 '
80 Upl=20: '                           Bus-Address
90 IEC TERM 10: IEC TIME 10000: '      Terminator and timeout
100 IEC OUT Upl,"MMEM:LOAD:STAT 0,'C:\UPL\IEC_EXAM\EXAM2.SAC'"
110 IEC OUT Upl,"init:cont off": '     select single sweep
120 IEC OUT Upl,"init;*wai": '         Trigger and wait for termination
130 IEC OUT Upl,"trac:poin? trac1": '  ask for number of points
140 IEC IN Upl,W$: Poin=VAL(W$): '     Poin = number of measured values
150 PRINT "Number of measured values: ";Poin
160 DIM Lev(Poin),Freq(Poin): '     Dimension of results
170 '
180 IEC OUT Upl,"trac? trac1": '  ask for tracedata channel 1
190 IEC TERM 44: ' Stringterminator ','
200 FOR Ix=0 TO Poin-2
210  IEC IN 20,S$: Lev(Ix)=VAL(S$)
220 NEXT Ix
230 IEC TERM 10: IEC IN 20,S$: Lev(Poin-1)=VAL(S$): 'last value
240 '
250 IEC OUT Upl,"sour:list:freq?": '   ask for frequency values
260 IEC TERM 44
270 FOR Ix=0 TO Poin-2
280  IEC IN 20,S$: Freq(Ix)=VAL(S$)
290 NEXT Ix
300 IEC TERM 10: IEC IN 20,S$: Freq(Poin-1)=VAL(S$): 'last value
310 IEC LAD Upl: IEC GTL 
320 '
330 '    the measured results are now available in Lev(0) to Lev(Poin-1)
340 '    and the frequency values in Freq(1) to Freq(Poin)
350 '    all values are in basic units eg. in Volts for any level measurements
360 '    all calculations have to consider this
370 '    the grafical display in the UPL is independend !
380 '
390 '  Example for printout all values
400 N=0
410 FOR I=0 TO Poin-1
420 PRINT USING "##";I+1;
430 PRINT TAB(10);USING "######.##";"Freq";Freq(I);" Hz";
440 PRINT TAB(35);USING "###.####";"Level";Lev(I);" V"
450 N=N+1: IF N=19 THEN INPUT "Press RETURN for more data!";X$: N=0
460 NEXT 
470 '    with following line you can ask UPL for syntax errors (wo REM)
480 REM IEC OUT Upl,"syst:err?": IEC IN Upl,W$: PRINT W$
490 END 
