
Sensorless FOC using PLL Estimator and Single-Shunt Current Reconstruction Algorithm for PMSM : MCHV-230VAC-1.5kW and dsPIC33AK128MC106 Motor Control DIM
This document describes the setup requirements for driving a Permanent Magnet Synchronous Motor (PMSM) using Sensorless Field Oriented Control (FOC), PLL Estimator and Single-Shunt Current Reconstruction Algorithm on the hardware platform EV78U65A "MCHV-230VAC-1.5kW Development Board" and EV68M17A "dsPIC33AK128MC106 Motor Control Dual In-line Module (DIM)".
For details about PLL estimator, refer to Microchip application note AN1292 “Sensorless Field Oriented Control (FOC) for a Permanent Magnet Synchronous Motor (PMSM) Using a PLL Estimator and Field Weakening (FW)”
For details about Single-Shunt Current Reconstruction algorithm, refer to Microchip application note AN1299 "Single-Shunt Three-Phase Current Reconstruction Algorithm for Sensorless FOC of a PMSM".
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.
To clone or download this application firmware on GitHub,
- Navigate to the main page of this repository and
- On the tab <> Code, above the list of files in the right-hand corner, click Code, then from the menu, click Download ZIP or copy the repository URL to clone.
Note:
In this document, hereinafter this firmware package is referred as firmware.
- MPLAB® X IDE v6.25
- Device Family Pack (DFP): dsPIC33AK-MC_DFP v1.1.109
- Curiosity/Starter Kits Tool Pack : PKOB4_TP v1.19.1503
- MPLAB® XC-DSC Compiler v3.21
- MPLAB® X IDE Plugin: X2C-Scope v1.7.0
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)
- Leadshine 400W 220VAC Servo Motor(EL5-M0400-1-24 : AC300025)
Note:
All items listed under the section Hardware Tools Required for the Demonstration are available at 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. 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 (no specific order) of the connector J13(MOTOR) on the development board.
-
Power the development board from a controlled AC source by applying voltage of 220Vac rms 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 isolated on-board programming tool called the Isolated PKoB4 Daughter Board. To use the isolated on-board programmer, connect a micro-USB cable between the Host PC and the 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 the connector J8(USB-UART) on the development board. This interface provides an isolated USB-UART communication.
Note:
Use only shielded micro-USB cables intended for data transfer.
Install MPLAB X IDE and MPLAB XC-DSC Compiler versions that support the device dsPIC33AK128MC106 and PKoBv4. The MPLAB X IDE, MPLAB XC-DSC Compiler, and X2C-Scope plug-in used for testing the firmware are mentioned in the Motor Control Application Firmware Required for the Demonstration section.
To get help on
If MPLAB IDE v8 or earlier is already installed on your computer, then run the MPLAB driver switcher (Installed when MPLAB®X IDE is installed) to switch from MPLAB IDE v8 drivers to MPLAB X IDE drivers. If you have Windows 8 or 10, you must run the MPLAB driver switcher in Administrator Mode. To run the Device Driver Switcher GUI application as administrator, right-click on the executable (or desktop icon) and select Run as Administrator. For more details, refer to the MPLAB X IDE help topic “Before You Begin: Install the USB Device Drivers (For Hardware Tools): USB Driver Installation for Windows Operating Systems.”
X2C-Scope is a MPLAB X IDE plugin that allows developers to interact with an application while it runs. X2C-Scope enables you to read, write, and plot global variables (for motor control) in real-time. It communicates with the target using the UART. To use X2C-Scope, the plugin must be installed. To set up and use X2C-Scope, refer to the instructions provided on the web page.
The firmware version needed for the demonstration is mentioned in the section Motor Control Application Firmware Required for the Demonstration section. This firmware is implemented to work on Microchip’s Digital signal controller (dsPIC® DSC) dsPIC33AK128MC106. For more information, see the dsPIC33AK128MC106 Family datasheet (DS70005539).
The Motor Control Demo application uses a push button to start or stop the motor and a potentiometer to vary the speed of the motor. This Motor Control Demo Application configures and uses peripherals like PWM, ADC, UART, OP-AMP, CMP, DAC etc. For more details, refer to Microchip Application note AN1292, “Sensorless Field Oriented Control (FOC) for a Permanent Magnet Synchronous Motor (PMSM) Using a PLL Estimator and Field Weakening (FW)” available on the Microchip website.
Note:
The project may not build correctly in Windows OS if the Maximum path length of any source file in the project is more than 260 characters. In case the absolute path exceeds or nears the maximum length, do any (or both) of the following:
- Shorten the directory name containing the firmware used in this demonstration. If you renamed the directory, consider the new name while reading the instructions provided in the upcoming sections of the document.
- Place firmware in a location such that the total path length of each file included in the projects does not exceed the Maximum Path length specified.
Refer to MPLAB X IDE help topic “Path, File, and Folder Name Restrictions” for details.
Follow the below instructions, step by step, to set up and run the motor control demo application:
-
Start MPLAB X IDE and open the project pmsm.X (File > Open Project) with device selection dsPIC33AK128MC106.
-
Set the project pmsm.X as the main project by right-clicking on the project name and selecting Set as Main Project as shown. The project pmsm.X will then appear in bold.
-
Open
mc1_user_params.h
(pmsm.X > Header Files) in the project pmsm.X.-
Ensure the macro
OPEN_LOOP_FUNCTIONING
is undefined andSINGLE_SHUNT
is defined -
Firmware is configured to run with Leadshine 400W 220VAC Servo Motor(EL5-M0400-1-24 : AC300025) by default. The motor is tested under no load conditions. To achieve optimal performance under loaded conditions, the control parameters in the firmware may need additional tuning.
-
By default, the macro
FLUX_WEAKENING_VARIANT
is defined to 1, enabling the flux weakening control through a PI controller that limits the voltage circle using voltage feedback. Define the macro to 2 to enable the flux weakening using reference speed feed-forward control based on PMSM steady state equations. The flux weakening can be disabled by defining the macro to 0.Note:
When the input AC voltage is 220Vac rms, the MAXIMUM_SPEED_RPM is achieved by utilizing the available DC bus voltage, rather than by employing the flux weakening algorithm. -
When internal amplifiers are used for current amplification (referred to as internal op-amp configuration), define the macro
INTERNAL_OPAMP_CONFIG
-
Otherwise, if external amplifiers are used for current amplification (referred to as external op-amp configuration), undefine the macro
INTERNAL_OPAMP_CONFIG
-
Note:
The motor phase currents are reconstructed from the DC Bus current by appropriately sampling it during the PWM switching period, called as single-shunt reconstruction algorithm. The firmware is configured to demonstrate the single shunt reconstruction algorithm by defining the macroSINGLE_SHUNT
in the header filemc1_user_params.h
. For additional information, refer to Microchip application note AN1299, “Single-Shunt Three-Phase Current Reconstruction Algorithm for Sensorless FOC of a PMSM.”
-
Right-click on the project pmsm.X and select Properties to open its Project Properties Dialog. Click the Conf:[default] category to reveal the general project configuration information. The development tools used for testing the firmware are listed in section 2.2 Software Tools Used for Testing the firmware.
In the Conf:[default] category window:
- Ensure the selected Device is dsPIC33AK128MC106.
- Select the Connected Hardware Tool to be used for programming and debugging.
- Select the specific Device Family Pack (DFP) from the available list of Packs. In this case, dsPIC33AK-MC_DFP 1.1.109 is selected.
- Select the specific Compiler Toolchain from the available list of XC-DSC compilers. In this case, XC-DSC(v3.21) is selected.
- After selecting Hardware Tool and Compiler Toolchain, Device Pack, click the button Apply
Please ensure that the selected MPLAB® XC-DSC Compiler and Device Pack support the device configured in the firmware
-
Ensure that the checkbox Load symbols when programming or building for production (slows process) is checked under the Loading category of the Project Properties window.
Also, go to Tools > Options , and
Open the Embedded > Generic Settings tab and ensure that the ELF debug session symbol load methodology (MIPS/ARM) is selected as Pre-procesed (Legacy) from the drop down.
-
To build the project (in this case, pmsm.X) and program the device dsPIC33AK128MC106, click Make and Program Device Main project on the toolbar
-
If the device is successfully programmed, LED1 (D15) will be blinking, indicating that the dsPIC® DSC is enabled.
-
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 LED LED2(D16) is turned ON to show the button is pressed to start the motor.The specific motor was tested under no load conditions. To achieve optimal performance under loaded conditions, the control parameters in the firmware may need additional tuning.
-
The motor speed can be varied using the potentiometer (POT).
-
Press the push button BUTTON 2 to change the direction of rotation of motor.
-
Press the push button BUTTON 1 to stop the motor.
Note:
The macrosNOMINAL_SPEED_RPM
andMAXIMUM_SPEED_RPM
are defined in the respective motor header files as per the Motor manufacturer’s specifications. Exceeding manufacture's specifications may damage the motor or the board or both.
X2C-Scope is a third-party plug-in in MPLAB X, which helps in real-time diagnostics. The application firmware comes with the initialization needed to interface the controller with the host PC to enable data visualization through the X2C-Scope plug-in. Ensure the X2C-Scope plug-in is installed. For more information on how to set up a plug-in, refer to either the Microchip Developer Help page or the web page.
-
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. This interface provides an isolated USB-UART communication.
-
Ensure the application is configured and running as described under section 5.2 Basic Demonstration by following steps 1 through 10.
-
Open the X2C-Scope window by selecting Tools>Embedded>X2CScope.
-
In the X2C-Scope Configuration window, open the Connection Setup tab and click Select Project. This opens the drop-down menu Select Project with a list of opened projects. Select the specific project pmsm from the list of projects and click OK.
-
To configure and establish the serial communication for X2C-Scope, open the X2CScope Configuration window, click on the Connection Setup tab and:
- Set Baudrate as 115200, which is configured in the application firmware.
- Click on the Refresh button to refresh and update the list of the available Serial COM ports connected to the Host PC.
- Select the specific Serial port detected when interfaced with the development board. The Serial port depends on the system settings
-
Once the Serial port is detected, click on Disconnected and turn to Connected, to establish serial communication between the Host PC and the board.
-
Open the Project Setup tab in the X2CScope Configuration window and,
- Set Scope Sampletime as the interval at which
X2CScopeUpdate()
is called. In this application, it is every50µs.
- Then, click Set Values to save the configuration.
- Set Scope Sampletime as the interval at which
-
Click on Open Scope View (in the Data Views tab of the X2CScope Configuration Window); this opens Scope Window.
-
In the Scope Window, select the variables that must be watched. To do this, click on the Source against each channel, and a window Select Variables opens on the screen. From the available list, the required variable can be chosen. Ensure checkboxes Enable and Visible are checked for the variables to be plotted. To view data plots continuously, uncheck Single-shot. When Single-shot is checked, it captures the data once and stops. The Sample time factor value multiplied by Sample time decides the time difference between any two consecutive data points on the plot.
-
Click on SAMPLE, then the X2C-Scope window plots variables in real-time, which updates automatically.
-
Click on ABORT to stop.
For additional information, refer following documents or links.
- AN1299 Application Note “Single-Shunt Three-Phase Current Reconstruction Algorithm for Sensorless FOC of a PMSM”
- 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
- Installation and setup of X2Cscope plugin for MPLAB X
- Microchip Packs Repository