How to connect an NA HMI to an NX/NJ PLC
Variable Mapping
Introduction
This guide will outline the steps required to connect an NA HMI screen to an NX or NJ PLC, using ethernet. This process uses a NX102 PLC, but can be applied to all NX and NJ units. This guide will refer to the PLC as an NX unit, for brevity. This guide will also assume that there is no program loaded into either NA or NX devices.
If a program is loaded into either device, the general process of the below guide still applies, excluding the program creation elements.
Procedure
Step 1 - Physical Connection
Connect the NA HMI and NX PLC using an ethernet cable. Ensure that the cable is connected to either Ethernet/IP port on the PLC, and NOT the EtherCAT port.
Step 2 - Program Creation
Open Sysmac Studio and create a new project, selecting the NX PLC as the device:
Once the project is open, add an NA HMI to it by selecting ‘Insert - HMI - NA5’ from the top menu. This will show the following selection window:
Select the appropriate model for your NA HMI and click ‘OK’.
Step 3 - Variable Creation
You can switch between the PLC and HMI in the project using the Multiview Explorer, located on the left of the window by default. Select the drop down menu as shown, and click on the desired device.
Use this method to select the NX PLC, which will be named ‘new_Controller_0’ by default. Navigate to the ladder program editor in the Multiview Explorer ('Programming - POUs - Programs - Program0 - Section0' by default).
In the ladder program, we will create a simple rung for demonstration, as below:
Note that in this rung, both the ‘Input_1’ and ‘Output_1’ variables have their names coloured in black, indicating that they are local variables. It is required that these variables be global variables for communication with the NA HMI.
To change these variables to global variables, click on the ‘Variables’ bar below the name of the program in the previous image, which will expand to show the following:
Right click on one of the variables, and select ‘Move to Global’, as shown below:
Repeat this for the second variable. Both variables will now have been moved to the ‘Externals’ tab of the expanded Variables bar, and can also be seen in the Multiview Explorer, under ‘Programming - Data - Global Variables’.
Our variables are now created and properly prepared for use on the PLC.
Step 4 - Variable Mapping
Switch devices to the NA HMI, and navigate using the Multiview Explorer to ‘Configurations and Setup - Variable Mapping’. You will see a window similar to the below image:
In this window, click the arrow icon next to the PLC name, and then the arrow next to the ‘User Variables’ option that appears. This will show you all of the user created global variables on the PLC, as shown below:
To use these variables on the HMI, we need to provide these PLC global variables with a local name on the HMI. This can be done manually, by entering a name into the ‘Variable’ column for the specific PLC global variables, or it can be done automatically by right clicking on a variable and selecting either ‘Create Device Variable’ or ‘Create Device Variable with Prefix’, as shown in the below image:
This automatic process can be performed for groups of variables. Select the desired variables using control or shift clicking before selecting the ‘Create Device Variable’ option. If it is required to perform this process for all of the PLC global variables, simply right click ‘User Variables’ and select the appropriate option.
Below is an example of the automatically created variables:
As can be seen, the automatically generated name is ‘<PLC Name> + <Variable Name>’.
The variables are now mapped to the HMI, and can be used in an HMI program.
Step 4 - Testing
Create a new page on the HMI (using 'HMI - Pages - Page0' by default on the Multiview Explorer. For demonstration, a simple page was created as shown below:
In the above image, the left toggle button has been assigned the variable ‘new_Controller_0_Input_1’, while the right lamp has been assigned the variable ‘new_Controller_0_Output_1’.
According to the logic in the PLC and HMI, if the left button is pressed, the ‘Input_1’ global variable on the PLC should become high, which will cause the ‘Output_1’ global variable to become high, which in turn will turn the right lamp on.
Once transferred to the PLC and HMI, the programs can be monitored to verify this, as shown in the below images:
Button off,
Button on,