Step Four – Create Adams Target for Code Generation
In order to generate the external system library from the MATLAB/Simulink model, you need to generate some special files for MATLAB/Code Generation. You will customize the makefile template and source code template for Adams based on the version of MATLAB your are using. Once this is done, you can use the customized template files for other Simulink models.
To create the Code Generation files for the Adams Controls model:
1. At the MATLAB prompt (>>), type setup_rtw_for_adams
This will automatically detect the version of Matlab you are using and create the makefile template and source code template for Adams. This function will also build template for specific versions of Matlab if desired by entering the desired version token as an argument: setup_rtw_for_adams('<version')) For help with this, enter setup_rtw_for_adams('h').
You should see the following message for success in this step:
%%% Successfully created files for Adams library export from MATLAB/RTW.
You should also confirm that in your working directory that .tlc and .tmf files were created by this step.
Alternatively, since the function setup_rtw_for_adams also uses process.py, you can still setup using the old method:
(Optional method if not using setup_rtw_for_adams function)
1. Set the MATLAB_ROOT environment variable to the MATLAB installation directory. For example:
■On Windows (DOS shell): set MATLAB_ROOT= C:\ Progra~1\MATLAB\R2016b\
■On Linux (c shell): setenv MATLAB_ROOT /usr/local/MATLAB/R2016b/
■On Linux (korn shell): export MATLAB_ROOT = /usr/local/MATLAB/R2016b/
■Change the directory paths to match your installation.
2. In the directory where your Adams model resides, issue the following command, where $adams_dir is the directory in which Adams is installed:
■On Linux:
adams2024_1 -c python ($adams_dir)/controls/utils/process.py -v 9.1 exit
■On Windows:
adams2024_1 python ($adams_dir)\controls\utils\process.py -v 9.1
Alternatively, you can copy the process.py file from the <adams_dir>/controls/utils/ directory on Linux or <adams_dir>\controls\utils\ on Windows to the current directory and issue the following command:
■On Linux:
adams2024_1 -c python process.py -v 9.1 exit
■On Windows:
adams2024_1 python process.py -v 9.1
The argument -v 9.1 stands for MATLAB 9.1 (R2016b).
This command customizes several files from the MATLAB installation for the Adams target and your computer setup. You should notice several new files in your working directory with a .tlc extension and two new files with a .tmf extension. These are files required by MATLAB’s Real Time Workshop in the steps that follow. For help with process.py, use the -h flag (that is, process.py -h).
Note: | The value for MATLAB_ROOT should have no quote, no spaces (on Windows, get short names with command dir /x), and a final slash on the path. |