
4
Other C- and h-files are generated for the model to specify a header-file, the base
types, e.g. Int32, and the data types, e.g. CONTINUOUS in the example code
above.
TargetLink also provides powerful simulation capabilities to analyse fixed-point
quantization and overflow effects which is done by choosing to simulate using the
generated code using Software In the Loop, SIL, simulation. The code can also be
run on the target directly using Process In the Loop, PIL, to validate the controller
designs directly on the target.
Real-Time Workshop Embedded Coder is a separate, additional product for use in
Matlab/Simulink environment. RTW EC generates code from Simulink and
Stateflow models. For fixed-point simulation and code generation an additional
tool is required, that is the Fixed-Point Toolbox. Code can be generated by a
simple click for both fixed-point and floating-point. To run the code directly on
the target some modifications are required to the Embedded Real-Time target files
provided by RTW EC.
RTW EC generates code directly from Simulink model and no conversion is
necessary.
#ifndef _TARGETLINK_TEST_C_
#define _TARGETLINK_TEST_C_
#include "tl_defines_a.h"
#include "TargetLink_test.h"
CONTINUOUS Sa1_InPort;
CONTINUOUS Sa1_OutPort;
Void TargetLink_test(Void)
{
/* SLLocal: Default storage class for local variables |
Width: 32 */
CONTINUOUS Sa1_Gain;
/* Gain: TargetLink_test/Gain */
Sa1_Gain = Sa1_InPort * 5.F;
/* Saturation: TargetLink_test/Saturation */
if (Sa1_Gain > 100.F) {
/* # combined # TargetLink outport:
TargetLink_test/OutPort */
Sa1_OutPort = 100.F;
}
else {
if (Sa1_Gain < 0.F) {
/* # combined # TargetLink outport:
TargetLink_test/OutPort */
Sa1_OutPort = 0.F;
}
else {
/* # combined # TargetLink outport:
TargetLink_test/OutPort */
Sa1_OutPort = Sa1_Gain;
}
}
}
#endif/*_TARGETLINK_TEST_C_ */
Commentaires sur ces manuels