Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
Variable Attributes Explained in Sysmac Studio
Intermediate

Variable Attributes Explained in Sysmac Studio

Omron
PLC Programming
Sysmac Studio

Introduction

When creating a variable in Omron Sysmac Studio, it's essential to be familiar with Variable Attributes. How so? Because it results in several benefits which become useful during programming.

Using variables with the correct attributes can help you to write more efficient code. It can reduce the risk of errors in your code and make it easier to debug your code. 

In addition, it can enhance the documentation of your code and help organize the program structure, and make it easier to read and understand. Also, it can result in better communication with external devices through the industrial network.

Prerequisites

What you will need to follow along with this tutorial:

System-Defined Variables

The system predefines system-defined variables with fixed attributes. It includes their names and special functions, which cannot be altered. Once the controller is registered on Sysmac Studio, you can utilize the system-defined variables. The names of system-defined variables begin with an underscore. Lists containing these variables can be accessed in the Ladder or ST editors for your selection.

Figure 1.1 - Sysmac Studio PLC Programming| Lists of system-defined variables in the Ladder and ST editors
Figure 1.1 - Sysmac Studio PLC Programming | Lists of system-defined variables in the Ladder and ST editors

Specifying Variable Attributes

Step 1: Name and Data Type. Here, you will learn the steps for assigning characteristics to variables. To begin, input a string as the name. Then, directly type a data type or choose one from the provided list.

Figure 2.1 - Sysmac Studio PLC Programming | Assigning a name and data type to a variable
Figure 2.1 - Sysmac Studio PLC Programming | Assigning a name and data type to a variable

Step 2: Initial Value. Provide a value for the variable under one of the following conditions if the Retain attribute is not defined:

  • When the power supply is activated
  • When the operating mode is modified
  • When you determine to initialize the value upon program transfer

You can manually input a value or choose from the list of available options (which vary according to the data type). If no initial value is entered, the default initial value of 0 will be used.

Figure 2.2 - Sysmac Studio PLC Programming | Assigning an initial value to a BOOL variable
Figure 2.2 - Sysmac Studio PLC Programming | Assigning an initial value to a BOOL variable

Input the starting values for the array variable's elements or the structure variable's members in the Initial Value Settings window. To access the Initial Value Settings window and view its contents, left-click the button within the initial value entry cell. You can see an instance of a two-dimensional structure array in Figure 2.3. The intersection of the [*,0] column and the [0,*] row displays the starting value of member Struct1[0,0] in this particular example.

Figure 2.3 - Sysmac Studio PLC Programming | Opening an initial value setting window for an array variable
Figure 2.3 - Sysmac Studio PLC Programming | Opening an initial value setting window for an array variable

Input the starting values of the members. Then, press the OK button to finalize and set the initial values.

Figure 2.4 - Sysmac Studio PLC Programming | Assigning an initial value to an element of an array variable
Figure 2.4 - Sysmac Studio PLC Programming | Assigning an initial value to an element of an array variable

Step 3: AT Description. The AT field contents of the device variables listed in the I/O Map will be presented automatically.

Figure 2.5 - Sysmac Studio PLC Programming | AT specification of a device variable
Figure 2.5 - Sysmac Studio PLC Programming | AT specification of a device variable

Now, examine the scenario when an AT address is designated for axes group or axis variables. If the Data Type input field contains either _sGROUP_REF or _sAXIS_REF, a button will be shown in the AT input area. By clicking this button, the AT Setting window will be displayed.

Figure 2.6 - Sysmac Studio PLC Programming | Opening the AT setting window
Figure 2.6 - Sysmac Studio PLC Programming | Opening the AT setting window

In the AT Setting window, choose a single variable from the list of axes groups or axis variables. Once you press the OK button, the AT specification for the axes group or axis variables will be established.

Figure 2.7 - Sysmac Studio PLC Programming | Assigning an AT address to an axis variable
Figure 2.7 - Sysmac Studio PLC Programming | Assigning an AT address to an axis variable

Step 4: Retain. Determine whether to preserve the value of the variable in the following scenarios:

  • After a power outage, when the power supply is restored and turned back ON
  • Upon switching to the RUN mode of operation
  • When the computer transfers programs to the controller for execution

If you want to preserve the values, put a checkmark in the box.

Figure 2.8 - Sysmac Studio PLC Programming | Preserving the values of a variable
Figure 2.8 - Sysmac Studio PLC Programming | Preserving the values of a variable

Step 5: Constant. By checking the Constant check box, you can specify the variable's initial value during downloading. However, any subsequent attempts to overwrite this value will not be permitted.

Figure 2.9 - Sysmac Studio PLC Programming | Specifying the variable’s initial value during downloading
Figure 2.9 - Sysmac Studio PLC Programming | Specifying the variable’s initial value during downloading

Step 6: Network Publish (Restricted to Global Variables). Choose the desired option for the Network Publish attribute from the drop-down menu. If you select the Do not publish option, the variable will not be accessible by external devices. Even so, the variable can still be accessible by the Support Software, irrespective of this setting.

Figure 2.10 - Sysmac Studio PLC Programming | Network publish attribute - Do not publish
Figure 2.10 - Sysmac Studio PLC Programming | Network publish attribute - Do not publish

When you select the Publish Only option for a variable, you can access it from external devices using CIP communications. However, note that once you apply this attribute to variables, you can’t rely on using the tag data links for these variables.

Figure 2.11 - Sysmac Studio PLC Programming | Network publish attribute - Do not publish
Figure 2.11 - Sysmac Studio PLC Programming | Network publish attribute - Do not publish

By selecting the Input option for a variable, you can access it from external devices through a tag data link or CIP communications. When using tag data links, the variable will be designated as a data input variable. It means data will be transferred from another controller to the local controller.

Figure 2.12 - Sysmac Studio PLC Programming | Network publish attribute - Input
Figure 2.12 - Sysmac Studio PLC Programming | Network publish attribute - Input

Once you select the Output option for a variable, it can be accessed from external devices via a tag data link or CIP communications. In the case of tag data links, this variable will be designated as a data output variable. It means data will be transferred from the local controller to another controller.

Figure 2.13 - Sysmac Studio PLC Programming | Network publish attribute - Output
Figure 2.13 - Sysmac Studio PLC Programming | Network publish attribute - Output

Step 7: In/Out (Restricted to Input/Output Variable Group). When using the input/output variable group in functions or function blocks, you need to specify the role of each variable. These variables can be either an input variable, an output variable, or an input-output variable.

Figure 2.14 - Sysmac Studio PLC Programming | In/Out attribute restricted to in/out variable group
Figure 2.14 - Sysmac Studio PLC Programming | In/Out attribute restricted to in/out variable group

Step 8: Edge (Restricted to Input/Output Variable Group). You can count on the Edge attribute to signal a function block with a TRUE value. When? Whenever a BOOL variable transitions from FALSE to TRUE or changes from TRUE to FALSE.

Figure 2.15 - Sysmac Studio PLC Programming | Edge attribute restricted to in/out variable group - Down function
Figure 2.15 - Sysmac Studio PLC Programming | Edge attribute restricted to in/out variable group - Down function

The attribute is exclusively applicable to input variables of function blocks. You are presented with a list of attribute settings to choose from. The available options for the Edge attribute setting are as follows:

  • No edge: No change in value will signal the function block with a TRUE value
  • Up: Transition from FALSE to TRUE will signal the function block with a TRUE value
  • Down: Transition from TRUE to FALSE sill signal the function block with a TRUE value
Figure 2.16 - Sysmac Studio PLC Programming | Available options for edge attribute restricted to in/out variable group
Figure 2.16 - Sysmac Studio PLC Programming | Available options for edge attribute restricted to in/out variable group

Step 9: Comment. The Comment field provides a space for users to enter descriptive explanations about the function and purpose of a variable.

Figure 2.17 - Sysmac Studio PLC Programming | Entering a comment for a created variable
Figure 2.17 - Sysmac Studio PLC Programming | Entering a comment for a created variable

Do the following procedure to enter comments for the members of a structure variable or the elements of an array variable. This way, you can access the Comment Settings window. Click on the button that displays the dialog box for Comment Settings in the comment entry cell. After entering the desired comments for the elements, click on the OK button. This way, you confirm and complete the process of entering commentaries.

Figure 2.18 - Sysmac Studio PLC Programming | Entering comments for elements of an array variable
Figure 2.18 - Sysmac Studio PLC Programming | Entering comments for elements of an array variable

Also, just by following a few simple steps, there is another way to access the Comment Settings Dialog Box. Firstly, you need to go to the variable table and locate the desired variable you want to work with. Now, you can right-click on the variable to open a pop-up menu, where you will find the Show Comment Setting Dialog option. You can access the Comment Settings window by left-clicking it and creating the comment for the selected variable. This feature can be practical for managing and organizing comments related to your variables and save you time and effort in the long run.

Figure 2.19 - Sysmac Studio PLC Programming | Accessing the comment settings dialog box through the shortcut menu
Figure 2.19 - Sysmac Studio PLC Programming | Accessing the comment settings dialog box through the shortcut menu

When working with array and structure variables, you can expand or collapse multiple levels of elements and members. To do so, right-click on the variable, element, or member and choose either Collapse All under the Selected Item or Expand All under the Selected Item.

Figure 2.20 - Sysmac Studio PLC Programming | Expanding multiple levels of elements of an array variable to enter comments
Figure 2.20 - Sysmac Studio PLC Programming | Expanding multiple levels of elements of an array variable to enter comments

You can go to the Tools menu in the top toolbar and select the Option to open the settings window. Then, you can activate the Use global variable comment check box in the Comments for Variables and Data Types section. This way, you can't modify the comments of the related variables listed as external variables in the local variable tables.

Figure 2.21 - Sysmac Studio PLC Programming | Using a global variable comment for an external variable in the local variable table
Figure 2.21 - Sysmac Studio PLC Programming | Using a global variable comment for an external variable in the local variable table

Conclusion

In conclusion, you learned how to define variables with appropriate attributes. It results in taking advantage of its benefits while you are programming.

You learned about system-defined variables that have fixed attributes. You understood how to assign a name and data type to a variable. You also understood the necessity of giving a variable an initial value sometimes.

You got familiar with AT specifications for device, axis, and axes group variables. You learned how to preserve the variable value using Retain. You understood how to specify the variable's initial value during downloading using Constant. Finally, you learned Network Publish and Edge attributes and their purposes in defining new variables.