I'm currently trying to synchronize analog pulses on both AWGs with digital pulses, and simultaneously run both analog scopes and the digital scope. I am trying to trigger all outputs and all scope acquisitions to happen simultaneously with a single PC-Trigger source using the SDK.
First question: Why isn't there an AnalogInTriggerSlopeSet function? (You can set the TriggerSlope to rising edge for AnalogOut, DigitalOut, and DigitalIn). Without an AnalogInTriggerSlopeSet function, how do you set the AnalogInTrigger to respond to the same signal as the other three?
Second Question: What prompts the change in Analog/DigitalInStatus from 'prefill' to 'armed' or 'done'? In the Acquisition code in the SDK, it looks like the status changes when the buffer fills? In my code below, why isn't it progressing to 2=Done to break out of the loop? It looks like it is getting stuck waiting for the trigger (which already happened).
#digital pulse control setup
self.dwf.FDwfDigitalOutEnableSet(hdwf, c_int(0), c_int(1)) # enable dIO pin 0
self.dwf.FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(int(hzSys.value/(100*self.qRate)))) # divider=internal clock/ (100counts*frequency)
self.dwf.FDwfDigitalOutCounterSet(hdwf, c_int(0), c_int(100-self.qDuty), c_int(self.qDuty)) # set counts low, counts high from duty cycle
print "configured digital output"
# analog pulse control setup
self.dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(True))
self.dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_int(True))
# for second channel set master the first channel, slave channel is controlled by the master
self.dwf.FDwfAnalogOutMasterSet(hdwf, c_int(1), c_int(0));
self.dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(-1), AnalogOutNodeCarrier, funcSquare)
self.dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(self.xRate))
self.dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(0.5))
self.dwf.FDwfAnalogOutOffsetSet(hdwf, c_int(-1), c_double(0.5))
self.dwf.FDwfAnalogOutNodeSymmetrySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(symm)) #pulse width
self.dwf.FDwfAnalogOutNodePhaseSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_double(self.x2Phase)) #phase shift for second channel
self.dwf.FDwfAnalogOutRunSet(hdwf, c_int(-1), c_double(self.xDuration)) #set run duration on all channels
self.dwf.FDwfAnalogOutIdleSet(hdwf,c_int(-1), c_int(0))
print "configured analog output"
#configure digital input scope
self.dwf.FDwfDigitalInDividerSet(hdwf, c_int(int(hzSys.value/(100*self.xRate)))) #same sample rate as xray
self.dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16)) # 16bit per sample format
cSamples = 1000 # set number of sample to acquire
rgwSamples = (c_uint16*cSamples)()
self.dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
print "configured digital input"
#configure analog input scope
self.dwf.FDwfAnalogInFrequencySet(hdwf, c_double(int(hzSys.value/(100*self.xRate))))
self.dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(1000))
rg1 = (c_double*1000)() #rg = pointer to allocated buffer to copy the acquisition data
rg2 = (c_double*1000)() #rg = pointer to allocated buffer to copy the acquisition data
print "configured analog input"
#set up PC trigger to start pulse output AND acquisition
self.dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), trigsrcPC)
self.dwf.FDwfDigitalOutTriggerSourceSet(hdwf, trigsrcPC)
self.dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(0), c_int(0)) # set channel 1 to trigger on rising edge
self.dwf.FDwfDigitalOutTriggerSlopeSet(hdwf, c_int(0))
Question
spri
I'm currently trying to synchronize analog pulses on both AWGs with digital pulses, and simultaneously run both analog scopes and the digital scope. I am trying to trigger all outputs and all scope acquisitions to happen simultaneously with a single PC-Trigger source using the SDK.
First question: Why isn't there an AnalogInTriggerSlopeSet function? (You can set the TriggerSlope to rising edge for AnalogOut, DigitalOut, and DigitalIn). Without an AnalogInTriggerSlopeSet function, how do you set the AnalogInTrigger to respond to the same signal as the other three?
Second Question: What prompts the change in Analog/DigitalInStatus from 'prefill' to 'armed' or 'done'? In the Acquisition code in the SDK, it looks like the status changes when the buffer fills? In my code below, why isn't it progressing to 2=Done to break out of the loop? It looks like it is getting stuck waiting for the trigger (which already happened).
#digital pulse control setup
self.dwf.FDwfDigitalOutEnableSet(hdwf, c_int(0), c_int(1)) # enable dIO pin 0
self.dwf.FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(int(hzSys.value/(100*self.qRate)))) # divider=internal clock/ (100counts*frequency)
self.dwf.FDwfDigitalOutCounterSet(hdwf, c_int(0), c_int(100-self.qDuty), c_int(self.qDuty)) # set counts low, counts high from duty cycle
print "configured digital output"
# analog pulse control setup
self.dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(True))
self.dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_int(True))
# for second channel set master the first channel, slave channel is controlled by the master
self.dwf.FDwfAnalogOutMasterSet(hdwf, c_int(1), c_int(0));
self.dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(-1), AnalogOutNodeCarrier, funcSquare)
self.dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(self.xRate))
self.dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(0.5))
self.dwf.FDwfAnalogOutOffsetSet(hdwf, c_int(-1), c_double(0.5))
self.dwf.FDwfAnalogOutNodeSymmetrySet(hdwf, c_int(-1), AnalogOutNodeCarrier, c_double(symm)) #pulse width
self.dwf.FDwfAnalogOutNodePhaseSet(hdwf, c_int(1), AnalogOutNodeCarrier, c_double(self.x2Phase)) #phase shift for second channel
self.dwf.FDwfAnalogOutRunSet(hdwf, c_int(-1), c_double(self.xDuration)) #set run duration on all channels
self.dwf.FDwfAnalogOutIdleSet(hdwf,c_int(-1), c_int(0))
print "configured analog output"
#configure digital input scope
self.dwf.FDwfDigitalInDividerSet(hdwf, c_int(int(hzSys.value/(100*self.xRate)))) #same sample rate as xray
self.dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16)) # 16bit per sample format
cSamples = 1000 # set number of sample to acquire
rgwSamples = (c_uint16*cSamples)()
self.dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
print "configured digital input"
#configure analog input scope
self.dwf.FDwfAnalogInFrequencySet(hdwf, c_double(int(hzSys.value/(100*self.xRate))))
self.dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(1000))
self.dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True))
self.dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5))
self.dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(1), c_bool(True))
self.dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(1), c_double(5))
rg1 = (c_double*1000)() #rg = pointer to allocated buffer to copy the acquisition data
rg2 = (c_double*1000)() #rg = pointer to allocated buffer to copy the acquisition data
print "configured analog input"
#set up PC trigger to start pulse output AND acquisition
self.dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), trigsrcPC)
self.dwf.FDwfDigitalOutTriggerSourceSet(hdwf, trigsrcPC)
self.dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(0), c_int(0)) # set channel 1 to trigger on rising edge
self.dwf.FDwfDigitalOutTriggerSlopeSet(hdwf, c_int(0))
self.dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcPC)
self.dwf.FDwfDigitalInTriggerSlopeSet(hdwf, c_int(0)) #rising edge
self.dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcPC)
# self.dwf.FDwfAnalogInTriggerSlopeSet(hdwf,) #this command doesn't exist for analogin!
print "set up triggers"
#configure everything to wait for trigger
self.dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True)) # start master, slave will follow
self.dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
self.dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
self.dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(1)) # starts both analog in pins (hdwf, bool-reconfigure, bool-start)
print "initialized pins"
#send the trigger
self.dwf.FDwfDeviceTriggerPC(hdwf)
print "PC trigger pulse sent"
#plot the things
sts = c_int()
while True: #data acquisition status should == 5 - filling buffer
self.dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
sts1 = sts.value
self.dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
print ("analog status = " + str(sts.value))
print ("digital status = " +str(sts1))
if sts.value == DwfStateDone.value : #status ==2 = done
print "acquisition complete"
break
When I run this, this is my printout:
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.