model engine using n-凯发k8网页登录

main content

model engine using n-d adaptive lookup table

objectives

in this example, you learn how to capture the time-varying behavior of an engine using an n-d adaptive lookup table. you accomplish the following tasks using the simulink® software:

  • configure an adaptive lookup table block to model your system.

  • simulate the model to update the lookup table values dynamically.

  • export the adapted lookup table values to the matlab® workspace.

  • lock a specific cell in the table during adaptation.

  • disable the adaptation process and use the adaptive lookup table as a static lookup table.

about the data

in this example, you use the data in vedata.mat which contains the following variables measured from an engine:

  • x — 10 input breakpoints for intake manifold pressure in the range [10,100]

  • y — 36 input breakpoints for engine speed in the range [0,7000]

  • z — 10x36 matrix of table data for engine volumetric efficiency

    to learn more about breakpoints and table data, see .

the output volumetric efficiency of the engine is time varying, and a function of two inputs—intake manifold pressure and engine speed. the data in the mat-file is used to generate the time-varying input and output (i/o) data for the engine.

in next section, you open a preconfigured simulink model.

engine data model

load the engine data.

load vedata.mat

open the preconfigured model.

open_system('enginetable1_data')

building a model using adaptive lookup table blocks

in this portion of the tutorial, you learn how to build a model of an engine using an adaptive lookup table block.

  1. the experimental data subsystem in the simulink model generates time-varying i/o data during simulation.

    this command also loads the variables x, y and z into the matlab workspace. to learn more about this data, see about the data.

  2. add an adaptive lookup table block to the simulink model.

    1. open the simulink library browser.

      at the matlab prompt, enter sllibrarybrowser.

    2. open the simulink design optimization™ library.

      in the libraries pane, expand the simulink design optimization node.

    3. in the simulink design optimization library tree, click adaptive lookup tables.

    4. drag and drop the adaptive lookup table (nd stair-fit) block from the adaptive lookup tables library to the simulink model window.

  3. double-click the adaptive lookup table (nd stair-fit) block to open the function block parameters: adaptive lookup table (nd stair-fit) dialog box.

  4. in the function block parameters dialog box:

    1. specify the following block parameters:

      • table breakpoints (cell array) — enter {[x; 110], [y; 7200]} to specify the range of input breakpoints.

      • table data (initial) — enter rand(10,36) to specify random numbers as the initial table values for the volumetric efficiency.

      • table numbering data — enter reshape(1:360,10,36) to specify a numbering scheme for the table cells.

    2. verify that sample mean (with forgetting) is selected in the adaptation method drop-down list.

    3. enter 0.98 in the adaptation gain (0 to 1) field to specify the forgetting factor for the sample mean (with forgetting) adaptation algorithm.

      an adaptation gain close to 1 indicates high robustness of the lookup table values to input noise. to learn more about the adaptation gain, see in .

    4. select the make adapted table an output check box.

      this action adds a new port named tout to the adaptive lookup table block. you use this port to plot the table values as they are being adapted.

    5. select the add adaptation enable/disable/reset port check box.

      this action adds a new port named enable to the adaptive lookup table block. you use this port to enable or disable the adaptation process.

    6. select the add cell lock enable/disable port check box.

      this action adds a new port named lock to the adaptive lookup table block. you use this port to lock a cell during the adaptation process.

    7. verify that ignore is selected in the action for out-of-range drop-down list.

      this selection specifies that the software ignores any time-varying inputs outside the range of input breakpoints during adaptation.

      tip

      to learn more, see block reference page.

      after you configure the parameters, the block parameters dialog box looks like the following figure.

    8. click ok to close the function block parameters dialog box.

      the simulink model now looks similar to the following figure.

  5. assign the input and output data to the engine model by connecting the u and y ports of the experimental data block to the u and y ports of the adaptive lookup table block, respectively.

  6. design a logic using simulink blocks to enable or disable the adaptation process. connect the logic to the adaptive lookup table block, as shown in the following figure.

    this logic outputs an initial value of 1 which enables the adaptation process.

  7. design a logic to lock a cell during adaptation. connect the logic to the adaptive lookup table block, as shown in the following figure.

  8. in the simulink library browser, select the simulink > sinks library, and drag display blocks to the model window. connect the blocks, as shown in the following figure.

    during simulation, the display blocks show the following:

    • display block — shows the value of the current cell being adapted.

    • display1 block — shows the number of the current cell being adapted.

  9. write a matlab function to plot the lookup table values as they adapt during simulation.

    alternatively, type enginetable at the matlab prompt to open a preconfigured simulink model. the efficiency surface subsystem contains a function to plot the lookup table values, as shown in the next figure.

  10. connect a to workspace block to export the adapted table values:

    1. in the simulink library browser, select the simulink > sinks library, and drag the to workspace block to the model window.

      to learn more about this block, see the block reference page in the simulink documentation.

    2. double-click the to workspace block to open the sink block parameters dialog box, and type tout in the variable name field.

    3. click ok.

    4. connect the to workspace block to the adaptive lookup table output signal tout, as shown in the next figure.

you have now built the model for updating and viewing the adaptive lookup table values. you must now simulate the model to start the adaptation, as described in adapting the lookup table values using time-varying i/o data.

adapting the lookup table values using time-varying i/o data

in this portion of the tutorial, you learn how to update the lookup table values to adapt to the time-varying input and output values.

you must have already built the simulink model, as described building a model using adaptive lookup table blocks.

to perform the adaptation:

  1. in the simulink editor, specify the simulation time as inf.

    the simulation time of infinity specifies that the adaptation process continues as long as the input and output values of the engine change.

  2. in the simulink editor, click run under simulation to start the adaptation process.

    a figure window opens that shows the volumetric efficiency of the engine as a function of the intake manifold pressure and engine speed:

    • the left plot shows the measured volumetric efficiency as a function of intake manifold pressure and engine speed.

    • the right plot shows the volumetric efficiency as it adapts with the time-varying intake manifold pressure and engine speed.

    during simulation, the lookup table values displayed on the right plot adapt to the variations in the i/o data. the left and the right plots resemble each other after a few seconds, as shown in the next figure.

    tip

    during simulation, the cell number and adaptive table outputs blocks in the simulink model display the cell number, and the adapted lookup table value in the cell, respectively.

  3. pause the simulation by clicking pause under simulation.

    this action also exports the adapted table values tout to the matlab workspace.

    note

    after you pause the simulation, the adapted table values are stored in the adaptive lookup table block.

  4. examine that the left and the right plots match. this resemblance indicates that the table values have adapted to the time-varying i/o data.

  5. lock a table cell so that only one cell adapts. you may find this feature useful if a portion of the data is highly erratic or otherwise difficult for the algorithm to handle.

    1. click run under simulation to restart the simulation.

    2. double-click the lock block. this action toggles the switch and feeds the output of the on block to thelock input port of the adaptive lookup table(nd stair-fit) block.

      you can view the number of the locked cell in the cell number block in the simulink model.

  6. after the table values adapt to the time-varying i/o data, you can continue to use the adaptive lookup table block as a static lookup table:

    1. in the simulink model window, double-click the enable block. this action toggles the switch, and disables the adaptation.

    2. click run under simulation to restart the simulation, if it is not already running.

      during simulation, the adaptive lookup table block works like a static lookup table, and continues to estimate the output values as the input values change. you can see the current lookup table value in the adaptive table outputs block in the simulink model window.

    note

    after you disable the adaptation, the adaptive lookup table block does not update the stored table values, and the figure that displays the table values does not update.

see also

related topics

    网站地图