Example 8, Command Preset - Agilent Technologies 86082A User Manual

Wavelength domain component analyzer
Table of Contents

Advertisement

Example 8, Command Preset

Description
All the Visual Basic sample applications have a button to preset the instru-
ment. This function returns the instrument to a known state.
Program
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const OPC_TMO = 180
Private Const LZ_TMO = 360
Private Sub cmdRST_Click()
Dim TimeStart As Double
'-- VISA session variables
Dim DefRM As Long
Dim DevSessionNum As Long
Dim ReadBuffer As String * 65500
Dim STB As Integer
Dim Status As Long: Status = 0
Dim ErrMsg As String: ErrMsg = ""
On Error GoTo ErrorHandler
MousePointer = vbHourglass
'-- Call function to initialize a VISA session to the WDCA
Status = InitVISASession(txtGPIB_IN.Text, txtGPIB_PA.Text, DefRM, DevSessionNum, ErrMsg)
If Status <> 0 Or ErrMsg <> "" Then GoTo ErrorHandler
'-- Preset the instrument and send OPC
Status = viVPrintf(DevSessionNum, "*RST;*OPC" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
'-- Wait for completion
TimeStart = Now * 86400
Do
Loop While (STB And 32) <> 32
'-- Clear status information
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
'Used to track elapsed time
'-- If a minute goes by, throw a timeout
If (Now * 86400) - TimeStart > OPC_TMO Then GoTo OPCTimeOut
'-- Check bit 5 of the status byte register to see if the operation is complete
Status = viReadSTB(DevSessionNum, STB)
If Status <> 0 Then GoTo ErrorHandler
Call Sleep(5) 'Delay so the instrument isn't tied up with responding to STB
DoEvents
Remote Operation
Example Programs
'VISA session
'VISA session to device
'Buffer to read back data
'Status byte
5-77

Advertisement

Table of Contents
loading

Table of Contents