SICK OPEN TCP RA V1 0 en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Operating Instructions

SICK
Open TCP Connection
Add-On Instruction

SICK_OPEN_CONNECTION AOI for


Logix5000 Controllers

Date: 25.10.2012
SICK Open Connection
Operating Instructions Add-On Instruction

Table of contents
1 About this document........................................................................................................ 3
1.1 Function of this document ............................................................................................ 3
1.2 Target group ................................................................................................................ 3
2 General information ......................................................................................................... 4
2.1 Block specifications...................................................................................................... 5
2.2 Supported PLC systems .............................................................................................. 5
3 Integration of the AOI in RSLogix5000............................................................................ 6
3.1 AOI import.................................................................................................................... 6
3.2 Configuration of the Create Socket message parameter .............................................. 6
3.3 Configuration of the Delete Socket message parameter .............................................. 7
3.4 Configuration of the Open Connection message parameter......................................... 8
3.5 AOI functions ..............................................................................................................10
3.5.1 Connect................................................................................................................10
3.5.2 Disconnect ...........................................................................................................12
3.6 TCP connection loss ...................................................................................................12
3.7 Behavior when error occurs ........................................................................................12
3.8 Parameters .................................................................................................................13
4 Error description .............................................................................................................15
5 Example ...........................................................................................................................16
5.1 Connect ......................................................................................................................16
5.2 Disconnect ..................................................................................................................17

2
SICK Open Connection
Operating Instructions Add-On Instruction

1 About this document


Please read this chapter carefully before working with this documentation and the
SICK_OPEN_CONNECTION Add-On instruction.

1.1 Function of this document


This operating instruction explains how to use the SICK_OPEN_CONNECTION Add-On
instruction.

1.2 Target group


This operating instruction addresses planning engineers, developers and operators of
machines and systems who use TCP to connect a SICK device with a Logix5000 controller.

3
SICK Open Connection
Operating Instructions Add-On Instruction

2 General information
The Add-On Instruction (AOI) “SICK_OPEN_CONNECTION” simplifies the establishment of
a TCP connection between a SICK sensor and an RSLogix5000 controller.

The function block makes it possible create a socket service and open a TCP
connection.

Transactions:
- Create socket
- Open connection
- Close connection

Picture 1 shows the concept behind the Add-On Instruction.

SICK_OPEN_CONNECTION AOI
Message
(CreateSocket)

TCP
(Port 2112) Message Message
Device
(OpenConnection) (DeleteSocket)

Instance Tag

UDT
(SICKTCPData)

Instance Tag

Picture 1: Concept of the SICK_OPEN_CONNECTION AOI

4
SICK Open Connection
Operating Instructions Add-On Instruction

2.1 Block specifications


AOI name: SICK_OPEN_CONNECTION
Version: 1.0
Called UDTs: SICKTCPData
SICKTCPCreateSocket
SICKTCPOpenConnection
Block call: Cyclic
Block language: ST (Structured text)
Used RSLogix version: RSLogix5000 (V20.01.00 (CPR 9 SR 5))

Picture 2: SICK_OPEN_CONNECTION AOI

The AOI works asynchronously, i.e. processing occurs over several PLC cycles.

2.2 Supported PLC systems


The SICK_OPEN_CONNECTION AOI established a TCP connection between a SICK
sensor and the RSLogix5000 controller via a socket interface. The socket interface enables a
Logix5000 controller to communicate via an EtherNet/IP module with Ethernet devices that
do not support the EtherNet/IP application protocol.

Socket services are available with these modules (December 2011):


- 1756-EWEB ControlLogix Ethernet/IP web server module, firmware revision 4.006 or later
- 1768-EWEB CompactLogix™ Ethernet/IP web server module, firmware revision 1.002 or
later
- 1769-L30ER, 1769-L30ERM, 1769-L30ER-NSE, 1769-L33ER,1769-L33ERM, and 1769-
L36ERM CompactLogix controllers, firmware revision 20.011 or later
- 1769-L24ER-QB1B, 1769-L24ER-QBFC1B, 1769-L27ERM-QBFC1B CompactLogix
controllers, firmware revision 20.011 or later
- 1769-L16ER, 1769-L18ER, 1769-L18ERM CompactLogix controllers, firmware revision
20.011 or later

