I am trying to create two square wave signals on the AD2 Analog instrument. Both signals should start at 5v, one should drop to 0v at the trigger, and the other should go to 0v after a certain delay time after the trigger (delay time = self.d/1000). Both signals should return to 5v at the same time (end of RunSet). I think I have to do this using the 'funcCustom' output, at least for the delayed signal. However, I am not able to get the funcCustom signal to give me the desired output. It just outputs 5v constantly after the trigger signal. (The funcSquare signal does what is expected).
Is there an easier way to create this delay between two analog channels without using funcCustom? Or is there something wrong in my syntax for getting the funcCustom signal to work?
#set up external trigger input channel, configure to wait for trigger signal
self.dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(-1), trigsrcExternal1)
self.dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(-1), c_int(1)) # set to trigger on rising edge
#set channel idles
self.dwf.FDwfAnalogOutIdleSet(hdwf, c_int(-1), c_int(1)) #set both channels to idle to offset value
self.dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(5.0)) #ch0-Qsys idles high
self.dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_double(5.0)) #ch1-Xray idles high
#set run duration
totald=float(self.active.xduration+self.d/1000)
self.dwf.FDwfAnalogOutRunSet(hdwf, c_int(-1), c_double(totald)) #set run duration on both channels
#calculate delay/run percentages
nhigh = int((self.d/1000)/totald*10000) #10000 counts, calculate number of counts low&high as ratio of self.d(ms)/totald(s)
nlow = 10000-nhigh
rgdSamples = (c_double*10000)(*[1.0]*nhigh+[0.0]*nlow)
#set up signal configuration
#ch0=QTrig, needs to change voltage on trigger
self.dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, funcSquare) #create square wave with 100% pulse width
self.dwf.FDwfAnalogOutNodeSymmetrySet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(0.0)) # 0% duty cycle at +amplitude, 100% at -amplitude
#ch1=xray-trigs, need to change after trigger+delay using custom array
self.dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(1), AnalogOutNodeCarrier, funcCustom) #create custom wave using rgdsamples data
self.dwf.FDwfAnalogOutNodeDataSet(hdwf, c_int(1), AnalogOutNodeCarrier, rgdSamples, c_int(10000)) #custom data = rgdsamples
self.dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(5)) #5V amplitude on both channels
self.dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(1/totald)) #1 cycle = total xray+delay duration
Question
spri
I am trying to create two square wave signals on the AD2 Analog instrument. Both signals should start at 5v, one should drop to 0v at the trigger, and the other should go to 0v after a certain delay time after the trigger (delay time = self.d/1000). Both signals should return to 5v at the same time (end of RunSet). I think I have to do this using the 'funcCustom' output, at least for the delayed signal. However, I am not able to get the funcCustom signal to give me the desired output. It just outputs 5v constantly after the trigger signal. (The funcSquare signal does what is expected).
Is there an easier way to create this delay between two analog channels without using funcCustom? Or is there something wrong in my syntax for getting the funcCustom signal to work?
Thank you!
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.