5-40
Remote Operation
Example Programs
Status = viVPrintf(DevSessionNum, "*CLS" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
’-- Map OPC to bit 5 of the Standard Event Status Enable Register
Status = viVPrintf(DevSessionNum, "*ESE 1" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
’-- Ensure that the instrument isn’t in repeat sweep mode
Status = viVPrintf(DevSessionNum, "INIT:CONT 0" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
’-- Send Calibration command OPC
Status = viVPrintf(DevSessionNum, "CAL:WAV:INT;*OPC" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
’-- Wait for completion
TimeStart = Now * 86400 ’Used to track elapsed time
Do
’-- 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
Loop While (STB And 32) <> 32
’-- Clear status information
Status = viVPrintf(DevSessionNum, "*CLS" & Chr$(10), 0)
If Status <> 0 Then GoTo ErrorHandler
Call MsgBox("Calibration Completed!", vbOKOnly, "Done")
EndSession:
On Error Resume Next
’-- Close VISA session to the WDCA
Call viClose(DevSessionNum)
’-- End VISA session
Call viClose(DefRM)
MousePointer = vbDefault
Exit Sub
OPCTimeOut:
MousePointer = vbDefault
Call MsgBox("Timeout while waiting for OPC. Make sure all cables are securely fastened.", _
vbOKOnly, "Timeout")
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com