Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop   

Tunable Workspace Parameter Data Type Considerations

If you are using tunable workspace parameters, you need to be aware of potential issues regarding data types. A workspace parameter is tunable when the following conditions exist:

When generating code for tunable workspace parameters, the Real-Time Workshop product checks and compares the data types used for a particular parameter in the workspace and in Block Parameter dialog boxes.

If...The Real-Time Workshop Product...
The data types matchUses that data type for the parameter in the generated code.
You do not explicitly specify a data type other than double in the workspaceUses the data type specified by the block in the generated code. If multiple blocks share a parameter, they must all specify the same data type. If the data type varies between blocks, the product generates an error similar to the following:
Variable 'K' is used in incompatible ways 
in the dialog fields of the following: 
cs_params/Gain, cs_params/Gain1. The 
variable'value is being used both directly
and after a transformation. Only one of 
these usages is permitted for any given 
variable.
You explicitly specify a data type other than double in the workspaceUses the data type from the workspace for the parameter. The block typecasts the parameter to the block specific data type before using it.

Guidelines for Specifying Data Types

The following table provides guidelines on specifying data types for tunable workspace parameters.

If You Want to...Then Specify Data Types in...
Minimize memory usage (int8 instead of single)The workspace explicitly
Avoid typecastingBlocks only
Interface to legacy or custom codeThe workspace explicitly
Use the same parameter for multiple blocks that specify different data typesThe workspace explicitly

The Real-Time Workshop product enforces limitations on the use of data types other than double in the workspace, as explained in Limitations on Specifying Data Types in the Workspace Explicitly.

Limitations on Specifying Data Types in the Workspace Explicitly

When you explicitly specify a data type other than double in the workspace, blocks typecast the parameter to the appropriate data type. This is an issue for blocks that use pointer access for their parameters. Blocks cannot use pointer access if they need to typecast the parameter before using it (because of a data type mismatch). Another case in which this occurs is for workspace variables with bias or fractional slope. Two possible solutions to these problems are

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS