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 to
ExportedGlobal
or
ImportedExtern
.
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
Code
. Enable
Resolve for the Data Store
Memory block. For more information, see Configure Data Properties by Using the Model Data Editor (Simulink) .
In your model, attach the signals that you want to Data Store Read blocks that read from the data store and Data Store Write blocks that 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.
If you follow this workflow for Rockwell Automation RSLogix
5000 AOIs, the generated code uses INOUT
variables
for the global data.