• 沒有找到結果。

欧姆龙ZW-S20网络连接指南手册ZW-S20手册_广州菱控

N/A
N/A
Protected

Academic year: 2022

Share "欧姆龙ZW-S20网络连接指南手册ZW-S20手册_广州菱控"

Copied!
78
0
0

加載中.... (立即查看全文)

全文

(1)

Machine Automation Controller NJ-series

General-purpose Ethernet

Connection Guide (TCP/IP)

OMRON Corporation

ZW-series Displacement Sensor

(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 GmbH, Germany.

ODVA and EtherNet/IP™ are trademarks of ODVA

Company names and product names in this document are the trademarks or registered trademarks of their respective companies.

(3)

1. Related Manuals ... 1

2. Terms and Definitions ... 2

3. Remarks ... 3

4. Overview ... 5

5. Applicable Devices and Support Software... 6

5.1. Applicable Devices... 6

5.2. Device Configuration... 7

6. Ethernet Communications Settings... 9

6.1. Ethernet Communications Settings... 9

6.2. Example of Checking Connection ... 10

7. Connection Procedure ...11

7.1. Work Flow ...11

7.2. Setting Up the Displacement Sensor ... 12

7.3. Setting Up the Controller... 19

7.4. Checking the Ethernet Communications ... 27

8. Initialization Method... 30

8.1. Initializing the Controller... 30

8.2. Initializing the Displacement Sensor ... 30

9. Program... 31

9.1. Overview ... 31

9.2. Destination Device Command... 35

9.3. Error Detection Processing ... 39

9.4. Variables ... 42

9.5. ST Program... 47

9.6. Timing Charts... 64

9.7. Error Process ... 70

10. Revision History ... 74

(4)

1. Related Manuals

The table below lists the manuals related to this document.

To ensure system safety, make sure to 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 which is used in the system.

Cat.No. Model Manual name

W500 NJ501-[][][][]

NJ301-[][][][]

NJ-series CPU Unit Hardware User's Manual

W501 NJ501-[][][][]

NJ301-[][][][]

NJ-series CPU Unit Software User's Manual

W506 NJ501-[][][][]

NJ301-[][][][]

NJ-series CPU Unit Built-in EtherNet/IP Port User's Manual

W504 SYSMAC-SE2[][][] Sysmac Studio Version 1 Operation Manual W502 NJ501-[][][][]

NJ301-[][][][]

NJ-series Instructions Reference Manual

Z322 ZW-C1[] Confocal Fiber Type Displacement Sensor User's Manual Z332 ZW-CE1[] ZW Series Displacement Sensor (Confocal Fiber Type)

User's Manual

(5)

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.

Socket A socket is an interface that allows you to directly use TCP or UDP functions from the user program. The socket services enable data exchange with destination nodes. The NJ-series Machine Automation Controller performs socket communications by using the standard socket service instructions.

Connect processing/

Accept processing

Open processing is executed on each node to connect the TCP socket.

The open method depends on whether the node is opened as a server or client.

In this document, the processing executed to open a node as a client is called "connect processing" and the processing executed to open as a server is called "accept processing".

Keep-alive function When the keep-alive function is used with TCP/IP socket services, the keep-alive communications frame is used to check the status of the connection with the destination node (either a server or client) if there are no communications during the specified time interval.

Checks are executed at a certain interval, and if there is no response to any of them then the connection is terminated.

Linger function This is an option for the TCP socket that enables immediate connect processing using the same port number without waiting until the port number opens after RST data is sent when the TCP socket closes.

If the linger option is not specified, FIN data will be sent when a TCP socket is closed, and then approximately 1 minute will be required to confirm the transmission and perform other closing management with the destination node. Therefore, it may not be possible to immediately use TCP sockets with the same port number.

(6)

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.

(3) The user is encouraged to confirm the standards and regulations that the system must conform to.

(4) It is prohibited to copy, to reproduce, and to distribute a part of or whole part of this document without the permission of OMRON Corporation.

(5) The information contained in this document is current as of July 2013. It is subject to change without notice for improvement.

(7)

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.

Precautions for Safe Use

Precautions on what to do and what not to do to ensure safe usage of the product.

Precautions for Correct Use

Precautions on what to do and what not to do to ensure proper operation and performance.

Additional Information

Additional information to read as required.

This information is provided to increase understanding or make operation easier.

Symbol

(8)

4. Overview

This document describes the procedure for connecting OMRON Corporation’s Displacement Sensor (ZW series) (hereinafter referred to as the Displacement Sensor) to the NJ-series Machine Automation Controller (hereinafter referred to as the Controller) via Ethernet, and provides the procedure for checking their connection.

Refer to the Ethernet communications settings of the prepared Sysmac Studio project file to understand the setting procedure and key points to connect the devices via 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.

Prepare the latest Sysmac Studio project file beforehand. To obtain the file, contact your OMRON representative.

File name Version

Name

Sysmac Studio project file (extension: smc)

OMRON_ZW_ETN(TCP)_EV101.smc Ver.1.01

*Hereinafter, the Sysmac Studio project file is referred to as the “project file”.

The user program in the project file is referred to as the “program”.

This document aims to explain the wiring method and communications settings necessary to connect the corresponding devices and provide the setting procedure. The program used in this document is designed to check if the connection was properly established, and is not designed to be constantly used at a site. Therefore, functionality and performances are not sufficiently taken into consideration. When you construct an actual system, please use the wiring method, communications settings and setting procedure described in this document as a reference and design a new program according to your application needs.

(9)

5. Applicable Devices and Support Software

5.1. Applicable Devices

The applicable devices are as follows:

Manufacturer Name Model Version

NJ-series CPU Unit NJ501-[][][][]

NJ301-[][][][]

OMRON

Confocal Fiber Type Displacement Sensor Controller

ZW-C1[]/CE1[]CE1[]T OMRON

Sensor Head ZW-S[][]

Versions listed in Section 5.2 or higher versions OMRON

Additional Information

As applicable devices above, the devices listed in Section 5.2. are actually used in this document to check the connection. When using devices not listed in Section 5.2, check the connection by referring to the procedure in this document.

Additional Information

This document describes the procedure to establish the network connection. It does not provide information about operation, installation nor wiring method of each device.

For details on the above products (other than communication connection procedures), refer to the manuals for the corresponding products or contact your OMRON representative.

Additional Information

You can connect devices with the versions listed in Section 5.2 or higher versions.

For devices whose versions are not listed in Section 5.2, the versions are not managed or there is no version restriction.

To connect a device whose model number is not listed in Section 5.2, use the same version of the device that is listed.

(10)

5.2. Device Configuration

The hardware components to reproduce the connection procedure of this document are as follows:

Manufacturer

USB cable

LAN cable NJ501-1500

(Built-in EtherNet/IP port) Personal computer

(Sysmac Studio installed, OS: Windows 7)

Switching hub W4S1-05C

ZW-S20 ZW-C15

Name Model Version

OMRON NJ-series CPU Units (Built-in EtherNet/IP port)

NJ501-1500 Ver.1.03

OMRON Power Supply Unit NJ-PA3001

OMRON Switching Hub W4S1-05C Ver.1.0

OMRON Sysmac Studio SYSMAC-SE2[][][] Ver.1.04

OMRON Sysmac Studio project file OMRON_ZW_ETN(TCP)_

EV101.smc Ver.1.01

- Personal computer

(OS:Windows7) -

- USB cable

(USB 2.0 type B connector) -

- LAN cable (STP (shielded,

twisted-pair) cable of Ethernet category 5 or higher)

-

OMRON Displacement Sensor

Controller ZW-C15 Ver.1.000

OMRON Displacement Sensor

Sensor Head ZW-S20

OMRON Calibration ROM (Included with Sensor

Head.)

Precautions for Correct Use

Prepare the latest project file in advance.

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. In that case, use the equivalent procedures described in the Sysmac Studio Version 1 Operation Manual (Cat.No.

W504).

(11)

Additional Information

It may not be possible to reproduce the same operation with different devices or versions.

Check the configuration, model and version. If they are different from your configuration, contact your OMRON representative.

Additional Information

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).

