Using SRQ to Detect End of Measurement

Other topics about Sample Programs

Overview

This sample program uses an SRQ to detect the end of measurement.

The program aborts the trigger system, makes the SRQ setting, and then initiates the trigger system once. When an SRQ is generated at the end of measurement, the program displays the end message.

See these topics for this programming:

Sample Program in Excel VBA Using VISA-COM

Dim Age4982x As VisaComLib.FormattedIO488

Option Explicit

Implements VisaComLib.IEventHandler

Sub EOM_Detect_Click()

    Dim gmgr As VisaComLib.ResourceManager

    Dim SRQ As VisaComLib.IEventManager

    Dim i As Double

  

    Dim strdmy As String

  

    Set gmgr = New VisaComLib.ResourceManager

    Set Age4982x = New VisaComLib.FormattedIO488

    Set Age4982x.IO = gmgr.Open("GPIB0::17::INSTR") ' Sets the GPIB address and select code.

    Age4982x.IO.Timeout = 10000                     ' Sets the time out time

  

    Set SRQ = Age4982x.IO

  

   

    With Age4982x

        'Sets the trigger source to the BUS.

        .WriteString "*RST"

        .WriteString ":TRIG:SOUR BUS"

        .WriteString ":INIT:CONT ON"

        

        ' Sets the positive transition filter to 0 and the negative transition filter

        ' to 1 so that the operation status event register at bit 4 is set to 1 only

        ' when the operation status condition register at bit 4 is changed from 1 to 0.

        .WriteString ":STAT:OPER:PTR 0"

        .WriteString ":STAT:OPER:NTR 16"

        ' Enables bit 4 in the operation status event register and bit 8 in the status byte register.

        .WriteString ":STAT:OPER:ENAB 16"

        .WriteString "*SRE 128"

        ' Clears the operation status event register and the status byte register

        .WriteString "*CLS"

        .WriteString "*OPC?"

         strdmy = .ReadString

    End With

    With Age4982x

        ' Set the table with 10 points to make a longer time measurement

        .WriteString ":SOUR:LIST 10, 1E6, 100, -10, 2E6, 100, -10, 3E6, 100, -10, 4E6, 100, -10, 5E6, 100, -10, 6E6, 100, -10, 7E6, 100, -10, 8E6, 100, -10, 9E6, 100, -10, 10E6, 100, -10 "

        .WriteString ":SOUR:LIST:STAT ON"

    End With

    SRQ.InstallHandler EVENT_SERVICE_REQ, Me        ' Enable SRQ event

    SRQ.EnableEvent EVENT_SERVICE_REQ, EVENT_HNDLR  '

    

    ' Initiates the trigger system one time

    Age4982x.WriteString ":TRIG:IMM"

 

Loop1:

    DoEvents   ' When SRQ is generated by the measurement end, the IEventHandler_HandleEven sub routine is called.

    GoTo Loop1

   

    SRQ.DisableEvent ALL_ENABLED_EVENTS, EVENT_ALL_MECH, 0  ' Disable SRQ event

  

End Sub

Sub IEventHandler_HandleEvent(ByVal vi As VisaComLib.IEventManager, ByVal SRQevent As VisaComLib.IEvent, ByVal userHandle As Long)

  

    Age4982x.WriteString "*CLS"

    MsgBox "Measurement Complete", vbOKOnly, "Complete"

    End

    

  

End Sub