Skip to content

Commit

Permalink
Merge branch 'pr/cmf84/284' into feature/slow-integrator-fast-dacs
Browse files Browse the repository at this point in the history
  • Loading branch information
bleykauf committed Feb 28, 2023
2 parents 610640b + 2656e46 commit cf61773
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 124 deletions.
17 changes: 16 additions & 1 deletion gateware/linien_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def init_csr(self, width, signal_width, chain_factor_width):
self.mod_channel = CSRStorage(1)
self.control_channel = CSRStorage(1)
self.sweep_channel = CSRStorage(2)
self.control_slow_channel = CSRStorage(2)

self.fast_mode = CSRStorage(1)

Expand Down Expand Up @@ -312,6 +313,12 @@ def connect_everything(self, width, signal_width, coeff_width, chain_factor_bits

fast_outs = list(Signal((width + 4, True)) for channel in (0, 1))

self.comb += self.slow.pid.running.eq(
self.logic.autolock.lock_running.status
)
slow_pid_out = Signal((width, True))
self.comb += slow_pid_out.eq(self.slow.output)

for channel, fast_out in enumerate(fast_outs):
self.comb += fast_out.eq(
Mux(self.logic.control_channel.storage == channel, pid_out, 0)
Expand All @@ -324,7 +331,12 @@ def connect_everything(self, width, signal_width, coeff_width, chain_factor_bits
self.logic.out_offset_signed,
0,
)
+ Mux(
self.logic.control_slow_channel.storage == channel, slow_pid_out, 0
)
)



for analog_idx in range(4):
if analog_idx == 0:
Expand All @@ -340,7 +352,10 @@ def connect_everything(self, width, signal_width, coeff_width, chain_factor_bits
slow_out = Signal((width + 3, True))
self.comb += [
slow_out.eq(
slow_pid_out
#control_slow_channel=2 -> ANALOG_OUT0
Mux(
self.logic.control_slow_channel.storage == 2, slow_pid_out, 0
)
+ Mux(
self.logic.sweep_channel.storage == ANALOG_OUT0,
self.logic.sweep.y,
Expand Down
13 changes: 9 additions & 4 deletions linien-gui/linien_gui/ui/general_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def dual_channel_changed(value):
param2ui(self.parameters.mod_channel, self.ids.mod_channel)
param2ui(self.parameters.control_channel, self.ids.control_channel)
param2ui(self.parameters.sweep_channel, self.ids.sweep_channel)
param2ui(self.parameters.pid_on_slow_enabled, self.ids.slow_control_channel)
param2ui(self.parameters.control_slow_channel, self.ids.slow_control_channel)

param2ui(self.parameters.polarity_fast_out1, self.ids.polarity_fast_out1)
param2ui(self.parameters.polarity_fast_out2, self.ids.polarity_fast_out2)
Expand All @@ -121,7 +121,7 @@ def show_polarity_settings(*args):
)

if self.parameters.pid_on_slow_enabled.value:
used_channels.add(ANALOG_OUT0)
used_channels.add(self.parameters.control_slow_channel.value)

self.ids.polarity_selector.setVisible(len(used_channels) > 1)

Expand All @@ -135,7 +135,7 @@ def set_visibility(element, channel_id):
self.parameters.control_channel.on_change(show_polarity_settings)
self.parameters.sweep_channel.on_change(show_polarity_settings)
self.parameters.mod_channel.on_change(show_polarity_settings)
self.parameters.pid_on_slow_enabled.on_change(show_polarity_settings)
self.parameters.control_slow_channel.on_change(show_polarity_settings)

for idx in range(4):
if idx == 0:
Expand Down Expand Up @@ -188,7 +188,12 @@ def control_channel_changed(self, channel):
self.control.write_registers()

def slow_control_channel_changed(self, channel):
self.parameters.pid_on_slow_enabled.value = bool(channel)
self.parameters.control_slow_channel.value = channel
self.control.write_registers()
if channel>2:
self.parameters.pid_on_slow_enabled.value = False
else:
self.parameters.pid_on_slow_enabled.value = True
self.control.write_registers()

def sweep_channel_changed(self, channel):
Expand Down
12 changes: 11 additions & 1 deletion linien-gui/linien_gui/ui/general_panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,26 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>FAST OUT 1</string>
</property>
</item>
<item>
<property name="text">
<string>disabled</string>
<string>FAST OUT 2</string>
</property>
</item>
<item>
<property name="text">
<string>ANALOG OUT 0</string>
</property>
</item>
<item>
<property name="text">
<string>disabled</string>
</property>
</item>
</widget>
</item>
</layout>
Expand Down
233 changes: 117 additions & 116 deletions linien-server/linien_server/csrmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,122 +169,123 @@
'logic_mod_channel': (8, 0x00d, 1, True),
'logic_control_channel': (8, 0x00e, 1, True),
'logic_sweep_channel': (8, 0x00f, 2, True),
'logic_fast_mode': (8, 0x010, 1, True),
'logic_slow_value': (8, 0x011, 14, False),
'logic_slow_decimation': (8, 0x013, 5, True),
'logic_analog_out_1': (8, 0x014, 15, True),
'logic_analog_out_2': (8, 0x016, 15, True),
'logic_analog_out_3': (8, 0x018, 15, True),
'logic_mod_amp': (8, 0x01a, 14, True),
'logic_mod_freq': (8, 0x01c, 32, True),
'logic_sweep_step': (8, 0x020, 30, True),
'logic_sweep_min': (8, 0x024, 14, True),
'logic_sweep_max': (8, 0x026, 14, True),
'logic_sweep_run': (8, 0x028, 1, True),
'logic_sweep_pause': (8, 0x029, 1, True),
'logic_limit_error_signal_min': (8, 0x02a, 25, True),
'logic_limit_error_signal_max': (8, 0x02e, 25, True),
'logic_limit_fast1_min': (8, 0x032, 14, True),
'logic_limit_fast1_max': (8, 0x034, 14, True),
'logic_limit_fast2_min': (8, 0x036, 14, True),
'logic_limit_fast2_max': (8, 0x038, 14, True),
'logic_pid_setpoint': (8, 0x03a, 25, True),
'logic_pid_kp': (8, 0x03e, 14, True),
'logic_pid_ki': (8, 0x040, 14, True),
'logic_pid_reset': (8, 0x042, 1, True),
'logic_pid_kd': (8, 0x043, 14, True),
'logic_autolock_robust_time_scale': (8, 0x045, 14, True),
'logic_autolock_robust_N_instructions': (8, 0x047, 5, True),
'logic_autolock_robust_final_wait_time': (8, 0x048, 14, True),
'logic_autolock_robust_peak_height_0': (8, 0x04a, 28, True),
'logic_autolock_robust_peak_height_1': (8, 0x04e, 28, True),
'logic_autolock_robust_peak_height_2': (8, 0x052, 28, True),
'logic_autolock_robust_peak_height_3': (8, 0x056, 28, True),
'logic_autolock_robust_peak_height_4': (8, 0x05a, 28, True),
'logic_autolock_robust_peak_height_5': (8, 0x05e, 28, True),
'logic_autolock_robust_peak_height_6': (8, 0x062, 28, True),
'logic_autolock_robust_peak_height_7': (8, 0x066, 28, True),
'logic_autolock_robust_peak_height_8': (8, 0x06a, 28, True),
'logic_autolock_robust_peak_height_9': (8, 0x06e, 28, True),
'logic_autolock_robust_peak_height_10': (8, 0x072, 28, True),
'logic_autolock_robust_peak_height_11': (8, 0x076, 28, True),
'logic_autolock_robust_peak_height_12': (8, 0x07a, 28, True),
'logic_autolock_robust_peak_height_13': (8, 0x07e, 28, True),
'logic_autolock_robust_peak_height_14': (8, 0x082, 28, True),
'logic_autolock_robust_peak_height_15': (8, 0x086, 28, True),
'logic_autolock_robust_peak_height_16': (8, 0x08a, 28, True),
'logic_autolock_robust_peak_height_17': (8, 0x08e, 28, True),
'logic_autolock_robust_peak_height_18': (8, 0x092, 28, True),
'logic_autolock_robust_peak_height_19': (8, 0x096, 28, True),
'logic_autolock_robust_peak_height_20': (8, 0x09a, 28, True),
'logic_autolock_robust_peak_height_21': (8, 0x09e, 28, True),
'logic_autolock_robust_peak_height_22': (8, 0x0a2, 28, True),
'logic_autolock_robust_peak_height_23': (8, 0x0a6, 28, True),
'logic_autolock_robust_peak_height_24': (8, 0x0aa, 28, True),
'logic_autolock_robust_peak_height_25': (8, 0x0ae, 28, True),
'logic_autolock_robust_peak_height_26': (8, 0x0b2, 28, True),
'logic_autolock_robust_peak_height_27': (8, 0x0b6, 28, True),
'logic_autolock_robust_peak_height_28': (8, 0x0ba, 28, True),
'logic_autolock_robust_peak_height_29': (8, 0x0be, 28, True),
'logic_autolock_robust_peak_height_30': (8, 0x0c2, 28, True),
'logic_autolock_robust_peak_height_31': (8, 0x0c6, 28, True),
'logic_autolock_robust_wait_for_0': (8, 0x0ca, 14, True),
'logic_autolock_robust_wait_for_1': (8, 0x0cc, 14, True),
'logic_autolock_robust_wait_for_2': (8, 0x0ce, 14, True),
'logic_autolock_robust_wait_for_3': (8, 0x0d0, 14, True),
'logic_autolock_robust_wait_for_4': (8, 0x0d2, 14, True),
'logic_autolock_robust_wait_for_5': (8, 0x0d4, 14, True),
'logic_autolock_robust_wait_for_6': (8, 0x0d6, 14, True),
'logic_autolock_robust_wait_for_7': (8, 0x0d8, 14, True),
'logic_autolock_robust_wait_for_8': (8, 0x0da, 14, True),
'logic_autolock_robust_wait_for_9': (8, 0x0dc, 14, True),
'logic_autolock_robust_wait_for_10': (8, 0x0de, 14, True),
'logic_autolock_robust_wait_for_11': (8, 0x0e0, 14, True),
'logic_autolock_robust_wait_for_12': (8, 0x0e2, 14, True),
'logic_autolock_robust_wait_for_13': (8, 0x0e4, 14, True),
'logic_autolock_robust_wait_for_14': (8, 0x0e6, 14, True),
'logic_autolock_robust_wait_for_15': (8, 0x0e8, 14, True),
'logic_autolock_robust_wait_for_16': (8, 0x0ea, 14, True),
'logic_autolock_robust_wait_for_17': (8, 0x0ec, 14, True),
'logic_autolock_robust_wait_for_18': (8, 0x0ee, 14, True),
'logic_autolock_robust_wait_for_19': (8, 0x0f0, 14, True),
'logic_autolock_robust_wait_for_20': (8, 0x0f2, 14, True),
'logic_autolock_robust_wait_for_21': (8, 0x0f4, 14, True),
'logic_autolock_robust_wait_for_22': (8, 0x0f6, 14, True),
'logic_autolock_robust_wait_for_23': (8, 0x0f8, 14, True),
'logic_autolock_robust_wait_for_24': (8, 0x0fa, 14, True),
'logic_autolock_robust_wait_for_25': (8, 0x0fc, 14, True),
'logic_autolock_robust_wait_for_26': (8, 0x0fe, 14, True),
'logic_autolock_robust_wait_for_27': (8, 0x100, 14, True),
'logic_autolock_robust_wait_for_28': (8, 0x102, 14, True),
'logic_autolock_robust_wait_for_29': (8, 0x104, 14, True),
'logic_autolock_robust_wait_for_30': (8, 0x106, 14, True),
'logic_autolock_robust_wait_for_31': (8, 0x108, 14, True),
'logic_autolock_fast_target_position': (8, 0x10a, 14, True),
'logic_autolock_request_lock': (8, 0x10c, 1, True),
'logic_autolock_autolock_mode': (8, 0x10d, 2, True),
'logic_autolock_lock_running': (8, 0x10e, 1, False),
'logic_raw_acquisition_iir_z0': (8, 0x10f, 27, True),
'logic_raw_acquisition_iir_a1': (8, 0x113, 25, True),
'logic_raw_acquisition_iir_a2': (8, 0x117, 25, True),
'logic_raw_acquisition_iir_a3': (8, 0x11b, 25, True),
'logic_raw_acquisition_iir_a4': (8, 0x11f, 25, True),
'logic_raw_acquisition_iir_a5': (8, 0x123, 25, True),
'logic_raw_acquisition_iir_b0': (8, 0x127, 25, True),
'logic_raw_acquisition_iir_b1': (8, 0x12b, 25, True),
'logic_raw_acquisition_iir_b2': (8, 0x12f, 25, True),
'logic_raw_acquisition_iir_b3': (8, 0x133, 25, True),
'logic_raw_acquisition_iir_b4': (8, 0x137, 25, True),
'logic_raw_acquisition_iir_b5': (8, 0x13b, 25, True),
'logic_control_signal_clr': (8, 0x13f, 1, True),
'logic_control_signal_max': (8, 0x140, 25, False),
'logic_control_signal_min': (8, 0x144, 25, False),
'logic_combined_error_signal_clr': (8, 0x148, 1, True),
'logic_combined_error_signal_max': (8, 0x149, 25, False),
'logic_combined_error_signal_min': (8, 0x14d, 25, False),
'logic_combined_error_signal_filtered_clr': (8, 0x151, 1, True),
'logic_combined_error_signal_filtered_max': (8, 0x152, 25, False),
'logic_combined_error_signal_filtered_min': (8, 0x156, 25, False),
'logic_control_slow_channel': (8, 0x010, 2, True),
'logic_fast_mode': (8, 0x011, 1, True),
'logic_slow_value': (8, 0x012, 14, False),
'logic_slow_decimation': (8, 0x014, 5, True),
'logic_analog_out_1': (8, 0x015, 15, True),
'logic_analog_out_2': (8, 0x017, 15, True),
'logic_analog_out_3': (8, 0x019, 15, True),
'logic_mod_amp': (8, 0x01b, 14, True),
'logic_mod_freq': (8, 0x01d, 32, True),
'logic_sweep_step': (8, 0x021, 30, True),
'logic_sweep_min': (8, 0x025, 14, True),
'logic_sweep_max': (8, 0x027, 14, True),
'logic_sweep_run': (8, 0x029, 1, True),
'logic_sweep_pause': (8, 0x02a, 1, True),
'logic_limit_error_signal_min': (8, 0x02b, 25, True),
'logic_limit_error_signal_max': (8, 0x02f, 25, True),
'logic_limit_fast1_min': (8, 0x033, 14, True),
'logic_limit_fast1_max': (8, 0x035, 14, True),
'logic_limit_fast2_min': (8, 0x037, 14, True),
'logic_limit_fast2_max': (8, 0x039, 14, True),
'logic_pid_setpoint': (8, 0x03b, 25, True),
'logic_pid_kp': (8, 0x03f, 14, True),
'logic_pid_ki': (8, 0x041, 14, True),
'logic_pid_reset': (8, 0x043, 1, True),
'logic_pid_kd': (8, 0x044, 14, True),
'logic_autolock_robust_time_scale': (8, 0x046, 14, True),
'logic_autolock_robust_N_instructions': (8, 0x048, 5, True),
'logic_autolock_robust_final_wait_time': (8, 0x049, 14, True),
'logic_autolock_robust_peak_height_0': (8, 0x04b, 28, True),
'logic_autolock_robust_peak_height_1': (8, 0x04f, 28, True),
'logic_autolock_robust_peak_height_2': (8, 0x053, 28, True),
'logic_autolock_robust_peak_height_3': (8, 0x057, 28, True),
'logic_autolock_robust_peak_height_4': (8, 0x05b, 28, True),
'logic_autolock_robust_peak_height_5': (8, 0x05f, 28, True),
'logic_autolock_robust_peak_height_6': (8, 0x063, 28, True),
'logic_autolock_robust_peak_height_7': (8, 0x067, 28, True),
'logic_autolock_robust_peak_height_8': (8, 0x06b, 28, True),
'logic_autolock_robust_peak_height_9': (8, 0x06f, 28, True),
'logic_autolock_robust_peak_height_10': (8, 0x073, 28, True),
'logic_autolock_robust_peak_height_11': (8, 0x077, 28, True),
'logic_autolock_robust_peak_height_12': (8, 0x07b, 28, True),
'logic_autolock_robust_peak_height_13': (8, 0x07f, 28, True),
'logic_autolock_robust_peak_height_14': (8, 0x083, 28, True),
'logic_autolock_robust_peak_height_15': (8, 0x087, 28, True),
'logic_autolock_robust_peak_height_16': (8, 0x08b, 28, True),
'logic_autolock_robust_peak_height_17': (8, 0x08f, 28, True),
'logic_autolock_robust_peak_height_18': (8, 0x093, 28, True),
'logic_autolock_robust_peak_height_19': (8, 0x097, 28, True),
'logic_autolock_robust_peak_height_20': (8, 0x09b, 28, True),
'logic_autolock_robust_peak_height_21': (8, 0x09f, 28, True),
'logic_autolock_robust_peak_height_22': (8, 0x0a3, 28, True),
'logic_autolock_robust_peak_height_23': (8, 0x0a7, 28, True),
'logic_autolock_robust_peak_height_24': (8, 0x0ab, 28, True),
'logic_autolock_robust_peak_height_25': (8, 0x0af, 28, True),
'logic_autolock_robust_peak_height_26': (8, 0x0b3, 28, True),
'logic_autolock_robust_peak_height_27': (8, 0x0b7, 28, True),
'logic_autolock_robust_peak_height_28': (8, 0x0bb, 28, True),
'logic_autolock_robust_peak_height_29': (8, 0x0bf, 28, True),
'logic_autolock_robust_peak_height_30': (8, 0x0c3, 28, True),
'logic_autolock_robust_peak_height_31': (8, 0x0c7, 28, True),
'logic_autolock_robust_wait_for_0': (8, 0x0cb, 14, True),
'logic_autolock_robust_wait_for_1': (8, 0x0cd, 14, True),
'logic_autolock_robust_wait_for_2': (8, 0x0cf, 14, True),
'logic_autolock_robust_wait_for_3': (8, 0x0d1, 14, True),
'logic_autolock_robust_wait_for_4': (8, 0x0d3, 14, True),
'logic_autolock_robust_wait_for_5': (8, 0x0d5, 14, True),
'logic_autolock_robust_wait_for_6': (8, 0x0d7, 14, True),
'logic_autolock_robust_wait_for_7': (8, 0x0d9, 14, True),
'logic_autolock_robust_wait_for_8': (8, 0x0db, 14, True),
'logic_autolock_robust_wait_for_9': (8, 0x0dd, 14, True),
'logic_autolock_robust_wait_for_10': (8, 0x0df, 14, True),
'logic_autolock_robust_wait_for_11': (8, 0x0e1, 14, True),
'logic_autolock_robust_wait_for_12': (8, 0x0e3, 14, True),
'logic_autolock_robust_wait_for_13': (8, 0x0e5, 14, True),
'logic_autolock_robust_wait_for_14': (8, 0x0e7, 14, True),
'logic_autolock_robust_wait_for_15': (8, 0x0e9, 14, True),
'logic_autolock_robust_wait_for_16': (8, 0x0eb, 14, True),
'logic_autolock_robust_wait_for_17': (8, 0x0ed, 14, True),
'logic_autolock_robust_wait_for_18': (8, 0x0ef, 14, True),
'logic_autolock_robust_wait_for_19': (8, 0x0f1, 14, True),
'logic_autolock_robust_wait_for_20': (8, 0x0f3, 14, True),
'logic_autolock_robust_wait_for_21': (8, 0x0f5, 14, True),
'logic_autolock_robust_wait_for_22': (8, 0x0f7, 14, True),
'logic_autolock_robust_wait_for_23': (8, 0x0f9, 14, True),
'logic_autolock_robust_wait_for_24': (8, 0x0fb, 14, True),
'logic_autolock_robust_wait_for_25': (8, 0x0fd, 14, True),
'logic_autolock_robust_wait_for_26': (8, 0x0ff, 14, True),
'logic_autolock_robust_wait_for_27': (8, 0x101, 14, True),
'logic_autolock_robust_wait_for_28': (8, 0x103, 14, True),
'logic_autolock_robust_wait_for_29': (8, 0x105, 14, True),
'logic_autolock_robust_wait_for_30': (8, 0x107, 14, True),
'logic_autolock_robust_wait_for_31': (8, 0x109, 14, True),
'logic_autolock_fast_target_position': (8, 0x10b, 14, True),
'logic_autolock_request_lock': (8, 0x10d, 1, True),
'logic_autolock_autolock_mode': (8, 0x10e, 2, True),
'logic_autolock_lock_running': (8, 0x10f, 1, False),
'logic_raw_acquisition_iir_z0': (8, 0x110, 27, True),
'logic_raw_acquisition_iir_a1': (8, 0x114, 25, True),
'logic_raw_acquisition_iir_a2': (8, 0x118, 25, True),
'logic_raw_acquisition_iir_a3': (8, 0x11c, 25, True),
'logic_raw_acquisition_iir_a4': (8, 0x120, 25, True),
'logic_raw_acquisition_iir_a5': (8, 0x124, 25, True),
'logic_raw_acquisition_iir_b0': (8, 0x128, 25, True),
'logic_raw_acquisition_iir_b1': (8, 0x12c, 25, True),
'logic_raw_acquisition_iir_b2': (8, 0x130, 25, True),
'logic_raw_acquisition_iir_b3': (8, 0x134, 25, True),
'logic_raw_acquisition_iir_b4': (8, 0x138, 25, True),
'logic_raw_acquisition_iir_b5': (8, 0x13c, 25, True),
'logic_control_signal_clr': (8, 0x140, 1, True),
'logic_control_signal_max': (8, 0x141, 25, False),
'logic_control_signal_min': (8, 0x145, 25, False),
'logic_combined_error_signal_clr': (8, 0x149, 1, True),
'logic_combined_error_signal_max': (8, 0x14a, 25, False),
'logic_combined_error_signal_min': (8, 0x14e, 25, False),
'logic_combined_error_signal_filtered_clr': (8, 0x152, 1, True),
'logic_combined_error_signal_filtered_max': (8, 0x153, 25, False),
'logic_combined_error_signal_filtered_min': (8, 0x157, 25, False),
'scopegen_external_trigger': (6, 0x000, 1, True),
'scopegen_dac_a_clr': (6, 0x001, 1, True),
'scopegen_dac_a_max': (6, 0x002, 25, False),
Expand Down
Binary file modified linien-server/linien_server/linien.bin
Binary file not shown.
6 changes: 6 additions & 0 deletions linien-server/linien_server/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self):
"mod_channel",
"control_channel",
"sweep_channel",
"control_slow_channel",
"polarity_fast_out1",
"polarity_fast_out2",
"polarity_analog_out0",
Expand Down Expand Up @@ -155,6 +156,11 @@ def __init__(self):
# configures the output of the lock signal. A value of 0 means
# FAST OUT 1 and a value of 1 corresponds to FAST OUT 2
self.control_channel = Parameter(start=1, min_=0, max_=1)
# configures the output of the slow PID control:
# 0 --> FAST OUT 1
# 1 --> FAST OUT 2
# 2 --> ANALOG OUT 0 (slow channel)
self.control_slow_channel = Parameter(start=2, min_=0, max_=2)

# set the output of GPIO pins. Each bit corresponds to one pin, i.e.:
# parameters.gpio_p_out.value = 0b11110000
Expand Down
Loading

0 comments on commit cf61773

Please sign in to comment.