Not able to export to standalone FMU the look up tables with tunable size

4 次查看(过去 30 天)
Hi all , I am trying to export some lookup tables from simulink to standalone FMU for co-simulation purpose. I am trying to use the "support tunable sizes" option in the look up table , so that we can change the size of the table in the future. I am using a variable to assign the tunable size to it. When I try to export to standalone FMU , the variables used for tunable size are not being exported. I have attached the screen shot of the FMU export window, warning and the lookup table .
Is there any other way to export tunable size lookup tables to FMU?

回答(2 个)

Aabha
Aabha 2025-6-10
Simulink FMU export supports tunable parameters, but in this case, it does not automatically export the size control variable SSPB_ActiveReg_len. The variable is treated more as an internal configuration for code generation or parameter tuning and is not exposed through the FMU interface unless explicitly specified.
To address this, you can make this parameter tunable in the FMU by creating it as aSimulink.Parameter object in the MATLAB base workspace. You will also need to set it’s StorageClass to ExportedGlobal.
Please refer to the following documentation links for more information about ‘Simulink Parameters’:
Additionally, here are a few links to other similar MATLAB Answer posts that might help in resolving the issue:
I hope this helps.
  1 个评论
Yasho Bharat
Yasho Bharat 2025-6-15
Hi @Aabha,
I tried the way you mentioned . It still doesn't export the variables used for tunable size. I still have the same issue. Ihave attached the pics for your reference. Let me know , if I have missed anything. Thanks for your reply.

请先登录,再进行评论。


Adarsh
Adarsh 2025-6-30
For the variable to be exported along with the FMU for the lookup tables along with “Support Tunable Size” option, the variable must be a tunable Simulink.Parameter object with its Storage class set to ExportedGlobal.
Also check the “Argument” checkbox corresponding to the Tunable Parameter in the “Model Workspace” section of the “Model Explorer.
The steps mentioned in the following documentation link can be followed to create a Tunable Parameter for the ‘Lookup Table’ and the fields can be populated as shown in the “Tunable Table Size in the Simulation and the Generated Code” section of the documentation link:
Also, the “Parameter ‘N1’ of <model/lookuptable> is non-tunable but refers to tunable variables” warning can be resolved by using a scalar integer value instead of Tunable parameter for the “Tunable Size” attribute in the Lookup Table block because as per documentation the “Tunable Size” attribute refers to the maximum size of the Lookup table if the table is defined to be “Tunable in size.
Hence, the “Tunable Size” value must be a scalar integer referring to the maximum size the Lookup Table can be, and the Tunable Parameters can be used for the “Table Data” and the “Breakpoints” attributes of the Lookup Table.
When the “Tunable Parameters” or data is referenced in the “Lookup Table” ‘s “Table Data” or “Breakpoints” section the parameters will be exported while generating FMU.
Also ensure that the “Tunable Parameters” Defined in the model are displayed in the “Parameters” tab while exporting to the Standalone FMU.
For more information the following documentation links can be referred:
  1. https://www.mathworks.com/help/simulink/slref/1dlookuptable.html
  2. https://www.mathworks.com/help/simulink/slref/1dlookuptable.html#f7-890882_sep_mw_a7e379c0-c70f-44d1-b2a2-37432f927f55
Hope this helps.
  3 个评论
Adarsh
Adarsh 2025-7-2
Hi @Yasho Bharat, I got your point but as per documentation "Tunable Table Size" does'nt imply a "Tunable Parameter" representing the current size of the table which you can modify, rather it means the maximum possible size a "Lookup Table" can be. Because when generating "C" code the memory allocated for the Array/Data Structure representing the "Lookup Table" is allocated based on "Tunable Table Size" which has the value for maximum table size possible in your case, so that once code is generated the required amount of memory is used and the remaining memory is ignored if the present size of "Lookup Table" is smaller than the value mentioned in "Tunable Size" attribute.
Hence, a Tunable Parameter cannot be given as input to the "Tunable Size" attribute. Rather in this can you can provide tunable parameters for breakpoints and "Table Data" and modify them from an external script such that at any point of time the size of the "Table Data" does not exceed the value mentioned in the "Tunable Size" attribute.
Adarsh
Adarsh 2025-7-2
The "Tunable Size" attribute itself cannot be set to a tunable parameter, it must be a fixed integer at code generation/export time.
This is due to how memory must be allocated at compile/export time for both code generation and FMU export.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by