If you do not have an Keysight GPIB card, you can still use the SCPI Status System to signal an instrument service request. Instead of an SRQ Event, you periodically poll for the instrument status.

Note: You cannot use SRQ polling with the RS-232 interface.

See the previous section Using SRQ Events for some typical ways an instrument can generate a service request.

Setting up the SRQ polling is similar to using an SRQ event as described above except that we periodically check or 'poll' the instrument to see if SRQ is set. Polling does not interfere with the normal operation of the instrument.

  1. Clear the instrument and enable registers and status byte register to generate the desired service request.
  2. Set up the instrument for the required operation and initiate the operation. Include the IEEE-488.2 Common Command *OPC as the last instrument command.
  3. Enable the timer that polls for SRQ periodically.
  4. Periodically check the SRQ status. When the SRQ is set, execute the desired operation (for the DMM we will get the readings).

1. The instrument is cleared and set to give an SRQ

For example, the Keysight 34401A Multimeter can generate a service request when all operations are complete by programming the multimeter to set the *OPC bit (bit 0) in the Standard Event register. The following code is an example of how to set the Keysight 34401A to generate a service request when operations are complete. This is a repeat of item 2 in Using SRQ Events.

With DMM
  .Output "*RST" ' Reset multimeter
  .Output "*CLS" ' Clear status registers
  ' Enable Operation Complete bit to 
  .Output "*ESE 1"
  ' Enable standard event bit in status byte
  .Output "*SRE 32"
  .WriteString "*OPC?"     ' Assure synchronization
  strTemp = .ReadString    ' Discard returned value
End With

Now, set the instrument to make measurements and set the Operation Complete bit when done. The following code sets the Keysight 34401A to make 10 measurements. Each measurement will take approximately 0.16 seconds to complete (10 NPLC), so the entire measurement sequence requires more than 1.6 seconds. The *OPC command sets the bit in the Standard Event register when the measurements are complete and in the output buffer.

2. Set up the instrument for the required task

At this point we set up the configuration of the instrument to take a reading. This is the code to set the 34401A to take a burst of readings.

numberReadings = 10
    With DMM
        .WriteString "Configure:Voltage:dc 10"  
        .WriteString "Voltage:DC:NPLC 10" 
        .WriteString "Trigger:count" & Str$(numberReadings) 
        .WriteString "Init"                      
        .WriteString "*OPC"                                            
    End With

3. Enable the timer that polls for SRQ periodically

To periodically check the SRQ status, use a Visual Basic Timer control such as tmrPollForSRQ (the name given the Timer control) in the code below. You can set the timer interval in the property page at design time, or you can set the value in code using the interval property. When you are ready to begin polling for SRQ, enable the timer. For more information about the Visual Basic timer object refer to Using the Timer Control in the Visual Basic documentation.

tmrPollForSRQ.Interval = 1000  ' set 1 second interval
tmrPollForSRQ.Enabled = True   ' begin checking for SRQ

4. Periodically check the SRQ status

The timer subroutine (tmrPollForSRQ_Timer) is executed each time the timer fires. Put the SRQ polling code in the timer subroutine. If the service request is found, the timer method calls ReadData to read the data into an array.

Private Sub tmrPollForSRQ_Timer()
    Dim statusValue As Byte
    
    ' read the status byte
    statusValue = DMM.IO.ReadSTB
    
    ' Test for the SRQ bit
    If statusValue And 64 Then       ' SRQ from Operation complete
        ' Turn off the timer and stop polling.
        tmrPollForSRQ.Enabled = False
        ' Get the Data, the meter is ready
        ReadData
    Else
        Debug.Print "Test for SRQ, SRQ not fired"
    End If
    
End Sub
Private Sub ReadData()
    Dim readings() As Double
    
    With DMM
        .WriteString "Fetch?"      ' Query for the data in memory
        ' get the data put in array
        readings = . ReadList(ASCIIType_R8)     
    End With
End Sub