From 829f8f58c26a1925e9c4ce979382cbb1b582bd19 Mon Sep 17 00:00:00 2001 From: Arnaud Watlet <arnaud.watlet@umons.ac.be> Date: Wed, 6 Dec 2023 23:01:35 +0100 Subject: [PATCH] Adds vmax settings in default settings so that they can be passed with update_settings --- ohmpi/hardware_system.py | 4 +++- ohmpi/ohmpi.py | 16 ++++++++++++++-- settings/default.json | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index acacb318..0028e61b 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -407,7 +407,7 @@ class OhmPiHardware: return new_vab def compute_tx_volt(self, pulse_duration=0.1, strategy='vmax', tx_volt=5., vab_max=None, - iab_max=None, vmn_max=None, vmn_min=voltage_min, polarities=(1, -1), delay=0.05, + iab_max=None, vmn_max=None, vmn_min=None, polarities=(1, -1), delay=0.05, p_max=None, diff_vab_lim=2.5, n_steps=4): # TODO: Optimise how to pass iab_max, vab_max, vmn_min # TODO: Update docstring @@ -458,6 +458,8 @@ class OhmPiHardware: iab_max = current_max if vab_max is None: vab_max = voltage_max + if vmn_min is None: + vmn_min = voltage_min # print(f'Vmn max: {vmn_max}') if p_max is None: p_max = vab_max * iab_max diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index bc4a537f..c6a7a137 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -452,7 +452,7 @@ class OhmPi(object): os.system('poweroff') # this may require admin rights def run_measurement(self, quad=None, nb_stack=None, injection_duration=None, duty_cycle=None, - autogain=True, strategy='constant', tx_volt=5., best_tx_injtime=0.1, + autogain=True, strategy=None, tx_volt=None, best_tx_injtime=0.1, cmd_id=None, vab_max=None, iab_max=None, vmn_max=None, vmn_min=None, **kwargs): # TODO: add sampling_interval -> impact on _hw.rx.sampling_rate (store the current value, change the _hw.rx.sampling_rate, do the measurement, reset the sampling_rate to the previous value) # TODO: default value of tx_volt and other parameters set to None should be given in config.py and used in function definition @@ -514,10 +514,22 @@ class OhmPi(object): injection_duration = self.settings['injection_duration'] if duty_cycle is None: duty_cycle = self.settings['duty_cycle'] + if tx_volt is None: + tx_volt = self.settings['tx_volt'] + if strategy is None: + strategy = self.settings['strategy'] + if vab_max is None: + vab_max = self.settings['vab_max'] + if iab_max is None: + iab_max = self.settings['iab_max'] + if vmn_max is None: + vmn_max = self.settings['vmn_max'] + if vmn_min is None: + vmn_min = self.settings['vmn_min'] bypass_check = kwargs['bypass_check'] if 'bypass_check' in kwargs.keys() else False d = {} if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id): - tx_volt = self._hw.compute_tx_volt(tx_volt=tx_volt, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, iab_max=iab_max) # TODO: use tx_volt and vmn_max instead of hardcoded values + tx_volt = self._hw.compute_tx_volt(tx_volt=tx_volt, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, iab_max=iab_max, vmn_min=vmn_min) # TODO: use tx_volt and vmn_max instead of hardcoded values time.sleep(0.5) # to wait for pwr discharge self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle) if 'delay' in kwargs.keys(): diff --git a/settings/default.json b/settings/default.json index a0178639..dce3250f 100644 --- a/settings/default.json +++ b/settings/default.json @@ -7,6 +7,10 @@ "tx_volt": 5, "duty_cycle": 0.5, "strategy": "constant", + "iab_max": null, + "vab_max": null, + "vmn_max": null, + "vmn_min": null, "fw_in_csv": true, "fw_in_zip": true, "export_path": "data/measurements.csv" -- GitLab