AN 994: Drive-on-Chip Design Example for Intel Agilex® 7 Devices

ID 780361
Date 6/26/2023
Public
Document Table of Contents

6. Motor Control Software

The Drive-on-Chip Design Example motor control software is in C, runs under the Micrium µC/OS-II real-time operating system on the Nios V/g soft-processor, and is in two parts.

The BSP is generated from the Platform Designer system via the .qsys file, which contains a description of the system interconnectivity and module base addresses. The design includes drivers for Nios V/g peripherals that the Nios V/g and Intel® FPGA Hardware Abstraction Layer (HAL) supports.

The application program comprises several threads handling initialization, status reporting, and communication functions and an ISR, triggered by the PWM time base, which covers the real-time aspects of running the motor control FOC algorithm. The design includes header files and basic drivers for motor control peripherals that the Nios V/g HAL does not directly support.

For more details about the software look for the source files in <project>/software. The design achieves FOC control and open loop mode based on the interrupt rate of the ISR of the ADC. This rate is 16 kHz or 32 kHz according to the selected mode. If the control loop is calculated in software or hardware the ISR keeps the real time capabilities of the system ensuring that every 62.5 us or 31.25 us ADC measuring and output for the control loops are available.

Figure 15. Main Program
Figure 16. IRQ Routine