Three-Phase AC/DC Boost PFC (DQ control & DSOGI PLL) Hardware-in-the-Loop (DiY) with STM32F7 & Spartan-7 (Cmod S7)
The MIL (Model in the loop) simulation pfc_desktop.slx contains both a linear model of the FETs (FPGA/HIL implementation which could be use upto 8Arms AC) and a nonlinear model for more fidelity. The Simulink model HDL_pfc_gold_fi_og.slx is for the VHDL code gen that is produce for a CLK of 98MHz. The Vivado Project contains all IPs (PFC, DAC driver etc.) The Model pfc_control.slx is use for MIL & PIL & code generated directly to the SMT32F7 which is also one thing I was always looking to find on the internet but never could.
- Blue: VDC
- Green: IAC1
- Starting the controller VDC increases and the amplitud of IAC
- Load dump from IDC = 8A to 0A
- Load increase from IDC = 0A to 8A
HIL-3Phase-PFC
├── stf7
│ ├── stf7
│ ├── main.c (All code and binaries)
│ └── 3ph.elf
│ ├── matlab
│ ├──*.slx (All Simulink & Matlab files for the STM32F7)
│
├── matlab
│ ├── sim
│ ├── *.slx (All Simulink files for the Spartan7)
├── vivado_lite
│ ├── All vivado files for the project
├── ips
│ ├── All vivado IPs for the project
└── README.md
- Application: Digital control of a 3-phase PFC converter in real time using PLL Dsogi.
- Controller: STM32F767ZI (ARM Cortex-M7 @ 216MHz)
- FPGA: Xilinx Spartan-7
- Mode: Hardware-in-the-Loop with real-time plant emulation in FPGA
- Real-time HIL simulation of a 3-phase AC/DC PFC stage DACs MCP4922.
- FPGA-based fast plant model (fixed-step solver at 110MHz rate), FETs were linearize.
- Digital control loop implementation on STM32F7 @8Khz (which is ok for a S7) (PID, PLL Dsogi).
- MATLAB/Simulink/Simscape model for validation using PiL, MiL.
- Scalable for DSP or other FPGA platforms.
| Component | Function |
|---|---|
Spartan-7 FPGA |
Emulates PFC power stage dynamics in real time |
STM32F7 MCU |
Executes control algorithms (current, voltage regulation) |
MATLAB/Simulink |
Design, test, and compare control loops and plant models |
- STM32CubeIDE 1.15+
- Vivado 2022.1 or later
- MATLAB R2022b
- STM32F767ZI Nucleo or custom board
- Spartan-7 FPGA board (e.g., Digilent Cmod S7 or custom design)
- Flash the STM32 with
pfc3van.elf/ - Load bitstream to FPGA from
design_1_wrapper.bin/ - Run host-side script or GUI to initiate control loop test
- Observe performance via scope
- STM32CubeMX / STM32CubeIDE – Microcontroller development
- Xilinx Vivado – FPGA synthesis and implementation
- MATLAB/Simulink/Simscape – Plant and control modeling
- CAN/EtherCAT interface for industrial integration
- Adaptive control algorithms
- Integration with real-time OS (FreeRTOS)
- PWM jitter analysis and suppression
- Fully parameterized VHDL generator from Simulink
Contributions, bug reports, and feature requests are welcome.
Please open an Issue or submit a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Lead Developer: Angel Rodriguez
- Email:
[email protected]Subject:HIL PFC 3PH
⚠️ This project is for research and development purposes. Not certified for use in safety-critical or production energy systems.

