Implement Field-Oriented Control on FPGA SoC
This example shows how to deploy a Field-Oriented Control (FOC) algorithm for brushless DC motors to an SoC device by using a custom board target. A custom board target for the Trenz Electronic Motor Control Development Kit, based on Xilinx Zynq UltraScale+ MPSoC, allows the FOC application to be deployed as a mix of software to the Arm Cortex-A processor and hardware to the programmable logic of the device. This example uses the model and control algorithm partitioning developed in the Hardware-Software Partitioning of a Motor Control Algorithm example.
Add Trenz Custom Board Support
This example includes file
createCustomBoard_te0820 script and premade
te0820_ps.tcl. Add the Trenz custom board definition to the SoC Blockset board registry by running
Board registration files get generated into the same folder. For more information on how to create and register custom board support with SoC Blockset, see Add a New Hardware Board to SoC Blockset.
Using the SoC Model Creator tool, you can create an empty model configured to the target the selected board and reference design. For information on how to create reference design, see Define Custom Board and Reference Design for Zynq Workflow (HDL Coder). Other elements of the model, such as algorithm, can then be added.
This example includes the soc_trenz_top model created with SoC Model Creator tool based on a shipping reference design Trenz TE0820 with CR00140 containing the ADC, encoder, and PWM components.
The model has been updated to include the design elements of the FOC application from the Hardware-Software Partitioning of a Motor Control Algorithm example. Run this command in MATLAB® command prompt to open the model.
In the System On Chip tab, you can see the current Hardware Board selection set to
Trenz Electronic TE0820 Custom SoC Board.
Set up the Trenz Electronic Motor Control Development Kit
Connect parts of the Trenz Electronic Motor Control Development Kit as shown in this image.
5V DC Power Supply
Micro USB cable for UART and JTAG
24V DC Power Supply
Motor Power cable (A, B, C)
24V Brushless DC Motor
Switch 1 (S1) controls power to the driver board
Download the prebuilt Linux image Zip archive from MathWorks GitHub repository. The Linux image is built with Builroot and kernel version 4.9. Extract the zip archive onto the microSD card and insert the card into the SD Card slot on the hardware board.
Implement and Run on Hardware
Click Configure, Build & Deploy to launch SoC Builder from
soc_trenz_top model and follow the steps.
In the step Select Build Action, choose Build and load for external mode to monitor the motor operation from Simulink®. Open the Simulation Data Inspector and observe the velocity command and motor velocity response.
Other Things to Try
You can use Dashboard blocks to interactively set the reference speed from the generated software model. The
soc_trenz_top_sw_exmode model is provided as a reference.