0% found this document useful (0 votes)
41 views4 pages

MTCP NJ Client E

The document describes the Modbus TCP Client function block for the NJ Controller, detailing its capabilities for read/write operations in accordance with Modbus specifications. It outlines input and output variables, error codes, and precautions for using socket services. The function block is provided 'as is' and users are advised to test its adequacy for their applications.

Uploaded by

juan.barrios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views4 pages

MTCP NJ Client E

The document describes the Modbus TCP Client function block for the NJ Controller, detailing its capabilities for read/write operations in accordance with Modbus specifications. It outlines input and output variables, error codes, and precautions for using socket services. The function block is provided 'as is' and users are advised to test its adequacy for their applications.

Uploaded by

juan.barrios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Function Block

Reference MTCP_NJ_Client OMRON ELECTRONICS S.A.S.


Revision 1.3 14 Rue de Lisbonne
93561 Rosny-sous-Bois cedex
Author JP Viskovic
Date 04/02/2014
+ Support http://support-omron.fr/

Modbus TCP Client for NJ Controller

Function Modbus TCP client for Built-in Ethernet Port of NJ Controller


Connexion

Read/write
Fn

File MTCP_NJ.zip
Function Block MTCP_NJ_Client Modbus TCP Client for NJ Controller

Conditions of The FB Modbus TCP Client provides some read/write features in accordance with
use the specifications defined by the Modbus organization.

The Modbus TCP Client function block is offered 'as is' and may serve as a basis
for development.
Users should previously test its adequacy to the final application.
Omron could not be held responsible in case of malfunction.

Principe The function block MTCP_NJ_Connect establish the connection with a remote
Modbus TCP server when Connect input is activated.
Connected output could allow execution of read/write FB via the Enable input.

List of read/write functions provided :

Code Modbus Function Function Block


0x03 Read Holding Registers MTCP_Client_Fn03
0x05 Write Single Coil MTCP_Client_Fn05
0x06 Write Single Register MTCP_Client_Fn06
0x10 Write Multiple Registers MTCP_Client_Fn10

1- I/O variable of MTCP_Client_Connect

Input Variables
Name type range Description
Enable Bool OFF, ON FB Activation
IPaddress STRING n.n.n.n IP Address of the server
Connect Bool OFF, ON Request to connect to the server

Output Variables
Name type Range Description
Connected Bool OFF, ON ON : Connected to the server
Error Bool OFF, ON Error flag
ErrorID UINT 0 - FFFF Error Code returned by the socket or Modbus
TCP server (see error code list below).
TCP_Socket _sSocket Structure DstAdr, Handle and SrcAdr

Socket_Status _eCONNECTION_STATE

JPV 04/02/2014 Page 2/4


Function Block MTCP_NJ_Client Modbus TCP Client for NJ Controller

2- Input Variables of FB MTCP_Client_Fn03, Fn05, Fn06 and Fn10

MTCP_Client_Fn03 type range Description


Enable Bool OFF, ON FB Activation (use Connected output of FB connect)
TCP_Socket _sSocket structure Handle of the socket used (given by the FB Connect)
Register_Address WORD 0 - FFFF Address of 1rst register
Register_Qty WORD 0 - 00FF Number of registers
Send_Request Bool OFF, ON Read Command

MTCP_Client_Fn05 type range Description


Enable Bool OFF, ON FB Activation (use Connected output of FB connect)
TCP_Socket _sSocket structure Handle of the socket used (given by the FB Connect)
Coil_Address WORD 0 - FFFF Address of the coil
Set_Value Bool OFF, ON ON/OFF value to be written
Send_Request Bool OFF, ON Write command

MTCP_Client_Fn06 type range Description


Enable Bool OFF, ON FB Activation (use Connected output of FB connect)
TCP_Socket _sSocket structure Handle of the socket used (given by the FB Connect)
Register_Address WORD 0 - FFFF Address of the register
Set_Value WORD 0 - FFFF Value to write
Send_Request Bool OFF, ON Write command

MTCP_Client_Fn10 type range Description


