Main Content

Execute Serial Polls

Use visastatus Function

You can execute a serial poll with the visastatus function. This function is for all VISA interfaces.

Serial Poll for VISA-GPIB

In a serial poll for the VISA-GPIB interface, the Controller asks (polls) each addressed Listener to send back a status byte that indicates whether it has asserted the SRQ line and needs servicing. The seventh bit of this byte (the RQS bit) is set if the instrument is requesting service.

The Controller performs the following steps for every addressed Listener:

  1. The Listener is addressed to talk and the Serial Poll Enable (SPE) command byte is sent.

  2. The ATN line is set high and the Listener returns the status byte.

  3. The ATN line is set low and the Serial Poll Disable (SPD) command byte is sent to end the poll sequence.

Refer to Status and Event Reporting for more information on the GPIB bus lines and the RQS bit.

Execute Serial Poll

This example shows you how to execute a serial poll for a Keysight® 33120A function generator and a Tektronix® TDS 210 oscilloscope. In doing so, the example shows you how to configure many of the status bits described in Standard Event Status Register.

  1. Create VISA-GPIB objects — Create the VISA-GPIB object fgen associated with a Keysight 33120A function generator at primary address 1.

    fgen = visadev("GPIB0::1::0::INSTR");

    Create the VISA-GPIB object scope associated with a Tektronix TDS 210 oscilloscope at primary address 2.

    scope = visadev("GPIB0::2::0::INSTR");
  2. Configure property values — Configure both objects to time out after 1 second.

    fgen.Timeout = 1;
    scope.Timeout = 1;
  3. Write and read data — Configure the function generator to request service when a command error occurs.

    writeline(fgen,"*ESE 32");
    writeline(fgen,"*SRE 32");

    Configure the oscilloscope to request service when a command error occurs.

    writeline(scope,"*PSC 0");
    writeline(scope,"*ESE 32");
    writeline(scope,"DESE 32");
    writeline(scope,"*SRE 32");

    Determine if any instrument needs servicing.

    ans =
    ans =

    Query the voltage value for each instrument.


    Determine if either instrument produced an error due to the preceding query.

    ans =
    ans =

    Since Volt? is a valid command for the function generator, the value is read back successfully.

    volt1 = readline(fgen)
    volt1 =

    Since Volt? is an invalid command for the oscilloscope, it is requesting service. The oscilloscope read operation times out after 1 second.

    volt2 = readline(scope)
    Warning: The specified amount of data was not returned within the Timeout period for 'readline'.
    'visadev' unable to read any data. For more information on possible reasons, see visadev Read
    ans =
  4. Disconnect and clean up — Use clear to disconnect the instruments from the VISA-GPIB objects fgen and scope and to clear it from the MATLAB® workspace when you are done working with it.

    clear fgen scope

See Also

Related Topics