3-Phase PMSM Control Workshop with NXP's Model-Based Design Toolbox

Discussion created by dumitru-daniel.popa Employee on Nov 19, 2017
Latest reply on May 4, 2020 by hao xue



Design & Prototype Motor Control Applications with Model-Based Design Toolbox for S32K1xx




This is the Model-Based Design PMSM Workshops home page. The scope of this workshop is to familiarize readers with 3-phase PMSM control theory, NXP’s Automotive microprocessors designed for industrial control and provide prototyping implementation examples with Model-Based Design Toolbox.


This workshop is a medium to high complexity level but it does not require any prior knowledge of motor control, field oriented control or control system theory. All the important factors needed for a module completion will be presented as part of this workshop.


For demonstration we are going to use this NXP’s development kit platform. Anyhow, in order to avoid any hardware limitations we have designed the workshop’s examples to be generic so that you could use any other power stage inverters and/or PMSM motors.




Nowadays, our life without the means of transportation in various forms or the common indispensable household goods like washing machines, fridges or air conditioners is inconceivable. We are all living surrounded by things that one way or another are controlled via electric motors. The technology limits are pushed to extreme and the efficiency and price of solutions are stretched to limits.


Today’s applications require a large amount of integration across various subsystems such as electric motor, controlled supply source, control unit and wide range of sensors, which provide a conversion of electric energy to a specific mechanical movement.


Performing the mechanical movement according to certain specifications requires a suitable control strategy of the electric motor. The complexity of such control strategies requires deep knowledge of various engineering specializations: magnetic field theory, materials, mathematics, control systems and software development.




In this context, we are starting this workshop that will spread across the coming weeks. Considering the automotive industry, we are all witnesses to a growing demand for what is basically considered a motor controller subsystem. If we think about today & tomorrow cars we see a lot of applications that requires electric motors (a comprehensive article can be found here):

Fig. 1: Example of motor applications in a typical car - source: http://etn-demeter.eu


The motor control techniques are quite complex and require knowing of controlled system parameters and control structure parameters. This is a matter of experience in the motor control theory which can cause difficulties to motor control developers or users. To avoid these problems and make the development of the motor control applications easier, we are starting this workshop with 4 main objectives:


Fig. 2: Workshop Objectives




Throughout the coming weeks we plan to tackle with Model-Based Design, four types of common PMSM motor control applications as depicted in the next figure.


Fig. 3: PMSM typical applications for motor control


We are going thru prototyping from scratch using only MATLAB and Simulink, motor control applications for open and closed loop systems. We’ll discuss the theory behind every method, we will simulate and then test on the real hardware the Simulink models.


We shall start with a simple scalar control V/f to spin a motor and then based on this basic setup we are going to add PMSM phase current readings, close the current loop and finally build a closed loop speed control system. We shall pay special attention to FOC topics like Clarke and Park transformation, PI controller tuning, PMSM startup sequence and Position & Speed Estimation based on motor back-EMF observer.




Due to subject complexity, we are going to use a mix of Community Articles and Community Videos to explain the concepts behind each topic. Each section will have a dedicated article with all the steps needed to fulfill a functionality and whenever is needed a brief video to explain the concept and/or to show that functionality in real time. All Simulink models and accompanying slides will be available for download.


If you are interested in this subject, please bookmark this page or click on Actions/Following In button to get periodic updates. As always, any suggestions for improvement and/or subjects are more than welcome!




This workshop is divided in 10 modules that will be released each week giving you plenty of time for interactions and clarifications. The plan of intend is shown below:


M1: Environment Setup

    - Setting up the software: MBDT for S32K1xx, GCC and FreeMASTER

    - Setting up the hardware: S32K144EVB evaluation board and Motor GD development kit

    - Verify SW and HW setup: code generation, execution, real time data visualization


M2: PMSM and FOC Theory

    - PMSM Main Components and Mathematical Models

    - BLDC vs PMSM Comparison

    - Field Oriented Control

    - Clarke and Park Transformations

    - Field Oriented Control Stages


M3: System Partitioning

    - FOC algorithm mapping over S32K1xx hardware

    - Timings for slow and fast control loops

    - Inputs/Outputs used for motor control


M4: Space Vector Modulation

    - Single phase modulation

    - 3-Phase modulation

    - 3rd harmonic injection

    - PWM strategy


M5: V/f Scalar Control of PMSM

    - Build a Simulink model to test SVM

    - Build a Simulink model for the PMSM

    - Test the model on SIMULATION and HARDWARE and compare the results

    - Build an application spin the motor using V/F scalar control


M6: Current Sensing

    - Current sensing techniques (dual-shunt method)

    - System delays that affect the measurements

    - PWM – PDB – ADC synchronization

    - Current and Voltage scaling

    - Real time measurements of phase currents and DC bus current and voltage

    - Due to limitations in Jive platform the lecture comes in two parts:

       Module 6: Current Sensing (Part 1/2) 

       Module 6: Current Sensing (Part 2/2) 


M7: FOC Torque Control

    - Close the current loop

    - Tune current controller

    - Implement PMSM start-up sequence

    - Test application


M8: FOC Speed Control

    - Implement a speed and position estimator based on hall sensor inputs

    - Close the speed loop

    - Tune the speed controller

    - Test application under various conditions


M9: Position Observer

    -  Design a back-EMF estimator

    -  Design a position tracking observer

    -  Mathematical model

    -  Compute parameters for back-EMF estimator and Tracking observer automatically

    - Testing the position observer

    - Due to limitations in Jive platform the lecture comes in two parts:

     Module 9: Position Observer (Part 1/2) 

     Module 9: Position Observer (Part 2/2) 


M10: Sensorless Speed Control

    - Adapt startup-sequence to handle open to closed loop transitions

    - Tune application

    - Test application