Main Content

PLC_RemoveSSStep for Distributed Code Generation

Generate structured text code for different components of your model.

Open model

Open the model by using the following command:

open_system('mSystemIntegration');

Configure Model Components for Distributed Code Generation

To autogenerate structured text code with the same ssMethod type for every component of your model for external code integration later on, use Keep Top-Level ssMethod Name the Same as the Non-Top Level Name. For more information, see Keep Top-Level ssmethod Name the Same as the Non-Top Level Name function.

Mark Externally Defined Variables

  1. Open the Simulink PLC Coder app. For more information, see Simulink PLC Coder.

  2. Select the TopSystem block.

  3. Click Settings. Navigate to PLC Code Generation > Identifiers. In the Identifier Names box enter Subsystem1,Subsystem2,Subsystem3.

  4. Click OK.

Code Generation

  1. Open the Simulink PLC Coder app. For more information, see Simulink PLC Coder.

  2. Select the Subsystem1 block.

  3. Click Settings. Navigate to PLC Code Generation > Identifiers. Select the Keep top level ssMethod name same as non-top level check box.

  4. Click OK.

  5. Repeat steps 2 through 4 for SubSystem2, SubSystem3, and TopSystem.

Generate Code for the Subsystem

To generate code for the individual subsystem use the plcgenerate code function:

plcgeneratecode('mSystemIntegration/TopSystem/SubSystem1');

plcgeneratecode('mSystemIntegration/TopSystem/SubSystem2');

plcgeneratecode('mSystemIntegration/TopSystem/SubSystem3');

Generate Code for the Integrated Model

To generate code for the integrated model:

plcgeneratecode('mSystemIntegration/TopSystem');

Related Topics