Jump to content
  • 0

Corrupt signal using Digital Discovery Play Mode


AlanB

Question

I have been trying to set up a pattern to play back using Play Mode, and am finding that occasionally (1 time in ~10) I see a corrupted pattern being output.  This can manifest in one of a few ways.

The first way uses code that I've modified from the DigitalDiscovery_Play.py example.  I've shortened the pattern and used FDwfDigitalOutRunSet to ensure that it is only played a single time.  The code is as follows:

"""
   DWF Python Example
   Author:  Digilent, Inc.
   Revision:  2021-09-10

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

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.FDwfDeviceParamSet(hdwf, DwfParamOnClose, c_int(0)) # 0 = run, 1 = stop, 2 = shutdown
# 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, or 128Mi 16bits samples
nPlay = 1*1024
rgwPlay = (c_uint16*int(nPlay))()

for i in range(len(rgwPlay)):
    rgwPlay[i] = i

print("Samples:"+str(nPlay)+" Rate:"+str(hzPlay)+"Hz "+" Period:"+str(nPlay/hzPlay)+"s")
dwf.FDwfDigitalOutPlayRateSet(hdwf, c_double(hzPlay)) # play sample rate

# enable play mode for the wanted signals
for i in range(0, 16):
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(i), c_int(1)) # enable
    dwf.FDwfDigitalOutTypeSet(hdwf, c_int(i), c_int(5)) # DwfDigitalOutTypePlay
    dwf.FDwfDigitalOutIdleSet(hdwf, c_int(i), DwfDigitalOutIdleLow)

# set play data array of 16 bit samples
dwf.FDwfDigitalOutPlayDataSet(hdwf, byref(rgwPlay), c_int(16), c_int(int(nPlay)))

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

print("Starting Digital Out...")
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

time.sleep(1)

dwf.FDwfDeviceCloseAll()

This usually gives me a 102.4us burst of output as I would expect.  However it occasionally gives me a random-looking output for the first  ~12us before becoming the pattern I expect for the remaining time.  I can see this corruption using a separate logic analyser connected to the Discovery outputs.  Changing the output sample rate changes the period of the corruption - whenever it happens, it appears to be 128 samples of garbage.

I have also seen occasions when my pattern repeats - when I output at 10MS/s the repeat happens every 102.4us.  At 5MS/s it repeats every 204.8us.  This is when I have been generating longer patterns - and they appear slightly corrupted during the some of the repeat.  I haven't managed to reproduce my program down to a simple example yet, but hoped it might be connected in some way to the issues from the first example.

Edited by AlanB
Link to comment
Share on other sites

2 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...