For more information see the Rockwell EtherNet/IP Socket Interface document.

5
SICK Open Connection
Operating Instructions Add-On Instruction

3 Integration of the AOI in RSLogix5000


The integration of the SICK_OPEN_CONNECTION routine into the control environment is
handled via an Add-On Instruction (AOI). This AOI includes a program routine and several
data structures called UDTs. The Add-On Instruction can be used in any one of the Ladder
Diagram, Function Block, or Structured Text language. The appearance of the instruction
conforms to the language in which it is placed.

3.1 AOI import


When importing the Add-On Instruction (“File  Import Component  Add-On Instruction“),
the parameters, local tags, and routines are imported as part of the Add-on instruction. Once
the project has the AOI, you can use it in your program.

Picture 3: Import the SICK_OPEN_CONNECTION AOI

3.2 Configuration of the Create Socket message parameter


The Socket Create service creates an instance of the socket object. The parameter must be
once configured on the “…” button as follows.

Message Type: CIP Generic


Service Type: Socket Create
Service Code: Is automatically set to 16#4B
Instance: 0
Class: Is automatically set to 16#342
Attribute: Is automatically set to 16#0
Source Element: Choose the “CreateSocketSource” tag, defined in the SICKTCPData
UDT. Please note, that the UDT must be instantiated as a controller
tag.
Destination Element: Choose the “CreateSocketDestination” tag, defined in the
SICKTCPData UDT. Please note, that the UDT must be instantiated
as a controller tag.
Path: Communication path of the used EtherNet/IP module
Connected: Clear this checkbox

6
SICK Open Connection
Operating Instructions Add-On Instruction

Picture 4: Configuration of the msgCreateSocket message (Configuration)

Picture 5: Configuration of the msgCreateSocket message (Communication)

3.3 Configuration of the Delete Socket message parameter


The Delete Socket service closes the TCP connection and deletes the socket instance. The
parameter must be once configured on the “…” button as follows.

Message Type: CIP Generic


Service Type: DeleteSocket
Service Code: Is automatically set to 16#4F
Instance: 0
Class: Is automatically set to 16#342
Attribute: Is automatically set to 16#0
Path: Communication path of the used EtherNet/IP module
Connected: Clear this checkbox

7
SICK Open Connection
Operating Instructions Add-On Instruction

Picture 6: Configuration of the msgDeleteSocket message (Configuration)

Picture 7: Configuration of the msgDeleteSocket message (Communication)

3.4 Configuration of the Open Connection message parameter


The Open Connection service opens a TCP connection with a specific destination address.
The parameter must be once configured on the “…” button as follows.

Message Type: CIP Generic


Service Type: OpenConnection
Service Code: Is automatically set to 16#4C
Instance: 0
Class: Is automatically set to 16#342
Attribute: Is automatically set to 16#0

8
SICK Open Connection
Operating Instructions Add-On Instruction

Source Element: Choose the “OpenConnectionSource” tag, defined in the


SICKTCPData UDT. Please note, that the UDT must be instantiated
as a controller tag.
Source Length: 1 Byte
Path: Communication path of the used EtherNet/IP module
Connected: Clear this checkbox

Picture 8: Configuration of the msgOpenConnection message (Configuration)

Picture 9: Configuration of the msgOpenConnection message (Communication)

9
SICK Open Connection
Operating Instructions Add-On Instruction

3.5 AOI functions


The routine uses a user defined data type (UDT) called SICKTCPData to handle data. This
UDT includes all parameters which are needed to communicate with a device. The UDT
must be instantiated as a controller tag.

Picture 10: Structure of the SICKTCPData UDT

The UDT includes three structures called “CreateSocketSource”, “CreateSocketDestination”


and “OpenConnectionSource”.

The AOI needs a socket interface to open a TCP connection between the SICK device and
the Logix5000 controller. The socket interface is implemented via the socket object in the
EtherNet/IP module. The PLC program communicates with the socket object via message
instructions (MSG).

Please note:
The socket interface, via messaging, is not well suited for real-time control as communication
with this method is not scheduled or deterministic.