(12)

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. For information on the program, refer to Section 9. Program.

6.1. Ethernet Communications Settings

The settings required for Ethernet communications are shown below.

6.1.1. Communications Settings between the Controller and the Displacement Sensor

The setting example below is used to explain the procedure for connecting the Controller to the Displacement Sensor.

Setting item Controller Displacement Sensor

IP address 192.168.250.1 192.168.250.2

Subnet mask 255.255.255.0 255.255.255.0 (Default)

Gateway ---.---.---.--- 192.168.0.1 (Default) Port number Automatic allocation

(Set by the program.)

9600 (Default)

Terminator - [CR] (Default)

*In this document, the gateway setting is unnecessary because the connection is made in the same segment.

*This project file uses the default settings of the keep-alive and linger option functions for the TCP socket communications (keep-alive: use, linger option: Do not use). Use these functions according to the system when necessary.

(13)

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). The following figure outlines the operation.

Controller (CPU Unit)

Built-in EtherNet/IP port Ethernet Displacement Sensor Project file

ST Program

IF …. THEN ……….

ELSE ……….

Local_SrcData Send data setting area

Connect processing

Close processing Receive data

Send data

Sending/Receiving Ethernet command

VR (Version information acquisition)

Executing Ethernet communications command

Socket communications

function

Local_RecvData Receive data

storage area

(14)

7. Connection Procedure

This section describes the procedure for connecting the Displacement Sensor to the Controller via Ethernet.

This document explains the procedures for setting up the Controller and Displacement Sensor from the factory default setting. For the initialization, refer to Section 8 Initialization Method.

7.1. Work Flow

Take the following steps to connect the Displacement Sensor to the Controller via Ethernet.

7.2. Setting Up the Displacement Sensor

Set up the Displacement Sensor.

7.2.1. Parameter Setting Set the parameters for 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.

7.3.2. Checking the Parameters and Building

