Hi All,
I'd like to output a simple sine wave that is triggered by a rising edge on one of the inputs. I'm currently using the following python code to achieve this:
I use the AnalogInTrigger detection setup shown below
#set up trigger
cSamples = 1024
hzRate = 100e6
dwf.FDwfAnalogInTriggerAutoTimeoutSet(hdwf, c_double(0)) #disable auto trigger
dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcDetectorAnalogIn) #one of the analog in channels
dwf.FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge)
dwf.FDwfAnalogInTriggerChannelSet(hdwf, c_int(0)) # first channel
dwf.FDwfAnalogInTriggerLevelSet(hdwf, c_double(3.0)) # 0.0V
dwf.FDwfAnalogInTriggerConditionSet(hdwf, DwfTriggerSlopeRise)
# relative to middle of the buffer, with time base/2 T0 will be the first sample
dwf.FDwfAnalogInTriggerPositionSet(hdwf, c_double(0.5*cSamples/hzRate))
dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(0))
# wait at least 2 seconds with Analog Discovery for the offset to stabilize, before the first reading after device open or offset/range change
time.sleep(2)
dwf.FDwfAnalogInConfigure(hdwf, c_int(0), c_int(1))
Followed by a loop structure to check the trigger on every iteration of the loop
while True:
dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
if sts.value == 2 : # done
break
# Generating sine wave
dwf.FDwfAnalogOutConfigure(hdwf, channel, c_int(1))
time.sleep(0.5)
dwf.FDwfAnalogOutConfigure(hdwf, channel, c_int(0))
Unfortunately this yields a large delay (~2.5ms) between the rising edge of the input, and the start of the sine waveform. Furthermore, this delay has some jitter to it (i.e. it is not a consistent delay).
Is there a better way to do this that doesn't require polling from FDwfAnalogInStatus? It would be helpful to be able to do this with a minimal delay bias and variance.