Public Sub ocs_read_value()
Dim byteData() As Byte
Dim wfm() As Byte
Dim screen As String
Dim tem As String
Dim status As Integer
Dim ocsno As String
'示波器通道
read_ch = "CH1"
'读值类型
read_type = "MAX"
Dim stracq, dorecordl, DoCommand, strrl, time, dateofcos, row, column As String
Set AppSheet = ActiveSheet
Set rm = New VisaComLib.ResourceManager
idos = "TCPIP0::" & Sheets("示波器地址").Cells(1, 2) & "::inst0::INSTR" '示波器地址写在工作表“示波器地址”,1行2列
Set fmio.IO = rm.Open(idos)
fmio.IO.Timeout = 2000 '延时
fmio.IO.Clear
Sleep 200 '添加Delay时间,让示波器多点时间传输,防止卡死
wfm = screen '将拼接完成的String转换成Byte(),方便存入到波形
Dim strPath As String
fmio.IO.Timeout = 5000 '还原超时时间
fmio.WriteString ":MEASU:IMM:SOU " & read_ch & ";:MEASU:IMM:TYP " & read_type & ";:MEASU:IMM:VAL?;"
Sleep 100
'返回值 shuzhi
shuzhi = Replace(fmio.ReadString(), ":MEASUREMENT:IMMED:VALUE ", "")
End Sub
VBA读取示波器测量值
最新推荐文章于 2024-08-03 14:16:19 发布