Check the set parameters, execute the program check on the project data and build the Controller.

7.3.3. Connecting Online and Transferring the Project Data

Connect online with the Sysmac Studio and transfer the project data to the Controller.

7.4. Checking the Ethernet

Communications

Execute the program and confirm that Ethernet communications are normally performed.

7.4.1. Executing the Program and Checking the Receive Data

Execute the program and confirm that the correct data are written to the variables of the Controller.

(15)

7.2. Setting Up the Displacement Sensor

Set up the Displacement Sensor.

7.2.1. Parameter Setting

Set the parameters for the Displacement Sensor.

1

Check the keys and display used to set parameters for the Displacement Sensor.

Connect the Sensor Head.

Insert the Calibration ROM.

Connect the LAN cable.

Turn ON the power supply to the Displacement Sensor.

Main display(red) Sub-display(green)

ZERORST/EST key

Mode switching key

Calibration ROM Sensor Head

LAN cable

24V power supply Run indicator(green)

←(LEFT) key ↑(UP) key

→(RIGHT) key ↓(DOWN) key ZERO/SET key

2

After the startup screen is displayed, the RUN mode screen is displayed.

The RUN indicator is lit as shown on the right.

Hold down the Mode switching

Key for two seconds. Hold down the Mode switching Key for two seconds.

3

A confirmation screen for mode switching is displayed.

Press the ZERO/SET Key.

Press the ZERO/SET Key once.

(16)

4

The FUN mode screen is displayed.

The RUN indicator is not lit as shown on the right.

Press → (RIGHT) or ← (LEFT) Key to change the main display content from SENS to SYSTEM.

Press the ZERO/SET Key.

Press the → (RIGHT) or ← (LEFT) Key.

Press the ZERO/SET Key once.

5

SAVE is displayed on the main display.

Press → (RIGHT) or ← (LEFT) key to change the main display content from SAVE to COM.

Press the ZERO/SET Key.

Press the → (RIGHT) or ← (LEFT) Key.

Press the ZERO/SET Key once.

6

RS232C is displayed on the main display.

Press the → (RIGHT) Key and change the main display content from RS232C to ETN.

Press the ZERO/SET Key.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key once.

(17)

7

IPADDR is displayed on the main display.

Press the ZERO/SET Key.

Press the ZERO/SET Key once.

8

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 steps 11 and 12.

*In this step, you set 192 that is the first octet of IP address 192.168.250.2.

Press the ZERORST/ESC Key once. The first screen in this step is displayed again.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key.

Press the ZERORST/ESC Key.

IP1 is displayed.

Press the → (RIGHT) Key once.

9

IP2 is displayed on the main display.

Press the ZERO/SET Key.

Confirm that 168 is displayed on the sub-display.

*If the setting value is different, change the value by referring to steps 11 and 12.

*In this step, you set 168 that is the second octet of IP address 192.168.250.2.

Press the ZERORST/ESC Key once. The first screen in this step is displayed again.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key once.

Press the ZERORST/ESC Key once.

IP2 is displayed.

Press the → (RIGHT) Key once.

(18)

10

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 steps 11 and 12.

*In this step, you set 250 that is the third octet of IP address 192.168.250.2.

Press the ZERORST/ESC Key once. The first screen in this step is displayed again.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key once.

Press the ZERORST/ESC Key once.

IP3 is displayed.

Press the → (RIGHT) key once.

11

IP4 is displayed on the main display.

Press the ZERO/SET Key.

The default value is displayed on the sub-display.

Press the ZERO/SET Key.

The sub-display content changes, allowing you to change the value.

Select a digit whose value you want to change by pressing the

→ (RIGHT) or ← (LEFT) Key.

You can change the value of a blinking digit.

Change the value by pressing the ↑ (UP) or ↓ (DOWN) Key.

Change to 000002.

Press the ZERO/SET Key once.

Press the ZERO/SET Key once.

Press the → (RIGHT) or ← (LEFT) Key.

Press the ↑ (UP) or ↓ (DOWN) Key.

(19)

12

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 fourth octet of IP address 192.168.250.2.

Press ZERORST/ESC Key once. The first screen in step 11 is displayed again.

Press the ZERORST/ESC Key once.

Press the ZERO/SET Key once.

Press the ZERORST/ESC Key once.

IP4 is displayed.

Press the ZERORST/ESC Key once.

13

IPADDR is displayed on the main display.

Press the → (RIGHT) Key once to change the main display to SUBNET.

Press the ZERO/SET Key.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key once.

14

The main display content changes to SUB1.

Press the ZERO/SET Key.

255 is displayed on the sub-display.

Press the ZERORST/ESC Key once.

Press the ZERO/SET Key once.

Press the ZERORST/ESC Key once.

(20)

15

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.

After checking, press the ZERORST/ESC Key three times.

Press the ZERORST/ESC Key three times.

16

ETN is displayed on the main display.

Press the → (RIGHT) Key and change the main display content to DELIMI.

Press the ZERO/SET Key.

