NXP Semiconductors User's Guide Document Number: PMSMFOCRT1050UG Rev. 0, 05/2018 PMSM Field-Oriented Control on MIMXRT1050 EVK Contents 1. Introduction This user’s guide provides a step-by-step guide on how to open, compile, debug, and run Permanent Magnet Synchronous Motor (PMSM) projects in most common IDEs, such as IAR Embedded Workbench®, MCUXpresso, and µVision® Keil® IDEs on MIMXRT1050 EVK. This user’s guide also describes how to turn the NXP Freedom PMSM power stage and the i.
Hardware setup 2. Hardware setup To run the PMSM application using the NXP hardware development platform, you need: • i.MX RT1050 Evaluation Kit (MIMXRT1050-EVK). • 3-Phase Low-Voltage Freedom PMSM Power Stage (FRDM-MC-LVPMSM). • PMSM motor—in this case, TG Drives (TGT2-0032-30-24/T0PS1KX-1M). The hardware setup of each component is briefly described in the sections below. You can order both boards from www.nxp.com (or distributors) and easily build the hardware platform for the target application.
Hardware setup Figure 1. MIMXRT1050-EVK board with highlighted jumper settings The PWM modules are used in the motor-control application. For this purpose, it is necessary to solder the resistors R278, R279, R280, and R281 to the board. These resistors are located on the underside of the EVK board. For more details, see the schematic (revision A5). Figure 2. Resistors needed for the PWM on the underside of the EVK board PMSM Field-Oriented Control on MIMXRT1050 EVK, User's Guide, Rev.
Hardware setup For more information about the MIMXRT1050-EVK hardware (processor, peripherals, and so on), see the MIMXRT1050 EVK Board Hardware User’s Guide (document MIMXRT1050EVKHUG). 2.2. FRDM-MC-LVPMSM The FRDM-MC-LVPMSM low-voltage evaluation board (in a shield form factor) turns the MIMXRT1050-EVK board into a complete motor-control reference design. There is also an interface for the speed/position sensors (Encoder, Hall).
Hardware setup Figure 2. TG Drives motor The motor has two types of connectors (cables). The first cable has three wires and it is designated to power the motor. The second cable has five wires and it is designated for the Hall sensors’ signal sensing. NOTE For the sensorless control mode, you need only the power input wires. In the position control mode, connect also the sensor wires to the NXP Freedom power stage. The wiring is described in Section 2.4, “Hardware assembling”. 2.4.
Hardware setup Figure 3. Interconnection diagram Table 3.
Project file structure 3. Motor-control drivers vs. MCUXpresso SDK The motor-control examples use the MCUXpreso SDK peripheral drivers to configure the general peripherals, such as the clocks, SPI, SIM, and ports. However, motor control requires critical application timing because most of the control algorithm runs in a 100-µs loop.
Project file structure Figure 4. Directory tree The PMSM package consists of these folders: • build_ref_solutions. • freemaster. • src. The main project folder /build_ref_solutions/build_single/evkbimxrt1050/ contains these folders: • iar—for the IAR Embedded Workbench IDE. • mcux—for the MCUXpresso IDE. • mdk—for the µVision Keil IDE. Each folder contains IDE-related configuration files for the PMSM project—project files, output executable, linker files, and so on.
Project file structure The /src/common/ folder contains these subfolders common to the other motor-control projects: • freemaster_drv—contains the FreeMASTER header and source files. • rtcesl—contains the mathematical functions used in the project. This folder includes the required header files, source files, and library files used in the project. It contains three subfolders (each for a different IDE) that contain precompiled library files for the Arm Cortex-CM7 cores.
Building and debugging the application • board/mcdrv.h—this file ensures the abstraction of the mcdrv_evkbimxrt1050.h file inclusion. • board/mcdrv_evkbimxrt1050.c—contains the motor-control driver peripherals initialization functions that are specific for the board and MCU used. • board/mcdrv_evkbimxrt1050.h—header file for board/mcdrv_evkbimxrt1050.c. This file contains the macros for changing the PWM period and the ADC channels assigned to the phase currents and board voltage.
Building and debugging the application 6.1. IAR Embedded Workbench IDE The first step is to open the project file. It is in the build_ref_solutions/evkbimxrt1050/iar folder, which contains all necessary files. Double-click “pmsm_ref_sol.eww” to open this project. The project opened in the IAR Embedded Workbench IDE is fully configured and includes all necessary source and header files required by the application, such as startup code, clock configuration, and peripherals configuration. Figure 5.
Building and debugging the application different than the one mentioned in Section 4, “Project file structure”. However, it is composed of the same files and organized to fit into the IDE workspace. • Point 5—shows the output file generated by the compiler, and ready to use by the debugger. • Point 6—“Download and Debug” (useful for debugging the Debug RAM configuration). This button downloads the compiled project into the MIMXRT1050-EVK’s RAM.
Building and debugging the application Figure 6. IAR debug workspace 6.1.2. Release FLASH This configuration links the application to the Hyper Flash memory. The optimization is set to the highest level for speed. The significant difference (opposite to the Debug configuration) is the ability to choose the functions which are going to be executed from the RAM.
Building and debugging the application • ENABLE_RAM_VECTOR_TABLE—the linker reserves an empty space from address 0x0 to 0x400 (RAM). With the reset signal, the IVT is copied from 0x60002000 to 0x0 and the pointer to the IVT (VTOR register of the “System Control Block”) is set to address 0x0. • If you do not want to place the IVT into the RAM, undefine the ENABLE_RAM_VECTOR_TABLE symbol from “Preprocessor” and “Linker”.
Building and debugging the application Figure 7. MCUXpresso SDK download 3. Click the “Download SDK” button. 4. Open the MCUXpresso IDE. On the bottom of the workspace, there is a panel with some tools. Click “Installed SDKs” (Figure 8) and drag and drop the downloaded file into the “SDKs” field. Figure 8. MCUXpresso installed SDKs 5. After waiting a moment to import, the SDK successfully installs into the MCUXpresso IDE. The second step is to import the project to the IDE.
Building and debugging the application Figure 9. MCUXpresso import The next step is to select the folder containing the project files. Click the “Browse” button and find the mcux folder on your hard disk. In the PMSM project, it is in build_ref_solutions/evkbimxrt1050/mcux. (Figure 10). Confirm the import by clicking the “Finish” button in the corner on the lower right-hand side. PMSM Field-Oriented Control on MIMXRT1050 EVK, User's Guide, Rev.
Building and debugging the application Figure 10. MCUXpresso import Now you see the MCUXpresso’s workspace with the PMSM project imported (Figure 11). The project in the MCUXpresso IDE is fully configured and includes all necessary source and header files required by the application, such as the startup code, clock configuration, and peripherals configuration. • Point 1—shows the imported project’s file structure. • Point 2—“Build” button.
Building and debugging the application Figure 11. MCUXpresso workspace The next step is to choose the build configuration. 6.2.1. Debug RAM This configuration links the application to the RAM memory. The optimization is disabled. To build, run, and debug this configuration, follow these instructions: 1. Select the “Debug RAM” build configuration (Point 2 in Figure 11). 2. Click the “Build” button (Point 2 in Figure 11). PMSM Field-Oriented Control on MIMXRT1050 EVK, User's Guide, Rev.
Building and debugging the application 3. Create a new debug configuration by clicking the “Debug” button (Point 4 in Figure 11). A new window with the discovered probes appears (see Figure 12). Choose “DAPLink CMSIS-DAP” and click the “OK” button. NOTE This step creates the debug configuration for both build configurations (Debug RAM and Release FLASH).
Building and debugging the application • To STOP debugging, press the “Terminate” button (Point 3 in Figure 13). Figure 13. MCUXpresso debug workspace 5. If debugging for a second time, you do not have to create the debug configuration again. Just click the little arrow in the “Debug Configuration” button (Point 3 in Figure 13) and select a debug configuration. 6.2.2. Release FLASH This configuration links the application to the Hyper Flash memory. The optimization is set to the “O1” level.
Building and debugging the application IVT is copied from 0x60002000 to 0x0 and the pointer to the IVT (VTOR register of System Control Block) is set to address 0x0. • Change the linker file path. Go to the “Project->Properties->C/C++ Build->Settings->Tool Settings” tab. Select “Managed Linker Script” in the list of the “MCU Linker” settings and find the “Linker script” text box. Change its value to “pmsm_ref_sol_Release_FLASH_IVT_RAM.ld” (see Figure 14).
Building and debugging the application configuration. In “Debug Configurations” (Point 3 in Figure 15), you should see both configurations (Figure 15). 5. When clicking the “pmsm_ref_sol LinkServer Release FLASH” configuration and the “Debugger” tab, the debug configuration settings should be visible (Figure 15). Set the values as follows: • “Stop on startup at”—uncheck. • “Attach only”—True. • “Load Image”—False. Figure 15. MCUXpresso debug configurations 6.
Building and debugging the application Figure 16. Keil workspace • • • • Point 1 in Figure 16 shows the imported project’s file structure. Point 2—the “Build” button. Point 3—the “Build configuration” selection. You can switch between the “Debug RAM” and “Release FLASH” build configurations. Point 4—the “Debug” button. This button is used to connect to the target application for debugging purposes. The second step is to choose the build configuration. 6.3.1.
Building and debugging the application 4. After a successful build, the application is ready for download to the RAM. To perform this action, press CTRL+F5 or click the “Debug” button (Point 4 in Figure 16). 5. As shown in Figure 17, the layout is switched to the debugging mode. • To run the application, press the “Run” button (Point 1 in Figure 17). • To pause the running application, press the “Pause” button (Point 2 in Figure 17).
Building and debugging the application You can also choose, whether the Interrupt Vector Table (IVT) is going be placed into the RAM or Hyper Flash. To place the IVT into the RAM, perform these steps: • Define the ENABLE_RAM_VECTOR_TABLE symbol in “Preprocessor”. The linker reserves an empty space from address 0x0 to 0x400 (RAM). With the reset signal, the IVT is copied from 0x60002000 to 0x0 and the pointer to the IVT (VTOR register of the system control block) is set to address 0x0.
Building and debugging the application 2. Choose CMSIS-DAP as the debugger. Go to “Project->Options For Target->Utilities” tab and uncheck “Update Target before Debugging”. Switch to the “Debug” tab and set the options as follows (Figure 19). Figure 19. Keil - Release FLASH debugger settings 3. Press the “Build” button (Point 2 in Figure 16). 4. After a successful build, the output binary file is ready for download to the Hyper Flash. To perform this action, see Section 6.4, “Boot from Hyper Flash”. 5.
Building and debugging the application • To pause the running application, press the “Pause” button (Point 2 in Figure 17). • To run the application, press the “Run” button (Point 1 in Figure 17). • To stop debugging, press the “Debug” button (Point 4 in Figure 16). 6.4. Boot from Hyper Flash The OpenSDA circuit (CMSIS–DAP) is an open-standard serial and debug adapter.
Building and debugging the application Figure 21. RT1050-EVK appears 5. Power down the board. Configure the board to the Hyper Flash boot mode – SW7-2 and SW7-3 pull up, the others pull down (Figure 21). Figure 22. Hyper Flash boot mode configuration 6. Power up the board. The embedded application executes automatically. Now you can connect to the running target.
User interface 3. Press and hold the SW4 button and power on the board simultaneously. Release the SW4 button after one second. 4. After several seconds, a new drive with the “MAINTENANCE” label appears. Drag and drop or copy and paste the downloaded firmware file to that drive. After a few seconds, the drive disappears. 5. Reset the board. 6. The firmware is now replaced and you can flash your application to the Hyper Flash. 6.6.
User interface You can control the application using these two interfaces: • Buttons on the NXP MIMXRT1050-EVK boards. • Remote control using FreeMASTER. 7.1. Remote control using FreeMASTER The remote operation is provided by FreeMASTER via the USB interface. FreeMASTER 2.0 is required for the application to operate properly. You can download FreeMASTER 2.0 at www.nxp.com/freemaster. Perform these steps to control a PMSM motor using FreeMASTER: 1.
User interface Figure 5. FreeMASTER communication setup window 6. If “OpenSDA-CDC Serial Port” is not printed out in the message box next to the “Port” dropdown menu, unplug and then plug in the USB cable, and reopen the FreeMASTER project. 7. Make sure to supply your development board from a sufficient energy source. Sometimes the PC USB port is not sufficient to supply the development board. 7.1.1.
User interface 7.1.2. Control page After launching the application and performing all necessary settigs, you can control the PMSM motor using the FreeMASTER control page. The FreeMASTER control page contains: • Speed gauge—shows the actual and required speeds. • Required speed—sets up the required speed. • DC-bus voltage—shows the actual DC-bus voltage. • DC-bus motor current—shows the actual torque-producing current. • Current limitation—sets up the DC-bus current limit.
Performing basic tasks Here are the basic instructions: • To start the motor, set the required speed using the speed slider. • In case of a fault, click on the fault notification to clear the fault. • Click the “Demo Mode” button to turn the demonstration mode on/off. • Click the “STOP” button to stop the motor. 8. Performing basic tasks 8.1. Running the motor 1. Assembly the NXP hardware according to the instructions in Section 2, “Hardware setup”. 2.
References 9. Acronyms and abbreviations Table 4. Acronyms and abbreviations Term Meaning AC Alternating Current AN Application Note DRM Design Reference manual EVK Evaluation Kit FOC Field-Oriented Control IVT Interrupt Vector Table MCAT Motor Control Application Tuning tool MCU Microcontroller MSD Mass Storage Device PMSM Permanent Magnet Synchronous Motor TSA Target Side Addressing 10. References The following references are available on www.nxp.
How to Reach Us: Information in this document is provided solely to enable system and software implementers to use NXP products. There are no express or implied copyright licenses Home Page: www.nxp.com granted hereunder to design or fabricate any integrated circuits based on the Web Support: www.nxp.com/support notice to any products herein. information in this document.