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 / 
Omron PLC Training | Global and Device Variables Explained in Omron Sysmac Studio
Beginner

Omron PLC Training | Global and Device Variables Explained in Omron Sysmac Studio

Omron
PLC Programming
Sysmac Studio

‍Introduction

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.

Prerequisites

What you will need to follow along with this tutorial:

Global Variables

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.

Figure 1.1 - Omron PLC Training | Global variables are accessible from various POUs
Figure 1.1 - Omron PLC Training | Global variables are accessible from various POUs

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.

Figure 1.2 - Omron PLC Training | How to open the global variables table
Figure 1.2 - Omron PLC Training | How to open the global variables table

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.

Figure 1.3 - Omron PLC Training | How to create a new global variable
Figure 1.3 - Omron PLC Training | How to create a new global variable

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.

Figure 1.4 - Omron PLC Training | How to apply changes to a global variable
Figure 1.4 - Omron PLC Training | How to apply changes to a global variable

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.

Figure 1.5 - Omron PLC Training | How to delete a global variable only
Figure 1.5 - Omron PLC Training | How to delete a global variable only

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.

Figure 1.6 - Omron PLC Training | How to delete a global variable along with any external variables that reference it
Figure 1.6 - Omron PLC Training | How to delete a global variable along with any external variables that reference it

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.

Figure 1.7 - Omron PLC Training | How to detect invalid data in the global variables table
Figure 1.7 - Omron PLC Training | How to detect invalid data in the global variables table

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.

Figure 1.8 - Omron PLC Training | How to apply the desired filter to the global variables table
Figure 1.8 - Omron PLC Training | How to apply the desired filter to the global variables table

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.

Figure 1.9 - Omron PLC Training | How to notice a filtered column in the global variables table
Figure 1.9 - Omron PLC Training | How to notice a filtered column in the global variables table

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.

Figure 1.10 - Omron PLC Training | How to remove the filter from the global variables table
Figure 1.10 - Omron PLC Training | How to remove the filter from the global variables table

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.

Device Variables

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.

Figure 2.1 - Omron PLC Training | How to register pre-defined device variables manually
Figure 2.1 - Omron PLC Training | How to register pre-defined device variables manually

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.

Figure 2.2 - Omron PLC Training | How to create new device variables manually
Figure 2.2 - Omron PLC Training | How to create new device variables manually

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.

Figure 2.3 - Omron PLC Training | How to create a new device variable automatically
Figure 2.3 - Omron PLC Training | How to create a new device variable automatically

If you select Create Device Variable with Prefix, you will be prompted to specify either Prefix, Suffix or None in the following dialog box.

Figure 2.4 - Omron PLC Training | How to register device variables with a prefix, a suffix, or none automatically
Figure 2.4 - Omron PLC Training | How to register device variables with a prefix, a suffix, or none automatically

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.

Figure 2.5 - Omron PLC Training | Copying and pasting variables between Excel and I/O Map
Figure 2.5 - Omron PLC Training | Copying and pasting variables between Excel and 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.

Figure 2.6 - Omron PLC Training | How to expand all available tabs in I/O Map
Figure 2.6 - Omron PLC Training | How to expand all available tabs in I/O Map

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.

Figure 2.7 - Omron PLC Training | How to select and copy the entire I/O Map
Figure 2.7 - Omron PLC Training | How to select and copy the entire I/O Map

Next, choose a cell located in the top-left corner of a spreadsheet and paste the contents.

Figure 2.8 - Omron PLC Training | How to paste copied I/O Map data into a spreadsheet
Figure 2.8 - Omron PLC Training | How to paste copied I/O Map data into a spreadsheet

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.

Figure 2.9 - Omron PLC Training | The configuration of pasted I/O Map data
Figure 2.9 - Omron PLC Training | The configuration of pasted I/O Map data

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.

Figure 2.10 - Omron PLC Training | How to remove the first device information line from a spreadsheet
Figure 2.10 - Omron PLC Training | How to remove the first device information line from a spreadsheet

Document the variables and their corresponding comments in the spreadsheet.

Figure 2.11 - Omron PLC Training | How to document the variables and their corresponding comments in a spreadsheet
Figure 2.11 - Omron PLC Training | How to document the variables and their corresponding comments in a 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.

Figure 2.12 - Omron PLC Training | How to select and copy the modified data from a spreadsheet
Figure 2.12 - Omron PLC Training | How to select and copy the modified data from a spreadsheet

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.

Figure 2.13 - Omron PLC Training | How to paste modified spreadsheet data into I/O Map
Figure 2.13 - Omron PLC Training | How to paste modified spreadsheet data into I/O Map

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.

Conclusion

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.

‍