3.5.1 Connect
The connect action creates a new socket instance and opens a TCP connection with a
specified destination address.

The following diagram shows the sequence of socket interface transactions with the
Logix5000 controller acting as a TCP client. Each transaction between the Logix5000
controller and the EtherNet/IP module is a MSG instruction.

10
SICK Open Connection
Operating Instructions Add-On Instruction

Picture 11: Sequence of MSG transaction to open a TCP connection

Before a TCP connection can establish, some parameters must be entered in the
SICKTCPData tag.

CreateSocketSource.Port: Specify the local port number on which the


application is listening and receiving. “0” means
that the EtherNet/IP module chooses the local port
number automatically.
OpenConnectionSource.DeviceAddress: This string defines the destination address of the
connection. For example enter
‘192.168.10.19?port=2112’ if you want to connect
to the IP-Address 192.168.10.19 on port 2112.

All other parameters are generated by the AOI automatically.

Picture 12: TCP communication parameters

The connect action starts by calling up the AOI with a positive trigger (signal change from
FALSE to TRUE) at the bConnect input bit. As long as there is no valid answer the output
bBusy is TRUE. In case the timeout period is excided, a timeout error will be generated and
the thread will be terminated. The bDone (=TRUE) output shows that the transaction was
successful. Now the requested socket instance is available at the iSocketInstance output.
The outputs retain its states as long as there is no new positive trigger at the bConnect or
bDisconnect input.

If you use a local port number that is already in use by the EtherNet/IP module, you receive
an error. The EtherNet/IP module uses these port numbers:
- 20,21: FTP
- 25: SMTP
- 80: HTTP
- 123: NTP
- 161: SNMP
- 2222: EtherNet/IP
- 44818: EtherNet/IP
11
SICK Open Connection
Operating Instructions Add-On Instruction

Please note:
Each socket instance has an inactivity timeout with a default of 5 minutes. If a socket
instance receives no service requests for the amount of time specified by the inactivity
timeout, the socket instance is deleted. If you then try to use the socket instance, the MSG
instruction receives the error class or instance not supported.

You can change the timeout by setting the inactivity time-out attribute via the Set Attribute
service. For more information see the Rockwell EtherNet/IP Socket Interface document.

3.5.2 Disconnect
The disconnect action close the specified connection and deletes the associated socket
instance.

The “iSocketInstance” input/output specifies which socket should be closed. The disconnect
action starts by calling up the AOI with a positive trigger (signal change from FALSE to
TRUE) at the bDisonnect input bit. As long as there is no valid answer the output bBusy is
TRUE. In case the timeout period is excided, a timeout error will be generated and the thread
will be terminated. The bDone (=TRUE) output shows that the transaction was successful.
The outputs retain its states as long as there is no new positive trigger at the bConnect or
bDisconnect input.

3.6 TCP connection loss


Your application program may encounter conditions that result in TCP connection loss. For
example, a network cable can be unplugged, or a target device can be turned off. You can
detect a connection loss when the ReadSocket / WriteSocket service returns with an error.

In some cases the connection established automatically (unplugged network cable). But if
the target device switched off and switched on again, the connection must be reestablished
(create a new socket instance and open a TCP connection).

3.7 Behavior when error occurs


An error bit (bError) is set and an error code (iErrorcode) is generated if there is an invalid
input value or an incorrect input connection of the SICK_OPEN_CONNECTION AOI. In this
case, no further processing is carried out until the input has been corrected.

12
SICK Open Connection
Operating Instructions Add-On Instruction

3.8 Parameters
Parameter Declara- Data type Description
tion
EnableIn INPUT BOOL Enable input (only in the FBD view)
msgCreate IN/OUT MESSAGE The Socket Create service creates an instance
Socket of the socket object.

This message must be configured as described


in chapter 3.2.
msgDelete IN/OUT MESSAGE The Delete Socket service closes the TCP
Socket connection and deletes the socket instance.

This message must be configured as described


in chapter 3.3.
msgOpen IN/OUT MESSAGE The Open Connection service opens a TCP
Connection connection with a specific destination address.

This message must be configured as described


in chapter 3.4.
iTimeout INPUT DINT Timeout time in milliseconds.

If the AOI action requires a longer time than the


