Cat. No.
CS1W-ETN21 (100Base-TX) CJ1W-ETN21 (100Base-TX) Ethernet Units Construction of Applications Operation Manual Revised November 2005
Notice: OMRON products are manufactured for use according to proper procedures by a qualified operator and only for the purposes described in this manual. The following conventions are used to indicate and classify precautions in this manual. Always heed the information provided with them. Failure to heed precautions can result in injury to people or damage to property. !DANGER Indicates an imminently hazardous situation which, if not avoided, will result in death or serious injury.
vi
TABLE OF CONTENTS PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi 1 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii 2 General Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii 3 Safety Precautions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TABLE OF CONTENTS SECTION 4 FTP Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4-1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 4-2 FTP Server Function Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4-3 Using the FTP Server Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TABLE OF CONTENTS Appendices A Ethernet Network Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 B Buffer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 C TCP Status Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 D ASCII Characters . . . . . . . . . . . . . . . . . . . . . . . . . .
TABLE OF CONTENTS x
About this Manual: This manual describes the operation of the CS1W-ETN21 and CJ1W-ETN21 Ethernet Units (100BaseTX) for constructing applications and includes the sections described below. Please read this manual carefully and be sure you understand the information provided before attempting to install or operate the Ethernet Unit. Be sure to read the precautions provided in the following section.
Relevant Manuals The following table lists CS- and CJ-series manuals that contain information relevant to Ethernet Units.
Manual number W394 Model Name Contents CS1G/H-CPU@@H CS1G/H-CPU-@@V1 CJ1G/H-CPU@@H CJ1G-CPU@@ Programmable Controllers Programming Manual W340 CS1G/H-CPU@@H CS1G/H-CPU-@@V1 CJ1G/H-CPU@@H CJ1G-CPU@@ Programmable Controllers Instructions Reference Manual W414 WS02-CX-@@JV3 CX-Programmer Ver.3.@ Operation Manual Describes programming, tasks, file memory, and other functions for the CS-series and CJ-series PLCs.
xiv
Read and Understand this Manual Please read and understand this manual before using the product. Please consult your OMRON representative if you have any questions or comments. Warranty and Limitations of Liability WARRANTY OMRON's exclusive warranty is that the products are free from defects in materials and workmanship for a period of one year (or other period if specified) from date of sale by OMRON.
Application Considerations SUITABILITY FOR USE OMRON shall not be responsible for conformity with any standards, codes, or regulations that apply to the combination of products in the customer's application or use of the products. At the customer's request, OMRON will provide applicable third party certification documents identifying ratings and limitations of use that apply to the products.
Disclaimers CHANGE IN SPECIFICATIONS Product specifications and accessories may be changed at any time based on improvements and other reasons. It is our practice to change model numbers when published ratings or features are changed, or when significant construction changes are made. However, some specifications of the products may be changed without any notice. When in doubt, special model numbers may be assigned to fix or establish key specifications for your application on your request.
xviii
Unit Versions of CS/CJ-series Unit Versions A “unit version” has been introduced to manage Units in the CS/CJ Series according to differences in functionality accompanying Unit upgrades. Notation of Unit Versions on Products The unit version is given to the right of the lot number on the nameplate of the products for which unit versions are being managed, as shown below. Product nameplate CS1WUNIT Unit version Example for unit version 1.3 Lot No. Lot No.
Using Unit Version Label The following unit version label is provided with the Ethernet Unit. This label can be attached to the front of the Ethernet Unit to differentiate between Ethernet Units with different unit versions. Unit Version Notation Product nameplate In this manual, the unit version of a Ethernet Unit is given as shown in the following table. Notation used in this manual Ver. 2.0 or later number shown to right of the lot number Ethernet Unit Ver. 1.
PRECAUTIONS This section provides general precautions for using the CS1W-ETN21 and CJ1W-ETN21 Ethernet Units (100Base-TX). The information contained in this section is important for the safe and reliable application of Ethernet Units. You must read this section and understand the information contained before attempting to set up or operate an Ethernet Unit. 1 2 3 4 5 6 Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . General Precautions . . . . . .
1 Intended Audience 1 Intended Audience This manual is intended for the following personnel, who must also have knowledge of electrical systems (an electrical engineer or the equivalent). • Personnel in charge of installing FA systems. • Personnel in charge of designing FA systems. • Personnel in charge of managing FA systems and facilities. 2 General Precautions The user must operate the product according to the performance specifications described in the operation manuals.
Safety Precautions 3 !WARNING Provide safety measures in external circuits (i.e., not in the Programmable Controller), including the following items, to ensure safety in the system if an abnormality occurs due to malfunction of the PLC or another external factor affecting the PLC operation. Not doing so may result in serious accidents. • Emergency stop circuits, interlock circuits, limit circuits, and similar safety measures must be provided in external control circuits.
Operating Environment Precautions 4 4 Operating Environment Precautions !Caution Do not operate the control system in the following locations: • Locations subject to direct sunlight. • Locations subject to temperatures or humidity outside the range specified in the specifications. • Locations subject to condensation as the result of severe changes in temperature. • Locations subject to corrosive or flammable gases. • Locations subject to dust (especially iron dust) or salts.
5 Application Precautions • Always use the power supply voltages specified in the operation manuals. An incorrect voltage may result in malfunction or burning. • Take appropriate measures to ensure that the specified power with the rated voltage and frequency is supplied. Be particularly careful in places where the power supply is unstable. An incorrect power supply may result in malfunction. • Install external breakers and take other safety measures against short-circuiting in external wiring.
6 Conformance to EC Directives • When transporting the Unit, use special packing boxes and protect it from being exposed to excessive vibration or impacts during transportation. • CPU Bus Units will be restarted when routing tables are transferred from a Programming Device to the CPU Unit. Restarting these Units is required to read and enable the new routing tables. Confirm that the system will not be adversely affected before allowing the CPU Bus Units to be reset.
SECTION 1 Introduction This section introduces the functions and protocols used in Ethernet Unit communications services. 1-1 Ethernet Unit Communications Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1-2 Functions Listed by Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1-3 Table of Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1-4 Common Protocol Settings . . . . . . . . . . . .
Section 1-1 Ethernet Unit Communications Services 1-1 Ethernet Unit Communications Services Service Mail send function Main functions Through intranet or Used to e-mail specified I/O memory internet data or a file (up to 1 MB) from the PLC to the computer automatically when a preset condition is met.
Section 1-3 Table of Protocols Timing and direction Automatic execution when a preset condition is met, sent to computer (See note.) User purpose Communications Method service Mail Send FuncSpecify a data file as an attached tion file and specify the starting read address and number of words. Reading data in the CPU Unit's I/O memory Specify any file as an attached file. The maximum data size is 1 MB.
Section 1-4 Common Protocol Settings Communications service Mail Receive Function Protocol used Situation when used CXReference Programmer's Unit setting tag name SMTP SECTION 3 Receive Mail POP Function DNS SMTP Required POP DNS Required When specifying the SMTP server and POP server by host names FTP Server Function FTP Optional User set SECTION 4 FTP Server Socket Service Function TCP/IP UDP/IP Optional Optional User set User set SECTION 6 Socket Services Automatic Clock Adjust Functi
Section 1-4 Common Protocol Settings Item IP Address Contents Set the IP address for the SMTP server used for sending mail. This setting is enabled only when “IP address” is selected as the method for specifying the server. Host name Set the host domain name (i.e., the host None name) for the SMTP server that is to be used for sending mail. This setting is enabled only when “host name” is selected as the method for specifying the server.
Section 1-4 Common Protocol Settings Item Server specification type Contents Select whether the POP3 server used for receiving mail is to be specified by IP address or the host's domain name (i.e., host name). Default IP Address IP Address Set the IP address for the POP3 server used for receiving mail. This setting is enabled only when “IP address” is selected as the method for specifying the server. Set the host domain name (i.e.
Section 1-4 Common Protocol Settings The DNS server manages the IP addresses and host names of the nodes that communicate in the network. The Ethernet Unit automatically acquires each server's IP address from the DNS server and uses those acquired IP addresses. Item IP Address Contents Set the IP address for the DNS server. Default None Port No. Set the port to be used for connecting to the 0 DNS server. Normally, the default setting is (Number 53 is used. used.
Common Protocol Settings 8 Section 1-4
SECTION 2 Mail Send Function This section provides an overview and describes how to use the Ethernet Unit’s Mail Send Function, including application examples and troubleshooting information. 2-1 2-2 2-3 2-4 2-5 Mail Send Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2-1-1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2-1-2 Comparison with the Earlier Mail Send Function . . . . . . . . . . . .
Section 2-1 Mail Send Function Overview 2-1 2-1-1 Mail Send Function Overview Introduction The Mail Send Function sends an e-mail from the Ethernet Unit to a specified e-mail address when a predetermined condition occurs in the PLC. Data in the CPU Unit's I/O memory areas (or any file in the Memory Card) can be sent as an attached file. In addition, user-set ASCII information as well as the Ethernet Unit's error log and status information can be sent as text in the body of the e-mail.
Section 2-2 Mail Send Function Details ■ Attached Files An I/O memory data file created automatically by the Ethernet Unit (a specified range of the CPU Unit's I/O memory data converted to a .IOM, .TXT, or .CSV file) or any file in file memory (in the CPU Unit's Memory Card) can be sent as an attached file.
Section 2-2 Mail Send Function Details 2-2-1 Contents of E-mail Body Date and time Header Ethernet Unit's e-mail address Date: Fri, 1 Jan 2004 13:00:00 +0900 From: alpha@omron.co.jp Message-Id: To: beta@omron.co.jp Subject: OMRON Ethernet Unit Mail Service (posted at regular intervals) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Trigger Setting Number = 1 This is OMRON ethernet unit mail posting service.
Section 2-2 Mail Send Function Details 2-2-2 Contents of E-mail Body Ethernet Unit's Status Information Header The following header information is included. • Subject: OMRON Ethernet Unit Mail Service (Indicates trigger condition. See note.) • Content-Type: text/plain;charset=US-ASCII • Content-Transfer-Encoding:7bit Note The following trigger conditions are available.
Section 2-2 Mail Send Function Details Trigger condition Trigger-specific message in e-mail header Change in CPU Unit This mail have been posted at changing CPU mode (PRG>MON) This mail have been posted at changing CPU mode (PRG>RUN) This mail have been posted at changing CPU mode (MON>PRG) This mail have been posted at changing CPU mode (MON>RUN) This mail have been posted at changing CPU mode (RUN>PRG) This mail have been posted at changing CPU mode (RUN>MON) This mail have been posted at changing CPU
Section 2-2 Mail Send Function Details ■ Error Log Information The error log information includes all of the data stored in the Ethernet Unit's error log. The error log can contain up to 64 records. For details on the error log, refer to 8-3 Error Log in the Operation Manual Construction of Networks (W420). ■ Status Information The following Ethernet Unit data is sent. 1. Open/closed status of UDP sockets 1 to 8 2. TCP status of TCP sockets 1 to 8 3. Unit error information 4.
Section 2-2 Mail Send Function Details • Since the Ethernet Unit creates the data file automatically, the Accessing Memory/Sending Mail Flag (bit 01 of n+17 in the allocated CPU Bus Unit Area) will be ON while the CPU Unit's I/O memory is being accessed. • To maintain the integrity of the data, write-protect the region of I/O memory being converted to a data file by preventing the region from being written from the ladder program while this flag is ON. File Data (1 MB Max.
Mail Send Function Specifications 2-3 2-3-1 Section 2-3 Mail Send Function Specifications Function Specifications Item Destination e-mail address Specifications Up to 2 addresses can be registered in the Unit Setup (CPU Bus Unit System Setup) and the addresses can be up to 50 characters long. Subject Body Fixed text (Depends on the trigger condition.
Section 2-4 Using the Mail Send Function 2-3-2 Details of the Available Mail Triggers Classification User-set Trigger type Trigger when a specified word in the CPU Unit's I/O memory becomes equal to a set value. Trigger when a specified word in the CPU Unit's I/O memory becomes greater than a set value. Trigger when a specified word in the CPU Unit's I/O memory becomes less than a set value. Trigger when a specified bit in the CPU Unit's I/O memory goes from OFF to ON.
Section 2-4 Using the Mail Send Function become effective. Verify that it is safe for the Ethernet Unit to restart before transferring the settings data. 2-4-2 Settings Required for the Mail Send Function The following Unit settings must be made when using the Mail Send Function. CXProgrammer Unit Setup Tab SMTP POP (See note 1.) DNS (See note 2.) Setting Reference Server specification type Required.
Section 2-4 Using the Mail Send Function CXSetting Programmer Unit Setup Tab Send Mail Trigger type (Send mail conditions 1 to 8) Setting requirement Reference One type must be selected. page 21 • Rising edge of the Mail Send Switch: Select the Software switch Option. • Change in specified word's value: Select the Word value change Option and specify the Area, Address, Value, and State. • Change in specified bit's status: Select the Bit value change Option and specify the Area, Address, Bit, and State.
Using the Mail Send Function 2-4-3 Section 2-4 Mail Address Set up to 2 destination mail addresses. Item Contents Default Mail address 1 Set one of the addresses to which the Ethernet Unit None Mail address 2 is to send mail. (Up to two addresses can be set.) Each mail address can be up to 50 characters long. Note: Mail can be sent to multiple addresses by punctuating the mail address with commas. For example, the following mail address entry will send the e-mail to address1@omron.co.
Section 2-4 Using the Mail Send Function Send Mail Condition Settings Item Contents Default Trigger No. Select a number as the trigger condition for None sending mail. Up to eight trigger numbers can be registered. Send mail upon trigger Sets whether or not the selected mail trigger is to be enabled. Not selected Mail Address Specification (Required) Item Mail address Contents Default Select whether the e-mail will be sent to destina- Address 1 tion mail address 1 or destination mail address 2.
Section 2-4 Using the Mail Send Function ■ Attached File Name Item Attached file name Contents If the above setting is checked so that files can be sent as attachments, then specify the name of the file that is to be sent. Default None I/O data file The data file will be created autoselected matically with the file name entered in this field. Note Even if a filename extension is entered, it will be ignored. The Unit automatically adds the appropriate extension (.IOM, .TXT, or .CSV).
Section 2-5 Mail Send Function Status Note Item CPU condition Contents Default If this option is selected, mail is sent whenever Not selected any of the following conditions occur at the CPU Unit. Use the drop-down list at the right to select one of the following three conditions as the mail trigger. • When a non-fatal error occurs • When a fatal error occurs • When the operating mode is changed Periodic timer If this option is selected, an e-mail is sent at Not selected fixed time intervals.
Section 2-5 Mail Send Function Status ■ Send Mail Status 2 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 m+17 Status of Send Condition Setting 5 Status of Send Condition Setting 6 Status of Send Condition Setting 7 Status of Send Condition Setting 8 The transmission status of each send condition is indicated by the content of the corresponding 3 bits in Send Mail Status 1 or Send Mail Status 2, as shown in the following table.
Section 2-6 I/O Memory Data Formats n 15 14 13 12 11 10 09 08 07 06 05 04 - - - - - - - - - - - - 03 02 01 00 - - Mail Send Switch ■ Accessing Memory/Sending Mail Flag (Bit 01 of n+17) When a data file (IOM, TXT, or CSV) is being attached to the e-mail, the Ethernet Unit will access the CPU Unit's I/O memory and automatically create the data file when the e-mail is being sent.
Section 2-7 Attached File Transfer Times I/O memory contents +0 +10 +0 +1 1234 5678 9ABC DEF0 +2 +3 +4 +5 +6 +7 +8 +9 9ABC DEF0 1234 5678 9ABC DEF0 1234 5678 1234 5678 9ABC DEF0 1234 5678 9ABC DEF0 TXT file contents 31 1 32 2 35 5 33 3 36 6 34 09 35 36 37 4 [HT] 5 6 7 37 38 0D 0A 39 7 8 [CR] [LF] 9 38 09 39 41 42 8 [HT] 9 A B 41 42 43 09 A B C [HT] 43 09 C [HT] Contents of TXT file when displayed 1234@5678@9ABC@DEF0@1234@5678@9ABC@DEF0@1234@5678@ 9ABC@DEF0@1234@5678@9ABC@DEF0@1234@5678@9ABC@DEF0
Section 2-8 Mail Send Function Errors ■ Access Times for CS1 and CJ1 CPU Units Command Data size CPU Unit's operating mode PROGRAM RUN --- ■ IOM data 1 word 0.1 s 10 ms cycle time 0.1 s File data 6,000 words 1 KB 0.3 s 0.3 s 0.3 s 1.1 s 10 KB 100 KB 1.3 s 10.6 s 7.3 s 72.2 s 1 MB 137.4 s 1,139.5 s Access Times for CS1-H and CJ1-H CPU Units Command Data size CPU Unit's operating mode PROGRAM RUN --- IOM data (words) File data (bytes) Note 1 word 0.1 s 10 ms cycle time 0.
Section 2-8 Mail Send Function Errors Cause Details of trigger setting error Correction Correctly set the trigger type setting. Specified word or specified bit data area/ Correctly set the data area and address address error for the specified word or bit.
Section 2-9 Example Application Error code Note 2-9 2-9-1 Meaning Detailed error code 1st byte 2nd byte Correction 03C1 Server set- 00: DNS ting error 01: SMTP 02: POP3 03: SNTP 01: IP address 02: Host name 03: Port number 04: Other parameters 03C4 Server 00: DNS 01: Specified connection 01: SMTP host does not error exist 02: POP3 02: No service 03: SNTP at specified host 03: Timeout 04: Closed unilaterally by host 05: Cannot connect because account information does not match 06: Host name resolu
Section 2-9 Example Application Tab DNS Item Setting IP Address 10.56.3.24 Port No. Retry timer 53 (default value) 10 s (default value) Item Mail address 1 Setting beta@omron.co.jp Item Mail address Address 1 2. Destination Mail Address Setup Tab Mail Address 3.
Section 2-9 Example Application Example: Send e-mail when W300 bit 00 goes from OFF to ON.
SECTION 3 Receive Mail Function This section describes how to use the Ethernet Unit’s Mail Receive Function, including specifications, status details, I/O memory data formats, file transfer timing, application examples, and troubleshooting information. 3-1 3-2 3-3 3-4 3-5 Mail Receive Function Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3-1-1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Section 3-1 Mail Receive Function Overview 3-1 3-1-1 Mail Receive Function Overview Introduction The mail receive function performs the following functions using e-mails sent to the Ethernet Unit. 1,2,3... 1. The user can enter a command in the e-mail and send that e-mail to the Ethernet Unit. 2. A command written in the e-mail subject can be executed when the e-mail is received. (The Ethernet Unit periodically checks the mail server to determine whether mail has been delivered.) 3.
Section 3-1 Mail Receive Function Overview ■ Remote Mail Commands Enter the remote command (for example, FileRead) in ASCII in the e-mail subject line. ■ Command Parameters Enter the parameters (for example, Para1:Overwrite=OK) in ASCII in the email body. ■ Attached File Data With remote write commands, a single file can be attached containing the write data. When writing data (up to 6,000 words) in a specified part of I/O memory, the I/ O memory data is attached as a data file (.IOM, .TXT, or .CSV).
Section 3-2 Mail Receive Function Specifications Remote mail command type File memory operaPerforming file operations on a tions Memory Card in the CPU Unit or EM file memory Contents A file can be attached to read/ write data in any file in EM file memory or a Memory Card mounted in the CPU Unit. It is also possible to delete files and list files.
Section 3-2 Mail Receive Function Specifications Attached file Item Data format Data size Format Number of attachments Reception (decoding) Specification • IOM Write command: Writes an I/O memory data file (IOM, TXT, or CSV) to the CPU Unit. • File Write command: Any type of file (a file with any filename extension) can be written to EM file memory or a Memory Card mounted in the CPU Unit. • IOM Write command: 6,000 words max. (same limit for all file types) • File Write command: 1 MB max.
Using the Mail Receive Function 3-3 3-3-1 Section 3-3 Using the Mail Receive Function Procedure 1. Mount the Ethernet Unit in the CPU Rack or Expansion Rack, connect online with the CX-Programmer or Programming Console, and create the I/O table. ↓ 2.
Section 3-3 Using the Mail Receive Function 3-3-2 Settings Required for the Mail Receive Function The following Unit settings must be made when using the Mail Receive Function. CX-Programmer Unit Setup Tab SMTP Setting Setting requirement Server specification type Required. IP Address Host name One or the other is required, depending on the Server specification type setting. Port No. Rarely required (when a setting other than the default setting of 25 is required).
Section 3-3 Using the Mail Receive Function 3-3-3 Receive Mail Tab The CPU Bus Unit settings for the mail receive function can be set in the CXProgrammer's CPU Bus Unit Setup Window. Posting Mail Address Protection Setting Item 40 Contents Default Protect using mail address Select this option when you do not want to receive mail from addresses other than the specified address(es). Set the allowed source e-mail address in the Mail address field.
Section 3-3 Using the Mail Receive Function Receive Attached File Setting Item Receive file with specified extension only Contents Default Select this option when you do not want to Selected receive attached files other than the specified file types (filename extensions). Multiple extensions can be selected. OBJ Select this option to accept files with the ".OBJ" Selected extension.
Section 3-4 Remote Mail Command Details 3-4 3-4-1 Item MailLogClear Contents Select when you want to execute the Mail Log Clear command. Default Selected Test Select when you want to execute the Mail Test command. Selected FinsSend Select when you want to execute the FINS Command Send command. Not selected Remote Mail Command Details Format Command Format To: etn@omron.co.jp Enter the Ethernet Unit's local mail address. CC: Subject: Body: Attached file: FileWrite Enter the command name.
Section 3-4 Remote Mail Command Details FileWrite (File Write) Function Writes the attached file to the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit. Command Format Subject: FileWrite Notation Body: Para1:Destination folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Para2:Overwrite=OK or NG Example) Allowing existing file to be overwritten: Para2:Overwrite=OK Description Specifies the destination folder.
Section 3-4 Remote Mail Command Details FileRead (File Read) Function Reads any file from the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit and returns the file as an attachment. Command Format Subject: FileRead Notation Body: Para1:Source folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Para2:File name Example) Specifying AUTOEXEC.STD: Para2:AUTOEXEC.STD Description Specifies the source folder.
Section 3-4 Remote Mail Command Details FileDelete (File Delete) Function Deletes the specified file from the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit. Command Format Subject: FileDelete Notation Body: Para1:Folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Para2:File name Example) Specifying AUTOEXEC.STD: Para2:AUTOEXEC.STD Description Specifies the folder containing the file to be deleted.
Section 3-4 Remote Mail Command Details FileList (File List Read) Function Returns a list of the files contained in the specified folder in the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit. Command Format Subject: FileList Notation Body: Para1:Source folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Description Specifies the source folder containing the files that will be listed. Omission Can be omitted.
Section 3-4 Remote Mail Command Details UMBackup (User Memory Backup) Function Backs up (saves) the CPU Unit's user program in the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit. Command Format Details Subject: UMBackup Notation Body: Para1:Destination folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Para2:File name Example) Specifying USER.OBJ: Para2:USER.
Section 3-4 Remote Mail Command Details PARAMBackup (Parameter Area Backup) Function Backs up (saves) the parameter area data in the CPU Unit's EM file memory or a Memory Card mounted in the CPU Unit. Command Format Subject: PARAMBackup Notation Body: Para1:Destination folder name Example) Specifying subdirectory OMRON in the Memory Card: Para1:MEMCARD\OMRON Para2:File name Example) Specifying USER.STD: Para2:USER.
Section 3-4 Remote Mail Command Details IOMWrite (I/O Memory Write) Function Writes the contents of the attached file to the specified data area in the CPU Unit's I/O memory. The data is written in word units.
Section 3-4 Remote Mail Command Details Attached file: Yes Attach an I/O data file (IOM, CSV, or TXT format). Cannot be omitted. Note Up to 6,000 words can be written from the data file. Attach a file with 6,000 or fewer words of data. Note Only a file with the IOM, CSV, or TXT can be written to I/O memory. Files with any other filename extension cannot be written to I/O memory regardless of the allowed file settings set in the Receive Mail Tab.
Section 3-4 Remote Mail Command Details IOMRead (I/O Memory Read) Function Reads the contents of the specified range of words from the CPU Unit's I/O memory and returns the data in an attached file. The data is read in word units.
Section 3-4 Remote Mail Command Details Para4:File name Example) Specifying MEMORY.TXT: Para4:MEMORY.TXT Specifies the name of the file (including the filename extension) in which the read data will be stored. Note Only filename extensions IOM, CSV, and TXT can be used. Other filename extensions cannot be specified. Note If this parameter is omitted, the file will be saved as BACKUP.IOM, BACKUP.TXT, or BACKUP.CSV. Can be omitted.
Section 3-4 Remote Mail Command Details ChangeMode (Operating Mode Change) Function Changes the CPU Unit's operating mode. Command Format Subject: ChangeMode Notation Body: Para1:RUN (or MON or PRG) Example) Changing to RUN mode: Para1:RUN Description Changes the CPU Unit's operating mode. • To change to RUN mode, enter RUN. • To change to MONITOR mode, enter MON. • To change to PROGRAM mode, enter PRG. Omission Cannot be omitted. Note If this parameter is omitted, a parameter error will occur.
Section 3-4 Remote Mail Command Details ErrorLogRead (Error Log Read) Function Reads the entire error log from the CPU Unit or a specified Special Unit (CPU Bus Unit or Special I/O Unit). Command Format Subject: ErrorLogRead Notation Body: Para1:Unit address Example) Specifying a CPU Bus Unit (unit number 0): Para1:10 Description Specifies the unit address of the Unit from which the error log will be read. Omission Cannot be omitted. Note If this parameter is omitted, a parameter error will occur.
Section 3-4 Remote Mail Command Details ErrorLogClear (Error Log Clear) Function Clears the entire error log from the CPU Unit or a specified Special Unit (CPU Bus Unit or Special I/O Unit). Command Format Subject: ErrorLogClear Notation Body: Para1:Unit address Example) Specifying a CPU Bus Unit (unit number 0): Para1:10 Description Specifies the unit address of the Unit from which the error log will be cleared. Omission Cannot be omitted.
Section 3-4 Remote Mail Command Details MailLogRead (Mail Log Read) Function Reads the mail log, which contains information on mail received by the Ethernet Unit. (The mail log contains basic information on all of the mail received since power was turned ON or the mail log was cleared.
Section 3-4 Remote Mail Command Details MailLogClear (Mail Log Clear) Function Clears the mail log, which contains information on mail received by the Ethernet Unit. Command Format Subject: MailLogClear Notation Body: None Description --- Omission --- Attached file: None Response Format Subject: Re:MailLogClear Response contents Body: Response Code:@@@@ Response Status:@@@@ Description Refer to 3-4-2 Response List. Refer to 3-4-2 Response List.
Section 3-4 Remote Mail Command Details Test (Mail Test) Function Performs an e-mail send/receive test with the Ethernet Unit. When this remote mail command is executed, the Ethernet Unit returns a response to the address that sent the remote mail command.
Section 3-4 Remote Mail Command Details FinsSend (FINS Command Send) Function Requests execution of the specified FINS command by the Ethernet Unit. Command Format Subject: FinsSend Notation Body: Para1:FINS header Example) Specifying DNA=01, DA1=02, and DA2=00: Para1:010200 Para2:Command code and parameter Example) Specifying 0501: Para2:0501* Description Enter the desired FINS header values for DNA, DA1, and DA2. Omission Cannot be omitted.
Section 3-5 Mail Receive Function Status Response Code F304 F305 F4FF 3-5 3-5-1 Response Status Description Protected (File extension) Attached file type (filename extension) is disabled in the protection settings. File size exceeds than the maximum size. Other Error Attached file is too large. Other error Mail Receive Function Status Accessing Memory/Receiving Mail Flag The Accessing Memory/Receiving Mail Flag is located in CIO Area words allocated to the Ethernet Unit as a CPU Bus Unit.
Section 3-6 I/O Memory Data Formats TXT Format When hexadecimal I/O memory data (1234, 5678, 9ABC, etc.) is being copied to an attached file in TXT format, the data is converted to ASCII in one-word fields or two-word fields. The fields (one-word or two-word) are delimited by tabs ([HT]: 09) and a return and line feed ([CR][LF]: 0D0A) are inserted after the specified number of fields.
Section 3-7 Attached File Transfer Times 3-7 Attached File Transfer Times When sending an attached file with the Mail Receive Function, the access time can be as long as 30 or 40 minutes for a very large file. The following tables show how long the CPU Unit's memory will be accessed by the Ethernet Unit (how long the Accessing Memory/Receiving Mail Flag will be ON). Access Times for CS1 and CJ1 CPU Units Command Data size CPU Unit's operating mode PROGRAM --- FileWrite 1 KB 10 KB 0.3 s 1.5 s 1.
Section 3-8 Mail Receive Function Errors 3-8 3-8-1 Mail Receive Function Errors Identifying and Correcting Mail Receive Function Errors The following table shows the primary causes of e-mail transmission errors and corresponding solution. Cause Correction • The POP, SMTP, or DNS server address has not been set. • Correctly set each server address (IP address or host name). • POP authentication error • Correctly set the POP settings (account and password).
Section 3-8 Mail Receive Function Errors 3-8-3 Error Log Codes Related to the Mail Receive Function If an error occurs while the Ethernet Unit is operating, the main error code, detailed error code, and time stamp will be recorded in the error log. The contents of the error log can be read by sending a FINS command to the Ethernet Unit or sending the ErrorLogRead command through e-mail.
Section 3-9 Example Application 3-9 3-9-1 Example Application Step 1. Create the I/O Table Mount the Ethernet Unit in the CPU Rack or Expansion Rack, connect online with the CX-Programmer or Programming Console, and create the I/O table. 3-9-2 Step 2. Make the Unit Setup Settings from the CX-Programmer With the CX-Programmer connected online, select the Ethernet Unit in the CX-Programmer's PLC I/O Table Window, right-click and select Unit Setup from the popup menu.
Section 3-9 Example Application Receive Command Setting 3-9-3 Item name Receive specified commands only Example Selected FileWrite FileRead Not selected Selected FileDelete FileList Not selected Selected UMBackup PARAMBackup Selected Selected IOMWrite IOMRead Not selected Selected ChangeMode ErrorLogRead Not selected Selected ErrorLogClear MailLogRead Selected Selected MailLogClear Test Selected Selected FinsSend Not selected Step 3.
SECTION 4 FTP Server This section describes the functions provided by the FTP server. 4-1 4-2 4-3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 4-1-1 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 FTP Server Function Details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4-2-1 File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Section 4-1 Overview 4-1 Overview The Ethernet Unit has a built-in FTP (File Transfer Protocol) server function, so other computers on the Ethernet can read or write (upload/download) large files in the EM file memory by executing FTP commands from the FTP client software. Intranet FTP client Specify the file and upload or download using FTP commands such as get and put. Ethernet Download Ethernet Unit Upload Large file Files in the EM File Memory or the Memory Card mounted to the CPU Unit.
Section 4-2 FTP Server Function Details 4-2 4-2-1 FTP Server Function Details File Types The file system in the CPU Unit that can be accessed by the Ethernet Unit includes files in any Memory Card mounted in the CPU Unit and files in the EM file memory. The directory tree is shown below. /: root MEMCARD: Memory card directory EM: EM file memory directory A connection will be initially made to the root directory. Note 1.
Section 4-3 Using the FTP Server Function • If a login name is not set or contains illegal characters, the default login name, CONFIDENTIAL, must be used. No password is required and any password that is set will be ignored. FTP File Transfer Mode FTP has two file transfer modes: ASCII mode and binary mode. Before starting to transfer files, use the type command (specifies the data type of transferred files) to select the required mode. Always select binary mode for binary files (extensions .IOM, .
Section 4-3 Using the FTP Server Function become effective. Verify that it is safe for the Ethernet Unit to restart before transferring the settings data. 4-3-2 List of Settings Required for the FTP Server Function Make the following settings for the unit setup when the server function is used. CX-Programmer tab Setup Settings Login Password Port No.
Section 4-4 FTP Server Application Example 4-4 FTP Server Application Example The following procedure shows how to use the FTP server by connection with the default login name, CONFIDENTIAL. No password is required. Note The login name and a password must be set in the CPU Bus Setup for the Ethernet Unit in the CPU Unit to use any login name other than CONFIDENTIAL. Note When general-purpose FTP software is used, files can be transferred and read using a graphical user interface similar to Explorer.
Section 4-5 Using FTP Commands 4-5 Using FTP Commands This section describes the FTP commands which the host computer (FTP client) can send to the Ethernet Unit’s FTP server. The descriptions should also apply to most UNIX workstations, but slight differences may arise. Refer to your workstation’s operation manuals for details. 4-5-1 Table of Commands The FTP commands which can be sent to the Ethernet Unit are listed in the following table.
Section 4-5 Using FTP Commands user Format user [user_name] Function Specifies the user name. Specify the FTP login name set in the Ethernet Unit system setup. The default FTP login name is “CONFIDENTIAL.” If a non-default login name is used, it must be followed by the password. In this case, enter the FTP password set in the system setup. The user name is automatically requested immediately after connection to the FTP server.
Section 4-5 Using FTP Commands mkdir Format mkdir DIRECTORY_NAME Function Creates a directory of the specified name at the remote host (Memory Card or EM File Memory). An error will occur if a file or directory of the same name already exists in the working directory. rmdir Format rmdir DIRECTORY_NAME Function Deletes the directory of the specified name from the remote host (Memory Card or EM File Memory). The directory must be empty to delete it.
Section 4-5 Using FTP Commands type Format type data_type Function Specifies the file data type. The following data types are supported: ascii: Files are transferred as ASCII data binary (image): Files are transferred as binary data. All files are treated by the PLC as binary files. Before reading or writing any files, always use the type command to set the file type to binary. File contents cannot be guaranteed if transferred as ASCII data. The default file type is ASCII.
Section 4-5 Using FTP Commands Any existing file with the same name in the remote host (Memory Card or EM File Memory) will be overwritten by the contents of the transferred file. If an error occurs during file transfer, the file being transferred will be deleted and the transmission of that file will end in an error. However, mput execution will continue and remaining files will be transferred.
Section 4-5 Using FTP Commands 4-5-3 Error Messages and FTP Status Error Messages The error messages returned by the Ethernet Unit are listed in the following table. Message PPP is a directory. Meaning The path name indicated at PPP is a directory. PPP is not a directory. Another unit has access authority (FINS error 0 x 3001). The path name indicated at PPP is not a directory. Another Unit currently has the access right. Bad sequence of commands. Can't create data socket (X.X.X.X, YY).
Section 4-6 Checking FTP Status PPP: XXX: YY: MM: NN: 4-6 4-6-1 Path name IP address Port number FINS error code Socket error code Checking FTP Status FTP Status Flag The current status of the FTP server can be obtained from the service status in the words allocated to the Ethernet Unit in the CPU Bus Unit Area in the CIO Area.
Section 4-7 Using File Memory 4-7 Using File Memory There are two media that can be used to store files in memory for CS/CJseries PLCs: • Memory Cards • EM File Memory CPU Unit File Memory Card File File EM File Memory File 4-7-1 File Memory Media CS/CJseries Memory Cards Memory type Flash memory 8 MB EM File Memory RAM 4-7-2 Capacity 15 MB 30 MB Model HMC-EF861 HMC-EF171 HMC-EF371 File data recognized by CPU Unit • Complete user program • Specified portions of I/O Memory • Parameter area dat
Section 4-7 Using File Memory File Names Handled by CPU Unit The files described in the following table can be read or written by the CPU Unit. File type Data file File name ******** Extension Contents .IOM Specified ranges of I/ O Memory Program file ******** .OBJ Parameter area file ******** .STD Files transferred at startup Data files AUTOEXEC .IOM Program files AUTOEXEC .OBJ Parameter area file AUTOEXEC .
Section 4-7 Using File Memory 4-7-3 Initializing File Memory Memory Memory Cards Initialization method 1. Insert the Memory Card into the CPU Unit. 2. Initialize the Memory Card from a Programming Device (Programming Consoles included). EM File Mem- 1. Specify in the PLC Setup the first bank to convert to file memory. ory 2. Initialize EM File Memory from the CX-Programmer.
Section 4-7 Using File Memory I/O memory +0 +0 +10 +1 1234 5678 9ABC DEF0 +2 +3 9ABC DEF0 1234 +4 +5 1234 5678 +6 +7 9ABC DEF0 5678 9ABC DEF0 1234 +8 +9 1234 5678 5678 9ABC DEF0 .TXT file contents 31 32 33 34 09 35 36 37 38 09 39 41 42 43 09 1 2 3 4 [HT] 5 6 7 8 [HT] 9 A B C [HT] 35 36 37 38 0D 0A 39 41 42 43 09 5 6 7 8 [CR][LF] 9 A B C [HT] .
Section 4-7 Using File Memory I/O memory +0 +0 +10 +1 1234 +2 5678 +3 9ABC DEF0 9ABC DEF0 1234 +4 +5 1234 5678 +6 +7 9ABC DEF0 5678 9ABC DEF0 1234 +8 +9 1234 5678 5678 9ABC DEF0 .CSV file contents 31 32 33 34 2C 35 36 37 38 2C 39 41 42 43 2C 1 2 3 4 , 5 6 7 8 , 9 A B C , 35 36 37 38 0D 0A 39 41 42 43 2C 5 6 7 8 [CR] [LF] 9 A B C , .
Section 4-8 FTP File Transfer Time 4-8 FTP File Transfer Time File transfers using FTP can require 30 or 40 minutes depending on the capacity of the file. Approximate file transfer time are provided in the following table for reference. All times are in seconds unless otherwise specified. ■ CS1 CPU Units/CJ1 CPU Units File system Memory Card EM File Memory CPU Unit status Operating mode PROGRAM Cycle time --- RUN 20 ms PROGRAM --- RUN 20 ms Transfers using put 1 KB 30 KB 0.7 s 4.5 s 6.0 s 38.
Section 4-9 UNIX Application Example 4-9 UNIX Application Example The following procedure provides an example of FTP operations from a UNIX workstation. In this example, the following assumptions are made. • The IP address of the Ethernet Unit is registered in /etc/hosts on the workstation as [cs1]. • The default FTP login name is being used (CONFIDENTIAL). • A processing results data file called RESULT.IOM already exists on the Memory Card in the CPU Unit.
Section 4-9 UNIX Application Example 4. Change to the MEMCARD directory. Change to MEMCARD directory. 5. Change data type to binary. Binary data type set. 6. Transfer the file RESULT.IOM to the workstation. File read. 7. Write the file PLAN.IOM to the Memory Card. File written 8. End FTP. FTP ended.
UNIX Application Example 88 Section 4-9
SECTION 5 Automatic Clock Adjustment Function This section provides an overview of the automatic clock adjustment function, including details on specifications, required settings, operations from CX-Programmer, and troubleshooting. 5-1 5-2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5-1-1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5-1-2 Specifications . . . . . . . .
Section 5-1 Overview 5-1 5-1-1 Overview Overview The Ethernet Unit can obtain the clock information from the SNTP server (see note 1) at a particular time or when a designated bit turns ON and then refresh the internal clock information of the CPU Unit to which it is mounted (referred to as the local CPU Unit). Intranet SNTP server Automatic clock adjustment The clock information can be broadcast to other CPU Units on the same Network.
Section 5-2 Using the Automatic Clock Adjustment Function 5-1-2 Specifications Item Protocol Port number Adjustment timing 5-2 5-2-1 Specification SNTP 123 (UDP) Can also be set from the CX-Programmer in the Unit Setup. Automatic (fixed time) and manual (manual only cannot be set) Access to SNTP server Writes the clock information from the SNTP server to the local CPU Unit.
Section 5-2 Using the Automatic Clock Adjustment Function 5-2-2 Settings Required for Automatic Clock Adjustment Function The following settings must be set in the Unit Setup when using the automatic clock adjustment function. CXProgrammer tab Auto Adjust Time Settings Server specification type Setting conditions Required. Reference 5-2-3 Auto Adjust Time on page 93 IP Address Host name One or the other is required, depending on the Server specification type setting. Port No. Rarely required.
Using the Automatic Clock Adjustment Function 5-2-3 Section 5-2 Auto Adjust Time The contents in the CPU Bus Unit System Setup that are set for using mail send and receive functions are shown in the CX-Programmer’s Unit Setup. Item Get the time information from the SNTP server Contents Enable to set the CPU Unit's clock to the time at the SNTP server's clock. The clock can be changed only for the CPU Unit to which the Ethernet Unit is mounted.
Section 5-3 Automatic Clock Adjustment Switch 5-3 Automatic Clock Adjustment Switch The Automatic Clock Adjustment Switch is allocated in the CIO Area as shown below. The first word n of the CIO Area is calculated using the following equation. n = CIO 1500 + (25 × unit number) Automatic Clock Adjustment Switch (Bit 04 of n) The Unit control bit is shown in the following diagram.
Section 5-4 Automatic Clock Adjustment Error Processing Note 5-4-3 For details on other error log information, refer to the Operation Manual, Construction of Networks: SECTION 8 Troubleshooting. Error Log Error Codes for the Automatic Clock Adjustment Function When an error occurs while the Ethernet Unit is operating, the error code, detailed error code, and time the error occurred are saved in the error log. The following table provides a list of the error codes.
Section 5-4 Automatic Clock Adjustment Error Processing Error code 03C6 Note Meaning Detailed error code 1st byte 2nd byte Correction EEPROM Clock data write error 0001: Clock data could not be refreshed because of a CPU Unit error. Clear the CPU Unit error. 0002: Clock data could not be refreshed because the CPU Unit could not write clock data in that operation mode.
SECTION 6 Socket Services This section describes the functionality provided by the Ethernet Unit via the socket services. 6-1 6-2 6-3 6-4 6-5 6-6 6-7 Overview of Socket Communications from Ethernet Units . . . . . . . . . . . . . . 99 6-1-1 What are Sockets?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 6-1-2 Socket Port Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Protocol Overview. . . . . . . . . . . . . . . . . . . .
6-8 6-9 98 Using Socket Services with CMND(490) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 6-8-1 Using Socket Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 6-8-2 Socket Services and Socket Status . . . . . . . . . . . . . . . . . . . . . . . . . . 137 6-8-3 Basic FINS Command Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 6-8-4 Response Codes in the Command Response. . . . . . . . . . . . . . . . . . .
Section 6-1 Overview of Socket Communications from Ethernet Units 6-1 6-1-1 Overview of Socket Communications from Ethernet Units What are Sockets? Sockets are interfaces that allow TCP and UDP protocols to be used directly from the user program. With personal computers, socket are provided as C language interface libraries, which allow TCP or UDP protocols to be programming using library functions. With UNIX computers, socket interfaces are supported in the form of system calls.
Section 6-2 Protocol Overview 6-2 6-2-1 Protocol Overview Differences between TCP and UDP There are differences in the socket services between TCP and UDP. ■ TCP Communications The following procedure is followed each time data is transmitted to ensure that the data arrives normally at the remote node: 1,2,3... 1. The remote node returns ACK when data is received normally. 2.
Section 6-2 Protocol Overview ■ Passive OPEN and Active OPEN An open command is executed for a node to establish a connection. The open method differs depending on whether the node is a client or server. A passive open method is used to open the node as a server and the active open method is used to open the node as a client. Client TCP socket Active open Passive open Server TCP socket Connection Note 1.
Section 6-2 Protocol Overview 6-2-3 Fragmentation of Send Data The Ethernet Unit fragments data for TCP transmission into units of 1,024 bytes and data for UDP transmission into units of 1,472 bytes. TCP requires one reception request to receive each unit of data. UDP, however, restores the original data before passing it to the user process, allowing all the data in a single transmission to be received with one reception request.
Section 6-3 Overview 3. Data A and Data B are sent consecutively. 4. When the receiving user program sends a request to receive 1,984 bytes of data, Data A and Data B are linked to restore the original data, which is passed to the user program. Ethernet Unit Sending User Program 1. Send request 1,984bytes 1,472 bytes Source data Data A Receiving Node Receiving User Program 4. First receive request 1,984 bytes Data A Data B Data B 512 bytes 2. 3.
Section 6-3 Overview The two methods of using the socket services are as follows: • Dedicated Control Bits (Socket Service Request Switches) Requests can be made to a socket service by setting parameters and then merely manipulating specific Socket Service Request Switches. • CMND(490) Requests can be made to a socket service by sending service request commands to the Ethernet Unit.
Section 6-3 Overview reception, data is received to the send/receive data addresses set in the parameter area. 6-3-3 Using Socket Services with CMND(490) Service request commands can be sent to the Ethernet Unit by executing the CMND(490) instruction in the ladder diagram. CS/CJ Ethernet Units support the same functionality as the CVM1/CV-series Ethernet Unit, so heritage programs can be easily corrected and reused. Up to 16 sockets can be connected using CMND(490): 8 UDP sockets and 8 TCP sockets.
Section 6-4 Socket Service Function Guide 6-3-5 Differences with Previous Models Compared with the socket service functions of previous models (CS1WETN01/11 and CJ1W-ETN11 Ethernet Units), the Number of Bytes Received at the TCP Socket that stores the size of received data accumulated in the reception buffer and a related Data Received Flag have been added.
Section 6-5 Using Socket Service Functions 6-5 6-5-1 Using Socket Service Functions Procedure 1. Make the basic settings. Refer to SECTION 2 Startup Procedure in the Operation Manual Construction of Networks. ↓ 2. Use the CX-Programmer or Programming Console to make the socket service settings in the socket service parameter areas 1 to 8 (m+18 to m+88) allocated in the DM Area. Note: The first word m in the allocated DM Area = D30000 + (100 × unit number) ↓ 3.
Section 6-5 Using Socket Service Functions 6-5-3 Setup Tab The CPU Bus Unit System Setup, which is set when using socket services, is shown in the CX-Programmer's Unit Setup Window. . ■ Setup Item Broadcast Details Default value Set the method for specifying IP address All 1 (4.3BSD) when broadcasting with FINS/UDP. • All 1 (4.3BSD): Broadcast with host number set to all ones. • All 0 (4.2BSD): Broadcast with host number set to all zeros. For normal operations use the default: All 1 (4.
Using Socket Service Functions Section 6-5 Item IP Router Table Details Default value Set when the Ethernet Unit will communi- None cate with nodes in other IP network segments via an IP router. TCP/IP keep-alive Set the liveness checking interval (keep- 0 alive). When using FINS/TCP or TCP/IP (120 min) socket services, if the remote node (server or client) continues idling (no response) for the duration of time set here or longer, the connection will be closed.
Section 6-6 Socket Service Status 6-6 6-6-1 Socket Service Status CIO Area Allocations The following CIO Area words are allocated in the CPU Bus Unit Area in the CIO Area starting at word n+ 1. The value of n can be calculated from the unit number as follows: Beginning word n = CIO 1500 + (25 x unit number) ■ UDP/TCP Socket Status (Ethernet Unit to CPU Unit) The status of the UDP and TCP sockets is provided in the socket status words shown in the following diagram.
Section 6-6 Socket Service Status 15 14 13 12 11 10 9 8 7 6 5 4 - - - - - - - - - 3 2 1 0 Data Received/Requested Flag Opening Flag Results Storage Flag Receiving Flag TCP Connection/UDP Open Flag Sending Flag Closing Flag Bit Opening Flag Status Manipulated Unit operation by ON Unit Turns ON when an open request is received. Receiving Flag OFF ON Turns OFF when open processing has been completed. Turns ON when a receive request is received.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Up to 4,096 bytes of data are stored in the reception buffer, but the value stored is within the range (maximum: 1,984 bytes) that can be set by manipulating the control bits or sending the receive request in the CMND(490) instruction.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits m = D30000 + (100 x unit number) CPU Bus Unit Area in the DM Area 15 0 m+18 Socket Service Parameter Area 1 Parameters Socket option UDP/TCP socket No. Local UDP/TCP port No. Remote IP address m+28 Socket Service Parameter Area 2 Remote UDP/TCP port No. Number of bytes to send/receive Send/Receive data address m+88 Time out time Socket Service Parameter Area 8 Response code 2.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Start UDP Open. Program Flow Error Evaluation Check TCP Connection/UDP Open Flag. OFF? Is Bit 15 (Open Flag) in the socket status word for the socket being used OFF? (Checks to see if the socket is open before communications and close processing.) NO The specified UDP socket is already open. YES Turn ON UDP Open Request Switch.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits 6-7-3 Socket Service Parameters The Socket Service Parameter Areas in which parameters are set to request socket services are in the CPU Bus Unit Area in the DM Area of the CPU Unit. The Socket Service Parameter Areas are allocated as shown in the following diagrams.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Parameter Settings The following table shows the parameters that are required for each service and the use of the parameters by the socket service. UDP Socket Services Parameter No. of words Socket option UDP/TCP socket No. 1 Local UDP/TCP port No. 1 Remote IP address 2 Remote UDP/TCP port No.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits R: ---: 6-7-4 Read by user for results at completion Not used. Parameters ■ Socket Option For the TCP OPEN REQUEST (ACTIVE or PASSIVE) command, specifies whether or not the keep-alive function is to be used. When the keep-alive function is used, bit 8 is ON (set to 1). ■ UDP/TCP Socket No. Specify the number of the UDP or TCP socket to open. ■ Local UDP/TCP Port No.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits If the Remote IP Address is set to 0, a connection can be made to any remote node and the remote IP address of the node that is connected will be stored as the Remote IP Address in the Socket Service Parameter Area. If a specific remote I/O address is set, then a connection can be made only to the node with the specified address. If the Remote TCP Port No.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits 6-7-5 Socket Service Request Switches Dedicated control bits can be manipulated to request socket services. These bits are called Socket Service Request Switches, and are turned ON in the CPU Unit to request socket services through the Ethernet Unit. The Socket Service Request Switches are allocated in the CPU Bus Unit Area in the CIO Area starting at the word n + 19.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Bit 13 5 Switch Status Manipulated Unit operation by ON User Close processing executed when switch is turned ON. (The protocol (TCP/UDP) is determined when the socket is opened.) Close Request Switch OFF Unit Unit turns OFF switch when close processing has been completed. As shown in the above table, the Request Switches are turned OFF by the Ethernet Unit when the requested processes has been completed.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Response code 1103 Meaning The bit number in the Send/Receive Data Address is not 00. 110C 220F Request Switch turned ON during other processing. Specified socket is already processing a receive request. 2210 2211 The specified socket is not open. Unit is busy; cannot execute service. 2607 Specified Socket Service Parameter Area is already being used for another socket.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits TCP Socket Passive Open Request Response code 0000 Normal end 0105 0302 Local IP address setting error. CPU Unit error; cannot execute. 1100 110C TCP socket number is not 1 to 8 or local TCP port number is 0. Request Switch turned ON during other processing. 220F Specified socket is already open or already processing an open request. Unit is busy; cannot execute.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Response code 000D Meaning Remote IP address parameter error (EACCES). 003E Internal buffer cannot be obtained due to high reception traffic (ENOBUFS). 0042 (See note.) Error (EMSGSIZE). 0044 0045 ICMP data received (ENOPROTOOPT). Error in communications with remote node (ECONNABORTED). 0049 The same port number has been specified more than once (EADDRINUSE).
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Response code 004F (See note.) 0051 (See note.) 0053 Meaning Error in communications with remote host (ETIMEDOUT). 0066 0080 Internal memory cannot be obtained; cannot execute. Receive request timed out. 0081 The specified socket was closed during receive processing. ICMP data received (EHOSTDOWN). ICMP data received (EHOSTUNREACH). Note These response codes will be returned only on large, multilevel networks.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits TCP Socket Close Request 6-7-7 Response code 0000 Meaning Normal end 0302 2210 CPU Unit error; cannot execute. The specified socket is not been connected. 2211 2607 Unit is busy; cannot execute. Specified Socket Service Parameter Area is already being used for another socket.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Close Request Switch The processing results are stored as the response code when the Close Request Switch is used. There will always be one PLC cycle time between turning OFF the Request Switch for the canceled process and turning of the Close Request Switch, allowing time for the response code to be read.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits 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 communications. System Configuration The programming example uses the following system configuration.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Program Memory Map The send and receive data and bits (flags) used by the program are shown in the following diagram.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Programming Example 000000 @RSET 000100 @SET TCP Passive Open When the TCP Open Bit (CIO 000000) turns ON, the TCP Open Error Flag (CIO 000100) is turned OFF and the TCP Opening Flag (CIO 000200) is turned ON to initialize processing.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Continued from previous page. 000001 000201 151905 SET <>(305) 000101 D30027 000001 000201 #0000 151905 TCP Send When the TCP Send Bit (CIO 000002) turns ON, the TCP Send Error Flag (CIO 000102) is turned OFF and the TCP Sending Flag (CIO 000202) is turned ON to initialize processing.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Continued from previous page. 000003 000203 MOV(21) #0001 D30018 MOV(21) #0064 D30023 When the TCP Receiving Flag (CIO 000203) turns ON, the following parameters are written to the parameter area for socket number 1. D30018: 0001 Hex = UDP/TCP socket No. 1 D30023: 0064 Hex = No. of send/receive bytes is 100 D30024 and D30025: 8203 E800 Hex = Send/receive data address D01000 D30026: 0000 Hex = No timeout time.
Section 6-7 Using Socket Services by Manipulating Dedicated Control Bits Basic Operations • CIO 000000 is turned ON to request opening a UDP socket from the Ethernet Unit. • CIO 000001 is turned ON to request closing the UDP socket from the Ethernet Unit. • CIO 000002 is turned ON to request sending data from the Ethernet Unit. The data is sent (100 bytes) beginning from word D00000. • CIO 000003 is turned ON to request receiving data from the Ethernet Unit.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Programming Example 000000 @RSET 000100 @SET UDP Open When the UDP Open Bit (CIO 000000) turns ON, the UDP Open Error Flag (CIO 000100) is turned OFF and the UDP Opening Flag (CIO 000200) is turned ON to initialize processing. 000200 000000 000200 MOV(21) #0001 D30018 MOV(21) When the UDP Opening Flag (CIO 000200) turns ON, the following parameters are written to the parameter area for socket number 1.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Continued from previous page. 000002 000202 MOV(21) #0001 D30018 MOV(21) #C424 D30020 MOV(21) #2037 When the UDP Sending Flag (CIO 000202) turns ON, the following parameters are written to the parameter area for socket number 1. D30018: 0001 Hex = UDP/TCP socket No. 1 D30020 and D30021: C424 2037 Hex = Remote IP address 196.36.32.55 D30022: 1000 Hex = Remote UDP/TCP port No. 4096 D30023: 0064 Hex = No.
Using Socket Services by Manipulating Dedicated Control Bits Section 6-7 Continued from previous page. 000003 000203 MOV(21) #0001 D30018 MOV(21) #0064 D30023 When the UDP Receiving Flag (CIO 000203) turns ON, the following parameters are written to the parameter area for socket number 1. D30018: 0001 Hex = UDP/TCP socket No. 1 D30023: 0064 Hex = No. of send/receive bytes is 100 D30024 and D30025: 8203 E800 Hex = Send/receive data address D01000 D30026: 0000 Hex = No timeout time.
Section 6-8 Using Socket Services with CMND(490) 6-8 6-8-1 Using Socket Services with CMND(490) Using Socket Service Each Ethernet Unit has eight TCP sockets and eight UDP sockets. Open, close, send, and receive processes are available for communications with sockets. Open Enables communications on a specified socket. A socket must be opened before it can be used for socket services. Opening a TCP socket establishes a connection. Close Ends use of the socket. Breaks the connection for a TCP socket.
Section 6-8 Using Socket Services with CMND(490) CPU Ethernet Unit Other node Communications 4. When the process has been completed, the result is stored in the results storage area defined in the socket service request command and the socket status will indicate completion of processing.
Section 6-8 Using Socket Services with CMND(490) Start UDP Open Program Flow Error Evaluation Check socket status. OFF? Is Bit 15 (Open Flag) in the socket status word for the socket being used OFF? (Checks to see if the socket is open before communications and close processing.) NO The specified UDP socket is already open. NO The specified port is running network communications. NO An error occurred. The Ethernet Unit did not receive the UDP OPEN REQUEST command.
Section 6-8 Using Socket Services with CMND(490) Note If there is more than one Communications Unit mounted to the PLC, the FINS network address must be set as a parameter for CMND(490) and a local network table must be created in the routing tables from the CX-Programmer. 6-8-4 Response Codes in the Command Response A response code is returned in the command response as a 2-byte code that indicates the results of command execution.
Section 6-8 Using Socket Services with CMND(490) ■ CLOSE REQUEST 1 0 Port Enabled Flag Running Running Error response code CMND(490) response code Normal response code 1 0 Close Flag 1 0 Closing Flag Store normal response code Results storage area CLOSE REQUEST command received ■ Error end CLOSE REQUEST command received Normal end SEND REQUEST Port Enabled Flag 1 0 Running Running Normal response code Error response code CMND(490) response code Send Flag 1 0 Opening Flag 1 0 St
Section 6-8 Using Socket Services with CMND(490) ■ CLOSE REQUEST during RECEIVE REQUEST RECEIVE REQUEST command received Port Enabled Flag 1 0 Running CMND(490) (RECEIVE REQUEST) response command CLOSE REQUEST command received Running Normal response code CMND(490) (CLOSE REQUEST) response command Normal response code Receive Flag 1 0 Close Flag 1 0 Opening Flag 1 0 Results storage area for RECEIVE REQUEST Store error response code Results storage area for CLOSE REQUEST Store normal res
Section 6-8 Using Socket Services with CMND(490) Data Flow The data will flow between the CPU Unit, Ethernet Unit, and host computer as shown in the following diagram. Host computer Line (Ethernet) (4) Sent to line.
Section 6-8 Using Socket Services with CMND(490) Program Memory Maps The send and receive data and bits (flags) used by the program are shown in the following diagrams. The following example shows how the memory maps are structured. Legend Describes the meaning of the data. 0 D0000 1 2 CMND(490) control data 0012H 0004H 0001H 00 Indicates the contents of D00001 is 0004 Hex. Indicates the contents of D00000 is 0012 Hex.
Section 6-8 Using Socket Services with CMND(490) 0 1 2 3 4 5 6 7 8 9 CMND(490) control data for TCP RECEIVE REQUEST D00030 000CH 0004H 0001H 0110H 0000H 0032H Number bytes to receive: 4 bytes Number of TCP RECEIVE REQUEST command data bytes: 12 bytes (000Chex) Number of bytes received specified in command data.
Section 6-8 Using Socket Services with CMND(490) 0 D01040 1 2 3 4 5 6 7 8 9 6 7 8 9 TCP CLOSE REQUEST response Re- 2714H sponse code D01050 TCP CLOSE REQUEST results storage area Response code 0 D02000 1 2 3 4 5 TCP SEND REQUEST command data Send data: 100 bytes (0064hex) 2713H 0001H 820BH C200H 0064H No.
Section 6-8 Using Socket Services with CMND(490) CIO Area 15 to 8 6 5 4 3 2 1 0 CIO 0000 TCP TCP Receive Send Bit Bit TCP Close Bit TCP Open Bit CIO 0001 TCP Receive Error Flag TCP Send Error Flag TCP Close Error Flag TCP Open Error Flag CIO 0002 146 7 TCP TCP TCP TCP Receiving Sending Closing Opening Flag Flag Flag Flag
Section 6-8 Using Socket Services with CMND(490) Programming Example 000000 @RSET 000100 @SET TCP Passive Open When the TCP Open Bit (CIO 000000) turns ON, the TCP Open Error Flag (CIO 000100) is turned OFF and the TCP Opening Flag (CIO 000200) is turned ON to initialize processing.
Section 6-8 Using Socket Services with CMND(490) Continued from previous page. 000002 @RSET 000102 TCP Send When the TCP Send Bit (CIO 000002) turns ON, the TCP Send Error Flag (CIO 000102) is turned OFF and the TCP Sending Flag (CIO 000202) is turned ON to initialize processing.
Section 6-8 Using Socket Services with CMND(490) 6-8-9 UDP/IP Communications Programming Example The following programming example illustrates transferring 100 bytes of data between an Ethernet Unit and a host computer using UDP/IP communications. For the UDP connection, the Ethernet Unit uses a PASSIVE OPEN and the host computer uses an ACTIVE OPEN. System Configuration The system configuration for the program example and the Ethernet Unit system setup are shown below.
Section 6-8 Using Socket Services with CMND(490) Program Memory Maps The send and receive data and bits (flags) used by the program are shown in the following diagrams.
Section 6-8 Using Socket Services with CMND(490) 0 D01010 1 2 3 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 UDP OPEN response Re- 2701H sponse code Stores the response after command execution.
Section 6-8 Using Socket Services with CMND(490) 0 D03000 D03010 1 3 4 5 6 7 8 9 6 7 8 9 UDP SEND REQUEST response Response 2703H code UDP SEND REQUEST results storage area Response code No. of send bytes 0 D04000 2 1 2 3 4 5 UDP RECEIVE REQUEST command data 2702H 0001H 820FH B400H 0064H 0000H Timeout value: Not set No.
Section 6-8 Using Socket Services with CMND(490) Programming Example 000000 @RSET 000100 UDP Passive Open When the UDP Open Bit (CIO 000000) turns ON, the UDP Open Error Flag (CIO 000100) is turned OFF and the UDP Opening Flag (CIO 000200) is turned ON to initialize processing.
Section 6-8 Using Socket Services with CMND(490) Continued from previous page. 000002 @RSET 000102 @SET D02000 When the UDP Sending Flag (CIO 000202) turns ON, the status of the Port Enabled Flag (A20200) is checked to be sure it is ON and a UDP SEND REQUEST command is sent using CMND(490). D02000: First command word D03000: First response word D00020: First control data word D03000 The UDP Sending Flag (CIO 000202) is also turned OFF.
Precautions in Using Socket Services 6-9 6-9-1 Section 6-9 Precautions in Using Socket Services UDP and TCP Socket Services • If a short response monitor time is specified in CMND(490) control data and the Ethernet Unit is operating under a high load, a result may be stored even if the response code indicates a time-out. If this occurs, increase the monitor time specified with CMND(490). • The socket status area in the CIO Area is zeroed when the PLC’s operating mode is changed (e.g.
Precautions in Using Socket Services Section 6-9 • Data can remain in a buffer at the local node if the remote TCP socket closes during communications. Any data remaining in the buffer will be discarded when the TCP socket is closed. To avoid problems of this nature, steps will have to be taken in the application program, such as sending data to enable closing, and then only closing once reception of this data has been confirmed.
Precautions in Using Socket Services 6-9-5 Section 6-9 Maximum Transmission Delays (Ignoring other Network Delays) The transmission delays for socket service is calculated as the sum of the communications processing times for both nodes.
Section 6-9 Precautions in Using Socket Services Note 4: When the CPU Unit cycle time is less than 2 ms, A = 27, and when it is 2 ms or more, A = 53 Note 1. The values obtained from the above equations are guidelines for the transmission delay time when one socket in the Ethernet Unit is used only. The execution time required for the user program is not included. 2. The communications time for the remote nodes depends on the device being used.
SECTION 7 Using FINS Communications to Create Host Applications This section provides information on communicating on Ethernet Systems and interconnected networks using FINS commands. The information provided in the section deals only with FINS communications in reference to Ethernet Units. FINS commands issued from a PLC are sent via the SEND(090), RECV(098), and CMND(490) instructions programmed into the user ladder-diagram program.
Section 7-1 Overview of FINS Communications 7-1 7-1-1 Overview of FINS Communications Communications On an Ethernet Network Data is sent and received as UDP packets or UDP packets on an Ethernet network. PLC or host computer Ethernet Unit UDP packet (FINS command) Ethernet UDP packet (FINS response) Ethernet Unit PLC In the FINS communications service, both an IP address for IP (the Internet layer) and a FINS node address for FINS (the application layer) are used for the remote device.
Section 7-1 Overview of FINS Communications 7-1-2 Using the FINS/UDP and FINS/TCP Methods It is recommended that FINS/UDP and FINS/TCP be used as follows: • When remote devices do not support the FINS/TCP method: Use the FINS/UDP method for FINS communications with those devices. • When FINS nodes are connected on the same Ethernet segment: Use the FINS/UDP method between those nodes. Note FINS/UDP offers a slight advantage in performance.
Section 7-2 FINS Frames 7-2 FINS Frames The FINS communications service is carried out through the exchange of FINS command frames and their corresponding response frames. (There are also commands with no responses.) Both command frames and response frames are comprised of a FINS header for storing transfer control information, a FINS command field for storing a command, and a FINS parameter/data field for storing command parameters and transmission/response data.
Section 7-3 FINS/UDP Method RSV (Reserved by System) Set to 00 (Hex). GCT (Permissible Number of Gateways) Set to 02 (Hex). DNA (Destination Network Address) Specifies the number of the network where the destination node is located. The address can be specified in the following range. 00 (Hex): Local network 01 to 7F (Hex): Destination network address (1 to 127) DA1 (Destination Node Address Specifies the number of the node where the command is being sent.
Section 7-3 FINS/UDP Method Node Node Data transmission 1 Data transmission 2 Data transmission 3 Data is sent in one direction, with no confirmation of whether the data was received. Because there are few procedures involved, data can be sent at high speed but with less reliability than with TCP. The FINS/UDP method has the following features: • Because FINS/UDP is a connectionless protocol, there is no limit to the number of corrections. • FINS/UDP can be used for broadcasting.
Section 7-3 FINS/UDP Method The UDP port number for the host application (e.g., personal computer) functions differently from the ports that can be used depending on the setting for the address conversion method at the Ethernet Unit. Basically, the same number can be used for the UDP port number set in the Ethernet Unit (default: 9600), but the number does not need to be the same as the Ethernet Unit under the following application conditions.
Section 7-3 FINS/UDP Method It is not necessary to set routing tables if one Communications Unit is mounted to the PLC and the nodes are connected as one network. For details on routing table, refer to the section on Creating Routing Tables in the Operation Manual, Construction of Networks: Section 6 FINS Communications. 7-3-2 Sending Commands from a Host Computer When sending FINS commands from a computer, the command data in the computer’s program must be created in command frame format.
FINS/UDP Method Section 7-3 UDP port number: FINS UDP port number (Ethernet Unit of relay node) FINS addresses (Remote node CPU Unit): Network address: 2 Node address: 1 Unit number: 0 FINS addresses (Host computer): Network address: 1 Node address: 50 Unit number: 0 FINS/UDP Sample Program Operation Overview • This program reads 150 words of the PLC memory beginning at D00100 by sending a FINS command (MEMORY AREA READ, command code 0101) from a UNIX workstation (WS) to the PLC on the Ethernet network.
Section 7-3 FINS/UDP Method Sample Program 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 #define FINS_UDP_PORT 9600 9 #define SERV_IP_ADDR "196.36.32.
FINS/UDP Method Section 7-3 32 /* ALLOCATE IP ADDRESS AND PORT # TO SOCKET*/ 33 bzero((char *) & s_addr,sizeof(ws_addr)); 34 ws_addr.sin_family = AF_INET; 35 ws_addr.sin_addr.s_addr = htonl(INADDR_ANY); 36 ws_addr.
Section 7-3 FINS/UDP Method 85 /* RECEIVE FINS RESPONSE*/ 86 addrlen = sizeof(cs_addr); 87 88 if ((recvlen = recvfrom(sockfd,fins_resp,MAX_MSG,0,&cs_addr,&addrlen)) < 0) 89 { 90 if (errno == EINTR) 91 goto CMND_SEND; /* RE-SEND FINS COMMAND*/ 92 err_exit("receive error"); 93 } 94 else 95 { 96 alarm(0); /* STOP RESPONSE MONITOR TIMER*/ 97 printf("recv length %d¥n",recvlen); 98 99 if (recvlen < 14) /* ILLEGAL RESPONSE LENGTH CHECK*/ 100 err_exit("FINS length error"); 101 if ((fins_cmnd[3] != fins_resp[6]) |
Section 7-4 FINS/TCP Method 7-4 7-4-1 FINS/TCP Method Overview FINS/TCP Features The FINS/TCP method is a FINS communications method that uses the TCP/ IP protocol. TCP/IP is a connection-type communications protocol. Before a message is sent from one node to another, it is necessary to establish a virtual circuit, i.e., a connection. Once a connection has been established, communications are quite reliable.
Section 7-4 FINS/TCP Method • Once a FINS/TCP connection (connection number, remote IP address) has been set in the Unit Setup, it can be dynamically changed from the ladder program using a FINS command (i.e., FINS/TCP CONNECTION REMOTE NODE CHANGE REQUEST). FINS/TCP Frame Format Ethernet V.2 The following diagram shows the structure of a TCP packet sent over an Ethernet network.
Section 7-4 FINS/TCP Method FINS/TCP Connection Status (Word n+23) While a connection with a remote node is established, the bit corresponding to the FINS/TCP connection status turns ON in the section of the CPU Bus Unit words allocated in the CIO Area. The bit turns OFF if the connection is terminated by an error in communications with a remote node or a FINS command (i.e., FINS/TCP CONNECTION REMOTE NODE CHANGE REQUEST).
Section 7-4 FINS/TCP Method • If there is no response from the client when the keep-alive function is in effect. • If a command other than FINS FRAME SEND or CONNECTION CONFIRMATION is received from the server, the connection will close after the FINS FRAME SEND ERROR NOTIFICATION command is sent. Even if the connection is closed at the FINS/TCP client, requests continue to be made to the FINS/TCP server every few seconds to open a connection.
Section 7-4 FINS/TCP Method ■ Setting Range for Automatic Allocation of FINS Node Addresses The range of node addresses that can be used as automatically allocated FINS node addresses is set in the Ethernet Unit’s Unit Setup. Normally (default status), node addresses 239 to 254 are allocated to each of the connections 1 to 16. These allocations can be changed, but the default node address setting range should be used if there is no particular reason for changing it.
Section 7-4 FINS/TCP Method Even if the keep-alive function is not specified at the Ethernet Unit, a response is sent for checks sent from other nodes. If the power is turned OFF to the host application (e.g., personal computer) while a connection is established, the connection is no longer required, but will remain open until explicit close processing is performed.
Section 7-4 FINS/TCP Method • When routing tables are used for one or more other nodes on the same network. It is not necessary to set routing tables if one Communications Unit is mounted to the PLC and the nodes are connected as one network. For details on setting routing tables, refer to the section on creating routing tables in Section 6 FINS Communications in the Operation Manual, Construction of Networks.
Section 7-4 FINS/TCP Method When automatically allocated FINS node addresses are set, the client node address automatically allocated at the server is stored in the client node address field. After a connection has been established as a FINS/TCP client or server, do not send this command again. Otherwise, the error code (00000003 hexadecimal: The command is not supported) will be received in the FINS FRAME SEND ERROR NOTIFICATION command and the connection will be terminated.
Section 7-4 FINS/TCP Method Header FINS/TCP header Length Command Error code FINS frame FINS frame Size (bytes) 4 4 4 4 12 to 2,012 (Refer to 7-2 FINS Frames for details.) The details of the above frame are shown in the following table. Item FINS FRAME SEND ERROR NOTIFICATION Command Contents (hexadecimal) Remarks Header Length 46494E53 00000014 to 000007E4 ASCII code: ‘FINS’ 20 to 2020 bytes: Length of data after command.
Section 7-4 FINS/TCP Method After the command is sent, if ACK is returned in the TCP layer by the remote node, the connection that is established is maintained. If RST is returned in the TCP layer by the remote node, the established connection is closed.
Section 7-4 FINS/TCP Method 1,2,3... 1. After the TCP connection is established, the client node address is sent by the client to the server using the FINS NODE ADDRESS DATA SEND (CLIENT TO SERVER) command. 2. The client’s FINS node address (client node address) is obtained from the received command. 3. The server’s node address is sent by the server to the client using the FINS NODE ADDRESS DATA SEND (SERVER TO CLIENT) command. 4. The server’s FINS node address is obtained from the received command. 5.
Section 7-4 FINS/TCP Method Connection Sequence for Automatic Allocation of FINS Node Addresses Server Client accept SYN connect SYN, ACK ACK send A B recv ACK recv D Normal C send E send ACK recv F ACK send connect E F recv Socket interface Message from TCP/IP layer ACK Message from host layer 1,2,3... 1.
Section 7-4 FINS/TCP Method Recovery Connection Sequence when Host Computer (WS) is Stopped by an Error Server Client send A B ACK recv C D accept accept recv send ACK Power interruption E SYN connect SYN, ACK ACK send F G ACK H I send Connection error check RST close recv recv J K FIN send close FIN close ACK connect L Connection is closed using TCP/IP protocol procedure. ACK 1,2,3...
Section 7-4 FINS/TCP Method From step 12 onwards, the connection is established again. Note 7-4-3 When FINS node addresses are automatically allocated, the node address cannot be specified, so the connection remains open until it is closed by the keep-alive function. Sending Commands from a Host Computer When sending FINS commands from a computer, the command data in the computer’s program must be created in command frame format.
Section 7-4 FINS/TCP Method ■ Example 2: Host Computer and Remote Node Connected Via Relay Node (Ethernet Unit) Host computer IP address: 196.36.32.50 FINS network address: 1 FINS node address: 50 FINS unit number: 0 Remote node Relay node IP address: 196.36.32.100 FINS network address: 2 FINS node address: 1 FINS unit number: 0 Ethernet Unit Controller Link Ethernet Controller Link Unit Destination IP Address: 196.36.32.
Section 7-4 FINS/TCP Method Sample Program 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 #define FINS_TCP_PORT 9600 9 #define SERV_IP_ADDR "196.36.32.
Section 7-4 FINS/TCP Method 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 /* ALLOCATE IP ADDRESS AND PORT # TO SOCKET*/ bzero((char *) &ws_addr,sizeof(ws_addr)); ws_addr.sin_family = AF_INET; ws_addr.sin_addr.s_addr = htonl(INADDR_ANY); ws_addr.
Section 7-4 FINS/TCP Method 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 188 else { err_exit("FINS/TCP header send error"); } /*RECEIVE FINS/TCP COMMAND (READ RECEIVE recvlen = 24; if (tcp_recv(sockfd, fins_tcp_header, recvlen) == recvlen) { alarm(0); /*STOP RESPONSE MONITOR TIMER*/ FUNCTIONS)*/ /* CONFIRM WHETHER FINS NODE NUMBER SEND (CLIENT TO SERVE
Section 7-4 FINS/TCP Method 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 alarm(RESP_TIMEOUT); /* START RESPONSE MONITOR TIMER*/ printf("FINS/TCP header send length %d¥n",sendlen); } else { err_exit("FINS/TCP header send error"); } /* SEND FINS COMMAND FRAME*/ /* * GENERATE MEMORY AREA READ COMMAND * (READ 150 WORDS FROM DM 100) */ fins_cmnd
FINS/TCP Method Section 7-4 192 } 193 194 printf("FINS/TCP header receive length %d¥n",recvlen); 195 recvlen = fins_tcp_header[6]; 196 recvlen <<=8; 197 recvlen += fins_tcp_header[7]; 198 recvlen -= 8; /* SUBTRACT LENGTH OF COMMAND & ERROR CODE OF FINS/TCP HEADER*/ 199 printf("FINS/TCP frame receive length %d¥n",recvlen); 200 } 201 else 202 { 203 err_exit("TCP receive error"); 204 } 205 206 /* RECEIVE FINS RESPONSE FRAME*/ 207 if (tcp_recv(sockfd, fins_resp, recvlen) == recvlen) 208 { 209 alarm(0); /* STOP
Section 7-4 FINS/TCP Method 245 int total_len = 0; 246 int recv_len; 247 248 for (;;) 249 { 250 recv_len = recv(sockfd, (char *)buf, len, 0); 251 252 if (recv_len > 0) 253 { 254 if (recv_len < (int)len) 255 { 256 len -= recv_len; 257 buf += recv_len; 258 total_len += recv_len; 259 } 260 else 261 { 262 total_len += recv_len; 263 break; 264 } 265 } 266 else 267 { 268 err_exit("TCP receive error"); 269 total_len = 0; 270 break; 271 } 272 } 273 274 return total_len; 275 276 } 277 278 /* 279 * ERROR PROCESSING
Section 7-5 Maximum Transmission Delays: Writing/Reading to CPU Unit 7-5 Maximum Transmission Delays: Writing/Reading to CPU Unit The time for the response to be received after a remote node on the Ethernet network sends a memory area read or write command to a PLC can be calculated using the following formula.
Section 7-5 Maximum Transmission Delays: Writing/Reading to CPU Unit CPU execution mode Processing time considerations Parallel processing with Set time for peripheral servicing synchronous memory (Default: 4% of CPU Unit cycle time) access Parallel processing with 1 ms max. asynchronous memory access For details, refer to the CPU Unit operation manual. Transmission Processing (Response) Note 0.
Section 7-5 Maximum Transmission Delays: Writing/Reading to CPU Unit For details, refer to the CPU Unit operation manual. CPU Bus Unit Service Processing Time The processing time will be as follows, depending on the CPU processing mode settings at the CPU Unit. CPU execution mode Processing time considerations Normal Mode Priority peripheral servicing 4% of CPU Unit cycle time Ethernet Unit is given Time slice peripheral servicing priority.
Appendix A Ethernet Network Parameters Parameter Value Description TCP send buffer TCP receive buffer 4,096 bytes 4,096 bytes Maximum capacity of the TCP send buffer Maximum capacity of the TCP receive buffer UDP send buffer UDP receive buffer 9,000 bytes 9,016 bytes Maximum capacity of the UDP send buffer Maximum capacity of the UDP receive buffer RAW send buffer RAW receive buffer 2,048 bytes 2,048 bytes Maximum capacity of the RAW send buffer Maximum capacity of the RAW receive buffer FINS r
Ethernet Network Parameters 196 Appendix A
Appendix B Buffer Configuration UDP socket reception request buffers (8 × 9,016 max.) (See note 1.) TCP socket reception request buffers (8 × 4,096 max.) (See note 1.) IP packet input queue (50 max. × 1,500 bytes) CPU Unit FTP service reception buffer (4,096 bytes) FINS processing buffers (192 × 2,020 bytes) FINS reception buffer (16,383 bytes max.) Communications controller Network FINS send buffer (9,000 bytes max.) FTP service send buffer (4,096 bytes) IP packet output queue (50 max.
Buffer Configuration Appendix B Network Memory Most of the buffers used for communications servicing by the Ethernet Unit are administered in a buffer configuration called network memory. Network memory consists of 196K bytes of memory divided into short and long buffers. The use of short and long buffers is determined by the status of the various services when the Ethernet Unit is running. The capacity of all buffers cannot be used due to limits in the mounted memory capacity.
Appendix C TCP Status Transitions The TCP socket status can be confirmed using the socket status data returned for the FINS command SOCKET STATUS READ (2764).
TCP Status Transitions 200 Appendix C
Appendix D ASCII Characters Bits 1 to 4 Bits 5 to 7 Binary Hex 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F 0000 0 NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 0001 1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 0010 2 Space ! ” # $ % & ’ ( ) * + , .
ASCII Characters 202 Appendix D
Appendix E Maintenance The Ethernet Unit makes up part of a network. Repair a defective Ethernet Unit as soon as possible as it can have a negative effect on the entire network. We recommend that customers keep one or more spare Ethernet Units to allow immediate recovery of the network. Replacing an Ethernet Unit Observe the following precautions when replacing the Ethernet Unit. • Always turn OFF the power supply before replacing the Ethernet Unit.
Maintenance 204 Appendix E
Appendix F Inspections Carry out regular inspections to ensure the Ethernet Unit is functioning perfectly. Items Most of the parts that make up an Ethernet Unit are semiconductor components. None of the parts in the Unit will wear out after a specific lifetime, but some parts may deteriorate due to extreme operating condition. Therefore, it is important to inspect the Unit regularly. Inspection Interval Normally inspect once or twice per year.
Inspections 206 Appendix F
Index Numerics 100Base-TX transmission delays, 193 10Base-T transmission delays, 193 A Accessing Memory/Receiving Mail Flag, 60 Accessing Memory/Sending Mail Flag, 25 Account Name field, 6, 19, 39 Adjust Time field, 92, 93 transmission delays, 193 Bit value change field, 23 bits Automatic Clock Adjustment Switch, 94 dedicated control bits, 103 Socket Service Request Switches, 119 Close Request Switch, 120 Send Request Switch, 119 TCP Active Open Request Switch, 119 TCP Passive Open Request Switch, 119 UDP
Index D delete command, 68, 73, 77 dir command, 68, 73, 74 DNS communications, 3 DNS server, 31 automatic clock adjustment errors, 94 DNS Tab, 6, 19, 39, 92 initial settings, 31 E EC Directives, xxvi electromagnetic fields, xxiv EM File Memory, 80 using, 80 E-mail attached files, 16, 17, 35 receiving, 41 body, 16, 17, 36 command line, 37 compression, 17, 37 data sent, 22 decoding, 37 destination e-mail-address, 17 encoding, 17 encryption, 17, 37 errors troubleshooting, 28 Ethernet Unit information, 13 hea
Index FileWrite command, 2, 36 command/response format, 43 FREAD instruction, 26, 60 FileWrite field, 41 FTP indicator, 79 FINS communications, 2, 4 address conversion, 161 application layers, 160 commands CONNECTION CONFIRMATION, 179 FINS FRAME SEND, 178 FINS FRAME SEND ERROR NOTIFICATION, 179 FINS NODE ADDRESS DATA SEND (CLIENT TO SERVER), 177 FINS NODE ADDRESS DATA SEND (SERVER TO CLIENT), 177 FINS frames, 162 format, 162 headers, 162 FINS/TCP method, 160, 171 connection sequences, 180 connection sta
Index I I/O memory data, 15 CSV format, 61 IOM format, 60 TXT format, 61 I/O tables creating, 30 ICF, 162 inspections, 205 installation location, xxiv Interval time field, 20, 24 IO memory data field, 20, 22 IOM field, 41 IOM format, 15, 26 IOMRead command, 2, 35 command/response format, 51 IOMRead field, 41 IOMWrite command, 2, 35 command/response format, 49 IOMWrite field, 41 IP Address field, 5, 7, 19, 39, 92, 93 IP communications IP addresses remote devices, 117 programming examples, 127, 131, 141, 149
Index send timing, 11 sending method (encoding), 17 settings, 19 DNS Tab, 19 Mail Address Tab, 19 POP Tab, 19 SMTP Tab, 19 SMTP settings, 4 status, 17, 24 Send Mail Status 1, 24 Send Mail Status 2, 25 status information, 15 subject, 17 triggers, 13, 17, 18, 23 user-set information, 14 Mail Send Switch, 25 MailLogClear command, 36 command/response format, 57 MailLogClear field, 42 MailLogRead command, 36 command/response format, 56 MailLogRead field, 41 maintenance, 203 inspections, 205 mdelete command, 68,
Index TCP/IP, 4 UDP/IP, 4 Send Error Log information field, 20, 22 Send file data or I/O memory data field, 22 put command, 68, 73, 76, 85 Send Mail Status words, 24, 25 pwd command, 68, 73, 75 Send Mail Tab, 20, 21, 31 Send mail upon trigger field, 22 Q quit command, 68, 73, 77 Send Request Switch, 119 Send status information field, 20, 22 Send user data field, 20, 22 Server access interval time field, 6, 19, 39 R radioactivity, xxiv Server specification type field, 4, 6, 19, 39, 92, 93 Setup Tab,
Index port numbers, 99 TCP status, 199 TCP sockets, 184 number, 117 status, 199 UDP socket number, 117 UDP sockets, 166 Software switch field, 23 specifications FTP server, 68 mail receive function, 36 mail send function, 17 SRES, 139 static electricity, xxiv precautions, xxv STD field, 41 switches Socket Service Request Switches, 119 T TCP Active Open Request Switch, 119 TCP communications comparison with UDP, 100 data fragmentation, 102 precautions, 102 programming example, 127, 141 socket services param
Index 214
Revision History A manual revision code appears as a suffix to the catalog number on the front cover of the manual. Cat. No. W421-E1-03 Revision code The following table outlines the changes made to the manual during each revision. Page numbers refer to the previous version. Revision code 1 02 03 Date Revised content July 2003 March 2004 Original production The following revisions were made. Page xiv: Added information on unit versions.
Revision History 216
OMRON Corporation Control Devices Division H.Q. Shiokoji Horikawa, Shimogyo-ku, Kyoto, 600-8530 Japan Tel: (81)75-344-7109/Fax: (81)75-344-7149 Regional Headquarters OMRON EUROPE B.V. Wegalaan 67-69, NL-2132 JD Hoofddorp The Netherlands Tel: (31)2356-81-300/Fax: (31)2356-81-388 OMRON ELECTRONICS LLC 1 East Commerce Drive, Schaumburg, IL 60173 U.S.A. Tel: (1)847-843-7900/Fax: (1)847-843-8568 OMRON ASIA PACIFIC PTE. LTD.
Authorized Distributor: Cat. No. W421-E1-03 Note: Specifications subject to change without notice This manual is printed on 100% recycled paper.