In this tutorial, you learn how to:
Open the plcdemo_tunable_params
model and migrate the model to
use Simulink Data Dictionary (SLDD).
Generate code for the model.
Base workspace variable definition must match the variable definition in the SLDD file. If there is a mismatch, Simulink® PLC Coder™ displays an error during the code generation process.
If your model has a Data Store Memory(DSM) object, you must have a matching Simulink.Signal
object in the SLDD file.
Migrate the plcdemo_tunable_params
model base workspace variables to
an SLDD file for code generation:
Note
Copy the plcdemo_tunable_params
model to your current working
directory prior to starting the workflow.
Open the plcdemo_tunable_params
model .
From the Simulink Editor Modeling tab, click Model Explorer.
Under the Model Hierarchy pane, click Base Workspace . The Contents pane displays the base workspace variables.
Right-click K1
, K2
, and K3
.
Choose the Convert to parameter object
option to convert them
to the Simulink.Parameter
type.
Right-click plcdemo_tunable_params
, and then select
Properties
.
Select the External Data tab.
Click New. Enter the file name as
plcdemo_tunable_params
.
Click the Migrate data button. Then click
Apply in response to the Link Model to Data
Dictionary
message and Migrate in response to the
Migrate Data
message.
Click OK.
To open the dictionary, in the Simulink
Editor, click the model data badge in the bottom left corner, then click the
External Data link. To inspect the contents of the dictionary, in
the Model Explorer Model Hierarchy pane, under the
External Data node, expand the dictionary node.
To generate code for the model, see Generate and Examine Structured Text Code .