Jump to content
  • 0

Pattern generator frequency - Digital Discovery


Limitha

Question

Hi,

I have been using python  to program the pattern generator of digilent digital discovery but when I am checking for the frequency of the generated output it is limited to 6KHz. I am writing here to know if there is anyway to use the device to its full potential like say 50 MHz? Thanks in advance.

Regards,

Limitha

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Hi @attila

I tried modifying the Digital_io.py code as shown,

 

from ctypes import *
from dwfconstants import *
import sys
import random
import pandas as pd

dwf = cdll.dwf

hdwf = c_int()
dwRead = c_uint32()
iDevId = c_int()
iDevRev = c_int()
hzSys = c_double()
devicename = create_string_buffer(64)
serialnum = create_string_buffer(16)  
    
dwf.FDwfEnum(c_int(0), byref(hdwf))
print("Number of Devices: "+str(hdwf.value))

dwf.FDwfEnumDeviceName (c_int(hdwf.value-1), devicename)
dwf.FDwfEnumSN (c_int(hdwf.value-1), serialnum)
dwf.FDwfEnumDeviceType (c_int(hdwf.value-1), byref(iDevId), byref(iDevRev))
print("------------------------------")
print("Device "+str(hdwf.value-1)+" : ")
print("\tName: \'" + str(devicename.value) + "' " + str(serialnum.value))
print("\tID: " + str(iDevId.value) + " rev: " + str(iDevRev.value))

print("Opening first device")
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))

if hdwf.value == hdwfNone.value:
    print("failed to open device")
    szerr = create_string_buffer(512)
    dwf.FDwfGetLastErrorMsg(szerr)
    print(str(szerr.value))
    quit()

dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(1.8))

dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))
print("Internal frequency is " + str(hzSys.value/1e6)+" MHz")

# enable output/mask on 8 LSB IO pins, from DIO 0 to 7
pin_status = c_uint32()  
  
# On DD the DIO-0 represents 24, 1 -> 25, 2 -> 26, 3 -> 27, 4 -> 28...
# Here for 28 it is the 5 bit which is set by 10000
pin=0x0010

dwf.FDwfDigitalIOOutputEnableSet(hdwf, c_int(pin)) 
dwf.FDwfDigitalIOOutputEnableGet(hdwf, byref(pin_status))
print("Pin value is " + bin(pin_status.value)[2:])

for i in range(int(hzSys.value)):
    data = str(random.randint(0, 50))
    # set value on enabled IO pins
    dwf.FDwfDigitalIOOutputSet(hdwf, c_int(int(data))) 
    
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))  

# fetch digital IO information from the device           
dwf.FDwfDigitalIOStatus(hdwf) 
# read state of all pins, regardless of output enable
dwf.FDwfDigitalIOInputStatus(hdwf, byref(dwRead)) 

#print(dwRead as bitfield (32 digits, removing 0b at the front)
print("Digital IO Pins: ", bin(dwRead.value)[2:].zfill(16))

dwf.FDwfDeviceClose(hdwf)

 

I guess the frequency is limited in this case yeah? So if I need to get a higher frequency I need to use the out configuration?

 

Regards,

Limitha 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

  • 0

Hi @Limitha

You have used the digital-io functions for software control which have ~millisecond latency.
For high frequency use the earlier mentioned digital-out functions:

On 11/19/2021 at 3:26 PM, attila said:

Hi @Limitha

It is possible to configure it up to 50MHz or the set system frequency / 2.
The FDwfDigitalOutDividerSet specifies the prescaler from 100MHz and FDwfDigitalOutCounterSet the low and high counts.
See the WF SDK manual and the samples/ py/ DigitalOut_Clock.py DigitalOut_Duty.py ... examples

image.png.f65b0577eb950674fe8763092dda2abb.png

 

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