Jump to content
  • 0

When using FDwfDigitalOutPlayDataSet with large sample values results in corrupted signals


RRahul

Question

When trying to play a pattern in an infinite loop with a sample frequency of 8MHz and 6,000,000 samples a corrupted signal appears at the beginning of every period. My pattern is still visible but before the rising edge there are some signals which seem to be random. Additionally what is the format for the data for example to have one line be constant 0 while the other lines are doing some clock signals

CODE:

"""

   DWF Python Example

   Author:  Digilent, Inc.

   Revision:  2022-02-11

 

   Requires:          

       Python 2.7, 3

"""

 

from ctypes import *

from 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()

sts = c_ubyte()

 

version = create_string_buffer(16)

dwf.FDwfGetVersion(version)

print("DWF Version: "+str(version.value))

 

dwf.FDwfParamSet(DwfParamOnClose, c_int(1)) # 0 = run, 1 = stop, 2 = shutdown

 

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()

 

dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))# 0 = the device will be configured only when calling FDwf###Configure

 

print("Configuring Digital Out...")

 

hzPlay = 10e6

# for infinite playback fill the entire 256MiByte memory

nSamples = 6000000

rgbSamples= (c_ubyte*int(nSamples))()

 

for i in range(len(rgbSamples)):

    if i < 3000000:

        rgbSamples[i]=1

    else:

        rgbSamples[i] = 0



 

dwf.FDwfDigitalOutRunSet(hdwf, c_double(nSamples / float(hzPlay)))

dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(0)) # infinite repeats


 

# enable play mode for the wanted signals

for i in range(8):

    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(i), c_int(1)) # enable

    dwf.FDwfDigitalOutTypeSet(hdwf, c_int(i), DwfDigitalOutTypePlay)

    dwf.FDwfDigitalOutIdleSet(hdwf, c_int(i), DwfDigitalOutIdleLow)

 

print("Samples:"+str(nSamples)+" Rate:"+str(hzPlay)+"Hz "+" Period:"+str(nSamples/hzPlay)+"s")

dwf.FDwfDigitalOutPlayRateSet(hdwf, c_double(hzPlay)) # play sample rate

# set play data array of 8 bit samples

dwf.FDwfDigitalOutPlayDataSet(hdwf, byref(rgbSamples), c_int(8), c_int(int(nSamples)))


 

print("Arming Digital Out...")

dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

time.sleep(100)

dwf.FDwfDeviceCloseAll()

 

Corrupted Signal in Oscope.jpg

test.py

Edited by RRahul
Link to comment
Share on other sites

Recommended Posts

  • 0

@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

Edited by RRahul
Link to comment
Share on other sites

  • 0

Only by using wait of about 1us, for the DDR RAM read cache to be refilled, before restart. This play features was later added, on used request, and not to sophisticated. 
If 32ki samples / dio is sufficient you can use the simple custom mode.

Link to comment
Share on other sites

  • 0

In play, successive samples are output on the specified number of DIOs at a specified rate.
It may be more constructive if you explain what you want you want to achieve. There may be another solution to this.

Link to comment
Share on other sites

  • 0
On 9/13/2024 at 10:32 AM, attila said:

Only by using wait of about 1us, for the DDR RAM read cache to be refilled, before restart. This play features was later added, on used request, and not to sophisticated. 
If 32ki samples / dio is sufficient you can use the simple custom mode.

@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. 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...