Detecting End of Measurement

Other topics about Controlling E5061B

Overview

This chapter uses sample programs to demonstrate how to trigger the instrument to start a new measurement cycle and how to detect the end of a measurement cycle. The trigger system is responsible for such tasks as detecting the start of a measurement cycle (triggering) and enabling/disabling measurement on each channel.

You can detect the end of measurement by using either the status register or the SCPI.TRIGger.SEQuence.SINGle object.

Using Status Register

The status of the E5061B can be detected through the status register. If your program is based on SPCI commands, you can use SRQ (Service Request) interruptions to detect the end of measurement.

On the other hand, if your program is based on COM objects, SRQ interruptions are not available; instead, you can use the following object to suspend the program until SRQs are generated upon completion of measurement.

Sample program is available to download from the Keysight Support page, named meas_srq.vba. It demonstrates how to use the status register to suspend the program until the end of measurement. This VBA program consists of the following modules:

Object name

Module type

Content

frmSrqMeas

UserForm

Uses the status register to wait for the end of measurement.

mdlSrqMeas

Standard module

Invokes a UserForm.

When you run this VBA program, the following UserForm appears.

The UserForm when running the meas_srq.vba program

 For how to use each element, see the following description.

  1. The program turns ON/OFF Continuous Activation mode for each channel and determines whether to enable or disable each channel for measurement.

  2. The program triggers the instrument to start a new measurement cycle, waits for the end of measurement, and then displays a message. For detail, see the description of the code window.

  3.  The program exits, and the UserForm disappears.

In Visual Basic Editor, open the UserForm (object name: frmSrqMeas), and double-click the Meas or Exit button to bring up the code window. The following is the description of the subprograms associated with the respective buttons.

 

Using SRQs to detect the end of measurement (object name: frmSrqMeas)

''''

' Procedure called when the user clicks the Exit button on the UserForm.

''''

private Sub cmdExit_Click()

'

' Unloads the UserForm from the memory, and terminates the program.

'

    Unload Me

'

End Sub

'

'

''''

' Procedure called when the user clicks the Meas button on the UserForm.

''''

Private Sub cmdMeas_Click()

    Dim Cond As Boolean

'

' Hides the UserForm (object name: frmSrqMeas) from the screen.

'

    frmSrqMeas.Hide

'

' Displays 4 channel windows.

'

    SCPI.DISPlay.Split = "d12_34"

'

' Sets the trigger source to "bus".

'

    SCPI.TRIGger.SEQuence.Source = "bus"

'

' These lines turn on or off Continuous Activation mode for each channel

' depending on whether the corresponding option buttons are on or off.

' By default, the mode is turned on for channel 1 only.

'

    SCPI.INITiate(1).CONTinuous = optOn1.Value

    SCPI.INITiate(2).CONTinuous = optOn2.Value

    SCPI.INITiate(3).CONTinuous = optOn3.Value

    SCPI.INITiate(4).CONTinuous = optOn4.Value

'

' These lines configure the instrument so that operation status event

' register's bit 4 is set to 1 only when operation status condition

' register's bit 4 is changed from 1 to 0 (negative transition).

'

    SCPI.STATus.OPERation.PTRansition = 0

    SCPI.STATus.OPERation.NTRansition = 16

'

' Enables the operation status event register's bit 4.

'

    SCPI.STATus.OPERation.ENABle = 16

'

' Enables the status byte register's bit 7.

'

    SCPI.IEEE4882.SRE = 128

'

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

'

    SCPI.IEEE4882.CLS

'

' Triggers the instrument to start a measurement cycle.

'

    SCPI.IEEE4882.TRG

'

' Verifies that the instrument is in a measurement cycle, and suspends

' the program until the end of measurement.

' The time-out is set to 100 seconds (maximum value).

'

    WaitOnSRQ Cond, 100000

'

' These lines display a measurement completion message upon detecting

' the end of measurement.

'

    If Cond = True Then

      MsgBox "Measurement Completion"

    End If

'

' Displays the UserForm (object name :frmSrqMeas) on the screen.

'

    frmSrqMeas.Show

'

End Sub

 

 

Using the SCPI.TRIGger.SEQuence.SINGle Object

When you trigger the instrument by issuing the SCPI.TRIGger.SEQuence.SINGle object, you can use the SCPI.IEEE4882.OPC object to suspend the program until the end of measurement.

The sample program is available to download from the Keysight Support page, named meas_sing.vba. It demonstrates how to use the SCPI.TRIGger.SEQuence.SINGle object to suspend the program until the end of measurement. This VBA program consists of the following modules:

Object name

Module type

Content

frmSingMeas

UserForm

Uses the SCPI.TRIGger.SEQuence.SINGle and SCPI.IEEE4882.OPC objects to suspend the program until the end of measurement.

mdlSingMeas

Standard module

Invokes a UserForm.

When you run this VBA program, a Userform appears.

The UserForm when running the meas_sing.vba program

In Visual Basic Editor, open the UserForm (object name:frmSingMeas), and double-click the Meas or Exit button to bring up the code window. The following is the description of the subprograms associated with the respective buttons.

 

Using the SCPI.TRIGger.SEQuence.SINGle object to suspend the program until the end of measurement (object name:frmSingMeas)

''''

' Procedure called when the user clicks the Exit button on the UserForm.

''''

Private Sub cmdExit_Click()

'

' Unloads the UserForm from the memory, and terminates the program.

'

    Unload Me

'

End Sub

'

'

''''

' Procedure called when the user clicks the Meas button on the UserForm.

''''

Private Sub cmdMeas_Click()

    Dim Dmy As Long

'

' Hides the UserForm (object name: frmSingMeas) from the screen.

'

    frmSingMeas.Hide

'

' Displays 4 channel windows.

'

    SCPI.DISPlay.Split = "d12_34"

'

' Sets the trigger source to "bus".

'

    SCPI.TRIGger.SEQuence.Source = "bus"

'

' These lines turn on or off Continuous Activation mode for each channel

' depending on whether the corresponding option buttons are on or off.

' By default, the mode is turned on for channel 1 only.

'

    SCPI.INITiate(1).CONTinuous = optOn1.Value

    SCPI.INITiate(2).CONTinuous = optOn2.Value

    SCPI.INITiate(3).CONTinuous = optOn3.Value

    SCPI.INITiate(4).CONTinuous = optOn4.Value

'

' Triggers the instrument to start a measurement cycle.

'

    SCPI.TRIGger.SEQuence.SINGle

'

' Executes the SCPI.IEEE4882.OPC object to suspend the program until

' the value of 1 is returned indicating the end of measurement.

'

    Dmy = SCPI.IEEE4882.OPC

'

' Displays a measurement completion message.

'

    MsgBox "Measurement Completion"

'

' Displays the UserForm (object name: frmSingMeas) on the screen.

'

    frmSingMeas.Show

'

End Sub