Skip to content

Latest commit

 

History

History
103 lines (85 loc) · 5.13 KB

README.md

File metadata and controls

103 lines (85 loc) · 5.13 KB

pps-tools

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:

Dependencies

  • Python <= 2.7
  • Python YAML module
  • Pyserial module

Install with:

sudo apt-get install python-yaml python-serial

Theory of (entirely stupid) operation

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.

Communication protocol

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 #NameDescription
00StartPacket header; always 0xaa
01AddressUnused, zero-fill
02Channel 1 Voltage High ByteMultiplied by 2.56V
03Channel 1 Voltage Low ByteMultiplied by 0.01V
04Channel 1 Current High ByteMultiplied by 0.256A
05Channel 1 Current Low ByteMultiplied by 0.001A
06Channel 2 Voltage High ByteMultiplied by 2.56V
07Channel 2 Voltage Low ByteMultiplied by 0.01V
08Channel 2 Current High ByteMultiplied by 0.256A
09Channel 2 Current Low ByteMultiplied by 0.001A
10Channel 3 Voltage High ByteMultiplied by 2.56V
11Channel 3 Voltage Low ByteMultiplied by 0.01V
12Channel 3 Current High ByteMultiplied by 0.256A
13Channel 3 Current Low ByteMultiplied by 0.001A
14RESERVEDZero-fill
15OutputBitmask for toggling per-channel output (HIGH bit == ON)
16AlarmSet to enable alarm, clear to disable
17RESERVEDZero-fill
18OCPSet for constant current output, zero for over-current protection
19Connection0 - independent output, 1 - in series, 2 - in parallel
20RESERVEDZero-fill
21RESERVEDZero-fill
22RESERVEDZero-fill
23CalibrationUnused, zero-fill

Utilities

pps-config

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.

pps-monitor

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).