Create Shared Variables Between NJ-R PLC and Omron Robot
Introduction
With the new NJ-R controller you can commission/program your PLC and Robot, along with other devices through one software package (Sysmac Studio). The advantage of using one software package is you can create share variables created in your PLC Project to the V+ Program created for the Omron Robot.
Procedure
Step1
First create all variables that needs to be shared between the PLC and Robot program in the Global Variables Section of the PLC Controller:
Step 2
Next declare the same position/location variables that have been created in the PLC Project, in the Robot Variables section.
Step 3
Finally to link the shared variables between the Programs, declare these created position/location variables with the EXTERNAL Keyword in the V+ Program. In addition to declaring the position/location type variables you can also add bool, integer, etc. These will all be shared between the PLC and Robot Programs.
After you have declared all shared variables you now need to initialize these variables so they have a default value.
An example of the Declaration and Initialization section can be seen highlighted in the above screenshot.
Example
-
In this example the PLC receives a 6 element array of long real positional values from a FH Vision system. The LREAL array variable (Fh_Location) in this example is assigned with simulated values.
- A new Real Array of 6 elements are created in the Robot Variable table.
- A new empty location vision_location variable was also created as a place holder.
- In addition to the shared fh_location array variable, robot_bool and plc_var boolean variable are created.
- The robot_bool variable is triggered via the PLC to start the Robot movement.
- The plc_var variable is a signal send to the PLC to indicate that the robot is running.
- Location variables are defined as follow: (X,Y,Z,Rx,Ry,Rz).
- vision_location which is used as a place holder. Gets transformed from being an empty location to assigning all 6 elements of fh_location array to each element of the location.
- This means that X = fh_location[0] , Y = fh_location[1] , Z = fh_location[2] , Rx = fh_location[3] , Ry = fh_location[4] , Rz = fh_location[5]
- As soon as the initialization section in the V+ program is executed, you will see the updated values for vision_location
V+ Sample code:
.PROGRAM program0() ;Declaration of shared variables EXTERNAL robot_bool, fh_location[] ;Initialize shared variables robot_bool = FALSE SET vision_location = TRANS(fh_location[0],fh_location[1],fh_location[2],fh_location[3], fh_location[4],fh_location[5]) plc_var = FALSE ATTACH () ;Attach a device (Robot) to the program WHILE TRUE DO ;Infinite loop IF robot_bool == TRUE THEN plc_var = TRUE MOVE home MOVE point1 MOVE vision_location MOVE point2 MOVE point3 END plc_var = FALSE END .ENDDelete