• 0

ScanShift or ScanScreen simultaneously for analog and digital inputs


Because the ScanScreen and ShiftScreen acquisition modes ignore triggers, how do I know precisely when they start the first acquisition?  Is it possible to start the analog and digital scan-acquisitions simultaneously to ensure that both data streams are reading/displaying with a common time axis?  Or do I misunderstand how these types of acquisition work?

My previous approach was to generate a slow pulse and use the rising edge as a trigger to simultaneously start single acquisitions on both analog and digital scopes, then plot and repeat on the next pulse. But this is tedious, I can't get it to play nice with threading, and it means I only get snapshots of my data instead of seeing the whole stream. 


Share this post

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Thanks. I have tried this and things look better (the pulses are occuring around the same time), but I am still having a hard time getting it to work perfectly (they aren't totally synchronized). Over the course of a single 20-second acquisition, the relative position of my data samples seems to shift around some -- see the two snips about 5sec apart during the same trial. The blue pulse should by synchronized with the rising edge of the black pulse. I have verified with an external oscilliscope that the pulses are occurring simultaneously, so it must be the synchronization of the acquisition/plotting which is failing. Is this a problem with how I am configuring the scopes, or is it an artifact of how I am reading from the buffers and updating the plot? Either way, thoughts on how to fix it?




            #configure digital in               
            cSamples = 200 # set number of sample to acquire
            rgwSamples = (c_uint16*cSamples)()
            rg1 = (c_double*cSamples)()   #rg = pointer to allocated buffer to copy the acquisition data
            rg2 = (c_double*cSamples)()   #rg = pointer to allocated buffer to copy the acquisition data

            sts = c_int()

            self.dwf.FDwfDigitalInAcquisitionModeSet(hdwf, c_int(1))
            self.dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcAnalogIn)
            self.dwf.FDwfDigitalInDividerSet(hdwf, c_int(int(hzSys.value/(100*self.xRate)))) #sample rate at same freq as X-Ray
            self.dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16))            # 16bit per sample format
            self.dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
            self.dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_int(cSamples/2)) # trigger position in middle of buffer
            #configure analog in 
            self.dwf.FDwfAnalogInAcquisitionModeSet(hdwf, c_int(1))
            self.dwf.FDwfAnalogInFrequencySet(hdwf, c_double(int(hzSys.value/(100*self.xRate))))
            self.dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(cSamples)) 
            self.dwf.FDwfAnalogInTriggerPositionSet(hdwf, c_double(0)) # trigger position in middle of buffer           
            self.dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(-1), c_bool(True))
            self.dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(-1), c_double(5))
            # begin acquisition on both analog and digital
            self.dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
            self.dwf.FDwfAnalogInConfigure(hdwf, c_int(0), c_int(1))  

            while True:
                self.dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))            
                self.dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
                if sts.value == DwfStateDone.value :               
                #read data            
                self.dwf.FDwfAnalogInStatusData(hdwf, c_int(0), rg1, len(rg1)) # get Analog channel 1 data from buffer
                self.dwf.FDwfAnalogInStatusData(hdwf, c_int(1), rg2, len(rg2)) # get Analog channel 2 data from buffer  
                self.dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, 2*cSamples) # get Digital data
                #set up plots
                myplt = self.canvasQ.figure.add_subplot(111)
                for i in range(0,len(rgpy)):
                    rgpy= 1 & rgwSamples                       
                for i in range(0,len(rgpy1)):
                myplt.plot(rgpy, 'k')   
                myplt.plot(rgpy1, 'r')
                myplt.plot(rgpy2, 'b') 

Share this post

Link to post
Share on other sites
  • 0

Hi @spri

Some observation regarding the code:
- scan shift acquisition mode is selected which does not use trigger
- FDwfAnalogInFrequencySet expects frequency (Hz) not base clock divider value as FDwfDigitalInDividerSet

Share this post

Link to post
Share on other sites
  • 0
On 12/21/2017 at 12:28 PM, attila said:

Hi @spri

For synchronous analog/digital acquisition set DigitalInTriggerSource to AnalogIn, start DigitalIn then start AnalogIn.
This will ensure the digital and analog start at the same time even for scan acquisitions, +/-1 sample delay due to different signal paths.


Sorry for my confusion, but I think I'm hearing two different things from you on synchronizing the start of the scan acquisition. Trigger or no trigger?

Share this post

Link to post
Share on other sites
  • 0

Hi @spri

Sorry for the confusion created. The scan screen and shift modes ignore the trigger.
You could use record mode with trigger, which returns only the new samples since the previous status call and you keep/display only the last N samples. Specifying zero for FDwfAnalogInRecordLengthSet it will run indefinitely.

ACQMODE Constants

FUNC Constant Capabilities


Perform a single buffer acquisition. This is the default setting.


Perform a continuous acquisition in FIFO style. The trigger setting is ignored. The last sample is at the end of buffer. The FDwfAnalogInStatusSamplesValid function is used to show the number of the acquired samples, which will grow until reaching the BufferSize. Then the waveform “picture” is shifted for every new sample.


Perform continuous acquisition circularly writing samples into the buffer. The trigger setting is ignored. The IndexWrite shows the buffer write position. This is similar to a heart monitor display.


Perform acquisition for length of time set by FDwfAnalogInRecordLengthSet.

Share this post

Link to post
Share on other sites
  • 0

I have a similar problem with the synchronization of AnalogIN and DigitalIN. I use AcqmodeRecord. I did everything as in the second message, but the signals are not synchronous. Is there a solution to this issue? Thank

ad2ww worked!.vi

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