Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a658582
Initial draft of DDS sweeper
carterturn Mar 31, 2025
9e946f7
updating worker functions to match current firmware
Json-To-String Apr 15, 2025
1a42e34
Merge branch 'labscript-suite:master' into carterturn-dds-sweeper
carterturn Apr 17, 2025
2ffb2ba
added logic for max instructions per channel, getting pico board, and…
Json-To-String Apr 18, 2025
24e00ae
change assert_OK() calls in __init__ to match current firmware
Json-To-String Apr 21, 2025
4048745
Some initial docs additions
Json-To-String Apr 23, 2025
b02ec9b
Indenting python block properly
Json-To-String Apr 23, 2025
71e107b
fix uf2 link rendering and renamed runviewer parser to plural
Json-To-String Apr 23, 2025
03352fd
adding support for simultaneous dynamic and static instructions
Json-To-String Apr 24, 2025
5630a47
Add check that device is ready for the number of bytes we will send i…
carterturn Apr 27, 2025
4387a42
Add overview and specifications for docs.
carterturn Apr 27, 2025
0595dd4
Add option for external reference clock
carterturn Apr 27, 2025
68c25c5
Expand docstring for labscript device
carterturn Apr 27, 2025
9469d0b
removing internal timing, added a parentheses to table size check
Json-To-String Apr 28, 2025
7b20811
pluralism
Json-To-String Apr 28, 2025
1f6bc6b
Some documentation and docstring updates
carterturn Apr 29, 2025
fb5acda
min version and status map update
Json-To-String Apr 29, 2025
a8adf76
no s in readline
Json-To-String Apr 29, 2025
43b4821
Add Pico2 instruction counts to docs.
carterturn Apr 29, 2025
aed9873
saving progress, all static ins works, final value update works, stil…
Json-To-String Apr 29, 2025
eebf6f6
Graceful aborts and docstring updates
Json-To-String Apr 30, 2025
995a0f4
status string format specifier fix
Json-To-String Apr 30, 2025
b821fea
transition_to_buffered supports smart cache, borrowing logic from Pra…
Json-To-String May 1, 2025
0c02e78
adding clock_limit class attribute
Json-To-String May 2, 2025
c2ec2b9
limit calculation uses dynamic channels, not all, and ref clk freq be…
Json-To-String May 2, 2025
146157a
removed unnecessary if statement checks for both dyn and stat DDSs
Json-To-String May 6, 2025
d3671af
More docstrings
carterturn May 6, 2025
46bcc9f
Default connection table example
Json-To-String May 8, 2025
4580b06
Cleaned up extra imports in the examples
Json-To-String May 8, 2025
f1985c5
smart cache logic cleanup, removed inaccurate debug msg, moved explic…
Json-To-String May 8, 2025
d7b0dfc
Conversion to DDS units is done on Pi Pico for set_output.
carterturn May 14, 2025
5377b59
Placeholder values for scale factor when only static channels are used.
carterturn May 14, 2025
b0797fe
Don't need to do unit conversions for set output
carterturn May 14, 2025
adfa697
Remove stray? factor of 10 from tuning_words_to_SI dictionary.
carterturn May 14, 2025
3f55bde
removing explicit break, is the same as returning self.final_values
Json-To-String May 19, 2025
fe811ef
program manual will invalidate static cache
Json-To-String May 19, 2025
e0fe6ee
Add dynamic channels to constructor, and add checks in add_device to …
carterturn May 20, 2025
273c42d
calculate max freq
Json-To-String May 20, 2025
10911d6
program manual should only invalidate static cache
Json-To-String May 22, 2025
0fe0504
update examples with dynamic_channels parameter
Json-To-String May 22, 2025
9f37751
Compute scale factors separately from quantising data.
carterturn May 23, 2025
9854b3c
Cache scale factor calculations and fully separate for quantization f…
dihm May 29, 2025
34436d5
Move `generate_code` break if no channels are connected earlier in th…
dihm May 29, 2025
b3aee0a
Tidy up some lints
dihm May 29, 2025
4527466
program_manual should not erase dds_data from smart cache.
carterturn Jun 10, 2025
33e1b61
Ensure data table is constructed in correct order.
carterturn Jun 24, 2025
2c0e678
Compare original cache length to DDS data length.
carterturn Sep 21, 2025
2efc496
Prevent cache from being extended with stale data from np.empty
Json-To-String Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions labscript_devices/AD9959DDSSweeper/blacs_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@

from blacs.device_base_class import DeviceTab


class AD9959DDSSweeperTab(DeviceTab):
def initialise_GUI(self):
device = self.settings['connection_table'].find_by_name(self.device_name)

ref_clk_freq = device.properties['ref_clock_frequency']
pll_mult = device.properties['pll_mult']
self.com_port = device.properties['com_port']

max_freq = 0.5 * (ref_clk_freq * pll_mult)
# Capabilities
self.base_units = {'freq':'Hz', 'amp':'Arb', 'phase':'Degrees'}
self.base_min = {'freq':0.0, 'amp':0, 'phase':0}
self.base_max = {'freq':250.0*10.0**6, 'amp':1, 'phase':360}
self.base_max = {'freq':max_freq, 'amp':1, 'phase':360}
self.base_step = {'freq':10**6, 'amp':1/1023., 'phase':1}
self.base_decimals = {'freq':1, 'amp':4, 'phase':3}
self.num_DDS = 4
Expand All @@ -38,10 +46,6 @@ def initialise_GUI(self):
dds_widgets, _, _ = self.auto_create_widgets()
self.auto_place_widgets(('DDS Outputs', dds_widgets))

device = self.settings['connection_table'].find_by_name(self.device_name)

self.com_port = device.properties['com_port']

