Power Measurement Tool#
Note
Two prebuilt binaries (tegra-power-sensing.linux
and tegra-power-sensing.qnx
) are packaged in this release under drive-foundation/tools/power_measurement
.
Power measurement uses the Texax Instruments INA3221 measurement chip to monitor the power usage of the GPU+SOC, CPU+CV, 5V input, and DDR power rails. The INA3221 is a three-channel, high-side current and bus voltage monitor with an I2C and SMBUS compatible interface. The INA3221 monitors both shunt voltage drops and bus supply voltages, in addition to having programmable conversion times and averaging modes for these signals.
Current is measured from the voltage drop across a sense resistor and is calculated by Ohm’s law.
V = I * R ===> I = V / R
This is then multiplied by the bus voltage to get the power usage:
Power = V_buss * I
The INA3221 ADC native resolution is 13 bits. The resolution of the bus voltage is 8mV (8000 uV) per bit and the resolution for the shunt voltage is 40uV per bit across the sense resistor.
Sample Averaging#
The INA3221 has an averaging function built into the chip itself and is described in the data sheet as:
“Operation begins by first measuring the shunt input signal on channel 1. This value is then subtracted from the previous value that was present in the corresponding data output register. This difference is then divided by the value programmed by the averaging mode setting and stored in an internal accumulation register. The computed result is then added to the previously loaded data output register value, and the resulting value is loaded to the corresponding data output register … The larger the value selected for the averaging mode setting, the less impact or influence any new conversion has on the average value” .
The INA3221 has eight programmable settings, which allow between one and 1,024 samples (in powers of two) to be averaged together.
Running the Application#
The application requires sudo privileges but can be used directly from the command line to get a quick measurement of the power being used at that moment. By default the application will be in “single shot” mode and will just give a snap-shot of the current state. To see a continuous sampling use the -z
option to make it continuous. If you want to have the values output to a log file, use the -l
option and specify the absolute path.
Current options for the application are as follows:
Option
Description
-h
Prints this help message and exits.
-c
Loads configuration values from the configuration file.
-d
Adds extra debug prints.
-l
Log data to file in CSV format. Provide absolute path to output file and -z
is automatically set.
-m
Exponential weighted running average alpha (range between 0 and 1, default = 1.0 no averaging) recursive algorithm:
y[n] = ax[n] + (1-a)y[n-1]
-t
Time delay between samples. Can be decimal. EX: sleep for 0.25 seconds (default = 0.25 sec)
-r
Number of seconds to run for (continuous mode -z
option automatically set). The accuracy/resolution here is given by the time delay (-t
option) if -t
is set to 1 sec then the accuracy of this option is +/- 1 sec.
-a
Number of samples to average. Available options are:
0 = 1 sample (default)
1 = 4 samples
2 = 16 samples
3 = 64 samples
4 = 128 samples
5 = 256 samples
6 = 512 samples
7 = 1024 samples
-b
Bus conversion times. Available options are:
0 = 140 us
1 = 204 us
2 = 332 us
3 = 588 us
4 = 1.1 ms (default)
5 = 2.1 ms
6 = 4.2 ms
7 = 8.2 ms
-s
Shunt conversion times. Available options are:
0 = 140 us
1 = 204 us
2 = 332 us
3 = 588 us
4 = 1.1 ms (default)
5 = 2.1 ms
6 = 4.2 ms
7 = 8.2 ms
-u
Disables GPU-SOC power measurement.
-v
Disables CPU-CV power measurement.
-w
Disables SYS-5V power measurement.
-x
Disables DDR power measurement.
-y
Single shot mode (default).
-z
Continuous mode.