Document Number: AN5309 NXP Semiconductors Application Note Rev. 0, 08/2016 Sensorless PMSM Field-Oriented Control on Kinetis KV31 with FreeRTOS & eGUI By: Marek Zeman Contents 1. Introduction 1. Introduction ........................................................................ 1 This application note describes the implementation of 1.1. Description .............................................................. 2 the sensorless Motor Control Reference Solution 2. Hardware Requirements ..................................................... 2 Package (MCRSP) software for a 3-phase Permanent 2.1. FRDM-KV31F ........................................................ 2 2.2. FRDM-MC-LVPMSM ............................................ 3 Magnet Synchronous Motor (PMSM) with the 2.3. Arduino LCD TFT shield ........................................ 4 FreeRTOS OS (including the motor-parameters 2.4. Step-up headers and assembly ................................. 5 identification algorithm) on 32-bit Kinetis V series 3. Real-Time Operating System ............................................. 6 3.1. Tasks ....................................................................... 6 MCUs. The communication is provided by 3.2. Interrupt processing ................................................. 9 FreeMASTER. The sensorless control software itself 3.3. Memory management and stack ............................ 10 and the PMSM control theory in general are described 3.4. RTOS configuration .............................................. 10 4. Motor Control ................................................................... 12 in Sensorless PMSM Field-Oriented Control 4.1. 3-phase PMSM ...................................................... 12 (document DRM148) and Sensorless PMSM Field- 4.2. Application concept ............................................... 12 Oriented Control on Kinetis KV (document AN5237). 4.3. Control theory........................................................ 13 5. System Parts ..................................................................... 14 The LCD display shield is used to show the application 5.1. Graphical library .................................................... 14 states and the current motor speed on gauges. The 5.2. FreeMASTER ........................................................ 16 demo mode is controlled using either the on-board 6. FreeRTOS and Motor Control Implementation ................ 16 6.1. Program flow ......................................................... 17 push-button or the FreeMASTER control page that also 6.2. Interrupt configuration ........................................... 22 supports on-line application monitoring and debugging. 6.3. CPU load and memory usage ................................ 24 7. Conclusion ........................................................................ 24 8. Acronyms and Abbreviations ........................................... 25 9. References ........................................................................ 25 10. Revision History ............................................................... 25 2016 NXP B.V. Hardware Requirements 1.1. Description The purpose of this application note is to describe the motor-control part implementation with the FreeRTOS OS. This application note covers: Overview and important details Basic introduction to the FreeRTOS OS Implementation of the motor-control part and the FreeRTOS OS Interrupt control This application note doesnt describe: Full description of the FreeRTOS OS (all functions) Detailed PMSM motor control (can be found in Sensorless PMSM Field-Oriented Control (document DRM148)) Detailed description of eGUI (can be found in Freescale Embedded GUI (D4D) (document DRM116)) 2. Hardware Requirements The development platform chosen for the embedded application is the NXP Freedom FRDM-KV31F board populated with the KV3x family MCU, the FRDM-MC-LVPMSM board for driving 3-phase low-voltage PMSM motors, and the Arduino R3-compatible LCD TFT shield driven by the SPI signals and the on-board graphical IC HX8347. 2.1. FRDM-KV31F The KV31F MCU family is a highly-scalable member of the Kinetis V series and provides a high-performance, cost-competitive, motor-control solution. It is built around the ARM Cortex-M4 core running at 120 MHz with up to 512 KB flash and up to 96 KB RAM, combined with the floating-point unit. It delivers a platform that enables the customers to build a scalable solution portfolio. The additional features include dual 16-bit ADCs sampling at up to 1.2 MS/s in a 12-bit mode, 20 channels of flexible motor-control timers (PWMs) across four independent time bases, and a large RAM block that enables local execution of fast control loops at full clock speed. For more details, see KV31F Sub-Family Reference Manual (document KV31P100M120SF7RM). The NXP Freedom KV31F board is a powerful, low-cost development platform targeted for low-voltage motor-control applications. The board combines the main KV31F MCU, a micro-USB connector with a compatible debugger, and four headers where the outer columns have Arduino-compatible signals (the inner columns are intended for the NXP Freedom evaluation boards). The signal routing can be found in the particular scheme or application note for the specific evaluation board. The main NXP Freedom board can be mounted with various motor-control shields, such as FRDM-MC-LVPMSM for driving low-voltage PMSM motors or FRDM-MC-LVBLDC targeted for low-voltage BLDC motors. Sensorless PMSM Field-Oriented Control on Kinetis KV31 with FreeRTOS & eGUI, Application Note, Rev. 0, 08/2016 2 NXP Semiconductors