PLC Coder settings: Generate reusable code

2 visualizzazioni (ultimi 30 giorni)
Sindre Møller
Sindre Møller il 14 Set 2021
Modificato: Infinite_king il 6 Mag 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!

Risposte (1)

Infinite_king
Infinite_king il 6 Mag 2024
Modificato: Infinite_king il 6 Mag 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.

Categorie

Scopri di più su Simulink PLC Coder in Help Center e File Exchange

Tag

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by