Tcp/ip communications programming example, 7-8 tcp/ip communications programming example – Omron CS CJ1W-ETN21 User Manual

Page 151

Advertising
background image

127

Using Socket Services by Manipulating Dedicated Control Bits

Section 6-7

Note The Open Flag will not turn ON at all if a force-close request is made during

open processing.

6-7-8

TCP/IP Communications Programming Example

The following programming example illustrates transferring 100 bytes of data
between an Ethernet Unit and a host computer using TCP/IP communica-
tions.

System Configuration

The programming example uses the following system configuration. For the
TCP connection, the Ethernet Unit uses a passive open and the host com-
puter uses an active open.

Data Flow

The data will flow between the CPU Unit, Ethernet Unit, and host computer as
shown in the following diagram.

Note Here, “execution bits” refer to CIO 000000 to CIO 000003, which are used in

the ladder diagram to control execution of communications.

Basic Operations

• CIO 000000 is turned ON to request opening a TCP socket from the

Ethernet Unit.

• CIO 000001 is turned ON to request closing the TCP socket from the

Ethernet Unit.

• CIO 000002 is turned ON to request sending data from the Ethernet Unit.

Data (100 bytes) is sent beginning at D00000.

• CIO 000003 is turned ON to request receiving data from the Ethernet

Unit. The data that is received (100 bytes) is stored beginning at D01000.

• One of the bits between CIO 000100 and CIO 000103 will turn ON if an

error occurs. Refer to 6-7-5 Socket Service Request Switches for informa-
tion on errors.

Host computer

Ethernet Unit

IP address: 196.36.32.55
Port number: 4096

IP address: 196.36.32.101
Port number: 4096

PLC

Host computer

Line
(Ethernet)

Ethernet
Unit

CPU Unit

Request Switches and ex-
ecution bits turned ON
(see note).

Sent to line.

Processing in
host computer

Execution bits turned OFF

Advertising