I am a bit confused, in the following example i am using continiously the record mode and programmed a time.sleep(0.1) in my aquisition loop. So i would expect the new aquired samples should be the whole buffer size (nsamples = 15000) because there should be 50000000 new samples/s. But actual it is variating between ~150 -~ 8000 per loop. What i am doing wrong?
Question
Weevil
I am a bit confused, in the following example i am using continiously the record mode and programmed a time.sleep(0.1) in my aquisition loop. So i would expect the new aquired samples should be the whole buffer size (nsamples = 15000) because there should be 50000000 new samples/s. But actual it is variating between ~150 -~ 8000 per loop. What i am doing wrong?
#set samplerate
libdwf.FDwfAnalogInFrequencySet(hdwf, c_double(50000000))
#set up acquisition
libdwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True))
libdwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5))
libdwf.FDwfAnalogInAcquisitionModeSet(hdwf, c_int(3)) #record
libdwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(0))
#wait at least 2 seconds for the offset to stabilize
time.sleep(2)
#begin acquisition
libdwf.FDwfAnalogInConfigure(hdwf, c_int(0), c_int(1))
cSamples = 0
nSamples = 15000
for i in range(100):
rgdSamples1 = (c_double*nSamples)()
rgdSamples2 = (c_double*nSamples)()
libdwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
if cSamples == 0 and (sts == DwfStateConfig or sts == DwfStatePrefill or sts == DwfStateArmed) :
# Acquisition not yet started.
continue
libdwf.FDwfAnalogInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted))
cSamples += cLost.value
if cLost.value :
fLost = 1
if cCorrupted.value :
fCorrupted = 1
if cAvailable.value==0 :
continue
if cSamples+cAvailable.value > nSamples :
cAvailable = c_int(nSamples-cSamples)
# get samples1
libdwf.FDwfAnalogInStatusData(hdwf, c_int(0), byref(rgdSamples1, 8*cSamples), cAvailable)
results = np.array(rgdSamples1)
XX = results[np.nonzero(results)]
print(len(XX))
time.sleep(0.1)
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.