From f6b37f5e67782fecc9dbd74e1e5aa101372a297b Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Tue, 26 Sep 2023 17:57:28 +0200 Subject: [PATCH] Renames io as connection; renames mux_2023_rev_0_0 and mux_2024_rev_0_0 as mux_2023_0_X and mux_2024_0_X; renames ohmpi_card_3_15 as mb_2023_0_X --- configs/config_mb_2023_2_mux_2024.py | 10 +++++----- configs/config_mb_2023_3_mux_2024.py | 12 +++++------ configs/config_mb_2023_4_mux_2023.py | 12 +++++------ configs/config_mb_2023_4_mux_2024.py | 14 ++++++------- configs/config_mb_2023_mux_2024.py | 8 ++++---- configs/config_mb_2023_mux_2024_2_roles_AB.py | 9 ++++----- configs/config_mb_2023_mux_2024_2_roles_MN.py | 6 +++--- configs/config_tmp.py | 4 ++-- dev/test_2_mux_2024.py | 2 +- dev/test_3_mux_2024.py | 2 +- dev/test_4_mux_2024.py | 2 +- ...ohmpi_card_3_15.py => test_mb_2023_0_X.py} | 4 ++-- ...15.py => test_measure_with_mb_2023_0_X.py} | 0 dev/test_mux_2024.py | 2 +- dev/test_mux_2024_2_roles_AB.py | 2 +- .../abstract_hardware_components.py | 10 +++++----- .../{ohmpi_card_3_15.py => mb_2023_0_X.py} | 14 ++++++------- ohmpi/hardware_components/mb_2024_0_2.py | 4 ++-- .../{mux_2023_rev_0_0.py => mux_2023_0_X.py} | 2 +- .../{mux_2024_rev_0_0.py => mux_2024_0_X.py} | 7 +++---- ohmpi/hardware_components/pwr_dps5005.py | 12 +++++------ ohmpi/hardware_components/raspberry_pi.py | 20 +++++++++---------- ohmpi/hardware_system.py | 2 +- 23 files changed, 79 insertions(+), 81 deletions(-) rename dev/{test_ohmpi_card_3_15.py => test_mb_2023_0_X.py} (88%) rename dev/{test_measure_with_ohmpi_card_3_15.py => test_measure_with_mb_2023_0_X.py} (100%) rename ohmpi/hardware_components/{ohmpi_card_3_15.py => mb_2023_0_X.py} (94%) rename ohmpi/hardware_components/{mux_2023_rev_0_0.py => mux_2023_0_X.py} (98%) rename ohmpi/hardware_components/{mux_2024_rev_0_0.py => mux_2024_0_X.py} (96%) diff --git a/configs/config_mb_2023_2_mux_2024.py b/configs/config_mb_2023_2_mux_2024.py index 3b0e8cad..74645aaf 100644 --- a/configs/config_mb_2023_2_mux_2024.py +++ b/configs/config_mb_2023_2_mux_2024.py @@ -18,15 +18,15 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model': 'raspberry_pi_i2c'}, + 'ctl': {'model': 'raspberry_pi'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, - 'tx': {'model': 'ohmpi_card_3_15', + 'tx': {'model': 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx': {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V 'latency': 0.010, # latency in seconds in continuous mode 'sampling_rate': 50 # number of samples per second @@ -36,7 +36,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_1': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x22', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... @@ -45,7 +45,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+8, j): ('mux_1', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_2': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x24', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/configs/config_mb_2023_3_mux_2024.py b/configs/config_mb_2023_3_mux_2024.py index a4134e6d..78673566 100644 --- a/configs/config_mb_2023_3_mux_2024.py +++ b/configs/config_mb_2023_3_mux_2024.py @@ -18,15 +18,15 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model': 'raspberry_pi', 'connection': 'i2c'}, + 'ctl': {'model': 'raspberry_pi'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, - 'tx': {'model': 'ohmpi_card_3_15', + 'tx': {'model': 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx': {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V 'latency': 0.010, # latency in seconds in continuous mode 'sampling_rate': 50 # number of samples per second @@ -36,7 +36,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_02': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x22', # TODO: Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... @@ -45,7 +45,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_00': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x24', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... @@ -54,7 +54,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+16, j): ('mux_00', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_04': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x26', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/configs/config_mb_2023_4_mux_2023.py b/configs/config_mb_2023_4_mux_2023.py index 0c0309a2..7d7fa2fd 100644 --- a/configs/config_mb_2023_4_mux_2023.py +++ b/configs/config_mb_2023_4_mux_2023.py @@ -20,13 +20,13 @@ OHMPI_CONFIG = { HARDWARE_CONFIG = { 'ctl': {'model': 'raspberry_pi'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, - 'tx': {'model': 'ohmpi_card_3_15', + 'tx': {'model': 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx': {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'nb_samples': 20, # Max value 10 # was named integer before... }, @@ -35,25 +35,25 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_1': - {'model': 'mux_2023_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2023_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x70, 'roles': {'A': 'X'}, 'cabling': {(i, j): ('mux_1', i) for j in ['A'] for i in range(1, 65)}, 'voltage_max': 12.}, 'mux_2': - {'model': 'mux_2023_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2023_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x71, 'roles': {'B': 'X'}, 'cabling': {(i, j): ('mux_2', i) for j in ['B'] for i in range(1, 65)}, 'voltage_max': 12.}, 'mux_3': - {'model': 'mux_2023_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2023_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x72, 'roles': {'M': 'X'}, 'cabling': {(i, j): ('mux_3', i) for j in ['M'] for i in range(1, 65)}, 'voltage_max': 12.}, 'mux_4': - {'model': 'mux_2023_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2023_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x73, 'roles': {'N': 'X'}, 'cabling': {(i, j): ('mux_4', i) for j in ['N'] for i in range(1, 65)}, diff --git a/configs/config_mb_2023_4_mux_2024.py b/configs/config_mb_2023_4_mux_2024.py index 66dbfda3..23689580 100644 --- a/configs/config_mb_2023_4_mux_2024.py +++ b/configs/config_mb_2023_4_mux_2024.py @@ -18,15 +18,15 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model': 'raspberry_pi_i2c'}, + 'ctl': {'model': 'raspberry_pi'}, 'pwr': {'model': 'pwr_batt', 'voltage': 12.}, - 'tx': {'model': 'ohmpi_card_3_15', + 'tx': {'model': 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx': {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V 'latency': 0.010, # latency in seconds in continuous mode 'sampling_rate': 50 # number of samples per second @@ -36,7 +36,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_02': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x77, 'tca_channel': 0, 'mcp_0': '0x22', # NOTE: Check pos of jumper on MUX board (refer to doc) @@ -45,7 +45,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+8, j): ('mux_02', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, # TODO: avoid redundency of mux_id 'voltage_max': 12.}, 'mux_05': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x77, 'tca_channel': 0, 'mcp_0': '0x26', # NOTE: Check pos of jumper on MUX board (refer to doc) @@ -54,7 +54,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+16, j): ('mux_05', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_04': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x77, 'tca_channel': 1, 'mcp_0': '0x24', # NOTE: Check pos of jumper on MUX board (refer to doc) @@ -63,7 +63,7 @@ HARDWARE_CONFIG = { 'cabling': {(i+24, j): ('mux_04', i) for j in ['A', 'B', 'M', 'N'] for i in range(1, 9)}, 'voltage_max': 12.}, 'mux_03': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': 0x77, 'tca_channel': 1, 'mcp_0': '0x26', # NOTE: Check pos of jumper on MUX board (refer to doc) diff --git a/configs/config_mb_2023_mux_2024.py b/configs/config_mb_2023_mux_2024.py index f8075ecd..e78a44a6 100644 --- a/configs/config_mb_2023_mux_2024.py +++ b/configs/config_mb_2023_mux_2024.py @@ -18,16 +18,16 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model' : 'raspberry_pi_i2c' + 'ctl': {'model' : 'raspberry_pi' }, 'pwr': {'model' : 'pwr_batt', 'voltage': 12.}, - 'tx' : {'model' : 'ohmpi_card_3_15', + 'tx' : {'model' : 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx': {'model': 'ohmpi_card_3_15', + 'rx': {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'sampling_rate': 100., # Hz 'nb_samples': 20, # Max value 10 # was named integer before... @@ -37,7 +37,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_1': - {'model' : 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model' : 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0' : '0x22', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/configs/config_mb_2023_mux_2024_2_roles_AB.py b/configs/config_mb_2023_mux_2024_2_roles_AB.py index 0b04b948..42fe5c13 100644 --- a/configs/config_mb_2023_mux_2024_2_roles_AB.py +++ b/configs/config_mb_2023_mux_2024_2_roles_AB.py @@ -18,16 +18,15 @@ OHMPI_CONFIG = { } HARDWARE_CONFIG = { - 'ctl': {'model' : 'raspberry_pi_i2c' - }, + 'ctl': {'model' : 'raspberry_pi'}, 'pwr': {'model' : 'pwr_batt', 'voltage': 12.}, - 'tx' : {'model' : 'ohmpi_card_3_15', + 'tx' : {'model' : 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx' : {'model': 'ohmpi_card_3_15', + 'rx' : {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'sampling_rate': 100., # Hz 'nb_samples': 20, # Max value 10 # was named integer before... @@ -37,7 +36,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_1': - {'model': 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model': 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x22', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/configs/config_mb_2023_mux_2024_2_roles_MN.py b/configs/config_mb_2023_mux_2024_2_roles_MN.py index 04057da5..d5ea1a50 100644 --- a/configs/config_mb_2023_mux_2024_2_roles_MN.py +++ b/configs/config_mb_2023_mux_2024_2_roles_MN.py @@ -21,13 +21,13 @@ HARDWARE_CONFIG = { 'ctl': {'model' : 'raspberry_pi_i2c' }, 'pwr': {'model' : 'pwr_batt', 'voltage': 12.}, - 'tx' : {'model' : 'ohmpi_card_3_15', + 'tx' : {'model' : 'mb_2023_0_X', 'mcp_board_address': 0x20, 'voltage_max': 12., # Maximum voltage supported by the TX board [V] 'current_max': 4800 / 50 / 2, # Maximum current supported by the TX board [mA] 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx' : {'model': 'ohmpi_card_3_15', + 'rx' : {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'sampling_rate': 100., # Hz 'nb_samples': 20, # Max value 10 # was named integer before... @@ -37,7 +37,7 @@ HARDWARE_CONFIG = { # both will be overwritten by properties specified in the board dict below. Use with caution... {'boards': {'mux_1': - {'model' : 'mux_2024_rev_0_0', # 'ohmpi_i2c_mux64_v1.01', + {'model' : 'mux_2024_0_X', # 'ohmpi_i2c_mux64_v1.01', 'tca_address': None, 'tca_channel': 0, 'mcp_0': '0x22', # TODO : Replace this with pos of jumper on MUX board (address doesn't mean anything for the average user... diff --git a/configs/config_tmp.py b/configs/config_tmp.py index cde239e5..11f80db4 100644 --- a/configs/config_tmp.py +++ b/configs/config_tmp.py @@ -20,12 +20,12 @@ OHMPI_CONFIG = { HARDWARE_CONFIG = { 'ctl': {'model' : 'raspberry_pi_i2c' }, - 'tx' : {'model' : 'ohmpi_card_3_15', + 'tx' : {'model' : 'mb_2023_0_X', 'mcp_board_address': 0x20, 'current_max': 4800 / 50 / 2, # Maximum current 'r_shunt': 2 # Shunt resistance in Ohms }, - 'rx' : {'model': 'ohmpi_card_3_15', + 'rx' : {'model': 'mb_2023_0_X', 'coef_p2': 2.50, # slope for current conversion for ADS.P2, measurement in V/V 'sampling_rate': 100., # Hz 'nb_samples': 20, # Max value 10 # was named integer before... diff --git a/dev/test_2_mux_2024.py b/dev/test_2_mux_2024.py index 9451657a..a033c719 100644 --- a/dev/test_2_mux_2024.py +++ b/dev/test_2_mux_2024.py @@ -3,7 +3,7 @@ from ohmpi.utils import change_config from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_2_mux_2024.py', verbose=False) -from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG +from ohmpi.hardware_components.mux_2024_0_X import Mux, MUX_CONFIG from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG diff --git a/dev/test_3_mux_2024.py b/dev/test_3_mux_2024.py index ff6e15e0..c928b087 100644 --- a/dev/test_3_mux_2024.py +++ b/dev/test_3_mux_2024.py @@ -3,7 +3,7 @@ from ohmpi.utils import change_config from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_3_mux_2024.py', verbose=False) -from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux +from ohmpi.hardware_components.mux_2024_0_X import Mux from ohmpi.hardware_components import raspberry_pi as ctl_module from ohmpi.config import HARDWARE_CONFIG MUX_CONFIG = HARDWARE_CONFIG['mux'] diff --git a/dev/test_4_mux_2024.py b/dev/test_4_mux_2024.py index 98f93e89..1798a59c 100644 --- a/dev/test_4_mux_2024.py +++ b/dev/test_4_mux_2024.py @@ -3,7 +3,7 @@ from ohmpi.utils import change_config from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_4_mux_2024.py', verbose=False) -from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG +from ohmpi.hardware_components.mux_2024_0_X import Mux, MUX_CONFIG from ohmpi.hardware_components import raspberry_pi as ctl_module from ohmpi.config import HARDWARE_CONFIG diff --git a/dev/test_ohmpi_card_3_15.py b/dev/test_mb_2023_0_X.py similarity index 88% rename from dev/test_ohmpi_card_3_15.py rename to dev/test_mb_2023_0_X.py index aa1310cc..04dfe529 100644 --- a/dev/test_ohmpi_card_3_15.py +++ b/dev/test_mb_2023_0_X.py @@ -1,7 +1,7 @@ # import sys # sys.path.extend(['/home/su530201/PycharmProjects/ohmpi_reversaal/OhmPi']) -from ohmpi.hardware_components.ohmpi_card_3_15 import Tx -from ohmpi.hardware_components.ohmpi_card_3_15 import Rx +from ohmpi.hardware_components.mb_2023_0_X import Tx +from ohmpi.hardware_components.mb_2023_0_X import Rx from ohmpi.logging_setup import create_stdout_logger import numpy as np diff --git a/dev/test_measure_with_ohmpi_card_3_15.py b/dev/test_measure_with_mb_2023_0_X.py similarity index 100% rename from dev/test_measure_with_ohmpi_card_3_15.py rename to dev/test_measure_with_mb_2023_0_X.py diff --git a/dev/test_mux_2024.py b/dev/test_mux_2024.py index 93fb74ea..da950eb9 100644 --- a/dev/test_mux_2024.py +++ b/dev/test_mux_2024.py @@ -2,7 +2,7 @@ import time from ohmpi.utils import change_config import logging change_config('../configs/config_mb_2023_mux_2024.py', verbose=False) -from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG +from ohmpi.hardware_components.mux_2024_0_X import Mux, MUX_CONFIG from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG diff --git a/dev/test_mux_2024_2_roles_AB.py b/dev/test_mux_2024_2_roles_AB.py index d946fe5c..88fd729d 100644 --- a/dev/test_mux_2024_2_roles_AB.py +++ b/dev/test_mux_2024_2_roles_AB.py @@ -2,7 +2,7 @@ import time from ohmpi.utils import change_config import logging change_config('../configs/config_mb_2023_mux_2024_2_roles_AB.py', verbose=False) -from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG +from ohmpi.hardware_components.mux_2024_0_X import Mux, MUX_CONFIG from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG diff --git a/ohmpi/hardware_components/abstract_hardware_components.py b/ohmpi/hardware_components/abstract_hardware_components.py index ab9da2a0..4cd0c655 100644 --- a/ohmpi/hardware_components/abstract_hardware_components.py +++ b/ohmpi/hardware_components/abstract_hardware_components.py @@ -9,7 +9,7 @@ from threading import Event, Barrier, BrokenBarrierError class CtlAbstract(ABC): def __init__(self, **kwargs): self.board_name = kwargs.pop('board_name', 'unknown CTL hardware') - self.connections = None # TODO: allow for several buses + self.interfaces = None # TODO: allow for several buses self.exec_logger = kwargs.pop('exec_logger', None) if self.exec_logger is None: self.exec_logger = create_stdout_logger('exec_ctl') @@ -56,7 +56,7 @@ class PwrAbstract(ABC): self._voltage_min = kwargs.pop('voltage_min', 0.) self._voltage_max = kwargs.pop('voltage_max', 0.) self.ctl = kwargs.pop('ctl', None) - self.io = kwargs.pop('io', None) + self.connection = kwargs.pop('io', None) @property @abstractmethod @@ -111,7 +111,7 @@ class MuxAbstract(ABC): if self.board_id is None: self.exec_logger.error(f'MUX {self.board_name} should have an id !') self.exec_logger.debug(f'MUX {self.board_id} ({self.board_name}) initialization') - self.io = kwargs.pop('io', None) + self.connection = kwargs.pop('io', None) cabling = kwargs.pop('cabling', None) self.cabling = {} if cabling is not None: @@ -256,7 +256,7 @@ class TxAbstract(ABC): if self.soh_logger is None: self.soh_logger = create_stdout_logger('soh_tx') self.ctl = kwargs.pop('ctl', None) - self.io = kwargs.pop('io', None) + self.connection = kwargs.pop('io', None) self.pwr = kwargs.pop('pwr', None) self._polarity = 0 self._injection_duration = None @@ -374,7 +374,7 @@ class RxAbstract(ABC): if self.soh_logger is None: self.soh_logger = create_stdout_logger('soh_rx') self.ctl = kwargs.pop('ctl', None) - self.io = kwargs.pop('io', None) + self.connection = kwargs.pop('io', None) self.board_name = kwargs.pop('board_name', 'unknown RX hardware') self._sampling_rate = kwargs.pop('sampling_rate', 1) # ms self.exec_logger.debug(f'{self.board_name} RX initialization') diff --git a/ohmpi/hardware_components/ohmpi_card_3_15.py b/ohmpi/hardware_components/mb_2023_0_X.py similarity index 94% rename from ohmpi/hardware_components/ohmpi_card_3_15.py rename to ohmpi/hardware_components/mb_2023_0_X.py index b3cee905..a8e1c10a 100644 --- a/ohmpi/hardware_components/ohmpi_card_3_15.py +++ b/ohmpi/hardware_components/mb_2023_0_X.py @@ -97,13 +97,13 @@ class Tx(TxAbstract): self.ctl = ctl_module.Ctl() # elif isinstance(self.ctl, dict): # self.ctl = ctl_module.Ctl(**self.ctl) - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.connection = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] # I2C connexion to MCP23008, for current injection - self.mcp_board = MCP23008(self.io, address=TX_CONFIG['mcp_board_address']) + self.mcp_board = MCP23008(self.connection, address=TX_CONFIG['mcp_board_address']) # ADS1115 for current measurement (AB) self._ads_current_address = 0x48 - self._ads_current = ads.ADS1115(self.io, gain=self.adc_gain, data_rate=860, + self._ads_current = ads.ADS1115(self.connection, gain=self.adc_gain, data_rate=860, address=self._ads_current_address) self._ads_current.mode = Mode.CONTINUOUS @@ -134,7 +134,7 @@ class Tx(TxAbstract): def adc_gain(self, value): assert value in [2/3, 2, 4, 8, 16] self._adc_gain = value - self._ads_current = ads.ADS1115(self.io, gain=self.adc_gain, data_rate=860, + self._ads_current = ads.ADS1115(self.connection, gain=self.adc_gain, data_rate=860, address=self._ads_current_address) self._ads_current.mode = Mode.CONTINUOUS self.exec_logger.debug(f'Setting TX ADC gain to {value}') @@ -229,12 +229,12 @@ class Rx(RxAbstract): self.exec_logger.event(f'{self.board_name}\trx_init\tbegin\t{datetime.datetime.utcnow()}') if self.ctl is None: self.ctl = ctl_module.Ctl() - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.connection = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] # ADS1115 for voltage measurement (MN) self._ads_voltage_address = 0x49 self._adc_gain = 2/3 - self._ads_voltage = ads.ADS1115(self.io, gain=self._adc_gain, data_rate=860, + self._ads_voltage = ads.ADS1115(self.connection, gain=self._adc_gain, data_rate=860, address=self._ads_voltage_address) self._ads_voltage.mode = Mode.CONTINUOUS self._coef_p2 = kwargs.pop('coef_p2', RX_CONFIG['coef_p2']) @@ -252,7 +252,7 @@ class Rx(RxAbstract): def adc_gain(self, value): assert value in [2/3, 2, 4, 8, 16] self._adc_gain = value - self._ads_voltage = ads.ADS1115(self.io, gain=self.adc_gain, data_rate=860, + self._ads_voltage = ads.ADS1115(self.connection, gain=self.adc_gain, data_rate=860, address=self._ads_voltage_address) self._ads_voltage.mode = Mode.CONTINUOUS self.exec_logger.debug(f'Setting RX ADC gain to {value}') diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py index ba915e98..7186942b 100644 --- a/ohmpi/hardware_components/mb_2024_0_2.py +++ b/ohmpi/hardware_components/mb_2024_0_2.py @@ -99,7 +99,7 @@ class Tx(TxAbstract): self.ctl = ctl_module.Ctl() # elif isinstance(self.ctl, dict): # self.ctl = ctl_module.Ctl(**self.ctl) - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.io = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] # I2C connexion to MCP23008, for current injection self.mcp_board = MCP23008(self.io, address=TX_CONFIG['mcp_board_address']) @@ -231,7 +231,7 @@ class Rx(RxAbstract): self.exec_logger.event(f'{self.board_name}\trx_init\tbegin\t{datetime.datetime.utcnow()}') if self.ctl is None: self.ctl = ctl_module.Ctl() - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.io = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] # I2C connexion to MCP23008, for DG411 self.mcp_board = MCP23008(self.io, address=RX_CONFIG['mcp_board_address']) diff --git a/ohmpi/hardware_components/mux_2023_rev_0_0.py b/ohmpi/hardware_components/mux_2023_0_X.py similarity index 98% rename from ohmpi/hardware_components/mux_2023_rev_0_0.py rename to ohmpi/hardware_components/mux_2023_0_X.py index 7850131a..4951d845 100644 --- a/ohmpi/hardware_components/mux_2023_rev_0_0.py +++ b/ohmpi/hardware_components/mux_2023_0_X.py @@ -82,7 +82,7 @@ class Mux(MuxAbstract): else: self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self._mode = '' - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.io = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] self._tca = [adafruit_tca9548a.TCA9548A(self.io, tca_address)[i] for i in np.arange(7, 3, -1)] # self._mcp_addresses = (kwargs.pop('mcp', '0x20')) # TODO: add assert on valid addresses.. self._mcp = [None, None, None, None] diff --git a/ohmpi/hardware_components/mux_2024_rev_0_0.py b/ohmpi/hardware_components/mux_2024_0_X.py similarity index 96% rename from ohmpi/hardware_components/mux_2024_rev_0_0.py rename to ohmpi/hardware_components/mux_2024_0_X.py index eb3ec474..48fed410 100644 --- a/ohmpi/hardware_components/mux_2024_rev_0_0.py +++ b/ohmpi/hardware_components/mux_2024_0_X.py @@ -63,7 +63,7 @@ class Mux(MuxAbstract): kwargs.update({'current_max': max(0., min(kwargs.pop('current_max', SPECS['current_max']), SPECS['current_max']))}) super().__init__(**kwargs) - assert isinstance(self.io, I2C) + assert isinstance(self.connection, I2C) self.exec_logger.debug(f'configuration: {kwargs}') tca_address = kwargs.pop('tca_address', None) tca_channel = kwargs.pop('tca_channel', 0) @@ -77,11 +77,10 @@ class Mux(MuxAbstract): else: self.exec_logger.error(f'Invalid role assignment for {self.board_name}: {self._roles} !') self._mode = '' - # self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] -> to hardware_system if tca_address is None: - self._tca = self.io + self._tca = self.connection else: - self._tca = adafruit_tca9548a.TCA9548A(self.io, tca_address)[tca_channel] + self._tca = adafruit_tca9548a.TCA9548A(self.connection, tca_address)[tca_channel] self._mcp_addresses = (kwargs.pop('mcp_0', '0x22'), kwargs.pop('mcp_1', '0x23')) # TODO: add assert on valid addresses.. self._mcp = [None, None] self.reset() diff --git a/ohmpi/hardware_components/pwr_dps5005.py b/ohmpi/hardware_components/pwr_dps5005.py index 5f0a25cd..7e4d7cea 100644 --- a/ohmpi/hardware_components/pwr_dps5005.py +++ b/ohmpi/hardware_components/pwr_dps5005.py @@ -27,7 +27,7 @@ class Pwr(PwrAbstract): # if a controller is passed in kwargs, it will be instantiated if self.ctl is None: self.ctl = ctl_module.Ctl(**CTL_CONFIG) - self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)] + self.connection = self.ctl.interfaces[kwargs.pop('connection', ctl_connection)] self.voltage_adjustable = True self._voltage = voltage self._current_adjustable = False @@ -43,11 +43,11 @@ class Pwr(PwrAbstract): self.exec_logger.debug(f'Current cannot be set on {self.board_name}') def turn_off(self): - self.io.write_register(0x09, 1) + self.connection.write_register(0x09, 1) self.exec_logger.debug(f'{self.board_name} is off') def turn_on(self): - self.io.write_register(0x09, 1) + self.connection.write_register(0x09, 1) self.exec_logger.debug(f'{self.board_name} is on') @property @@ -56,11 +56,11 @@ class Pwr(PwrAbstract): @voltage.setter def voltage(self, value): - self.io.write_register(0x0000, value, 2) + self.connection.write_register(0x0000, value, 2) def battery_voltage(self): - self.io.read_register(0x05, 2) + self.connection.read_register(0x05, 2) @property def current_max(self,value): - self.io.write_register(0x0001, value * 10, 0) + self.connection.write_register(0x0001, value * 10, 0) diff --git a/ohmpi/hardware_components/raspberry_pi.py b/ohmpi/hardware_components/raspberry_pi.py index 54789394..86c6f00a 100644 --- a/ohmpi/hardware_components/raspberry_pi.py +++ b/ohmpi/hardware_components/raspberry_pi.py @@ -21,24 +21,24 @@ class Ctl(CtlAbstract): modbus_slave_address = kwargs.pop('modbus_slave_address', 1) super().__init__(**kwargs) - self.connections = dict() + self.interfaces = dict() # I2C - self.connections['i2c'] = busio.I2C(board.SCL, board.SDA) # noqa + self.interfaces['i2c'] = busio.I2C(board.SCL, board.SDA) # noqa # Extended I2C try: - self.connections['i2c_ext'] = ExtendedI2C(4) # 4 is defined + self.interfaces['i2c_ext'] = ExtendedI2C(4) # 4 is defined except Exception as e: self.exec_logger.warning('Could not initialize Extended I2C:\n{e}') # modbus try: - self.connections['modbus'] = minimalmodbus.Instrument(port=modbus_port, slaveaddress=modbus_slave_address) - self.connections['modbus'].serial.baudrate = modbus_baudrate # Baud rate 9600 as listed in doc - self.connections['modbus'].serial.bytesize = modbus_bitesize # - self.connections['modbus'].serial.timeout = modbus_timeout # greater than 0.5 for it to work - self.connections['modbus'].debug = modbus_debug # - self.connections['modbus'].serial.parity = modbus_parity # No parity - self.connections['modbus'].mode = modbus_mode # RTU mode + self.interfaces['modbus'] = minimalmodbus.Instrument(port=modbus_port, slaveaddress=modbus_slave_address) + self.interfaces['modbus'].serial.baudrate = modbus_baudrate # Baud rate 9600 as listed in doc + self.interfaces['modbus'].serial.bytesize = modbus_bitesize # + self.interfaces['modbus'].serial.timeout = modbus_timeout # greater than 0.5 for it to work + self.interfaces['modbus'].debug = modbus_debug # + self.interfaces['modbus'].serial.parity = modbus_parity # No parity + self.interfaces['modbus'].mode = modbus_mode # RTU mode except Exception as e: self.exec_logger.warning('Could not initialize Extended modbus:\n{e}') diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index bdf03b00..f3fe7ba6 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -110,7 +110,7 @@ class OhmPiHardware: mux_ctl_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["ctl"]["model"]}') mux_config['ctl'] = mux_ctl_module.Ctl(**mux_config['ctl']) # (**self.ctl) assert issubclass(type(mux_config['ctl']), CtlAbstract) - io = mux_config.pop('io', mux_config['ctl'].connections[mux_config.pop('connection', 'i2c')]) + io = mux_config.pop('io', mux_config['ctl'].interfaces[mux_config.pop('connection', 'i2c')]) mux_config.update({'io': io}) mux_config['id'] = mux_id -- GitLab