From 97149ee328c3fe7df8a091ceaf78972b6012139a Mon Sep 17 00:00:00 2001 From: jkl <sagitta1618@gmail.com> Date: Wed, 29 Nov 2023 12:13:01 +0100 Subject: [PATCH] Add troubleshooting text (to be reviewed) --- doc/source/conf.py | 2 +- doc/source/source_rst/api.rst | 4 +-- ohmpi/config.py | 65 +++++++++++++++++++++++++++-------- ohmpi/ohmpi.py | 55 ++++++++++++++--------------- 4 files changed, 81 insertions(+), 45 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index fcab499e..0b58c081 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,7 +15,7 @@ import os import sys sys.path.append(os.path.abspath('../..')) -import ohmpi # import Ohmpi module to be documented in api.rst by numpydoc +#import ohmpi # import Ohmpi module to be documented in api.rst by numpydoc import sphinx_rtd_theme diff --git a/doc/source/source_rst/api.rst b/doc/source/source_rst/api.rst index c5c9a92a..59ed01aa 100644 --- a/doc/source/source_rst/api.rst +++ b/doc/source/source_rst/api.rst @@ -3,7 +3,7 @@ API reference .. toctree:: :maxdepth: 2 :caption: Contents: -.. automodule:: ohmpi +.. automodule:: ohmpi.ohmpi :members: - + diff --git a/ohmpi/config.py b/ohmpi/config.py index 0763f48c..40665972 100644 --- a/ohmpi/config.py +++ b/ohmpi/config.py @@ -1,7 +1,7 @@ import logging from ohmpi.utils import get_platform -from paho.mqtt.client import MQTTv31 +from paho.mqtt.client import MQTTv31 # noqa _, on_pi = get_platform() # DEFINE THE ID OF YOUR OhmPi @@ -17,26 +17,61 @@ OHMPI_CONFIG = { 'settings': 'ohmpi_settings.json', # INSERT YOUR FAVORITE SETTINGS FILE HERE } +r_shunt = 2. HARDWARE_CONFIG = { - 'ctl': {'model' : 'dummy_ctl' - }, - 'tx' : {'model' : 'dummy_tx', - 'current_max': 4800 / 50 / 2, # Maximum current mA - 'r_shunt': 2, # Shunt resistance in Ohms - 'low_battery': 12. # Volts + 'ctl': {'model': 'raspberry_pi'}, + 'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'}, + 'tx': {'model': 'mb_2023_0_X', + 'voltage_max': 50., # Maximum voltage supported by the TX board [V] + 'current_max': 4.80/(50*r_shunt), # Maximum voltage read by the current ADC on the TX board [A] + 'r_shunt': r_shunt, # Shunt resistance in Ohms + 'interface_name': 'i2c' }, - 'rx' : {'model': 'dummy_rx', + 'rx': {'model': 'mb_2023_0_X', + 'coef_p2': 2.50, # slope for conversion for ADS, measurement in V/V + 'sampling_rate': 50., # number of samples per second + 'interface_name': 'i2c', }, - 'mux': {'model' : 'dummy_mux', - 'max_elec': 64, - 'voltage_max' : 100, - 'current_max' : 3 - } + 'mux': # default properties given in config are system properties that will be + # overwritten by properties defined in each the board dict below. + # if defined in board specs, values out of specs will be bounded to remain in specs + # omitted properties in config will be set to board specs default values if they exist + {'boards': + {'mux_A': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x70, + 'roles': {'A': 'X'}, + 'cabling': {(i, j): ('mux_A', i) for j in ['A'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_B': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x71, + 'roles': {'B': 'X'}, + 'cabling': {(i, j): ('mux_B', i) for j in ['B'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_M': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x72, + 'roles': {'M': 'X'}, + 'cabling': {(i, j): ('mux_M', i) for j in ['M'] for i in range(1, 65)}, + 'voltage_max': 12.}, + 'mux_N': + {'model': 'mux_2023_0_X', + 'mux_tca_address': 0x73, + 'roles': {'N': 'X'}, + 'cabling': {(i, j): ('mux_N', i) for j in ['N'] for i in range(1, 65)}, + 'voltage_max': 12.}, + }, + 'default': {'interface_name': 'i2c', + 'voltage_max': 12., + 'current_max': 3.} + } } + # SET THE LOGGING LEVELS, MQTT BROKERS AND MQTT OPTIONS ACCORDING TO YOUR NEEDS # Execution logging configuration EXEC_LOGGING_CONFIG = { - 'logging_level': logging.INFO, + 'logging_level': logging.INFO, # TODO: set logging level back to INFO 'log_file_logging_level': logging.DEBUG, 'logging_to_console': True, 'file_name': f'exec{logging_suffix}.log', @@ -60,8 +95,8 @@ DATA_LOGGING_CONFIG = { # State of Health logging configuration (For a future release) SOH_LOGGING_CONFIG = { 'logging_level': logging.INFO, - 'log_file_logging_level': logging.DEBUG, 'logging_to_console': True, + 'log_file_logging_level': logging.DEBUG, 'file_name': f'soh{logging_suffix}.log', 'max_bytes': 16777216, 'backup_count': 1024, diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index e67269a3..3d3eb04f 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -44,23 +44,24 @@ VERSION = '3.0.0-beta' class OhmPi(object): """OhmPi class. - Construct the ohmpi object. - - Parameters - ---------- - settings : dict, optional - Dictionnary of parameters. Possible parameters with their default values: - `{'injection_duration': 0.2, 'nb_meas': 1, 'sequence_delay': 1, - 'nb_stack': 1, 'sampling_interval': 2, 'tx_volt': 5, 'duty_cycle': 0.5, - 'strategy': 'constant', 'export_path': None - sequence : str, optional - Path of the .csv or .txt file with A, B, M and N electrodes. - Electrode index starts at 1. See `OhmPi.load_sequence()` for full docstring. - mqtt : bool, optional - If True (default), publish on mqtt topics while logging, - otherwise use other loggers only (print). """ def __init__(self, settings=None, sequence=None, mqtt=True): + """Construct the ohmpi object. + + Parameters + ---------- + settings : dict, optional + Dictionnary of parameters. Possible parameters with their default values: + `{'injection_duration': 0.2, 'nb_meas': 1, 'sequence_delay': 1, + 'nb_stack': 1, 'sampling_interval': 2, 'tx_volt': 5, 'duty_cycle': 0.5, + 'strategy': 'constant', 'export_path': None + sequence : str, optional + Path of the .csv or .txt file with A, B, M and N electrodes. + Electrode index starts at 1. See `OhmPi.load_sequence()` for full docstring. + mqtt : bool, optional + If True (default), publish on mqtt topics while logging, + otherwise use other loggers only (print). + """ self._sequence = sequence self.nb_samples = 0 self.status = 'idle' # either running or idle @@ -473,10 +474,10 @@ class OhmPi(object): Either: - vmax : compute Vab to reach a maximum Vmn_max and Iab without exceeding vab_max - vmin : compute Vab to reach at least Vmn_min - - constant : apply given Vab (tx_volt) - - Safety check (i.e. short voltage pulses) performed prior to injection to ensure - injection within bounds defined in vab_max, iab_max, vmn_max or vmn_min. This can adapt Vab. - To bypass safety check before injection, tx_volt should be set equal to vab_max (not recpommanded) + - constant : apply given Vab (tx_volt) + Safety check (i.e. short voltage pulses) performed prior to injection to ensure + injection within bounds defined in vab_max, iab_max, vmn_max or vmn_min. This can adapt Vab. + To bypass safety check before injection, tx_volt should be set equal to vab_max (not recpommanded) vab_max : str, optional Maximum injection voltage. Default value set by config or boards specs @@ -947,14 +948,14 @@ class OhmPi(object): def update_settings(self, settings: str, cmd_id=None): """Updates acquisition settings from a json file or dictionary. Parameters can be: - - nb_electrodes (number of electrode used, if 4, no MUX needed) - - injection_duration (in seconds) - - nb_meas (total number of times the sequence will be run) - - sequence_delay (delay in second between each sequence run) - - nb_stack (number of stack for each quadrupole measurement) - - strategy (injection strategy: constant, vmax, vmin) - - duty_cycle (injection duty cycle comprised between 0.5 - 1) - - export_path (path where to export the data, timestamp will be added to filename) + - nb_electrodes (number of electrode used, if 4, no MUX needed) + - injection_duration (in seconds) + - nb_meas (total number of times the sequence will be run) + - sequence_delay (delay in second between each sequence run) + - nb_stack (number of stack for each quadrupole measurement) + - strategy (injection strategy: constant, vmax, vmin) + - duty_cycle (injection duty cycle comprised between 0.5 - 1) + - export_path (path where to export the data, timestamp will be added to filename) Parameters ---------- -- GitLab