This application note describes the implementation of sensorless FOC on NXP MCX E31B MCUs. Please refer to AN14797 for complete instructions on how to use this software.
The demo code for PMSM sensorless control uses following NXP platforms:
• FRDM-MCXE31B
• Freedom Development Platform for Low-Voltage, 3-Phase PMSM Motor Control (FRDM-MC-LVPMSM)
• Motor LINIX 45ZWN24-40 or Teknic M-2310P
- Download and install MCUXpresso IDE V25.06 or later.
- SDK_25_09_00_FRDM-MCXE31B
- Download and install the latest version of FreeMASTER(3.2.2.2).
- Download the code from Git repository an-mc-pmsm-mcxe31B.
- MCUXpresso for Visual Studio Code: This example supports MCUXpresso for Visual Studio Code, for more information about how to use Visual Studio Code please refer here.
- (Optional) Download GUI Guilder(1.8.0 GA) here
- FRDM-MCXE31B board
- FRDM-MC-LVPMSM
- Motor: Linix 45ZWN24-40, or Teknic M-2310P
- USB Type-C cable
- Personal Computer
Connect the FRDM-MC-LVPMSM shield to the J1~J4 arduino connector of FRDM-MCXE31B board. Connect the 3-phase wire of the motor to the J7 connector on FRDM-MC-LVPMSM according to phase sequence.
For motor LINIX 45ZWN24-40:
White wide --phaseA;
Bule wide --phaseB;
Green wide --phaseC.
For motor Teknic M-2310P:
Black wide--phaseA;
Red wide--phaseB;
White wide--phaseC.
Power the FRDM-MC-LVPMSM board on J6 with a 24V adaptor.
Use a USB type-C cable to connect to the FRDM-MCXE31B board via J13 connector. Download the code using debug button in tool bar after compiler. Select CMSIS-DAP or J-Link in Debug As according firmware in your on-board debugger.
- Open MCUXpresso IDE, in the Quick Start Panel, choose Import from Application Code Hub.
- Enter the demo name in the search bar.
- Click Copy GitHub link, MCUXpresso IDE will automatically retrieve project attributes, then click Next>.
- Select main branch and then click Next>, Select the MCUXpresso project, click Finish button to complete import.
- Click Build to start compiling the project.
- Select the GUI Flash Tool from the toolbar to program the executable to the board.
The application contains the demo mode to demonstrate motor rotation. You can operate it either using the user button, or using FreeMASTER.
-
The NXP development boards include a user button associated with a port interrupt (generated whenever one of the buttons is pressed). At the beginning of the ISR, a simple logic executes and the interrupt flag clears. When you press the button, the demo mode starts. When you press the same button again, the application stops and transitions back to the STOP state.
-
The other way to interact with the demo mode is to use the FreeMASTER tool. The FreeMASTER application consists of two parts: the PC application used for variable visualization and the set of software drivers running in the embedded application. The serial interface transfers data between the PC and the embedded application. This interface is provided by the debugger included in the boards.
Remote control using FreeMASTER (Following chapter): Setting a variable in the FreeMASTER Variable Watch
There are two motor parameter and control parameter header file in source folder of the project, "m1_pmsm_appconfig.h" is for LINIX 45ZWN24-40 and "m2_pmsm_appconfig.h" is for Teknic M-2310P.
If use LINIX 45ZWN24-40 , m1_pmsm_appconfig should be included in header file m1_sm_snsless.h (an-mc-pmsm-mcxe31B\motor_control\pmsm\pmsm_float\mc_state_machine) by default.
If use Teknic M-2310P, change the included file to m2_pmsm_appconfig.
Press SW2 to RUN or STOP the mode. Press SW3 to stop the motor.
This section provides information about the tools and recommended procedures to control the sensor/ sensorless PMSM Field-Oriented Control (FOC) application using FreeMASTER.
You can download the latest version of FreeMASTER at www.nxp.com/freemaster. To run the FreeMASTER application including the MCAT tool, double-click the pmsm_float.pmpx file located in the middleware\motor_control\freemaster
folder. The FreeMASTER application starts and the environment is created automatically, as defined in the *.pmpx file.
Note: In MCUXpresso, the FreeMASTER application can run directly from IDE in motor_control/ freemaster folder.
-
Download the project from your chosen IDE to the MCU and run it.
-
Open the FreeMASTER project pmsm_float.pmpx
-
To establish the communication, click the communication button (the green "GO" button in the top left-hand corner).
- If the communication is established successfully, the FreeMASTER communication status in the bottom right-hand corner changes from "Not connected" to "RS-232 UART Communication; COMxx; speed=115200". Otherwise, the FreeMASTER warning pop-up window appears. as below:
-
Control the PMSM motor by writing to a control variable in a variable watch.
-
If use quadrature encoder based sensor control on Teknic M-2310P, switch M1 MCAT_POSE_Sensor value to 1(0 by default for sensorless control) in Variable watch window of 3. Speed Control watch subblock.
This demo also supports the NXP GUI Guider UI interface. It essentially uses FreeMASTER's TCP port as a relay, utilizing the local TCP data interface to visualize data on the GUI Guider interface.
The GUI Guider project files are located in the ./gui_guider directory.
The specific usage steps are as follows:
- Open and confirm that the FreeMASTER interface is fully functional and controllable. If the FreeMASTER interface is not working properly, ignore the remaining steps.
- Use GUI Guider 1.8.0 to open ./gui_guider/motor_control_v1.guiguider
- Click on FreeMASTER in the lower right corner, click Link To FreeMASTER Server, and click OK with the default parameters.
- Click Sync Variables to synchronize the FreeMASTER data source.
- Click Simulator, compile the C project, and then the GUI Guider interface will be ready to use.
Note that GUI Guider does not allow any special characters (spaces, ".", "-", etc.). Please carefully check the path, otherwise the GUI Guider project will fail to compile.
The board can drive the motor and motor can run.
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
| Version | Description / Update | Date |
|---|---|---|
| 1.1 | Update emios output and cmp functions | December 31th 2025 |
| 1.0 | Initial release on Application Code Hub | November 26th 2025 |
