Chapter 7 Application Programs

Example Programs for Excel 7.0

Sub OpenPort() ’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Be sure that the HP-IB address has been set in the ’VISAaddr’ variable

before calling this routine. ’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Open the VISA session

errorStatus = viOpenDefaultRM(videfaultRM) ’ Open communications to the instrument

errorStatus = viOpen(videfaultRM, "GPIB0::" & VISAaddr & "::INSTR", 0, 2500, vi)

If an error occurs, give a message If errorStatus < VI_SUCCESS Then

Range("A2").Select

Cells(1, 1) = "Unable to Open Port" End If

End Sub

Sub ClosePort() errorStatus = viClose(vi) ’ Close the session

errorStatus = viClose(videfaultRM) End Sub

’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

This subroutine is used to create delays. The input is in seconds and

fractional seconds are allowed. ’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Sub delay(delay_time As Single)

Dim Finish As Single Finish = Timer + delay_time Do

Loop Until Finish <= Timer End Sub

BAC

Page 321
Image 321
HP 34970A manual Bac