PLC Coder: Identifiers

Identifiers Overview

Select the automatically generated identifier naming rules.

See Also

Generate Structured Text from the Model Window

Use Subsystem Instance Name as Function Block Instance Name

Specify how you want the software to name the Function block instances it generates for the subsystem. When you select this option, the software uses the subsystem instance name as the name of the Function blocks in the generated code. By default, the software generates index-based instance names.

This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: off

On

Uses the subsystem instance name as the name of the Function block instances in the generated code.

Off

Uses auto-generated index-based instance names for the Function blocks in the generated code.

Command-Line Information

Parameter: PLC_FBUseSubsystemInstanceName
Type: string
Value: 'on' | 'off'
Default: 'off'

See Also

Generate Structured Text from the Model Window

Override Target Default Maximum Identifier Length

If your custom target IDE version supports long name identifiers, you can use this option along with the Maximum identifier length to specify the maximum number of characters in the generated function, type definition, and variable names. By default, the software complies with the maximum identifier length of standard versions of the target IDE and ignores unsupported values specified in the Maximum identifier length.

This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: off

On

Override target default maximum identifier length in the generated code.

Off

The generated code uses the default identifier length of the target IDE.

Command-Line Information

Parameter: PLC_OverrideDefaultNameLength
Type: string
Value: 'on' | 'off'
Default: 'off'

See Also

Generate Structured Text from the Model Window

Maximum Identifier Length

Specify the maximum number of characters in generated function, type definition, and variable names. This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: 31

Minimum: 31

Maximum: 256

You can use this parameter to limit the number of characters in function, type definition, and variable names. Many target IDEs have their own restrictions for these names. Simulink® PLC Coder™ complies with target IDE limitations.

Command-Line Information

Parameter: PLC_RTWMaxIdLength
Type: int
Value: 31 to 256
Default: 31

See Also

Generate Structured Text from the Model Window

Override Target Default enum Name Behavior

Use this option to enable enum names to be used as the identifier names instead of enum values. The PLC target IDE must support enum type.

This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: off

On

Override target default enum behavior and always have enum names instead of enum values.

Off

The generated code uses the enum behavior of the target IDE.

Command-Line Information

Parameter: PLC_GenerateEnumSymbolicName
Type: string
Value: 'on' | 'off'
Default: 'off'

See Also

Generate Structured Text from the Model Window

Generate enum Cast Function

Autogenerate the enum type conversion code. The target PLC IDE must support enum type.

This option is available in the Configuration Parameters dialog box, PLC Code Generation > Identifiers pane .

Settings

Default: off

On

Simulink PLC Coder autogenerates the enum type conversion code.

Off

Manually create a MATLAB function to convert the enum type value to an integer or to convert an integer to an enum type value.

Command-Line Information

Parameter: PLC_GenerateEnumCastFunction
Type: string
Value: 'on' | 'off'
Default: 'off'

See Also

Generate Structured Text from the Model Window

Use the Same Reserved Names as Simulation Target

Specify whether to use the same reserved names as those specified in the Reserved names field of the Simulation Target pane in the Configuration Parameters dialog box. This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: off

On

Uses the same reserved names as those specified in the Reserved names filed of the Simulation Target pane in the Configuration Parameters dialog box.

Off

Does not use the same reserved names as those specified in the Simulation Target > Identifiers pane pane.

Command-Line Information

Parameter: PLC_RTWUseSimReservedNames
Type: string
Value: 'on' | 'off'
Default: 'off'

See Also

Generate Structured Text from the Model Window

Reserved Names

Enter the names of variables or functions in the generated code that you do not want to be used. This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: ( )

Changes the names of variables or functions in the generated code to avoid name conflicts with identifiers in custom code. Reserved names must be fewer than 256 characters in length.

Tips

  • Start each reserved name with a letter or an underscore.

  • Each reserved name must contain only letters, numbers, or underscores.

  • Separate the reserved names by using commas or spaces.

Command-Line Information

Parameter: PLC_RTWReservedNames
Type: string
Value: string
Default: ''

See Also

Generate Structured Text from the Model Window

Externally Defined Identifiers

Specify the names of identifiers for which you want to suppress definitions. This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Settings

Default: ( )

Suppresses the definition of identifiers, such as those for function blocks, variables, constants, and user types in the generated code. This suppression allows the generated code to refer to these identifiers. When you import the generated code into the PLC IDE, you must provide these definitions.

Tips

  • Start each name with a letter or an underscore.

  • Each name must contain only letters, numbers, or underscores.

  • Separate the names by using spaces or commas.

Command-Line Information

Parameter: PLC_ExternalDefinedNames
Type: string
Value: string
Default: ''

See Also

Preserve Alias Type Names for Data Types

Specify that the generated code must preserve alias data types from your model. This option is available on the PLC Code Generation > Identifiers pane in the Configuration Parameters dialog box.

Using the Simulink.AliasType class, you can create an alias for a built-in Simulink data type. If you assign an alias data type to signals and parameters in your model, when you use this option, the generated code uses your alias data type to define variables corresponding to the signals and parameters.

For instance, you can create an alias SAFEBOOL from the base data type boolean. If you assign the type SAFEBOOL to signals and parameters in your model, the variables in the generated code corresponding to those signals and parameters also have the type SAFEBOOL. Using this alias type SAFEBOOL, you can conform to PLCopen safety specifications that suggest using safe data types for differentiation between safety-relevant and standard signals.

Settings

Default: off

On

The generated code preserves alias data types from your model.

For your generated code to be successfully imported to your target IDE, the IDE must support your alias names.

Off

The generated code does not preserve alias types from your model. Instead, the base type of the Simulink.AliasType class determines the variable data type in generated code.

Tips

The alias that you define for a Simulink type must have the same semantic meaning as the base Simulink type. It must not be a data type already supported in Structured Text and semantically different from the base Simulink type. For instance, WORD is a data type supported in Structured Text but is semantically different from an integer type. If you define an alias WORD for a Simulink built-in integer type, for instance uint16, and preserve the alias name, the type WORD that appears in your generated code is used semantically as a WORD and not as an INT. The generated code has a different meaning from the semantics of the model.

Command-Line Information

Parameter: PLC_PreserveAliasType
Type: string
Value: 'on' | 'off'
Default: 'off'