- 易迪拓培训,专注于微波、射频、天线设计工程师的培养
等待触发状态(OPC?)
概述
Excel VBA中的样本程序
HT Basic中的样本程序
概述
这个样本程序说明如何使用:TRIG:SING命令,直到完成测量周期。
这个样本程序在通道/迹线的最大数量设置为9时能正确运行。
这个样本程序使用:TRIG:SING命令开始一个扫描(测量)周期,使用*OPC命令等待测量周期完成,然后打印消息并退出。
参见这个程序的等待测量结束。
Excel VBA中的样本程序
Sub trg_sing_Click()
Dim defrm As Long
Dim vi As Long
Dim ContMode(9) As String
Dim Result As String * 10
Dim i As Integer
Const TimeOutTime = 100000 ' TimeOut time should be greater than the measurement time.
'
' Assign a GPIB address to the I/O pass.
Call viOpenDefaultRM(defrm)
Call viOpen(defrm, "GPIB0::17::INSTR", 0, 0, vi)
Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime)
'
' Store the settings of continuous initiation mode for eachchannel
' (on for channels 1 and 2; off for channels 3 through 9)
' into the array variable ContMode().
ContMode(1) = "ON"
ContMode(2) = "ON"
For i = 3 To 9
ContMode(i) = "OFF"
Next i
'
' Turn on or off continuous initiation mode for each channel
' depending on the value of ContMode(*).
For i = 1 To 9
Call viVPrintf(vi, ":INIT" & CStr(i) & ":CONT " & ContMode(i) & vbLf, 0)
Next i
' Set the trigger source to Bus Trigger.
Call viVPrintf(vi, ":TRIG:SOUR BUS" & vbLf, 0)
'
' Trigger the instrument to start a sweep cycle.
Call viVPrintf(vi, ":TRIG:SING" & vbLf, 0)
'
' Execute the *OPC? command and wait until the command
' returns 1 (i.e., the measurement cycle is completed).
Call viVPrintf(vi, "*OPC?" & vbLf, 0)
Call viVScanf(vi, "%t", Result)
'
' Display a measurement completion message.
Stat = MsgBox("Measurement complete", vbOKOnly)
Call viClose(vi)
Call viClose(defrm)
End Sub
HT Basic中的样本程序(trg_sing.htb)
10 DIM Cont_mode$(1:9)[9],Buff$[9]
20 INTEGER I
30 !
40 ASSIGN @Agte507x TO 717
50 !
60 Cont_mode$(1)="ON"
70 Cont_mode$(2)="ON"
80 Cont_mode$(3)="OFF"
90 Cont_mode$(4)="OFF"
100 Cont_mode$(5)="OFF"
110 Cont_mode$(6)="OFF"
120 Cont_mode$(7)="OFF"
130 Cont_mode$(8)="OFF"
140 Cont_mode$(9)="OFF"
150 !
160 FOR I=1 TO 9
170 OUTPUT @Agte507x;":INIT"&VAL$(I)&":CONT "&Cont_mode$(I)
180 NEXT I
190 OUTPUT @Agte507x;":TRIG:SOUR BUS"
200 !
210 OUTPUT @Agte507x;":TRIG:SING"
220 OUTPUT @Agte507x;"*OPC?"
230 ENTER @Agte507x;Buff$
240 !
250 PRINT "Measurement complete"
260 END