Jump to content

minghan chao

Members
  • Posts

    2
  • Joined

  • Last visited

minghan chao's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. The error is the following File "/usr/lib64/python3.7/ctypes/__init__.py", line 369, in __getattr__ func = self.__getitem__(name) File "/usr/lib64/python3.7/ctypes/__init__.py", line 374, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: /usr/lib/libdwf.so: undefined symbol: FDwfDigitalSpiSelectSet pure virtual method called terminate called without an active exception Aborted I tried to use SPI built in function for digital discovery. FDwfDigitalSpiSelectSet and other spi functions are what I try to use. My code works in Windows environment, but in Linux system, I got this error. Actually, I have some codes running (mostly IO stuff) on Linux system, but this code involving SPI built-in function is not working. The libdwf.so may have some problems. Could you please help me to solve this problem? Thanks. Best regards, Minghan Chao
  2. I am trying to generate digital sequence of outputs, with four channels (using Digital Discovery). I want them to be synchonized. My problem is I only want the pattern output to be finite sequence (not looping). I used the example DigitalOut_Custom.py to do the job. But the sequence always restart. Could you please tell me the right way to generate a finite sequence of 0 and 1s? Is using the custom output function the right way? Thanks. I have attached the code. Currently it uses only two channels. """ DWF Python Example Author: Digilent, Inc. Revision: 2019-09-02 Requires: Python 2.7, 3 Description: Generates a custom pattern """ from ctypes import * from WF_SDK.dwfconstants import * import sys import time if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") hdwf = c_int() version = create_string_buffer(16) dwf.FDwfGetVersion(version) print("DWF Version: "+str(version.value)) print("Opening first device") dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == 0: print("failed to open device") szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) quit() print("Configuring Digital Out") hzSys = c_double() dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys)) print(hzSys) hzRate = 10e3 data_py_clk=[0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0] data_py_din=[0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1] # how many bytes we need to fit this many bits, (+7)/8 rgbdata=(c_ubyte*((len(data_py_clk)+7)>>3))(0) # array to bits in byte array for i in range(len(data_py_clk)): if data_py_clk[i] != 0: rgbdata[i>>3] |= 1<<(i&7) #clk pin session clk_pin=0 # generate pattern dwf.FDwfDigitalOutEnableSet(hdwf, c_int(clk_pin), c_int(1)) dwf.FDwfDigitalOutTypeSet(hdwf, c_int(clk_pin), DwfDigitalOutTypeCustom) # 10kHz sample rate dwf.FDwfDigitalOutDividerSet(hdwf, c_int(clk_pin), c_int(int(hzSys.value/hzRate))) # set sample rate dwf.FDwfDigitalOutDataSet(hdwf, c_int(clk_pin), byref(rgbdata), c_int(len(data_py_clk))) rgbdata_din=(c_ubyte*((len(data_py_din)+7)>>3))(0) # array to bits in byte array for i in range(len(data_py_din)): if data_py_din[i] != 0: rgbdata_din[i>>3] |= 1<<(i&7) #din pin session din_pin=1 # generate pattern dwf.FDwfDigitalOutEnableSet(hdwf, c_int(din_pin), c_int(1)) # 10kHz sample rate dwf.FDwfDigitalOutDividerSet(hdwf, c_int(din_pin), c_int(int(hzSys.value/hzRate))) # set sample rate dwf.FDwfDigitalOutDataSet(hdwf, c_int(din_pin), byref(rgbdata_din), c_int(len(data_py_din))) print("Generating pattern...") dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) dwf.FDwfDigitalOutReset(hdwf) dwf.FDwfDeviceCloseAll()
×
×
  • Create New...