I am sending synchronized, phase-shifted pulses with the AWG on both AnalogOut channels on the Discovery2, using a custom application I'm writing in python. I am feeding the AnalogOut directly back to the AnalogIn with no additional hardware involved. I am trying to read the two AWG signals using the AnalogIn channels, but I can't get Channel 2 to report the signal. Instead, both signals are adding together and displaying as coming from channel 1, with the expected channel 2 signal showing up as negative voltages on channel 1. How do I separate the two signals?
This is the chunk of code I am using to record samples and plot (mostly copied from the provided code samples):
#configure analog in
self.dwf.FDwfAnalogInFrequencySet(hdwf, c_double(int(hzSys.value/(100*self.xRate))))
self.dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(4000))
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))
#collect data
sts = c_int()
while True:
self.dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
if sts.value == DwfStateDone.value :
break
time.sleep(0.1)
#read data
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
self.dwf.FDwfAnalogInStatusData(hdwf, c_int(0), rg1, len(rg1)) # get channel 1 data
self.dwf.FDwfAnalogInStatusData(hdwf, c_int(1), rg2, len(rg2)) # get channel 2 data
#set up plot
self.canvasX.figure.clear()
plt1 = self.canvasX.figure.add_subplot(211)
plt2 = self.canvasX.figure.add_subplot(212)
#plot data
rgpy1=[0.0]*len(rg1)
rgpy2=[0.0]*len(rg2)
for i in range(0,len(rgpy1)):
rgpy1=rg1
rgpy2=rg2
plt1.plot(rgpy1, 'b')
plt2.plot(rgpy2, 'r')
self.canvasX.draw()
Question
spri
I am sending synchronized, phase-shifted pulses with the AWG on both AnalogOut channels on the Discovery2, using a custom application I'm writing in python. I am feeding the AnalogOut directly back to the AnalogIn with no additional hardware involved. I am trying to read the two AWG signals using the AnalogIn channels, but I can't get Channel 2 to report the signal. Instead, both signals are adding together and displaying as coming from channel 1, with the expected channel 2 signal showing up as negative voltages on channel 1. How do I separate the two signals?
This is the chunk of code I am using to record samples and plot (mostly copied from the provided code samples):
#configure analog in
self.dwf.FDwfAnalogInFrequencySet(hdwf, c_double(int(hzSys.value/(100*self.xRate))))
self.dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(4000))
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))
#begin acquisition
self.dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(1))
#collect data
sts = c_int()
while True:
self.dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
if sts.value == DwfStateDone.value :
break
time.sleep(0.1)
#read data
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
self.dwf.FDwfAnalogInStatusData(hdwf, c_int(0), rg1, len(rg1)) # get channel 1 data
self.dwf.FDwfAnalogInStatusData(hdwf, c_int(1), rg2, len(rg2)) # get channel 2 data
#set up plot
self.canvasX.figure.clear()
plt1 = self.canvasX.figure.add_subplot(211)
plt2 = self.canvasX.figure.add_subplot(212)
#plot data
rgpy1=[0.0]*len(rg1)
rgpy2=[0.0]*len(rg2)
for i in range(0,len(rgpy1)):
rgpy1=rg1
rgpy2=rg2
plt1.plot(rgpy1, 'b')
plt2.plot(rgpy2, 'r')
self.canvasX.draw()
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.