Press the → (RIGHT) Key once.

Press the ZERO/SET Key once.

17

Confirm that CR is displayed on the sub-display.

*If the value is different, change the value by pressing ↑ (UP) or

↓ (DOWN).

Hold down the Mode switching

Key for two seconds. Hold down the Mode switching Key for

two seconds.

Default: CR

<Setting range>

CR/LF/CRLF

(21)

18

The confirmation screen for mode switching is displayed.

Press the ZERO/SET Key.

The save confirmation screen is displayed.

Press the ZERO/SET Key.

The RUN mode screen is displayed.

Press the ZERO/SET Key once.

Press the ZERO/SET Key once.

19

Cycle the power supply to the Displacement Sensor.

*The new IP address and subnet mask will take effect after restarting.

(22)

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.

1

Confirm that the personal computer is connected to the Controller through a USB cable, and turn ON the power supply to the Controller.

Start the Sysmac Studio and click the Import Button.

*If a confirmation dialog for an access right is displayed at start, select to start.

2

The Import File Dialog Box is displayed. Select

OMRON_ZW_ETN(TCP)_EV10 1.smc and click the Open Button.

*Obtain the project file from OMRON.

3

OMRON_ZW_ETN(TCP)_V101 project is displayed.

The left pane is called Multiview Explorer, the right pane is called Toolbox and the middle pane is called Edit Pane.

*If an error message is displayed stating “Failed to Load Descendants”, change the version of the Sysmac Studio to any version specified in 5.2.

Device Configuration or higher version.

Edit Pane Toolbox

Multiview Explorer

(23)

7.3.2. Checking the Parameters and Building

Check the set parameters, execute the program check on the project data and build the Controller.

1

Double-click Built-in EtherNet/IP Port Settings under Configurations and Setup - Controller Setup in the Multiview Explorer.

2

The Built-in EtherNet/IP Port Settings Tab Page is displayed in the Edit Pane.

Select the TCP/IP Settings Button, select the Fixed setting Option in the IP Address Field, and make the following settings.

•IP address: 192.168.250.1

•Subnet mask: 255.255.255.0

•Default gateway:

_._._._ (blank)

3

Double-click the Task Settings under Configurations and Setup in the Multiview Explorer

4

The Task Settings Tab Page is displayed in the Edit Pane.

Click the Program Assignment Settings Button and confirm that Program0 is set under PrimaryTask.

5

Select Check All Programs from the Project Menu.

(24)

6

The Build Tab Page is displayed in the Edit Pane.

Confirm that “0 Errors” and “0 Warnings” are displayed.

7

Select Rebuild Controller from the Project Menu.

A screen is displayed indicating the conversion is being

performed.

8

Confirm that “0 Errors” and “0 Warnings” are displayed in the Build Tab 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.

The devices or machines may perform unexpected operation regardless of the operating mode of the CPU Unit.

1

Select Change Device from the Controller Menu.

2

The Change Device Dialog Box is displayed.

Confirm that the Device and Version are set as shown on the right and click the OK Button.

*If the settings are different, change the values from the pull-down list.

3

If settings are changed in step 2, the Build Dialog Box is

displayed. Click the Yes Button.

*This dialog box is not displayed if no change is made.

4

Select Communications Setup from the Controller Menu.

(26)

5

The Communications Setup Dialog Box is displayed.

Select the Direct Connection via USB Option for Connection Type.

Click the OK Button.

6

Select Online from the Controller Menu.

*If the dialog on the right is displayed, the model or version of the Controller does not match that of the project file.

Check the settings of the project file, return to step 1 and try again.

Click the OK Button to close the dialog box.

*The model and version displayed on the confirmation dialog box differ depending on the Controller used and the device setting of the project file.

*Example of confirmation dialog box

(27)

7

A confirmation dialog is

displayed. Click the Yes Button.

*The displayed dialog differs depending on the status of the Controller used. Select the Yes Button to proceed with the processing.

*The displayed serial ID differs depending on the device.

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).

8

When an online connection is established, a yellow bar is displayed on the top of the Edit Pane.

9

Select Synchronization from the Controller Menu.

(28)

10

The Synchronization Dialog Box is displayed.

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.

11

A confirmation dialog is

displayed. Click the Yes Button.

A screen stating "Synchronizing"

is displayed.

A confirmation dialog box is displayed. Click the Yes Button.

(29)

12

Confirm that the synchronized data is displayed with the color specified by “Synchronized” and that a message is displayed stating "The synchronization process successfully finished".

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.

(30)

7.4. Checking the Ethernet Communications

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.

Precautions for Correct Use

Please confirm that the LAN cable is connected before proceeding to the following steps.

If it is not connected, turn OFF the power to the devices, and then connect the LAN cable.

7.4.1. Executing the Program and Checking the Receive Data

Execute the program and confirm that the correct data are written to the variables of the Controller.

1

Confirm that RUN mode is displayed on the Controller Status Pane of the Sysmac Studio.

If PROGRAM mode is shown, select Mode - RUN Mode from the Controller Menu.

