Hi, using the GUI I'm able to sample at 100 MHz. I'd like to replicate this is software using pydwf or the SDK.
Here is my example using pydwf. I have two questions when running this code.
1. This is sampling at 2 MHz, but I expect 50 MHz or 100 MHz. How to I sample at 100 MHz? I'm not setting the divider, so I thought this would sample as fast as possible.
2. This is driving out at 1 MHz (measured externally). I expect this should be 25 MHz. How is the 1 MHz determined?
# %% Digilent Waveform Digital Inimport pydwf
from time import sleep
import matplotlib.pyplot as plt
from pydwf importDwfState,DwfTriggerSourcefrom pydwf.utilities import openDwfDevice
CH ={'out':0,'in':0}def main():
device = openDwfDevice(pydwf.DwfLibrary())
device.paramSet(pydwf.DwfDeviceParameter.Frequency, int(100e6))
digital_out = device.digitalOut
digital_in = device.digitalIn
# Configure for 1 MHz out
digital_out.enableSet(CH['out'],True)
digital_out.dividerSet(CH['out'],1)
digital_out.counterSet(CH['out'], low_count=2, high_count=2)
digital_in.inputOrderSet(dio_first=True)
clock_frequency = digital_in.internalClockInfo()
divider_count = digital_in.dividerGet()
digital_in.sampleFormatSet(num_bits=1)# 1 bit per sample format
number_samples =64
digital_in.bufferSizeSet(number_samples)
digital_in.triggerSourceSet(DwfTriggerSource.DetectorDigitalIn)
digital_in.triggerPositionSet(0)
digital_in.triggerSet(level_low=0, level_high=0, edge_rise=1<<CH['in'],
edge_fall=0)print(f'clock frequency: {clock_frequency/1e6} MHz')print(f'sample frequency: {clock_frequency/divider_count/1e6} MHz')
digital_in.configure(reconfigure=False, start=True)
digital_out.configure(start=True)whileTrue:
status = digital_in.status(read_data_flag=True)print(f'status: {status}')if status ==DwfState.Done:print("done")break
sleep(0.1)
data = digital_in.statusData(number_samples)
device.close()
plt.plot(data, marker='.')
plt.show()# %% Mainif __name__ =='__main__':
main()
Question
Empower
Hi, using the GUI I'm able to sample at 100 MHz. I'd like to replicate this is software using pydwf or the SDK.
Here is my example using pydwf. I have two questions when running this code.
1. This is sampling at 2 MHz, but I expect 50 MHz or 100 MHz. How to I sample at 100 MHz? I'm not setting the divider, so I thought this would sample as fast as possible.
2. This is driving out at 1 MHz (measured externally). I expect this should be 25 MHz. How is the 1 MHz determined?
Link to comment
Share on other sites
3 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 accountSign in
Already have an account? Sign in here.
Sign In Now