You are currently viewing a new version of our website. To view the old version click .
Electronics
  • Article
  • Open Access

2 April 2022

Prototyping Power Electronics Systems with Zynq-Based Boards Using Matlab/Simulink—A Complete Methodology

,
and
1
Instituto de Telecomunicações, University of Coimbra, Pole 2, 3030-290 Coimbra, Portugal
2
Department of Electrical and Computer Engineering, University of Coimbra, Pole 2, 3030-290 Coimbra, Portugal
*
Author to whom correspondence should be addressed.
This article belongs to the Special Issue Power Converter Design, Control and Applications

Abstract

Many advanced power electronics control techniques present a steep computational load, demanding advanced controllers, such as FPGAs. However, FPGA development is a daunting and time-consuming task, inaccessible to most users. This paper proposes a complete methodology for prototyping power electronics with Xilinx Zynq-based boards using Matlab/Simulink and HDL Coder. Even though these tools are relatively well documented, and several works in the literature have used them, a methodology for developing power electronics systems with them has never been proposed. This paper aims to address that, by proposing a complete programming and design methodology for Zynq-based power electronics and discussing important drawbacks and hurdles in Simulink/HDL Coder development, as well as their possible solutions. In addition, techniques for the implementation of all required peripherals (ADCs, digital outputs, etc.), system protections, and real-time data acquisition on Zynq boards are presented. This methodology considerably reduces the development time and effort of power electronics solutions using Zynq-based boards. In addition, a demonstration Simulink model is provided with all proposed techniques and protections, for use with a readily available development board (Zedboard) and ADC modules. This should further reduce the learning curve and development effort of this type of solution, contributing to a broader access to high-performance control prototyping using Zynq-based platforms. An application example is presented to demonstrate the potential of the proposed workflow, using a Zedboard to control a multilevel UPS inverter prototype with Model Predictive Control.

1. Introduction

