Estimate PMSM Parameters Using Parameter Estimation Blocks
This example uses the parameter estimation blocks provided by Motor Control Blockset™ to estimate these parameters of a permanent magnet synchronous motor (PMSM) with a quadrature encoder sensor:
Phase resistance, Rs (Ohm)
D-axis inductance, Ld (Henry)
Q-axis inductance, Lq (Henry)
Back-EMF constant, Ke (Vpk_LL/krpm, where Vpk_LL is the peak voltage line-to-line measurement)
Motor inertia, J (Kg.m^2)
Friction constant, B (N.m.s)
Motor parameter estimation is vital for implementing motor control algorithms accurately. Accurate motor parameters enable the algorithm to compute the control parameters with precision. Therefore, an accurate representation of motor parameters is necessary for a finer speed and torque control when you run PMSMs using control techniques such as field-oriented control (FOC). Motor parameter estimation also enables you to verify the parameter values provided by the motor datasheet. In addition, it enables you to accurately replicate the plant model in Simulink® using which you can simulate real-world scenarios and tests that are difficult to execute using a physical hardware setup.
An accurate simulation helps you reconfigure and run these tests multiple times, which can be difficult when you use physical hardware. Therefore, these exhaustive tests enable you to predict, find, and fix problems with ease including failures that are hard-to-reproduce.
The example shows you how to use these blocks to design and implement a PMSM parameter estimation algorithm on a Texas Instruments™ hardware board:
PMSM Parameter Estimation Configurator
PMSM Rs Estimator
Ld Estimator
Lq Estimator
PMSM Mechanical Parameter Estimation
Alternatively, using this example as a reference, you can utilize these blocks to implement a similar algorithm on a different hardware board or configuration.
The target model included in the example uses the parameter estimation blocks in the mcb_pmsm_param_est_f28379d/Parameter Estimation/Param Est
subsystem.
These subsystems use the parameter estimation blocks to estimate Rs, Ld, Lq, and the mechanical parameters:
RsTest
— Uses the Rs Estimator block to estimate the motor resistance.
LdTest
— Uses the Ld Estimator block to estimate d-axis inductance.
LqTest
— Uses the Lq Estimator block to estimate q-axis inductance.
MechParam
— Uses the PMSM Mechanical Parameter Estimation block to estimate the back-EMF constant, motor inertia, and the friction constant.
If you are only simulating the example, the target model displays the estimated parameters. When you deploy the target model to the hardware, use the host model to estimate the parameters using the hardware.
Model
The example includes the mcb_pmsm_param_est_f28379d model.
You can use the model for both simulation and code generation.
For details about the supported hardware configuration, see Required Hardware in the Generate Code and Deploy Model to Target Hardware section.
Required bat365 Products
To simulate model:
Motor Control Blockset
Stateflow® (needed only if you modify the example model)
To generate code and deploy model:
Motor Control Blockset
Embedded Coder®
C2000™ Microcontroller Blockset
Stateflow (needed only if you modify the example model)
Prerequisite
Check and update the mandatory motor, inverter, and other system parameters listed in the model initialization script mcb_pmsm_param_est_f28379d_data.m.
In addition, you can update the optional motor parameters for simulation.
You can use the inverter and motor hardware datasheet to determine these values.
Simulate Model
This example supports simulation. Complete these steps to simulate the model.
1. Open the target model included in this example.
2. If required, change the configuration elements for parameter estimation, by updating the mask parameters of the PMSM Parameter Estimation Configurator block available in the mcb_pmsm_param_est_f28379d/Serial Receive/Variant Subsystem/Sim
subsystem. For more details, see PMSM Parameter Estimation Configurator.
3. In the User Controls section, ensure that the Parameter Estimation switch is set to Stop.
4. Click Run on the Simulation tab to simulate the model.
5. Set the Test Method switch to either Manual or Auto mode.
- Manual — This mode enables you to manually execute the tests one by one in the prescribed sequence.
- Auto — This mode enables you to automatically run all the tests in the prescribed sequence.
If you are using the Manual mode:
a. Set the Test Method switch to Manual.
b. Use the Test Select button to select the first test Rs
.
c. Turn the Parameter Estimation switch to Start. The model runs the Rs estimation test after which it displays the computed value in the Estimated Parameters field.
d. Turn the Parameter Estimation switch to Stop.
e. Similarly, use the Test Select button to select the next test and repeat steps c to e.
Note: Ensure that you run all tests in the prescribed sequence of Rs
→ Ld
→ Lq
→ (Ke, J, B)
. Do not skip any test.
During simulation, the target model does not support computation of J.
If you are using the Auto mode:
a. Set the Test Method switch to Auto.
b. Turn the Parameter Estimation switch to Start. The model starts running all tests in the prescribed sequence of Rs
→ Ld
→ Lq
→ (Ke, J, B)
, after which it displays the computed parameter values in the Estimated Parameters field.
c. Turn the Parameter Estimation switch to Stop.
Note: In the Auto mode, the Test Select button selection has no effect.
During simulation, the target model does not support computation of J.
Generate Code and Deploy Model to Target Hardware
This section shows you how to generate code and run the parameter estimation algorithm on the target hardware to estimate the parameters of the connected motor.
This example uses a host and a target model. The host model is a user interface to the controller hardware board. You can run the host model on the host computer. To use the host model, first deploy the target model to the controller hardware board. The host model uses serial communication to command the target to run the parameter estimation tests.
Required Hardware
The example supports this hardware configuration. You can also use the target model name to open the model from the MATLAB command prompt.
LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter: mcb_pmsm_param_est_f28379d
For connections related to the hardware configuration, see LAUNCHXL-F28069M and LAUNCHXL-F28379D Configurations.
Generate Code and Run Model on Target Hardware
1. Complete the hardware connections.
2. The model automatically computes the ADC (or current) offset values. To disable this functionality (enabled by default), update the value 0 to the variable inverter.ADCOffsetCalibEnable in the model initialization script.
Alternatively, you can compute the ADC offset values and update them manually in the model initialization scripts. For instructions, see Run 3-Phase AC Motors in Open-Loop Control and Calibrate ADC Offset.
3. Compute the quadrature encoder index offset value and update it in the model initialization script associated with the target model. For instructions, see Quadrature Encoder Offset Calibration for PMSM.
Note: Verify the number of slits available in the quadrature encoder sensor attached to your motor. Check and update the variable pmsm.QEPSlits available in the model initialization script. This variable corresponds to the Encoder slits parameter of the quadrature encoder block. For more details about the Encoder slits and Encoder counts per slit parameters, see Quadrature Decoder.
4. Open the target model. If you want to change the default hardware configuration settings for the model, see Model Configuration Parameters.
5. Load a sample program to CPU2 of the LAUNCHXL-F28379D board to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1. For example, load the program that operates the CPU2 blue LED by using GPIO31 (c28379D_cpu2_blink.slx
). For more information about the sample program or model, see the Task 2 - Create, Configure and Run the Model for TI Delfino F28379D LaunchPad (Dual Core) section in Getting Started with Texas Instruments C2000 Microcontroller Blockset (C2000 Microcontroller Blockset).
6. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware.
7. Verify that the variables from the target model are available in the MATLAB base workspace.
8. Click the host model hyperlink in the target model to open the associated host model.
For details about serial communication between the host and target models, see Host-Target Communication.
9. If required, change the configuration elements for parameter estimation, by updating the mask parameters of the PMSM Parameter Estimation Configurator block available in the host model. For more details, see PMSM Parameter Estimation Configurator.
10. In the model initialization script associated with the target model, specify the communication port using the variable target.comport. This variable updates the Port parameter of the Host Serial Setup, Host Serial Receive, and Host Serial Transmit blocks available in the host model.
11. In the User Controls section, ensure that the Parameter Estimation switch is set to Stop.
12. Click Run on the Simulation tab to run the host model. This initiates communication between the host model and target hardware.
13. Use the Test Method switch to select either Manual or Auto mode.
- Manual — This mode enables you to manually execute the tests one-by-one in the prescribed sequence.
- Auto — This mode enables you to automatically run all the tests in the prescribed sequence.
If you are using Manual mode:
a. Set the Test Method switch to Manual.
b. Use the Test Select button to select the first test Rs
.
c. Turn the Parameter Estimation switch to Start. The model runs the Rs estimation test after which it displays the computed value in the host model.
d. Turn the Parameter Estimation switch to Stop.
e. Similarly, use the Test Select button to select the next test and repeat steps c to e.
Note: Ensure that you run all tests in the prescribed sequence of Rs
→ Ld
→ Lq
→ (Ke, J, B)
. Do not skip any test. The host model uses the Active Test field to display the test that is currently running.
If you are using Auto mode:
a. Set the Test Method switch to Auto.
b. Turn the Parameter Estimation switch to Start. The model starts running all tests in the prescribed sequence of Rs
→ Ld
→ Lq
→ (Ke, J, B)
after which it displays the computed parameter values in the host model.
c. Turn the Parameter Estimation switch to Stop.
Note: In the Auto mode, the Test Select button selection has no effect.
The host model uses the Active Test field to display the test that is currently running.
14. Use the Debug Signal combo box to select a debug signal. Monitor the selected signal in the scope.
Note: The model can interrupt the currently running test and turn the following LEDs red to protect the hardware from the following faults:
Over-current fault — This fault occurs when the actual current drawn from the power supply is more than the overcurrent limit specified by the variables motor.OverCurrLim and motor.I_rated in the model initialization script.
Under-voltage fault — This fault occurs when input DC voltage drops below the undervoltage limit specified by the variables inverter.UnderVoltLim and inverter.V_dc in the model initialization script.
After the parameter estimation tests are complete, the host model saves the computed parameters in the motorParam variable inside the base workspace.