Académique Documents
Professionnel Documents
Culture Documents
FINS Communications
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 PC are sent via the SEND(090), RECV(098), and CMND(490) instructions programmed into
the user ladder-diagram program. Although an outline of these instructions is provided in this section, refer to the CS1-series
CS1G/H-CPUjj-E Programmable Controllers Programming Manual (W340) for further details on programming these
instructions.
5-1
5-2
5-3
5-4
5-5
61
Section
5-1
5-1
UDP header
FINS frame
FCS
PC
or host computer
Ethernet Unit
UDP packet (FINS command)
Ethernet
UDP packet (FINS response)
Ethernet Unit
PC
When a FINS command is issued from the Ethernet Unit, the IP address is found
from the FINS address specified by CMND(490). For details, refer to 3-1 Before
Operation.
Note The UDP/IP protocol does not provide communications control to ensure communications reliability. Consequently, the FINS communications services using
the UDP/IP protocols cannot guarantee that any message arrived safely and unaltered at the destination. Methods to ensure reliability, such as retries and appropriate processing of FINS responses, must be programmed into the user application.
62
Section
5-1
Units and Boards that support FINS commands return responses automatically, so there is no need for a program at the receiving end.
The FINS communications service is mainly used between OMRON CPU Bus
Units, CPU Units, and Support Boards for FA Computers. By correctly setting
information such as headers, however, it can also be used from ordinary Ethernet communications devices.
The FINS communications service can be used from a PC with either of the following three instructions:
SEND(090)/RECV(098)
SEND(090) and RECV(098) are used to send and receive data (area reading and writing).
CMND(490)
CMND(490) is used to send FINS commands. The particular FINS commands that are supported vary depending of the type of Unit or Board. For
details on FINS commands addressed to Ethernet Units, refer to Section 11
FINS Commands Addressed to Ethernet Units. For details regarding FINS
commands addressed to CS1-series CPU Units, refer to the CS1-series
CS1G/H-CPUjj-E Programmable Controllers Communications Commands Reference Manual (W342).
The following table shows how the FINS communications service is used by the
communications source and destination, for PC to PC and host computer to PC.
Local node to remote node
PC to PC
SEND(090)/RECV(098)
CPU Unit
PC
CPU Unit
User program
Host computer to PC
Ethernet Unit
CPU Unit
PC
PC
CPU Unit
When addressed to
CPU Unit
User program
The host computer issues the data for the SEND(090)/RECV(098) or CMND(490) instruction as a UDP datagram. Programs are required for sending data and for receiving
and processing responses.
If the PC receives a SEND(090) or RECV(098) instruction, a program is not required for
processing the instruction.
Ethernet Unit
Host computer
CPU Unit
63
Section
5-2
Start
IP Address Table
Converted from table of correspondences between FINS node
numbers and IP addresses.
Automatic Generation
Automatically converted from
FINS node number.
Combined Method
IP address table is referenced;
if IP address is not registered,
then it is converted from FINS
node number.
Yes
No
Set the FINS UDP port number
for all Ethernet Units on the
Ethernet network to the default
of 9600.
64
5-2
Section
5-3
5-3
5-3-1
Communications Specifications
The following table shows the specifications for PC communications using the
SEND(090), RECV(098), and CMND(490) instructions.
Item
Specifications
Destination
Data length
SEND(090): 990 words (1,980 bytes) max.; broadcasting: 727 words (1,454 bytes)
RECV(098): 990 words (1,980 bytes) max.
CMND(490): 1,990 bytes max.; broadcasting: 1,462 bytes (after FINS command code)
Data contents
The following data is sent and received with the execution of each instruction.
SEND(090): Sends request for remote node to receive data, and receives response data.
RECV(098): Sends request for remote node to send data, and receives response data.
CMND(490): Sends any FINS command and receives response data.
Communications port
number
0000:
2 s (default)
0001 to FFFF: 0.1 to 6,553.5 s in 0.1-s increments (specified by user)
Number of retries
0 to 15 retries
Note
1. The maximum data length is limited to 512 bytes for data exchange between
the PC and SYSMAC LINK Systems or the PC and SYSMAC BUS/2 Remote I/O Systems.
2. When broadcasting, do not require a response.
PC Communications
Data Areas
The following table shows the I/O data areas involved when SEND(090) and
RECV(098) are used.
Area
Note
Range
CIO Area
Work Area
W000 to W511
Holding Area
H000 to H511
Auxiliary Area
Timer Area
TIM0000 to 4095
Counter Area
CNT0000 to 4095
DM Area
D00000 to D32767
EM Area
65
Section
5-3
The SEND(090) instruction sends the data in n number of words, starting from
the beginning word S at the local node, to the words starting from the beginning
word D at the remote destination node (node number N).
Destination node number N
Number
of words
(n)
SSS
SSS
Local node
Number of retries
0 to F (Hex): 0 to 15 retries
CPU Unit
Unit #0 to #15
Unit connected to network
Unit connected to network
Note The message service does not guarantee that a message will reach the destination node. A message may be lost during transmission due to factors such as
noise. To prevent this from occurring when using message services, it is common to set up retry processing at the node from which instructions are issued.
With the SEND(090), RECV(098), and CMND(490) instructions, retry processing is executed automatically by specifying the number of retries, so specify a
number other than 0.
66
Section
With the RECV(098) instruction, the data in m number of words, starting from the
beginning word S at the remote node (node number M) is received at the words
starting from the beginning word D at the local node.
Remote node number N
Number
of words
(m)
SSS
Local node
SSS
RECV(098)
5-3
Number of retries
0 to F (Hex): 0 to 15 retries
Communications port number: 0 to 7
Response
0: Required.
1: Not required.
Note The message services function does not guarantee that a message will reach
the destination node. A message may be lost during transmission due to factors
such as noise. In order to prevent this from occurring when using message services, it is common to set up retry processing at the node from which instructions
are issued. With the SEND(090), RECV(098), and CMND(490) instructions,
retry processing is executed automatically by specifying the number of retries,
so specify a number other than 0.
67
Section
5-3
The CMND(049) instruction sends n bytes of command data, starting from the
beginning word S at the local node, to the node at node number N. the data in m
number of words, starting from the beginning word S at the remote node (node
number M) is received at the words starting from the beginning word D at the
local node.
CMND(049)
Local node
Command
SSS
SSS
Command
data: n
bytes
Interpretation
Response
Execution
SSS
Response
data: n bytes
CPU Unit
Unit #0 to #15
Inner Board
Unit connected to network
The range of node addresses is different for networks other than Ethernet.
Note The message services function does not guarantee that a message will reach
the destination node. A message may be lost during transmission due to factors
such as noise. In order to prevent this from occurring when using message services, it is common to set up retry processing at the node from which instructions
are issued. With the SEND(090), RECV(098), and CMND(490) instructions,
retry processing is executed automatically by specifying the number of retries,
so specify a number other than 0.
68
Section
5-3
Usage
MR
I/O memory area
access
Name
Function
SR
01
01
01
02
01
03
01
04
01
05
02
01
02
02
02
03
Program
g
area
access
03
03
03
06
07
08
Operating mode
changes
g
04
01
RUN
04
02
STOP
Machine
configuration
fi
i
reading
05
05
01
02
Status reading
g
06
06
01
20
07
01
CLOCK READ
07
02
CLOCK WRITE
Message display
09
20
MESSAGE READ/CLEAR
Access rights
0C
01
0C
02
0C
03
Parameter area
access
69
Section
Command
code
MR
Error log
g
File memory
y
Debugging
70
Name
5-3
Function
SR
21
21
21
22
22
01
02
03
01
02
ERROR CLEAR
ERROR LOG READ
ERROR LOG POINTER CLEAR
FILE NAME READ
SINGLE FILE READ
22
03
22
22
04
05
22
07
FILE COPY
22
22
08
0A
22
0B
PARAMETER AREAFILE
TRANSFER
22
0C
22
23
15
01
CREATE/DELETE DIRECTORY
FORCED SET/RESET
23
02
Section
5-3
Programs incorporating the SEND(090), RECV(098), and CMND(490) instructions are generally created using the Communications Port Enabled Flag and
the Communications Port Error Flag as input conditions. CS1-series CPU Units
have eight communications ports. Only one instruction can be executed at any
given port at one time, however, so the program must not overlap the use of any
of the ports. A program example is provided below.
Communications port
Ethernet Unit
CPU Unit
Instruction 1
Instruction 2
Instruction 3
Instruction 4
Instruction 5
Instruction 6
Instruction 7
Instruction 8
There are eight communications ports, so up to eight communications instructions can be executed
at a time. The number of messages that can be sent or received with a single CPU Bus Unit service, though, is not more than two each for the CPU Unit to the Ethernet Unit and for the Ethernet
Unit to the CPU Unit.
Execution
condition
Communications
Port Enabled Flag
KEEP(011) A
Reset B
Remote Node Network
Participation Flag
Local Node Network
Participation Flag
Operand,
control data
created with
@MOV and
@XFER.
Communications
instructions
@SEND
@RECV
@CMND
Communications
Port Enabled Flag
DIFU(013) B
Communications
Port Error Flag
Send Error Flag display
(Retry can be executed.)
Execution
condition
Communications
Port Enabled Flag
Use exclusive control so that no other communications instructions are started before execution of the
above communications instruction is complete.
Reset D
(Continued in same way.)
71
Section
5-3
The execution status of the SEND(090), RECV(098), and CMND(490) instructions is always reflected by the communications flags (i.e., the Communications
Port Enabled Flag and the Communications Port Error Flag). The CS1-series
CPU Units communications flags are allocated in the Auxiliary Area as shown in
the following table.
Address
Flag
g name
Communications
Port Enabled Flag
Communications
Port Error Flag
Word
A202
A219
Bits
Bit 7: Port 7
Bit 6: Port 6
Bit 5: Port 5
Bit 4: Port 4
Bit 3: Port 3
Bit 2: Port 2
Bit 1: Port 1
Bit 0: Port 0
Bit 7: Port 7
Bit 6: Port 6
Bit 5: Port 5
Bit 4: Port 4
Bit 3: Port 3
Bit 2: Port 2
Bit 1: Port 1
Bit 0: Port 0
Contents
OFF: Execution enabled
(being executed)
ON: Execution disabled
(not being executed)
Note With CS1-series PCs, communications ports 0 to 7 are also used for executing
the PCMR(260) (PROTOCOL MACRO) instruction, so these flags are used in
common for SEND(090), RECV(098), CMND(490), and PCMR(260). While
PCMR(260) is being executed, SEND(090), RECV(098), and CMND(490) cannot be executed at the same communications port.
Communications Port
Completion Codes
The status of a SEND(090), RECV(098), and CMND(490) instruction after execution is reflected as a communications port completion code, in one word (two
bytes) of data as shown in the following table. (The value is 0000 during instruction execution.) The recorded status is saved until execution of the next instruction.
Word
Contents
A203
A204
A205
A206
A207
A208
A209
A210
The meanings of the communications port completion codes are the same as
those for FINS commands and responses. When CMND(490) is used, however,
even if a FINS command has an abnormal completion, it will not be reflected in
the communications port completion code. For details, refer to Communications
Port Error Flag and Completion Codes for CMND(490) below.
Bits 08 to 15 in the communications port completion code correspond to the first
byte of the response code, and bits 00 to 07 correspond to the second byte. For
details, refer to 10-6 Troubleshooting With Response Codes.
72
Section
5-3
Instruction 1
being executed.
Instruction 2
being executed.
Instruction 3
being executed.
73
Section
5-3
Execution
condition (See note)
000000
A20207
120002
S
KEEP
120000
R
120001
120000
@MOV(21)
#000A
D00000
@MOV(21)
Contents
Meaning
#0002
D0000
00
0A
D00001
D0001
00
02
D0002
04
00
D0003
07
05
@MOV(21)
#0400
D00002
@MOV(21)
#0705
D00003
Number of retries = 5
D0004
00
64
@MOV(21)
#0064
D00004
0000
D00010
@SEND(90)
D00010
D00020
D00000
120000
A20207
(See note)
DIFU(13)
120001
120000
A21907
120000
74
Section
5-3
A20207
120000
KEEP
120002
R
120003
120002
@MOV(21)
#0010
D00005
@MOV(21)
Contents
Meaning
#0003
D0005
00
10
D00006
D0006
00
03
D0007
20
00
D0008
07
05
Response required.
Communications port No. used = 7
@MOV(21)
#2000
D00007
@MOV(21)
Number of retries = 5
#0705
D00008
D0009
00
00
@MOV(21)
#0000
D00009
@RECV(98)
A100
2000
D00005
120002
DIFU(13)
120003
120002
A21907
121001
120002
120003
A21907
@XFER(70)
#0016
2000
D00040
Note With CS1-series PCs, the Communications Port Enabled Flags at bits 0 to 7 in
word A202 turn OFF even when the PCMR(260) instruction is being executed
using the ports corresponding to those flags.
5-3-3
Transmission Delays
The methods of computing the maximum time required from execution of the
SEND(090), RECV(098), and CMND(490) instructions until processing is completed are described in this section. These times, however, do not take transmission delay times on the network into account, so they may be increased depending on the conditions under which the instructions are executed.
75
Section
5-3
SEND(090)
The transmission delay for the SEND(090) instruction can be calculated using
the following equation, which is illustrated in the following diagram.
Max. delay =Local node service cycle + local node service processing time +
transmission processing time + reception processing time + remote node service cycle + remote node service processing time +
CPU data set processing time (remote node)
SEND(090) executed
in user program
CPU Bus Unit service cycle (local node)
CPU Bus Unit service processing time (local node)
Transmission processing time
Reception processing time
CPU Bus Unit service cycle (remote node)
CPU Bus Unit service processing time (remote node)
CPU data set processing time (remote node)
Maximum transmission delay
This is the time required to process CPU Bus Units and is approximately 1 ms for
Ethernet Units.
Transmission Processing
Time
Reception Processing
Time
The following example shows calculations for sending 256 words between two
PC nodes using SEND(090). The local nodes CPU cycle time is 10 ms, and the
remote nodes CPU cycle time is 5 ms. Calculations are shown in the following
table.
Item
76
Calculation
PC cycle time = 10 ms
1 ms
6 ms
6 ms
5 ms
1 ms
Total
10 + 1 +6 + 6 + 5 + 1 + 25= 54 ms
25 ms
Section
5-3
RECV(098)
The transmission delay for the RECV(098) instruction can be calculated using
the following equation, which is illustrated in the following diagram.
Max. delay =Local node service cycle + local node service processing time +
transmission processing time (command) + reception processing
time (command) + remote node service cycle + remote node service processing time + CPU data read processing time (remote
node) + remote node service processing time + transmission processing time (response) + reception processing time (response) +
local node service cycle + local node service processing time +
CPU data set processing time (local node)
RECV(098) executed in user program
Service processing
CPU Bus Unit service cycle (remote node)
CPU Bus Unit service processing time (remote node)
Maximum transmission delay
This is the time required to process CPU Bus Units and is approximately 1 ms for
Ethernet Units.
Transmission and
Reception Processing
Times
Command:
Response:
The CPU data read processing time is the integer portion of the minimum cycle
time, which satisfies the following formula.
Number of words transferred x 0.02 + 20 ms < Integer portion of remote node
cycle time
3 ms
Number of words transferred x 0.011 + 3 ms
77
Section
The following example shows calculations for receiving 256 words between two
PC nodes using RECV(098). The local nodes CPU cycle time is 10 ms, and the
remote nodes CPU cycle time is 15 ms. Calculations are shown in the following
table.
Item
5-4
5-4
Calculation
PC cycle time = 10 ms
1 ms
3 ms
Service processing
1 ms
Total
10 + 1 + 3 + 25 + 30 + 1 + 6 + 17 + 25 =
118 ms
78
1. The FINS UDP port number at the Ethernet Unit is set to the default of 9600.
It can be changed in the CPU Bus Unit System Setup, but the same FINS
UDP port number must be set for all of the Ethernet Units on the same Ethernet network.
2. Even if the Ethernet network is comprised of multiple segments, set the
same value for the FINS network number.
Section
5-4
In this example, the host computer and the remote node (Ethernet Unit) are on
the same network. The communications parameters specified from the host
computer would be as follows:
Destination IP Address: 196.36.32.100 (Ethernet Unit of remote node)
UDP port number:
FINS UDP port No. (Ethernet Unit of remote node)
FINS addresses (Remote node CPU Unit):
Network number:
1
Node number:
100
Unit number:
0
FINS addresses (Host computer):
Network number:
1
Node number:
50
Unit number:
0
Host computer
IP address: 196.36.32.50
FINS network/node/unit: 1/50/0 (Hex)
Remote node
IP address: 196.36.32.100
FINS network/node/unit: 1/100/0 (Hex)
Ethernet
Example 2: Internetwork
Addressing
In this example, the host computer and the remote node (Ethernet Unit) are on
different networks, connected by a relay node. The communications parameters
specified from the host computer would be as follows:
Destination IP Address: 196.36.32.100 (Ethernet Unit of relay node)
UDP port number:
FINS UDP port number (Ethernet Unit of relay node)
FINS addresses (Remote node CPU Unit):
Network number:
2
Node number:
1
Unit number:
0
FINS addresses (Host computer):
Network number:
1
Node number:
50
Unit number:
0
Host computer
IP address: 196.36.32.50
FINS network/node/unit: 1/50/0 hex)
Relay node
IP address: 196.36.32.100
Remote node
FINS network/node/unit: 2/1/0 (Hex)
Ethernet Unit
Controller Link
Ethernet
79
Section
5-4
FINS header
FINS command
ICF
RSV
Reserved by system.
GCT
DNA
DA1
DA2
SNA
SA1
SA2
SID
Service ID
MRC
SRC
Sub-request code
Parameter/
data field
FINS parameter/data
Contents
2000 max.
The response code (one byte each for MRES and SRES) for the command is
added at the beginning of the FINS parameter/data field in the response frame.
Size (bytes)
Contents
FINS header
10
FINS command
MRES
SRES
Data
1998 max.
Response data
There are some frames in which
the data length is 0.
80
Section
5-4
This program reads 150 words of the PC memory beginning at D00100 by sending an FINS command (MEMORY AREA READ, command code 0101) from a
UNIX workstation to the PC on the Ethernet network. If no response is received
within two seconds of sending the FINS command, the command will be resent.
Settings
The Ethernet Unit IP address is 196.36.32.100, and the FINS node number is
100. IP address conversion is set to automatic generation.
The workstations IP address is 196.36.32.50 and its FINS node number is 50.
The FINS UDP port number is 9600 (default).
Sample Program
1 #include <errno.h>
2 #include <stdio.h>
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <signal.h>
7
8 #define FINS_UDP_PORT 9600
9 #define SERV_IP_ADDR 196.36.32.100
10 #define MAX_MSG
2010
11 #define RESP_TIMEOUT 2
12
13
14 /*
15 * FINS COMMUNICATIONS SAMPLE PROGRAM
81
82
Section
*/
main(argc,argv)
int
argc;
char *argv[];
{
int
sockfd;
struct sockaddr_in , ws_addr,cv_addr;
char
fins_cmnd[MAX_MSG],fins_resp[MAX_MSG];
int
sendlen,recvlen,addrlen;
char
sid=0;
extern recv_fail();
/*GENERATE UDP SOCKET*/
if((sockfd=socket(AF_INET,SOCK_DGRAM,0))<0)
err_exit(cant open datagram socket);
/*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.sin_port=htons(FINS_UDP_PORT);
if(bind(sockfd,(struct sockaddr*)&ws_addr,sizeof(ws_addr))<0)
err_exit(cant bind local address);
/*
*GENERATE MEMORY AREA READ COMMAND
*(READ 150 WORDS FROM D00100.)
/*
fins_cmnd[0]=0x80; /*ICF*/
fins_cmnd[1]=0x00; /*RSV*/
fins_cmnd[2]=0x02; /*GCT*/
fins_cmnd[3]=0x01; /*DNA*/
fins_cmnd[4]=0x64; /*DA1*/
/*Ethernet Unit FINS NODE NUMBER*/
fins_cmnd[5]=0x00; /*DA2*/
fins_cmnd[6]=0x01; /*SNA*/
fins_cmnd[7]=0x32; /*SA1*/
/*WS FINS NODE NUMBER*/
fins_cmnd[8]=0x00; /*SA2*/
fins_cmnd[9]=++sid; /*SID*/
fins_cmnd[10]=0x01; /*MRC*/
fins_cmnd[11]=0x01; /*SRC*/
fins_cmnd[12]=0x82; /*VARIABLE TYPE: DM*/
fins_cmnd[13]=0x00; /*READ START ADDRESS: 100*/
fins_cmnd[14]=0x64;
fins_cmnd[15]=0x00;
fins_cmnd[16]=0x00; /*WORDS READ: 150*/
fins_cmnd[17]=0x96;
/*SEND FINS COMMAND*/
bzero((char*)&cv_addr,sizeof(cv_addr));
cv_addr.sin_family=AF_INET;
cv_addr.sin_addr.s_addr=inet_addr(SERV_IP_ADDR);
cv_addr.sin_port=htons(FINS_UDP_PORT);
singnal((SIGALRM,recv_fail);
CMND_SEND:
sendlen = 18;
if(sendto(sockfd,fins_cmnd,sendlen,0,&cv_addr,sizeof(cv_addr))
==sendlen){
alarm(RESP_TIMEOUT); /*START RESPONSE MONITOR TIMER*/
printf(send length %dn,sendlen);
{
else{
err_exit(send error);
}
/*RECEIVE FINS RESPONSE*/
5-4
Section
5-4
if((recvlen = recvfrom(sockfd,fins_resp,MAX_MSG,0,&cv_addr,&addrlen))
<0){
if(errno == EINTR)
goto CMND_SEND; /*RE-SEND FINS COMMAND*/
err_exit(receive error);
}
else{
alarm(0); /*STOP RESPONSE MONITOR TIMER*/
printf(recv length %dn,recvlen);
if(recvlen<14) /*ILLEGAL RESPONSE LENGTH CHECK*/
err_exit(FINS length error);
if((fins_cmnd[3]!=fins_resp[6])||(fins_cmnd[4]!=fins_resp[7])
||(fins_cmnd[5]!=fins_resp[8])){ /*DESTINATION ADDRESS CHECK*/
err_exit(illegal source address error);
}
if(fins_cmnd[9]!=fins_resp[9]) /*SID CHECK*/
err_exit(illegal SID error);
}
/*CLOSE SOCKET*/
close(sockfd);
}
/*
* ERROR PROCESSING FUNCTIONS
*/
err_exit(err_msg)
char
*err_msg;
{
printf(client: %s %xn,err_msg,errno);
exit(1);
}
/*
*SIGNAL CAPTURE FUNCTIONS
*/
recv_fail()
{
printf(response timeout error n);
}
Example
1. The transfer time may exceed the calculated value due to the actual operating environment. Factors affecting the transfer time are network traffic, the
window size of each node, Ethernet Unit traffic (e.g., socket services, FTP
server communications, etc.), and the system configuration.
2. The CPU data set processing time is the standard when the peripheral service time is set in the CPU Unit System Setup to the default of 4%. As this
value is increased, the processing time is shortened.
This example shows the calculations for a host computer sending a write command for 256 words to the PC. The standard for the maximum transfer delay
time is as follows when the PCs CPU cycle time is 10 ms.
83
Section
FINS Server
5-5
5-5
FINS Server
The following table shows the FINS commands that can be addressed to the
Ethernet Units. The Ethernet Units automatically send responses for these commands. For details, refer to Section 11 FINS Commands Addressed to Ethernet
Units.
MRC
Name
03
RESET
05
01
06
08
01
01
02
03
02
03
01
02
03
04
10
11
12
13
14
20
50
60
61
62
63
64
65
21
27
84
SRC
04