Variable Attributes Explained in 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:
- The installation of Sysmac Studio software on your computer. The Sysmac Studio version 1.50 will be utilized in this tutorial; however other Sysmac Studio versions are also acceptable.
- Understanding of how to create a new project in Sysmac Studio.
- Understanding global and device variables in Sysmac Studio.
- Understanding axis and axes group variables in Sysmac Studio.
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.
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.
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.
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.
Input the starting values of the members. Then, press the OK button to finalize and set the initial values.
Step 3: AT Description. The AT field contents of the device variables listed in the I/O Map will be presented automatically.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
Step 9: Comment. The Comment field provides a space for users to enter descriptive explanations about the function and purpose of a 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.
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.
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.
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.
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.