DurandA

Members
  • Content Count

    8
  • Joined

  • Last visited

Posts posted by DurandA

  1. Hi @attila

    Unfortunately your solution does not work. The power supply still shuts down during the second FDwfDeviceOpen() for about 1 second. Here is a minimal script to reproduce the issue:

    from ctypes import *
    from dwfconstants import *
    
    dwf = cdll.LoadLibrary("libdwf.so")
    hdwf = c_int()
    
    dwf.FDwfParamSet(DwfParamOnClose, c_int(0))
    dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
    dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True))
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(1.15))
    dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True))
    dwf.FDwfAnalogIOConfigure(hdwf)
    dwf.FDwfDeviceClose(hdwf)
    # start over
    dwf.FDwfParamSet(DwfParamOnClose, c_int(0))
    dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) # power shut down during ~ 1 sec
    dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True))
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(1.15))
    dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True))
    dwf.FDwfAnalogIOConfigure(hdwf)
    dwf.FDwfDeviceClose(hdwf)

    Thank you for your help.

  2. I am trying to automate some tests using different supply voltages.

    First, I am using dwfcmd to set a voltage during the setup phase:

    dwfcmd connect analogio channel=1 enable=1 voltage=1.15 masterenable=1 disconnect

    Then I use a Python script to vary the voltage:

    from dwfconstants import *
    
    dwf = cdll.LoadLibrary("libdwf.so")
    hdwf = c_int()
    
    print("Opening first device")
    dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
    
    if hdwf.value == hdwfNone.value:
        print("failed to open device")
        quit()
    
    time.sleep(5)
    
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(True))
    dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(1.20))
    dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True))

    However, calling FDwfDeviceOpen() disables the power supply. In the example above, I inserted a 5 sec sleep, which means there is no power during more than 5 seconds.

    How can access the Analog Discovery 2 from Python without disabling the power supply?

    Edit: I tried to remove disconnect from dwfcmd args and reuse the hdwf handle which just seems to be the enumeration id (always 1 in my case). However, the last line of dwfcmd.cpp is FApi("FDwfDeviceCloseAll", FDwfDeviceCloseAll());. I tried recompiling dwfcmd without this line using "g++ -o dwfcmd_noclose -I/usr/include/digilent/waveforms/ dwfcmd.cpp -ldwf" but once compiled it fails:

    pure virtual method called
    terminate called without an active exception
    Aborted (core dumped)

    It seems that this error happens whenever FDwfDeviceClose is not called, including outside of dwfcmd.

  3. I want to record data on one channel using the scope tool from WaveForms using the Analog Discovery 2. Additionally, I need to record digital signals on 4 channels at the same time in order to delimit windows for post-processing.

    Even at a (very) low sampling rate, WaveForms displays "Samples were lost! Reduce sample rate." when I attach some digital channels to the scope tool. Even when the sampling rate is reduced to 1Hz, this error still happens. Is this a WaveForms bug? I put my workspace in attachment to reproduce the issue.

    waveforms-scope.png

    scope-digital.dwf3work

  4. Is it possible to use digital signals in addition to analog channels with the data logger (Logger) tool in WaveForms?

    I know this is possible with the Scope tool. However, I want to use digital signals generated from a MCU to delimit windows in long-running captures. Is it possible to access digital channels from a script using a function?