iTimeout time, an error is set.

Example:
iTimeout = 5000
bConnect INPUT BOOL Positive trigger creates a new socket instance
and opens a TCP connection with a specified
destination address.

The destination address must be entered in the


instantiated UDT structure (see chapter 3.5.1).
bDisconnect INPUT BOOL Positive trigger close the specified connection
and deletes the associated socket instance
(see chapter 3.5.2).
stDATA IN/OUT SICKTCPData Reference to the SICKTCPData UDT.

The UDT must be instantiated as a controller


tag.
iSocket IN/OUT DINT Socket instance number.
Instance
You can use it for subsequent socket
operations (for example ReadSocket or
WriteSocket services).
bDone OUTPUT BOOL The rising edge indicates if the processing is
completed
bBusy OUTPUT BOOL Request in process

FALSE: Request is terminated


TRUE: Request is being processed

13
SICK Open Connection
Operating Instructions Add-On Instruction

Parameter Declara- Data type Description


tion
bError OUTPUT BOOL Error flag

FALSE: No error detected


TRUE: Error detected
iErrorcode OUTPUT DINT Error code (see error code description)
EnableOut OUTPUT BOOL Enable output (only in the FBD view)
Table 1: Parameters of the SICK_OPEN_CONNECTION AOI

14
SICK Open Connection
Operating Instructions Add-On Instruction

4 Error description
The parameter ERRORCODE contains the following error information:
- AOI error codes
- Rockwell specific error codes generated by the message blocks (SocketCreate,
DeleteSocket, OpenConnection)

Error codes of the SICK_OPEN_CONNECTION AOI:


Error code Short description Description
16#0000_0000 No Error No Error
16#0000_0001 Time out Time out error occurred while communicating with
the SICK device.
16#0000_0002 Invalid message The message class of the msgCreateSocket
configuration (Create message <> 16#342.
Socket MSG)
16#0000_0003 Invalid message The message class of the msgOpenConnection
configuration message <> 16#342.
(OpenConnection
MSG)
16#0000_0004 Invalid message The message class of the msgDeleteSocket
configuration message <> 16#342.
(DeleteSocket MSG)
16#XXXX_0005 Message error The MSG service “CeateSocket” has detected an
(Create Socket MSG) error. The first 16 bit represents the error code of
the message.

Further information is given in the message


configuration or in the RSLogix5000 help system.
16#XXXX_0006 Message error The MSG service “OpenConnection”has detected
(OpenConnection an error. The first 16 bit represents the error code
MSG) of the message.

Further information is given in the message


configuration or in the RSLogix5000 help system.
16#XXXX_0007 Message error These errors are generated by Message
(DeleteSocket MSG) “ReadSocket“. Further information is given in the
message configuration or in the RSLogix5000 help
system.
Table 2: Error code description

15
SICK Open Connection
Operating Instructions Add-On Instruction

5 Example
Picture 13 shows an example configuration of the SICK_OPEN_CONNECTION AOI.

Picture 13: RSLogix5000 example project

5.1 Connect
The connection parameters are entered into the “SICKTCPData.OpenConnectionSource” tag
which is defined by the SICKTCPData UDT.

CreateSocketSource.Port: Specify the local port number on which an


application is listening and receiving. “0” means
that the EtherNet/IP module choose the local port
number automatically.
OpenConnectionSource.DeviceAddress: IP-Address and Port-Number of the SICK
Bulkscan device.

Picture 14: TCP Connection parameters

The TCP connection must be established by calling up the SICK_OPEN_CONNECTION AOI


with a positive trigger at the “bConnect” input bit. The bDone (=TRUE) output shows that the
connection was successful established. Now the “iSocketInstance” shows the instance of the
Socket connection service using for subsequent socket operations (for example ReadSocket
or WriteSocket services).

16
SICK Open Connection
Operating Instructions Add-On Instruction

Picture 15: Start connection

5.2 Disconnect
To disconnect the current connection with the socket instance (iSockInstance = 25177) call
the SICK_OPEN_CONNECTION AOI with a positive trigger at the “bDisconnect” input bit.
The bDone (=TRUE) output shows that the disconnection was successful.

Picture 16:Start disconnection

17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy