Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

MicroZed Chronicles: Using PYNQ to Access PMBus

PMBus and how to work with it in PYNQ.

Adam Taylor
5 years ago

Within our FPGA and SoC designs we create many exciting applications from machine learning, to image and signal processing and industrial control.

However, without the ability to correctly power our devices we will not be able to run our FPGA and SoC-based applications. Modern FPGA and SoC are complex devices requiring low voltage rails at high currents, for the power designer there are several challenges in delivering these voltages within the tight tolerances at high current demands.

The solution to these challenges is to use PMICs or power management ICs such as the IRPS5401 and IRPS5401 that you will find on the Ultra96v2 boards.

These PMICs not only supply the voltages and currents required, but they are also highly configurable over PMBus. Therefore, using PMBus allows the switching frequencies, output voltages and current limits etc to be set.

Even better, we can if need be connect to the PMBus during operation and observe real-time operational conditions.

PMBus is based upon SMbus, which itself is based upon I2C, meaning we can have several slaves on the same bus and read and write the configuration settings of the PMICs on the bus fairly easily. You can find more about PMBus here.

One way these settings are accessed is via a external dongle that connects into the bus. This lets us drive the I2C bus over USB from a PC.

Typically, the PC will run an application which enables the settings of the PMICs to be observed and changed.

However, one of the cool things about the Ultra96v2 is that the I2C bus is also connected into the PMBus via the I2C expander.

This allows us, if we desire, to be able to access the PMICs during operation, read back telemetry and use that information intelligently perhaps to control fan speed based on power dissipation.

Of course, if so desired we can also update the settings of the PMICs at run time though this needs to be done carefully!

To access the PMICs, we would need to create an application to read and write PMBus commands over the I2C bus.

But if you are running PYNQ on your Ultra96v2, you can very easily access the PMBus thanks to the PMBus package contained within the PYNQ package.

While this package does not give us the ability to update the PMICs, it does let us read them, capture and record data that may be of interest later. For example, we could monitor power dissipation during complex applications to determine the power efficiency of the algorithm.

We can access the PMBus functions by opening a new notebook and from the PYNQ package and importing PMBus.

Once this has been imported, we begin to understand a little more about the PMBus network on out Ultra96v2.

To determine the supply rails in the system, we can use the command pmbus.get_rails()

This will report each of the rails in the system along with the current value.

If we wish to record PMbus data, we can use the DataRecorder to record values on a rail for later analysis as well.

This rail information is actually provided by a configuration file within the etc/sensors.d directory of the Linux installation and included as part of the PYNQ build.

If you want to examine this, you can navigate to the directory using a Jupyter Notebook terminal and vi using the command:

root@pynq:/etc/sensors.d# vi ultra96.conf

from within the etc/sensors.d folder.

If you are building PYNQ from scratch for a custom board and wish to include this configuration file, it is installed within packages directory of the board you are targeting.

Now that we understated a little more about how we can use PMBus from our PYNQ environment, I will take a look in future blogs about how we can access PMBus and work with it in directly from our PetaLinux environment to enable us to gather operational telemetry and change current limits.

See My FPGA / SoC Projects: Adam Taylor on Hackster.io

Get the Code: ATaylorCEngFIET (Adam Taylor)

Access the MicroZed Chronicles Archives with over 300 articles on the FPGA / Zynq / Zynq MpSoC updated weekly at MicroZed Chronicles.

Adam Taylor
Adam Taylor is an expert in design and development of embedded systems and FPGA’s for several end applications (Space, Defense, Automotive)
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles