Detecting End of Measurement

Other topics about Controlling E5071C

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 E5071C can be detected through the status register. If your program is based on SPCI commands, you can use SRQ (Service Request) interrupts to detect the end of measurement.

On the other hand, if your program is based on COM objects, SRQ interrupts 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, that 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.

Procedure called when the user clicks the Exit button on the UserForm (lines 10 to 50)

Line 30

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

Procedure called when the user clicks the Meas button on the UserForm (lines 70 to 390)

Line 110

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

Line 130

Displays 9 channel windows.

Line 140

Sets the trigger source to "bus".

Lines 160 to 240

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.

Lines 260 to 270

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).

Line 280

Enables the operation status event register's bit 4.

Line 290

Enables the status byte register's bit 7.

Line 300

Clears the status byte register and operation status event register.

Line 310

Triggers the instrument to start a measurement cycle.

Line 320

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).

Lines 330 to 350

These lines display a measurement completion message upon detecting the end of measurement.

Line 370

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

 

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

10| Private Sub cmdExit_Click()

20|

30| Unload Me

40|

50| End Sub

60|

70| Private Sub cmdMeas_Click()

80|

90| Dim Cond As Boolean

100|

110| frmSrqMeas.Hide

120|

130| SCPI.DISPlay.Split = "d123_456_789"

140| SCPI.TRIGger.SEQuence.Source = "bus"

150|

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

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

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

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

200| SCPI.INITiate(5).CONTinuous = optOn5.Value

210| SCPI.INITiate(6).CONTinuous = optOn6.Value

220| SCPI.INITiate(7).CONTinuous = optOn7.Value

230| SCPI.INITiate(8).CONTinuous = optOn8.Value

240| SCPI.INITiate(9).CONTinuous = optOn9.Value

250|

260| SCPI.STATus.OPERation.PTRansition = 0

270| SCPI.STATus.OPERation.NTRansition = 16

280| SCPI.STATus.OPERation.ENABle = 16

290| SCPI.IEEE4882.SRE = 128

300| SCPI.IEEE4882.CLS

310| SCPI.IEEE4882.TRG

320| WaitOnSRQ Cond, 100000

330| If Cond = True Then

340| MsgBox "Measurement Completion"

350| End If

360|

370| frmSrqMeas.Show

380|

390| 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", that 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.

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.

Procedure called when the user clicks the Exit button on the UserForm (lines 10 to 50)

Line 30

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

Procedure called when the user clicks the Meas button on the UserForm (lines 70 to 330)

Line 110

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

Line 130

Displays 9 channel windows.

Line 140

Sets the trigger source to "bus".

Lines 160 to 240

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.

Line 260

Triggers the instrument to start a measurement cycle.

Line 270

Executes the SCPI.IEEE4882.OPC object to suspend the program until the value of 1 is returned indicating the end of measurement.

Line 290

Displays a measurement completion message.

Line 310

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

 

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

10| Private Sub cmdExit_Click()

20|

30| Unload Me

40|

50| End Sub

60|

70| Private Sub cmdMeas_Click()

80|

90| Dim Dmy As Long

100|

110| frmSingMeas.Hide

120|

130| SCPI.DISPlay.Split = "d123_456_789"

140| SCPI.TRIGger.SEQuence.Source = "bus"

150|

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

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

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

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

200| SCPI.INITiate(5).CONTinuous = optOn5.Value

210| SCPI.INITiate(6).CONTinuous = optOn6.Value

220| SCPI.INITiate(7).CONTinuous = optOn7.Value

230| SCPI.INITiate(8).CONTinuous = optOn8.Value

240| SCPI.INITiate(9).CONTinuous = optOn9.Value

250|

260| SCPI.TRIGger.SEQuence.SINGle

270| Dmy = SCPI.IEEE4882.OPC

280|

290| MsgBox "Measurement Completion"

300|

310| frmSingMeas.Show

320|

330| End Sub