Skip to main content

ATLAS ITK Pixels Multi-Module Cycling Box environmental monitoring/control.

Project description

Software support for the ATLAS ITK pixels multi-module cycling box

Particle Physics, University of Liverpool, UK

This repository provides command line tools to monitor and control equipment in the ATLAS ITK pixels multi-module cycling box test setup, and includes a Python-importable package to read from environmental sensors. It is used in the test setups for a number of other projects for environmental sensing.

This project expects to be run on a Raspberry Pi, and has a few dependencies - outlined below - that cannot be automatically installed by pip.

Installation (Raspberry Pi OS only)

Create a Python virtual environment

mkdir ~/dev && cd ~/dev

python3 -m venv pve
. pve/bin/activate

Add . ~/dev/pve/bin/activate to the end of ~/.bashrc to activate the Python virtual environment at login.

Install package and (most) dependencies

python3 -m pip install --upgrade mmcb-avt

The above installs all of the dependencies required except for the MCP9601 and NAU7802.

MCP9601 (manual installation)

The Adafruit MCP9601 API was broken when last tested, so use the Pimoroni MCP9600 API instead. Since the Pimoroni API is for the MCP9600 rather than the MCP9601, we need to make a small change before installation:

git clone https://github.com/pimoroni/mcp9600-python
cd mcp9600-python

In file library/mcp9600/__init__.py make these changes:

Change from:

CHIP_ID = 0x40
I2C_ADDRESSES = list(range(0x60, 0x68))
I2C_ADDRESS_DEFAULT = 0x66
I2C_ADDRESS_ALTERNATE = 0x67

To:

CHIP_ID = 0x41
I2C_ADDRESSES = list(range(0x65, 0x67 + 1))
I2C_ADDRESS_DEFAULT = 0x67
I2C_ADDRESS_ALTERNATE = 0x66

Also edit the PYTHON="..." line in install.sh to point to the correct Python version, which in this case is python3 from the Python virtual environment. Use the full path provided by which python3, it'll look something like this:

#PYTHON="/usr/bin/python3"
PYTHON="/home/ds20k/dev/pve/bin/python3"

Then finally:

sudo ./install.sh --unstable

Reboot after the above step.

NAU7802 (manual installation)

cd ~/dev
git clone https://github.com/CedarGroveStudios/CircuitPython_NAU7802.git

# copy file into the python virtual environment

# For 64-bit Raspberry Pi OS
cp ~/dev/CircuitPython_NAU7802/cedargrove_nau7802.py ~/dev/pve/lib/python3.9/site-packages/

# For 32-bit Raspberry Pi OS
sudo cp ~/dev/CircuitPython_NAU7802/cedargrove_nau7802.py /usr/local/lib/python3.7/dist-packages/

Notes

The installation process will make the following new commands available in the shell:

Main commands

Command Function
iv Highly configurable script to measure IV/IT curves using the Keithley 2410/2614b (RS232). It can operate multiple PSUs concurrently, embed environmental data from other scripts received via ZeroMQ into log files, and can be easily used in shell scripts to automate tasks such as HV-cycling.
peltier Queries and/or sets parameters for the two relay boards that control the polarity of the four Peltier devices, via Raspberry Pi GPIO pins.
psuset Sets current/voltage parameters for power supplies (RS232: Keithley 2410/2614b, Hameg HMP4040). Works in both constant voltage and constant current modes.
sense Reads environmental sensors connected to the Raspberry Pi by I2C. Hardware setup is specified in a user defined configuration file. Progressively writes data to a human-readable log file, and streams compressed binary data to an HDF5 file. Directly supports the BME680, HYT221, NAU7802, SHTC3 sensors, and various thermocouples via MCP9601. Indirectly supports the SMC ZSE30A-01-F, SMC PFM725S-F01-F and the ATLAS common hybrid module NTC via ADS1015 and PCF8591 ADCs.
ult80 Queries and/or sets parameters for the ULT80 chiller (RS232).

Support commands