Over the last years, many advanced computation and control techniques have been proposed for power electronics. These advanced techniques include solutions such as Model Predictive Control [,] or Artificial Intelligence [], which have proven to be highly advantageous in the fields of energy conversion and power electronics, resulting in significant interest from both the scientific and industrial community. For example, Model Predictive Control (MPC) has shown to be highly advantageous in power electronics, providing good steady-state performance and excellent dynamic response [,]. In addition, this type of controller allows the simultaneous pursuit of multiple independent (and often conflicting) objectives and easy inclusion of system non-linearities and constraints. Hence, it is highly advantageous for the control of complex multi-objective and multi-converter systems, in all kinds of applications [,], such as wind generation [], UPS systems [,] or microgrids [,].
However, these advanced control techniques typically present a critical limitation: they carry a very high computational burden. This characteristic makes their practical implementation extremely difficult. It was only in recent years that available control platforms have become sufficiently powerful to enable broader study and use of these types of computational solutions. The overall complexity of power electronics converters has also significantly increased in the last decades due to the adoption of more complex topologies (such as multilevel converters with an increasing number of levels) and more complex systems and applications (such as multi-phase machines [], modular/paralleled converters [], or multi-converter systems [,]). Using techniques such as MPC leads to an enormous increase in the computational load of the controller. In addition, techniques like MPC require high sampling frequencies, which means all computations must be completed consistently within a very short period (tens of microseconds). Furthermore, the controller must ensure precise timing and perfect synchronization between the acquisition of multiple signals and numerous control inputs and outputs. These requirements greatly hinder the practical implementation of advanced control techniques in power electronics and lead to a critical need for new (affordable and industrially viable) control platforms with very high processing power.
In the context of power electronics development, control platforms can typically be divided into two types: rapid-prototyping solutions and custom platforms. Rapid-prototyping solutions are mainly directed to development and laboratory use, presenting easy-to-use interfaces, numerous safety features, and dedicated development tools that enable fast and easy programming. However, these solutions typically present very high costs, making them unviable for industrial use and inaccessible to many small companies and research groups. On the other hand, custom-developed platforms provide significantly lower costs and perfectly fit the specific needs of a specific product or application. However, this type of solution typically requires dedicated hardware development and complex and time-consuming programming using low-level tools. For this reason, this type of approach is generally not appropriate for research purposes or initial development stages.
Currently, most rapid-prototyping solutions found on the market are based on central processing units (CPUs) or digital signal processors (DSPs), which provide simple and versatile programming, ideal for fast testing and development, with a low programming effort. This approach can be found in products from dSPACE, OPAL-RT, Speedgoat, National Instruments, and others. However, the sequential execution nature of processors limits their processing throughput, limiting the sampling frequencies achievable with complex control systems. Moreover, the sequential nature of processors and the need to switch between multiple tasks limit their ability to ensure perfect timing in input and output (I/O) management and hinder synchronization between different interfaces (such as the ADC sampling and output signal updates). For this reason, several rapid-prototyping platforms now use an FPGA to manage the I/O, in addition to the processor. This allows precise interface control and enables critical parts of the code to be implemented in the FPGA, taking advantage of its parallel execution. The code generation and deployment of rapid-prototyping solutions differ from brand to brand but typically rely on well-known software tools for programming. For example, dSpace, OPAL-RT, and Speedgoat rely on Matlab/Simulink for model-based development, while National Instruments solutions use Labview. On the other hand, many platforms use dedicated proprietary tools for monitoring and interface development (for example, Control Desk from dSpace and RT-LAB from OPAL-RT).
Despite their many advantages, including their ready-made nature and easy programming, rapid-prototyping platforms typically share a common problem: a very high cost. For this reason, researchers frequently resort to lower-cost solutions, such as development boards. While cheap DSPs have historically been a go-to solution for low-cost prototyping of power electronics, they lack the processing power required to control complex systems with advanced control algorithms, such as MPC. Given the steep processing and timing requirements of this type of controller, FPGAs become one of the main options for prototyping. FPGAs offer a high processing capacity and throughput due to their parallel computing capabilities, enable precise I/O timing and synchronization, and guarantee a deterministic processing time. These advantages make FPGAs ideal for advanced controller implementation. However, FPGA programming can be a daunting and time-consuming task, requiring highly specialized hardware description language (HDL) knowledge. The HDL Coder tool found in Matlab/Simulink significantly simplifies FPGA programming, by providing automatic HDL code generation from a model-based Simulink design. This significantly speeds up FPGA development and eliminates the need for HDL expertise [,,,].
Regardless of the used programming technique, debugging and data acquisition can be highly problematic on FPGAs since it is very difficult to have external access to internal variables in real-time, and user interface implementation is also a significant challenge. Hybrid System-on-Chip (SoC) solutions, which include both an FPGA and a processor, partly solve this problem by simultaneously providing the determinism and high processing power of FPGAs and the simple connectivity and user interface of a processor. Furthermore, a dedicated communication interface between the FPGA and processor enables easier data capture and variable visualization, making this solution advantageous for prototyping. Xilinx Zynq chips are the most common hybrid SoCs and are available on numerous development boards.
Despite the clear advantages of Zynq SoCs, their programming is still very complex, especially for non-experts. However, it is now possible to use Matlab/Simulink to program these chips entirely using model-based techniques. HDL Coder enables a direct generation of HDL code for the FPGA directly from Simulink models, while Embedded Coder enables code generation for the ARM processor found on Zynq chips. This reduces (or even eliminates) the need for low-level programming and makes prototyping with these chips viable to non-experts. Additionally, it is possible to simulate both the processor and FPGA response directly from Simulink, shortening the development time. Given the low cost of many Zynq-based development boards, these SoCs become an excellent choice for low-cost prototyping with advanced control techniques.
Various work can be found in the literature taking advantage of both standalone FPGAs [,,,,] and Zynq SoCs [,,,,,,,,,,] to control power electronics devices. Most presented Zynq-based solutions use development boards for prototyping [,,,,,,,], including the Zedboard used in this paper [,,,,]. A custom hardware platform is proposed in [] specifically for power electronics control. In [], a high-performance custom control platform is also proposed for power electronics, using the higher-end Ultrascale+ family of Zynq chips, for ultra-high performance (but with significantly higher cost).
Many FPGA-based solutions found on the literature rely on conventional low-level coding (typically using HDL and C on Xilinx tools) [,,,,]. Other solutions use the Xilinx System Generator toolbox in Matlab/Simulink, to enable model-based design [,]. However, despite providing a model-based design approach, this tool does not provide some of the advantages of HDL Coder, such as several automatic optimization and pipelining options, automatic delay balancing, assisted fixed-point design, or the use of regular Simulink blocks (much more intuitive for Simulink users).
Several solutions found on the literature have used Matlab/Simulink and HDL Coder [,,,,,,] for FPGA programming, including on Zynq chips [,]. However, even though these works use these tools for experimental implementation, they do not discuss their use, the programming philosophy, or their limitations. Therefore, even though these papers discuss the advantages of using HDL Coder, they do not provide any information on its use or the development process. In fact, several papers mention only a partial use of HDL Coder, to generate the HDL code for a given algorithm, then using other development tools (such as the Xilinx Vivado suite) for final programming and deployment. This paper proposes a complete methodology to fully program the FPGA of Zynq-based boards using Simulink and HDL Coder and to deploy the code into the platform.
Furthermore, the programming of the ARM processor in Zynq-based boards using the Embedded Coder tool is not typically leveraged by the solutions found in the literature—low-level development tools are typically adopted or the processor is not extensively used. In [], the authors discuss the advantages of using Embedded Coder for partial development of the ARM processor code. However, it is only used to generate a C code for specific algorithms, with that code being manually integrated into a more complex code using low-level tools. Hence, Embedded Coder is not used for the overall programming of the ARM processor nor for direct deployment. The use of this tool is also only briefly mentioned, but not discussed. To the best of the authors’ knowledge, no solutions found in the literature have yet used the HDL Coder and Embedded Coder tools to fully program and deploy power electronics control and monitoring solutions in Zynq-based boards, in power electronics applications. This paper proposes a complete methodology and workflow to design and deploy power electronics solutions entirely from the Matlab/Simulink environment, without the need for interaction with additional tools or low-level coding (neither C nor HDL).
In addition to the design methodology and development workflow, this paper extensively covers the real-time monitoring of power electronics systems from Simulink, using Zynq-based boards. This presents a crucial advantage for debugging and fine-tuning control algorithms implemented in the FPGA for real-time execution, not possible when using stand-alone FPGAs (even if programmed using HDL Coder). In [], a custom interface is proposed for real-time monitoring, but it relies on custom code and therefore implies development outside Matlab/Simulink, with low-level coding tools.
Even though the tools provided by Mathworks are relatively well documented and make prototyping with Zynq devices significantly easier, their setup and use are not entirely straightforward and can present a steep learning curve. For this reason, this paper presents a detailed description on setting up and using all the necessary tools. The proposed design methodology is then described in detail. This paper does not merely show how to use the software tools, but instead presents a complete programming philosophy and design methodology, from peripheral management to real-time monitoring. This includes the analysis of several drawbacks of HDL Coder’s automatic code generation for real-time power electronics control and solutions to overcome them.
This paper also proposes techniques for the implementation of all peripheral hardware typically required for power electronics (ADCs, isolated digital outputs, etc.) and to overcome possible controller limitations, such as insufficient input/output ports. Several protection mechanisms are also proposed for safe power electronics prototyping. The proposed solution allows a continuous real-time monitoring of any number of waveforms and internal controller variables using Simulink External mode. A technique is also proposed to perform lossless data acquisition (with no undersampling) of limited time windows.
A demonstration model is provided by the authors, with the proposed techniques and peripheral management code pre-implemented, for immediate testing on a commercially available development board—a Zedboard—and with off-the-shelf ADC modules. This provides the reader with a low-cost, easy-to-use starting point to test the proposed techniques and start prototyping power electronics systems using the proposed methodology. This should significantly reduce the learning curve and development effort of this type of solution, contributing to a broader access to high-performance power electronics control using Zynq-based platforms.
To demonstrate the potential of this type of controller for advanced control of power electronics converters, the Zedboard is used to control a multilevel inverter using Model Predictive Control. Experimental results are presented for the proposed techniques and for the UPS application example.
To summarize, the main contributions of this paper are as follows:
  • A complete design methodology for power electronics using Zynq-based boards and Matlab/Simulink tools is proposed for the first time.
  • The proposed methodology allows programming of both the FPGA and ARM processor found in Zynq-based boards entirely from the Simulink graphical environment, with no low-level coding. Previous solutions found in the literature typically program only the FPGA using Simulink and often for partial development (completed in low-level tools). Few previous solutions have used Simulink to program the ARM processor in Zynq chips for power electronics applications, and none have used it for complete development (FPGA+ARM) and real-time deployment and monitoring, entirely from Simulink (with no additional tools or coding).
  • The proposed methodology allows continuous real-time monitoring of power electronics systems with Zynq-based boards directly from Simulink, with no need to develop custom interface tools. This presents a vital advantage for FPGA control algorithm implementation, since it enables easy real-time access to any internal control variable—critical for debug and controller tuning. A technique for data acquisition with no sample loss is also proposed.
  • Analysis of several HDL Coder drawbacks for power electronics control, such as unreliable processor execution cycles or peripheral timing corruption due to automatic delay balancing, is not properly described in the literature. Techniques are proposed in this research to avoid/mitigate these problems.
  • This paper also includes a proposal of hardware peripheral management techniques and protection mechanisms to stop power converter operation in case of over-current, over-voltage, processor lock (crash), or loss of communication with the host computer.
  • We also provide distribution of a Simulink demonstration model including all proposed programming techniques and hardware management solutions, for easy and immediate reproduction and testing by the reader, using commercially available development board and ADC modules.
