Jump to content
  • 0

AD3 Arbitrary Waveform Generator file I/O


AndyMessier

Question

I have been writing scripts in Python for the AD3 but I'm looking for some general advice on how to use the Arbitrary Waveform Generator Function.  I see that it can run at 125Msps .. but what is the max memory data-points? Is there an example of how the memory can be filled from a file? (I see some .wav example but I think the sample rate is encoded in those? I want to define that at the full rate).  In my application I'd like to play a waveform and hold the last sample indefinitely until I decide to play another waveform. Any high level advice on how I could do this or what sample files are the closest to this? Many thanks!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @AndyMessier

It can generate waveform or pattern from device buffer up to system frequency sample rate or higher, by skipping some, see AnalogOut_Custom.py example
The system frequency, for all instruments can be adjusted with DwfParamFrequency.
In play mode the data is streamed, transferred in chunks from computer, limiting the sample rate to 1-2MHz
The newly added idle hold option keeps the last output value in done state, with finite run time.

Link to comment
Share on other sites

  • 0
Posted (edited)

Thanks Attila. I have something running but I'm not sure how to implement that hold function properly ... In this code example it seems that the hold function works, but then when I play the next waveform there is a 200us glitch before it plays my samples (see the scope shot). 

 

def play_waveform(y):
    
    ts = 1/fs
    hzFreq = 1 / (len(y)*ts)
    cSamples = len(y)
    channel = c_int(0)
    rgdSamples = (c_double * len(y))(*y)

    dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) 
    dwf.FDwfAnalogOutModeSet(hdwf, channel, DwfAnalogOutIdleHold)
    dwf.FDwfAnalogOutIdleSet(hdwf, c_int(0), DwfAnalogOutIdleHold)
    dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel, AnalogOutNodeCarrier, c_int(1))
    dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel, AnalogOutNodeCarrier, funcCustom) 
    dwf.FDwfAnalogOutNodeDataSet(hdwf, channel, AnalogOutNodeCarrier, rgdSamples, c_int(cSamples))
    dwf.FDwfAnalogOutNodeFrequencySet(hdwf, channel, AnalogOutNodeCarrier, c_double(hzFreq)) 
    dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, channel, AnalogOutNodeCarrier, c_double(3.3))   
    dwf.FDwfAnalogOutRunSet(hdwf, channel, c_double(1.0/hzFreq)) 
    dwf.FDwfAnalogOutConfigure(hdwf, channel, c_int(1))

 

Picture1.png

 

ramp_test.py

Edited by AndyMessier
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...