Commit 7ed78b9e authored by remi.clement's avatar remi.clement
Browse files

Update for mb2024 4 mux 2023

Showing with 60 additions and 41 deletions
+60 -41
File mode changed from 100644 to 100755
#!/bin/bash
# ensure that the libatlas-base-dev library is installed
sudo apt-get install -y libatlas-base-dev
# Create the virtual environment
python3 -m venv ohmpy
# Activate it
source ohmpy/bin/activate || exit 1 # NOTE: Added || exit to avoid installing requirements in system python if the virtual environment can't be loaded
# Solve issues associated to storage allocation
export CFLAGS=-fcommon
# install all required packages in the virtual environment.
pip install -r requirements.txt
......@@ -7,7 +7,7 @@ import subprocess
from ohmpi.utils import change_config
#change_config('../configs/config_mb_2023.py', verbose=False)
change_config('../configs/config_mb_2023_4_mux_2023.py', verbose=False)
change_config('../configs/config_mb_2024_0_2__4_mux_2023_dps5005.py', verbose=False)
from ohmpi.ohmpi import OhmPi
from ohmpi.config import OHMPI_CONFIG
......
......@@ -7,9 +7,9 @@ import time
import logging
from ohmpi.config import HARDWARE_CONFIG
stand_alone = True
stand_alone = False
part_of_hardware_system = False
within_ohmpi = False
within_ohmpi = True
# Stand alone
if stand_alone:
......@@ -96,12 +96,12 @@ if within_ohmpi:
# k._hw.switch_mux([A, B, M, N], state='off')
# print(f'OhmPiHardware Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV')
# k._hw._plot_readings()
k.load_sequence('sequences/9991_GRAD_16_s1_a1.txt')
k.load_sequence('sequences/test_circuit_1423.txt')
k.run_sequence(tx_volt=5, injection_duration=1., nb_stack=2, duty_cycle=0.5)
print('using OhmPi')
#d = k.run_measurement([A, B, M, N], injection_duration=1., nb_stack=2, duty_cycle=0.5)
# print(d)
# k._hw._plot_readings()
#print(d)
#k._hw._plot_readings()
print(f'OhmPiHardware: Resistance: {k._hw.last_resistance() :.2f} ohm, dev. {k._hw.last_dev():.2f} %, sp: {k._hw.sp:.2f} mV, rx bias: {k._hw.rx._bias:.2f} mV')
print(f'OhmPi: Resistance: {d["R [ohm]"] :.2f} ohm, dev. {d["R_std [%]"]:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV')
# k._hw._plot_readings(save_fig=False)
......
install.sh 0 → 100755
#!/bin/bash
# ensure that the libatlas-base-dev library is installed
sudo apt-get install -y libatlas-base-dev libopenblas-dev
# Create the virtual environment
python3 -m venv ohmpy
# Activate it
source ohmpy/bin/activate || exit 1 # NOTE: Added || exit to avoid installing requirements in system python if the virtual environment can't be loaded
# Solve issues associated to storage allocation
export CFLAGS=-fcommon
# install all required packages in the virtual environment.
pip install -r requirements.txt
# install a second i2c bus
sudo apt-get install -y i2c-tools
echo -e "[all]\ndtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=22,i2c_gpio_scl=23" | sudo tee -a /boot/config.txt
# install local mqtt broker
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtdef='\e[0;0m' # Default
echo -e "${txtgrn}>>> Updating system and installing MQTT broker...${txtdef}"
sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service
echo -e "\n${txtgrn}>>> Broker is installed. Starting now...${txtdef}"
mosquitto -v
echo -e "\n${txtgrn}>>> Updating configuration to allow anonymous remote connections...${txtdef}"
echo "listener 1883" | sudo tee -a /etc/mosquitto/mosquitto.conf
echo "allow_anonymous true" | sudo tee -a /etc/mosquitto/mosquitto.conf
echo -e "\n${txtgrn}>>> Current configuration stored in /etc/mosquitto/mosquitto.conf is displayed below${txtdef}"
cat /etc/mosquitto/mosquitto.conf
echo -e "\n${txtylw}>>> Adapt it according to your needs!${txtdef}\n"
import logging
from ohmpi.utils import get_platform
from paho.mqtt.client import MQTTv31 # noqa
_, on_pi = get_platform()
......@@ -20,23 +19,20 @@ OHMPI_CONFIG = {
r_shunt = 2.
HARDWARE_CONFIG = {
'ctl': {'model': 'raspberry_pi'},
'pwr': {'model': 'pwr_batt', 'voltage': 12., 'interface_name': 'none'},
'tx': {'model': 'mb_2023_0_X',
'pwr': {'model': 'pwr_dps5005', 'voltage': 3., 'interface_name': 'modbus'},
'tx': {'model': 'mb_2024_0_2',
'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': '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',
'rx': {'model': 'mb_2024_0_2',
'coef_p2': 1.00, # 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
'interface_name': 'i2c'
},
'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': {'boards':
{'mux_A':
{'model': 'mux_2023_0_X',
'mux_tca_address': 0x70,
......@@ -55,23 +51,23 @@ HARDWARE_CONFIG = {
'roles': {'M': 'X'},
'cabling': {(i, j): ('mux_M', i) for j in ['M'] for i in range(1, 65)},
'voltage_max': 12.},
'mux_N':
'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.,
'default': {'interface_name': 'i2c_ext',
'voltage_max': 100.,
'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, # TODO: set logging level back to INFO
'logging_level': logging.INFO,
'log_file_logging_level': logging.DEBUG,
'logging_to_console': True,
'file_name': f'exec{logging_suffix}.log',
......
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