• 0
Sign in to follow this  
Weevil

Analog Discovery 2, gap between aquisition

Question

Hello,

i am working on a real time application with the Analog Discovery 2 in Python. 

So i am doing a continiously aquisition with a while loop controled with a state machine. Now i see between the loops there is a gap (when the loop ends and start again).

Is there a possibility to improve the aquisition for don't losing this datas?

 

libdwf.FDwfAnalogInAcquisitionModeSet(hdwf, c_int(2)) #acqmodeScanShift1 #scan screen2  

while True:

            #Buffersize = 8192
            libdwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
        
            libdwf.FDwfAnalogInStatusSamplesValid(hdwf, byref(cValid))
                    
            libdwf.FDwfAnalogInStatusData(hdwf, c_int(0), byref(rgc), len(rgc))
            results1=[0.0]*len(rgc)
            for i in range(0,len(results1)):
                results1=rgc
                 
            libdwf.FDwfAnalogInStatusData(hdwf, c_int(1), byref(rgc), len(rgc))
            results2=[0.0]*len(rgc)
            for i in range(0,len(results2)):
                results2=rgc
            

 

 

Edited by Weevil

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 1

Hello,

Depending on your needs you can capture in each iternation the last N samples with shift screen (see the AnalogIn_ShiftScreen.py example) or gather many (unlimited with FDwfAnalogInRecordLengthSet 0) samples with record, getting in each iteration the newly acquired samples (see the AnalogIn_Record.py example).

 

Share this post


Link to post
Share on other sites
  • 0

Thank you very much for the good advise. I did further tests and now i would have one more question.

I see the ShiftScreen is similar to a ring buffer. So as example if i use a buffer size of 8192 and in my loop time there are only 4000 samples generated, i would have 4192 samples from the iteration before in my buffer. Is there a possibility to only get the new aquired samples? ...Or letting the Buffer run full with new aquired samples?

 

 

Edited by Weevil

Share this post


Link to post
Share on other sites
  • 0

With shift screen you get in each iteration up to buffer size of samples, regardless of previous iteration timing you get the last acquired samples.
See the  AnalogIn_ShiftScreen.py example which sets the buffer size to 1000.

With record mode you can collect infinite number of samples, in each iteration you only get the newly acquired ones since the previous iteration.
See the AnalogIn_Record.py example.

Share this post


Link to post
Share on other sites
  • 0

I didn't test your code but from my experience with high speed python variable declaration is critical:

results1=[0.0]*len(rgc)

^-- this could happen before the loop --> then within the iteration you would not need to wait for the declaration.

 

Did this solve your problem?

Or did I misunderstand you question?

Share this post


Link to post
Share on other sites
  • 0

Thank you!

I made several tests and get the highest speed with the following code in my loop. I also reduced the sample rate to reduce the gap. Actual its enough for my application and my problems are solved. If there are any other ideas to speed up the aquisition i would appreciate it.

.....

dwf.FDwfAnalogInAcquisitionModeSet(hdwf, c_int(1)) #acqmodeScanShift1

while True:
     
            dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
        
            dwf.FDwfAnalogInStatusSamplesValid(hdwf, byref(cValid))
        
            dwf.FDwfAnalogInStatusData(hdwf, c_int(0), byref(rgdSamples1), cValid)
          
            dwf.FDwfAnalogInStatusData(hdwf, c_int(1), byref(rgdSamples2), cValid)
          
          
        

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