Generate Global Variables from Signals in Model
If you want to generate a global variable in your code, use a global Data Store
Memory block based on a Simulink.Signal
object in your
model.
Set up a data store in your model by using a Data Store Memory block.
Associate a
Simulink.Signal
object with the data store.In the base workspace, define a
Simulink.Signal
object with the same name as the data store. Set the storage class of the object toExportedGlobal
orImportedExtern
.Use the Model Data Editor to enable the Data store name must resolve to Simulink signal object parameter of the Data Store Memory block. To use the Model Data Editor in a model, on the Modeling tab, select Model Data Editor under the Design category. On the Data Stores tab, set the Change View drop-down to
Design
. Enable Resolve for the Data Store Memory block. For more information, see Model Data Editor.
To utilize Data Store Read and
Data Store Write
blocks, attach the signals in your model that you want to read from or write to the data store.
The Simulink.Signal
object that is associated with the
global Data Store Memory block appears as a global variable in generated
code.
Note
If you follow this workflow for Rockwell Automation RSLogix
5000 AOIs, the generated code uses INOUT
variables
for the global data.