Microchip logo
Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes

Microchip Motor Control Library Blockset, Revision 0.30b

The Microchip Motor Control Library Blockset contains a number of basic Simulink® blocks that can be used to jumpstart model-based design of motor control applications using Microchip dsPIC® Digital Signal Controllers in the dsPIC33F and dsPIC33E families.

These blocks include reference frame transforms, a proportional-integral controller, and trigonometric functions, all of which can be used with Embedded Coder® to generate efficient code on the dsPIC DSC that utilizes the Microchip Motor Control Library.

Simulink® Demo Model for Sensorless FOC with PLL Estimator

Register to download a demonstration model for motor control development and code generation using Simulink and the Motor Control Library Blockset

Sensorless FOC w/ PLL Model User Manual for Model

System Requirements

For simulation, you will need

  • MATLAB® R2013a or later, 32-bit or 64-bit Windows
  • Simulink
  • Fixed-Point Designer™

For code generation, you will also need

  • Simulink Coder™
  • MATLAB Coder™
  • Embedded Coder

This blockset includes only algorithmic blocks. Support for dsPIC® DSC peripherals is provided separately, with the MPLAB® 16-Bit Device Blocks for Simulink package from Microchip.

Compilation and programming of the code generated with this blockset requires an MPLAB® XC compiler and the MPLAB X IDE. At this time the Motor Control Library Blockset is compatible only with the XC16 v1.11 compiler.


Once you have done this, the Motor Control Library Blockset will appear in the Simulink Library Browser the next time you start MATLAB.


Documentation on each of the blocks is provided in the following section. These blocks may be placed in a Simulink model like any other Simulink block.

For best results in code generation, turn on Inline Parameters.

The Proportional-Integral controller block requires mchp_MC_PISTATE_T in the MATLAB base workspace to contain a particular structure definition. This can be automatically set up by creating the required structure in the Simulink model's InitFcn.

  • In a Simulink model using the Motor Control Library Blockset, select File > Model Properties > Model Properties > Callbacks > InitFcn.
  • Add the following statement to the model initialization function shown in the InitFcn dialog box:
  • Save the Simulink model.

This only needs to be done once per new model file.

Block Listing

Block Name Block Desription
Clarke:ab-to-alphabeta clarke transformClarke transform (ab → αβ)
2 → 2 transform from per-phase measurements (ab) to stationary orthogonal (αβ) reference frame
ClarkeInv:alphabeta-to-abc:input-swap inverse clarke transformInverse Clarke transform (αβ → abc)
2 → 3 transform from stationary orthogonal (αβ) reference frame to per-phase values (abc)
Legacy form with swapped inputs
Park:alphabeta-to-dq Park transformPark transform (αβ → dq)
2 → 2 transform from stationary orthogonal (αβ) reference frame to rotating (dq) reference frame
ParkInv:dq-to-alphabeta Inverse Park transformInverse Park transform (dq → αβ)
2 → 2 transform from rotating (dq) reference frame to stationary orthogonal (αβ) reference frame
PI-controller:antiwindup antiwindupProportional-integral controller with antiwindup
Sincos:table-interp Sine and cosine calculationSine and cosine calculation (table-based with interpolation)
Arctan2:CORDIC ArctangentArctangent (xy → θ)
Compute angle of input coordinates (x,y) using the CORDIC algorithm.
SVM-generator:gain-and-phase-shift Space vector modulationSpace vector modulation
Legacy form, with gain and phase shift