A confirmation dialog box is displayed. Click the Yes Button.

2

Select Watch Tab Page from the View Menu.

3

The Watch Tab Page 1 is displayed in the lower section of the Edit Pane.

(31)

4

Confirm that the variables shown on the right are displayed in the Name Columns.

*To add a variable, click Input Name…

*Program0 of the Name is omitted from the following descriptions.

Program execution status Receive data Send data

5

Click TRUE on the Modify Column of Input_Start.

The Online value of Input_Start changes to True.

The program is operated and Ethernet communications are performed with the destination device.

Start input Error codes

TCP connection status

(32)

6

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.

The online value of Local_Status.Done, which indicates the execution status of the program, changes to True. In the case of error end,

Local_Status.Error changes to True.

*When Input_Start changes to FALSE, each Local_Status variable also changes to False.

For details, refer to 9.6 Timing Charts.

7

The response data received from the destination device is stored in Output_RecvMess.

(ETN_SendMessageSet_instanc e.Send_Data is the send

command.)

Specify an area where you want to reference in the Watch Tab Page1 as shown in the right figure.

*The response data differs depending on the device used.

*Refer to 9.2. Destination Device Command for details on the command.

Receive data

•Version information Product type: ZW-C15 Blank: (2 characters) Version: Ver1.000 Blank: (1 character) Release date: 2012/02/09

•Terminator: “$R”([CR])

(33)

8. Initialization Method

This document explains the setting procedure from the factory default setting.

Some settings may not be applicable as described in this document unless you use the devices with the factory default setting.

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.

8.2. Initializing the Displacement Sensor

For the initialization of the Displacement Sensor, refer to Initializing Settings in Setting the System in Chapter 3 SETTINGS FOR FUNCTIONS of the Confocal Fiber Type Displacement Sensor User's Manual (Cat. No. Z322).

(34)

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).

This program uses the socket service functions of the Controller to send and receive the “VR (read version information)” command to/from the destination device and to detect a normal end or an error end.

A normal end of this program means a normal end of the TCP socket communications.

An error end means an error end of the TCP socket communications and an error end of the destination device (detected with the response data from the destination device).

In this section, the prefix “10#" (possible to omit) is added to decimal data and the prefix "16#"

to hexadecimal data when it is necessary to distinguish between decimal and hexadecimal data. (e.g., “1000” or “10#1000” for decimal data and “16#03E8” for hexadecimal data, etc.) Also, to specify a specific data type, the prefix “<data type>#” is added. (e.g.,

“WORD#16#03E8”)

Additional Information

OMRON has confirmed that normal communications can be performed using this program under the OMRON evaluation conditions including the test system configuration, version of each product, and product Lot, No. of each device which was used for evaluation.

OMRON does not guarantee the normal operation under the disturbance such as electrical noise or the performance variation of the device.

(35)

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. The receive processing is repeated when the response data is divided and multiple receive data arrive.

1. Connect processing The Controller issues a TCP socket connect request to the destination device, and establishes a TCP connection.

2. Sending a command The Controller issues a send message (command data), which is set in the program, to the destination device.

3. Receiving a response The Controller receives the receive message (response data) from the destination device and stores it in the specified internal variable (storage area).

4. Close processing The Controller issues a close request to the destination device, and terminates the TCP connection.

*Depending on a destination device and a command, the response data may not be sent after receiving command data or the response data may not be sent immediately after a connection is established. With this program, the Send/Receive processing required/not required setting can be set for the General-purpose Ethernet communications send data setting function block.

If Send only is set, the response data receive processing is not performed. If Receive only is set, the command data send processing is not performed.

(36)

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. No. W502).

●Socket Service Instructions

This program uses the following 5 standard instructions to perform socket communications.

Function blocks Description

Name Connect TCP Socket

SktTCPConnect Connects the TCP port of the destination device.

TCP Socket Send

SktTCPSend Sends data from the specified TCP socket.

TCP Socket Receive

SktTCPRcv Reads the data from the receive buffer for the specified TCP socket.

Close TCP Socket

SktClose Closes the specified TCP socket.

Read TCP Socket Status

SktGetTCPStatus Reads the status of the specified TCP socket.

The program uses this instruction for the following 2 types of processing.

(1) Processing to check the arrival of divided packets

(2) Processing to check the close status at the close processing

*The socket obtained by the Connect TCP socket instruction (SktTCPConnect) is used as an input parameter for another socket service instruction. The data type of Socket is structure _sSOCKET. The specifications are as follows:

Variable Meaning Description Data type Valid range Default

Socket Socket Socket _sSOCKET - -

Handle Handle Handle for data

communications UDINT Depends on

data type - SrcAdr Local

address Local address *1 _sSOCKET_ADD

RESS - -

PortNo Port number

Port number UINT 1 to 65535

IpAdr IP address IP address or host name

*2

STRING Depends on

data type DstAdr Destination

address

Destination address *1 _sSOCKET_ADD RESS

- - PortNo Port

number Port number UINT 1 to 65535

IpAdr IP address IP address or host name