This type of detailed study and proposal of a development methodology for rapid prototyping of power electronics using Zynq-based devices has never been available in the literature. Furthermore, the distribution of ready-to-use solutions (Simulink code made available for direct use) provides a major contribution for research groups, educators, and companies to be able to use these tools for power electronics prototyping, significantly reducing the development time and effort.
This paper is organized as follows: in Section 2, the hardware requirements for power electronics control are analyzed and possible implementations are discussed. In Section 3, the proposed design philosophy for Zynq SoCs from Matlab/Simulink is presented. Section 4 presents the required software tools and respective setup process. Section 5 is the main section of the paper and presents the proposed development methodology for Zynq-based boards using Simulink. Section 6 presents a power electronics application example controlled using a Zedboard. Lastly, Section 7 presents the final conclusions.

2. Control platform Hardware Requirements for Power Electronics Control

Power electronics systems can present radically different structures, with different converter topologies and applications. Thus, hardware requirements change significantly depending on the system and its defined requirements. For example, the number and type of sensors and the number of semiconductors to control varies significantly depending on the target application and converter topology. The connectivity requirements of the system can also significantly vary, ranging from no connectivity at all (fully standalone operation) to networked or internet-connected applications (critical for the industry 4.0 paradigm).
Figure 1 presents a simplified representation of some of the most common controller interfaces and peripheral hardware required for power electronics converter control.
Figure 1. Most common controller interfaces and peripheral hardware needed for power electronics control.
As shown in the figure, many distinct controller interfaces can be used in power electronics control for different purposes. However, some interfaces are mandatory and can be found in all power electronics controllers (highlighted in red in Figure 1):
  • Digital outputs for power switch gate signals;
  • Analog inputs for sensor data acquisition.
Without these interfaces, closed-loop power converter control would be impossible. Other interfaces can also be highly advantageous for power electronics design and control but are not found in all applications. Some of the most common examples are:
  • User interface and data acquisition—enables data visualization, debugging, and parameter tuning;
  • Gate driver status readout—useful when gate drivers provide status/error signals;
  • Communication interfaces for interaction with other systems (e.g., other controllers), internet connectivity or remote monitoring;
  • Digital inputs/outputs for auxiliary signals, such as panel signaling and command.
All listed interfaces can be implemented in several manners. This paper presents simple and inexpensive ways to implement these interfaces for prototyping using Zynq-based controllers. The requirements for each interface and proposed implementations are presented below.

2.1. Main Controller

The most critical component of the control platform is the main controller board. In the context of this paper, the main controller is assumed to be a Zynq-based board. Using a Zynq-based controller enables both the precise peripheral control and deterministic execution of an FPGA and the simple connectivity of a processor. In this paper, a commercially available Zedboard development kit is used. This board was selected due to its wide availability, comprehensive documentation, and vast community support. Additionally, this board is pre-supported by HDL Coder and Embedded Coder, which means no manual board configuration is required to start programming the board from Matlab/Simulink. This is ideal for the first contact with Zynq-based development from Simulink, making setup easier for new users.

2.2. Analog to Digital Converters (ADCs)

Analog inputs are essential in power electronics systems, as they define how the controller perceives the state of the system. ADCs must have an acceptable level of precision and a sufficiently high sampling frequency. In addition, all ADC channels must be sampled simultaneously—this is especially important in many advanced control techniques, such as MPC.
For easy implementation and reproduction, commercially available ADC modules are used in this paper, specifically Pmod AD1 modules from Digilent []. Each module provides two simultaneously sampled ADC channels with a 12-bit resolution and up to 1 million samples per second. Each module can be directly plugged into a Pmod connector on the Zedboard, making prototyping and experimenting very practical. The controller must read data from the ADC modules using serial communication (implementation discussed in Section 5).

2.3. Digital Inputs and Outputs

