Retrieving Results Using *TRG (ASCII Format)

Other topics about Sample Programs

Overview

This sample program performs two tasks: it triggers the instrument and returns the results. It is useful, for example when you want to retrieve measurement results immediately after triggering the instrument from an external controller.

The program demonstrates the use of the *TRG command and it uses ASCII format.

The program also retrieves and displays the measurement status as well as the measurement results for parameters 1 and 2 and the result of test signal current level monitoring.

See these topics for this programming:

Sample Program in Excel VBA Using VISA-COM

Sub TRG_ASCII()

    '*** The variables of the resource manager and the instrument I/O are declared

    Dim ioMgr As VisaComLib.ResourceManager

    Dim Age4982x As VisaComLib.FormattedIO488

    '*** The memory area of the resource manager and the instrument I/O are acquired

    Set ioMgr = New VisaComLib.ResourceManager

    Set Age4982x = New VisaComLib.FormattedIO488

    '*** Open the instrument & Sets the GPIB address

    Set Age4982x.IO = ioMgr.Open("GPIB0::17::INSTR")

    Age4982x.IO.timeout = 30000   ' TimeOut time should be greater than the measurement time.

    

    MsgBox ("4982X is Open!"), vbOKOnly

    

    '*** Variable declaration

    Dim Para1, Para2 As String

    Dim Result() As Double

    Dim Point, Cond_reg As Integer

    Dim BitWaitingForTrigger As Integer

    

    '* Sets the Point variable to the number of measurement points for single-point measurement.

    Point = 1

    

    '* Sets the data transfer format to ASCII

    Age4982x.WriteString ":FORM ASC", True

    

    '* Instructs the instrument to show the results for measurement parameters 1 and 2 as well as

    '*  the result of test signal current level monitoring while hiding the measurement results of

    '*  measurement parameters 3 and 4 as well as the result of test signal voltage level monitoring.

    Age4982x.WriteString ":DISP:TEXT1:CALC1 ON", True

    Age4982x.WriteString ":DISP:TEXT1:CALC2 ON", True

    Age4982x.WriteString ":DISP:TEXT1:CALC3 OFF", True

    Age4982x.WriteString ":DISP:TEXT1:CALC4 OFF", True

    Age4982x.WriteString ":DISP:TEXT1:CALC11 ON", True

    Age4982x.WriteString ":DISP:TEXT1:CALC12 OFF", True

    

    '* Retrieves the parameter names of measurement parameters 1 and 2 and stores the names into

    '*  the Para1 and Para2 variables, respectively.

    Age4982x.WriteString ":CALC:PAR1:FORM?", True

    Para1 = Age4982x.ReadString

    Age4982x.WriteString ":CALC:PAR2:FORM?", True

    Para2 = Age4982x.ReadString

    

    '* Instructs the instrument to perform single-point measurement at the point identified by the Point variable.

    Age4982x.WriteString ":SOUR:LIST:STAT OFF", True

    Age4982x.WriteString ":SOUR:LIST:POIN " & Point, True

    

    '* Turns off the bin sorting and Rdc measurement functions.

    Age4982x.WriteString ":CALC:COMP OFF", True

    Age4982x.WriteString ":SOUR:LIST:RDC OFF", True

    

    '*** Trigger source setting

    '* Sets the trigger source to GPIB/LAN trigger and turns on the continuous activation of the trigger system.

    Age4982x.WriteString ":TRIG:SOUR BUS", True

    Age4982x.WriteString ":INIT:CONT ON", True

    

    '*** Triggering and data read

    '* Triggers the instrument after the trigger system is put into trigger wait state.

    Do

        Age4982x.WriteString ":STAT:OPER:COND?", True

        Cond_reg = Age4982x.ReadNumber

        BitWaitingForTrigger = Cond_reg And 32

    Loop While BitWaitingForTrigger = 0

    

    Age4982x.WriteString "*TRG", True

    

    '* Retrieves the measurement status, the measurement results for parameters 1 and 2,

    '*  and the result of test signal current level monitoring and then stores the data into

    '*  the Stat, Res1, Res2, and Imon variables.

    Result() = Age4982x.ReadList(ASCIIType_R8, ",")

             

    '*** Display Results

    '* Displays the measurement results.

    MsgBox "### Result ###", vbOKOnly

    MsgBox ("Meas. Status: " & Result(0) & vbCrLf & "Para1: " & Para1 & "Result: " & Result(1) & vbCrLf & "Para2: " & Para2 & "Result: " & Result(2) & vbCrLf & "Imon: " & Result(3)), vbOKOnly, "Measurement Results"

    MsgBox ("End of ""Retrieving Results Using TRG* (ASCII Format)"" program"), vbOKOnly

End Sub