On the AFG31K models, in the Advanced mode, the SEQ feature is separately licensed.
Trial license can be obtained here:
Tek AMS Trial License for AFG
Here is a Python simple demo program to use the SEQ feature from the sample waveform files on the unit P: drive for predefined waveforms.
import pyvisa
import time
#Get the this from NI-MAX
instrumentdescriptor = 'USB0::0x0699::0x035A::C013392::INSTR'
debug = 1
# define a couple helper functions
def error_check():
e = int(AFG.query('*esr?'))
if e != 0:
err_msg = AFG.query("SYST:ERR?")
print(err_msg)
#raise Exception('non-zero esr: ' + err_msg)
# some operations need a litte time
# and if we send next command too soon, bad things happen.
# so use the operation complete query to be kind to AFG.
# if operation takes longer than our VISA timeout, that errow will occur
def check_if_done():
e = int(AFG.query('*opc?'))
if e != 1:
print("did we get visa timeout?")
# *************** Connect to AFG
resource_mgr = pyvisa.ResourceManager()
AFG = resource_mgr.open_resource(instrumentdescriptor)
AFG.read_termination = '\n'
AFG.encoding = 'latin_1' #for any binary data, this is needed
AFG.timeout = 10000 #number of msec before timeout error for VISA read
print(AFG.query('*IDN?'))
print("Do you have the SEQ license?")
print(AFG.query("LIC:LIST?")) # make sure you have SEQ license!!
#reset and clear the AFG status
AFG.write('*RST')
AFG.write('*CLS')
#put instrument into Advanced/SEQ mode
AFG.write("SEQControl:STATe ON")
check_if_done()
AFG.write("SEQuence:NEW") #this gives us "clean slate" in the SEQ setup
check_if_done()
AFG.write("SEQControl:RMODe SEQ") # run node = SEQ
check_if_done()
AFG.write("SEQuence:LENGth 2") #this example will load two index in our SEQ
AFG.write("SEQControl:SRATe 5.0E6")
AFG.write("SEQControl:SOURce1:SCALe 100") # 1000 is max value = FS of your AFG model
AFG.write("SEQControl:SOURce1:OFFSet 0") #offset in volts
# load files from predefined location (P:)
# this gives our sequence two Waveforms to use
AFG.write("WLISt:WAVeform:IMPort \"P:/Pulse1000.tfwx\"")
check_if_done()
if debug: error_check()
AFG.write("WLISt:WAVeform:IMPort \"P:/Sine1000.tfwx\"")
check_if_done()
if debug: error_check()
AFG.write("SEQuence:ELEM1:WAVeform1 \"P:/Pulse1000.tfwx\"") # load first element
check_if_done()
if debug: error_check()
AFG.write("SEQuence:ELEM2:WAVeform1 \"P:/Sine1000.tfwx\"") # load second element
check_if_done()
if debug: error_check()
# set Repeat values for each element
AFG.write("SEQuence:ELEM1:LOOP:COUNt 5") # up to 1E6
check_if_done()
if debug: error_check()
AFG.write("SEQuence:ELEM2:LOOP:COUNt 3")
check_if_done()
if debug: error_check()
# have last element GOTO index 1 element
AFG.write("SEQuence:ELEM2:GOTO:STATe 1") # enable GOTO index behavior
AFG.write("SEQuence:ELEM2:GOTO:INDEX 1") # have last index GOTO index 1
check_if_done()
if debug: error_check()
#the SEQ is loaded...now run it
AFG.write("OUTPut1:IMPedance INF") # presently connected to Hi-Z scope channel
AFG.write("OUTPut1:STATe ON")
AFG.write("SEQControl:RUN:IMMediate")
time.sleep(5) # let it run for a few seconds
AFG.write("SEQControl:STOP:IMMediate")
check_if_done() # this is one example where a little time needed
AFG.write("OUTPut1:STATe OFF") # if you want the output reliably turned off
#clean up our VISA connection
AFG.clear()
AFG.close()
resource_mgr.close()
print("*** all done ****")