Other topics about Sample Programs
This sample program is provided in this section where the command processing time is improved by controlling the update timing of the LCD display.
This sample program correctly runs when the maximum number of channels/traces is set to 4 channels/4 traces.
This program sets the necessary measurement conditions and then turns OFF the updating of the LCD display. Next, it performs measurement, reads out the result, and updates the screen once. This program repeats this measurement procedure ten times.
Example of excel sheet with control LCD update timing program
Private Sub Ctrl_LCD_Click()
Dim defrm As Long
Dim Age506x As Long
Dim SwType As String
Dim Cent As Double, Span As Double
Dim Param(1) As String, Fmt(1) As String
Dim NumPoin As Integer, NumData As Integer
Const SwTime = 2#
Dim Dummy As String * 20
Dim Tr1ptr(3) As Long
Dim Tr1Data() As Double
Dim Tr2ptr(3) As Long
Dim Tr2Data() As Double
Dim WrtFmt As String
'***
'*** Open session.
'***
Call viOpenDefaultRM(defrm)
Call viOpen(defrm, "GPIB0::17::INSTR", 0, 0, Age506x)
Call viSetAttribute(Age506x, VI_ATTR_TMO_VALUE, 10000)
'***
'*** Set variable of measurement condition.
'***
SwType = Trim(Cells(3, 3).Value)
Cent = CDbl(Cells(4, 3).Value)
Span = CDbl(Cells(5, 3).Value)
NumPoin = CInt(Cells(6, 3).Value)
Param(0) = Trim(Cells(7, 3).Value)
Fmt(0) = Trim(Cells(8, 3).Value)
Param(1) = Trim(Cells(9, 3).Value)
Fmt(1) = Trim(Cells(10, 3).Value)
'***
'*** Send measurement condition to E5061B.
'***
Call viVPrintf(Age506x, ":SENS1:SWE:TYPE " + Trim(SwType) + vbLf, 0)
Call viVPrintf(Age506x, ":SENS1:FREQ:CENT " + CStr(Cent) + vbLf, 0)
Call viVPrintf(Age506x, ":SENS1:FREQ:SPAN " + CStr(Span) + vbLf, 0)
Call viVPrintf(Age506x, ":SENS1:SWE:POIN " + CStr(NumPoin) + vbLf, 0)
Call viVPrintf(Age506x, ":TRIG:SOUR BUS" + vbLf, 0)
Call viVPrintf(Age506x, ":INIT1:CONT ON" + vbLf, 0)
Call viVPrintf(Age506x, ":SENS1:SWE:TIME:AUTO OFF" + vbLf, 0)
Call viVPrintf(Age506x, ":SENS1:SWE:TIME " + CStr(SwTime) + vbLf, 0)
Call viVPrintf(Age506x, "*OPC?" + vbLf, 0)
Call viVScanf(Age506x, "%t", Dummy)
For i = 2 To 4
Call viVPrintf(Age506x, ":INIT" + CStr(i) + ":CONT OFF" + vbLf, 0)
Next i
Call viVPrintf(Age506x, ":DISP:SPL D1" + vbLf, 0)
Call viVPrintf(Age506x, ":DISP:WIND1:SPL D1_2" + vbLf, 0)
Call viVPrintf(Age506x, "*OPC?" + vbLf, 0)
Call viVScanf(Age506x, "%t", Dummy)
'***
'*** Setting Trace 1 and 2.
'***
Call viVPrintf(Age506x, ":CALC1:PAR:COUN 2" + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:PAR1:DEF " + Trim(Param(0)) + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:PAR1:SEL" + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:FORM " + Trim(Fmt(0)) + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:PAR2:DEF " + Trim(Param(1)) + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:PAR2:SEL" + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:FORM " + Trim(Fmt(1)) + vbLf, 0)
Call viVPrintf(Age506x, ":DISP:ENAB OFF" + vbLf, 0)
Call viVPrintf(Age506x, ":FORM:DATA REAL" + vbLf, 0)
Call viVPrintf(Age506x, "*OPC?" + vbLf, 0)
Call viVScanf(Age506x, "%t", Dummy)
'***
'*** redim for read data.
'***
NumData = NumPoin * 2
ReDim Tr1Data(NumData - 1)
Tr1ptr(0) = VarPtr(NumData)
Tr1ptr(1) = VarPtr(Tr1Data(0))
ReDim Tr2Data(NumData - 1)
Tr2ptr(0) = VarPtr(NumData)
Tr2ptr(1) = VarPtr(Tr2Data(0))
WrtFmt = "%#Zb%1t"
'***
'*** Cycling trigger, read data, and screen update.
'***
For i = 1 To 10
'***
'*** Trigger.
'***
Call viVPrintf(Age506x, ":TRIG:SING" + vbLf, 0)
Call viVPrintf(Age506x, "*OPC?" + vbLf, 0)
Call viVScanf(Age506x, "%t", Dummy)
'***
'*** Read trace data.
'***
Call viVPrintf(Age506x, ":CALC1:PAR1:SEL" + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:DATA:FDAT?" + vbLf, 0)
Call viVScanf(Age506x, WrtFmt, Tr1ptr(0))
For j = 0 To NumData / 2 - 1
Cells(14 + j, 4).Value = Tr1Data(j * 2)
Cells(14 + j, 5).Value = Tr1Data(j * 2 + 1)
Next j
Call viVPrintf(Age506x, ":CALC1:PAR2:SEL" + vbLf, 0)
Call viVPrintf(Age506x, ":CALC1:DATA:FDAT?" + vbLf, 0)
Call viVScanf(Age506x, WrtFmt, Tr2ptr(0))
For j = 0 To NumData / 2 - 1
Cells(14 + j, 6).Value = Tr2Data(j * 2)
Cells(14 + j, 7).Value = Tr2Data(j * 2 + 1)
Next j
'***
'*** screen update.
'***
Call viVPrintf(Age506x, ":DISP:UPD" + vbLf, 0)
Next i
Call viVPrintf(Age506x, ":FORM:DATA ASC" + vbLf, 0)
Call viClose(Age506x)
Call viClose(defrm)
End Sub
10 REAL Trace1(1:201,1:2),Trace2(1:201,1:2)
20 DIM Buff$[9],Img$[30]
30 INTEGER Nop,I
40 !
50 ASSIGN @Agte506x TO 717
60 ASSIGN @Binary TO 717;FORMAT OFF
70 !
80 OUTPUT @Agte506x;":SENS1:SWE:TYPE LIN"
90 OUTPUT @Agte506x;":SENS1:FREQ:CENT 950E6"
100 OUTPUT @Agte506x;":SENS1:FREQ:SPAN 100E6"
110 OUTPUT @Agte506x;":SENS1:SWE:POIN 201"
120 OUTPUT @Agte506x;":TRIG:SOUR BUS"
130 OUTPUT @Agte506x;":INIT1:CONT ON"
140 FOR I=2 TO 4
150 OUTPUT @Agte506x;":INIT"&VAL$(I)&":CONT OFF"
160 NEXT I
170 !
180 OUTPUT @Agte506x;":DISP:SPL D1"
190 OUTPUT @Agte506x;":DISP:WIND1:SPL D1_2"
200 !
210 OUTPUT @Agte506x;":CALC1:PAR:COUN 2"
220 OUTPUT @Agte506x;":CALC1:PAR1:DEF S21"
230 OUTPUT @Agte506x;":CALC1:PAR1:SEL"
240 OUTPUT @Agte506x;":CALC1:FORM MLOG"
250 OUTPUT @Agte506x;":CALC1:PAR2:DEF S11"
260 OUTPUT @Agte506x;":CALC1:PAR2:SEL"
270 OUTPUT @Agte506x;":CALC1:FORM MLOG"
280 !
290 OUTPUT @Agte506x;":DISP:ENAB OFF"
300 OUTPUT @Agte506x;":FORM:DATA REAL"
310 !
320 FOR I=1 TO 10
330 OUTPUT @Agte506x;":TRIG:SING"
340 OUTPUT @Agte506x;"*OPC?"
350 ENTER @Agte506x;Buff$
360 !
370 ! Read Trace Data
380 !
390 OUTPUT @Agte506x;":CALC1:PAR1:SEL"
400 OUTPUT @Agte506x;":CALC1:DATA:FDAT?"
410 ENTER @Agte506x USING "#,8A";Buff$
420 ENTER @Binary;Trace1(*)
430 ENTER @Agte506x USING "#,1A";Buff$
440 !
450 OUTPUT @Agte506x;":CALC1:PAR2:SEL"
460 OUTPUT @Agte506x;":CALC1:DATA:FDAT?"
470 ENTER @Agte506x USING "#,8A";Buff$
480 ENTER @Binary;Trace2(*)
490 ENTER @Agte506x USING "#,1A";Buff$
500 !
510 ! Update Display
520 !
530 OUTPUT @Agte506x;":DISP:UPD"
540 NEXT I
550 END
Lines 50 to 60
Assigns a GPIB address to the I/O pass.
Lines 80 to 110
These lines set the sweep type to linear sweep, the sweep center value to 950 MHz, the sweep span value to 100 MHz, and the number of measurement points to 201.
Lines 120 to 160
These lines set the trigger source to bus trigger, turn ON Continuous Activation mode for channel 1, and turn the mode OFF for channels 2 through 4.
Lines 180 to 190
These lines display the window for channel 1 only and arrange two graphs tiled horizontally.
Lines 210 to 270
These lines set the number of traces for channel 1 to 2, the measurement parameter and its data format for trace 1 to S21 and Log Mag, respectively, and those for trace 2 to S11 and Log Mag, respectively.
Line 290
This line turns OFF the updating of the LCD screen.
Line 300
This line sets the data transfer format to binary.
Lines 320 to 540
These lines repeat the following procedure ten times.
Lines 340 to 360: These lines trigger the instrument and wait until the measurement cycle finishes.
Lines 400 to 440: Reads out the formatted data array of trace 1 in channel 1.
Lines 460 to 500: Reads out the formatted data array of trace 2 in channel 1.
Line 540: This line updates the LCD screen once.