<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 PMBus on the ZCU104
The ZCU104 has some support for monitoring power rails on the board using PMBus. PYNQ exposes these rails through the get_rails function that returns a dictionary of all of the rails available to be monitored.
Step1:  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 rails 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.
Step2:  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
Step3:  The DataRecorder exposes the sensor data as a pandas dataframe
Step4:  or by plotting the results using matplotlib
Step5:  We can get more information by using the mark function which will increment the invocation number without having to stop and start the recorder
<ASSISTANT_TASK:>
Python Code:
import pynq
rails = pynq.get_rails()
rails
Explanation: PMBus on the ZCU104
The ZCU104 has some support for monitoring power rails on the board using PMBus. PYNQ exposes these rails through the get_rails function that returns a dictionary of all of the rails available to be monitored.
End of explanation
recorder = pynq.DataRecorder(rails['12V'].power)
Explanation: 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 rails 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.
End of explanation
import time
with recorder.record(0.5):
    time.sleep(10)
    for _ in range(10000000):
        pass
    time.sleep(10)
Explanation: 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
End of explanation
recorder.frame
Explanation: The DataRecorder exposes the sensor data as a pandas dataframe
End of explanation
%matplotlib inline
recorder.frame['12V_power'].plot()
Explanation: or by plotting the results using matplotlib
End of explanation
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)
Explanation: We can get more information by using the mark function which will increment the invocation number without having to stop and start the recorder
End of explanation
<END_TASK>