- The global variable is defined as a 'Simulink.Signal' in the PreLoadFcn callback of the model (File > Model Properties > Model Properties > Callbacks tab)
- In the Data Store Memory block's Signal Attributes tab, check the 'Data store name must resolve to Simulink signal object.'.
How do I define global variables using PLC Coder?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 5 Juil 2019
Modifié(e) : MathWorks Support Team
le 5 Sep 2024
How do I define global variables using PLC Coder?
Réponse acceptée
MathWorks Support Team
le 5 Sep 2024
Modifié(e) : MathWorks Support Team
le 5 Sep 2024
The supported way of defining global variables for PLC Coder is using Data Store Memory (DSM) blocks that resolve to Simulink.Signal objects. See below documentation page for more information:
>> web(fullfile(docroot, 'plccoder/define-global-variables.html'))
>> web(fullfile(docroot, 'plccoder/release-notes.html?rntext=&startrelease=R2014b&endrelease=R2019a&groupby=release&searchHighlight='))
To model externally defined output data, use DSM read/write block to access the data; to suppress the definition as VAR_GLOBAL, add the Simulink.Signal name to the "Externally defined symbols" list as follows: Simulation > Model Configuration Parameters > PLC Code Generation > Symbols pane > Externally Defined Symbols.
Attached is an example which illustrates this. Things to note:
Note that in contrast to Embedded Coder, PLC Coder does not support using signals that resolve to a Simulink.Signal object to define global variables.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simulink PLC Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!