Specifications

252 Chapter 15
Controlling Peripherals
Programming with VISA
170|
180| ' Opens the session to the specified instrument.
190| status = viOpen(Defrm, "GPIB0::5::INSTR", 0, 0, Dcsp)
200| If (status <> VI_SUCCESS) Then GoTo VisaErrorHandler
210|
220| ' Asks for the instrument to turn the dc power on.
230| status = viVPrintf(Dcsp, "INST P6V" & Chr$(10), 0)
240| status = viVPrintf(Dcsp, "VOLT MAX" & Chr$(10), 0)
250| status = viVPrintf(Dcsp, "CURR %lf" & Chr$(10), Cur)
260| status = viVPrintf(Dcsp, "OUTP ON" & Chr$(10), 0)
270| status = viVPrintf(Dcsp, "MEAS?" & Chr$(10), 0)
280| If (status <> VI_SUCCESS) Then GoTo VisaErrorHandler
290|
300| ' Reads the result.
310| status = viVScanf(Dcsp, "%t", Res)
320| If (status <> VI_SUCCESS) Then GoTo VisaErrorHandler
330|
340| ' Displays the result.
350| MsgBox "Result is: " & Res
360|
370| ' Performs a single measure.
380| SingleMeasure
390|
400| ' Turns the dc power off.
410| status = viVPrintf(Dcsp, "OUTP OFF" & Chr$(10), 0)
420|
430| ' Closes the resource manager session (which closes
everything)
440| Call viClose(Defrm)
450|
460| GoTo Prog_end
470|
480| VisaErrorHandler:
490| Dim VisaErr As String * 200
500| Call viStatusDesc(Defrm, status, VisaErr)
510| MsgBox "Error : " & VisaErr, vbExclamation
520| End
530|
540| Prog_end: End Sub