Main Content

Fill Lookup Tables from Data

Setting Up a Lookup Table and Experimental Data

If you are considering a straightforward strategy, you might want to fill lookup tables directly from experimental data. For example, a simple torque strategy fills a lookup table with values of torque over a range of speed and relative air charge, or load. You can use CAGE to fill this strategy (which is a set of lookup tables) by referring to a set of experimental data. You can also fill lookup tables with the output of optimizations.

This tutorial takes you through the steps of calibrating a lookup table for torque, based on experimental data.

Start CAGE by typing

cage

First, set up a blank lookup table ready for filling using experimental data or optimization output.

  1. Add the variables for speed and load by importing a variable dictionary.

  2. Add a new table to your session.

  3. Import your experimental data.

Add Variables

Before you can add lookup tables to your session, you must add variables to associate with the normalizers or axes.

To add a variable dictionary,

  1. Select File > Import > Variable Dictionary.

  2. Select table_filling_tutorial.xml from the matlab\toolbox\mbc\mbctraining folder.

This loads a variable dictionary into your session. The variable dictionary includes:

  • N, the engine speed

  • L, the relative air charge

  • A, the air/fuel ratio (AFR)

  • stoich, the stoichiometric constant

You can now add a lookup table to your session.

Add a New Lookup Table

First, add a lookup table to fill.

  1. Select File > New > 2D Lookup Table.

    This opens a dialog box that asks you to specify the variable names for the normalizers. As you can see in the dialog box controls, accepting the defaults creates a lookup table with 10 rows and 10 columns with an initial value of 0 in each cell.

  2. Change the number of columns to 7.

  3. Select L as the variable for normalizer Y and N as the variable for normalizer X, then click OK.

CAGE takes you to the Lookup Tables view.

Cage browser with lookup table view. New_2D_Table selected.

CAGE has automatically initialized the normalizers by spacing the breakpoints evenly across the range of values for the engine speed (N) and load (L). The variable ranges are found in the variable dictionary. Switch to the Normalizer view to inspect the normalizers.

Expand the lookup table branch by t NNormalizer as shown.

This displays the two normalizers for the lookup table.

You have an empty lookup table with breakpoints over the ranges of the engine speed and load, which you can fill with values based on experimental data.

Import Experimental Data

To fill a lookup table with values based on experimental data, you must add the data to your session. If you want to fill a lookup table with the output of an optimization, the output appears automatically in the Data Sets view as a new data set called Exported_Optimization_Data when you select the Export to Data Set toolbar button. For this tutorial, you need some experimental data.

CAGE uses the Data Sets view to store grids of data. Thus, add a data set to your session.

Select File > New > Data Set to add a data set to your session. This changes the view to the Data Set view.

You can now import experimental data into the data set:

  1. Select File > Import > Data.

  2. In the file browser, select meas_tq_data.csv from the matlab\toolbox\mbc\mbctraining folder and click Open.

    This set of data includes six columns of data: the test cell settings for engine speed (RPM), and the measured values of torque (tqmeas), engine speed (nmeas), air/fuel ratio (afrmeas), spark angle (spkmeas), and load (loadmeas).

  3. This opens the Data Set Import Wizard. The first screen asks which of the columns of data you want to import. Click Next to import them all.

    The following screen asks you to associate variables in your project with data columns in the data.

  4. Highlight N in the Project Assignments column and nmeas in the Data Column, then click the assign button, shown.

  5. Repeat this to associate L with loadmeas. The dialog box should be the same as the following.

    Data set import wizard with L and loadmeas selected.

  6. Click Finish to close the dialog box.

You now have an empty lookup table and some experimental data in your session. You are ready to fill the lookup table with values based on this data.

Fill Lookup Table from Experimental Data

You have an empty lookup table and the experimental data in your session. You can now fill the lookup table with values based on your data.

The data that you have imported is a series of measured values of torque at a selection of different operating points. These operating points do not correspond to the values of the breakpoints that you have specified. The lookup table has a range of engine speed from 500 revolutions per minute (rpm) to 3500 rpm. The range of the experimental data is far greater.

CAGE extrapolates the values of the experimental data over the range of your lookup table. Then it fills the lookup table by selecting the torque values of the extrapolation at your breakpoints.

To fill the lookup table with values based on the experimental data,

  1. To view the Lookup Table Filler display, click in the toolbar in the Data Sets view; or select View > Lookup Table Filler.

    You can use this display to specify the lookup table you want to fill and the factor you want to use to fill it.

  2. In the lower pane, select New_2D_Table from the Lookup table to fill list.

  3. Select tqmeas from the Factor to fill lookup table list. This is the data that you want to use to fill the lookup table.

  4. Select N from the X-axis factor list and L from the Y-axis factor list. Your session should be similar to this.

    Filling table view of L versus N.

    The upper pane displays the breakpoints of your lookup table as crosses and the operating points where there is data as blue dots. Data sets display the points in the experimental data, not the values at the breakpoints. You can inspect the spread of the data compared to the breakpoints of your lookup table before you fill the lookup table.

  5. To view the lookup table after it is filled, ensure that the Show lookup table history after fill box, at the bottom left, is selected.

  6. To fill the lookup table with values of tqmeas extrapolated over the range of the normalizers, click Fill.

    The History dialog box opens.

    History dialog box with version and comment showing.

  7. Click Close to close the History dialog box and return to the Lookup Table Filler display.

  8. To view the graph of your lookup table, as shown, select Data > Plot > Surface.

    3D table of filling versus L and N.

This display shows the lookup table filled with the experimental points overlaid as purple dots.

The lookup table has been calibrated by extrapolating over the values of your data and filling the values that the data predicts at your breakpoints.

Notice that the range of the lookup table is smaller than the range of the data, as the lookup table only has a range from 500 rpm to 3500 rpm.

The data outside the range of the lookup table affects the values that the lookup table is filled with. You can exclude the points outside the range of the lookup table so that only points in the range that you are interested in affect the values in the lookup table.

Select Data Regions

You can ignore points in the data set when you fill your lookup table.

For example, in this tutorial the experimental data ranges over values that are not included in the lookup table. You want to ignore the values of engine speed that are greater than the range of the lookup table.

To ignore points in the data set,

  1. Select Data > Plot > Data Set. This returns you to the view of where the breakpoints lie in relation to the experimental data.

  2. To define the region that you want to include, left-click and drag the plot. Highlight all the points that are included in your lookup table range, as shown.

    Filling table view with L on vertical axis and N on horizontal axis.

  3. To fill the lookup table based on an extrapolation over these data points only, click Fill. This opens the History display again.

  4. In the History display, select version 2 and 3, using Ctrl+click. The following display shows a comparison between the lookup table filled with two different extrapolations.

    History dialog box with version and comment selected for version 3 and 2.

  5. Click Close to close the History viewer.

  6. Select Data > Plot > Surface to view the surface again.

The display of the surface now shows the lookup table filled only by reference to the data points that are included in the range of the lookup table.

You have filled a lookup table with values taken from experimental data.

Export the Calibration

To export the calibration:

  1. To highlight the lookup table that you want to export, click Lookup Tables.

  2. Highlight the New_2D_Table.

  3. Select File > Export > Calibration > Selected Item.

  4. Choose the type of file you want to save your calibrations as. For the purposes of this tutorial, select Comma Separated Value (.csv).

  5. Enter table_filling_tutorial.csv as the file name and click Save.

See Also

Topics