31
7 Miscellaneous
7.1 Own Experiences
As a beginner working with TargetLink was easier than working with Real-Time
Workshop Embedded Coder. TargetLink has a well written user guide that gives
the first time users all the information needed to start code generation for any
model, whether with floating point or with fixed point. To generate code in RTW
EC, two user guides are needed if fixed-point is used which makes it hard for
beginners to start code generation. It takes time to know where the desired tools
are located in the RTW EC and sometimes it is not clear what steps the user
should take in order to give a certain result. For example the user has to make
changes in two different panes to make a variable defined as extern global
variable in the generated code. However it is not hard to handle once the user gets
used to the tool.
In TargetLink all the information needed to generate code is gathered in one place
which makes it easy for the user to handle the tool. TargetLink has also a very
useful tool for gathering all variables and signals in the model in one place, so
called Data Dictionary, which can be saved and accessed from any model built in
TargetLink.
RTW EC tools are very well integrated with the rest of the Simulink tools which
can be confusing for the user at first. But once the user can find his way around,
most desirable code settings can be achieved. The MathWorks recommends to use
an excel sheet to save variables for reuse.
One of the problems that were faced with Real-Time Workshop Embedded Coder
was to have a function call in the simulation that executes a different code when
connected to the hardware. This problem can be caused by quantization errors.
These errors should be considered when running with the target, but they are
irrelevant in the simulation since no quantization errors occur when the hardware
is not connected. To solve this problem, a different code is executed when
connected to the hardware, while in the simulation a simpler code is run instead.
The model tested in this work contained a block called Quantisation. This block
takes care of the problem described above. Two approaches were tested to solve
this. The first is the use of the so called Legacy Code in RTW EC. An S-Function
is used in the simulation which just gives an output that is equal to one of the
inputs, see Figure 9. Using Legacy Code tool the generated code can have a
certain function call instead of the S-function that is used when simulation is run.
This solution was not adopted in this work since it was not clear how it can be
used with reusable code. If the user chooses to generate the S-function for a
subsystem automatically then an extra option must be set manually in the S-
function in order to be able to use Legacy Code with reusable code. This was not
clear from the beginning so another approach was used in this work.
Commentaires sur ces manuels