Jump to content
  • 0

Analog Discovery 2, gap between aquisition


Weevil

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
            

 

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

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

 

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)
          
          
        

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...