I have been using the AD2 for years with Raspberry Pi 4's. The included code snippet has been used frequently in those devices without issue. I have some running now for a few years.
I have now migrated to AD3 and Raspberry Pi 5's. When I run the same exact code, I will eventually see the Digital output cease. Sometimes it is almost immediate, sometimes it may take up to 30 minutes. But it always stops seemingly on its own -- eventually. Is there something that has changed in the AD3 or something in my code that would cause such an issue? The code, AD3, and RPi 5 are used in a radar.
There are some caveats here:
The DigitalOut code should continue to run unless stopped by me or if the device loses power. That is the intent at least.
The DigitalOut is passed to an RF switch, which then generates transmitted RF pulses. The transmitted pulses are sufficiently large to wrap back into the receiver antenna and trigger the A/D channels to acquire the received data. So running both channels of the A/D at the same time as the DigitalOut is firing. Those pulses are around 100 to 500 ns and they are generated at a rate of 10k to 40k per second.
I also control a high power amp, which requires a negative voltage to set the peak output power of the amp. I use one the Analog Out channels for this.
I have external power connected to the AD3 and can confirm through the use of a voltage analyzer that I have rock solid voltage with more than sufficient current.
I have been using successfully the AtoD channels with threading, which allowed me to process the previously captured data at the same time I am capturing new data. I thought that might be an issue, so disabled the threading and am processing serially. But that didn't help. So there is about a tenth of second of processing time between groups of captures.
A/D capture will cease when DigitalOut stops, so that's how I know something has happened.
I have tried this on 4 separate AD3's and RPi5's and have the same result. I have made a temporary fix that resets the AD3 when this happens, but I lose seconds of data during that time.
Does anyone know what might be happening here?
CODE:
#Access OS to determine whether Windows or Linux
if sys.platform.startswith("win"):
dwf = cdll.dwf
print("dwf=win")
elif sys.platform.startswith("darwin"):
dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
print("dwf=darwin")
else:
dwf = cdll.LoadLibrary("libdwf.so")
print("dwf=other")
if hdwf.value == hdwfNone.value:
szerr = create_string_buffer(512)
dwf.FDwfGetLastErrorMsg(szerr)
print(szerr.value)
print("failed to open device")
quit()
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) # 0 = the device will only be
#Digital Channel 0 is used to trigger the SPST RF Switch
PRF = 20000 #Pulse Repetition frequency (pulses per second)
PW = 400e-9 #Pulse in nanoseconds
Delay = 0
PWvalue=int(PW/1e-9) #Convert PW number into an interger # of nanoseconds
hzFreq = PRF
cSamples = 12000
version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))
# #Start Pulsing for the safety of the amplifier
iChannel = 0
# for low frequencies use divider as pre-scaler to satisfy counter limitation of 32k
cDiv = int(math.ceil(hzSys.value/hzFreq/maxDiv.value))
# count steps to generate the give frequency
cPulse = (1/PRF)/10e-9 # Example: 12500 => 1/125000ns = 8000 Hz PRF. So 8000 = 12.5kHz PRF, 25000 = 4 kHz PRF
# Generating Pulse train with cHigh representing the pulsewidth and cLow representing the time between pulses.
cHigh= int(PWvalue/10)#----------- this sets pulsewidth to increments of 10 ns. So 20 = 200 ns.
cLow = int(cPulse-cHigh)
if cLow + cHigh > 32768: #--------- to handle low frequencies. Max number is 32768 on FDWfDigitalOutCounterSet.
cLow= int(32768-cHigh)
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(iChannel), c_int(1))
dwf.FDwfDigitalOutTypeSet(hdwf, c_int(iChannel), c_int(0)) # DwfDigitalOutTypePulse
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(iChannel), c_int(cDiv)) # max 2147483649, for counter limitation or custom sample rate
dwf.FDwfDigitalOutCounterInitSet(hdwf,c_int(iChannel), c_int(0), c_int(Delay))
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(iChannel), c_int(cLow), c_int(cHigh)) # max 32768
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
Question
eradarhughes
I have been using the AD2 for years with Raspberry Pi 4's. The included code snippet has been used frequently in those devices without issue. I have some running now for a few years.
I have now migrated to AD3 and Raspberry Pi 5's. When I run the same exact code, I will eventually see the Digital output cease. Sometimes it is almost immediate, sometimes it may take up to 30 minutes. But it always stops seemingly on its own -- eventually. Is there something that has changed in the AD3 or something in my code that would cause such an issue? The code, AD3, and RPi 5 are used in a radar.
There are some caveats here:
I have tried this on 4 separate AD3's and RPi5's and have the same result. I have made a temporary fix that resets the AD3 when this happens, but I lose seconds of data during that time.
Does anyone know what might be happening here?
CODE:
#Access OS to determine whether Windows or Linux
if sys.platform.startswith("win"):
dwf = cdll.dwf
print("dwf=win")
elif sys.platform.startswith("darwin"):
dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
print("dwf=darwin")
else:
dwf = cdll.LoadLibrary("libdwf.so")
print("dwf=other")
hdwf = c_int()
# #open device
print("Opening first device...")
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
if hdwf.value == hdwfNone.value:
szerr = create_string_buffer(512)
dwf.FDwfGetLastErrorMsg(szerr)
print(szerr.value)
print("failed to open device")
quit()
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) # 0 = the device will only be
#Digital Channel 0 is used to trigger the SPST RF Switch
PRF = 20000 #Pulse Repetition frequency (pulses per second)
PW = 400e-9 #Pulse in nanoseconds
Delay = 0
PWvalue=int(PW/1e-9) #Convert PW number into an interger # of nanoseconds
hzFreq = PRF
cSamples = 12000
version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))
# #Start Pulsing for the safety of the amplifier
iChannel = 0
hzSys = c_double()
maxDiv = c_uint()
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))
dwf.FDwfDigitalOutCounterInfo(hdwf, c_int(0), 0, byref(maxDiv))
# for low frequencies use divider as pre-scaler to satisfy counter limitation of 32k
cDiv = int(math.ceil(hzSys.value/hzFreq/maxDiv.value))
# count steps to generate the give frequency
cPulse = (1/PRF)/10e-9 # Example: 12500 => 1/125000ns = 8000 Hz PRF. So 8000 = 12.5kHz PRF, 25000 = 4 kHz PRF
# Generating Pulse train with cHigh representing the pulsewidth and cLow representing the time between pulses.
cHigh= int(PWvalue/10)#----------- this sets pulsewidth to increments of 10 ns. So 20 = 200 ns.
cLow = int(cPulse-cHigh)
if cLow + cHigh > 32768: #--------- to handle low frequencies. Max number is 32768 on FDWfDigitalOutCounterSet.
cLow= int(32768-cHigh)
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(iChannel), c_int(1))
dwf.FDwfDigitalOutTypeSet(hdwf, c_int(iChannel), c_int(0)) # DwfDigitalOutTypePulse
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(iChannel), c_int(cDiv)) # max 2147483649, for counter limitation or custom sample rate
dwf.FDwfDigitalOutCounterInitSet(hdwf,c_int(iChannel), c_int(0), c_int(Delay))
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(iChannel), c_int(cLow), c_int(cHigh)) # max 32768
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now