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 Controllercurrent 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 theFlux-Based PM Controllerblock 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- andq- axis current
d- andq- 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- andq- axis current, respectively |
is, | Current magnitude |
Ψd,Ψq | d- andq- 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 filematlab\toolbox\mbc\mbctraining\PMSMEfficiencyData.xlsx
contains the motor flux data.
Model Motor Data
To model the motor data, use theMBC Model Fittingapp to import, filter, and fit the data with a point-by-point model. For this example, the data filePMSMEfficiencyData.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 thed- andq-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 theAppstab, in theAutomotivegroup, clickMBC Model Fitting.
In the Model Browser home page, clickImport Data.ClickOKto 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
一个。Total flux,Ψtotal, less than or equal to allowed fluxΨmax
In the Data Editor, selectTools>Filtersto open theFilter 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, selectTools>Test Groupsto open theDefine Test Groupingsdialog 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, selectFile>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, selectFit Models.
InFit 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, selectOK.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 forIq.模型浏览器显示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, selectFiles>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 theAppstab, in theAutomotivegroup, clickMBC Optimization.
In the Cage Browser, selectModels.If it is not already opened, in the MBC Model Fitting browser, open the
gs_example.mat
project.In Import Models, clickOK.Close the CAGE Import Tool.
In the Cage Browser toolbar, useNew Function Modelwizard 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.SelectFile>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, selectLookup Tables and Tradeoff.In Create Lookup Tables from Model, select
Iq
.ClickNext.In the Create Lookup Tables from Model wizard:
ClearUse model operating points.
SetTable rowsto
31
.SetTable columnsto
29
.ClickNext.
In Create Lookup Tables from Model:
Select
Id
andIq
.ClickFinish.
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
一个。Maximizes torque per ampere,TPA.
On the Cage Browser home, selectOptimization.
In Create Optimization from Model, select
TPA
andNext.In Create Optimization from Model:
Select
Id
.SetObjective typeto
Maximize
.ClickFinish.
Add the optimization constraint for the current magnitude,Is.In the CAGE Browser, selectOptimization>Constraints>Add Constraints打开编辑约束。使用cre的对话框ate a constraint on the current.
Is <= 300
In the Cage Browser,carefullyverify the Objectives and Constraints.
In the Cage Browser, selectRun.
The optimization results are similar to these.
Fill Lookup Tables
In the CAGE Browser, selectFill 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
.
ClickNext.For theFill Method, select
Clip Fill (column-based)
.ClickFinish.
Review results for
Iq_Table
.The results are similar to these.Review results for
Id_Table
.The results are similar to these.SelectFile>Save Project.Save
gs_example.cag
towork
folder.
Export Results
SelectFile>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 theseFlux-Based PM Controllerblock 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 calibrationgs_example
分配的断点参数数据帐目ined 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/snbp=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';