Jump to content
  • 0

Is there any reason the digital output from the AD3 should stop on its own when using DigitalOut?


eradarhughes

Question

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

  • 0

Hi @eradarhughes

It could be a powering issue, the USB supply voltage drops and the device gets reset.
Try using powered hub or 5VDC auxiliary power for the AD3.

By the way, you can set a parameter to continue running on close, so the device will continue to generate the output after device close and app exit.
...
dwf.FDwfParamSet(DwfParamOnClose, 0) # 0 = rundwf.FDwfDeviceOpen
dwf.FDwfDeviceOpen... 
...
dwf.FDwfDigitalOutConfigure...
dwf.FDwfDeviceCloseAll()
exit

Link to comment
Share on other sites

  • 0
Posted (edited)
6 hours ago, attila said:

Hi @eradarhughes

It could be a powering issue, the USB supply voltage drops and the device gets reset.
Try using powered hub or 5VDC auxiliary power for the AD3.

By the way, you can set a parameter to continue running on close, so the device will continue to generate the output after device close and app exit.
...
dwf.FDwfParamSet(DwfParamOnClose, 0) # 0 = rundwf.FDwfDeviceOpen
dwf.FDwfDeviceOpen... 
...
dwf.FDwfDigitalOutConfigure...
dwf.FDwfDeviceCloseAll()
exit

I do have 5VDC on the auxilary power port of the AD3. But that may actually be the problem.   Here's what I mean.....   I've been checking voltage that on boot-up, and it is reading 5.0 volts exactly.   So then I started running the code, and the voltage dropped and held very steady at 4.94 VDC.  The pull is from other 5 V sources, which is why it drops.   So that could indeed be the issue.  I imagine 4.94V is close to the cuttoff on the device.     I have a separate supply on the Pi, so it's keeping 5.1 V input.   Since I'm not pulling hardly any current on the AD3 pins or outputs, I'm going to just run it with the USB port power.    I will post if that does the trick.   Thanks for suggesting this.

I did not know about the OnClose command.   Thanks!

 

UPDATE:  No, powering from the USB only made it worse.   So I bypassed one of my filtering steps on power and that kept input to the auxiliary port to 5.03V.    So far I have not seen any random shutdowns.   So that must have been the issue.   Thanks again.

 

Edited by eradarhughes
More information.
Link to comment
Share on other sites

  • 0
5 hours ago, attila said:

Hi @eradarhughes

The under/over cutoff voltages for both USB and AUX supply are 4.5/5.5V

image.png

Hmmm.  I did set the Raspberry Pi 5 to allow the max USB output, but I believe there is also a current setting that needs to be set in addition.  That could have caused things to be worse when plugged in with the USB.  But since boosting the voltage to the auxiliary port to 5V, it's been working fine.   I will keep an eye on it and report if the phantom stoppage returns.

Link to comment
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
×
×
  • Create New...