Posted Sun, 15 Jan 2023 02:57:45 GMT by C, Andrea
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 ****")
Posted Tue, 17 Jan 2023 14:42:11 GMT by Eglowstein, Howard

Thank you Andrea!  That's really helpful, and I'll check to see if we licensed that feature. We wanted this specific unit because of the ability to send large waveforms but didn't know they had to be sequenced. We probably didn't buy that option because you know how purchasing people are - they see an extra cost and skip it to save money.

Is it the case that a sequenced waveform has to go to channel 1 and you can't have two of them going to channels 1 and 2 at the same time? I think there's a lot of questions we should have asked before choosing this instrument that we didn't ask first.

Howard

Posted Tue, 17 Jan 2023 21:25:48 GMT by C, Andrea
If the optional SEQ license is not there, then the SEQ feature of Advanced mode can still be used, but only in run mode = continuous.
Continuous also limits you to one waveform entry with infinite repeat.
Wait, jump are disabled too.

Both channels can have a waveform (but need same number of points in each).

Right now, it seems the only means to present a single waveform file that contains more than 131K entries to the SEQ is to bring it on a thumb drive (*.tfwx).

How to get it onto a thumb drive?  I used ArbExpress (3.6).  Use the File>Open to open a saved scope waveform or a csv file of the waveform.  Then use File>Save As to save the tfwx file for the AFG to use.
Hopefully in near future we will have an API for creating the large sequence directly onto the AFG storage.

You must be signed in to post in this forum.