Commit 7e6ad486 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Updates hardware_system to handle no mux

Showing with 11 additions and 7 deletions
+11 -7
...@@ -17,6 +17,7 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.}, ...@@ -17,6 +17,7 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.},
'data_rate': {'default': 860.}, 'data_rate': {'default': 860.},
'bias': {'min': -5000., 'default': 0., 'max': 5000.}, 'bias': {'min': -5000., 'default': 0., 'max': 5000.},
'coef_p2': {'default': 2.50}, 'coef_p2': {'default': 2.50},
'mcp_address': {'default': None},
'voltage_min': {'default': 10.0}, 'voltage_min': {'default': 10.0},
'vmn_hardware_offset': {'default': 0.} 'vmn_hardware_offset': {'default': 0.}
}, },
...@@ -24,6 +25,7 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.}, ...@@ -24,6 +25,7 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.},
'adc_voltage_max': {'default': 4500.}, # Maximum voltage on ads1115 used to measure current 'adc_voltage_max': {'default': 4500.}, # Maximum voltage on ads1115 used to measure current
'voltage_max': {'min': 0., 'default': 12., 'max': 12.}, # Maximum input voltage 'voltage_max': {'min': 0., 'default': 12., 'max': 12.}, # Maximum input voltage
'data_rate': {'default': 860.}, 'data_rate': {'default': 860.},
'mcp_address': {'default': 0x20},
'compatible_power_sources': {'default': 'pwr_batt', 'others' : ['dps5005']}, 'compatible_power_sources': {'default': 'pwr_batt', 'others' : ['dps5005']},
'r_shunt': {'min': 0., 'default': 2. }, 'r_shunt': {'min': 0., 'default': 2. },
'activation_delay': {'default': 0.005}, # Max turn on time of 211EH relays = 5ms 'activation_delay': {'default': 0.005}, # Max turn on time of 211EH relays = 5ms
...@@ -78,7 +80,7 @@ class Tx(TxAbstract): ...@@ -78,7 +80,7 @@ class Tx(TxAbstract):
self.current_adjustable = False self.current_adjustable = False
# I2C connexion to MCP23008, for current injection # I2C connexion to MCP23008, for current injection
self.mcp_board = MCP23008(self.connection, address=0x20) self.mcp_board = MCP23008(self.connection, address=kwargs['mcp_address'])
# ADS1115 for current measurement (AB) # ADS1115 for current measurement (AB)
self._ads_current_address = 0x48 self._ads_current_address = 0x48
self._ads_current_data_rate = kwargs['data_rate'] self._ads_current_data_rate = kwargs['data_rate']
......
...@@ -13,7 +13,8 @@ from ohmpi.hardware_components.mb_2023_0_X import Rx as Rx_mb_2023 ...@@ -13,7 +13,8 @@ from ohmpi.hardware_components.mb_2023_0_X import Rx as Rx_mb_2023
SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.}, SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.},
'data_rate': {'default': 860.}, 'data_rate': {'default': 860.},
'bias': {'min': -5000., 'default': 0., 'max': 5000.}, 'bias': {'min': -5000., 'default': 0., 'max': 5000.},
'coef_p2': {'default': 2.50}, 'coef_p2': {'default': 1.00},
'mcp_address': {'default': 0x27},
'voltage_min': {'default': 10.0}, 'voltage_min': {'default': 10.0},
'vmn_hardware_offset' : {'default': 2500.}, 'vmn_hardware_offset' : {'default': 2500.},
}, },
...@@ -21,8 +22,9 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.}, ...@@ -21,8 +22,9 @@ SPECS = {'rx': {'sampling_rate': {'min': 2., 'default': 10., 'max': 100.},
'adc_voltage_max': {'default': 4500.}, # Maximum voltage on ads1115 used to measure current 'adc_voltage_max': {'default': 4500.}, # Maximum voltage on ads1115 used to measure current
'voltage_max': {'min': 0., 'default': 12., 'max': 12.}, # Maximum input voltage 'voltage_max': {'min': 0., 'default': 12., 'max': 12.}, # Maximum input voltage
'data_rate': {'default': 860.}, 'data_rate': {'default': 860.},
'mcp_address': {'default': 0x21},
'compatible_power_sources': {'default': 'pwr_batt', 'others' : ['dps5005']}, 'compatible_power_sources': {'default': 'pwr_batt', 'others' : ['dps5005']},
'r_shunt': {'min': 0., 'default': 2. }, 'r_shunt': {'min': 0., 'default': 2.},
'activation_delay': {'default': 0.010}, # Max turn on time of OMRON G5LE-1 5VDC relays 'activation_delay': {'default': 0.010}, # Max turn on time of OMRON G5LE-1 5VDC relays
'release_delay': {'default': 0.005}, # Max turn off time of OMRON G5LE-1 5VDC relays = 1ms 'release_delay': {'default': 0.005}, # Max turn off time of OMRON G5LE-1 5VDC relays = 1ms
}} }}
...@@ -81,8 +83,8 @@ class Tx(Tx_mb_2023): ...@@ -81,8 +83,8 @@ class Tx(Tx_mb_2023):
class Rx(Rx_mb_2023): class Rx(Rx_mb_2023):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
# I2C connexion to MCP23008, for current injection # I2C connexion to MCP23008, for voltage
self.mcp_board = MCP23008(self.connection, address=0x27) self.mcp_board = MCP23008(self.connection, address=kwargs['mcp_address'])
# ADS1115 for voltage measurement (MN) # ADS1115 for voltage measurement (MN)
self._coef_p2 = 1. self._coef_p2 = 1.
# Define default DG411 gain # Define default DG411 gain
...@@ -94,12 +96,12 @@ class Rx(Rx_mb_2023): ...@@ -94,12 +96,12 @@ class Rx(Rx_mb_2023):
self.pin_DG1.direction = Direction.OUTPUT self.pin_DG1.direction = Direction.OUTPUT
self.pin_DG2 = self.mcp_board.get_pin(2) self.pin_DG2 = self.mcp_board.get_pin(2)
self.pin_DG2.direction = Direction.OUTPUT self.pin_DG2.direction = Direction.OUTPUT
# TODO: try to only log this event and not the one created by super()
self.exec_logger.event(f'{self.board_name}\trx_init\tend\t{datetime.datetime.utcnow()}')
self.pin_DG0.value = True # open self.pin_DG0.value = True # open
self.pin_DG1.value = True # open gain 1 inactive self.pin_DG1.value = True # open gain 1 inactive
self.pin_DG2.value = False # close gain 0.5 active self.pin_DG2.value = False # close gain 0.5 active
self.gain = 1/3 self.gain = 1/3
# TODO: try to only log this event and not the one created by super()
self.exec_logger.event(f'{self.board_name}\trx_init\tend\t{datetime.datetime.utcnow()}')
def _dg411_gain_auto(self): def _dg411_gain_auto(self):
u = ((AnalogIn(self.ads_voltage, ads.P0).voltage * 1000) - self._vmn_hardware_offset) / self.voltage_gain u = ((AnalogIn(self.ads_voltage, ads.P0).voltage * 1000) - self._vmn_hardware_offset) / self.voltage_gain
......
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