Digital inputs and outputs (I/O) are the most common interfaces found in control boards, reading or writing binary signals. In power electronics, digital outputs are critical for activating the power switch gate drivers. Digital inputs and outputs can also be used for other purposes, such as interacting with auxiliary circuits, reading back gate driver status or activating signaling (such as panel lighting). Hence, in complex power electronics systems, such as those with multiple converters or multilevel topologies, a tremendous amount of digital ports may be required.
Since most Zynq-based development boards have limited FPGA ports available externally, these may be insufficient to implement all necessary peripherals directly. In this case, several techniques can be used to overcome the limitation.
Most converter topologies use complementary signals to activate pairs of power switches: Thus, it is possible to generate control signals for only half the switches and use external logic to invert those signals for the remaining switches. However, this makes it impossible to simultaneously deactivate all switches (which might be necessary for safety reasons). It also makes it impossible to generate a deadtime between the activation of complementary switches. For this reason, this technique is not considered in this paper. Instead, different approaches are proposed to increase the number of available digital outputs (or inputs). These approaches are schematically represented in Figure 2 for the output case (inputs can be implemented analogously).
Figure 2. Proposed techniques for digital output implementation and expansion. (a) Direct connection of FPGA ports to the target circuit. (b) Expansion of available output ports using shift registers. (c) Expansion of available output ports using a secondary FPGA for port management.
If the used board has sufficient ports for all peripherals, each digital port can be controlled directly by an FPGA port, as shown in Figure 2a. This is the easiest option to implement and the most reliable. The gate activation signals must be isolated from the potential of the power switch, not only to prevent short-circuits between different points of the converter but also to protect the controller from any phenomena on the power circuit. Optocouplers or digital isolators typically ensure this isolation. In this paper, SI8237 digital isolators [] are used, simultaneously providing isolation and level shifting from the 3.3 V found on the Zedboard ports to 15 V, the voltage level required by the used gate drivers. An analogous approach can be used for digital inputs.
If sufficient ports are not available, it is possible to use serial-to-parallel shift registers to convert a single data line (streamed serially) into a high number of outputs. This solution, represented in Figure 2b, allows almost infinite expansion of the available outputs, with very few data lines. However, the output port update time increases with the number of signals, so a very long chain is not recommended. The non-negligible port update time means this solution may not allow a reliable generation of deadtimes or the implementation of modulators. This solution is therefore better suited for low-speed non-critical outputs. In this paper, BU4094BCF shift registers [] are used, associated in a daisy chain. This way, only four data lines are needed on the Zynq FPGA-serial clock, data line, strobe, and output enable. Furthermore, only four digital isolators are required, instead of one for each channel. The used SI8237 isolators translate the signals to 15V, and the shift registers operate directly at this voltage—this significantly reduces system cost compared to individual isolators for all outputs. An analogous approach can be used for reading inputs, using parallel-to-serial shift registers.
A more advanced solution, illustrated in Figure 2c, is to use a secondary (low-cost) FPGA uniquely for port management. The main advantage of this approach is its extremely high versatility. Since each output is controlled directly by an FPGA, deadtimes can be precisely controlled, and modulation techniques can be easily implemented. The Zynq controller sends commands to the secondary FPGA over a communication bus, so only a few ports are needed on the Zynq board. The secondary FPGA is intended only for I/O management and does not perform intensive calculations. Thus, very cheap FPGA boards with a high number of ports can be used. This paper uses a Spartan 7 FPGA board (S7 Mini from Trenz []), which has 64 available FPGA ports. Even cheaper FPGA boards can be found (e.g., Spartan 6 or Spartan 3 FPGAs). However, the Vivado tools only support Xilinx 7-series FPGAs. Thus, a 7-series FPGA was selected to enable its programming from Simulink (discussed in Section 5.8.4).
The communication interface with the secondary FPGA can be implemented in many different ways, but a simple serial communication approach is proposed in this paper. This approach requires only three output ports: two for communication (a serial clock and a data line) and one output clock that indicates the start of the sampling period. The synchronization with the secondary FPGA is implemented as shown in Figure 3.
Figure 3. Proposed synchronization mechanism for outputs managed by the secondary FPGA.
As shown in Figure 3, the controller has a given (deterministic) calculation time. When all calculations are complete, the main controller (Zynq) immediately sends the switching states (or duty cycles) to be applied in the next sampling period to the second FPGA. This way, the secondary FPGA receives this information before the next sampling instant. When the next sampling period begins (indicated by the cycle_start bit), the secondary FPGA applies the new states (or updates the duty cycle of the modulator, if one is used). This guarantees near-perfect synchronization between the analog sampling and digital output activation, making this solution perfect for critical signals and signals with strict timing requirements, such as the power switch gate signals.
In addition to outputs, the secondary FPGA can also be used to manage inputs. If bidirectional communication is implemented, it can read inputs and return their value to the Zynq-based controller.

2.4. User Interface and Data Acquisition

In this paper, all user interface and acquisition functions are performed using Matlab/Simulink and supporting Add-Ons. This toolchain allows easy simulation and programming of both the FPGA and processor components of the Zynq platform. The Zynq board is network-connected to a host computer (via ethernet in the Zedboard case). The host computer can monitor and control the system in real-time, allowing the user to acquire data from the platform and alter controller parameters. The controller programming philosophy and workflow are discussed in the following sections.

4. Development Workflow Setup

The presented development workflow requires several tools and components to be properly configured. The overall setup process is schematically represented in Figure 6 and described in detail below.
Figure 6. Setup process of the proposed development workflow.
The following software tools are required to develop and deploy control algorithms from Matlab/Simulink to Zynq-based platforms:
  • Matlab/Simulink with HDL Coder Toolbox and Embedded Coder Toolbox.
  • Xilinx Vivado (System Edition is recommended, but the free Webpack can be used if the chosen board is supported).
