From f9c9615aebf9f7290f25bfdebe5dcce227740946 Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Thu, 19 Oct 2023 16:14:44 +0200 Subject: [PATCH] Tests pwr_latency --- ohmpi/hardware_components/abstract_hardware_components.py | 4 +++- ohmpi/hardware_components/pwr_dps5005.py | 2 +- ohmpi/hardware_system.py | 3 --- ohmpi/ohmpi.py | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ohmpi/hardware_components/abstract_hardware_components.py b/ohmpi/hardware_components/abstract_hardware_components.py index 146cdfc8..be1e51e2 100644 --- a/ohmpi/hardware_components/abstract_hardware_components.py +++ b/ohmpi/hardware_components/abstract_hardware_components.py @@ -55,6 +55,7 @@ class PwrAbstract(ABC): self._current_max = kwargs.pop('current_max', 0.) self._voltage_min = kwargs.pop('voltage_min', 0.) self._voltage_max = kwargs.pop('voltage_max', 0.) + self._switchable = False self.connection = kwargs.pop('connection', None) self._battery_voltage = np.nan @@ -422,7 +423,8 @@ class TxAbstract(ABC): def pwr_state(self, state): if state == 'on': self._pwr_state = 'on' - self.exec_logger.debug(f'{self.model} cannot switch on power source') + if not self.pwr.switchable: + self.exec_logger.debug(f'{self.model} cannot switch on power source') self.pwr.reload_settings() elif state == 'off': self._pwr_state = 'off' diff --git a/ohmpi/hardware_components/pwr_dps5005.py b/ohmpi/hardware_components/pwr_dps5005.py index f018ab7a..13fed777 100644 --- a/ohmpi/hardware_components/pwr_dps5005.py +++ b/ohmpi/hardware_components/pwr_dps5005.py @@ -14,7 +14,7 @@ SPECS = {'model': {'default': os.path.basename(__file__).rstrip('.py')}, 'current_max': {'default': 60.}, 'current_adjustable': {'default': False}, 'voltage_adjustable': {'default': True}, - 'pwr_latency': {'default': .3} + 'pwr_latency': {'default': .5} } # TODO: Complete this code... handle modbus connection diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 6356e09b..7ac3f947 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -329,9 +329,6 @@ class OhmPiHardware: # bounds on vmn vmn_upper_bound = vmn_mean + 2 * vmn_std vmn_lower_bound = np.max([0.000001, vmn_mean - 2 * vmn_std]) - # ax.plot([vab[k]] * 2, [vmn_lower_bound, vmn_upper_bound], '-b') - # ax.plot([0, vab_max], [0, vmn_upper_bound * vab_max / vab[k]], '-r', alpha=(k + 1) / n_steps) - # ax.plot([0, vab_max], [0, vmn_lower_bound * vab_max / vab[k]], '-g', alpha=(k + 1) / n_steps) # bounds on rab rab_lower_bound = np.max([0.1, np.abs(vab / iab_upper_bound)]) rab_upper_bound = np.max([0.1, np.abs(vab / iab_lower_bound)]) diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index de9ed31f..8ffa5ce4 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -500,7 +500,7 @@ class OhmPi(object): 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=.5, strategy=strategy, vmn_max=5.) # TODO: use tx_ + tx_volt = self._hw._compute_tx_volt(tx_volt=.5, strategy=strategy, vmn_max=5.) # TODO: use tx_volt and vmn_max instead of hardcoded values 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(): delay = kwargs['delay'] @@ -528,7 +528,7 @@ class OhmPi(object): "nbStack": nb_stack, "Tx [V]": tx_volt, "CPU temp [degC]": self._hw.ctl.cpu_temperature, - "Nb samples [-]": len(self._hw.readings), # TODO: use only samples after a delay in each pulse + "Nb samples [-]": len(self._hw.readings[x,2]), # TODO: use only samples after a delay in each pulse "fulldata": self._hw.readings[:, [0, -2, -1]], # "I_stack [mA]": i_stack_mean, "I_std [%]": I_std, -- GitLab