Skip to content

02_basicVectorControl_labEmbeddedModel

rdelpoux edited this page Oct 6, 2025 · 2 revisions

Embedded model

For a successful experimental velocity vector control, the control strategy needs to be initially applied in simulation. A simulation of the motor and it's control is proposed in the section. The simulation permits to develop the embedded Simulink file.

Open a template Model

  • Start Simulink.

  • In the Simulink Start Page, create a model from the template : MCLV 48V 300W - dsPIC33AK128MV106 DIM

  • A Simulink model opens :

    • This model requires some configurations to be adapted to the motor parameters. Double click on the Board Subsystem and configure following parameters :

      • Set Board Variants as Internal Op-amp. It allows the use on micro-controller internal operational amplifier for ADC measurements

      • Set motor pole pairs to 4

      • Set Optical Encoder resolution per Mechanical Rotation to 4000

      • Set Optical encoder reset to on index signal and keep the offset equal to 0, since the motor has an encoder with index signal.

      • Save the model.

      • A the end the block should looks like :

      • To not hesitate to click on the gray arrow in the left bottom conner of the block to open the template and feel free to explore the Simulink model.

Open loop control

  • On the model, you may add the LED blink blocks realized previously to ensure that the microcontroller is working correctly

  • Add also the UART Tx-Matlab Block To visualize the signals using tue Serial Link.

  • On the PWM input of the template, add three sinusoidal functions

$$ \rho_a = 0.05\sin(10\times 2\pi t) + 0.5 $$

$$ \rho_b = 0.05\sin(10\times 2\pi t-2\pi/3) + 0.5 $$

$$ \rho_c = 0.05\sin(10\times 2\pi t+2\pi/3) + 0.5 $$

  • To visualize the signals with picgui, download the DataVisu.m script, and write DataVisu in the main window as follows. This will allow you the visualize the different signals properly.

  • You should visualize the following plot:

Simulation

To run this simulink model, first run the mfile and then run the simulink file. Explore the simulation file and the different modes.

Closed loop control

Embedded control

  • Migrate the controller from simulation to the motor program step by step.

    • Try first the park transformation

    • Then go for speed control
Clone this wiki locally