In [1]:
import pynq
rails = pynq.get_rails()
rails
Out[1]:
As can be seen, the keys of the dictionary are the names of the voltage rails while the values are Rail
objects which contain three sensors for the voltage, current and power. Due to limitations of the regulators used on the ZCU104 the resolution of most of the power railes are only to 1/8 W.
To see how power changes under CPU load we can use the DataRecorder
class. For this example we are going to look at total board power as we load one of the CPU cores in Python.
In [2]:
recorder = pynq.DataRecorder(rails['12V'].power)
We can now use the recorder to monitor the applied sensor. For this example we'll sample the power every half second while sleeping and performing a dummy loop
In [3]:
import time
with recorder.record(0.5):
time.sleep(10)
for _ in range(10000000):
pass
time.sleep(10)
The DataRecorder
exposes the sensor data as a pandas dataframe
In [4]:
recorder.frame
Out[4]:
or by plotting the results using matplotlib
In [5]:
%matplotlib inline
recorder.frame['12V_power'].plot()
Out[5]:
We can get more information by using the mark
function which will increment the invocation number without having to stop and start the recorder
In [6]:
recorder.reset()
with recorder.record(0.5):
time.sleep(10)
recorder.mark()
for _ in range(10000000):
pass
recorder.mark()
time.sleep(10)
recorder.frame.plot(subplots=True)
Out[6]:
This clearly shows the power spike when the for loop starts running.