PLC Coder settings: Generate reusable code

2 次查看(过去 30 天)
Hello,
I'm a bit confused regarding the PLC Coder settings, more specifically the "Generate reusable code" option in the Optimization tab.
From the documentation (https://se.mathworks.com/help/plccoder/ug/plc-coder-optimization.html): If the model contains multiple instances of the same subsystem and some instances have constant inputs, by default, the generated code contains separate function blocks for each instance.
However when testing the demo model plcdemo_simple_subsystem, and duplicating the subssytem (attached), I see no difference in the generated structured text when turning this setting on or off. From my understanding the structured text should contain two function blocks if this setting was turned off?
Does anybody have an example where the generated code differs based on this setting?
Thanks!

回答(1 个)

Infinite_king
Infinite_king 2024-5-6
编辑:Infinite_king 2024-5-6
Hi Sindre Møller,
In the Simulink model 'plcdemo_simple_subsystem_modified.slx', the subsystem's perform very basic operations. Simulink PLC Coder usually optimizes the output to increase efficiency. Hence, the subsystems are merged into one single function block by the PLC Coder even when the 'Generate Reusable Code' option is not selected.
To see the effect of the 'generate reusable code' option, choose any example with a complex subsystem, duplicate it, and generate the code. You can find examples here :- https://www.mathworks.com/help/plccoder/examples.html
Hope this is helpful.

类别

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

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by