PLC Coder settings: Generate reusable code

2 views (last 30 days)
Sindre Møller
Sindre Møller on 14 Sep 2021
Edited: Infinite_king on 6 May 2024
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!

Answers (1)

Infinite_king
Infinite_king on 6 May 2024
Edited: Infinite_king on 6 May 2024
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.

Categories

Find more on Simulink PLC Coder in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!