RRahul
Members-
Posts
23 -
Joined
-
Last visited
RRahul's Achievements
Member (2/4)
3
Reputation
-
attila reacted to an answer to a question: Signal Issue
-
Thanks for the Info
- 2 replies
-
- digital discovery
- python
-
(and 1 more)
Tagged with:
-
RRahul started following Signal Issue
-
""" DWF Python Example Author: Digilent, Inc. Revision: 2024-09-13 Requires: Python 2.7, 3 """ import csv import numpy as np import pandas as pd from ctypes import * from dwfconstants import * import sys df = pd.read_csv('rst_clk.csv') #CONSTANTS: TICKS = 40 LINE_TIME = TICKS*128 FRAME_TIME = LINE_TIME*4096 for i in range(len(df.index)): print(df['Repeat'].loc[df.index[i]]) pattern1 = np.genfromtxt(df['Pattern'].loc[df.index[0]], delimiter=',') new_pattern1 = np.tile(pattern1,4096) 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() sts = c_ubyte() version = create_string_buffer(16) dwf.FDwfGetVersion(version) print("DWF Version: "+str(version.value)) dwf.FDwfParamSet(DwfParamOnClose, 0) # 0 = run, 1 = stop, 2 = shutdown print("Opening first device") dwf.FDwfDeviceOpen(-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() dwf.FDwfDeviceAutoConfigureSet(hdwf, 0)# 0 = the device will be configured only when calling FDwf###Configure # dwf.FDwfDigitalIODriveSet(hdwf, 0, c_double(0.008), 2) # 8mA, 2=Fast print("Generating pattern...") hzPlay = 2e6 # for infinite playback fill the entire 256MiByte memory #nPlay = 256*1024*1024 #rgbPlay = (c_uint8*int(nPlay))() #for i in range(len(rgbPlay)): # rgbPlay[i] = c_uint8(i) nPlay = len(pattern1) rgbPlay = (c_uint8 * FRAME_TIME)() for i in range(len(new_pattern1)): rgbPlay[i] = int(new_pattern1[i]) print("Configuring Digital Out...") print("Samples:"+str(nPlay)+" Rate:"+str(hzPlay)+"Hz "+" Period:"+str(nPlay/hzPlay)+"s") dwf.FDwfDigitalOutPlayRateSet(hdwf, c_double(hzPlay)) # play sample rate if nPlay < 256*1024*1024 : # use wait if length is less than the 256MiB dwf.FDwfDigitalOutRunSet(hdwf, c_double(nPlay/hzPlay)) dwf.FDwfDigitalOutWaitSet(hdwf, c_double(1e-6)) dwf.FDwfDigitalOutRepeatSet(hdwf, 0) for i in range(8): dwf.FDwfDigitalOutEnableSet(hdwf, i, 1) # enable dwf.FDwfDigitalOutTypeSet(hdwf, i, DwfDigitalOutTypePlay) dwf.FDwfDigitalOutIdleSet(hdwf, i, DwfDigitalOutIdleLow) dwf.FDwfDigitalOutConfigure(hdwf, 0) # stop earlier run # set play data array of 8 bit samples if dwf.FDwfDigitalOutPlayDataSet(hdwf, byref(rgbPlay), c_uint(8), int(nPlay)) == 0: szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) quit() print("Starting Digital Out...") if dwf.FDwfDigitalOutConfigure(hdwf, 1) == 0: szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) quit() dwf.FDwfDeviceCloseAll() print("done") Why when I change the hzPlay variable to 8 MHz a corrupted signal is produced.
- 2 replies
-
- digital discovery
- python
-
(and 1 more)
Tagged with:
-
@attila Using the SDK, how do you trigger an output from a raspberry pi Pico producing an clock signal connected to high speed input 1 on the rising edge. For clarification when the input reads a clock edge it should produce the desired output and hold the last value until the next clock edge
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
""" DWF Python Example Author: Digilent, Inc. Revision: 2024-08-21 Requires: Python 2.7, 3 Description: Generates a custom pattern """ from ctypes import * from dwfconstants import * import sys import time import numpy import matplotlib.pyplot as plt 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)) # continue running after device close dwf.FDwfParamSet(DwfParamOnClose, 0) # 0 = run, 1 = stop, 2 = shutdown print("Opening first device") dwf.FDwfDeviceOpen(-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() # the device will only be configured when FDwf###Configure is called dwf.FDwfDeviceAutoConfigureSet(hdwf, 0) dwf.FDwfParamSet(hdwf,DwfParamDigitalVoltage,1800) PIXEL_TIME =12 LINE_TIME = 128*PIXEL_TIME FRAME_TIME=4096*LINE_TIME pin = 0 hzRate = 8e6 data_py = [0]*32000 for i in range(12000): data_py[i] =1 cBits = len(data_py) print(cBits) # digital-in hzDI = c_double() hzSys = c_double() dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys)) print("DigitanOut base freq: "+str(hzSys.value/1e6)+"MHz") # how many bytes we need to fit this many bits, (+7)/8 rgbdata = (c_ubyte*((cBits+7)>>3))(0) # array to bits in byte array for i in range(cBits): if data_py[i] != 0: rgbdata[i>>3] |= 1<<(i&7) # generate pattern dwf.FDwfParamSet(hdwf, DwfParamDigitalVoltage, 1800) dwf.FDwfDigitalOutEnableSet(hdwf, pin, 1) dwf.FDwfDigitalOutIdleSet(hdwf, pin, DwfDigitalOutIdleLow) dwf.FDwfDigitalOutTypeSet(hdwf, pin, DwfDigitalOutTypeCustom) # 100kHz sample rate dwf.FDwfDigitalOutDividerSet(hdwf, pin, int(hzSys.value/hzRate)) # set sample rate dwf.FDwfDigitalOutDataSet(hdwf, pin, byref(rgbdata), cBits) dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(0)) dwf.FDwfDigitalOutRunSet(hdwf, c_double(cBits/hzRate)) dwf.FDwfDigitalOutConfigure(hdwf, 1) Lastly, why is this code not producing an maximum output of around 1.8 V instead of 3.3 V
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
@attila For this 1us delay what are the requirements of the pattern generator. Are all signals held at 0, or held at the last value, etc.
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
For example if my data is [3,1,3,1,3,1] then on DIO-0 it will be [1,1,1,1,1,1] however when I probe that pin with an oscilloscope it's not constant at digital high.
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
Additionally is it possible to make a constant pattern at digital high or '1' using play ?
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
@attila could I also have an example of creating a custom pattern using play with an arbitrary array not the "rgbValues[i] = i" to further my understanding of the how the data is stored and used by the signals ?
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
RRahul reacted to an answer to a question: When using FDwfDigitalOutPlayDataSet with large sample values results in corrupted signals
-
@attila one last question, is it possible to not fill the full 256M and repeat the pattern infinitely without getting garbage/corrupted signals. Is there a work around this issue ?
- 32 replies
-
- digital output
- play mode
- (and 4 more)
-
attila reacted to an answer to a question: When using FDwfDigitalOutPlayDataSet with large sample values results in corrupted signals
-
@attila when I run it from command prompt there are no errors however I have hooked it up to an external oscilloscope and there the output does not make sense. I expected it to be some sort of square wave
- 32 replies
-
- digital output
- play mode
- (and 4 more)