

10 '   ******************************************************************
20 '   * Example program EXAM3.BAS                                      *
30 '   * 1-channel frequency response sweep                             *
40 '   * with readout of measured values and calc. of related curve     *
50 '   * Poin = Number of measured points                               *
60 '   * Setup for this example: EXAM3.SAC (Actual Setup Mode!)         *
70 '   ******************************************************************
80 '
90 Upl=20
100 IEC TERM 10: IEC TIME 10000
110 IEC OUT Upl,"MMEM:LOAD:STAT 0,'C:\UPL\IEC_EXAM\EXAM3.SAC'": 'load setup
120 '
130 Poin=50: '                  number of sweep points
140 DIM Lev(Poin): '        dimension of results
150 DIM Calc(Poin): '          dimension of calculated values
160 IEC OUT Upl,"init:cont off;*WAI": ' set single sweep
170 IEC OUT Upl,"trac? trac1": '   ask for trace data channel 1
180 IEC TERM 44: ' Stringterminator ','
190 FOR Ix=0 TO Poin-2
200  IEC IN Upl,S$: Lev(Ix)=VAL(S$)
210 NEXT Ix
220 IEC TERM 10: IEC IN Upl,S$: Lev(Poin-1)=VAL(S$): ' last value
230 '  the results are now available in Lev(0) to Lev(Poin-1)
240 '  all values are in basic units eg in Volts for level measurements
250 '  all calculations have to consider this !
260 '  the grafical display of the UPD is independent !
270 '  calculation of a related curve - half the values gives -6 dB
280 S$=""
290 FOR I=0 TO Poin-2
300  Calc(I)=Lev(I)/2: ' divide measured values by 2
310  S$=S$+STR$(Calc(I))+","
320 NEXT 
330 Calc(I)=Lev(I)/2: ' divide measured values by 2
340 S$=S$+STR$(Calc(I)): ' Last value without ','
350 '  Write the calculated values into the trace buffer
360 IEC OUT Upl,"trac trac1,"+S$: '       write into trace buffer
370 '    Calculated and the measured curve will be displayed
380 '    (Setup EXAM3.SAC stores the measured values in trace B)
390 IEC LAD 20: IEC GTL 
420 END 
