MATLAB-Simulink Model for Sensorless FOC of PMSM using PLL estimator integrated with Power Factor Correction: MCHV-230VAC-1.5kW Development Board and dsPIC33AK128MC106 Motor Control DIM
This document describes the setup requirements to drive a PMSM Motor with Power Factor Correction (PFC) on the hardware platform EV78U65A "MCHV-230VAC-1.5kW Development Board" and EV68M17A "dsPIC33AK128MC106 Motor Control Dual In-line Module (DIM)".The motor considered for this demonstration is an air conditioner compressor motor.
Enhance your embedded applications with Microchip's high-performance dsPIC® Digital Signal Controllers (DSCs). Visit our Motor Control and Drive page to stay updated on the latest motor control solutions from Microchip.
- MATLAB model can be cloned or downloaded as zip file from the Github repository: main page of this repository.
- MPLAB® X IDE and IPE v6.25
- Device Family Pack (DFP): dsPIC33AK-MC_DFP v1.4.172
- Curiosity/Starter Kits Tool Pack : PKOB4_TP v1.19.1503
- MPLAB® XC-DSC Compiler v3.30
- MATLAB R2025b
- Required MATLAB add-on packages
- Simulink (v25.2)
- Simulink Coder (v25.2)
- Stateflow (v25.2)
- MATLAB Coder (v25.2)
- Embedded Coder (v25.2)
- MPLAB Device blocks for Simulink (v3.63.03)
- Motor Control Blockset (v25.2)
Note:
The software used for testing the firmware prior to release is listed above. It is recommended to use these or later versions of the tool for building the firmware. All previous versions of Device Family Packs (DFP) and Tool Packs can be downloaded from Microchip Packs Repository.
- MCHV-230VAC-1.5kW Development Board (EV78U65A)
- dsPIC33AK128MC106 Motor Control Dual In-line Module (EV68M17A)
- Airconditioner Setup
Note:
Items EV78U65A, and EV68M17A are available to purchase directly from microchip DIRECT
This section describes the hardware setup required for the demonstration. Refer "Motor Control High Voltage 230VAC-1.5kW Development Board User's Guide", before operating the unit.
Note:
In this document, hereinafter the MCHV-230VAC-1.5kW Development Board is referred as development board.
-
Motor currents are amplified on the MCHV-230VAC-1.5kW development board; it can also be amplified by the amplifiers internal to the dsPIC33AK128MC106 on the DIM. The firmware 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.
-
Ensure the development board is not powered and it is fully discharged. Verify the LEDs LD1(Green) and LD4(Red) on Power Factor Correction Board and LD1(Green) on Motor Control Inverter Board are not glowing.
-
Remove the thumb screw and open the top cover of the enclosure and measure the DC Bus voltage across the terminals which reads approximately '0 VDC'. If the voltage is greater than 1V, wait until it is completely discharged.
-
Insert the dsPIC33AK128MC106 Motor Control DIM into the DIM Interface connector J2 on the development board. Make sure the DIM is placed correctly and oriented before going ahead. Close the top cover of the enclosure and secure it with the thumb screw.
-
Connect the 3-phase wires from the motor to A, B, and C (Refer to compressor datasheet for motor direction) of the connector J13(MOTOR) on the development board.
-
Power the PFC board using a controlled AC source by applying a voltage within in the range 150-230Vac rms and a frequency of 50Hz through IEC connector connector J1 provided on the PFC board.
Note:
The Development Board is designed to operate in the 90 to 230Vac rms voltage range with a maximum input current of 10Arms. In the Input AC voltage range of 90 to 150Vac rms, the maximum input power to the Development Board must be derated (<1500W) to maintain the input current through the socket to less than or equal to 10Arms.
- The Development Board has an on-board programming tool called the Isolated PKoB4 Daughter Board. To use the on-board programmer, connect a micro-USB cable between the Host PC and connector J11(PROGRAM) on the development board.
Note:
Use only shielded micro-USB cables intended for data transfer.
- To establish serial communication with the host PC, connect a micro-USB cable between the host PC and connector J8(USB-UART) on the development board.
Note:
Use only shielded micro-USB cables intended for data transfer.
- Power on the Indoor unit and Exhaust fan from mains power supply.
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 parameters for single-stage boost power factor correction converter, PMSM motor and development board. By default, the script is configured to calculate PFC control parameters at a PWM frequency of 64 kHz, as the Power Factor Correction (PFC) board is specifically designed to operate at this switching frequency.When the PFC is enabled, the Motor Control (MC) PWM frequency must be set to 16 kHz to ensure proper synchronization and system performance. Run the file by clicking the “Run” icon and wait till all variables gets loaded on the ‘Workspace’ tab.
-
Double click on the Simulation Simulink model - pfc_foc_simulation.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.
-
Double click on the PFC code generation simulink model - pfc_codegen.slx.
-
This opens the simulink model as shown below.
-
From this Simulink model an MPLAB X project can be generated.
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 ‘Program Succeeded’ message will be displayed on the ‘Diagnostics Viewer’.
-
If the device is successfully programmed,LED1(D15) will be blinking, indicating that the dsPIC® DSC is enabled.
-
Measure the DC Bus voltage across the terminals (VDC and PGND) and ensure that the voltage is approximately 380V.
-
Run or stop the motor by pressing the push button BUTTON 1. Ensure the motor is spinning smoothly without any vibration in one direction.
-
The motor speed can be varied using the potentiometer (POT).
-
Press the push button BUTTON 1 to stop the motor.
Note:
The motor parameters and specifications are defined in themchp_pfc_foc_dsPIC33A_data.mfiles, based on the motor manufacturer's specifications. Exceeding these specifications may damage the motor, the board, or both.
The 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 J8(USB-UART) on the development board.
-
Enter the COM port number of the USB connection in the MATLAB script file.
-
Ensure the 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 additional information, refer following documents or links.
- AN1208 Application Note "Integrated Power Factor Correction (PFC) and Sensorless Field Oriented Control (FOC) System"
- AN1292 Application Note “Sensorless Field Oriented Control (FOC) for a Permanent Magnet Synchronous Motor (PMSM) Using a PLL Estimator and Field Weakening (FW)”
- Motor Control High Voltage 230VAC-1.5kW Development Board User’s Guide (DS70005576)
- dsPIC33AK128MC106 Motor Control Dual In-Line Module (DIM) Information Sheet (DS70005527)
- dsPIC33AK128MC106 Family datasheet (DS70005539)
- 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


















