Using External Mode or Rapid Simulation Target
Introduction
If you are using the Simulink®
Coder™ external mode or rapid simulation (RSim) target, there are situations where
you can get unexpected errors when tuning block parameters. These errors can arise when you
specify the Best precision
scaling option for blocks that support
constant scaling for best precision.
The sections that follow provide further details about the errors you might encounter.
To avoid these errors, specify a scaling value instead of using the Best
precision
scaling option.
External Mode
If you change a parameter such that the binary point moves during an external mode
simulation or during graphical editing, and you reconnect to the target, a checksum error
occurs and you must rebuild the code. When you use Best Precision
scaling, the binary point is automatically placed based on the value of a parameter. Each
power of two roughly marks the boundary where a parameter value maps to a different binary
point. For example, a parameter value of 1–2 maps to a particular binary point position. If
you change the parameter to a value of 2–4, the binary point moves one place to the right,
while if you change the parameter to a value of 0.5–1, it moves one place to the
left.
For example, suppose that a block has a parameter value of -2
. You
then build the code and connect in external mode. While connected, you change the parameter
to -4
. If the simulation is stopped and then restarted, this parameter
change causes a binary point change. In external mode, the binary point is kept fixed. If
you keep the parameter value of -4
and disconnect from the target, then
when you reconnect, a checksum error occurs and you must rebuild the code.
Rapid Simulation Target
If a parameter change is great enough, and you are using the best precision mode for constant scaling, then you cannot use the RSim target.
If you change a block parameter by a sufficient amount (approximately a factor of two), the best precision mode changes the location of the binary point. Any change in the binary point location requires the code to be rebuilt because the model checksum is changed. This means that if best precision parameters are changed over a great enough range, you cannot use the rapid simulation target and a checksum error message occurs when you initialize the RSim executable.