It is important to note that compatible versions of the two software tools must be installed. Each HDL Coder release supports only one version of the Vivado Design Suite, which can be found in []. For the results presented in this paper, Matlab R2019b and Vivado 2018.3 were used. It should be noted that if Vivado System Edition is used, the “System Generator” tool does not officially support the Matlab version required for HDL Coder compatibility, so it is necessary to manually alter the list of compatible versions for the tool to interact with Matlab (steps found on []). If Vivado System Edition is used, it is recommended to start Matlab using the System Generator tool, which automatically configures the connection to Xilinx tools. Otherwise, the HDL generation tool must be configured manually every time Matlab is opened (using the command hdlsetuptoolpath(‘ToolName’,‘XilinxVivado’,‘ToolPath’,‘C: \Xilinx\Vivado\2018.3\bin\vivado.bat’), with the appropriate Vivado version).
The following Matlab Add-Ons must be installed from the Add-On Explorer:
  • HDL Coder Support Package for Xilinx Zynq-7000 Platform.
  • Embedded Coder Support Package for Xilinx Zynq-7000 Platform.
  • A supported compiler (MinGW-w64 is a practical choice, which can be installed directly from the Matlab Add-On Explorer).
Next, it is necessary to configure the add-ons for the correct hardware board. In order to use the HDL Coder, a board definition is required, which defines the target FPGA and respective interfaces. The add-on natively supports several development boards, which include the Zedboard used in this paper. For any of these boards, the tool includes pre-configured board definition files, so no manual setup is required.
If the target platform is not pre-supported by HDL Coder, it is necessary to create a custom board definition to enable FPGA code generation from Simulink. With appropriate board definition files, the HDL Coder tool can generate code for any Xilinx board supported by the used Vivado version. The board files can be found in C:\ProgramData\MATLAB\SupportPackages\R2019b\toolbox\hdlcoder\supportpackages\zynq7000, where R2019b should be replaced with the correct Matlab version. Custom boards should be added here, according to the instructions found on []. After adding a custom board, Simulink is able to generate code for its FPGA.
To program the ARM processor from Simulink, the Embedded Coder Support Package for Xilinx Zynq-7000 Platform must also be configured. This requires the board to run an OS which supports all features and libraries required by the tool, enabling communication and programming directly from Simulink. Several development boards are natively supported by this Add-On (including the Zedboard). For these boards, pre-configured OS images are included. In this case, the user only needs to run the add-on setup from the Matlab Add-On Manager. This provides a setup wizard which writes the OS image to the target SD card and configures the network interface for communication with the board. Pre-configured files for other boards can also be found on the official Mathworks GitHub [] or in community forums.
If the desired board is not pre-supported by Mathworks or the community, it is also possible to generate a custom Linux OS image using the Buildroot tools provided by Mathworks [] or building a custom Petalinux image with all required libraries. However, this process depends on the target platform and requires a high level of familiarity with Linux OS building and these specific tools, so it will not be discussed in this paper. Additionally, if the user does not want to program the ARM processor using Simulink (only the FPGA), the Embedded Coder Support Package setup can be skipped.
This paper focuses uniquely on prototyping with Zynq-based boards entirely from Simulink, taking advantage of both the FPGA and processor, so both the HDL Coder and Embedded Coder tools are used. Given that the used board (Zedboard) is entirely supported by both tools, the initial setup is fast and effortless. This makes the Zedboard a perfect platform for initial testing of the proposed development workflow and for lab-oriented prototyping.

6. Application Example—Control of a Multilevel Converter using MPC

As an example to demonstrate the potential of the proposed prototyping and development workflow, Simulink was used to develop and program a Finite Control Set Model Predictive Controller for a UPS inverter, for execution on the Zedboard. The overall system representation is shown in Figure 28 and the experimental setup is shown in Figure 29. The controller internal assembly can be seen in Figure 27.
Figure 28. Schematic representation of the experimental setup used for UPS inverter control.
Figure 29. Experimental UPS inverter prototype setup.
A three-level Neutral-Point-Clamped converter topology was used, to increase the controller complexity. This multilevel topology has 12 power switches and 27 distinct switching possibilities. The UPS inverter is fed by a DC bus generated using an auto-transformer and a three-phase rectifier with capacitive filtering. A DC bus voltage of approximately 210 V is used. The UPS inverter uses an LC output filter, with parameters 2.7 mH and 66 μ F . A three-phase output voltage reference with 120 V RMS is used.
LEM sensors and custom signal conditioning boards are used to acquire the four currents and four voltages shown in Figure 28. The signal conditioning circuitry converts each (bipolar) sensor measurement into an analog unipolar voltage in the range 0–3.3 V, to be read by the ADC (a zero sensor reading translates directly a voltage of 1.65 V , centered with the ADC range). The bipolar voltage calculation used in the demo model is therefore used. Four Pmod AD1 modules are used to measure these eight signals simultaneously.
The output gate driver activation signals for the 12 Mosfets are obtained directly from independent Zedboard outputs. Each signal is isolated using SI8237 digital isolators, which ensure isolation and convert the signal from the 3.3 V at the Zedboard port to 15 V , as required by the used gate drivers. This system was also tested using the shift-register and secondary FPGA approaches for the implementation of the output pulses, with similar results being obtained. Nonetheless, this direct output implementation is advantageous because it allows deadtimes to be implemented (unlike the shift-register approach) and is less susceptible to EMI than using a secondary FPGA (since there is no need for the high-speed serial communication bus between FPGAs, which can be affected by noise).
A controller sampling period of 70 μ s is used, with an FPGA sampling period of 40 ns and an ARM sampling period of 210 μ s (the same periods used in the demo model). The controller takes approximately 11 μ s from the start of cycle (ADC sampling instant) to obtain the control states which should be applied at the next sampling instant. This can be seen in Figure 24a, when executing the same controller code, but using a secondary FPGA to control the outputs. Since the ADC conversion and data readout takes approximately 6.4 μ s, this means the FPGA takes approximately 4.6 μ s to perform all calculations required by the MPC algorithm and obtain the final switching decision. This is a quite low controller latency, especially considering that the FPGA programming done in Simulink was not optimized for fast execution. This means the same control algorithm could easily be used with a sampling time considerably below 10 μ s if the ADC communication frequency was increased. This would be extremely difficult to achieve with purely processor-based controllers, demonstrating the advantage of using the proposed Zynq-based solution for power electronics prototyping.
Since the study of the UPS inverter control is not the objective of this paper, the converter operation will not be studied in detail. Instead, only the main waveforms will be presented, to demonstrate the correct operation of the controller when executed in the Zedboard.
The MPC controller has two objectives in its objective function: minimization of load voltage error (in an α β reference frame), and minimization of the DC bus capacitors unbalance. The implemented UPS inverter prototype is used to feed both a linear load (resistive) and highly non-linear load (three-phase diode rectifier with parallel RC load). The results obtained in both cases are displayed in Figure 30 and Figure 31.
Figure 30. UPS Inverter prototype experimental waveforms with linear and non-linear loads, acquired with the the oscilloscope. (a) Linear Load. (b) Non-Linear Load.
Figure 31. UPS Inverter prototype experimental waveforms with linear and non-linear loads, acquired with the Zedboard, using Simulink External mode. (a) Linear Load. (b) Non-Linear Load.
As seen in Figure 30 and Figure 31, the UPS is able to maintain sinusoidal output voltage with relatively low distortion, even when feeding a highly non-linear load. When feeding a linear load, the load voltage THD is approximately 2.6%. In the non-linear case, which generates highly non-linear current waveforms, a load voltage THD of 3.4% is obtained. In both cases, the load voltage distortion is well below the limits defined in international standards. The DC bus capacitors also remain perfectly balanced in both scenarios. Hence, the controller is working perfectly, ensuring good performance in both considered objectives.
The waveforms presented in Figure 31 were obtained directly using Simulink External mode, which demonstrates the perfectly acceptable visualization provided by this execution mode (even with some under-sampling). The continuous External mode execution is extremely useful for overall system monitoring and for controller parameter adjustment and tuning.
The proposed FIFOs can also be used to obtain the full-sampled waveforms. These can be useful, for example, for precise THD calculation or fine controller debugging or reproduction. Figure 32 shows the load voltage waveforms measured directly from the AXI interface in External mode (under-sampled) and the waveforms reconstructed from the FIFO during the same time window (full-sampled).
Figure 32. Load voltage waveforms acquired directly from the AXI interface and using the FIFO, for the same time window.
As seen in Figure 32, the FIFO allows the waveforms to be acquired with significantly higher detail. This is important for better reproduction and for more accurate calculation of THDs, RMS values, etc.