Enable Bool OFF, ON FB Activation (use Connected output of FB connect)
TCP_Socket _sSocket structure Handle of the socket used (given by the FB Connect)
Register_Address WORD 0 - FFFF Address of 1rst register
Register_Qty WORD 0 - 00FF Number of registers
Registers ARRAY 0 - FFFF Source of data (Array of 128 WORD)
Send_Request BOOL OFF, ON Write command

3- Output Variables of FB MTCP_Client_Fn03, Fn05, Fn06 and Fn10

Name type Range Description


Cmd_Ok Bool OFF, ON ON : Command executed
Error Bool OFF, ON Execution error flag
ErrorID WORD 0 - FFFF Error Code returned by the socket or Modbus TCP
server (see error code list below).
Register (Fn03 only) ARRAY Read values are returned in an array of 128 WORD

Error Code returned

Code Description
0001 ILLEGAL FUNCTION
Modbus
0002 ILLEGAL DATA ADDRESS
Exception
0003 ILLEGAL DATA VALUE
2000 Local IP Address Setting Error
2001 TCP/UDP Port Already in Use
2002 Address Resolution Failed
2003 Socket Status Error
2004 error Local IP Address Not Set
2006 Socket Timeout
2007 Socket Handle Out of Range
2008 Socket Communications Resource Overflow

JPV 04/02/2014 Page 3/4


Function Block MTCP_NJ_Client Modbus TCP Client for NJ Controller

Precautions in Using Socket Services


9-7-1 Precautions for UDP and TCP Socket Services
• Communications processing are sometimes delayed when multiple functions of the built-in Ether-
Net/IP port are used simultaneously or due to the contents of the user program.
• Communications efficiency is sometimes reduced by high communications traffic on the network line.
• The close processing for a close request instruction discards all of the buffered send and receive data
for the socket. For example, send data from a send request instruction immediately before the close
processing is sometimes not sent.
• After a socket is open, the built-in EtherNet/IP port provides a receive buffer of 9,000 bytes per TCP
socket and 9,000 bytes per UDP socket to enable data to be received at any time. If the receive buffer
is full, data received by that socket is discarded. Make sure that the user application always executes
receive requests to prevent the internal buffer from becoming full.

9-7-2 Precautions for UDP Socket Services


• The destination IP address can be set to a broadcast address for a UDP socket to broadcast data to
all nodes on the network. However, in this case, the maximum length of send data is 1,472 bytes.
Data lengths broken into multiple fragments (1,473 bytes or more in UDP) cannot be sent.
• For UDP socket, controls to confirm the reliability of communications, such as the confirmation of
send data, are not performed. To improve the reliability of communications when you use UDP sockets,
make sure the user program confirms that data is sent and resends data when necessary.

9-7-3 Precautions for TCP Socket Services


• If the TCP socket is closed on the remote node without warning during communications (i.e., if the
connection is closed), the socket at the local node must also be closed. You can use the Read TCP
Socket Status instruction (SktGetTCPstatus) to see if the connection is closed. Immediately close the
socket at the local node if the TCP socket at the remote node is closed.
• If the remote node’s TCP socket closes without warning, the data to send may remain in the buffer at
the local node. The remaining data is discarded in the local node’s TCP close processing. The steps
that are required in applications to avoid this include sending data from the sending node that permits
closing and closing the socket only after checking the remote node.
• While open processing is performed for a TCP socket, a port that was closed first cannot be opened
again for 60 seconds from the time the close processing is performed for the remote socket. However,
this is not true if you specified 0 (automatic assignment by the Unit) as the port for the SktTCPConnect
instruction.
• You can use Connect from another socket to open a connection to a socket that was opened with
Accept. A connection is not opened if you try to use Connect from another socket to open a connection
to a socket that was opened with Connect. Also, a connection is not opened if you attempt to use
Accept from another socket to open a socket that was opened with Accept. Furthermore, you cannot
use Connect from more than one other node to establish multiple connections with a single TCP
socket that was opened with Accept on the built-in EtherNet/IP port.
• You can use the keep-alive function for TCP sockets at the built-in EtherNet/IP port. The keep alive
function checks whether a connection is normally established when no data is sent or received for a
certain period on the communications line where the connection was established. The built-in Ether-
Net/IP port responds to checks from other nodes even if keep alive is not specified.

JPV 04/02/2014 Page 4/4

You might also like