Skip to content

microchip-pic-avr-solutions/matlab-mclv48v300w-33ak512mc510-pmsm-foc-qei

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microchip Logo.

MATLAB/Simulink Model for Optical Encoder based FOC: MCLV-48V-300W Development Board and dsPIC33AK512MC510 Motor Control DIM

1. INTRODUCTION

This document describes the setup requirements to drive a PMSM motor on the hardware platform EV18H47A "MCLV-48V-300W Motor Control Development Board" and EV67N21A "dsPIC33AK512MC510 Motor Control Dual In-line Module(DIM)".

The Quadrature Encoder Interface (QEI) perpheral of the dsPIC DSC can be configured to obtain the position and speed information from the opitical encoder feedback of the motor.

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.

2. SUGGESTED DEMONSTRATION REQUIREMENTS

2.1 MATLAB Model Required for the Demonstration

To clone or download this MATLAB model on GitHub,

  • MATLAB model can be cloned or downloaded as zip file from the Github repository (link).

2.2 Software Tools Used for Testing the firmware

  • MPLAB® X IDE v6.25
  • MPLAB® XC-DSC 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.

2.3 Hardware Tools Required for the Demonstration

  • MCLV-48V-300W Development Board (EV18H47A)
  • dsPIC33AK512MC510 Motor Control Dual In-line Module (EV67N21A)
  • 24V Power Supply (AC002013)
  • 24V 3-Phase Brushless DC Motor With Encoder (AC300022)

Note:
All items listed under the section Hardware Tools Required for the Demonstration are available at microchip DIRECT


3. HARDWARE SETUP

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.

  1. 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.

  2. 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.

  3. Connect the 3-phase wires from the motor to PHC, PHB and PHA of the connector J4 (in the same order as shown in the picture), provided on the development board.

    Development Board Hurst300 Motor
    Winding Terminals (Color as per image below) Power Connector (Molex 39-01-2040)
    PHC Red 1
    PHB Black 2
    PHA White 3

  4. Connect the encoder from the motor to QEA and QEB terminals of connector J7 (in the same order as shown in the picture), provided on the Development Board.

    Development Board Hurst300 Motor
    Hall Terminals(Color as per image above) Encoder Connector (FCI Connect #69168-108)
    5V Red 1
    DGND Black 8
    Q A White 5
    Q B Blue 6


  5. Plug the 24V power supply to connector J1 on the development board. Alternatively, the development board can also be powered through connector J3.

  6. 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.

  7. Alternatively, connect the Microchip programmer/debugger MPLAB® PICkit™ 5 In-Circuit Debugger(PG164140) 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.


4. BASIC DEMONSTRATION

Follow the below instructions step-by-step, to set up and run the motor control demo application:

  1. Launch MATLAB (refer the section “2.2 Sofware Tools Used for Testing the MATLAB/Simulink Model").

  2. Open the folder downloaded from the repository, in which MATLAB files are saved (refer the section "2.1 MATLAB Model Required for the Demonstration").

  3. 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.

  4. Double click on the Encoder FOC Simulink model - pmsm_encoder.slx.

  5. This opens the Simulink model as shown below. Click on the "Run" icon to start the simulation.

  6. 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.

  7. 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.

  8. 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 dsPIC33AK512MC510 device.

  9. After completing the process, the ‘Operation Succeeded’ message will be displayed on the ‘Diagnostics Viewer’.

  10. If the device is successfully programmed, LED1 - LD2 and the LED2 - LD2 will be blinking.

  11. To Run the motor, press the push button SW1.

  12. The motor speed can be varied using the potentiometer (labeled “POT”).

  13. Press the push button SW1 to stop the motor. Make sure motor is reduced minimum potentimeter value before stopping the motor.

5. DATA VISUALIZATION USING MOTOR CONTROL BLOCKSET (MCB) HOST MODEL

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.

  1. 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.

  2. Enter the COM port number of the USB connection in the MATLAB script file.

  3. Ensure the Optical Encoder FOC model is programmed and running as described under section "4. Basic Demonstration" by following steps 1 through 13.

  4. Open the mcb_hostmodel_dsPIC33A.slx model and click on the Run icon to plot the real time data.

  5. Select the signals on Debug Select Value pannel to plotted available signals on the scope.

REFERENCES:

For more information, refer to the following documents or links.

  1. MCLV-48V-300W Development Board User’s Guide (DS50003297)
  2. dsPIC33AK512MC510 Motor Control Dual In-Line Module (DIM) Information Sheet (DS70005553)
  3. dsPIC33AK512MC510 Family datasheet (DS70005591)
  4. MPLAB® X IDE User’s Guide (DS50002027) or MPLAB® X IDE help
  5. MPLAB® X IDE installation
  6. MPLAB® XC-DSC Compiler installation
  7. Motor Control Blockset
  8. MPLAB Device Blocks for Simulink :dsPIC, PIC32 and SAM mcu

About

MATLAB-Simulink model for Optical Encoder Based FOC using MCLV-48V-300W Development Board and dsPIC33AK512MC510 MC DIM

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages