Page 2
About Intellectual Property Right and Trademarks Microsoft product screen shots reprinted with permission from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the USA and other countries. EtherCAT is registered trademark and patented technology, licensed by Beckhoff Automation ®...
2.Terms and Definitions 2. Terms and Definitions Term Explanation and Definition IP address Ethernet uses an IP address to perform communications. The IP address (Internet Protocol address) is an address that is used to identify a node (host computer or controller, etc.) on Ethernet. IP addresses must be set and managed so that they do not overlap.
3.Remarks 3. Remarks (1) Understand the specifications of devices which are used in the system. Allow some margin for ratings and performance. Provide safety measures, such as installing safety circuit in order to ensure safety and minimize risks of abnormal occurrence. (2) To ensure system safety, always read and heed the information provided in all Safety Precautions, Precautions for Safe Use, and Precaution for Correct Use of manuals for each device used in the system.
Page 7
3.Remarks The following notation is used in this document. Indicates a potentially hazardous situation which, if not avoided, will result in minor or moderate injury, or may result in serious injury or death. Additionally there may be significant property damage. Indicates a potentially hazardous situation which, if not avoided, may result in minor or moderate injury or in property damage.
Ethernet. The user program in this Sysmac Studio project file is used to check the Ethernet connection by sending/receiving the message of “VR (Version information acquisition)” to/from the destination device.
5.Applicable Devices and Support Software 5. Applicable Devices and Support Software 5.1. Applicable Devices The applicable devices are as follows: Manufacturer Name Model Version NJ501-[][][][] OMRON NJ-series CPU Unit NJ301-[][][][] Versions listed OMRON Confocal Fiber Type ZW-C1[]/CE1[]CE1[]T in Section 5.2 or Displacement Sensor higher versions Controller...
To obtain the file, contact your OMRON representative. Precautions for Correct Use Update the Sysmac Studio to the version specified in this section or higher version using the auto update function. If a version not specified in this section is used, the procedures described in Section 7 and subsequent sections may not be applicable.
Page 11
The system configuration in this document uses USB for the connection between the personal computer and the Controller. For information on how to install the USB driver, refer to A-1 Driver Installation for Direct USB Cable Connection of the Sysmac Studio Version 1 Operation Manual (Cat.No. W504).
6.Ethernet Communications Settings 6. Ethernet Communications Settings This section describes the specifications of the communication parameters that are set in this document and outlines the operation. Additional Information To perform communications without using the settings described in this section, you need to modify the program.
6.Ethernet Communications Settings 6.2. Example of Checking Connection This document shows an example of a Structured Text (ST) program in which the Controller executes the connect processing, send/receive processing, and close processing on the Displacement Sensor. The Controller and Displacement Sensor send and receive the message of “VR (Version information acquisition).
7.3. Setting Up the Controller Set up the Controller. ↓ 7.3.1. Starting the Sysmac Studio and Start the Sysmac Studio and import the project file. Importing the Project File ↓ 7.3.2. Checking the Parameters and Check the set parameters, execute the program Building check on the project data and build the Controller.
7.Connection Procedure 7.2. Setting Up the Displacement Sensor Set up the Displacement Sensor. 7.2.1. Parameter Setting Set the parameters for the Displacement Sensor. Check the keys and display Main display(red) used to set parameters for the Displacement Sensor. Sub-display(green) Run indicator(green) Connect the Sensor Head.
Page 16
7.Connection Procedure The FUN mode screen is displayed. The RUN indicator is not lit as shown on the right. Press → (RIGHT) or ← (LEFT) Press the → (RIGHT) or ← (LEFT) Key. Key to change the main display content from SENS to SYSTEM. Press the ZERO/SET Key.
Page 17
7.Connection Procedure IPADDR is displayed on the main display. Press the ZERO/SET Key. Press the ZERO/SET Key once. IP1 is displayed on the main display. Press the ZERO/SET Key. Confirm that 192 is displayed on the sub-display. *If the setting value is different, change the value by referring to Press the ZERO/SET Key.
Page 18
7.Connection Procedure IP3 is displayed on the main display. Press the ZERO/SET Key. Confirm that 250 is displayed on the sub-display. *If the setting value is different, change the value by referring to Press the ZERO/SET Key once. steps 11 and 12. *In this step, you set 250 that is the third octet of IP address 192.168.250.2.
Page 19
7.Connection Procedure 000002 is displayed on the sub-display. Press the ZERO/SET Key. 2 is displayed on the sub-display. *In this step, you set 2 that is the Press the ZERO/SET Key once. fourth octet of IP address 192.168.250.2. Press ZERORST/ESC Key once.
Page 20
7.Connection Procedure Press the → (RIGHT) Key and change the main display content to SUB2, SUB3 and SUB4. Press the ZERO/SET Key to check the setting values. Check that the values between SUB2 and SUB4 are as follows: •SUB2, SUB3: 255 •SUB4: 0 *In steps 14 and 15, you set subnet mask 255.255.255.0.
Page 21
7.Connection Procedure The confirmation screen for mode switching is displayed. Press the ZERO/SET Key. Press the ZERO/SET Key once. The save confirmation screen is displayed. Press the ZERO/SET Key. Press the ZERO/SET Key once. The RUN mode screen is displayed. Cycle the power supply to the Displacement Sensor.
7.3. Setting Up the Controller Set up the Controller. 7.3.1. Starting the Sysmac Studio and Importing the Project File Start the Sysmac Studio and import the project file. Install the Sysmac Studio and USB driver beforehand. Confirm that the personal...
Page 23
7.Connection Procedure 7.3.2. Checking the Parameters and Building Check the set parameters, execute the program check on the project data and build the Controller. Double-click Built-in EtherNet/IP Port Settings under Configurations and Setup - Controller Setup in the Multiview Explorer. The Built-in EtherNet/IP Port Settings Tab Page is displayed in the Edit Pane.
Page 24
7.Connection Procedure The Build Tab Page is displayed in the Edit Pane. Confirm that “0 Errors” and “0 Warnings” are displayed. Select Rebuild Controller from the Project Menu. A screen is displayed indicating the conversion is being performed. Confirm that “0 Errors” and “0 Warnings”...
Page 25
7.3.3. Connecting Online and Transferring the Project Data Connect online with the Sysmac Studio and transfer the project data to the Controller. Always confirm safety at the destination node before you transfer a user program, configuration data, setup data, device variables, or values in memory used for CJ-series Units from the Sysmac Studio.
Page 26
7.Connection Procedure The Communications Setup Dialog Box is displayed. Select the Direct Connection via USB Option for Connection Type. Click the OK Button. Select Online from the Controller Menu. *Example of confirmation dialog box *If the dialog on the right is displayed, the model or version of the Controller does not match that of the project file.
Page 27
Additional Information For details on online connections to a Controller, refer to Section 5 Going Online with a Controller in the Sysmac Studio Version 1 Operation Manual (Cat. No. W504). When an online connection is established, a yellow bar is displayed on the top of the Edit Pane.
Page 28
Confirm that the data to transfer (NJ501 in the right figure) is selected. Then, click the Transfer to Controller Button. *After executing Transfer to Controller, the Sysmac Studio project data is transferred to the Controller and the data are compared. A confirmation dialog is displayed.
Page 29
If there is no problem, click the Close Button. *A message stating "The synchronization process successfully finished" means that the project data of Sysmac Studio matches that of the Controller. *If the synchronization fails, check the wiring and repeat the procedure described in this section.
Execute the program and confirm that Ethernet communications are normally performed. Sufficiently confirm safety before you change the values of variables on a Watch Tab Page when the Sysmac Studio is online with the CPU Unit. Incorrect operation may cause the devices that are connected to Output Units to operate regardless of the operating mode of the Controller.
Page 31
7.Connection Procedure Confirm that the variables shown on the right are displayed in the Start input Name Columns. Error codes *To add a variable, click Input Name… connection *Program0 of the Name is omitted from the following status descriptions. Program execution status Receive data Send data Click TRUE on the Modify Column of Input_Start.
Page 32
7.Connection Procedure When the communications end normally, each error code changes to 0. The TCP connection status (Output_EtnTcpSta) changes to _CLOSED. *In the case of error end, the error code corresponding to the error is stored. For details on error codes, refer to 9.7 Error Process.
8.1. Initializing the Controller To initialize the settings of the Controller, place the operating mode to PROGRAM mode, and select Clear All Memory from the Controller Menu of the Sysmac Studio. The Clear All Memory Dialog Box is displayed. Click the OK Button.
9.Program 9. Program This section describes the details on the program in the project file used in this document. 9.1. Overview This section explains the specifications and functions of the program used to check the connection between the Displacement Sensor (ZW series) (hereinafter referred to as the destination device) and the Controller (built-in EtherNet/IP port).
Page 35
9.Program 9.1.1. Communications Data Flow The following figure shows the data flow from when the Controller issues command data with TCP socket communications to the destination device until when the Controller receives the response data from the destination device. This program executes a series of processing from the connect processing to the close processing continuously.
Page 36
9.Program 9.1.2. TCP Socket Communications with Socket Service Instructions This section explains the TCP socket service function blocks and outlines the general operation of the send/receive messages. Additional Information For details, refer to Communications Instructions in Section 2 Instruction Descriptions of the NJ-series Instructions Reference Manual (Cat.
Page 37
9.Program ●Send/Receive messages Send message Destination Header Command data Terminator device Controller Receive message (Response) Header Response data Terminator Receive message (Error response) Header Response data (Error code) Terminator ●Communications sequence TCP communications are performed between the destination device (server) and Controller (client) in the following procedure.
9.Program 9.2. Destination Device Command This section explains the destination device command used in this program. 9.2.1. Overview of the Command This program uses “VR (Version information acquisition)” command to read the controller information of the destination device. Command Description Acquire version information.
Page 39
9.Program Number of Command Remarks bytes Header None Version information Product type ”ZW-C15” Blank Fixed: ” “ Version “Ver1.000” Blank Fixed: ” “ Release data “2012/02/09” Terminator Fixed: [CR](16#0D) (Default) ●Command format of the receive message (error) This is the response format of the error message received by the Controller from the destination device according to the setting of the “VR (Version information acquisition)”...
Page 40
9.Program 9.2.3. Command Settings This section explains the details on the "VR (Version information acquisition)” command settings. ●Send data (command) settings The send data is set in the SendMessageSet function block. Variable Contents (Data type) Set value Send_Header Send header (STRING[5]) ‘’(Setting unnecessary) Send_Addr Send address (STRING[5])
9.Program 9.3. Error Detection Processing This section explains the error detection processing of this program. 9.3.1. Error Detection in the Program This program detects and handles errors (1) to (4). For information on the error codes, refer to 9.7.1 Error Code List. Controller Destination device Ethernet cable...
Page 43
9.Program 9.3.2. Time Monitoring Function This section explains the time monitoring function of this program. You can change the monitoring time settings by using the variables of the ParameterSet function block. ●Time monitoring function of the communication instruction processing To avoid the status that keeps executing a communications process without stop due to abnormality, the timer in this program is used to abort the processing (timeout).
Page 44
9.Program ●Resend/time monitoring function of TCP/IP When a communication problem occurs, TCP/IP automatically resends the data and monitors the processing time if there is no error in the Controller. If processing ends in an error, this program performs the close processing and stops the TCP/IP resend/time monitoring function.
9.Program 9.4. Variables The table below lists the variables used in this program. 9.4.1. List of Variables The data types, external variables (user-defined global variables/system-defined variables), and internal variables used in this program are listed below. ●Data type (Structure) [Communications processing status flags] Name Data type Description...
Page 46
9.Program [Send/Receive processing required/not required setting flag] Name Data type Description Send/Receive processing required/not required setting sComType STRUCT flags Send processing TRUE: Required / FALSE: Not Send BOOL required *Specify this when sending a command. Receive processing TRUE: Required / FALSE: Not Recv BOOL required...
Page 47
9.Program ●External variables [User-defined global variables] Variable name Data type Description Communications start switch Input_Start BOOL The program starts when this flag changes from FALSE to TRUE. An area that stores the receive data (response) Output_RecvMess STRING[256] (256 bytes) An area that stores the error flag for a communications error or a timeout error that is detected at the connect Output_ErrCode WORD...
Page 48
9.Program ●Internal variables (instance variables) The internal variables used to execute the function blocks in the program are listed below. An internal variable is called an "instance". The name of each function block to use is specified as the data type of the variable. [Instances for user-defined function blocks] Variable name Data type...
Page 49
9.Program ●Internal variables Variable name Data type Description Communications processing status flags Local_Status sStatus This variable is defined as sStatus structure. Local_State DINT Processing number An area in which an error code is edited. Local_ErrCode uErrorFlgs This variable is defined as uErrorFlgs union. Socket service instruction execution flags Local_ExecFlgs sControl...
9.Program 9.5. ST Program 9.5.1. Functional Components of the Program This program is written in the ST language. The functional components are as follows: Major classification Minor classification Description 1. Communications 1.1. Starting the communications The communications processing processing processing starts.
Page 51
9.Program Major classification Minor classification Description 7. Processing 7. Processing number error process The error process is executed if a number error non-existent processing number is process detected.
Page 52
9.Program 9.5.2. Program List This section shows the program. The function blocks (ParameterSet, SendMessageSet, and ReceiveCheck) are used to perform the communications settings, send data (command data) setting and receive data (response data) check that must be changed according to the destination device. To change these values, refer to 9.5.3 Detailed Description of Function Blocks.
Page 60
9.Program 7. Processing number error process...
Page 61
9.Program 9.5.3. Detailed Description of Function Blocks The user-defined function blocks are shown below. The code which you need to edit according to the destination device is indicated by the red frames on the function blocks below. ●ParameterSet function block (General-purpose Ethernet communications parameter setting) Instruction Meaning...
Page 63
9.Program ●SendMessageSet function block (General-purpose Ethernet communications send data setting) Instruction Meaning ST expression General-purpose ETN_SendMessageSet_instance( Execute, Ethernet SendMessageSet Send_Data, communications ComType); send data setting [Internal variables] Name Data type Description Send_Header STRING[5] Send header: Header of the send message Send_Addr STRING[5] Destination device address: Address of the destination device...
Page 65
9.Program ●ReceiveCheck function block (General-purpose Ethernet communications receive processing) Instruction Meaning ST expression ETN_ReceiveCheck_instance( Execute, General-purpose Recv_Data, Recv_Buff, Ethernet ReceiveCheck Error, Communications ErrorID, receive processing ErrorIDEx); [Internal variables] None [Input/Output] Name Data type Description Execution flag: The function block is executed when this Execute Input BOOL...
9.Program 9.7. Error Process 9.7.1. Error Code List The error codes of this program are shown below. ●Error flag (Error end/timeout) [Output_ErrCode] If the connect processing, send processing, receive processing or close processing ends in error or times out, the error flag will be set in the Output_ErrCode variable. Error flag Description 16#0000...
Page 74
9.Program ●Error codes [Output_SktCmdsErrorID], [Output_SkTcloseErrorID] If an error occurs in the connect processing, send processing or receive processing, the error code is stored in the Output_SktCmdsErrorID variable and then the close processing is performed. If an error occurs in the close processing, the error code is stored in the Output_SkTcloseErrorID variable and the processing ends.
Page 75
9.Program ●TCP connection status error [Output_EtnTcpSta] If the TCP connection status does not enter the normal status (_CLOSED) in time after the close processing, a TCP connection status code is set in the Output_EtnTcpSta variable. Error code enumerator Description _eCONNECTION_STATE Connection closed.
Page 76
9.Program 9.7.2. TCP Connection Status Error and Corrective Action This section describes the status when a TCP connection status error occurs and explains the corrective action. ●Affects of a TCP connection status error After a TCP connection status error occurs, if this program is executed again without taking any corrective action or without notifying the error, then the destination node specified with the destination IP address (DstAdr) input variable and destination port (DstTcpPort) input variable may not be waiting for a connection.
Need help?
Do you have a question about the Omron NJ Series and is the answer not in the manual?
Questions and answers