Platform Independent Application Development
In order to develop applications for the Concept Car, Simulink models can be created and easily executed on the platform. This topic describes the whole process to get Simulink Models running on the Concept Car.
As the Simulink Model is a platform independent model, the first step to get the model running on the Concept Car is to generate the correspondent C code. However, the code generated by RTW is still an application code and it is not ready to run on the target platform (AT91SAM7A2 board). In order to get this generated code running on the platform some glue code is necessary. This glue code accesses the run-time environments provided by the platform software (basic software to access the hardware resources described in Section Platform Software and Run-Time Environment).
Normally this glue code is developed manually. However, this document adopts a Model Driven approach and to take advantage of this, in the Concept Car Project all glue code is automatically generated using Simulink Target tool . In this way, the user does not have to write any additional code.
In the following, the process to generate code from a Simulink Model is described. At this moment, it is considered that the model is ready to generate code. This section does not focus on the development of Simulink Models. A brief tutorial about Simulink, Real-Time Workshop (RTW) and how to develop models using those tools is presented in Chapter 4. Chapter 5 presents examples of Simulink Models.
Software Application Code Generation
This Section describes the parameters that must be set in order to generate code for the created Simulink model.
The following settings must be applied to the Simulink model when generating code from it with the Real-Time Workshop & Embedded Coder. Failure to apply these settings will complicate the subsequent process to integrate this code into the ARM7 runtime platform. Currently, only single-rate/single-tasking models are supported. Other models require a more complex handling of the model_step() function.
Top level model
- At the top level there must be a Simulink model, data exchange with the environment is only possible through inports and outports at top level. Code generation from a library is not possible.
These settings must be applied in the “Configuration Parameters” dialog of the model. Each Configuration Section is described in the following.
- The ode3 (Bogacki-Shampine) is used as fixed step type with 20ms sample time. This sample time is the interval for the generated code that calls model_step function.
- fixed-step size is specified, not auto.
- Hardware implementation (as showed in Figure 2.1):
- Device vendor is ARM Compatible
- Device type is ARM 7
- Native word size is 32 bits
- Byte ordering is Little Endian
- Emulation hardware has to be set to None
- The Real-Time Workshop section is divided in several tabs. The parameters that have to be set are (some of them are showed in Figure 2.2):
- Tab General
- System target file is ert.tlc (choose the first with no auto configuration)
- Language is C
- Compiler optimization level is Optimizations on (faster run)
- Generate makefile is Disabled
- Generate code only is Enabled
- Tab Interface
- Target function library: GNU99 (GNU)
- Floating point numbers is Enabled
- Non-finite numbers is Enabled (Used for e.g. integrator saturation)
- Continuous time is Enabled
- GRT compatible call interface is Disabled
- Single output/update is Enabled
- Interface is None
- Tab Templates:
- Generate an example main program is Disabled
- Tab General
- Interface (Figure 2.3):
- Target function library is GNU99 (GNU)
- Floating-point numbers are Enabled
- GRT compatible call interface are Disable
- Select single output/update function
- Interface is None
- Deselect Generate an example main program