Main Content

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 and Post Process Motor Data

Collect the nonlinear motor flux data from dynamometer testing or finite element analysis (FEA). For this example, filePMSMEfficiencyData.xlsxcontains the data that you need:

  • 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

N/A

Model Motor Data

Use a one-stage model to fit the data. Specifically:

  • Import data

  • Filter data

  • Fit model

Model-Based Calibration Toolbox

Generate Calibration

Calibrate and optimize the data using objectives and constraints. Specifically:

  • Create functions.

  • Create tables from model.

  • Run an optimization.

  • Generate and fill optimized current controller calibration tables that are functions of motor torque and motor speed.

Model-Based Calibration Toolbox

Set Block Parameters

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:

ψ t o t a l = ψ d 2 + ψ q 2 i s = i d 2 + i q 2 n = 60 ω e 2 π P ψ m a x = V d c 3 ω e

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.xlsxcontains 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.xlsxcontains 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.xlsxcontains 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

  1. In MATLAB®, on theAppstab, in theAutomotivegroup, clickMBC Model Fitting

  2. In the Model Browser home page, clickImport Data.ClickOKto open a data source file.

  3. Navigate to thematlab\toolbox\mbc\mbctrainingfolder. 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 to300一个。

  • Total flux,Ψtotal, less than or equal to allowed fluxΨmax

  1. 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.

  1. In the Data Editor, selectTools>Test Groupsto open theDefine Test Groupingsdialog box. Create groups for the motor torque and speed.

  2. Set these tolerances:

    • Motor torque, Trq, to1.000

    • Motor speed, n, to10.000

  3. 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

  1. In the Model Browser, selectFit Models

  2. InFit Models, configure a Point-by-Point model with these responses and inputs.

    Responses Local Inputs Operating Points

    Iq

    Id

    Trq

    n

  3. 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.

  4. 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, selectIq.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.

  5. Save your project. For example, selectFiles>Save Project.Savegs_example.matto theworkfolder.

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

  1. In MATLAB, on theAppstab, in theAutomotivegroup, clickMBC Optimization

  2. In the Cage Browser, selectModels.If it is not already opened, in the MBC Model Fitting browser, open thegs_example.matproject.

  3. In Import Models, clickOK.Close the CAGE Import Tool.

  4. In the Cage Browser toolbar, useNew Function Modelwizard to create these functions:

    • Is = sqrt(Id^2 + Iq^2)

    • TPA = Trq/Is

  5. In the Cage Browser, verify that the function models forIsandTPAhave these descriptions.

  6. SelectFile>Save Project.Savegs_example.cagto theworkfolder.

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

  1. In the Cage Browser, selectLookup Tables and Tradeoff.In Create Lookup Tables from Model, selectIq.ClickNext

  2. In the Create Lookup Tables from Model wizard:

    • ClearUse model operating points

    • SetTable rowsto31

    • SetTable columnsto29

    • ClickNext

  3. In Create Lookup Tables from Model:

    • SelectIdandIq

    • ClickFinish

  4. 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 to300一个。

  • Maximizes torque per ampere,TPA

  1. On the Cage Browser home, selectOptimization

  2. In Create Optimization from Model, selectTPAandNext

  3. In Create Optimization from Model:

    • SelectId

    • SetObjective typetoMaximize

    • ClickFinish

  4. 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

  5. In the Cage Browser,carefullyverify the Objectives and Constraints.

  6. In the Cage Browser, selectRun

    The optimization results are similar to these.

Fill Lookup Tables

  1. In the CAGE Browser, selectFill Lookup Tables

  2. Use the Lookup Table Filling from Optimization Results Wizard to fill theId_TableandIq_Tabletables.

    • For theId_Table, fill withId

    • For theIq_Table, fill withIq

    ClickNext.For theFill Method, selectClip Fill (column-based)

    ClickFinish

  3. Review results forIq_Table.The results are similar to these.

  4. Review results forId_Table.The results are similar to these.

  5. SelectFile>Save Project.Savegs_example.cagtoworkfolder.

Export Results

  1. SelectFile>Export>Calibration

  2. Use Export Calibration Data to select the items to export and format. For example, export the Id and Iq tables and breakpoints to MATLAB filegs_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:

  1. Run the .mfile 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

  2. 分配的断点参数数据帐目ined in the .mfile. 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';