A Power Monitor tool for ZCU102 that reads INA226 power rails via hwmon.
Project description
Power Monitor ZCU102
The power_monitor tool provides a Python interface to accurately read INA226 power rails via the hwmon subsystems on the Xilinx Zynq UltraScale+ ZCU102 development board.
The design for this tool leverages the approach in the Xilinx EDA365 article: Accurate Design Power Measurement Made Easier by Don Matson and Luis Bielich.
Power Calculation Formulas
The total power of the board is divided into three major domains: Processing System (PS), Programmable Logic (PL), and Multi-Gigabit Transceivers (MGT). The formulas used to calculate total power are derived from the reference article:
- PS Power = VCCPSINTFP + VCCPSINTLP + VCCPSAUX + VCCPSPLL + VCCPSDDR + VCCOPS + VCCOPS3 + VCCPSDDRPL
- PL Power = VCCINT + VCCBRAM + VCCAUX + VCC1V2 + VCC3V3
- MGT Power = MGTRAVCC + MGTRAVTT + MGTAVCC + MGTAVTT
- Total Power = PS Power + PL Power + MGT Power
Note: While some legacy implementations vary where VCC3V3 is categorized, this tool adds it to PL as indicated by the formula structure in the article text.
INA226 Power Rails for ZCU102
The ZCU102 has shunt resistors placed on specific power rails, monitored by TI INA226 chips. These are accessible via the I2C bus exported to /sys/class/hwmon on PetaLinux systems.
Here is the table of the relevant rails (referenced from the article and board parameters):
| Sensor Name | Rail / Domain Name | Category |
|---|---|---|
ina226_u76 |
VCCPSINTFP | PS |
ina226_u77 |
VCCPSINTLP | PS |
ina226_u78 |
VCCPSAUX | PS |
ina226_u87 |
VCCPSPLL | PS |
ina226_u93 |
VCCPSDDR | PS |
ina226_u88 |
VCCOPS | PS |
ina226_u15 |
VCCOPS3 | PS |
ina226_u92 |
VCCPSDDRPL | PS |
ina226_u79 |
VCCINT | PL |
ina226_u81 |
VCCBRAM | PL |
ina226_u80 |
VCCAUX | PL |
ina226_u84 |
VCC1V2 | PL |
ina226_u16 |
VCC3V3 | PL |
ina226_u65 |
VADJ_FMC | PL |
ina226_u85 |
MGTRAVCC | MGT |
ina226_u86 |
MGTRAVTT | MGT |
ina226_u74 |
MGTAVCC | MGT |
ina226_u75 |
MGTAVTT | MGT |
Usage Example
Once the package is installed on the ZCU102 PetaLinux environment, you can use it in your Python scripts.
1. Simple Single Read
from power_monitor import PowerMonitor
# Initialize the monitor
pm = PowerMonitor()
# Read the aggregated power domains once
ps, pl, mgt, total = pm._read_once(verbose=True)
print(f"Total Power: {total:.3f} W")
2. Background Measurement (Non-Blocking)
Useful for measuring power while a separate workload runs.
import time
from power_monitor import PowerMonitor
pm = PowerMonitor(interval=0.5) # Sample every 0.5 seconds
print("Starting background power measurement...")
pm.start()
# Do your heavy workload here (e.g., neural network inference)
time.sleep(3.0)
# Stop monitoring and retrieve records
pm.stop()
# Summarize and save
avg_ps, avg_pl, avg_mgt, avg_total = pm.average()
print(f"Average Total Power during workload: {avg_total:.3f} W")
pm.save_samples("power_log.csv")
Installation
From source (PetaLinux 2022.2)
git clone <repository-url>
cd power_monitor
pip install .
Running Automated Tests
The tests are specifically written to target the hwmon structures of the ZCU102 running PetaLinux.
Requirements:
- A physical ZCU102 board running the PetaLinux 2022.2 image.
pytestinstalled.
To run the tests:
- Secure Shell (SSH) into the ZCU102 or use the serial terminal.
- Navigate to the
power_monitorproject root. - Install pytest if needed:
pip install pytest - Run the suite:
python -m pytest tests/
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file power_monitor_zcu102-0.1.2.tar.gz.
File metadata
- Download URL: power_monitor_zcu102-0.1.2.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdfab228b593c2bed33bb22a94c56f88f403b039269f5b6a49f0b5c72cf8cea3
|
|
| MD5 |
790c81f18213d9fa3ccc99c5853f1dfe
|
|
| BLAKE2b-256 |
f09dd3f62d37cb30dbd09c20d850fc815a73900bcf7044763cd549641423b534
|
Provenance
The following attestation bundles were made for power_monitor_zcu102-0.1.2.tar.gz:
Publisher:
publish.yml on drkh-n/power_monitor_zcu102
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
power_monitor_zcu102-0.1.2.tar.gz -
Subject digest:
bdfab228b593c2bed33bb22a94c56f88f403b039269f5b6a49f0b5c72cf8cea3 - Sigstore transparency entry: 991398263
- Sigstore integration time:
-
Permalink:
drkh-n/power_monitor_zcu102@be9a20d332e018a44fe3fc55f374b2d83dea5acc -
Branch / Tag:
refs/tags/v.0.1.0 - Owner: https://github.com/drkh-n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@be9a20d332e018a44fe3fc55f374b2d83dea5acc -
Trigger Event:
release
-
Statement type:
File details
Details for the file power_monitor_zcu102-0.1.2-py3-none-any.whl.
File metadata
- Download URL: power_monitor_zcu102-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff1501399b0cdbc7f20a44041e00c1ef9da73c53d518cca99ab2380ffc7aebad
|
|
| MD5 |
85af5665a3a69e1b067d8a230125bce0
|
|
| BLAKE2b-256 |
dd4a25743390ef718b992662789f566d37c138af209156ce42a1f46b6c8ef8a4
|
Provenance
The following attestation bundles were made for power_monitor_zcu102-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on drkh-n/power_monitor_zcu102
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
power_monitor_zcu102-0.1.2-py3-none-any.whl -
Subject digest:
ff1501399b0cdbc7f20a44041e00c1ef9da73c53d518cca99ab2380ffc7aebad - Sigstore transparency entry: 991398265
- Sigstore integration time:
-
Permalink:
drkh-n/power_monitor_zcu102@be9a20d332e018a44fe3fc55f374b2d83dea5acc -
Branch / Tag:
refs/tags/v.0.1.0 - Owner: https://github.com/drkh-n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@be9a20d332e018a44fe3fc55f374b2d83dea5acc -
Trigger Event:
release
-
Statement type: