DurandA
-
Posts
8 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Posts posted by DurandA
-
-
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.
-
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.
FDwfDeviceOpen disables power supply on Analog Discovery 2
in Test and Measurement
Posted
Thank you for your help, this solved the issue.
I was running WaveForms 2.21.3 but was missing the Adept Linux runtime. I am surprised that it even worked without the package. Device discovery is also much faster now.
Thanks @attila!