In this video, we will see how to use Motor Control Blockset to run instrumented tests on a brushless PMSM motor
to quickly estimate motor parameters that we can use to design controller gains and run closed-loop simulation.
Often times motor parameters are either not available from data sheet or the motor behavior that we observe is different
than what’s described by the data sheet. In that case, Motor Control Blockset and its parameter estimation capabilities can come handy
to provide an accurate parameterization of the motor.
To estimate motor parameters, we’ll use these two models that come with Motor Control Blockset.
These models have been configured to run parameter estimation for a particular combination of microcontroller and inverter
that we’re using here, Texas Instruments Launchpad F28379D and DRV8305 inverter.
These models can be used as starting point to adapt for your own application.
This particular model contains the algorithm that run instrumented tests on motor hardware.
As instructed here, we first click this link to open up the host model and click CTRL+D to update the workspace with the inputs
provided by this model. Then we go back to the target model.
We now navigate to the hardware tab and click this button to generate code from the model and upload the generated code
to the launchpad processor. Once the code is compiled and uploaded to the hardware,
we switch to the host model which runs on a host computer, in this case my laptop.
This model controls the operation of parameter estimation task.
Here, we define the nominal values for our motor such as the nominal voltage, current, speed, the number of pole pairs, and
the input DC voltage for our power supply. And here, we can specify the offset for the hall sensor
that we compute using other capabilities of Motor Control Blockset.
Once we have provided these values, we can start the instrumented tests on the motor control hardware.
To run the tests, we press this button that runs the host model.
We see that the stator resistance is estimated first followed by estimation of Ld and Lq, back-EMF, motor inertia and friction constant.
To see what was happening with the motor during this test, we can select the signal from the target that we want to look at.
We can view signals such as Vd, Vq, Id, Iq and so on. In this case, we’ll look at the speed signal using the provided scope.
We can see here that the test included spooling the motor up and spooling it down to compute the motor inertia.
Now that the parameters have been estimated, there are two things we can do. One is we can save the estimated parameters into a
MATLAB file. We can then use this MATLAB file to compute controller gains or to populate the parameters of the motor model for
closed-loop simulation. To do that, we click the “Save” button and specify the name of the file.
Now, we go to MATLAB command line, clear the workspace and load the file we just saved. This creates a structure called "motorParam".
And the structure has parameters that we just estimated. We can also press this “Open model” button.
This creates a new Simulink model that contains the block for modeling the motor dynamics.
If we open the block dialog, we see that this block has been parameterized with the estimated values of our motor parameters.
We can now use this block for accurate closed-loop simulation of motor dynamics.
Note that parameter estimation runs for the motor for no load.
If we add load to the motor, we might need to adjust our controller design and model the load dynamics in the simulation.
But these initial set of parameters that we obtained here is a useful start for computing motor parameters
and setting up closed-loop simulation of our motor control algorithm. This completes the demo.