diff --git a/configs/config_mb_2023_2_mux_2024.py b/configs/config_mb_2023_2_mux_2024.py index 3b0e8cad1e2ff6f1f1387b5e20ec4ddaa58ff84e..74645aafee9880eecf27d67c321cfb5ce98dadf5 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 a4134e6d9321c52512c706cee7439d4b63073d7e..78673566fccbe93641fcd012a407b05c80557aa8 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 0c0309a29718a650f1eb684a012ee1f440bcf9e6..7d7fa2fda28ae3cddbf33f04bdcf9b4c240960f5 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 66dbfda33dd5ce862528d707059f91bad3ae8432..23689580c1aa06dbf6e962c85f926ca5e27f54ce 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 f8075ecd87b2ed79981f0538f03520aebbe69194..e78a44a6ebd3839240ca7d56d03b1ff13e80936a 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 0b04b948764d0f1f8f1f405f6870040749ca8813..42fe5c13e36a6ecce55e4cfda1a862b92cce04ba 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 04057da5adcb12f84069eafb666be5df45c97b77..d5ea1a50000e9be4137baf7da405f67ee91b689c 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 cde239e52a8978f53b90ada4a25c184ba1f07644..11f80db46380e3dfe4fc36d469d46af0808cb471 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 9451657acff8d8e189aff87e8ed8563b16eaa86e..a033c7199327f94589ceeafe276a654a9280861d 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 ff6e15e0d7225fc5b5b11250c05ab62fdf14e5ec..c928b087c6f95a556ca03ee000633287044bd829 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 98f93e891ff989b49315a49840420a947b19bd17..1798a59c8757e118c3402f7c679399146d299449 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 aa1310cc82701fbdc870dea90f358fc378811437..04dfe529d679a698b2137ed915ccdb97009589e6 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 93fb74ea68a5124a2c07c433ab7434a9e75e9ae5..da950eb9ccabb20c8071678eaecd9a0c98f20c9a 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 d946fe5c02ec4698e7c2b3ef6550d5a499e9a500..88fd729da7ba129a0fbdea37d808bc43935e40d8 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 ab9da2a052467c2508404e34a30c121aec66013d..4cd0c6554f730f29ad576d3afc30a2a7ae6dd89d 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 b3cee905c07851dc44df567bb1a561a94dcae1b4..a8e1c10a695fbd5620dcb3e198968989aef1a57b 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 ba915e986474dcfb90fcaae8251e6e1b2bf5afe6..7186942be8fefea7d3c032ceca5bf759ff8feb76 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 7850131a3d9210ab60baf7757dc62d7f4b716941..4951d8451d3e600782d5945766c1f917faac7ea2 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 eb3ec474b29193222492f80560dff56fc2342d25..48fed4101b90252702ce5430689585ea7d392a81 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 5f0a25cd54af8408585c618e3f480f6508c5fc56..7e4d7ceac90172f0944f78f67e5923565e8b3acf 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 54789394498b2c5bf95d8a06e5f0d2242cee0c1f..86c6f00a4a8c3005a0b4aceaecb31dc4e301bd2b 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 bdf03b00c91571b40f740c416414026b7a6eb0e6..f3fe7ba648a64a416e331b2c4185b4811de9c4ca 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