Main Content


Using the trigger Function

You can execute a trigger with the trigger function. This function is equivalent to writing the GET (Group Execute Trigger) GPIB command to the instrument.

trigger instructs all the addressed Listeners to perform some instrument-specific function such as taking a measurement. Refer to your instrument documentation to learn how to use its triggering capabilities.

Executing a Trigger

This example illustrates GPIB triggering using a Keysight™ 33120A function generator. The output of the function generator is displayed with an oscilloscope so that you can observe the trigger.

  1. Create an instrument object — Create the GPIB object g associated with a National Instruments® GPIB controller with board index 0, and an instrument with primary address 1.

    g = gpib('ni',0,1);
  2. Connect to the instrument — Connect g to the function generator.

  3. Write and read data — Configure the function generator to produce a 5000 Hz sine wave, with 6 volts peak-to-peak.

    fprintf(g,'Func:Shape Sin')
    fprintf(g,'Volt 3')
    fprintf(g,'Freq 5000')

    Configure the burst of the trigger to display the sine wave for five seconds, configure the function generator to expect the trigger from the GPIB board, and enable the burst mode.

    fprintf(g,'BM:NCycles 25000')
    fprintf(g,'Trigger:Source Bus')
    fprintf(g,'BM:State On')

    Trigger the instrument.


    Disable the burst mode.

    fprintf(g,'BM:State Off')

    While the function generator is triggered, the sine wave is saved to the Ref A memory location of the oscilloscope. The saved waveform is shown below.

  4. Disconnect and clean up — When you no longer need g, you should disconnect it from the instrument, and remove it from memory and from the MATLAB® workspace.

    clear g