Generate Current Controller Parameters
Using the Model-Based Calibration Toolbox™, you can generate optimized current tables for flux-based motor controllers. Use the calibration tables for the Powertrain Blockset™ Flux-Based PM Controller current controller block parameters.
Based on nonlinear motor flux data, the calibration tables optimize:
Motor efficiency
Maximum torque per ampere (MTPA)
Flux weakening
To generate optimized current tables, follow these workflow steps.
Workflow Steps | Description | MathWorks® Tooling |
---|---|---|
Collect the nonlinear motor flux data from dynamometer testing
or finite element analysis (FEA). For this example, file
| N/A | |
Use a one-stage model to fit the data. Specifically:
| Model-Based Calibration Toolbox | |
Calibrate and optimize the data using objectives and constraints. Specifically:
| Model-Based Calibration Toolbox | |
Use the optimized current controller calibration tables for the Flux-Based PM Controller block current controller parameters. | Powertrain Blockset |
Collect and Post Process Motor Data
Collect this nonlinear motor flux data from dynamometer testing or finite element analysis (FEA):
d- and q- axis current
d- and q- axis flux linkage
Electromagnetic motor torque
Use the collected data and motor speed to calculate the total flux, maximum flux, and current magnitude:
The equations use these variables:
id, iq |
d- and q- axis current, respectively |
is, | Current magnitude |
Ψd, Ψq |
d- and q- axis flux linkage, respectively |
Ψtotal, Ψmax | Total and allowed flux, respectively |
ωe |
Electrical motor angular speed, rad/s |
n |
Motor speed, rpm |
Vdc | Inverter bus voltage |
P |
Number of pole pairs |
Finally, for each data point, create a file containing:
Total flux, Ψtotal, in Wb
Allowed flux, Ψmax, in Wb
d-axis flux, Ψd, in Wb
q-axis flux, Ψq, in Wb
d-axis current, Id, in A
q-axis current, Iq, in A
Current magnitude, Is, in A
Motor torque, Te, in N·m
Motor speed, n, in rpm
For this example:
Pole pairs, P, is 4
Inverter bus voltage, Vdc, is 500
the data file
matlab\toolbox\mbc\mbctraining\PMSMEfficiencyData.xlsx
contains the
motor flux data.
Model Motor Data
To model the motor data, use the MBC Model Fitting app to import,
filter, and fit the data with a point-by-point model. For this example, the data file
PMSMEfficiencyData.xlsx
contains a large data set. You could consider
using a design of experiment (DOE) to limit the data. However, the data set represents
typical FEA analysis results.
Since there is a simple relationship between the d- and q-axis currents for fixed torque-speed operating points, the point-by-point model provides an accurate fit.
For comparison, the PMSM maximum efficiency calibration case study contains the model fit.
Import Data
For this example, PMSMEfficiencyData.xlsx
contains this motor
controller data:
Total flux, Ψtotal, in Wb
Allowed flux, Ψmax, in Wb
d-axis flux, Ψd, in Wb
q-axis flux, Ψq, in Wb
d-axis current, Id, in A
q-axis current, Iq, in A
Current magnitude, Is, in A
Motor torque, Te, in N·m
Motor speed, n, in rpm
In MATLAB®, on the Apps tab, in the Automotive group, click MBC Model Fitting.
In the Model Browser home page, click Import Data. Click OK to open a data source file.
Navigate to the
matlab\toolbox\mbc\mbctraining
folder. Open data filePMSMEfficiencyData.xlsx
. The Data Editor opens with your data.
Filter Data
You can filter data to exclude records from the model fit. In this example, set up a filter to include only flux and current magnitudes that are less than a specified threshold. Specifically:
Current magnitude, Is, less than or equal to
300
A.Total flux, Ψtotal, less than or equal to allowed flux Ψmax
In the Data Editor, select Tools > Filters to open the Filter Editor. Create these filters:
Is <= 300
Flux <= Flux_allowed
Define Test Groupings
For point-by-point models, you need to define test groups. In the example, define groups for motor torque and speed. Set the tolerances to so that Model-Based Calibration Toolbox groups small variations in torque and speed at the same operating point.
In the Data Editor, select Tools > Test Groups to open the Define Test Groupings dialog box. Create groups for the motor torque and speed.
Set these tolerances:
Motor torque, Trq, to
1.000
Motor speed, n, to
10.000
In the Data Editor, select File > Save & Close. Accept the changes to the data.
Fit Model
Fit the data to a point-by-point model with these responses, local inputs, and operating points:
Responses
q-axis current, Iq, in A
Local inputs
d-axis current, Id, in A
Operating points
Motor speed, n, in rpm
Electromagnetic motor torque, Te, in N·m
In the Model Browser, select Fit Models.
In Fit Models, configure a Point-by-Point model with these responses and inputs.
Responses Local Inputs Operating Points Iq
Id
Trq
n
To fit the model, select OK. If prompted, accept changes to data. By default, the fit uses a Gaussian Process Model (GPM) to fit the data.
After the fit completes, examine the response models for Iq. The Model Browser displays information that you can use to determine the accuracy of the model fit.
In the Model Browser, select
Iq
. Examine the response surface and diagnostic statistics. These results indicate a reasonably accurate fit. You can browse through each test to examine the response for each torque-speed operating point.
Save your project. For example, select Files > Save Project. Save
gs_example.mat
to thework
folder.
Generate Calibration
After you fit the model, create functions and tables, run the optimization, and fill the calibration tables.
For comparison, the PMSM maximum efficiency calibration case study contains the calibration results.
Import Models and Create Functions
Import models and create the functions to use when you optimize the calibration. In this example, set up functions for:
Current magnitude, Is
Torque per amp, TPA
In MATLAB, on the Apps tab, in the Automotive group, click MBC Optimization.
In the Cage Browser, select Models. If it is not already opened, in the MBC Model Fitting browser, open the
gs_example.mat
project.In Import Models, click OK. Close the CAGE Import Tool.
In the Cage Browser toolbar, use New Function Model wizard to create these functions:
Is = sqrt(Id^2 + Iq^2)
TPA = Trq/Is
In the Cage Browser, verify that the function models for
Is
andTPA
have these descriptions.Select File > Save Project. Save
gs_example.cag
to thework
folder.
Create Lookup Tables from Model
Create tables that the Model-Based Calibration Toolbox optimizers uses to store the optimized parameters. For this example, the tables are:
d-axis current, Id, as a function of motor torque,
Trq
, and motor speed,n
.q-axis current, Iq, as a function of motor torque,
Trq
, and motor speed,n
.
In the Cage Browser, select Lookup Tables and Tradeoff. In Create Lookup Tables from Model, select
Iq
. Click Next.In the Create Lookup Tables from Model wizard:
Clear Use model operating points.
Set Table rows to
31
.Set Table columns to
29
.Click Next.
In Create Lookup Tables from Model:
Select
Id
andIq
.Click Finish.
In the CAGE Browser, examine the tables.
Run Optimization
In this example, run an optimization with these specifications:
Current magnitude, Is, less than or equal to
300
A.Maximizes torque per ampere, TPA.
On the Cage Browser home, select Optimization.
In Create Optimization from Model, select
TPA
and Next.In Create Optimization from Model:
Select
Id
.Set Objective type to
Maximize
.Click Finish.
Add the optimization constraint for the current magnitude, Is. In the CAGE Browser, select Optimization > Constraints > Add Constraints to open Edit Constraint. Use the dialog box to create a constraint on the current.
Is <= 300
In the Cage Browser, carefully verify the Objectives and Constraints.
In the Cage Browser, select Run.
The optimization results are similar to these.
Fill Lookup Tables
In the CAGE Browser, select Fill Lookup Tables.
Use the Lookup Table Filling from Optimization Results Wizard to fill the
Id_Table
andIq_Table
tables.For the
Id_Table
, fill withId
.For the
Iq_Table
, fill withIq
.
Click Next. For the Fill Method, select
Clip Fill (column-based)
.Click Finish.
Review results for
Iq_Table
. The results are similar to these.Review results for
Id_Table
. The results are similar to these.Select File > Save Project. Save
gs_example.cag
towork
folder.
Export Results
Select File > Export > Calibration.
Use Export Calibration Data to select the items to export and format. For example, export the Id and Iq tables and breakpoints to MATLAB file
gs_example.m
.
Set Block Parameters
The optimized current controller calibration tables are functions of motor torque and motor speed. Use the tables for these Flux-Based PM Controller block parameters:
Corresponding d-axis current reference, id_ref
Corresponding q-axis current reference, iq_ref
Vector of speed breakpoints, wbp
Vector of torque breakpoints, tbp
To set the block parameters:
Run the .
m
file that contains the Model-Based Calibration Toolbox calibration results for the current controller. For example, in the MATLAB command line, rungs_example.m
:% Access data from MBC current controller calibration gs_example
Assign the breakpoint parameters to the data contained in the .
m
file. In this example, the speed data is in rpm. To use the calibration data for the block parameters, convert the speed breakpoints from rpm to rad/s.Parameter MATLAB Commands Vector of speed breakpoints, wbp tbp=Trq_norm.X;
Vector of speed breakpoints, wbp % MBC data for speed is in rpm. % For the block parameter, use rad/s nbp=n_norm.X; conversion=(2*pi/60.); wbp=conversion.*nbp;
Corresponding d-axis current reference, id_ref id_table=Id_Table.Z; id_ref=id_table';
Corresponding q-axis current reference, iq_ref iq_table=Iq_Table.Z; iq_ref=iq_table';