
MATLAB/Simulink Model of SMO-based Sensorless FOC for PMSM: MCLV-48V-300W Development Board and dsPI33AK512MC510 Motor Control DIM
This demonstration describes the setup requirements to drive a Permanent Magnet Synchronous Motor (PMSM) using Sliding Mode Observer (SMO) based Field Oriented Control (FOC) on the hardware platform MCLV-48V-300W Development Board (EV18H47A) and dsPIC33AK512MC510 Motor Control Dual Inline Module (DIM) (EV67N21A).
The MATLAB/Simulink model includes Sensorless Field Oriented Control (FOC) with Sliding Mode Observer (SMO) Estimator referenced from (AN1078) “Sensorless Field Oriented Control of a PMSM”.
NOTE: The dsPIC33AK512MC510 is a Digital Signal Controller (DSC) from Microchip Technology and part of the dsPIC33AK512MPS512 family, designed for motor control and other high-performance embedded system applications.
- MATLAB model can be cloned or downloaded as zip file from the Github repository (link).
- MPLAB X IDE and IPE (v6.25)
- XC16 compiler (v3.21)
- MATLAB R2024b
- Required MATLAB add-on packages
- Simulink (v24.2)
- Simulink Coder (v24.2)
- Stateflow (v24.2)
- MATLAB Coder (v24.2)
- Embedded Coder (v24.2)
- MPLAB Device blocks for Simulink (v3.60)
- Motor Control Blockset (v24.2)
NOTE: The software used for testing the model during release is listed above. It is recommended to use the version listed above or later versions for building the model.
- Motor Control Low-Voltage 48V-300W Inverter Board (EV18H47A)
- dsPIC33AK512MC510 Motor Control Dual In-line Module (EV67N21A)
- 24V Power Supply (AC002013)
- 24V, 3-Phase Brushless DC Permanent Magnet Hurst Motor (AC300022)
NOTE: All items listed under this section Hardware Tools Required for the Demonstration are available at microchip DIRECT.
This section describes the hardware setup required for the demonstration.
Note:
In this document, hereinafter the MCLV-48V-300W Development Board is referred as development board.
-
Motor currents are amplified on the MCLV-48V-300W development board; it can also be amplified by the amplifiers internal to the dsPIC33AK512MC510 on the DIM. The Simulunk model and DIM are configured to sample and convert internal amplifier outputs ('internal op-amp configuration') by default to measure the motor currents needed to implement FOC. Table-1 summarizes the resistors to be populated and removed to convert the DIM from ‘internal op-amp configuration’ to ‘external op-amp configuration’ or vice versa.
-
Insert the dsPIC33AK512MC510 Motor Control DIM into the DIM Interface connector J8 on the development board. Make sure the DIM is placed correctly and oriented before going ahead.
-
Connect the 3-phase wires from the motor to PHC, PHB and PHA of the connector J4, provided on the development board.
-
Plug the 24V power supply to connector J1 on the development board. Alternatively, the development board can also be powered through connector J3.
-
The board has an onboard programmer PICkit™ On Board (PKoBv4) , which can be used for programming or debugging the microcontroller or dsPIC DSC on the DIM. To use the onboard programmer, connect a micro-USB cable between the Host PC and connector J16 on the development board.
-
Alternatively, connect the Microchip programmer/debugger MPLAB® PICkit™ 5 In-Circuit Debugger (PG164150) between the Host PC used for programming the device and the ICSP header J9 on the development board (as shown). Ensure that PICkit 4 is oriented correctly before proceeding.
Follow the below instructions step-by-step, to set up and run the motor control demo application:
-
Launch MATLAB (refer the section "2.2 Software Tools Used for Testing the MATLAB/Simulink Model").
-
Open the folder downloaded from the repository, in which MATLAB files are saved (refer the section "2.1 MATLAB Model Required for the Demonstration").
-
Double click and open the MATLAB script file (.m file). This script file contains the configuration parameter for the motor and board. By default, the script file is configured to run Hurst 300 motor and development board. Run the file by clicking the “Run” icon and wait till all variables gets loaded on the ‘Workspace’ tab.
-
Double click on the Encoder FOC Simulink model - pmsm_smo.slx.
-
This opens the Simulink model as shown below. Click on the "Run" icon to start the simulation.
-
To plot the simulation result, Data Inspector is used (refer to figure below). To observe the additional signals, log them as required. Alternatively, normal Simulink Scope can be used to plot the signals.
-
From this Simulink model an MPLAB X project can be generated, and it can be used to run the PMSM motor using development board.
To generate the code from the Simulink model, go to the "MICROCHIP" tab, and enable the tabs shown in the figure below.
-
To generate the code, click on "Build" option under the “Microchip” tab and "Build, Deploy & Start" drop down. This will generate the MPLAB X project from the Simulink model and program the dsPIC33AK128MC106 device.
-
After completing the process, the ‘Operation Succeeded’ message will be displayed on the ‘Diagnostics Viewer’.
-
If the device is successfully programmed, LED1 - LD2 and the LED2 - LD3 will be blinking.
-
To Run the motor, press the push button SW1.
-
The motor speed can be varied using the potentiometer (labeled “POT”).
-
Press the push button SW1 to stop the motor. Make sure motor is reduced minimum potentimeter value before stopping the motor.
The FOC model comes with the initialization required for data visualization using Motor Control Blockset Host Model (MCB Host Model). The MCB Host Model is a Simulink model which facilitates data visualization through the UART Serial Interface.
-
To establish serial communication with the host PC, connect a micro-USB cable between the host PC and connector J16 on the development board. This interface is also used for programming.
-
Enter the COM port number of the USB connection in the MATLAB script file.
-
Ensure the SMO-based sensorless FOC model is programmed and running as described under section "4. Basic Demonstration" by following steps 1 through 13.
-
Open the mcb_hostmodel_dsPIC33A.slx model and click on the Run icon to plot the real time data.
-
Select the signals on Debug Select Value pannel to plotted available signals on the scope.
For more information, refer to the following documents or links.
- Application Note on "Sensorless Field Oriented Control of a PMSM" (AN1078)
- MCLV-48V-300W Development Board User’s Guide (DS50003297)
- dsPIC33AK512MC510 Motor Control Dual In-Line Module (DIM) Information Sheet (DS70005553)
- dsPIC33AK512MC510 Family datasheet (DS70005591)
- MPLAB® X IDE User’s Guide (DS50002027) or MPLAB® X IDE help
- MPLAB® X IDE installation
- MPLAB® XC-DSC Compiler installation
- Motor Control Blockset
- MPLAB Device Blocks for Simulink :dsPIC, PIC32 and SAM mcu