stever Posted July 18, 2019 Share Posted July 18, 2019 HI, I am trying to create a custom output pattern using Digital Discovery. I have managed to get it to work referencing the python examples but now want to use the dwf api to simplify the code and avoid ctypes. I believed I had translated all the existing code but I do not get any output. Please help point me to what I missed - Thanks: bytestream = np.packbits(bytestream)[0:4096] # bytestream is the pattern data to output dwf_do.enableSet(pin, 1) # enable pin dwf_do.idleSet(pin, 0) # set idle state to low dwf_do.typeSet(pin, 1) # set custom for pattern generation dwf_do.outputSet(pin, 0) # set output type to push-pull dwf_do.dividerSet(pin, divider) # set output clock rate dwf_do.dataSet(pin, dwf.create_bitdata_stream(data=bytestream, bits=8, msb_first=False)) dwf_do.repeatSet(1) # just output the pattern once dwf_do.runSet(8 * len(bytestream) * divider / internal_clock) dwf_do.configure(1) # start the output Link to comment Share on other sites More sharing options...
stever Posted July 18, 2019 Author Share Posted July 18, 2019 OK - Solved I had to move the dwf_do.enableSet(pin,1) to after configuring and just before the dwf_do.configure() Link to comment Share on other sites More sharing options...
JColvin Posted July 18, 2019 Share Posted July 18, 2019 Hi @stever, Thanks for sharing the solution you found! Thanks, JColvin Link to comment Share on other sites More sharing options...
stever Posted July 19, 2019 Author Share Posted July 19, 2019 Hi, There are several beta releases of Waveforms but the dwf API is from August 2018. Is there a newer version and any documentation on these calls other than the examples. I have a problem getting analog io, digital in and digital out all working. I need analog io to set the IO voltages, digital output and digital inputs (recording) I implemented: dwf_dio = dwf.DwfDigitalIO() dwf_aio = dwf.DwfAnalogIO(dwf_dio) dwf_do = dwf.DwfDigitalOut(dwf_dio) dwf_di = dwf.DwfDigitalOut(dwf_dio) but some digital in calls are not recognised. They are recognised if I just use dwf_di = dwf.DwfDigitalOut() by itself But with the others then the instantiation fails as the device is in use. Any ideas please ? Link to comment Share on other sites More sharing options...
attila Posted July 22, 2019 Share Posted July 22, 2019 Hi @stever I don't know what the Python package are you using but the digital out is not equivalent to digital in, the functions are different, dwf_di /= dwf.DwfDigitalOut The latest documentation version, corresponding to the sdk version, is included in the application/sdk package. Link to comment Share on other sites More sharing options...
stever Posted July 23, 2019 Author Share Posted July 23, 2019 Hi Attila, and thanks for responding. I am using Pycharm IDE with python 2.7.6 I can now call all the functions after correctly instantiating: dio = dwf.DwfDigitalIO() aio = dwf.DwfAnalogIO(dio) do = dwf.DwfDigitalOut(dio) di = dwf.DwfDigitalIn(dio) I am trying to create a pattern on four outputs and capture data in sync on two inputs. Please review the file I attached and advise. Thanks stever digilent pattern.py Link to comment Share on other sites More sharing options...
attila Posted July 23, 2019 Share Posted July 23, 2019 Hi @stever Sorry but I'm not familiar with this 3rd party dwf wrapper. See the WF SDK/ samples/ py/ DigitalOut_CustomBus.py which performs digital-in and out. Link to comment Share on other sites More sharing options...
stever Posted July 24, 2019 Author Share Posted July 24, 2019 Hi Atilla, OK - thanks. Is there any way that I can stream large files out as a pattern ? If not, is there a way to make use of the 32k buffers on unused outputs and combine them into a larger buffer for four outputs ? The pattern I am generating is less than 512k Thanks stever Link to comment Share on other sites More sharing options...
attila Posted July 24, 2019 Share Posted July 24, 2019 Hi @stever It is not possible, the maximum digital-out buffer size on Digital Discovery is 32k samples / channel Link to comment Share on other sites More sharing options...
Question
stever
HI,
I am trying to create a custom output pattern using Digital Discovery.
I have managed to get it to work referencing the python examples but now want to use the dwf api to simplify the code and avoid ctypes.
I believed I had translated all the existing code but I do not get any output.
Please help point me to what I missed - Thanks:
bytestream = np.packbits(bytestream)[0:4096] # bytestream is the pattern data to output
dwf_do.enableSet(pin, 1) # enable pin
dwf_do.idleSet(pin, 0) # set idle state to low
dwf_do.typeSet(pin, 1) # set custom for pattern generation
dwf_do.outputSet(pin, 0) # set output type to push-pull
dwf_do.dividerSet(pin, divider) # set output clock rate
dwf_do.dataSet(pin, dwf.create_bitdata_stream(data=bytestream, bits=8, msb_first=False))
dwf_do.repeatSet(1) # just output the pattern once
dwf_do.runSet(8 * len(bytestream) * divider / internal_clock)
dwf_do.configure(1) # start the output
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.