Send Trigger to Instrument
Use visatrigger
Function
You can execute a trigger with the visatrigger
function. This function is only for VISA-GPIB and
VISA-VXI interfaces. It is equivalent to the viAssertTrigger
operation, as described in the VISA Specifications found at IVI
Specifications. For an instrument connected with the VISA-GPIB interface,
this function triggers the instrument using a GPIB bus event.
Refer to your instrument documentation to learn how to use its triggering capabilities.
Execute Trigger
This example illustrates VISA-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.
Create a VISA-GPIB object — Create the VISA-GPIB object
g
associated with a National Instruments™ GPIB controller with board index 0 and an instrument with primary address 1.g = visadev("GPIB0::1::0::INSTR");
Write and read data — Configure the function generator to produce a 5000 Hz sine wave, with 6 volts peak-to-peak.
writeline(g,"Func:Shape Sin") writeline(g,"Volt 3") writeline(g,"Freq 5000")
Configure the burst of the trigger to display the sine wave for 5 seconds, configure the function generator to expect the trigger from the GPIB board, and enable the burst mode.
writeline(g,"BM:NCycles 25000") writeline(g,"Trigger:Source Bus") writeline(g,"BM:State On")
Trigger the instrument.
visatrigger(g)
Disable the burst mode.
writeline(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 in the following figure.
Disconnect and clean up — Use
clear
to disconnect the instrument from the VISA-GPIB objectg
and to clear it from the MATLAB® workspace when you are done working with it.clear g