Jump to content

TickTock

Members
  • Posts

    2
  • Joined

  • Last visited

TickTock's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. I am debugging a Python test fixture using an AnalogDiscovery2. The DUT is outputting 8 bits at approximately 1kHz along with a clock (bin width of an ADC) and I am using the sync trigger mode to capture this data for processing. It appears to work most of the time but if I try to capture more than about 3000 samples, the acquisition freezes. Scope confirms I am still getting clocks out of the DUT but the cAvailable.value is returning 0. It is not indicating and lost or corrupt values. When this happens is somewhat variable and seems to get worse the longer the AD2 is powered on. Almost gets to all 4096 samples the first time I run it but freezes around 90%. from random import random from ctypes import * from dwfconstants import * import math import matplotlib.pyplot as plt from matplotlib.widgets import Button import sys import numpy if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") hdwf = c_int() sts = c_byte() channel = c_int(0) version = create_string_buffer(16) dwf.FDwfGetVersion(version) print("DWF Version: "+str(version.value)) print("Opening first device") dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) ##dwf.FDwfDeviceConfigOpen(c_int(-1), 0, byref(hdwf)) #if hdwf.value == 0: if hdwf.value == hdwfNone.value: print("failed to open device") szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) quit() ##dwf.FDwfDeviceReset(hdwf) ##dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))# 0 = the device will be configured only when calling FDwf###Configure print("Configuring Analog Out...") # enable positive supply dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True)) # set voltage to 5 V dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(5.0)) dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True)) # set up ramp dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel, AnalogOutNodeCarrier, c_bool(True)) dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel, AnalogOutNodeCarrier, funcTriangle) dwf.FDwfAnalogOutNodeFrequencySet(hdwf, channel, AnalogOutNodeCarrier, c_double(.05)) dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, channel, AnalogOutNodeCarrier, c_double(2.7)) dwf.FDwfAnalogOutNodeOffsetSet(hdwf, channel, AnalogOutNodeCarrier, c_double(2.5)) print("Generating wave...") dwf.FDwfAnalogOutConfigure(hdwf, channel, c_bool(True)) print("Configuring Digital In...") # record mode dwf.FDwfDigitalInAcquisitionModeSet(hdwf, acqmodeRecord) # for sync mode set divider to -1 dwf.FDwfDigitalInDividerSet(hdwf, c_int(-1)) # 8bit per sample format dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(8)) # number of samples dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_int(4096)) # in sync mode the trigger is used for sampling condition # trigger detector mask: low & hight & ( rising | falling ) dwf.FDwfDigitalInTriggerSet(hdwf, c_int(0), c_int(0), c_int(1<<6), c_int(0)) # CLK on DIO-6 rising edge class myButtons: nSamples = 4096 nStart = 0 def go(self, event): # begin acquisition rgwSamples = (c_uint8*4096)() for i in range(self.nSamples): rgwSamples[i]=0 cAvailable = c_int() cLost = c_int() cCorrupted = c_int() cSamples = 0 fLost = 0 fCorrupted = 0 maxBufferSize = 0 trycount = 0 go = 0 print("Searching for Start Signal") dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1)) while cSamples < (self.nStart+self.nSamples): #dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1)) dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts)) if cSamples == 0 and (sts == DwfStateConfig or sts == DwfStatePrefill or sts == DwfStateArmed) : # acquisition not yet started. continue dwf.FDwfDigitalInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted)) cSamples += cLost.value if cLost.value : fLost = 1 print("v",end='') if cCorrupted.value : fCorrupted = 1 print(",",end='') if cAvailable.value==0 : # no new values trycount += 1 if ((trycount%1000)==0) : print(".",end='') #When it hangs it keeps printing this line indicating no values continue else : trycount = 0 if cAvailable.value > 4096-cSamples : cAvailable = c_int(4096-cSamples) # get samples dwf.FDwfDigitalInStatusData(hdwf, byref(rgwSamples, cSamples), c_int(cAvailable.value)) #print("\navailable :",cAvailable.value," Total :",cSamples+cAvailable.value," Last :",go," ",end='') #Search for START if (rgwSamples[0] < 0x80) : go = 1 if go==1 : cSamples += cAvailable.value print("%2.1f%s complete" % (100*cSamples/(self.nStart+self.nSamples), '%')) if (rgwSamples[cSamples-1] < 0x80) and (cSamples > 64): break print("done") I am outputting the available samples and the current index (cSamples) so I know I am not overrunning a register space. I would appreciate any insights. Here is the last few lines of the debug output: It will keep printing the "." forever. available : 2 Total : 3516 Last : 1 85.8% complete available : 6 Total : 3522 Last : 1 86.0% complete available : 1 Total : 3523 Last : 1 86.0% complete ...................................................................................................................................
×
×
  • Create New...