Jump to content
Fourth of July -- Digilent US offices closed ×

attila

Technical Forum Moderator
  • Posts

    6,662
  • Joined

  • Last visited

Posts posted by attila

  1. Hi @longboard

    It is possible with Protocol/I2C/Spy and make sure to increase the "Max Lines" for long capture. For performance reasons this is by default limited.

    image.png.435581a8730b7af2230298c1cbcd22ec.png

     

    However such troubleshooting could result in a very long log which may be hard to parse.

    I would rather recommend using the Logic Analyzer and triggering on the event or on the outcome.
    Depending on the problem with I2C trigger (like on a value, NAK...), or using external trigger or other DIO line, or pulse width...
    Then look for the pretrigger data to see what lead to or caused the issue.

  2. Hi @Resul

    The Wavegen can output -5V to +5V. There is some reserve like +/-0.4V but this is not guaranteed to work on each device or with proper linearity.

    You may do +/-10V using +/-5V rails as reference instead of ground.
    - with -5V doing sweep from -5V to +5V which will be relative 0 to +10V
    - with +5V sweep from +5V to -5V will be like 0 to -10V
    Note that you could do this with minimal amplitude like 0.1V (or 0.2V) to limit the Wavegen amplitude to +/-5.1V
    or use +/-4V reference with 1V amplitude signal for +/-8V range.
    see point 3 :

     

  3. Hi @SaschaA

    For Analog Discovery the 3rd device configuration allocates 16k samples for carrier signal the AM/FM buffers are 2k 9bit
    You could use the custom FM to generate sweep but the 2k9b limits the resolution.

    image.png.ac683e0640ed026ab1a0e3087d1781a8.png

    You could use the Play mode for unlimited streaming at up to about 1MSps. You could also stream AM/FM samples which probably highly reduces the required update rate.
    See WF SDK/ samples/ py/ AnalogOut_Play.py AnalogOutIn_PlayRecord.py ...

    image.png.a053475f0a588c6800cd2d074a3673f4.png

    image.png.312a3cfaf78151175fbc4d0971ca3c64.png

  4. Hi @Resul

    I got a glitch due to setting the scope offset wrongly with opposite sign and the input entered in limitation. I will have to add some function or measurement to notify such.
    I also notice there is bug in calculating the scope sample rate to obtain the certain amount of periods.

    image.png.d75c1d2a231c52326f09be90eba577cc.png

    image.png.593405fbe2b82bab9057a83ed7021d40.png

     

    """
       DWF Python Example
       Author:  Digilent, Inc.
       Revision:  2021-08-24
    
       Requires:                       
           Python 2.7, 3
    """
    
    from ctypes import *
    from dwfconstants import *
    import math
    import time
    import sys
    import numpy
    import matplotlib.pyplot as plt
    
    if sys.platform.startswith("win"):
        dwf = cdll.LoadLibrary("dwf.dll")
    elif sys.platform.startswith("darwin"):
        dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
    else:
        dwf = cdll.LoadLibrary("libdwf.so")
    
    version = create_string_buffer(16)
    dwf.FDwfGetVersion(version)
    print("DWF Version: "+str(version.value))
    
    hdwf = c_int()
    szerr = create_string_buffer(512)
    print("Opening first device")
    dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
    
    if hdwf.value == hdwfNone.value:
        dwf.FDwfGetLastErrorMsg(szerr)
        print(str(szerr.value))
        print("failed to open device")
        quit()
    
    dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) 
    
    sts = c_byte()
    reference = 1e3
    freq = 1e3
    start = -4.0
    stop = 4.0
    steps = 101
    
    print("Reference: "+str(reference)+" Ohm  Frequency: "+str(freq)+" Hz Offset: "+str(start)+" V ... "+str(stop)+" V")
    
    dwf.FDwfAnalogImpedanceReset(hdwf)
    dwf.FDwfAnalogImpedanceModeSet(hdwf, c_int(8)) # 0 = W1-C1-DUT-C2-R-GND, 1 = W1-C1-R-C2-DUT-GND, 8 = AD IA adapter
    dwf.FDwfAnalogImpedanceReferenceSet(hdwf, c_double(reference)) # reference resistor value in Ohms
    dwf.FDwfAnalogImpedanceFrequencySet(hdwf, c_double(freq)) # frequency in Hertz
    dwf.FDwfAnalogImpedanceAmplitudeSet(hdwf, c_double(0.5)) # 0.5V amplitude = 1V peak2peak signal
    dwf.FDwfAnalogImpedanceOffsetSet(hdwf, c_double(start)) 
    dwf.FDwfAnalogImpedanceConfigure(hdwf, c_int(1)) # start 
    
    dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(0), c_double(start)) # set Scope C1 offset to start
    dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(1), c_double(0)) # set Scope C2 offset to 0V
    
    dwf.FDwfAnalogInFrequencySet(hdwf, c_double(freq*8192/16)) # override, periods are wrongly calculated in < v3.16.35
    
    dwf.FDwfAnalogInConfigure(hdwf, c_int(0)) # re-configure Scope
    
    time.sleep(1) # wait for the device, specially for the offsets to stabilize
    
    rgOff = [0.0]*steps
    rgRs = [0.0]*steps
    rgXs = [0.0]*steps
    
    for i in range(steps):
        vOff = start + i*(stop-start)/steps
        rgOff[i] = vOff
        dwf.FDwfAnalogOutOffsetSet(hdwf, c_int(0), c_double(vOff)) # adjust Wavegen 1 offset
        dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_int(1)) # configure and start Wavegen 1
        dwf.FDwfAnalogInChannelOffsetSet(hdwf, c_int(0), c_double(vOff)) # adjust Scope C1 offset
        dwf.FDwfAnalogInConfigure(hdwf, c_int(1)) # configure Scope
        
        time.sleep(0.01) # settle time depends on the circuit/DUT
        
        dwf.FDwfAnalogInConfigure(hdwf, c_int(1)) # start Scope
        while True:
            if dwf.FDwfAnalogImpedanceStatus(hdwf, byref(sts)) == 0:
                dwf.FDwfGetLastErrorMsg(szerr)
                print(str(szerr.value))
                quit()
            if sts.value == 2:
                break
                
        resistance = c_double()
        reactance = c_double()
        dwf.FDwfAnalogImpedanceStatusMeasure(hdwf, DwfAnalogImpedanceResistance, byref(resistance))
        dwf.FDwfAnalogImpedanceStatusMeasure(hdwf, DwfAnalogImpedanceReactance, byref(reactance))
        rgRs[i] = abs(resistance.value) # absolute value for logarithmic plot
        rgXs[i] = abs(reactance.value)
        
    
    dwf.FDwfAnalogImpedanceConfigure(hdwf, c_int(0)) # stop
    dwf.FDwfDeviceClose(hdwf)
    
    plt.plot(rgOff, rgRs, rgOff, rgXs)
    ax = plt.gca()
    ax.set_yscale('log')
    plt.show()
    

     

×
×
  • Create New...