Easy and Straightforward FPGA Implementation of Model Predictive Control Using HDL Coder
Abstract
:1. Introduction
- Smaller sampling times: The proposed methodology achieves significantly smaller sampling steps compared to previous state-of-the-art Finite Control Set MPC (FCS-MPC) implementations. Experimental results demonstrate a sampling step of 500 ns to avoid high switching frequencies, with the capability to achieve steps as short as 32 ns, significantly surpassing state-of-the-art implementations.
- Efficient resource utilization: The study highlights new findings regarding the synthesis and execution of MPC algorithms on FPGAs, showing that HDL Coder enables synthesis results nearly identical to those achieved with hand-coded HDL. This is particularly important for resource-constrained and low-cost FPGA devices, ensuring efficient hardware resource utilization.
- Single clock-period execution: The methodology introduces a novel approach by executing the entire MPC algorithm within a single clock period, enabling fully parallel operation of the controller. This optimization ensures highly responsive and efficient real-time control, essential for applications requiring rapid switching, such as power electronics systems.
- Practical accessibility: By leveraging HDL Coder, the proposed methodology simplifies FPGA programming, making advanced MPC implementation accessible to engineers without deep expertise in hardware description languages. Additionally, comprehensive design details in the Vivado tool are provided, offering a complete workflow from pure simulation to a fully implemented controller in FPGA hardware.
- Unified HIL and Controller Integration: A key advancement is the integration of the HIL model of the converter with the MPC controller within the same FPGA. This approach resolves the clock mismatch issue reported in HIL tests, where the controller and the HIL model do not share the same clock, a limitation specific to HIL testing and not observed in real hardware setups. By unifying the HIL setup within the same FPGA, this method eliminates such synchronization challenges, simplifying the testing process. The integrated HIL setup also follows the same design methodology, facilitating efficient and accurate controller validation before deployment in real hardware systems.
2. Model Predictive Control Overview
2.1. Grid Connected H-Bridge Mathematical Model
2.2. Discrete-Time Model
2.3. Cost Function and Optimum State Finder
2.4. Adaptation for Off-Grid Applications
2.5. Adaptation for Three-Phase H-Bridge Inverter
3. MPC Implementation Alternatives in FPGAs
3.1. FPGA Programming Alternatives
- Hand-Coded HDL: Hand-coded HDL provides the highest level of control and optimization, allowing designers to tailor FPGA implementations to meet precise performance requirements. Optimal results have been reported, such as integration steps as low as 17.7 ns [14]. However, this approach demands significant expertise in hardware description languages like Verilog or VHDL, as well as labor-intensive processes for design, debugging, and verification. These requirements make hand-coded HDL less accessible for designers without advanced FPGA knowledge, and increase development time.
- High-Level Synthesis (HLS): HLS tools aim to reduce design complexity by converting C/C++ code into FPGA-compatible HDL. While they simplify coding, the abstraction provided by HLS can obscure hardware details, leading to inefficiencies in resource utilization and timing performance without careful tuning [31]. Debugging is particularly complex, as it involves iterative refinement between the C/C++ and RTL levels. Additionally, the learning curve for mastering hardware-specific optimizations remains steep, and platform-specific constraints can limit portability, requiring redesign efforts for different FPGA targets. The quality of synthesized HDL also varies significantly, depending on algorithm complexity, tool capabilities, and designer expertise, which can make HLS less predictable for high-performance applications.
- LabVIEW G language offers a graphical interface, making it user-friendly for beginners. One of its main advantages is its robust debugging capabilities, which allow for effective signal analysis and validation within the National Instruments (NI) ecosystem. However, this strength comes at the expense of being tied to NI hardware, which is required not only for debugging but also for implementation. This dependency reduces flexibility for designers working with other FPGA platforms. Additionally, while LabVIEW simplifies design workflows, its high resource utilization can limit its suitability for resource-constrained applications like MPC controllers [21].
- Xilinx System Generator (XSG): XSG is a graphical tool specifically designed for Xilinx-AMD FPGAs, offering automated HDL code generation and better synthesis results for many applications compared with the LabVIEW G language alternative. However, according to [24], XSG produces worse synthesis results than MATLAB Simulink HDL Coder for MPC applications, making HDL Coder a preferable choice for such use cases. Additionally, XSG’s hardware-specific nature restricts its adaptability, as it is limited to Xilinx FPGAs. In contrast, HDL Coder is not only compatible with multiple FPGA vendors but also provides better synthesis results for MPC applications, making it a more versatile and efficient option.
- MATLAB Simulink HDL Coder: MATLAB Simulink HDL Coder was selected in this study due to its ability to effectively balance performance, accessibility, and adaptability. Unlike traditional hand-coded approaches, which require extensive FPGA expertise, HDL Coder automates the HDL code generation process, significantly reducing design complexity and development time. A critical factor in achieving a resource-optimized MPC model is the careful selection of signal formats, particularly in fixed-point arithmetic. Fixed-point formats allow efficient FPGA resource utilization by minimizing the hardware overhead associated with operations like multiplication and division. MATLAB Simulink HDL Coder excels in this regard, as it enables designers to seamlessly simulate the suitability of different signal formats within the Simulink environment before generating the HDL code. This simulation-based approach is far easier than alternatives like hand-coded HDL, where manual adjustments are required at the RTL level, or HLS tools, which involve iterative debugging between abstract C/C++ models and synthesized HDL. In contrast, HDL Coder provides an intuitive, graphical interface where designers can directly verify numerical precision and dynamic range, ensuring optimal signal representation without extensive trial-and-error. Unlike hardware-specific tools like XSG or LabVIEW, HDL Coder supports a wide range of FPGA families, including Xilinx’s Zynq and Kintex series, Intel’s Cyclone and Stratix series, and Lattice’s MachXO and iCE40 series, enhancing its versatility and portability across different hardware environments. Additionally, its seamless integration with MATLAB/Simulink enables iterative refinements within a unified environment, greatly simplifying the workflow. These attributes make it an ideal choice for implementing the MPC algorithms explored in this study.
3.2. MATLAB Simulink/HDL Coder
4. FPGA Implementation
5. MPC Algorithm Verification
5.1. MATLAB Simulation
5.2. HIL Simulation
5.3. Experimental HIL Test
5.4. Discussion
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Chu, S.; Wang, B.; Niu, X. Simplified Reactive Torque Model Predictive Control of Induction Motor with Common Mode Voltage Suppression. IEICE Trans. Electron. 2023, 30, 132–140. [Google Scholar] [CrossRef]
- Kouro, S.; Cortes, P.; Vargas, R.; Ammann, U.; Rodriguez, J. Model Predictive Control—A Simple and Powerful Method to Control Power Converters. IEEE Trans. Ind. Electron. 2009, 56, 1826–1838. [Google Scholar] [CrossRef]
- 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]
- 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]
- Karamanakos, P.; Liegmann, E.; Geyer, T.; Kennel, R. Model Predictive Control of Power Electronic Systems: Methods, Results, and Challenges. IEEE Open J. Ind. Appl. 2020, 1, 95–114. [Google Scholar] [CrossRef]
- Ahmed, A.A.; Koh, B.K.; Lee, Y.I. A Comparison of Finite Control Set and Continuous Control Set Model Predictive Control Schemes for Speed Control of Induction Motors. IEEE Trans. Ind. Inform. 2018, 14, 1334–1346. [Google Scholar] [CrossRef]
- Preindl, M.; Bolognani, S. Comparison of direct and PWM model predictive control for power electronic and drive systems. In Proceedings of the Twenty-Eighth Annual IEEE Applied Power Electronics Conference and Exposition (APEC), Long Beach, CA, USA, 17–21 March 2013; pp. 2526–2533. [Google Scholar]
- Baier, C.R.; Ramirez, R.O.; Marciel, E.I.; Hernández, J.C.; Melín, P.E.; Espinosa, E.E. FCS-MPC Without Steady-State Error Applied to a Grid-Connected Cascaded H-Bridge Multilevel Inverter. IEEE Trans. Power Electron. 2021, 36, 11785–11799. [Google Scholar] [CrossRef]
- Xue, C.; Ding, L.; Li, Y. CCS-MPC with Long Predictive Horizon for Grid-Connected Current Source Converter. In Proceedings of the IEEE Energy Conversion Congress and Exposition (ECCE), Detroit, MI, USA, 11–15 October 2020; pp. 4988–4993. [Google Scholar]
- Sanchez, P.M.; Machado, O.; Peña, E.J.; Rodríguez, F.J.; Meca, F.J. FPGA-Based Implementation of a Predictive Current Controller for Power Converters. IEEE Trans. Ind. Inform. 2013, 9, 1312–1321. [Google Scholar] [CrossRef]
- Sepúlveda, C.A.; Muñoz, J.A.; Espinoza, J.R.; Figueroa, M.E.; Baier, C.R. FPGA v/s DSP Performance Comparison for a VSC-Based STATCOM Control Application. IEEE Trans. Ind. Inform. 2013, 9, 1351–1360. [Google Scholar] [CrossRef]
- Monmasson, E.; Cirstea, M.N. FPGA Design Methodology for Industrial Control Systems—A Review. IEEE Trans. Ind. Electron. 2007, 54, 1824–1842. [Google Scholar] [CrossRef]
- Takasu, R.; Tomioka, Y.; Ishigaki, Y.; Li, N.; Shibata, T.; Nakanishi, M.; Kitazawa, H. An FPGA Implementation of the Two-Dimensional FDTD Method and Its Performance Comparison with GPGPU. IEICE Trans. Electron. 2014, E97-C, 697–706. [Google Scholar] [CrossRef]
- Cirugeda-Roldán, E.M.; Martínez-García, M.S.; Sanchez, A.; de Castro, A. Evaluation of the Different Numerical Formats for HIL Models of Power Converters after the Adoption of VHDL-2008 by Xilinx. Electronics 2021, 10, 1952. [Google Scholar] [CrossRef]
- Lamo, P.; de Castro, A.; Sanchez, A.; Ruiz, G.A.; Azcondo, F.J.; Pigazo, A. Hardware-in-the-Loop and Digital Control Techniques Applied to Single-Phase PFC Converters. Electronics 2021, 10, 1563. [Google Scholar] [CrossRef]
- Schafer, B.C.; Iguchi, Y.; Takahashi, W.; Nagatani, S.; Wakabayashi, K. Fixed Point Data Type Modeling for High Level Synthesis. IEICE Trans. Electron. 2010, E93-C, 361–368. [Google Scholar] [CrossRef]
- Nane, R.; Sima, V.M.; Pilato, C.; Choi, J.; Fort, B.; Canis, A.; Bertels, K. A Survey and Evaluation of FPGA High-Level Synthesis Tools. IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 2016, 35, 1591–1604. [Google Scholar] [CrossRef]
- Estrada, L.; Vázquez, N.; Vaquero, J.; de Castro, Á.; Arau, J. Real-Time Hardware in the Loop Simulation Methodology for Power Converters Using LabVIEW FPGA. Energies 2020, 13, 373. [Google Scholar] [CrossRef]
- Saralegui, R.; Sanchez, A.; de Castro, A. Efficient Hardware-in-the-Loop Models Using Automatic Code Generation with MATLAB/Simulink. Electronics 2023, 12, 2786. [Google Scholar] [CrossRef]
- Zamiri, E.; Sanchez, A.; Yushkova, M.; Martínez-García, M.S.; de Castro, A. Comparison of Different Design Alternatives for Hardware-in-the-Loop of Power Converters. Electronics 2021, 10, 926. [Google Scholar] [CrossRef]
- Iranian, M.E.; Mohseni, M.; Aghili, S.; Parizad, A.; Baghaee, H.R.; Guerrero, J.M. Real-Time FPGA-Based HIL Emulator of Power Electronics Controllers Using NI PXI for DFIG Studies. IEEE J. Emerg. Sel. Top. Power Electron. 2020, 10, 2005–2019. [Google Scholar] [CrossRef]
- Singh, V.K.; Tripathi, R.N.; Hanamoto, T. FPGA-Based Implementation of Finite Set-MPC for a VSI System Using XSG-Based Modeling. Energies 2020, 13, 260. [Google Scholar] [CrossRef]
- Mishra, I.; Tripathi, R.N.; Singh, V.K.; Hanamoto, T. Step-by-Step Development and Implementation of FS-MPC for a FPGA-Based PMSM Drive System. Electronics 2021, 10, 395. [Google Scholar] [CrossRef]
- Singh, V.K.; Tripathi, R.N.; Hanamoto, T. Implementation Strategy for Resource Optimization of FPGA-Based Adaptive Finite Control Set-MPC Using XSG for a VSI System. IEEE J. Emerg. Sel. Top. Power Electron. 2021, 9, 2066–2078. [Google Scholar] [CrossRef]
- Marmol, A.; Zamiri, E.; Purraji, M.; Murillo, D.; Díaz, J.T.; Vazquez, A.; de Castro, A. Dual Control Strategy for Non-Minimum Phase Behavior Mitigation in DC-DC Boost Converters Using Finite Control Set Model Predictive Control and Proportional–Integral Controllers. Appl. Sci. 2024, 14, 10318. [Google Scholar] [CrossRef]
- Nasika, D.; Yuvaraju, A.; Reddy, V.K.; Sundar, S.V.N.J. FPGA-In-Loop Simulation of an Improved Converter Firing Control for LCC HVDC and Validation Using Real-Time Digital Simulator (HIL). In Proceedings of the 2019 IEEE International Conference on Electrical, Computer and Communication Technologies (ICECCT), Coimbatore, India, 20–22 February 2019; pp. 1–8. [Google Scholar]
- Singh, V.K.; Tripathi, R.N.; Hanamoto, T. Model-based design approach for implementation of finite state MPC. In Proceedings of the 13th IEEE Conference on Industrial Electronics and Applications (ICIEA), Wuhan, China, 31 May–2 June 2018; pp. 881–886. [Google Scholar]
- Siwakoti, Y.P.; Town, G.E. Design of FPGA-controlled power electronics and drives using MATLAB Simulink. In Proceedings of the IEEE ECCE Asia Downunder, Melbourne, VIC, Australia, 3–6 June 2013; pp. 571–577. [Google Scholar]
- Sankar, D.; Syamala, L.; Chembathu Ayyappan, B.; Kallarackal, M. FPGA-Based Cost-Effective and Resource Optimized Solution of Predictive Direct Current Control for Power Converters. Energies 2021, 14, 7669. [Google Scholar] [CrossRef]
- Yushkova, M.; Sanchez, A.; de Castro, A. Strategies for choosing an appropriate numerical method for FPGA-based HIL. Int. J. Electr. Power Energy Syst. 2021, 132, 107186. [Google Scholar] [CrossRef]
- Cong, J.; Liu, B.; Neuendorffer, S.; Noguera, J.; Vissers, K.; Zhang, Z. High-Level Synthesis for FPGAs: From Prototyping to Deployment. IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 2011, 30, 473–491. [Google Scholar] [CrossRef]
- Zamiri, E.; Sanchez, A.; de Castro, A.; Martínez-García, M.S. Comparison of Power Converter Models with Losses for Hardware-in-the-Loop Using Different Numerical Formats. Electronics 2019, 8, 1255. [Google Scholar] [CrossRef]
- Aguirre, M.; Vazquez, S.; Alcaide, A.M.; Portillo, R.; Kouro, S.; Leon, J.I.; Franquelo, L.G. Period Control Approach Finite Control Set Model Predictive Control Switching Phase Control for Interleaved DC/DC Converters. IEEE Trans. Ind. Electron. 2024, 71, 8304–8312. [Google Scholar] [CrossRef]
- Montazeri, A.; König, O.; Griepentrog, G. Investigating Effects of Delta-Sigma Modulation for Current Measurement on FCS-MPC of IM: Hardware in the Loop Results. In Proceedings of the 2017 IEEE International Symposium on Predictive Control of Electrical Drives and Power Electronics (PRECEDE), Pilsen, Czech Republic, 4–6 September 2017; pp. 7–12. [Google Scholar]
- Iranian, M.E.; Zamiri, E.; de Castro, A. Optimal Implementation of d-q Frame Finite Control Set Model Predictive Control with LabVIEW. Electronics 2025, 14, 100. [Google Scholar] [CrossRef]
- Srinivasan, G.K.; Rivera, M.; Loganathan, V.; Ravikumar, D.; Mohan, B. Trends and Challenges in Multi-Level Inverter with Reduced Switches. Electronics 2021, 10, 368. [Google Scholar] [CrossRef]
- Aouichak, I.; Jacques, S.; Bissey, S.; Reymond, C.; Besson, T.; Le Bunetel, J.-C. A Bidirectional Grid-Connected DC–AC Converter for Autonomous and Intelligent Electricity Storage in the Residential Sector. Energies 2022, 15, 1194. [Google Scholar] [CrossRef]
- Beser, E.; Arifoglu, B.; Camur, S.; Beser, E.K. A grid-connected photovoltaic power conversion system with single-phase multilevel inverter. Sol. Energy 2010, 84, 2056–2067. [Google Scholar] [CrossRef]
- Nguyen, M.-K.; Tran, T.-T. A Single-Phase Single-Stage Switched-Boost Inverter With Four Switches. IEEE Trans. Power Electron. 2018, 33, 6769–6781. [Google Scholar] [CrossRef]
- Mebkhouta, T.; Golea, A.; Boumaraf, R.; Benchouia, T.M.; Karboua, D.; Bajaj, M.; Chebaani, M.; Blazek, V. Sensorless finite set predictive current control with MRAS estimation for optimized performance of standalone DFIG in wind energy systems. Results Eng. 2024, 24, 103622. [Google Scholar] [CrossRef]
- Cheng, Z.; Liu, Y.; Luo, B.; Zhang, Y. Improved vector selection model predictive control strategy for quasi-Z-source inverter virtual synchronous generator grid-connected system. J. Eng. 2024, 2024, e70034. [Google Scholar] [CrossRef]
State | ON Switches | Output Voltage () |
---|---|---|
1 | ||
2 | 0 | |
3 |
Model | LUTs | FFs | DSPs | |
---|---|---|---|---|
MPC alone | 216 | 7 | 8 | 30.125 ns |
(0.41%) | (0.01%) | (3.64%) | ||
Exp setup | 4287 | 5124 | 16 | 30.645 ns |
(8.06%) | (4.82%) | (7.27%) | ||
HIL [19] | 397 | 326 | 12 | 21.000 ns |
(0.75%) | (0.31%) | (5.45%) | ||
MPC [29] | 2261 | 274 | 22 | 3200.0 ns |
(28%) | (3%) | (46%) |
Parameters | Values |
---|---|
Input voltage | = 200 V |
Grid inductance | = 20 mH |
Grid resistance | |
Grid voltage | |
Reference current | |
MPC sampling step | ns |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Purraji, M.; Zamiri, E.; de Castro, A. Easy and Straightforward FPGA Implementation of Model Predictive Control Using HDL Coder. Electronics 2025, 14, 419. https://doi.org/10.3390/electronics14030419
Purraji M, Zamiri E, de Castro A. Easy and Straightforward FPGA Implementation of Model Predictive Control Using HDL Coder. Electronics. 2025; 14(3):419. https://doi.org/10.3390/electronics14030419
Chicago/Turabian StylePurraji, Marziye, Elyas Zamiri, and Angel de Castro. 2025. "Easy and Straightforward FPGA Implementation of Model Predictive Control Using HDL Coder" Electronics 14, no. 3: 419. https://doi.org/10.3390/electronics14030419
APA StylePurraji, M., Zamiri, E., & de Castro, A. (2025). Easy and Straightforward FPGA Implementation of Model Predictive Control Using HDL Coder. Electronics, 14(3), 419. https://doi.org/10.3390/electronics14030419