self.supports_remote_value_check(False)
self.supports_smart_programming(True)

Expand Down
15 changes: 1 addition & 14 deletions labscript_devices/AD9959DDSSweeper/blacs_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def program_manual(self, values):
values (dict): dictionary of dictionaries with keys of active DDS
channels, subkeys of ['freq', 'amp', 'phase']
'''
# invalidate static cache
self.smart_cache = {'static_data' : None, 'dds_data' : None}

for chan in values:
chan_int = int(chan[8:])
Expand Down Expand Up @@ -368,19 +368,6 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
'amp' : amp,
'phase' : phase,
}

else:
self.logger.debug(f'Setting outputs using cache on chan: {chan}')
self.intf.set_output(chan, cache_freq, cache_amp, cache_phase)
self.final_values[f'channel {chan}'] = {
'freq' : cache_freq * self.intf.tuning_words_to_SI['freq'],
'amp' : cache_amp * self.intf.tuning_words_to_SI['amp'],
'phase' : cache_phase * self.intf.tuning_words_to_SI['phase']
}

if dds_data is None and stat_data is None:
self.logger.debug('No instructions to set')
return self.initial_values

if dds_data is not None:
self.logger.debug(f'Dynamic Data found')
Expand Down
49 changes: 39 additions & 10 deletions labscript_devices/AD9959DDSSweeper/labscript_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AD9959DDSSweeper(IntermediateDevice):
}
)

def __init__(self, name, parent_device, com_port,
def __init__(self, name, parent_device, com_port, dynamic_channels,
pico_board='pico1', sweep_mode=0,
ref_clock_external=0, ref_clock_frequency=125e6, pll_mult=4, **kwargs):
'''Labscript device class for AD9959 eval board controlled by a Raspberry Pi Pico running the DDS Sweeper firmware (https://github.com/QTC-UMD/dds-sweeper).
Expand All @@ -67,6 +67,8 @@ def __init__(self, name, parent_device, com_port,
Pseudoclock clockline used to clock DDS parameter changes.
com_port (str): COM port assigned to the AD9959DDSSweeper by the OS.
On Windows, takes the form of `COMd` where `d` is an integer.
dynamic_channels (int): number of dynamic DDS channels that will be added.
This must be specified in the constructor so that update rates can be calculated correctly.
pico_board (str): The version of pico board used, pico1 or pico2.
sweep_mode (int):
The DDS Sweeper firmware can set the DDS outputs in either fixed steps or sweeps of the amplitude, frequency, or phase.
Expand All @@ -75,7 +77,6 @@ def __init__(self, name, parent_device, com_port,
ref_clock_frequency (float): Frequency of the reference clock. If ref_clock_external is 0, the Pi Pico system clock will be set to this frequency. If the PLL is used, ref_clock_frequency * pll_mult must be between 100 MHz and 500 MHz. If the PLL is not used, ref_clock_frequency must be less than 500 MHz.
pll_mult: the AD9959 has a PLL to multiply the reference clock frequency. Allowed values are 1 or 4-20.
'''
IntermediateDevice.__init__(self, name, parent_device, **kwargs)
self.BLACS_connection = '%s' % com_port

if pico_board in self.allowed_boards:
Expand All @@ -97,27 +98,55 @@ def __init__(self, name, parent_device, com_port,
self.dds_clock = ref_clock_frequency * pll_mult
self.clk_scale = 2**32 / self.dds_clock

# Store number of dynamic channels
if dynamic_channels > 4:
raise ValueError('AD9959DDSSweeper only supports up to 4 total channels, dynamic channels must be 4 or less.')
self.dynamic_channels = dynamic_channels

IntermediateDevice.__init__(self, name, parent_device, **kwargs)

@property
def clock_limit(self):
'''Dynamically computs clock limit based off of number of dynamic
channels and reference clock frequency.'''
num_dyn_chans = sum(isinstance(child, DDS) for child in self.child_devices)
if num_dyn_chans == 0:
# Set to worst case
# 4 channels, step mode, default 125 MHz pico ref clk
return 100000
if self.dynamic_channels == 0:
# No clock limit
return None

if self.sweep_mode > 0:
mode = 'sweeps'
else:
mode = 'steps'
try:
cycles_per_instruction = self.cycles_per_instruction_map[mode][num_dyn_chans - 1]
cycles_per_instruction = self.cycles_per_instruction_map[mode][self.dynamic_channels - 1]
except (KeyError, IndexError):
raise LabscriptError(f'Unsupported mode or number of channels: {mode}, {num_dyn_chans}')
raise LabscriptError(f'Unsupported mode or number of channels: {mode}, {self.dynamic_channels}')

return self.ref_clock_frequency / cycles_per_instruction


def add_device(self, device):
"""Confirms channel specified is valid before adding

Validity checks include channel name and static/dynamic status.
Dynamic channels must be specified before static channels.
Args:
device(): Device to attach. Must be a DDS or a StaticDDS.
Allowed connections are a string of the form `channel X`.
"""
conn = device.connection
chan = int(conn.split('channel ')[-1])

if isinstance(device, StaticDDS):
if chan < self.dynamic_channels:
raise LabscriptError(f'Channel {chan} configured as dynamic channel, can not create StaticDDS.')
elif chan >= 4:
raise LabscriptError('AD9959DDSSweeper only supports 4 channels')
elif isinstance(device, DDS):
if chan >= self.dynamic_channels:
raise LabscriptError(f'Channel {chan} not configured as dynamic channel, can not create DDS.')

super().add_device(device)

def get_default_unit_conversion_classes(self, device):
"""Child devices call this during their __init__ (with themselves
as the argument) to check if there are certain unit calibration
Expand Down