• 0
Sign in to follow this  
spri

Multi-Channel AnalogIn

Question

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? 

image.png.8d41fd6e90aafe351c2cb7e923d91b3a.png

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()

 

image.png

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @spri

It looks like you have connected the AWG1 to Scope 1 positive input and AWG2 to Scope 1 negative input. That's why you are seeing the addition of the two signals.

The Scope 2 positive input is the blue wire and connect the negative inputs to ground (orange/white and blue/white).

Share this post


Link to post
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
Sign in to follow this