Command Function
dat2plot From the binary data files generated by sense, create two plots featuring all environmental sensors/parameters: the first will contain the raw data acquired vs time, the second contains summary statistics.
dat2root Creates a CERN ROOT file containing the raw data from binary data files generated by sense, as well as a plot for each parameter.
detect Detects equipment attached by RS232, writes a cache file containing identified equipment to ~/.cache.json. Run once after the RS232 configuration has changed.
liveplot Companion to iv. Displays IV plot in real-time in a graphical window.
log2dat Creates a .dat file from the log file sense creates. Principally used with archived legacy data where binary data files are not available.
psustat Provides a single-shot view of the status of all power supply channels (RS232: Keithley 2410/2614b, Hameg HMP4040).

In addition, once in the Python venv, you will be able to do this:

(pve) ds20k@raspberrypi:~ $ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import mmcb.configure_environment as ce
>>> testenv = ce.TestEnvironment('config.txt')
>>> measurements = testenv.read_all_sensors()
>>> measurements
{'timestamp': 1653844116.1013656, 'hyt_M1 °C': 21.12342061893426, 'hyt_M1 RH%': 0.0, 'hyt_env °C': 21.324848928767622, 'hyt_env RH%': 0.0, 'hyt_M4 °C': 21.113349203442596, 'hyt_M4 RH%': 0.0, 'ntc_M1 °C': 18.874264620930205, 'smc kPa': -95.29101904000001, 'ntc_M4 °C': -60.849429204693735, 'TC_VC4 °C': 20.3125, 'TC_VC1 °C': 19.375, 'TC_N2 °C': 20.75, 'TC_VC3 °C': 21.0, 'TC_VC2 °C': 21.25, 'sht_ambient °C': 23.43, 'sht_ambient RH%': 31.48, 'bme_ambient °C': 23.924921875, 'bme_ambient RH%': 26.04732304850249, 'bme_ambient hPa': 1014.36410289236}
>>> measurements.get('hyt_M4 °C', None)
21.113349203442596

Check the installed version:

(pve) ds20k@raspberrypi:~ $ python3 -m pip show mmcb-avt
Name: mmcb-avt
Version: 0.0.59
Summary: ATLAS ITK Pixels Multi-Module Cycling Box environmental monitoring/control.
Home-page: https://gitlab.ph.liv.ac.uk/avt/atlas-itk-pmmcb
Author: Alan Taylor, Manex Ormazabal
Author-email: avt@hep.ph.liv.ac.uk
License:
Location: /home/ds20k/dev/pve/lib/python3.9/site-packages
Requires: Adafruit-Blinka, adafruit-circuitpython-ads1x15, adafruit-circuitpython-bme680, adafruit-circuitpython-pcf8591, adafruit-circuitpython-shtc3, matplotlib, numpy, pandas, pyserial, smbus, sparkfun-qwiic-tca9548a, tables, yoctopuce, zmq
Required-by:

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mmcb-avt-0.0.61.tar.gz (117.2 kB view details)

Uploaded Source

Built Distribution

mmcb_avt-0.0.61-py3-none-any.whl (122.9 kB view details)

Uploaded Python 3

File details

Details for the file mmcb-avt-0.0.61.tar.gz.

File metadata

  • Download URL: mmcb-avt-0.0.61.tar.gz
  • Upload date:
  • Size: 117.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for mmcb-avt-0.0.61.tar.gz
Algorithm Hash digest
SHA256 4c0096f9fd444e0dae6bfd4ba461e0bb1dad52bfee47a26bcf6ddfc32d5adfeb
MD5 371f5a3a7f387799e3da5fb37a18d415
BLAKE2b-256 7b08cb957a9fb39db6a5050bf4761e55e3471a73d8d650265a9ef2929a26d37c

See more details on using hashes here.

File details

Details for the file mmcb_avt-0.0.61-py3-none-any.whl.

File metadata

  • Download URL: mmcb_avt-0.0.61-py3-none-any.whl
  • Upload date:
  • Size: 122.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for mmcb_avt-0.0.61-py3-none-any.whl
Algorithm Hash digest
SHA256 ab98c84b5d0a2049b4d0b0058bd061753dbcb5dc035ff99c9d029caa2fd20c7a
MD5 a2f041bdacf511a50b753df5a182301c
BLAKE2b-256 1c82a7bb6b6224a4a209ecb5f753668970854dbe4d6ab3797e72cd5786464bea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page