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.
Question
DurandA
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.
Edited by DurandALink to comment
Share on other sites
8 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