This enhancement has been incorporated in Release 2009b (R2009b). For previous product releases, read below for any possible workarounds:
There is a bug in the way Real-Time Workshop 6.0 (R14) generates code for Lookup Table blocks. The cast is inserted because the data type (int16) of the Simulink.Parameter object differs from the data type (i.e., double) of the block's first input signal. The generated code casts the parameter to match the data type of the input signal.
To work around this issue:
- You can change the data type of the parameter to match the data type of the input signal. This will remove the need for the parameter cast.
- You can insert a data type conversion block onto the input signal to cast the input signal to the same data type as the parameter. This will also remove the need for the parameter cast.
Another option to consider:
- You can remove the explicit data type specification for the parameter (make it a 'double' instead of 'int16'). This will result in the block treating the parameter as "context-sensitive", so it will cast the parameter to the desired data type off-line (before generating code) and there will be no run-time cast generated. It should be noted that if a context sensitive parameter is used by multiple blocks, all of the blocks must use the parameter with the same data type or an error will occur.
Best Answer