7. Conclusions

A complete methodology for programming Zynq-based boards for power electronics prototyping using Matlab/Simulink and the HDL Coder and Embedded Coder tools is proposed in this paper for the first time. The proposed methodology enables the programming of Zynq chips, enabling the user to develop and monitor power electronics systems entirely from the Simulink graphical interface. This enables any user with Simulink experience to prototype power electronics systems with Zynq boards, even with no HDL or C expertise.
Unlike previous work found in the literature using HDL Coder for power electronics development, the proposed methodology allows full programming and deployment of code for both the FPGA and ARM processor, entirely from the Simulink, with no need for low-level coding or development in external tools. Most solutions found in the literature use Zynq boards as headless systems (no interface) or use custom-developed tools or low-level programming for graphical monitoring and data acquisition. The proposed techniques allow continuous real-time monitoring of power electronics systems directly from Simulink, providing a versatile and easy-to-use solution.
A thorough description of the setup and use of all tools required for the proposed software workflow is presented. The proposed design methodology and limitations of the Zynq platform are discussed in detail, proposing an optimal task distribution between the FPGA and processor for power electronics development, considering these limitations. The Simulink design requirements and limitations are also discussed, such as sampling times definition, delay balancing management and ARM execution reliability. The implementation of external hardware interfaces is also discussed in detail. Several shortcomings of the Zynq platform and Simulink tools that were not previously analyzed in the literature are discussed in detail, including possible peripheral timing corruption due to the automatic delay balancing mechanism in Simulink, which can compromise ADC operation, for example. A design solution is proposed to avoid this problem.
A data acquisition technique is also proposed for lossless (full-sampled) data acquisition, avoiding under-sampling due to a high processor execution time. This technique allows high-definition sampling of data, with customizable oscilloscope-like trigger control, which is ideal for power electronics applications, to enable the capture of specific events (displaying lossless data before and after the triggering event).
The proposed design methodology includes safety mechanisms to protect the system from over-voltages and over-currents, and avoid loss of control when the CPU crashes or communication with the host computer is lost. This guarantees that the FPGA safely disables the power converter when unwanted events are detected or the user loses the ability to monitor and control of the system (due to CPU or communication failure).
The Simulink implementation of all proposed techniques and mechanisms of the proposed design methodology is provided in a demo model. This enables easy and immediate reproduction by the reader and provides a major advantage for any new user—this typically cannot be found online, especially for all components needed for power electronics prototyping. The provided demo model uses only commercially available hardware (Zedboard development kit and Pmod AD1 ADC modules). This should jump-start development using this design methodology for any interested research group, company or individual.
The potential of the proposed workflow for power electronics control is demonstrated by controlling a three-level Neutral-Point-Clamped UPS inverter prototype with model predictive control. The low execution times obtained in the results (even without specific optimization) and good obtained UPS performance demonstrate that the proposed workflow can easily be used for the control of complex power electronics converters with advanced control techniques, using low-cost control platforms and peripheral hardware.
References yes

Author Contributions

Conceptualization, L.C.; methodology, L.C.; software, L.C. and D.C.; validation, L.C. and D.C.; formal analysis, L.C. and D.C.; investigation, L.C. and D.C.; resources, A.M.; data curation, L.C. and D.C.; writing—original draft preparation, L.C. and D.C.; writing—review and editing, L.C., D.C. and A.M.; visualization, L.C., D.C. and A.M.; supervision, L.C. and A.M.; project administration, A.M..; funding acquisition, L.C. and A.M. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported in part by the Project SAICT-45-2017-POCI-01-0145-FEDER-029112—PTDC/ EEI-EEE/29112/2017, funded by Programa Operacional Temático Competitividade e Internacionalização—FEDER and by the Foundation for Science and Technology (FCT)—OE, and in part by the Project UIDB/EEA/50008/2020, funded by FCT–OE.

Data Availability Statement

The demo model utilized in this paper is available here: https://github.com/PS-Co-IT/Zynq_Simulink, last accessed on 7 February 2022.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

References

  1. Alam, M.; Ahmad, S.; Anees, M.A.; Tariq, M.; Azeem, A. Comprehensive Review on Model Predictive Control Applied to Power Electronics. Recent Adv. Electr. Electron. Eng. 2020, 13, 632–640. [Google Scholar] [CrossRef]
  2. Vazquez, S.; Rodriguez, J.; Rivera, M.; Franquelo, L.G.; Norambuena, M. Model Predictive Control for Power Converters and Drives: Advances and Trends. IEEE Trans. Ind. Electron. 2017, 64, 935–947. [Google Scholar] [CrossRef] [Green Version]
  3. Zhao, S.; Blaabjerg, F.; Wang, H. An Overview of Artificial Intelligence Applications for Power Electronics. IEEE Trans. Power Electron. 2021, 36, 4633–4658. [Google Scholar] [CrossRef]
  4. Gonçalves, P.; Cruz, S.; Mendes, A. Finite Control Set Model Predictive Control of Six-Phase Asymmetrical Machines—An Overview. Energies 2019, 12, 4693. [Google Scholar] [CrossRef] [Green Version]
  5. Oliveira, T.; Caseiro, L.; Mendes, A.; Cruz, S.; Perdigão, M. Model Predictive Control for Paralleled Uninterruptible Power Supplies with an Additional Inverter Leg for Load-Side Neutral Connection. Energies 2021, 14, 2270. [Google Scholar] [CrossRef]
  6. Caseiro, L.M.A.; Mendes, A.M.S.; Cruz, S.M.A. Cooperative and Dynamically Weighted Model Predictive Control of a 3-Level Uninterruptible Power Supply With Improved Performance and Dynamic Response. IEEE Trans. Ind. Electron. 2020, 67, 4934–4945. [Google Scholar] [CrossRef]
  7. Garcia-Torres, F.; Zafra-Cabeza, A.; Silva, C.; Grieu, S.; Darure, T.; Estanqueiro, A. Model Predictive Control for Microgrid Functionalities: Review and Future Challenges. Energies 2021, 14, 1296. [Google Scholar] [CrossRef]
  8. Villalón, A.; Rivera, M.; Salgueiro, Y.; Muñoz, J.; Dragičević, T.; Blaabjerg, F. Predictive Control for Microgrid Applications: A Review Study. Energies 2020, 13, 2454. [Google Scholar] [CrossRef]
  9. van Beek, S.; Sharma, S.; Prakash, S. Four Best Practices for Prototyping MATLAB and Simulink Algorithms on FPGAs. Verif. Horiz. 2012, 8, 6. [Google Scholar]
  10. Versen, M.; Kipfelsberger, S.; Soekmen, F. Model-Based Reference Design Projects with MathWorks’ HDL Workflow Advisor for Custom-Specific Electronics with the Zedboard. In Proceedings of the ANALOG 2016; 15. ITG/GMM-Symposium, Bremen, Germany, 12–14 September 2016; pp. 1–4. [Google Scholar]
  11. Siwakoti, Y.P.; Town, G.E. Design of FPGA-controlled Power Electronics and Drives Using MATLAB Simulink. In Proceedings of the 2013 IEEE ECCE Asia Downunder, Melbourne, VIC, Australia, 3–6 June 2013; pp. 571–577. [Google Scholar] [CrossRef]
  12. Sumam, M.; Shiny, G. Rapid Prototyping of High Performance FPGA Controller for an Induction Motor Drive. In Proceedings of the 2018 8th International Conference on Power and Energy Systems (ICPES), Colombo, Sri Lanka, 21–22 December 2018; pp. 76–80. [Google Scholar] [CrossRef]
  13. Sumam, M.J.; Shiny, G. A Rapid Development Technique for Prototype FPGA Controllers. In Proceedings of the 2017 International Conference on Inventive Systems and Control (ICISC), Coimbatore, India, 19–20 January 2017; pp. 1–5. [Google Scholar] [CrossRef]
  14. Shah, V.; Prakash N., K. FPGA Implementation of Sensorless Field Oriented Current Control of Induction Machine. In Proceedings of the 2017 IEEE International Conference on Computational Intelligence and Computing Research (ICCIC), Coimbatore, India, 14–16 December 2017; pp. 1–5. [Google Scholar] [CrossRef]
  15. Titri, S.; Larbes, C.; Toumi, K.Y. Rapid Prototyping of PVS into FPGA: From Model Based Design to FPGA/ASICs Implementation. In Proceedings of the 2014 9th International Design and Test Symposium (IDT), Algeries, Algeria, 16–18 December 2014; pp. 162–167. [Google Scholar] [CrossRef]
  16. Zafra, E.; Vazquez, S.; Miranda, H.G.; Sanchez, J.A.; Marquez, A.; Leon, J.I.; Franquelo, L.G. Efficient FPSoC Prototyping of FCS-MPC for Three-Phase Voltage Source Inverters. Energies 2020, 13, 1074. [Google Scholar] [CrossRef] [Green Version]
  17. Galassini, A.; Lo Calzo, G.; Formentini, A.; Gerada, C.; Zanchetta, P.; Costabeber, A. uCube: Control Platform for Power Electronics. In Proceedings of the 2017 IEEE Workshop on Electrical Machines Design, Control and Diagnosis (WEMDCD), Nottingham, UK, 20–21 April 2017; pp. 216–221. [Google Scholar] [CrossRef]
  18. Wendel, S.; Geiger, A.; Liegmann, E.; Arancibia, D.; Durán, E.; Kreppel, T.; Rojas, F.; Popp-Nowak, F.; Diaz, M.; Dietz, A.; et al. UltraZohm-a Powerful Real-Time Computation Platform for MPC and Multi-Level Inverters. In Proceedings of the 2019 IEEE International Symposium on Predictive Control of Electrical Drives and Power Electronics (PRECEDE), Quanzhou, China, 31 May–2 June 2019; pp. 1–6. [Google Scholar] [CrossRef]
  19. Rojas-Rocco, F.; Baier-Fuentes, C.; Ramírez-Alegría, R.; Díaz-Bustos, M.; Melin-Coloma, P. Application of the Zynq 7000 System in the Control of a Boost Converter. In Proceedings of the 2019 IEEE CHILEAN Conference on Electrical, Electronics Engineering, Information and Communication Technologies (CHILECON), Valparaiso, Chile, 13–27 November 2019; pp. 1–6. [Google Scholar] [CrossRef]
  20. Sharma, S.; Deshpande, A. Design and Development of Maximum Power Point Tracking Algorithm Using Field Programmable Gate Array. In Proceedings of the 2017 2nd IEEE International Conference on Recent Trends in Electronics, Information Communication Technology (RTEICT), Bangalore, India, 19–20 May 2017; pp. 1560–1563. [Google Scholar] [CrossRef]
  21. Mohammadi, D.; Daoud, L.; Rafla, N.; Ahmed-Zaid, S. Zynq-Based SoC Implementation of an Induction Machine Control Algorithm. In Proceedings of the 2016 IEEE 59th International Midwest Symposium on Circuits and Systems (MWSCAS), Abu Dhabi, United Arab Emirates, 16–19 October 2016; pp. 1–4. [Google Scholar] [CrossRef]
  22. Moranchel, M.; Sanchez, F.M.; Bueno, E.J.; Rodriguez, F.J.; Sanz, I. Six-Level Modular Multilevel Converter Prototype with Centralized Hardware Platform Controller. In Proceedings of the IECON 2015-41st Annual Conference of the IEEE Industrial Electronics Society, Yokohama, Japan, 9–12 November 2015; pp. 003863–003868. [Google Scholar] [CrossRef]
  23. He, L.; Wang, F.; Wang, J.; Rodríguez, J. Zynq Implemented Luenberger Disturbance Observer Based Predictive Control Scheme for PMSM Drives. IEEE Trans. Power Electron. 2020, 35, 1770–1778. [Google Scholar] [CrossRef]
  24. Sankhe, D.N.; Sawant, R.R.; Rao, Y.S. FPGA-Based Hybrid Control Strategy for Resonant Inverter in Induction Heating Applications. IEEE J. Emerg. Sel. Top. Ind. Electron. 2022, 3, 156–165. [Google Scholar] [CrossRef]
  25. Bolun, W.; Tao, Z.; Zhengjin, S.; Hualiang, Z.; Feng, X.; Zihong, L. A Method for Rapid Deployment of Brushless DC Motor Servo System Model Based on FPGA. In Proceedings of the 2021 6th International Conference on Automation, Control and Robotics Engineering (CACRE), Dalian, China, 15–17 July 2021; pp. 379–384. [Google Scholar] [CrossRef]
  26. Pmod AD1-Digilent Reference. Available online: https://digilent.com/reference/pmod/pmodad1/start (accessed on 8 February 2022).
  27. Skyworks | Si822x/3x Isolated Gate Drivers. Available online: https://www.skyworksinc.com/Products/Isolation/Si822x-3x-Isolated-Gate-Drivers (accessed on 8 February 2022).
  28. BU4094BCF-Data Sheet, Product Detail | ROHM.Com. Available online: https://www.rohm.com/products/switch-multiplexer-logic/standard-logic/function-logic/bu4094bcf-product (accessed on 8 February 2022).
  29. GmbH, T.E. S7 Mini-Fully Open-Source Module with Xilinx Spartan-7 7S25, 64 Mbit HyperRAM. Available online: https://shop.trenz-electronic.de/en/TE0890-01-P1C-5-A-S7-Mini-Fully-Open-Source-Module-with-Xilinx-Spartan-7-7S25-64-Mbit-HyperRAM (accessed on 8 February 2022).
  30. Mathworks. Which Versions of Xilinx Vivado Are Supported with Which Release of HDL Coder?—Matlab Central. Available online: https://www.mathworks.com/matlabcentral/answers/518421-which-versions-of-xilinx-vivado-are-supported-with-which-release-of-hdl-coder (accessed on 8 February 2022).
  31. Mathworks. How to Configure Xilinx Vivado 2017.2 System Generator for Matlab2017b?—Matlab Central. Available online: https://www.mathworks.com/matlabcentral/answers/359646-how-to-configure-xilinx-vivado-2017-2-system-generator-for-matlab2017b (accessed on 8 February 2022).
  32. Define Custom Board and Reference Design for Zynq Workflow—MATLAB & Simulink. Available online: https://www.mathworks.com/help/hdlcoder/ug/define-and-register-custom-board-and-reference-design-for-zynq-workflow.html (accessed on 8 February 2022).
  33. Mathworks. MathWorks® Buildroot, 2022—Github. Available online: https://github.com/mathworks/buildroot (accessed on 8 February 2022).
  34. PS-Co-IT. Examples for Zynq-Based Power Electronics Development from Simulink—Github. Available online: https://github.com/PS-Co-IT/Zynq_Simulink (accessed on 8 February 2022).
  35. Mathworks. Getting Started with Targeting Xilinx Zynq Platform—MATLAB & Simulink. Available online: https://www.mathworks.com/help/hdlcoder/ug/getting-started-with-hardware-software-codesign-workflow-for-xilinx-zynq-platform.html (accessed on 8 February 2022).
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.