Block configuration for Motor Control

System Configuration

The Mplab Solution do not support continuous time. Indeed micro-controllers are themselves discrete.

The Mplab Solution for Simulink adds to the Simulink Library Browser a library including all the available blocks for the micro-controller.

Add the following blocks :

And configure the Microchip master. It allows the choice of the micro-controller, and the oscillator. For this project, the block must be configured as follow :

The first step to verify the configuration is to blink a LED for example with a frequency of 5Hz.

Motor interface

For motor vector control, three blocks need to be inserted and configured :

Pulse Width Modulation (PWM)

The PWM bloc needs to be configured carrefully :

The bloc configuration is the following :


The quadrature encoder encoder peripheral blocks for the SAM E5x is PDEC. It allows to provide position which can be reseted with using encoder index.

For the index to work, in the options tab, The Enable Auto-correction must be unchecked.

The block configuration is the following :


Currents measurements:

All Shunt resistances are 0.025 Ohms.

Two shunts measures Ia and Ib on PWM1 and PWM2 (low side). The third shunt measure Ibus which is the current sum of the three PWM (low side) currents.

Op-Amps (Internal or External) with a gain of 15 boost low voltage measured to higher voltage converted by the dsPIC ADC for signals Ia, Ib and Ibus.


For the ADC configured for 12 bits right aligned conversion, the raw output represents:


The maximum measurable current is +-4.4 A which provides values within [0 4096] range.

And must be configured as follow :

Site Map