
Sample Program
7-7
IM 760151-17E
7
Sample1(GPIB) Get Power Data
————————————————————————————————————————————
Private Function GpibPower() As Integer
Dim msg As String ‘Command buffer
Dim qry As String ‘Query buffer
Dim sts As Integer
Dim item As Integer
Dim comma As Integer
Dim length As Integer
Dim cnt As Integer
term = Chr$(10) ‘terminator
msg = Space$(100)
qry = Space$(900)
List1.AddItem “Now Initializing. Wait a moment.”
Dummy = DoEvents()
sts = InitGpib ‘Initialize GPIB
If (sts <> 0) Then
GpibPower = 1
Exit Function
End If
‘Initialize the settings
msg = “*RST” + term ‘Initialize the settings
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
‘Set the measurement condition
msg = “VOLTAGE:RANGE 100V” + term ‘Voltage range = 100V
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
msg = “CURRENT:RANGE 1A” + term ‘Current range = 1A
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
msg = “RATE 500MS” + term ‘Update Rate = 500ms
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
‘Set the numeric data output items
‘ASCII format, Preset pattern1, Number of data = 60
msg = “NUMERIC:FORMAT ASCII;NORMAL:PRESET 1;NUMBER 60” + term
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
‘Set the transition filter used to detect the completion of the data updating
msg = “STATUS:FILTER1 FALL” + term ‘Falling edge of bit0(UPD)
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
‘Clear the extended event register (Read and trash the response)
msg = “STATUS:EESR?” + term
sts = ilwrt(Dev, msg, Len(msg)) ‘Send Command
If (sts < 0) Then
Call DisplayGPIBError(sts, msg)
GpibPower = 1
Exit Function
End If
sts = ilrd(Dev, qry, Len(qry)) ‘Receive Query
If (sts < 0) Then
7.4 Output of Power Measurement Data