*2 STRING Depends on

data type

*1: The address indicates an IP address and a port number.

*2: A DNS or Hosts setting is required to use a host name.

(37)

●Send/Receive messages

Send message Controller

Destination device

** **

Command data

** ** **

Terminator

** ** ** ** ** **

Receive message

(Response) ** **

Response data

** ** **

Terminator

** ** ** ** ** **

Receive message

(Error response) ** **

Response data (Error code)

** ** **

Terminator

** ** ** ** **

Header

Header

Header

●Communications sequence

TCP communications are performed between the destination device (server) and Controller (client) in the following procedure.

Controller (Client)

Destination device (Server)

Passive open

Connection establishmed

Data receive request

Data send request

Next data send request

Close Close processing

Data receive processing

Next data send processing Data send processing

Connection established

Active open Connection requested

Send data Acknowledgement (ACK)

Send data Acknowledgement (ACK)

Close requested

(38)

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

VR Acquire version information.

Additional Information

For details on the destination device command and message format, refer to Command format in Chapter 5 Ethernet/RS-232C COMMUNICATION of the Confocal Fiber Type Displacement Sensor User's Manual (Cat. No. Z322).

9.2.2. Detailed Description of the Command

This section explains the “VR (Version information acquisition)” command.

●Command format of the send message

This is the command format of the message that is sent by the Controller to the destination device according to the setting of the “VR (Version information acquisition)” command.

•ASCII codes are sent except for the terminator.

Data name Number

of bytes Remarks

Header - None

Command 2 Fixed: ”VR”

Terminator 1 Fixed: [CR](16#0D) (Default)

●Command format of the receive message (normal)

This is the response format of the normal message received by the Controller from the destination device according to the setting of the “VR (Version information acquisition)”

command.

•ASCII codes are received except for the terminator.

•The version information differs depending on the Displacement Sensor used.

(39)

●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)”

command.

•ASCII codes are received except for the terminator.

Number of

bytes Remarks

Command

Header - None

Version

information - -

Product type 6 ”ZW-C15”

Blank 2 Fixed: ” “

Version 8 “Ver1.000”

Blank 1 Fixed: ” “

Release data 10 “2012/02/09”

Terminator 1 Fixed: [CR](16#0D) (Default)

Command Number

of bytes Remarks

Error code 2 Fixed: ”ER”(16#4552) Terminator 1 Fixed: [CR](16#0D) (Default)

(40)

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]) ‘’(Setting unnecessary) Send_Command Send data (STRING[256]) ‘VR’

