Commit 38f4321f authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

Adds default values in pwr dps at init

Showing with 24 additions and 29 deletions
+24 -29
......@@ -131,7 +131,7 @@ class Tx(Tx_mb_2023):
self._pwr_state = 'off'
def current_pulse(self, current=None, length=None, polarity=1):
""" Generates a square voltage pulse
""" Generates a square current pulse. Currenttly no DPS can handle this...
Parameters
----------
......@@ -148,7 +148,7 @@ class Tx(Tx_mb_2023):
length = self.injection_duration
if current is not None:
self.pwr.current = current
self.exec_logger.debug(f'Current pulse of {polarity*self.pwr.voltage:.3f} V for {length:.3f} s')
self.exec_logger.debug(f'Current pulse of {polarity*self.pwr.current:.3f} V for {length:.3f} s')
self.inject(polarity=polarity, injection_duration=length)
self.exec_logger.event(f'{self.model}\ttx_current_pulse\tend\t{datetime.datetime.utcnow()}')
......
......@@ -37,11 +37,13 @@ class Pwr(PwrAbstract):
self._voltage_max = kwargs['voltage_max']
self._power_max = kwargs['power_max']
self._current_max_tolerance = kwargs['current_max_tolerance']
self.voltage_default(self._voltage)
self.current_max_default(self._current_max)
self.current_max = self._current_max
self.voltage_max = self._voltage_max
self.power_max(self._power_max)
if self.connect:
self.voltage_default(self._voltage)
self.current_max_default(self._current_max)
self.current_max = self._current_max
self.current_overload = self._current_max
self.voltage_max = self._voltage_max
self.power_max(self._power_max)
self.voltage_adjustable = True
self.current_adjustable = False
self._current = np.nan
......@@ -53,13 +55,13 @@ class Pwr(PwrAbstract):
def _retrieve_current(self):
self._current = self.connection.read_register(0x0003, 2) * 100 # in mA (not sure why but value from DPS comes in [A*10]
# @property
# def current(self):
# return self._current
#
# @current.setter
# def current(self, value, **kwargs):
# self.exec_logger.debug(f'Current cannot be set on {self.model}')
@property
def current(self):
return self._current
@current.setter
def current(self, value, **kwargs):
self.exec_logger.debug(f'Current cannot be set on {self.model}')
def _retrieve_voltage(self):
self._voltage = self.connection.read_register(0x0002, 2)
......@@ -89,30 +91,23 @@ class Pwr(PwrAbstract):
self.connection.write_register(0x0052, np.round(value, 2), 2)
self._voltage_max = value
def battery_voltage(self):
self._battery_voltage = self.connection.read_register(0x05, 2)
return self._battery_voltage
@property
def current(self):
return self._current
@current.setter
def current(self, value, **kwargs):
# value = value # To set DPS max current slightly above (20%) the limit to avoid regulation artefacts
self.connection.write_register(0x0001, np.round((value), 3), 3)
self._current = value
# self.exec_logger.debug(f'Current cannot be set on {self.model}')
@property
def current_max(self):
return self._current_max
@current_max.setter
def current_max(self, value): # [A]
def current_max(self, value):
new_value = value * (
1 + self._current_max_tolerance / 100) # To set DPS max current slightly above (20% by default) the limit to avoid regulation artefacts
self.connection.write_register(0x0001, np.round((new_value), 3), 3)
self._current_max = value
def current_overload(self, value): # [A]
new_value = value * (1 + self._current_max_tolerance / 100) # To set DPS max current slightly above (20% by default) the limit to avoid regulation artefacts
print(new_value)
self.connection.write_register(0x0053, np.round((new_value), 3), 3)
self._current_max = value
......
......@@ -148,7 +148,7 @@ class OhmPiHardware:
self.pwr_state = 'off'
self.tx.pwr = self.pwr
self.tx.pwr._current_max = self.current_max
# self.tx.pwr._current_max = self.current_max
# Initialize Muxes
self._cabling = kwargs.pop('cabling', {})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment