Omron PLC Training | Global and Device Variables Explained in Omron Sysmac Studio
In the NJ/NX/NY-series controller, it's possible to create variables. They can store the data required for the control algorithms to operate effectively.
In Omron Sysmac Studio software, Global and Device Variables are crucial concepts to understand. Why? Because they allow you to store and manipulate data in your program.
Global Variables are variables that are accessible from anywhere in your program. Therefore, they are practical for storing data that needs to be accessed by multiple functions or subroutines.
On the other hand, Device Variables are variables tied to specific devices or hardware components in your system. Therefore, they are used to store data that is specific to those devices.
What you will need to follow along with this tutorial:
- You need to have the Sysmac Studio software installed on your computer. Although the tutorial uses version 1.50, other versions of Sysmac Studio can also be utilized.
- You need to know how to create a new project in Sysmac Studio
One can generate global variables accessible from various POUs. POUs include programs, functions, and function blocks.
Global variables are registered for device variables that allow the access of slave and Unit data. It includes variables for devices such as EtherCAT slave and CJ-series unit.
Double-click on Global Variables in the Multiview Explorer under Programming - Data to open the global variable table. Or right-click Global Variables and select Edit from the pop-up menu.
To create a new entry in the global variable table, press the Insert key or right-click in the table environment and select "Create New" from the menu.
After entering values for each item in the global variable table, press the Enter key to register the variable. Always be sure to set the variable name and data type.
Imagine you want to edit the Data Type cell. After clearing its cell, pressing the Ctrl + Space keys or typing the first character of the data type will display a drop-down list.
To apply changes to a variable, make the necessary adjustments and press the Enter key. The variable will be updated accordingly.
If you want to delete a global variable only, click on the row header and press the Delete key. Or right-click on the row and select Delete from the menu.
But, if you want to delete a global variable along with any external variables that reference it, use the Ctrl + Shift + Delete keys. Or select Delete (including external variables) from the pop-up menu.
Entering invalid characters or values outside the acceptable range will result in the cell highlighted in red. Therefore, if an error is detected during program checks, it is likely due to these invalid entries.
You can filter the variable table and show only the variables that meet particular conditions.
To filter the variable table, right-click on the title row cell for the column you want to use and select Filtering. The example below pertains to the variable name column. In the Filtering Dialog Box, enter the text string and condition you wish to use for filtering and click the OK button.
When filtering is active, an icon will appear in the title row indicating so. This way, only the variables that satisfy the specified condition will be visible.
To remove the filter and display all variables again, right-click on the title row cell for the column you used to filter the variable list. Then select Clear Filtering - Selected Column or Clear Filtering - All.
If you want to restrict the displayed variables further, you can apply filters to multiple columns. Also, please note that filtering results will be lost when the global variable table is closed.
A device variable is employed to access data stored in a device, such as a slave or unit, via a port that serves as an interface to an external device. This logical port is referred to as an I/O port.
Device variables can be named manually, which is helpful when you desire to assign your name to a slave I/O terminal or a basic I/O unit. Begin by generating the slave or unit configuration information. Next, select an I/O port within the I/O Map and input a variable in the Variable column. If you want to specify a variable table for the variable type, ensure that you have defined the Variable Type beforehand.
Device variables are allocated to the I/O ports of each slave or unit automatically. They are also automatically enlisted in the variable table designated in the Variable Type column.
The names of the device variables are generated by combining the device names or other strings with the I/O port labels in an automatic manner.
Choose a slave, unit, or one or multiple I/O ports from the I/O Map. Then, right-click and select Create Device Variable or Create Device Variable with Prefix from the pop-up menu. Before creating the variable, you should determine its variable type.
If you select Create Device Variable with Prefix, you will be prompted to specify either Prefix, Suffix or None in the following dialog box.
Data can be copied from the I/O Map and pasted into a spreadsheet application such as Excel. Or vice versa, data edited in a spreadsheet can be copied and pasted into the I/O Map.
To set up the I/O Map, you can register the names of variables and corresponding comments for each port in a spreadsheet. Then paste the resulting data into the I/O Map.
Upon creating a device configuration using Sysmac Studio, the I/O Map is generated automatically. Right-click one of the available tabs to select Expand/Collapse All. It will reveal the ports associated with each device.
To copy the entire I/O Map, use the Ctrl + A keys to select it, followed by the Ctrl + C keys to copy the data.
Next, choose a cell located in the top-left corner of a spreadsheet and paste the contents.
When I/O Map data is pasted into a spreadsheet, it is categorized into four items. 1) Column header: The item corresponding to each column is displayed and doesn’t need editing. 2) Device information: It does not need editing. Additionally, variable information within the I/O Map is write-protected. 3) Port information: It does not require editing. This information comprises five data points, including position (always left blank), port name, port description, read/write attribute, and data type. 4) Variable information: You can edit it. It comprises three data points: variable, variable comment, and variable type.
Imagine you want to Copy all I/O map data with the column header from a spreadsheet and paste it into the I/O map. Remove the line containing device information that is located under the Column header. When copying data for multiple devices, please ensure that you do not delete the rows containing device information for the second and subsequent devices.
Document the variables and their corresponding comments in the spreadsheet.
To copy all the data in the spreadsheet, use the Ctrl + A keys to select everything and then use the Ctrl + C keys to copy the selected data.
After copying the data, please paste it into the I/O Map, making sure to specify the top port of the first device as the paste position. When pasting, note that all variables will be pasted as global variables.
Copying and pasting variable names and comments of ports with an array data type from a spreadsheet into the I/O Map may not be successful. It is because when copying all I/O Map data, including the Column header, data of array-type ports may inadvertently be included, leading to an error in the pasting process.
In conclusion, managing variables is crucial for effective industrial automation programming. Sysmac Studio provides efficient tools for this purpose. Global variables allow for creating variables that can be accessed across multiple POUs. On the other hand, device variables enable access to data stored in external devices through I/O ports. The global variable table and I/O Map provide a convenient way to create, edit, filter, and copy/paste variables and their data. Proper documentation in spreadsheets can also aid in organizing and managing variable information. By utilizing these tools effectively, programmers can streamline their workflows. This way, they can increase productivity in industrial automation.