diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py index f9ae9368f2ec997d3fdf598b97a4644993e061de..7ba2a1652aa1d34523076bb589523293f70863d1 100644 --- a/ohmpi/hardware_components/mb_2023_0_X.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -21,6 +21,7 @@ SPECS = {'rx': {'model': {'default': os.path.basename(__file__).rstrip('.py')}, 'mcp_address': {'default': None}, 'ads_address': {'default': 0x49}, 'voltage_min': {'default': 10.0}, + 'voltage_max': {'default': 5000.0}, # [mV] 'vmn_hardware_offset': {'default': 0.} }, 'tx': {'model': {'default': os.path.basename(__file__).rstrip('.py')}, diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py index 33fe7ee461234b44c7a711558b96b85f5dc0742f..99f3883315f9116f9c26e67f8c7ad99e49b8afb9 100644 --- a/ohmpi/hardware_components/mb_2024_0_2.py +++ b/ohmpi/hardware_components/mb_2024_0_2.py @@ -21,6 +21,7 @@ SPECS = {'rx': {'model': {'default': os.path.basename(__file__).rstrip('.py')}, 'mcp_address': {'default': 0x27}, 'ads_address': {'default': 0x49}, 'voltage_min': {'default': 10.0}, + 'voltage_max': {'default': 5000.0}, # [mV] 'dg411_gain_ratio': {'default': 1/2}, # lowest resistor value over sum of resistor values 'vmn_hardware_offset': {'default': 2500.}, }, diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 4c817bacc10f4eb28ce23162319ebde91b98c8af..1b49bb51be3cfb8d87295089666b1817ef8462ce 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -355,7 +355,8 @@ class OhmPiHardware: return new_vab def _compute_tx_volt(self, pulse_duration=0.1, strategy='vmax', tx_volt=5., vab_max=voltage_max, - iab_max=current_max, vmn_max=5., vmn_min=voltage_min, polarities=(1, -1), delay=0.050): + iab_max=current_max, vmn_max=None, vmn_min=voltage_min, polarities=(1, -1), delay=0.05, + diff_vab_lim=2.5, n_steps=4): # TODO: Optimise how to pass iab_max, vab_max, vmn_min """Estimates best Tx voltage based on different strategies. At first a half-cycle is made for a short duration with a fixed @@ -397,12 +398,12 @@ class OhmPiHardware: """ if self.tx.pwr.voltage_adjustable: - # Get those values from components + if vmn_max is None: + vmn_max == self.rx._voltage_max / 1000. p_max = vab_max * iab_max # define a sill - diff_vab_lim = 2.5 - n_steps = 4 + # Set gain at min self.rx.reset_gain() diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index 165e2c5bc57b714b6452cc451555da2220240206..e82a5bad50ec6468844ce8a36703b51ef2e7c065 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -442,7 +442,7 @@ class OhmPi(object): 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, - cmd_id=None, **kwargs): + cmd_id=None, vmn_max=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 # TODO: add rs_check option (or propose an other way to do this) @@ -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, vab_max=50., vmn_max=1.) # 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) # 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']