A suite of Python scripts for remote control and acquisition of energy consumption data from power supplies.
These tools support the Atten PPS-3205t-3s power supply. There are variants and rebadged versions of this supply based on region. A non-exhaustive list:
- Python <= 2.7
- Python YAML module
- Pyserial module
Install with:
sudo apt-get install python-yaml python-serial
The firmware on these supplies is terrible. There is no read method for gathering power data; instead a 24-bit packet (defined below) must be sent to the supply to configure it, only then will a 24-bit packet containing measurement data be sent back. That packet contains a single sample of instantaneous current consumption for each channel.
Sampling rate is thus I/O bound; the speed with which reads & writes are performed over UART directly impacts the number of samples gathered on the host PC. There seems to be no target-side aggregation or averaging of samples. Each write/read transaction gives us a single measurement for each channel.
These limitations suck and have informed the design of these tools. In particular pps-monitor does absolutely nothing besides writing configuration data, reading back measurement data and printing the results to STDOUT. It is recommended that the user configure the supply to run at 19200 baud (the fastest rate) to increase sample rate.
A document floating around on the interwebs provides just enough information to understand the 24-bit packet format for sending data over the wire. A copy of this doc can be found in my Google Drive.
A byte-for-byte breakdown of the packet:
Byte # | Name | Description |
00 | Start | Packet header; always 0xaa |
01 | Address | Unused, zero-fill |
02 | Channel 1 Voltage High Byte | Multiplied by 2.56V |
03 | Channel 1 Voltage Low Byte | Multiplied by 0.01V |
04 | Channel 1 Current High Byte | Multiplied by 0.256A |
05 | Channel 1 Current Low Byte | Multiplied by 0.001A |
06 | Channel 2 Voltage High Byte | Multiplied by 2.56V |
07 | Channel 2 Voltage Low Byte | Multiplied by 0.01V |
08 | Channel 2 Current High Byte | Multiplied by 0.256A |
09 | Channel 2 Current Low Byte | Multiplied by 0.001A |
10 | Channel 3 Voltage High Byte | Multiplied by 2.56V |
11 | Channel 3 Voltage Low Byte | Multiplied by 0.01V |
12 | Channel 3 Current High Byte | Multiplied by 0.256A |
13 | Channel 3 Current Low Byte | Multiplied by 0.001A |
14 | RESERVED | Zero-fill |
15 | Output | Bitmask for toggling per-channel output (HIGH bit == ON) |
16 | Alarm | Set to enable alarm, clear to disable |
17 | RESERVED | Zero-fill |
18 | OCP | Set for constant current output, zero for over-current protection |
19 | Connection | 0 - independent output, 1 - in series, 2 - in parallel |
20 | RESERVED | Zero-fill |
21 | RESERVED | Zero-fill |
22 | RESERVED | Zero-fill |
23 | Calibration | Unused, zero-fill |
Takes in a TTY argument and configuration options for controlling the power supply. This tool writes its output to the configuration file (~/.config/pps-tools/config by default, or ~/.pps-tools.config, or a file specified by the user). Normally this tool does not communicate directly with the power supply but instead it can inform the pps-monitor process that it needs to update its cache of configuration data. There is an option for initiating monitor mode from this command if not already started.
Takes in a TTY arguement and an optional channels argument. This tool reads in configuration data from the config file, programs the power supply to operate via that same configuration and then monitors power consumption data until interrupted with SIGINT. Note that pps-config can be invoked while pps-monitor is running but monitoring will be disabled during the critical section where pps-monitor updates its configuration cache (bounded by SIGUSR1 and SIGUSR2).