Using the User Data Type in Local Variables for a Scan Program

Step Action
1 Open your project that contains the User Data Type.
2

Open the Local Variables file for the Scan Program.

3

In the blank line for adding a Local Variable, select the Variable Kind of your variable.

Variable kinds:

  • VAR: Non-constant local variable.

  • VAR_CONSTANT: This is a constant local variable.

  • VAR_EXTERNAL: This is a reference to a non-constant variable that is external to this Scan Program.

  • VAR_EXTERNAL_CONSTANT: This is a reference to a constant variable that is external to this Scan Program.

4

Give the local variable a name in the Variable column.

5

Select the User Data type for the variable in the Type column.

6

To setup initial values of the elements of the User Data Type, double-click on the space in the Initial Value column. A window will open to allow you to set initial values for the elements of the User Data Type.

Note: This step is optional.

7

Check the Retain box if the variable should store its value on power cycle of the PLC.

Note: This step is optional.

8

Add a Comment to provide a description of the variable.

9

Use your variable in your code. ‘variable_name.element_name’ is the method for using elements of the User Data Type.

 

 

 

LP305-3