Send_Check Addition of send check (STRING[5]) ‘’(Setting unnecessary) Send_Terminate Send terminator (STRING[5]) ‘$R’ ([CR]: 16#0D)

Variable Contents

(Data type) Data Description

Send_Data Send message (STRING[256])

CONCAT(Send_Header, Send_Addr, Send_Command, Send_Check, Send_Terminate)

Used as send data of SktTCPSend instruction.

●Receive data (response) that is stored

After a data check is performed on the receive data using the ReceiveCheck function block, the receive data is stored in the receive data storage area.

Variable Description (data type) Storage area Recv_Buff Receive data (STRING[256]) Receive buffer

Recv_Data Receive data (STRING[256]) Receive data storage area (stores the receive buffer data)

●Send/Receive messages

*Send message

56 52 0D V R [CR]

Command Terminator

*Receive message (at normal process)

5A 57 2D 43 31 35 20 20 Z W - C 1 5 [SP] [SP]

Product type Blank Blank

56 65 72 31 2E 30 30 30 20

V e r 1 . 0 0 0 [SP]

Version Blank

32 30 31 32 2F 30 32 2F 30 39 0D

2 0 1 2 / 0 2 / 0 9 [CR]

Release data Terminator

(41)

*Receive message (at error process)

45 52 0D

E R [CR]

Error code Terminator

(42)

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.

Ethernet cable

Destination device

(1) (2) (3)

Controller

Monitoring time (4)

(1)Communications errors in TCP socket communications using socket service instructions Errors occurred in the program during TCP socket communications such as a command format error and a parameter error are detected as communications errors. An error is detected with the socket service instruction argument ErrorID.

(2)Timeout errors during communication with the destination device

When the connect processing, send processing, receive processing, or close processing is not normally performed and cannot be completed within the monitoring time, it is detected as a timeout error. An error is detected with the timer in the program. For information on the time monitoring function of the timer in the program, refer to 9.3.2. Time Monitoring Function.

(3)Errors in the destination device (Destination device error)

The destination device errors include a command error, a parameter error, and an execution failure in the destination device. An error is detected with “ER” (16#4552) which is returned from the destination device when an error occurs.

(4)TCP connection status error that occurs when ending the processing

This program always performs the close processing at the end of the whole processing regardless of whether each processing from the connect processing to the receive processing ends normally or in an error. When the close processing is operated abnormally, the next connect processing may not be performed normally. The TCP connection status variable TcpStatus of the SktGetTCPStatus instruction is used to detect whether the close processing ends normally. For the corrective action of the TCP connection status error, refer to 9.7.2 TCP Connection Status Error and Corrective Action.

(43)

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). The timeout value for each processing from the connect processing to the close processing is 5 seconds.

[Monitoring time of the communications instruction processing]

Processing Monitoring Variable name Timeout time

Connect

processing Time from the start to the end of the

processing TopenTime 5 seconds

(UINT#500) Send

processing Time from the start to the end of the

processing TfsTime 5 seconds

(UINT#500) Receive

processing

Time from the start to the end of the processing

(Each receive processing) TfrTime 5 seconds (UINT#500) Close

processing

Time from the start of the processing until the TCP socket enters the close

status. TcloseTime 5 seconds

(UINT#500)

●Receive waiting function for divided packets/multiple response data

To repeat the receive processing, this function enables waiting for multiple responses that arrive continuously or the receive data that is divided. The timer of the program monitors the interval at which to receive the data. Then, if the next packet does not arrive from the destination device within the set time (300 ms: default) after each receive processing (If the receive data arrives at an interval of more than 300 ms), repeating the receive processing will end.

[Receive wait monitoring time]

Processing Monitoring Variable

name Maximum waiting time TCP socket

status read processing

Time from when

SktGetTCPStatus_instance.Dat RcvFlag is turned OFF until when the flag is turned ON.

TrTime 300 milliseconds (UINT#3)

(44)

●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.

*If a TCP connection status error occurs at the close processing, the TCP/IP resend/time monitoring function may still be operating. For information on the situation and corrective action, refer to 9.7.2. TCP Connection Status Error and Corrective Action.

(45)

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

sStatus STRUCT Structure of communications processing status flags Busy BOOL

Communications processing in progress flag TRUE: Processing is in progress.

FALSE: Processing is not in progress.

Done BOOL Communications processing normal end flag TRUE: Normal end / FALSE: Other than normal end Error BOOL Communications processing error end flag

TRUE: Error end / FALSE: Other than error end

[Socket service instruction execution flags]

Name Data type Description

sControl STRUCT Socket service instruction execution flags

Send BOOL Send processing instruction

TRUE: Executed / FALSE: Not executed

Recv BOOL Receive processing instruction

TRUE: Executed / FALSE: Not executed

Open BOOL Connect processing instruction

TRUE: Executed / FALSE: Not executed Close BOOL Close processing instruction

TRUE: Executed / FALSE: Not executed Status BOOL TCP socket status read processing instruction

TRUE: Executed / FALSE: Not executed

[Timer enable flags]

Name Data type Description

sTimerControl STRUCT Time monitoring timer enable flags

Tfs BOOL Send processing time monitoring timer instruction TRUE: Enabled / FALSE: Not enabled

Tfr BOOL Receive processing time monitoring timer instruction TRUE: Enabled / FALSE: Not enabled

Topen BOOL Connect processing time monitoring timer instruction TRUE: Enabled / FALSE: Not enabled

Tclose BOOL Close processing time monitoring timer instruction TRUE: Enabled / FALSE: Not enabled

Tr BOOL Receive waiting time monitoring timer instruction TRUE: Enabled / FALSE: Not enabled

(46)

[Send/Receive processing required/not required setting flag]

Name Data type Description

sComType STRUCT Send/Receive processing required/not required setting flags

Send BOOL

Send processing TRUE: Required / FALSE: Not required

*Specify this when sending a command.

Recv BOOL

Receive processing TRUE: Required / FALSE: Not required

*Specify this when receiving a response.

Error BOOL Send/Receive processing required/not required setting error flag (This flag changes to ON when a setting error occurred.)

●Data type (Union) [Error code processing]

Name Data type Description

uErrorFlags UNION Union for error code processing

BoolData ARRAY[0..15]

OF BOOL

2-byte error code is processed in units of 1 bit as 16-bit string.

: TRUE (Error) / FALSE (Normal)

•Communications error

BoolData[0]: Send processing BoolData[1]: Receive processing BoolData[2]: Connect processing BoolData[3]: Close processing BoolData[4]: Processing number error

•Timeout error

BoolData[8]: Send processing BoolData[9]: Receive processing BoolData[10]: Connect processing BoolData[11]: Close processing

•Others

BoolData[5]: Send/Receive required/not required detection error

BoolData[12]: Destination device error BoolData[6..7],[13..14]: Reserved BoolData[15]: Error

WordData WORD 2-byte error code is processed as WORD at once.

(47)

●External variables

[User-defined global variables]

Variable name Data type Description

Input_Start BOOL Communications start switch

The program starts when this flag changes from FALSE to TRUE.

Output_RecvMess STRING[256] An area that stores the receive data (response) (256 bytes)

Output_ErrCode WORD

An area that stores the error flag for a communications error or a timeout error that is detected at the connect processing, TCP socket status read processing, receive processing or close processing.

Normal end: 16#0000

Output_SktCmdsErrorID WORD

An area that stores the error code for a communications error or a timeout error that is detected at the connect processing, TCP socket status read processing and receive processing.

Normal end: 16#0000

Output_SktCloseErrorID WORD

An area that stores the error code for a communications error or a timeout error that is detected at the close processing.

Normal end: 16#0000 Output_EtnTcpSta _eCONNECTIO

N_STATE

An area that stores the TCP socket status _ESTABLISHED: Connect status

_CLOSED: Close status

Output_MErrCode DWORD

An area that stores the destination device’s error code for an FCS error or a destination device error that is detected after the receive processing.

Normal end: 16#00000000

[System-defined variable]

Variable name Data type Description

_EIP_EtnOnlineSta BOOL Status of built-in EtherNet/IP port communications function

TRUE: Can be used, FALSE: Cannot be used

Additional Information

For information on the system-defined variables, refer to Communications Instructions in 2 Instruction Descriptions of the NJ-series Instructions Reference Manual (Cat. No. W502).

(48)

●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 Description

ETN_ParameterSet_instan

ce ParameterSet

Ethernet communications parameter setting function block

This variable sets a destination IP address and monitoring time for each processing from the connect processing to the close processing.

ETN_SendMessageSet_in

stance SendMessageSet

Ethernet communications send data setting function block

This variable sets the send/receive processing required/not required setting and send data.

ETN_ReceiveCheck_insta

nce ReceiveCheck

Ethernet communications receive processing function block

This variable stores the receive data and detects a normal end or an error end.

*For information on the user-defined function blocks, refer to 9.5.3 Detailed Description of Function Blocks.

[Instances for timer]

Variable name Data type Description

SktTCPConnect_instance SktTCPConnect Connect TCP socket function block SktTCPSend_instance SktTCPSend TCP socket send function block SktTCPRcv_instance SktTCPRcv TCP socket receive function block SktClose_instance SktClose Close TCP socket function block SktGetTCPStatus_instance SktGetTCPStatus Read TCP socket status function block

Additional Information

For information on the communications instructions, refer to Communications Instructions in Section 2 Instruction Descriptions of the NJ-series Instructions Reference Manual (Cat. No.

W502).

[Instances for timer]

Variable name Data type Description

Topen_TON_instance TON Counts the time taken to perform the TCP connect processing.

Tfs_TON_instance TON Counts the time taken to perform the TCP send processing.

Tfr_TON_instance TON Counts the time taken to perform the TCP receive processing.

Tclose_TON_instance TON Counts the time taken to perform the close processing.

Tr_TON_instance TON Counts the time taken to wait for the next response.

(49)

●Internal variables

Variable name Data type Description

Local_Status sStatus Communications processing status flags This variable is defined as sStatus structure.

Local_State DINT Processing number

Local_ErrCode uErrorFlgs An area in which an error code is edited.

This variable is defined as uErrorFlgs union.

Local_ExecFlgs sControl Socket service instruction execution flags This variable is defined as sControl structure.

Local_SrcDataByte UINT The number of bytes of send data Local_SrcData ARRAY[0..255]

OF BYTE

An area that stores the send data of the SktTCPSend instruction (256 bytes)

Local_RecvData ARRAY[0..2000]

OF BYTE

An area that stores the receive data of the SktTCPRcv instruction (2001 bytes)

Local_ReceiveMessage STRING[256] An area that stores the receive data after converted into a string. (256 characters)

Local_ReceiveSize UINT The size of the receive data of SktTCPRcv instruction Local_RecvDataLength UINT The total byte length of the receive data

Local_RecvCHNo UINT The element number of Local_RecvData that stores the receive data

Local_RecvCheckFlg BOOL

Destination device error detection instruction execution flag

TRUE: Executed / FALSE: Not executed Local_InitialSettingOK BOOL Initialization processing normal setting flag Local_TONFlgs sTimerControl Timer enable flags

This variable is defined as sTimerControl structure.

Local_ComType sComType

Send/Receive processing required/not required setting flags

This variable is defined as sControl structure.

參考文獻

相關文件

„ Signaling over standard IP uses a common transport protocol that ensures reliable signaling delivery. „ Error-free

„ A socket is a file descriptor that lets an application read/write data from/to the network. „ Once configured the

• BP can not correct the latent error neurons by adjusting their succeeding layers.. • AIR tree can trace the errors in a latent layer that near the front

For consistent predictions or strongly ordinal costs, if g makes test error ∆ in the induced binary problem, then r g pays test cost at most ∆ in ordinal ranking. a one-step

For consistent predictions or strongly ordinal costs, if g makes test error ∆ in the induced binary problem, then r g pays test cost at most ∆ in ordinal ranking. a one-step

For concordant predictions or strongly ordinal costs, if g makes test error ∆ in the induced binary problem, then r g pays test cost at most ∆ in ordinal ranking. a one-step

For consistent predictions or strongly ordinal costs, if g makes test error ∆ in the induced binary problem, then r g pays test cost at most ∆ in ordinal ranking. a one-step

Experiment a little with the Hello program. It will say that it has no clue what you mean by ouch. The exact wording of the error message is dependent on the compiler, but it might