33002551_k01_000_10

136
33002551.10 www.schneider-electric.com Unity Pro 33002551 10/2013 Unity Pro TCP Open Block Library 10/2013

Upload: arfeem

Post on 26-Dec-2015

28 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 33002551_K01_000_10

Unity Pro

33002551 10/2013

3300

2551

.10

www.schneider-electric.com

Unity ProTCP OpenBlock Library

10/2013

Page 2: 33002551_K01_000_10

The information provided in this documentation contains general descriptions and/or technical characteristics of the performance of the products contained herein. This documentation is not intended as a substitute for and is not to be used for determining suitability or reliability of these products for specific user applications. It is the duty of any such user or integrator to perform the appropriate and complete risk analysis, evaluation and testing of the products with respect to the relevant specific application or use thereof. Neither Schneider Electric nor any of its affiliates or subsidiaries shall be responsible or liable for misuse of the information contained herein. If you have any suggestions for improvements or amendments or have found errors in this publication, please notify us.

No part of this document may be reproduced in any form or by any means, electronic or mechanical, including photocopying, without express written permission of Schneider Electric.

All pertinent state, regional, and local safety regulations must be observed when installing and using this product. For reasons of safety and to help ensure compliance with documented system data, only the manufacturer should perform repairs to components.

When devices are used for applications with technical safety requirements, the relevant instructions must be followed.

Failure to use Schneider Electric software or approved software with our hardware products may result in injury, harm, or improper operating results.

Failure to observe this information can result in injury or equipment damage.

© 2013 Schneider Electric. All rights reserved.

2 33002551 10/2013

Page 3: 33002551_K01_000_10

Table of Contents

Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5About the Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Part I General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Chapter 1 Block Types and their Applications . . . . . . . . . . . . . . . 11

Block Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12FFB Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14EN and ENO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Chapter 2 Block Availability on Various Hardware Platforms . . 21Availability of the Blocks on the Various Hardware Platforms . . . . . . . 21

Part II Introduction to TCP Open . . . . . . . . . . . . . . . . . . . 23Chapter 3 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

General Points and Principles of TCP Open . . . . . . . . . . . . . . . . . . . . 25Chapter 4 Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Notes and Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Chapter 5 Description of Operation . . . . . . . . . . . . . . . . . . . . . . . . 29

Operating Rules for TCP Open EFs . . . . . . . . . . . . . . . . . . . . . . . . . . 30Principle Governing Socket Operation . . . . . . . . . . . . . . . . . . . . . . . . 31General Structure of a TCP Open Communication EF . . . . . . . . . . . . 33Structure of TCP Open Management Parameters . . . . . . . . . . . . . . . 34Management Parameters: Communication and Operation Reports . . 36The Client/Server Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Example of Client/Server Applications . . . . . . . . . . . . . . . . . . . . . . . . 40

Chapter 6 Operating Modes and Performance . . . . . . . . . . . . . . . 45Operating Modes of the Network Module . . . . . . . . . . . . . . . . . . . . . . 46Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Debugging and Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Part III Advanced . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Chapter 7 FCT_ACCEPT: Accepts a Connection Request. . . . . . 53

Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Chapter 8 FCT_BIND: Binds a Socket Number to an IP Address

and a Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Chapter 9 FCT_CLOSE: Deletes the Specified Socket . . . . . . . . . 61Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

33002551 10/2013 3

Page 4: 33002551_K01_000_10

Chapter 10 FCT_CONNECT: Establishes a Connection with an IP Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Chapter 11 FCT_LISTEN: Configuration of a Socket Await Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Chapter 12 FCT_RECEIVE: Retrieves Data Available on a Socket 71Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Chapter 13 FCT_SELECT: Multiplexes Requests Over Sockets . . 73Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Chapter 14 FCT_SEND: Sending Data to a Specified Socket . . . . 77Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Chapter 15 FCT_SETSOCKOPT: Sets the Options Associated with the Socket. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Chapter 16 FCT_SHUTDOWN: Disables Transmission on the Socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Chapter 17 FCT_SOCKET: Creation of a New Socket . . . . . . . . . . 89Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

Part IV DFB Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93Chapter 18 DFB Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

DFB Library Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96TCP_CNX DFB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97TCP_SEND DFB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100TCP_RECEIVE DFB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Appendix A System Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

System Bit Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Description of System Bits %S15 to %S21 . . . . . . . . . . . . . . . . . . . . . 109Description of System Words %SW12 to %SW29. . . . . . . . . . . . . . . . 112

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

4 33002551 10/2013

Page 5: 33002551_K01_000_10

Safety Information

Important Information

NOTICERead these instructions carefully, and look at the equipment to become familiar with the device before trying to install, operate, or maintain it. The following special messages may appear throughout this documentation or on the equipment to warn of potential hazards or to call attention to information that clarifies or simplifies a procedure.

33002551 10/2013 5

Page 6: 33002551_K01_000_10

PLEASE NOTEElectrical equipment should be installed, operated, serviced, and maintained only by qualified personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of the use of this material.

A qualified person is one who has skills and knowledge related to the construction and operation of electrical equipment and its installation, and has received safety training to recognize and avoid the hazards involved.

6 33002551 10/2013

Page 7: 33002551_K01_000_10

About the Book

At a Glance

Document ScopeThis document describes the functions and function blocks of the TCP Open library.

Validity NoteThis document is valid from Unity Pro Version 8.0.

33002551 10/2013 7

Page 8: 33002551_K01_000_10

8 33002551 10/2013

Page 9: 33002551_K01_000_10

Unity ProGeneral33002551 10/2013

General

Part IGeneral

OverviewThis part contains general information about the TCP Open library.

What Is in This Part?This part contains the following chapters:

Chapter Chapter Name Page

1 Block Types and their Applications 11

2 Block Availability on Various Hardware Platforms 21

33002551 10/2013 9

Page 10: 33002551_K01_000_10

General

10 33002551 10/2013

Page 11: 33002551_K01_000_10

Unity ProBlock Types and their Applications33002551 10/2013

Block Types and their Applications

Chapter 1Block Types and their Applications

OverviewThis chapter describes the different block types and their applications.

What Is in This Chapter?This chapter contains the following topics:

Topic Page

Block Types 12

FFB Structure 14

EN and ENO 17

33002551 10/2013 11

Page 12: 33002551_K01_000_10

Block Types and their Applications

Block Types

Block TypesDifferent block types are used in Unity Pro. The general term for the block types is FFB.

There are the following types of block:Elementary Function (EF)Elementary Function Block (EFB)Derived Function Block (DFB)Procedure

NOTE: Motion Function Blocks are not available on the Quantum platform.

Elementary FunctionElementary functions (EF) have no internal status and one output only. If the input values are the same, the output value is the same for the executions of the function, for example the addition of two values gives the same result at every execution.

An elementary function is represented in the graphical languages (FBD and LD) as a block frame with inputs and an output. The inputs are represented on the left and the outputs on the right of the block frame. The name of the function, that is the function type, is shown in the center of the block frame.

The number of inputs can be increased with some elementary functions.

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0) causes links connected to its Input/Output to be reset. To transfer the state of the signal do not use a link. A variable must be connected to the EF’s output and must be used to connect the input of the element. With Unity Pro V4.1 and later versions you can maintain the output links even if an EF is deactivated by activating the option Maintain output links on disabled EF (EN=0) via the menu Tools → Program → Languages → Common.

CAUTIONUNEXPECTED BEHAVIOR OF EQUIPMENTFor Unity Pro V4.0 and earlier versions, do not use links to connect function blocks outputs, when your application relies on persistent output data of an EF.

Failure to follow these instructions can result in injury or equipment damage.

12 33002551 10/2013

Page 13: 33002551_K01_000_10

Block Types and their Applications

Elementary Function BlockElementary function blocks (EFB) have an internal status. If the inputs have the same values, the value on the outputs can have another value during the individual executions. For example, with a counter, the value on the output is incremented.

An elementary function block is represented in the graphical languages (FBD and LD) as a block frame with inputs and outputs. The inputs are represented on the left and the outputs on the right of the block frame. The name of the function block, that is the function block type, is shown in the center of the block frame. The instance name is displayed above the block frame.

Derived Function BlockDerived function blocks (DFBs) have the same properties as elementary function blocks. They are created by the user in the programming languages FBD, LD, IL and/or ST.

ProcedureProcedures are functions with several outputs. They have no internal state.

The only difference from elementary functions is that procedures can have more than one output and they support variables of the VAR_IN_OUT data type.

Procedures do not return a value.

Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.

There is no visual difference between procedures and elementary functions.

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0) causes links connected to its Input/Output to be reset. To transfer the state of the signal do not use a link. A variable must be connected to the EF’s output and must be used to connect the input of the element. With Unity Pro V4.1 and later versions you can maintain the output links even if an EF is deactivated by activating the option Maintain output links on disabled EF (EN=0) via the menu Tools → Program → Languages → Common.

CAUTIONUNEXPECTED BEHAVIOR OF EQUIPMENTFor Unity Pro V4.0 and earlier versions, do not use links to connect function blocks outputs, when your application relies on persistent output data of an EF.

Failure to follow these instructions can result in injury or equipment damage.

33002551 10/2013 13

Page 14: 33002551_K01_000_10

Block Types and their Applications

FFB Structure

StructureEach FFB is made up of an operation (name of the FFB), the operands are required for the operation (formal and actual parameters) and an instance name for elementary/derived function blocks.

Call of a function block in the FBD programming language:

CAUTIONUNEXPECTED APPLICATION BEHAVIORDo not call several times the same block instance within a PLC cycle

Failure to follow these instructions can result in injury or equipment damage.

14 33002551 10/2013

Page 15: 33002551_K01_000_10

Block Types and their Applications

Formal call of a function block in the ST programming language:

OperationThe operation determines which function is to be executed with the FFB, e.g. shift register, conversion operations.

OperandThe operand specifies what the operation is to be executed with. With FFBs, this consists of formal and actual parameters.

Formal/actual parametersInputs and outputs are required to transfer values to or from an FFB. These are called formal parameters.

Objects are linked to formal parameters; these objects contain the current process states. They are called actual parameters.

At program runtime, the values from the process are transferred to the FFB via the actual parameters and then output again after processing.

The data type of the actual parameters must match the data type of the input/output (formal parameters). The only exceptions are generic inputs/outputs whose data type is determined by the actual parameter. If the actual parameters consist of literals, a suitable data type is selected for the function block.

33002551 10/2013 15

Page 16: 33002551_K01_000_10

Block Types and their Applications

FFB Call in IL/STIn text languages IL and ST, FFBs can be called in formal and in informal form. Details can be found in the Reference manual.

Example of a formal function call:

out:=LIMIT (MN:=0, IN:=var1, MX:=5);

Example of an informal function call:

out:=LIMIT (0, var1, 5);

NOTE: The use of EN and ENO is only possible for formal calls.

VAR_IN_OUT variableFFBs are often used to read a variable at an input (input variables), to process it and to output the altered values of the same variable (output variables).

This special type of input/output variable is also called a VAR_IN_OUT variable.

The input and output variable are linked in the graphic languages (FBD and LD) using a line showing that they belong together.

Function block with VAR_IN_OUT variable in FBD:

Function block with VAR_IN_OUT variable in ST:

MY_EXAMP1 (IN1:=Input1, IN2:=Input2, IO1:=Comb_IN_OUT,OUT1=>Output1, OUT2=>Output2);

The following points must be considered when using FFBs with VAR_IN_OUT variables: The VAR_IN_OUT inputs must be assigned a variable.Literals or constants cannot be assigned to VAR_IN_OUT inputs/outputs.

The following additional limitations apply to the graphic languages (FBD and LD): When using graphic connections, VAR_IN_OUT outputs can only be connected with VAR_IN_OUT inputs. Only one graphical link can be connected to a VAR_IN_OUT input/output.Different variables/variable components can be connected to the VAR_IN_OUT input and the VAR_IN_OUT output. In this case the value of the variables/variable component on the input is copied to the output variables/variable component. No negations can be used on VAR_IN_OUT inputs/outputs.A combination of variable/address and graphic connections is not possible for VAR_IN_OUT outputs.

16 33002551 10/2013

Page 17: 33002551_K01_000_10

Block Types and their Applications

EN and ENO

DescriptionAn EN input and an ENO output can be configured for the FFBs.

If the value of EN is equal to "0" when the FFB is invoked, the algorithms defined by the FFB are not executed and ENO is set to "0".

If the value of EN is equal to "1" when the FFB is invoked, the algorithms defined by the FFB will be executed. After the algorithms have been executed successfully, the value of ENO is set to "1". If certain error conditions are detected when executing these algorithms, ENO is set to "0".

If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined by the FFB is executed (same as if EN equals to "1"), Please refer to Maintain output links on disabled EF (see Unity Pro, Operating Modes).

If the algorithms are executed successfully, then value of ENO is set to "1", else ENO is set to "0".

If ENO is set to "0" (caused by EN=0 or a detected error condition during execution or unsuccessful algorithm execution):

Function blocksEN/ENO handling with function blocks that (only) have one link as an output parameter:

If EN from FunctionBlock_1 is set to "0", the output connection OUT from FunctionBlock_1 retains the status it had in the last correctly executed cycle. EN/ENO handling with function blocks that have one variable and one link as output parameters:

If EN from FunctionBlock_1 is set to "0", the output connection OUT from FunctionBlock_1 retains the status it had in the last correctly executed cycle. The variable OUT1 on the same pin, either retains its previous status or can be changed externally without influencing the connection. The variable and the link are saved independently of each other.

33002551 10/2013 17

Page 18: 33002551_K01_000_10

Block Types and their Applications

Functions/Procedures

NOTE: With Unity Pro V4.0 and earlier versions the deactivation of an EF (EN=0) causes links connected to its Input/Output to be reset. To transfer the state of the signal do not use a link. A variable must be connected to the EF’s output and must be used to connect the input of the element. With Unity Pro V4.1 and later versions you can maintain the output links even if an EF is deactivated by activating the option Maintain output links on disabled EF (EN=0) via the menu Tools → Program → Languages → Common.

As defined in IEC61131-3, the outputs from deactivated functions (EN-input set to "0") is undefined. (The same applies to procedures.) Here is an explanation of the output status in this case:

EN/ENO handling with functions/procedures that (only) have one link as an output parameter:

If EN from Function/Procedure_1 is set to "0", the output connection OUT from Function/Procedure_1 is also set to "0". EN/ENO handling with function blocks that have one variable and one link as output parameters:

If EN from Function/Procedure_1 is set to "0", the output connection OUT from Function/Procedure_1 is also set to "0". The variable OUT1 on the same pin, either retains its previous status or can be changed externally without influencing the connection. The variable and the link are saved independently of each other.

The output behavior of the FFBs does not depend on whether the FFBs are called up without EN/ENO or with EN=1.

CAUTIONUNEXPECTED BEHAVIOR OF EQUIPMENTFor Unity Pro V4.0 and earlier versions, do not use links to connect function blocks outputs, when your application relies on persistent output data of an EF.

Failure to follow these instructions can result in injury or equipment damage.

18 33002551 10/2013

Page 19: 33002551_K01_000_10

Block Types and their Applications

Conditional/Unconditional FFB Call"Unconditional" or "conditional" calls are possible with each FFB. The condition is realized by pre-linking the input EN.

EN connectedconditional calls (the FFB is only processed if EN = 1)EN shown, hidden, and marked TRUE, or shown and not occupiedunconditional calls (FFB is processed independent from EN)

NOTE: For disabled function blocks (EN = 0) with an internal time function (e.g. DELAY), time seems to keep running, since it is calculated with the help of a system clock and is therefore independent of the program cycle and the release of the block.

Note for IL and STThe use of EN and ENO is only possible in the text languages for a formal FFB call, e.g.

MY_BLOCK (EN:=enable, IN1:=var1, IN2:=var2,ENO=>error, OUT1=>result1, OUT2=>result2);

Assigning the variables to ENO must be done with the operator =>.

With an informal call, EN and ENO cannot be used.

CAUTIONUNEXPECTED APPLICATION EQUIPMENTDo not disable function blocks with internal time function during their operation.

Failure to follow these instructions can result in injury or equipment damage.

33002551 10/2013 19

Page 20: 33002551_K01_000_10

Block Types and their Applications

20 33002551 10/2013

Page 21: 33002551_K01_000_10

Unity ProAvailability of the Blocks33002551 10/2013

Block Availability on Various Hardware Platforms

Chapter 2 Block Availability on Various Hardware Platforms

Availability of the Blocks on the Various Hardware Platforms

IntroductionNot all blocks are available on all hardware platforms. The blocks which are available on your hardware platform can be found in the following tables.

AdvancedAvailability of the blocks:

Block Name Block Type M340 Premium Quantum

FCT_ACCEPT Procedure - + -

FCT_BIND Procedure - + -

FCT_BIND_UINT Procedure - + -

FCT_CLOSE Procedure - + -

FCT_CONNECT Procedure - + -

FCT_CONNECT_UINT Procedure - + -

FCT_LISTEN Procedure - + -

FCT_RECEIVE Procedure - + -

FCT_SELECT Procedure - + -

FCT_SEND Procedure - + -

FCT_SETSOCKOPT Procedure - + -

FCT_SHUTDOWN Procedure - + -

FCT_SOCKET Procedure - + -

Legend:

+ available

- not available

33002551 10/2013 21

Page 22: 33002551_K01_000_10

Availability of the Blocks

22 33002551 10/2013

Page 23: 33002551_K01_000_10

Unity ProIntroduction to TCP Open33002551 10/2013

Introduction to TCP Open

Part IIIntroduction to TCP Open

OverviewThis part introduces the TCP Open service which can be used with Elementary Functions (EF) in Unity Pro.

What Is in This Part?This part contains the following chapters:

Chapter Chapter Name Page

3 General 25

4 Warnings 27

5 Description of Operation 29

6 Operating Modes and Performance 45

33002551 10/2013 23

Page 24: 33002551_K01_000_10

Introduction to TCP Open

24 33002551 10/2013

Page 25: 33002551_K01_000_10

Unity ProGeneral33002551 10/2013

General

Chapter 3General

General Points and Principles of TCP Open

At a GlanceTCP Open for Premium is a set of Elementary Functions (EFs) and Derived Function Blocks (DFBs) that provide TCP/IP services in an automation application on Premium PLCs.

The TCP Open EFs and DFBs are installed from a CD. Once installed in Unity Pro, they appear in the TCP Open library in the Advanced family.

These preset functions can be used for TCP/IP Client/Server applications without having to have any knowledge of programming languages such as C ++ or Java.

Programming is carried out directly using the EFs and DFBs in the desired automation language (ST, LD, FBD or IL).

This TCP Open is available on the following modules:

TSX ETY 110WSTSX ETY 5103

This documentation contains a description of the EFs for TCP Open; the documentation concerning the DFBs for TCP Open is supplied on the installation CD.

33002551 10/2013 25

Page 26: 33002551_K01_000_10

General

26 33002551 10/2013

Page 27: 33002551_K01_000_10

Unity ProWarnings33002551 10/2013

Warnings

Chapter 4Warnings

Notes and Warnings

At a GlanceImplementing TCP/IP services using TCP Open EFs is relatively straightforward. However, there are certain prerequisites for such an implementation, which is governed by the same development principles as a standard automation application.

ObservationsTo use the TCP Open EF library you must have a minimum working knowledge of TCP/IP applications and of how a socket system operates.

The implementation of Client/Server services follows certain programming rules which you must understand.

Using the TCP Open V2.0 Function LibraryWhen using DFBs from version V1 with Unity V2.0, you may encounter the following malfunction: when the project is compared with the library the "Object code different" error message is displayed and you are asked to update your DFBs. Due to a checksum error, updating the DFBs will always generate this message when performing subsequent comparisons with the library. In spite of this, the DFBs still function correctly and can be used without restriction whether you are importing the program from Unity 1.0 or using DFBs from CD.

This malfunction will be corrected in a future version of TCP Open > V2.0.

WARNINGUNINTENDED EQUIPEMENT OPERATIONThe implementation and maintenance of TCP Open should only be performed by qualified personnel, with the necessary skills to handle sockets. This document should not be considered to represent adequate training for someone who is not otherwise qualified to develop TCP/IP services.

Although all reasonable precautions have been taken to ensure that the information provided here is accurate and authoritative, no responsibility is assumed by Schneider Electric for any consequences arising from the use of this document.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

33002551 10/2013 27

Page 28: 33002551_K01_000_10

Warnings

ResponsibilitiesSchneider Electric is not liable for:

WARNINGUNEXPECTED SYSTEM BEHAVIORThe design of a TCP Opensystem implies:

To check and validate the design of the communication system architecture (client/server operating modes and protocols, performances, etc.)To check the implementation of appropriate EFs (or reuse of example EFs included in the TCP Open kit)To test and validate the EFs integrated into the communication system architectureTo perform appropriate maintenance and manage diagnostics errors.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

28 33002551 10/2013

Page 29: 33002551_K01_000_10

Unity ProOperation33002551 10/2013

Description of Operation

Chapter 5Description of Operation

Subject of this ChapterThis chapter describes the principles governing the operations and implementation of a TCP/IP service using preset TCP Open EFs.

What Is in This Chapter?This chapter contains the following topics:

Topic Page

Operating Rules for TCP Open EFs 30

Principle Governing Socket Operation 31

General Structure of a TCP Open Communication EF 33

Structure of TCP Open Management Parameters 34

Management Parameters: Communication and Operation Reports 36

The Client/Server Model 38

Example of Client/Server Applications 40

33002551 10/2013 29

Page 30: 33002551_K01_000_10

Operation

Operating Rules for TCP Open EFs

Execution of a TCP Open EFTCP Open EFs are executed asynchronously with the PLC cycle. Each EF call triggers a transaction with the Ethernet module concerned (TSX ETY 5103 or TSX ETY 110WS).

The transaction starts at the end of the PLC cycle and may take several cycles to complete. It is therefore necessary to manage the sequencing of calls so as not to saturate the module or request an action before the previous one is complete.

It is possible to call several TCP/IP services in the same PLC cycle. However, it is not certain that they will be processed in the chronological order in which they were called.

NOTE: We advise you to wait until the execution of one function is complete before requesting a new service on the same socket.

For example, wait for the FCT_SOCKET EF to be returned before calling the FCT_BIND EF, and wait for the FCT_BIND EF to be returned before calling the FCT_LISTEN EF.

EFs SuppliedThe number of TCP Open functions supplied, as well as the manner in which they are used have been deliberately reduced in order to simplify the implementation of these services.

In addition to this, certain parameters are a requirement of the TSX ETY 5103 module. These limitations are detailed as part of the description of the FCT_SOCKET (see page 89) function.

30 33002551 10/2013

Page 31: 33002551_K01_000_10

Operation

Principle Governing Socket Operation

IntroductionThe socket is the basic element of TCP communication. It is the socket which transports data.

The TCP/IP function library only provides sockets for flow management and connection between two devices.

NOTE: The TSX ETY 5103 Premium architecture can support up to 64 sockets. They can be used as listening (server) sockets or connected (client) sockets. In a server application, at least 1 socket must be a listening socket. There are no other hard boundaries with respect to the number of client connections versus server connections.

A socket can be created by either the FCT_SOCKET (see page 89) function or the FCT_ACCEPT (see page 53) function. The function returns a number that is used to access the socket.

Establishing a Server ConnectionThe following table describes the different steps that need to be created on the server in order to establish a connection.

Establishing a Client ConnectionThe following table describes the different steps that need to be created on the client in order to establish a connection.

Step Action

1 Create a socket using the FCT_SOCKET function

2 Associate the created socket with an address (Port number and IP address) using the FCT_BIND (see page 57) function.

3 Set up the socket to accept connections using the FCT_LISTEN (see page 69) function.Note: the PLC acts as TCP server, the initial socket listens, and receives client socket connections.

4 Apply the FCT_ACCEPT (see page 53) function to this socket to create a new socket which will establish the connection.Note: this new socket is then connected to the client socket, and its number is returned by the FCT_ACCEPT function. The initial socket is then freed for other clients which wish to connect to the server.

Step Action

1 Create a socket using the FCT_SOCKET function block. The block returns a socket number which can then be used in the subsequent function blocks.

2 Use FCT_CONNECT to make a connection to another Ethernet device by specifying its IP address and the particular port that you are going to communicate on.

33002551 10/2013 31

Page 32: 33002551_K01_000_10

Operation

Exchanging Data over a TCP ConnectionOnce a connection has been established, data can be transferred. Transfers are carried out using the FCT_SEND (see page 77) and FCT_RECEIVE (see page 71) functions. The diagram below shows how these exchanges work.

Managing SocketsOther functions can be used to act on sockets:

FCT_SETSOCKOPT (see page 81): associates options with a socket. These options modify the behavior of the socket.FCT_SELECT (see page 73): used to test events on sockets.FCT_SHUTDOWN (see page 85): disables transmission on the socket.FCT_CLOSE (see page 61): frees the socket descriptor when it is no longer used.

32 33002551 10/2013

Page 33: 33002551_K01_000_10

Operation

General Structure of a TCP Open Communication EF

At a GlanceCommunication functions are processed asynchronously in relation to the PLC cycle. A function is executed over several consecutive cycles following the cycle which launched its execution.

The parameters of a TCP Open communication function are the following:interface numberspecific parametersmanagement parameters

Interface NumberThis interface number corresponds to the slot number of the ETY module in the main rack.

NOTE: Only rack 0 can take an Ethernet module that uses TCP Open communication functions.

In the case of the TSXETY5103, the Premium architecture divides this integer into 2 bytes.The low byte contains the slot number of the sockets.The value in the high byte can be used to extend the number of sockets as follows:

00 is used for full backward compatibility with applications created on firmware version 3.3 or earlier.01 indicates that up to 64 sockets can be used; the firmware must be higher than version 3.3 to support this socket extension.

NOTE: When you set the value of the high byte to 01 (to extend the number of sockets to 64), make sure that the TSXETY5103 firmware is at an acceptable version. If you attempt to use this high-byte setting when the firmware is at version 3.3 or lower, the module goes into a constant reboot cycle and does not become operational.

Specific ParametersThese parameters are specific to each function. There may be more than one, in which case they are separated by commas. They are described in the chapters specific to each function.

Management ParametersThe management parameters consist of an array of 4 integers also known as the Management table (see page 34). It is identical to the management table for standard communication EFs except for the exchange number which is not managed and the Time out.

33002551 10/2013 33

Page 34: 33002551_K01_000_10

Operation

Structure of TCP Open Management Parameters

At a GlanceThe management parameters are grouped together in a array of four integers. The values contained in this array are used to control the communication functions.

NOTE: In the technical documentation, these parameters are also known as a management table or report.

StructureThe table below describes the data structure of the communication management table:

Activity BitThis bit signals the execution status of the communication function.

It is set to 1 when launched and falls back to 0 when execution is complete.

This is the first bit of the first element in the table.

Example: If the management table has been declared in the following way:

Tab_Gest ARRAY [1..4] OF INT, the activity bit is the bit with the notation Tab_Gest[1].0.

NOTE: The notation used above requires Unity Pro to be used in non-IEC mode. If this is not the case Tab_Gest[1].0 cannot be accessed in this manner.

Operation ReportOperation reports are described in Operation Report, page 37.

Communication ReportCommunication reports are described in Communication Report, page 36.

Word Order Most Significant Byte Least Significant Byte

1 Reserved Activity bit

2 operation report communication report

3 Reserved

4 Length

34 33002551 10/2013

Page 35: 33002551_K01_000_10

Operation

LengthThe length parameter is used with the FCT_SEND (see page 77) and FCT_RECEIVE (see page 71) functions. The length parameter is also used with the FCT_SELECT (see page 65) function. With FCT_SELECT the length field is not used when the high byte of the INTE parameter is set to 00. You should set the length to 8 when the high byte of the INTE parameter is set to 01. A setting of 8 allows you to see the data associated with all 64 connections. If you set the value lower, say to 4, you will see only the data associated with the first 32 connections.

33002551 10/2013 35

Page 36: 33002551_K01_000_10

Operation

Management Parameters: Communication and Operation Reports

At a GlanceCommunication and operation reports are part of the management parameters.

NOTE: It is recommended that you always test communication function reports as soon as their execution is complete and before they are re-activated. On a cold restart, you must under all circumstances check that all the management parameters of the communication functions have been reset to 0.

Communication ReportThis report is common to all functions. It is significant when the activity bit changes from 1 to 0.

Reports whose value is between 16#01 and 16#FE concern errors detected by the processor which executed the function.

The different values of this report are indicated in the following table:

NOTE: The function can detect an error in the parameters before activating the exchange. In this case, the activity bit remains at 0 and the report is initialized with the values corresponding to the fault.

Value Communication Report (Least Significant Byte)

16#00 Exchange successful

16#01 Exchange stopped on timeoutNOTE: : OK value returned when a Modbus M340 CPU sends a MODBUS BROADCAST request

16#05 Incorrect management parameter format

16#06 Incorrect specific parameters

16#07 Network module missing or incorrect address

16#0B No processor system resources

16#0E Incorrect send length

16#FF Message refusedNOTE: OK value returned when a TSX SCP ••• / TSX SCY ••• sends a MODBUS BROADCAST request

36 33002551 10/2013

Page 37: 33002551_K01_000_10

Operation

Operation ReportThis report byte describes the result of interaction of the function with the TCP/IP stack of the network module.

It is significant only if the communication report has the following values:16#00 (exchange successful)16#FF (message refused).

If this report has a value equal to 16#00, the operation report is specific to each function. It is described in the chapters devoted to these functions.

If the communication report has the value 16#FF, the operation report has the following values:

Value Operation Report (Most Significant Byte)

16#0B Inadequate system resources (too many EFs in the same PLC cycle)

16#0C Network module not running

33002551 10/2013 37

Page 38: 33002551_K01_000_10

Operation

The Client/Server Model

At a GlanceThe client/server model consists of two entities, one of which acts as a server, and which responds to requests and the other of which is a client, which makes the request.

The client/server model operates according to a specific protocol which must be implemented at either end of the connection.

This protocol is described in the following paragraphs.

NOTE: If you are developing your own client/server application, you are responsible for testing and managing the connections.

DescriptionThe model works in the following way:

The server application listens.A client application requests services from the server application.The server application accepts the request.Exchanges are made between the two entities.

38 33002551 10/2013

Page 39: 33002551_K01_000_10

Operation

IllustrationIllustration of how the client/server model works

33002551 10/2013 39

Page 40: 33002551_K01_000_10

Operation

Example of Client/Server Applications

At a GlanceConnections are managed by the application program. A client which terminates a connection without observing the correct TCP sequence (as a result of a power outage, for example), is considered as still being connected as long as nothing else has been sent or any other events have occurred.

The following paragraphs provide three significant examples which should enable you to better understand how the architecture works.

The client side is described in the form of a flow diagram, whereas on server side is shown as a sequence of operations closely linked to the events on the client side.

The scenario in example 2 is of a connection cut-off on the client side after FCT_RECEIVE (Sj), as there is no SEND_RECEIVE-processing loop.

40 33002551 10/2013

Page 41: 33002551_K01_000_10

Operation

Example 1The diagram below describes how a server application operates when processing two connections requested by two clients.

33002551 10/2013 41

Page 42: 33002551_K01_000_10

Operation

Example 2The diagram below describes how a server application operates when processing two connections requested by the same client. The first disconnection was not made in accordance with correct TCP procedure (e.g.: power failure). The socket is considered to still be connected as long as the client has not made a new connection.

42 33002551 10/2013

Page 43: 33002551_K01_000_10

Operation

Example 3The diagram below describes how a server application operates when processing two connections requested by the same client. The first disconnection was not made in accordance with correct TCP procedure (e.g.: power failure). As long nothing has been sent by the server, the socket is still considered to be connected.

33002551 10/2013 43

Page 44: 33002551_K01_000_10

Operation

44 33002551 10/2013

Page 45: 33002551_K01_000_10

Unity ProOperating Modes and Performance33002551 10/2013

Operating Modes and Performance

Chapter 6Operating Modes and Performance

Subject of this ChapterThis chapter is intended to provide you with an introduction to the operating modes, the basic notions required for debugging and the performance characteristics of the TSX ETY 5103 module (Ethernet module supporting TCP open functions).

What Is in This Chapter?This chapter contains the following topics:

Topic Page

Operating Modes of the Network Module 46

Performance 48

Debugging and Diagnostics 49

33002551 10/2013 45

Page 46: 33002551_K01_000_10

Operating Modes and Performance

Operating Modes of the Network Module

At a GlanceThe TSX ETY 5103 module has 4 operating states:

power offself-test runningconfigurednot configured

Self-tests are performed on power-up.

The module does not operate with its default configuration.

The configuration must be sent to the PLC via the terminal socket and not over the network.

If the module has not been correctly configured, it cannot process the sockets and a refuse message is sent back to the TCP Open functions.

Sending the Configuration to the ModuleThe configuration is sent to the module in the following cases:

when an application is downloadedwhen the PLC is powered upwhen the module is connected to the rack when the power is onon a warm or cold restartwhen the Premium is reset

Operating Mode after Configuration

WARNINGUNINTENDED APPLICATION BEHAVIOR - WARM OR COLD RESTARTThe programmer must test the system bits %S0 and %S1 in his application in order to re-create the connections if a warm or cold start has been performed. The programmer must also test the system bit %S13 in his application in order to check for first scan after a STOP/RUN command using the PLC software application.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

46 33002551 10/2013

Page 47: 33002551_K01_000_10

Operating Modes and Performance

Once a configuration has been defined, the module operates in the following way:

Step Action

1 The module resets the communication in progress.Result: Exchanges in progress are ended; TCP Open connections are closed, and all sockets are deleted.

2 The module reconfigures itself.

3 The module is ready to process the TCP Open communication functions of the application.

33002551 10/2013 47

Page 48: 33002551_K01_000_10

Operating Modes and Performance

Performance

Number of Simultaneous ConnectionsThe maximum number of simultaneous TCP/IP connections to a TSX ETY 5103 is:

32 if the high byte of the INTE is set to 00;16 can be connected (client) sockets and 16 can be listening (server) sockets.64 if the high byte of the INTE parameter is set to 01. The 64 socket can be used as listening (server) sockets or connected (client) sockets in any combination with one exception—in a server application, at least 1 socket must be a listening socket.

Data ExchangesThe maximum chunk of data that can be sent in one PLC cycle is 240 bytes. This limitation is due to the X-bus mechanism for data transfer between the module and the processor.

If you wish to transfer a message of 8 Kbytes, you must break down your message into blocks of 240 bytes. If you want to guarantee the order in which the blocks are sent so as to be able to reconstitute the whole message, you must send one block for each cycle. That means that 35 PLC cycles (8*1024/240) would be required. A PLC cycle of 50 ms would take 1.75 s.

NOTE: These calculations are based on the use of a single socket. If you are managing several clients, you must take into account the number of connected sockets.

For a message oriented protocol, a lower level interface has to manage the fragmentation process. Here performance depends on the number of FCT_SEND (see page 77) or FCT_RECEIVE (see page 71) functions executed in the same PLC cycle.

Performance can be reduced depending on the degree to which the TSX ETY 5103 module is used for other communications tasks (IO Scanning, Global Data, etc.).

48 33002551 10/2013

Page 49: 33002551_K01_000_10

Operating Modes and Performance

Debugging and Diagnostics

Debug ScreenIn online mode, Unity Pro software can be used to debug the application using the application-specific debug screens.

The module debug screen can be used to do this. However, you should note that: The number of connections displayed includes:

open profile connections (TCP Open)private profile connections (address declared in configuration)

The IP addresses of open profiles cannot be seen in this screen.

IP Communication TestsYou can use the communication test window to test IP communication with client devices if the IP address of the client is declared as a remote device (used by the private profile).

The list of IP addresses configured is used to select the station with which to communicate by activating a "ping", which feeds back as a status the loop-back or the time out of the message.

33002551 10/2013 49

Page 50: 33002551_K01_000_10

Operating Modes and Performance

50 33002551 10/2013

Page 51: 33002551_K01_000_10

Unity ProAdvanced33002551 10/2013

Advanced

Part IIIAdvanced

OverviewThis part describes the elementary functions and elementary function blocks of the Advanced family.

What Is in This Part?This part contains the following chapters:

Chapter Chapter Name Page

7 FCT_ACCEPT: Accepts a Connection Request 53

8 FCT_BIND: Binds a Socket Number to an IP Address and a Port 57

9 FCT_CLOSE: Deletes the Specified Socket 61

10 FCT_CONNECT: Establishes a Connection with an IP Address 65

11 FCT_LISTEN: Configuration of a Socket Await Connection 69

12 FCT_RECEIVE: Retrieves Data Available on a Socket 71

13 FCT_SELECT: Multiplexes Requests Over Sockets 73

14 FCT_SEND: Sending Data to a Specified Socket 77

15 FCT_SETSOCKOPT: Sets the Options Associated with the Socket 81

16 FCT_SHUTDOWN: Disables Transmission on the Socket 85

17 FCT_SOCKET: Creation of a New Socket 89

33002551 10/2013 51

Page 52: 33002551_K01_000_10

Advanced

52 33002551 10/2013

Page 53: 33002551_K01_000_10

Unity ProFCT_ACCEPT33002551 10/2013

FCT_ACCEPT: Accepts a Connection Request

Chapter 7FCT_ACCEPT: Accepts a Connection Request

Description

Function DescriptionThe FCT_ACCEPT function is used to accept a connection request received by the specified socket.

This connection request comes from a foreign socket.

Before FCT_ACCEPT is called, a socket must be set up to receive a connection request by issuing the FCT_LISTEN call. The FCT_ACCEPT function:

extracts the first connection request in the queue of pending connectionscreates a connected socket with the same properties as the original socketcompletes the connection between the foreign socket and the new socketand returns a number for the new socket

The new returned socket number is used to read from and write data to the foreign socket. It is not used to accept more connections. The original socket remains open for accepting further connections.

If there are no pending connections in the queue, FCT_ACCEPT returns an error.

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 53

Page 54: 33002551_K01_000_10

FCT_ACCEPT

Representation in LD

Representation in ILLD Module_Number

FCT_ACCEPT Socket_Number, Clie_Index, Gest_Index, Management_Param, Client_Address

Representation in STFCT_ACCEPT(Module_Number, Socket_Number, Clie_Index, Gest_Index, Management_Param, Client_Address);

Description of ParametersThe following table describes the input parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Clie_Index INT Index of first word in Client_Address array

Gest_Index INT Index of first word in Management_Param array

54 33002551 10/2013

Page 55: 33002551_K01_000_10

FCT_ACCEPT

The following table describes the output parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Client_Address ARRAY [0... 3] OF INT Array of 4 words containing the service socket number, the port number and the IP address of the client:

Client_Address[0]: connected socket numberClient_Address[1]: client port numberClient_Address[2]: least significant word of the client IP addressClient_Address[3]: most significant word of the client IP address

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) The operation report can have the following values:

16#00: no error16#09: the socket number is invalid16#16: the FCT_LISTEN function must be called before FCT_ACCEPT16#23: no connection request

33002551 10/2013 55

Page 56: 33002551_K01_000_10

FCT_ACCEPT

56 33002551 10/2013

Page 57: 33002551_K01_000_10

Unity ProFCT_BIND33002551 10/2013

FCT_BIND: Binds a Socket Number to an IP Address and a Port

Chapter 8FCT_BIND: Binds a Socket Number to an IP Address and a Port

Description

Function DescriptionThe FCT_BIND function is used to assign a port number and an internet address to a socket.

A socket is created without an address and cannot be used to receive data (except for connection requests) until it is assigned one. The internet address is fixed by the network module to its local configured IP address. The user is not allowed to use some port numbers because they are already used by the network module. These port numbers are:

20 and 21 (FTP ports)23 (Telnet port)67 and 68 (BOOTP DHCP ports)80 (HTTP port)161 and 162 (SNMP ports)502 (Schneider Electric port)5000 and 5001 (specific ports of module)1024 (TCP USER ports)3124 (I/O port)7400-8400 (RTPS ports)

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 57

Page 58: 33002551_K01_000_10

FCT_BIND

Representation in LD

Representation in ILLD Module_Number

FCT_BIND Socket_Number, Port_Number, Gest_Index, Management_Param

Representation in STFCT_BIND(Module_Number, Socket_Number, Port_Number, Gest_Index, Management_Param);

Description of ParametersThe following table describes the input parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Port_Number INT Port number to be assigned to socket

Gest_Index INT Index of first word in Management_Param array

58 33002551 10/2013

Page 59: 33002551_K01_000_10

FCT_BIND

The following table describes the input/output parameters:

Configuring Port Numbers Above 32KThe data type of the port parameter is an integer. In order to use port numbers higher than 15 bits (higher than 32K), you must use the UINT_TO_INT function block to convert the Unsigned Integer format (encoded in 16 bits) to an Integer format. Use the UINT_TO_INT function block before using EF FCT_BIND or FCT_CONNECT when a port number higher than 32K is used.

Input parameter:

Output parameter:

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34)The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.16#16: The socket is already bound.16#30: The specified port is already in use.16#37: The specified port number is not available.16#41: No route to host.

Parameter Data Type Meaning

UINT_variable UINT input value

Parameter Data Type Meaning

ConvertedVariable INT output value

33002551 10/2013 59

Page 60: 33002551_K01_000_10

FCT_BIND

60 33002551 10/2013

Page 61: 33002551_K01_000_10

Unity ProFCT_CLOSE33002551 10/2013

FCT_CLOSE: Deletes the Specified Socket

Chapter 9FCT_CLOSE: Deletes the Specified Socket

Description

Function DescriptionThe FCT_CLOSE function deletes the specified socket.

NOTE: If the socket number is not indicated or is 0, all open sockets are deleted.

As the sockets were opened with the SO_LINGER option when using FCT_SOCKET, the FCT_CLOSE function is not blocked, even if the queues have not yet been sent or been acknowledged. This is called a hard or abortive close, because the socket’s virtual circuit is reset immediately, and any unsent data is lost.

Any call to the FCT_RECEIVE function to the other side of the circuit will fail with the error message: connection reset (16#36).

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 61

Page 62: 33002551_K01_000_10

FCT_CLOSE

Representation in LD

Representation in ILLD Module_Number

FCT_CLOSE Socket_Number, Gest_Index, Management_Param

Representation in STFCT_CLOSE(Module_Number, Socket_Number, Gest_Index, Management_Param);

Description of ParametersThe following table describes the input parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Number of socket to be deleted. If the value of the Socket_Number is 0, all sockets are deleted.

Gest_Index INT Index of first word in Management_Param array

62 33002551 10/2013

Page 63: 33002551_K01_000_10

FCT_CLOSE

The following table describes the input/output parameters:

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34)The operation report can have the following values:

16#00: No error.16#16: The socket number is invalid.

33002551 10/2013 63

Page 64: 33002551_K01_000_10

FCT_CLOSE

64 33002551 10/2013

Page 65: 33002551_K01_000_10

Unity ProFCT_CONNECT33002551 10/2013

FCT_CONNECT: Establishes a Connection with an IP Address

Chapter 10FCT_CONNECT: Establishes a Connection with an IP Address

Description

Function DescriptionThe FCT_CONNECT function is used to establish a connection to a known port and internet address.

The additional parameters EN and ENO may be configured.

Representation in FBD

Representation in LD

33002551 10/2013 65

Page 66: 33002551_K01_000_10

FCT_CONNECT

Representation in ILLD Module_Number

FCT_CONNECT Socket_Number, Serv_Index, Gest_Index, Server_Address, Management_Param

Representation in STFCT_CONNECT(Module_Number, Socket_Number, Serv_Index, Gest_Index, Server_Address, Management_Param);

Description of ParametersThe following table describes the input parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Serv_Index INT Index of first word in Server_Address array

Gest_Index INT Index of first word in Management_Param array

Server_Address INT Array of 3 words containing the port number and IP address of the server

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34)The operation report can have the following values:

16#00: Correct operation.16#09: Invalid socket number.16#16: Invalid parameter.16#20: Connection is cut.16#24: Connection in progress.16#38: Socket already connected.16#3D: Connection refused.16#41: No route to host.

66 33002551 10/2013

Page 67: 33002551_K01_000_10

FCT_CONNECT

Configuring Port Numbers Above 32KThe data type of the port parameter is an integer. In order to use port numbers higher than 15 bits (higher than 32K), you must use the UINT_TO_INT function block to convert the Unsigned Integer format (encoded in 16 bits) to an Integer format. Use the UINT_TO_INT function block before using EF FCT_BIND or FCT_CONNECT when a port number higher than 32K is used.

Input parameter:

Output parameter:

Parameter Data Type Meaning

UINT_variable UINT input value

Parameter Data Type Meaning

ConvertedVariable INT output value

33002551 10/2013 67

Page 68: 33002551_K01_000_10

FCT_CONNECT

68 33002551 10/2013

Page 69: 33002551_K01_000_10

Unity ProFCT_LISTEN33002551 10/2013

FCT_LISTEN: Configuration of a Socket Await Connection

Chapter 11FCT_LISTEN: Configuration of a Socket Await Connection

Description

Function DescriptionThe FCT_LISTEN function sets up the specified socket to receive connections.

Connection requests are queued on the socket until they are accepted with the FCT_ACCEPT call. The length of the queue is set to 16. If a connection request arrives while the queue is full, the requesting client gets an ECONNREFUSED(16#3D) error.

The additional parameters EN and ENO may be configured.

Representation in FBD

Representation in LD

33002551 10/2013 69

Page 70: 33002551_K01_000_10

FCT_LISTEN

Representation in ILLD Module_Number

FCT_LISTEN Socket_Number, Gest_Index, Management_Param

Representation in STFCT_LISTEN(Module_Number, Socket_Number, Gest_Index, Management_Param);

Description of ParametersThe following table describes the input parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of the network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.

70 33002551 10/2013

Page 71: 33002551_K01_000_10

Unity ProFCT_RECEIVE33002551 10/2013

FCT_RECEIVE: Retrieves Data Available on a Socket

Chapter 12FCT_RECEIVE: Retrieves Data Available on a Socket

Description

Function DescriptionThe FCT_RECEIVE function looks for the data available on the socket. The maximum length of data to read is 240 bytes.

It returns the numbers of bytes read in the socket. You should always test this value \because it is the only way to check the actual number of data bytes stored in the user buffer.

NOTE: FCT_RECEIVE does not return out-of-band data.

The additional parameters EN and ENO may be configured.

Representation in FBD

Representation in LD

33002551 10/2013 71

Page 72: 33002551_K01_000_10

FCT_RECEIVE

Representation in ILLD Module_Number

FCT_RECEIVE Socket_Number, Pbuf_Index, Gest_Index, Management_Param, Received_Data

Representation in STFCT_RECEIVE(Module_Number, Socket_Number, Pbuf_Index, Gest_Index, Management_Param, Received_Data);

Description of ParametersThe following table describes the input parameters:

The following table describes the output parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of the network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Pbuf_Index INT Index of first word in Received_Data array

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Received_Data ARRAY [0... n] OF INT Array of maximum of 240 bytes containing the data read on the socket

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.16#23: No data to read.16#36: The connection has been reset by peer.16#39: The socket is not connected (listening socket).16#3C: The keep alive timed out on broken connection.16#0E: The length of the character string to be received is greater than 240 bytes.

The fourth word of the array should contain the number of bytes received if no error has occurred.

72 33002551 10/2013

Page 73: 33002551_K01_000_10

Unity ProFCT_SELECT33002551 10/2013

FCT_SELECT: Multiplexes Requests Over Sockets

Chapter 13FCT_SELECT: Multiplexes Requests Over Sockets

Description

Function DescriptionThe FCT_SELECT function is used to multiplex I/O requests among multiple sockets. It indicates which sockets have events to process using an array of integers.

For ETY 5103 firmware revision 3.3 or lower:

The socket descriptors are assigned a socket number from 1 to 32:Numbers from 1 to 16 are assigned to sockets created by the Socket function. They are client sockets.Numbers from 17 to 32 are assigned to sockets created by the Accept function. They are server sockets.

The array of the MASK (Socket_Activity) is for diagnosing the status of the listening (server) and connected (client) sockets.

Server Perspective: Any word of the array uses available bits of the array to correspond to the listening socket in the initial step. The Accept function outputs a different socket number to locate its associated bit in the second word of the array, which reports the status of the server connection.Client Perspective: The first word of the array reports the status of the client connection.

For ETY 5103 firmware greater than revision 3.3:

You may have up to 64 sockets that can be used as listening (server) sockets or connected (client) sockets. In a server application, at least 1 socket must be a listening socket. There are no other hard boundaries regarding listening versus connected sockets.To determine the listening sockets, see the socket number provided as output by the Socket function.To determine the connected sockets, see the socket number provided as output by the Accept function.The array of the MASK (Socket_Activity) is for diagnosing the status of the listening and connected sockets, which are now combined into a 2- or 4-word array (see note below). You must use the output of the Socket or Accept function to locate the corresponding bit in the array. See the Socket_Activity in the Description of Parameters table (see page 75).

NOTE: For versions higher than 3.3, a length parameter is required in the Management_Param structure.

33002551 10/2013 73

Page 74: 33002551_K01_000_10

FCT_SELECT

The length field is not used when the high byte of the INTE parameter is set to 00. You should set the length to 8 when the high byte of the INTE parameter is set to 01. A setting of 8 allows you to see the data associated with all 64 connections. If you set the value lower, say to 4, you will see only the data associated with the first 32 connections.

The additional parameters EN and ENO may be configured.

Representation in FBD

Representation in LD

Representation in ILLD Module_Number

FCT_SELECT Mask_Index, Gest_Index, Management_Param, Socket_Activity

Representation in STFCT_SELECT(Module_Number, Mask_Index, Gest_Index, Management_Param, Socket_Activity);

74 33002551 10/2013

Page 75: 33002551_K01_000_10

FCT_SELECT

Description of ParametersThe following table describes the input parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Mask_Index INT Index of first word in the Socket_Activity array

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) For this function, the operation report always returns the value 16#00 indicating that no error has occurred.

33002551 10/2013 75

Page 76: 33002551_K01_000_10

FCT_SELECT

The following table describes the output parameters:

Parameter Type Comment

Socket_Activity ARRAY [0... 1] OF INT- or -ARRAY [0... 3] OF INT (Refer to the note in the Function Description (see page 73) topic.)

Status of each socket. Each bit set to 1 indicates an event on the socket which corresponds to this bit. For example:For version 3.3 or earlier:

If bit 5 of the first word has the value 1, socket 6 will be read by the FCT_ACCEPT function.If bit 3 of the second word has the value 1, socket 20 will be read by the FCT_RECEIVE function.

For versions later than 3.3:If a bit is set to 1 on a listening socket, a server is ready to accept this connection. If a bit is set to 1 on a connected socket, data is ready to be sent or communication has been interrupted.

Client Perspective: Once you have a client connection, the corresponding bit for the connection (socket number) is set to 1 in the array. Example: Socket 33 will be found in the third word, first bit (bit 0).Server Perspective: The listening function opens a socket. This socket number has a corresponding bit set to 1 in the array. Example: Socket 3 will be found in the first word, third bit (bit 2). Then, the Accept function will return a different socket number, and this socket number will have a corresponding bit set to 1 in the array.NOTE: The listening function socket number bit will remain set to 1 until the socket is closed.

76 33002551 10/2013

Page 77: 33002551_K01_000_10

Unity ProFCT_SEND33002551 10/2013

FCT_SEND: Sending Data to a Specified Socket

Chapter 14FCT_SEND: Sending Data to a Specified Socket

Description

Function DescriptionThe FCT_SEND function is used to send data to a foreign socket. The maximum length of data to send is 240 bytes.

NOTE: it is not possible to send out of band data.

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 77

Page 78: 33002551_K01_000_10

FCT_SEND

Representation in LD

Representation in ILLD Module_Number

FCT_SEND Socket_Number, Pbuf_Index, Gest_Index,Data_to_Send, Management_Param

Representation in STFCT_SEND(Module_Number, Socket_Number, Pbuf_Index, Gest_Index,Data_to_Send, Management_Param);

78 33002551 10/2013

Page 79: 33002551_K01_000_10

FCT_SEND

Description of ParametersThe following table describes the input parameters:

The following table describes the input/output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

Pbuf_Index INT Index of first word in Pbuf_Address array

Gest_Index INT Index of first word in Management_Param array

Data_to_Send ARRAY [0... n] OF INT Array of a maximum of 120 words containing the data to be sent

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.16#20: Communication is broken.16#23: The socket is full.16#36: The connection has been reset by peer.16#39: The socket is not connected (listening socket).16#0E: The length of the character string to be sent is greater than 240 bytes.

The fourth word of the array should contain the number of bytes sent if no error has occurred.

33002551 10/2013 79

Page 80: 33002551_K01_000_10

FCT_SEND

80 33002551 10/2013

Page 81: 33002551_K01_000_10

Unity ProFCT_SETSOCKOPT33002551 10/2013

FCT_SETSOCKOPT: Sets the Options Associated with the Socket

Chapter 15FCT_SETSOCKOPT: Sets the Options Associated with the Socket

Description

Function DescriptionThe FCT_SETSOCKOPT function sets options associated with the specified socket. Some options are set automatically when the socket is created by the FCT_SOCKET (see page 89) function.

The following options are available:

DONT_ROUTE: indicates that the outgoing data should not be routed. Packets directed at unconnected nodes are dropped.RESET_DONT_ROUTE: resets DONT_ROUTE.KEEP_ALIVE: ensures a connection is kept active by regularly and automatically sending packets on the socket.RESET_KEEP_ALIVE: resets KEEP_ALIVE.

These options are selected by assigning a number in the Option_Type variable.

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 81

Page 82: 33002551_K01_000_10

FCT_SETSOCKOPT

Representation in LD

Representation in ILLD Module_Number

FCT_SETSOCKOPT Socket_Number, Option_Type, Gest_Index, Management_Param

Representation in STFCT_SETSOCKOPT(Module_Number, Socket_Number, Option_Type, Gest_Index, Management_Param);

Description of ParametersThe following table describes the input parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

82 33002551 10/2013

Page 83: 33002551_K01_000_10

FCT_SETSOCKOPT

The following table describes the input/output parameters:

Option_Type INT Type of option to be associated with socket. The values which can be assigned to this word are as follows:

1 for DONT_ROUTE2 for RESET_DONT_ROUTE3 for KEEP_ALIVE4 for RESET_KEEP_ALIVE

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT

Function management array (see page 34) The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.16#16: Invalid option.

The fourth word of the array should contain the number of bytes stored in the buffer.

Parameter Type Comment

33002551 10/2013 83

Page 84: 33002551_K01_000_10

FCT_SETSOCKOPT

84 33002551 10/2013

Page 85: 33002551_K01_000_10

Unity ProFCT_SHUTDOWN33002551 10/2013

FCT_SHUTDOWN: Disables Transmission on the Socket

Chapter 16FCT_SHUTDOWN: Disables Transmission on the Socket

Description

Function DescriptionThe FCT_SHUTDOWN function is used to disable either send/receive transmission on the socket.

The TCP window is not changed and incoming data will be accepted (but not acknowledged) until the window is exhausted.

NOTE: the function does not close the socket, and resources assigned to the socket are not freed until the FCT_CLOSE is sent. However you should not attempt to reuse the socket after the FCT_SHUTDOWN function has been executed.

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 85

Page 86: 33002551_K01_000_10

FCT_SHUTDOWN

Representation in LD

Representation in ILLD Module_Number

FCT_SHUTDOWN Socket_Number, Shutdown_Option, Gest_Index, Management_Param

Representation in STFCT_SHUTDOWN(Module_Number, Socket_Number, Shutdown_Option, Gest_Index,Management_Param);

Description of ParametersThe following table describes the input parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be used (firmware version must be higher than 3.3).

Socket_Number INT Socket number

86 33002551 10/2013

Page 87: 33002551_K01_000_10

FCT_SHUTDOWN

The following table describes the input/output parameters:

Shutdown_Option INT Disable transmission option:0: No further receives are allowed on the socket.1: No further sends are allowed on the socket; a FIN message is sent.2: No further sends or receives are allowed on the socket. This option does the same as both of the previous options together.

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34)The operation report can have the following values:

16#00: No error.16#09: The socket number is invalid.16#16: An argument is not valid.16#39: The socket is not connected.

Parameter Type Comment

33002551 10/2013 87

Page 88: 33002551_K01_000_10

FCT_SHUTDOWN

88 33002551 10/2013

Page 89: 33002551_K01_000_10

Unity ProFCT_SOCKET33002551 10/2013

FCT_SOCKET: Creation of a New Socket

Chapter 17FCT_SOCKET: Creation of a New Socket

Description

Function DescriptionThe FCT_SOCKET function creates a new socket and returns its socket number. The socket is a TCP/IP communication entity.

It is created as a STREAM TCP socket with the following options:

SO_LINGER without timeout. This option controls the action taken when unsent data is queued on a socket and a FCT_CLOSE function is performed. NO_DELAY. The delay acknowledgment algorithm is disabled. Data is sent immediately over the network instead of waiting for the window to be completely full.KEEP_ALIVE. The connection is kept active by regularly and automatically sending packets on the socket.REUSEADDR. Authorizes the local port for reuse when a FCT_BIND is called.

The additional parameters EN and ENO may be configured.

Representation in FBD

33002551 10/2013 89

Page 90: 33002551_K01_000_10

FCT_SOCKET

Representation in LD

Representation in ILLD Module_Number

FCT_SOCKET Gest_Index,Management_Param, Socket_Number

Representation in STFCT_SOCKET(Module_Number, Gest_Index, Management_Param, Socket_Number);

Description of ParametersThe following table describes the input parameters:

The following table describes the output parameters:

Parameter Type Comment

Module_Number INT Slot number of network module in rack 0.Low byte is the slot number of network module in rack 0.High byte can be used to extend the number of sockets.

00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.01: Up to 64 sockets can be assigned (firmware version must be higher than 3.3).

Gest_Index INT Index of first word in Management_Param array

Parameter Type Comment

Socket_Number INT Number of socket created if no error has occurred.

90 33002551 10/2013

Page 91: 33002551_K01_000_10

FCT_SOCKET

The following table describes the input/output parameters:

Parameter Type Comment

Management_Param ARRAY [0... 3] OF INT Function management array (see page 34) The operation report can have the following values:

16#00: No error.16#37: The maximum number of sockets has been reached.

33002551 10/2013 91

Page 92: 33002551_K01_000_10

FCT_SOCKET

92 33002551 10/2013

Page 93: 33002551_K01_000_10

Unity ProDFB Library33002551 10/2013

DFB Library

Part IVDFB Library

33002551 10/2013 93

Page 94: 33002551_K01_000_10

DFB Library

94 33002551 10/2013

Page 95: 33002551_K01_000_10

Unity ProDFB Library33002551 10/2013

DFB Library

Chapter 18DFB Library

OverviewThe TCP communication DFB library for Premium PLCs is used to transfer blocks of data between a PLC application and a remote application via a TCP/IP connection established at the initiative of the remote application.

The remote application is executed on a device that supports the TCP/IP communication profile.

What Is in This Chapter?This chapter contains the following topics:

Topic Page

DFB Library Introduction 96

TCP_CNX DFB 97

TCP_SEND DFB 100

TCP_RECEIVE DFB 102

33002551 10/2013 95

Page 96: 33002551_K01_000_10

DFB Library

DFB Library Introduction

OverviewThe communication DFB library is comprised of the following:

connection management TCP_CNX DFBTCP_SEND DFB for transmission of data blocks (8 kb maximum size)TCP_RECEIVE DFB for receipt of data blocks (8 kb maximum size)

NOTE: TCP communication DFBs for Premium PLCs use the services from the TCP Open for Premium range to manage TCP connections and to send and receive byte flows on its connections.

The function blocks use the messaging services implemented in the Premium processor. As a result, all the communication blocks can be executed over several PLC cycles. The CPU/module exchange of a datagram is made per PLC cycle.

DFB MaintenanceThe execution of function blocks is explicitly maintained. You must program maintenance of the DFB as long as its ACTIVITY bit is active.

NOTE: Do not execute the same DFB instance more than once in the same PLC cycle.

Maintenance of the DFBs is mandatory since all the communication function blocks are executed over several PLC cycles. As soon as the DFB is called, it is restarted for each turn of the PLC cycle as long as its ACTIVITY bit is equal to 1.

96 33002551 10/2013

Page 97: 33002551_K01_000_10

DFB Library

TCP_CNX DFB

OverviewThe TCP_CNX DFB manages the connections with remote clients as well as the operating modes of the connections. A TCP_CNX DFB is informed of breaks in connections by a TCP_SEND or TCP_RECEIVE DFB via the status of the management words. Only one TCP_CNX DFB instance exists for a TSX ETY 110 WS/5103 module.

Input Parameters

Input/Output Parameters

Parameter Type Description

RST bit Setting this input to 1:interrupts the exchanges in progresscloses all connections

Parameter Type Description

MANAGNT word table Management table common to all DBFs

33002551 10/2013 97

Page 98: 33002551_K01_000_10

DFB Library

Output Parameters

Internal Public Data

Parameter Type Description

ERROR bit This output bit is set to 1 if the exchange is not carried out correctly.The status word indicates the type of error that has occurred.

Parameter Type Write/Read Variables

Description

DEVICE word W Module number.Number of the physical slot where the TSX ETY 110 ES/5103 module is located in the rack.

PORT word table W Local port number No. i.Table of 16 local service ports to be listened to (signed value ≥ 5010). The value 0 indicates a non-significant value.

IPACCEPT double word

W IP address of the remote machine No. i.Word 4-byte IP address table from table 8. Remote machines authorized to connect to the PLC. The value 9 indicates a non-significant value.

EOM byte W End of Message character.This parameter defines the presence and the value of an End of Message character to be used in the message exchanges:

EOM = 0: no End of Message characterEOM from 0x01 to 0xFF: value of End of Message character:

added by the module during transmissionchecked and deleted by the module during reception

IPCNXi character string

R IP address of the remote machine No. i.Read-only character string to be used for maintenance only. Indicates the IP address of the remote machine in the format aaa.bbb.ccc.ddd connected to the port with index i in the configuration. The value 0.0.0.0 indicates that no machine is connected to this port.

ACTIVITY bit R This output bit is at 1 when the DFB is in progress and needs to be maintained. It is set to 0 with a warm or cold restart or a DFB RESET.

STATUS word R This word is only meaningful if the ERROR output bit is set to 1. It indicates the code of the error that occurred during the exchange. (Each word bit set to 1 indicates an error.)

98 33002551 10/2013

Page 99: 33002551_K01_000_10

DFB Library

OperationThe TCP_CNX DFB must be called at each turn of the PLC cycle to ensure permanent management of the TCP ports.

Listening to the configured ports starts if the RST and ACTIVITY bits are set to 0. Then, the ACTIVITY bit remains at 1 until the application allows the RST bit to return to 0.

If communication with the module is not correct, the output ERROR bit is set to 1.

At any time, setting the RST bit (priority input) to 1 enables all the connections in progress or on standby to be interrupted. The ACTIVITY bit (exchange finished) is set to 0, and the ERROR bit is set to 1. The status word <TCP_CNX instance name>.STATUS indicates the type of error.

At a cold or warm restart, the TCP_CNX DFB automatically returns to listen mode for the configured ports.

33002551 10/2013 99

Page 100: 33002551_K01_000_10

DFB Library

TCP_SEND DFB

OverviewThe TCP_SEND DFB allows a data message to be sent to a remote client application via a TCP/IP connection. The maximum size of the message is 8 kb.

Input Parameters

Input/Output Parameters

Parameter Type Description

RST bit Setting this bit to 1:interrupts the exchange in progress (if the ACTIVITY bit is set to 1)closes the connectionsets the ACTIVITY information bit to 0 and the ERROR output bit to 1

The error code is found in the STATUS word.

BUF word table This variable defines the address of the first %MWi word of the buffer in order to send the message.

Parameter Type Description

MANAGNT word table Management table common to all DFBs

100 33002551 10/2013

Page 101: 33002551_K01_000_10

DFB Library

Output Parameters

Internal Public Data

OperationData transfer is triggered when the TCP_SEND DFB is called, if the RST and ACTIVITY bits are set to 0. During the exchange, the ACTIVITY bit is set to 1. At the end of transmission, the ACTIVITY bit is set to 0. In addition, if the exchange is not correct, the ERROR output bit is set to 1.

At any time, setting the RST bit (priority input) to 1 allows the exchange in progress to be interrupted. The ACTIVITY bit (exchange finished) is set to 0, and the ERROR bit is set to 1. The status word <TCP_SEND instance name>.STATUS indicates the type of error. If the connection is open, it closes, and the module waits for the incoming connection. The TCP_CNX DFB (see page 97) reestablishes the connection to the TCP service port to start sending messages again.

When a message is sent, the following process occurs:check input parameters (IP address of the remote machine, number of local port)search for the open connection with the remote client requestedsend message by block of 240 bytes (adding the End of Message character, if the option is requested)

Parameter Type Description

ERROR bit This output bit is set to 1 if the exchange is not carried out correctly.The STATUS word indicates the type of error that has occurred.

Parameter Type Write/Read Variables

Description

DEST double word

W This variable defines the IP address of the remote machine on which the client is connected to the local port.By default, DEST = 0. The message is sent to the only remote client station connected to the local service port of the PLC.

PORT word W This variable defines the local port number to which the remote client is connected.

SIZE word W This variable defines the size of the message to be sent, from 0 to 8192 bytes.

ACTIVITY bit R This bit is set to 1 when an exchange is in progress. It is set to 0 when the exchange is finished.

INHIB bit R This bit enables the error warning to be inhibited. The ERROR output bit and the STATUS word remain at 0 (execution of the block is not interrupted).

STATUS word R This word is only meaningful if the ERROR output bit is set to 1. It indicates the error code that occurred during the exchange (each word bit set to 1 indicates an error).

33002551 10/2013 101

Page 102: 33002551_K01_000_10

DFB Library

TCP_RECEIVE DFB

OverviewThe TCP_RECEIVE DFB allows a data message to be received from a remote client application via a TCP/IP connection. The maximum size of the message is 8 kb.

Input Parameters

Input/Output Parameters

Parameter Type Description

RST bit Setting this bit to 1:interrupts the exchange in progress (if the ACTIVITY bit is set to 1)closes the connectionsets the ACTIVITY bit to 0 and the ERROR output bit to 1

The error code is found in the STATUS word.

Parameter Type Description

BUF word table This input and output parameter defines the address of the first %MWi word of the buffer in order to receive the message.

MANAGNT word table Management table common to all DFBs

102 33002551 10/2013

Page 103: 33002551_K01_000_10

DFB Library

Output Parameters

Internal Public Data

Parameter Type Description

ERROR bit This output bit is set to 1 if the exchange is not carried out correctly.The STATUS word indicates the type of error that has occurred.

Parameter Type Write/Read Variables

Description

FRM double word W This variable defines the IP address of the remote machine on which the client is connected.By default, FRM = 0, and the DFB awaits the message sent by the unique remote client connected to the local service port of the PLC.

PORT word W This variable defines the number of the local port to which the remote client is connected.

SIZE word W This variable defines the size of the message to be sent, from 0 to 8192 bytes.

ACTIVITY bit R This variable is set to 0 by the DFB when the exchange is finished. If the ERROR output bit is set to 0, the ACTIVITY bit indicates that the message has been received successfully. However, if the ERROR bit is set to 1, the ACTIVITY bit indicates that the exchange finished, but has errors.

INHIB bit W This variable allows the error warning to be inhibited. The ERROR output bit and the STATUS word remain at 0 (execution of the block is not interrupted).

STATUS word R This word is only significant if the ERROR output bit is set to 1. It indicates the error code that occurred during the exchange (each word bit set to 1 indicates an error).

LENGTH word R This variable contains the number of bytes received if the ERROR output bit is set to 0.

33002551 10/2013 103

Page 104: 33002551_K01_000_10

DFB Library

OperationData transfer is triggered when the TCP_RECEIVE DFB is called, if the RST and ACTIVITY bits are set to 0. During the exchange, the ACTIVITY bit is set to 1. At the end of transmission, the ACTIVITY bit is set to 0. In addition, if the exchange is not correct, the ERROR output bit is set to 1.

At any time, setting the RST bit (priority input) to 1 allows the exchange in progress to be interrupted. The ACTIVITY bit (exchange finished) is set to 0, and the ERROR bit is set to 1. The status word <TCP_RECEIVE instance name>.STATUS indicates the type of error. If the connection is open, it closes, and the module waits for the incoming connection. Any messages in the module’s receive buffers are lost.

When a message is received, the following process occurs:check input parameters (IP address of the remote machine, number of local port)search for the open connection with remote client requestedEF block receiving the message is queued to receive message

As soon as a DFB is active for a given connection, the module awaits the message to be received, and the first two bytes received indicate the length of the message. The data is then transferred into the PLC’s words in frames of 240 bytes.

When the full message is copied onto the PLC:The DFB checks the end of character message (if this option has been configured).The STATUS and LENGTH parameters of the DFB are filled in, and the ACTIVITY and ERROR bits are set for the module application.

104 33002551 10/2013

Page 105: 33002551_K01_000_10

Unity Pro

33002551 10/2013

Appendices

3

3002551 10/2013 105
Page 106: 33002551_K01_000_10

106 33002551 10/2013

Page 107: 33002551_K01_000_10

Unity ProSystem Objects33002551 10/2013

System Objects

Appendix ASystem Objects

Subject of this ChapterThis chapter describes the system bits and words of Unity Pro language.

Note: The symbols, associated with each bit object or system word, mentioned in the descriptive tables of these objects, are not implemented as standard in the software, but can be entered using the data editor.

They are proposed in order to ensure the homogeneity of their names in the different applications.

What Is in This Chapter?This chapter contains the following topics:

Topic Page

System Bit Introduction 108

Description of System Bits %S15 to %S21 109

Description of System Words %SW12 to %SW29 112

33002551 10/2013 107

Page 108: 33002551_K01_000_10

System Objects

System Bit Introduction

GeneralThe Modicon M340, Premium, Atrium, Quantum, and Momentum Unity PLCs use %Si system bits which indicate the state of the PLC, or they can be used to control how it operates.

These bits can be tested in the user program to detect any functional development requiring a set processing procedure.

Some of these bits must be reset to their initial or normal state by the program. However, the system bits that are reset to their initial or normal state by the system must not be reset by the program or by the terminal.

108 33002551 10/2013

Page 109: 33002551_K01_000_10

System Objects

Description of System Bits %S15 to %S21

Detailed DescriptionDescription of system bits %S15 to %S21:

BitSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momentum Unity

%S15STRINGERROR

Character string fault

Normally set to 0, this bit is set to 1 when the destination zone for a character string transfer is not of sufficient size (including the number of characters and the end of string character) to receive this character string.The application stops in error state if the %S78 bit has been to set to 1.This bit must be reset to 0 by the application.This bit is not available on Quantum safety PLCs.

0 YES YES YES(except

for safety PLCs)

YES

%S16IOERRTSK

Task input/output fault

Normally set to 1, this bit is set to 0 by the system when a fault on an in-rack module or device on Fipio is detected (e.g. non-compliant configuration, exchange fault, hardware fault, etc.).This bit must be reset to 1 by the user.

1 YES YES YES YES

CAUTIONUNEXPECTED APPLICATION BEHAVIOR - SPECIFIC VARIABLE BEHAVIOROn Quantum, network communication errors with remote devices detected by communication modules (NOM, NOE, NWM, CRA, CRP) and motion modules (MMS) are not reported on bits %S10, %S16 and %S119.

Failure to follow these instructions can result in injury or equipment damage.

33002551 10/2013 109

Page 110: 33002551_K01_000_10

System Objects

BitSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum Unity

%S17CARRY

Rotate shift output

Normally at 0.During a rotate shift operation, this bit takes the state of the outgoing bit.

0 YES YES YES YES

%S18OVERFLOW

Overflow or arithmetic error

Normally set to 0, this bit is set to 1 in the event of a capacity overflow if there is:

a result greater than + 32 767 or less than - 32 768, in single length,result greater than + 65 535, in unsigned integer,a result greater than + 2 147 483 647 or less than - 2 147 483 648, in double length,result greater than +4 294 967 296, in double length or unsigned integer,real values outside limits,division by 0,the root of a negative number,forcing to a non-existent step on a drum,stacking up of an already full register, emptying of an already empty register.

0 YES YES YES YES

Continued%S18OVERFLOW

Overflow or arithmetic error

There is only one case for which bit %S18 is not raised by the Modicon M340, Modicon M580, and Momentum PLCs when real values are outside limits. It is only if denormalized operands or some operations which generate denormalized results are used (gradual underflow).It must be tested by the user program after each operation where there is a risk of overflow, then reset to 0 by the user if there is indeed an overflow.When the %S18 bit switches to 1, the application stops in error state if the %S78 bit has been to set to 1.

0 YES YES YES YES

110 33002551 10/2013

Page 111: 33002551_K01_000_10

System Objects

%S19OVERRUN

Task period overrun (periodical scanning)

Normally set to 0, this bit is set to 1 by the system in the event of a time period overrun (i.e. task execution time is greater than the period defined by the user in the configuration or programmed into the %SW word associated with the task). The user must reset this bit to 0. Each task manages its own %S19 bit.

0 YES YES YES YES

%S20INDEXOVF

Index overflow

Normally set to 0, this bit is set to 1 when the address of the indexed object becomes less than 0 or exceeds the number of objects declared in the configuration.In this case, it is as if the index were equal to 0.It must be tested by the user program after each operation where there is a risk of overflow, then reset to 0 if there is indeed an overflow. When the %S20 bit switches to 1, the application stops in error state if the %S78 bit has been to set to 1.This bit is not available on Quantum safety PLCs.

0 YES YES YES(except

for safety PLCs)

YES

%S211RSTTASKRUN

First task cycle

Tested in a task (Mast, Fast, Aux0, Aux1, Aux2 Aux3), the bit %S21 indicates the first cycle of this task, including after a cold start with automatic start in run and a warm start. %S21 is set to 1 at the start of the cycle and reset to zero at the end of the cycle.Note: The bit %S21 does not have the same meaning in Unity Pro as in PL7.

0 YES YES YES YES

BitSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum Unity

33002551 10/2013 111

Page 112: 33002551_K01_000_10

System Objects

Description of System Words %SW12 to %SW29

Detailed DescriptionDescription of system words %SW12 to %SW29:

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

%SW12UTWPORTADDR

Processor serial port address

For Premium: Uni-Telway address of terminal port (in slave mode) as defined in the configuration and loaded into this word on cold start. The modification of the value of this word is not taken into account by the system.For Modicon M340: Gives the Modbus slave address of the CPU serial port. Modification is not taken into account. Is 0 if the CPU does not have a Serial Port link.

- YES-340NO-580

YES NO(see

%SW12 below)

YES

%SW12APMODE

Mode of the application processor

For Quantum safety PLC only, this word indicates the operating mode of the application processor of the CPU module.

16#A501 = maintenance mode16#5AFE = safe mode

Any other value is interpreted as an error.Note: In a HotStand By safety system, this word is exchanged from the primary to the standby PLC to inform the standby PLC of the safe or maintenance mode.For Momentum, this word contains the slave address for serial channel 0.

16#A501 NO NO YESOnly on safety PLCs

YES

112 33002551 10/2013

Page 113: 33002551_K01_000_10

System Objects

%SW13XWAYNETWADDR

Main address of the station

This word indicates the following for the main network (Fipway or Ethway):

the station number (least significant byte) from 0 to 127,the network number (most significant byte) from 0 to 63,

(value of the micro-switches on the PCMCIA card).

254(16#00FE)

NO YES NO(see

%SW13 below)

NO

%SW13INTELMODE

Mode of the Intel processor

For Quantum safety PLC only, this word indicates the operating mode of the Intel Pentium processor of the CPU module.

16#501A = maintenance mode16#5AFE = safe mode

Any other value is interpreted as an error.Note: In a HotStand By safety system, this word is exchanged from the primary to the standby PLC to inform the standby PLC of the safe or maintenance mode.

- NO NO YESOnly on safety PLCs

NO

%SW14OSCOMMVERS

Commercial version of PLC processor

This word contains the current Operating System (OS) version of the PLC processor.Example: 16#0135version: 01issue number: 35

- YES YES YES YES

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

33002551 10/2013 113

Page 114: 33002551_K01_000_10

System Objects

%SW15OSCOMMPATCH

PLC processor patch version

This word contains the commercial version of the PLC processor patch.It is coded onto the least significant byte of the word.Coding: 0 = no patch, 1 = A, 2 = B...Example: 16#0003 corresponds to patch C.

- YES YES YES YES

%SW16OSINTVERS

Firmware version number

This word contains the Firmware version number in hexadecimal of the PLC processor firmware.Example: 16#0011version: 2.1VN: 17

- YES YES YES YES

%SW17FLOATSTAT

Error status on floating operation

When an error in a floating arithmetic operation is detected, bit %S18 is set to 1 and %SW17 error status is updated according to the following coding:

%SW17.0 = Invalid operation / result is not a number,%SW17.1 =Denormalized operand / result is acceptable (flag not managed by Modicon M340 or Quantum Safety PLCs),%SW17.2 = Division by 0 / result is infinity,%SW17.3 = Overflow / result is infinity,%SW17.4 = Underflow / result is 0,%SW17.5 to 15 = not used.

This word is reset to 0 by the system on cold start, and also by the program for re-usage purposes.

0 YES YES YESOnly on safety PLCs

YES

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

114 33002551 10/2013

Page 115: 33002551_K01_000_10

System Objects

%SD18:%SW18 and%SW19100MSCOUNTER

Absolute time counter

%SW18 represents the least significant bytes and %SW19 the most significant bytes of the double word %SD18, which is incremented by the system every 1/10th of a second. The application can read or write these words in order to perform duration calculations.%SD18 is incremented systematically, even in STOP mode and equivalent states. However, times when the PLC is switched off are not taken into account, since the function is not linked to the real-time scheduler, but only to the real-time clock.For Quantum safety PLC, knowing that the 2 processors must process exactly the same data, the value of %SD18 is updated at the beginning of the mast task, and then frozen during the application execution.

0 YES YES YES YES

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

33002551 10/2013 115

Page 116: 33002551_K01_000_10

System Objects

%SD20:%SW20 and%SW21MSCOUNTER

Absolute time counter

For M340, Momentum and Quantum PLCs %SD20 is incremented every 1/1000th of a second by the system (even when the PLC is in STOP, %SD20 is no longer incremented if the PLC is powered down). %SD20 can be read by the user program or by the terminal.%SD20 is reset on a cold start.%SD20 is not reset on a warm start.For Premium TSX P57 1•4M/2•4M/3•4M/C024M/024M and TSX PCI57 204M/354M PLCs, %SD20 is incremented by 5 every 5/1000th of a second by the system. For all the others Premium PLCs, %SD20 is time counter at 1 ms like Quantum and M340 PLCs. For Quantum safety PLC, knowing that the 2 processors must process exactly the same data, the value of %SD18 is updated at the beginning of the mast task, and then frozen during the application execution.

0 YES YES YES YES

%SW23 Rotary switch value

The least significant byte contains the Ethernet processor rotary switch.It can be read by the user program or by the terminal.

- YES-340NO-580

NO NO NO

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

116 33002551 10/2013

Page 117: 33002551_K01_000_10

System Objects

%SW26 Number of requests processed

This system word allows to verifiy on server side the number of requests processed by PLC per second.

- YES NO NO YES

%SW27%SW28%SW29

System overhead time

%SW27 is the last system overhead time.%SW28 contains the maximum system overhead time.%SW29 contains the minimum system overhead time.

The system overhead time depends on the configuration (number of I/O...) and on the current cycle requests (communication, diagnostics).System overhead time = Mast Cycle Time - User code execution time.These can be read and written by the user program or by the terminal.

- YES NO NO YES

WordSymbol

Function Description Initial state

Modicon M340 & M580

Premium Atrium

Quantum Momen-tum

Unity

33002551 10/2013 117

Page 118: 33002551_K01_000_10

System Objects

118 33002551 10/2013

Page 119: 33002551_K01_000_10

Unity ProGlossary33002551 10/2013

Glossary

0-9%I

According to the CEI standard, %I indicates a language object of type discrete IN.

%IWAccording to the CEI standard, %IW indicates a language object of type analog IN.

%KWAccording to the CEI standard, %KW indicates a language object of type constant word.

%MAccording to the CEI standard, %M indicates a language object of type memory bit.

%MWAccording to the CEI standard, %MW indicates a language object of type memory word.

%QAccording to the CEI standard, %Q indicates a language object of type discrete OUT.

%QWAccording to the CEI standard, %QW indicates a language object of type analog OUT.

AADDM_TYPE

This predefined type is used as an output for the ADDM function. This is an ARRAY[0..8] OF Int. You can find it in the library, in the same family as the EFs that use it.

ADDR_TYPEThis predefined type is used as an output for the ADDR function. This is an ARRAY[0..5] OF Int. You can find it in the library, in the same family as the EFs that use it.

ANL_INANL_IN is the abbreviation of the analog input data type. It is used when processing analog values. %IW addresses in the configured analog input module, which are specified in the list of I/O components, are automatically assigned to data types, and therefore must be occupied by unassigned variables only.

ANL_OUTANL_OUT is the abbreviation of the analog output data type. It is used when processing analog values. %MW addresses in the configured analog input module, which are specified in the list of I/O components, are automatically assigned to data types, and therefore must be occupied by unassigned variables only.

33002551 10/2013 119

Page 120: 33002551_K01_000_10

Glossary

ANYThere is a hierarchy among the various data types. In the DFBs, it is sometimes possible to declare variables that can contain several types of values. In that case we use ANY_xxx types.

The figure below describes this hierarchical structure:

ARRAYAn ARRAY is a table containing elements of a single type.

The syntax is as follows: ARRAY [<limits>] OF <Type>

Example:

ARRAY [1..2] OF BOOL is a one-dimensional table with two elements of type BOOL.

ARRAY [1..10, 1..20] OF INT is a two-dimensional table with 10x20 elements of type INT.

ART(application response time) The time a PLC/ application takes to react to a given input. ART is measured from the time a physical signal in the PLC turns on and triggers a write command until the remote output turns on to signify that the data has been received.

120 33002551 10/2013

Page 121: 33002551_K01_000_10

Glossary

Assigned variablesA variable whose position in the PLC memory can be known. For example, the Water_pressure variable is associated with %MW102. Water_pressure is said to be assigned.

BBCD

BCD is the abbreviation of the Binary Coded Decimal format.

BCD can be used to represent decimal numbers between 0 and 9 using a set of four bits (nybble).

In this format, the four bits used to encode decimal numbers have an unused range of combinations.

Example of BCD encoding: The number 2,450 is encoded: 0010 0100 0101 0000

BOOLBOOL is the abbreviation for the Boolean type. This is the basic data type in computing. A BOOL variable can have either of the following two values: 0 (FALSE) or 1 (TRUE).

A bit extracted from a word is of type BOOL, for example: %MW10.4.

BYTEWhen 8 bits are grouped together, they are called a BYTE. You can enter a BYTE either in binary mode or in base 8.

The BYTE type is encoded in an 8 bit format which, in hexadecimal format, ranges from 16#00 to 16#FF.

DDATE

The DATE type, encoded in BCD in a 32 bit format, contains the following information:

the year encoded in a 16 bit field;the month encoded in an 8 bit field;the day encoded in an 8 bit field.

The DATE type must be entered as follows: D#<Year>-<Month>-<Day>

33002551 10/2013 121

Page 122: 33002551_K01_000_10

Glossary

This table shows the upper/lower limits of each field:

DATE_AND_TIMESee DT.

DBCDRepresentation of a double integer in double BCD format.

BCD format can be used to represent decimal numbers between 0 and 9 using a set of four bits.

In this format, the four bits used to encode decimal numbers have an unused range of combinations.

Example of DBCD encoding: The number 78,993,016is encoded: 0111 1000 1001 1001 0011 0000 0001 0110

DDTDDT is the abbreviation of Derived Data Type.

A derived data type is a set of elements with the same type (ARRAY) or with different types (structure).

Device DDT (DDDT)A Device DDT is a DDT predefined by the manufacturer and not modifiable by user. It contains the I/O language elements of an I/O module.

DFBDFB is the abbreviation of Derived Function Block.

DFB types are function blocks that can be defined by the user in ST, IL, LD or FBD language.

Using these DFB types in an application makes it possible to:

simplify the design and entry of the program;make the program easier to read;make it easier to debug;reduce the amount of code generated.

Field Limits Comment

Year [1990,2099] Year

Month [01,12] The leading 0 is displayed; it can be omitted during data entry.

Day [01,31] For months 01/03/05/07/08/10/12

[01,30] For months 04/06/09/11

[01,29] For month 02 (leap years)

[01,28] For month 02 (non-leap years)

122 33002551 10/2013

Page 123: 33002551_K01_000_10

Glossary

DINTDINT is the abbreviation of Double INTeger (encoded in 32 bits).

The upper/lower limits are as follows: -(2 to the power of 31) to (2 to the power of 31) - 1.

Example:

-2147483648, 2147483647, 16#FFFFFFFF.

DTDT is the abbreviation of Date and Time.

The DT type, encoded in BCD in a 64 bit format, contains the following information:

the year encoded in a 16 bit field;the month encoded in an 8 bit field;the day encoded in an 8 bit field;the time encoded in an 8 bit field;the minutes encoded in an 8 bit field;the seconds encoded in an 8 bit field.

NOTE: The 8 least significant bits are not used.

The DT type must be entered as follows:

DT#<Year>-<Month>-<Day>-<Hour>:<Minutes>:<Seconds>This table shows the upper/lower limits of each field:

Field Limits Comment

Year [1990,2099] Year

Month [01,12] The leading 0 is displayed; it can be omitted during data entry.

Day [01,31] For months 01/03/05/07/08/10/12

[01,30] For months 04/06/09/11

[01,29] For month 02 (leap years)

[01,28] For month 02 (non-leap years)

Hour [00,23] The leading 0 is displayed; it can be omitted during data entry.

Minute [00,59] The leading 0 is displayed; it can be omitted during data entry.

Second [00,59] The leading 0 is displayed; it can be omitted during data entry.

33002551 10/2013 123

Page 124: 33002551_K01_000_10

Glossary

DWORDDWORD is the abbreviation of Double Word.

The DWORD type is encoded in a 32 bit format.

This table shows the upper/lower limits of each of the bases that can be used:

Examples of representation:

EEBOOL

EBOOL is the abbreviation of Extended BOOLean. An EBOOL type has a value (0 (FALSE) or 1 (TRUE), but also rising or falling edges and forcing functions.

An EBOOL variable occupies one byte in memory.

The byte contains the following information:

one bit for the value;one bit for the history (whenever the object changes state, the value is copied to the history bit);one bit for forcing (equal to 0 if the object is not forced, or 1 if the bit is forced).

The default value of each bit is 0 (FALSE).

Base Lower limit Upper limit

Hexadecimal 16#0 16#FFFFFFFF

Octal 8#0 8#37777777777

Binary 2#0 2#11111111111111111111111111111111

Data Representation in one of the bases

00000000000010101101110011011110 16#ADCDE

00000000000000010000000000000000 8#200000

00000000000010101011110011011110 2#10101011110011011110

124 33002551 10/2013

Page 125: 33002551_K01_000_10

Glossary

EFEF is the abbreviation of Elementary Function.

This is a block used in a program which performs a predefined logical function.

A function does not have any information on the internal state. Several calls to the same function using the same input parameters will return the same output values. You will find information on the graphic form of the function call in the "[functional block (instance)]". Unlike a call to a function block, function calls include only an output which is not named and whose name is identical to that of the function. In FBD, each call is indicated by a unique [number ] via the graphic block. This number is managed automatically and cannot be modified.

You position and configure these functions in your program in order to execute your application.

You can also develop other functions using the SDKC development kit.

EFBEFB is the abbreviation of Elementary Function Block.

This is a block used in a program which performs a predefined logical function.

EFBs have states and internal parameters. Even if the inputs are identical, the output values may differ. For example, a counter has an output indicating that the preselection value has been reached. This output is set to 1 when the current value is equal to the preselection value.

Elementary functionSee EF.

ENEN stands for ENable; it is an optional block input. When the EN input is enabled, an ENO output is set automatically.

If EN = 0, the block is not enabled; its internal program is not executed, and ENO is set to 0.

If EN = 1, the block’s internal program is run and ENO is set to 1. If an error occurs, ENO is set to 0.

If the EN input is not connected, it is set automatically to 1.

ENOENO stands for Error NOtification; this is the output associated with the optional input EN.

If ENO is set to 0 (because EN = 0 or in case of an execution error):the status of the function block outputs remains the same as it was during the previous scanning cycle that executed correctly;the output(s) of the function, as well as the procedures, are set to "0".

33002551 10/2013 125

Page 126: 33002551_K01_000_10

Glossary

FFBD

FBD is the abbreviation of Function Block Diagram.

FBD is a graphical programming language that works like a flowchart. By adding simple logical blocks (AND, OR, etc.), each function or function block in the program is represented in this graphical format. For each block, the inputs are on the left and the outputs on the right. Block outputs can be linked to inputs of other blocks in order to create complex expressions.

FFBCollective term for EF (elementary function), EFB (elementary function block) and DFB (derived function block).

FTPFile Transfer Protocol.

FunctionSee EF.

Function Block DiagramSee FBD.

GGlobal Data

Global Data provides the automatic exchange of data variables for the coordination of PLC applications.

GRAYThe Gray code, or "reflected binary", is used to encode a numerical value developed in a string of binary configurations that may be differentiated by changing the status of a single bit.

For example, this code can be used to avoid the following random event: in pure binary, changing the value 0111 to 1000 may produce a range numbers between 0 and 1,000, given that the bits do not all change value at the same time.

Equivalence between decimal, BCD and Gray:

126 33002551 10/2013

Page 127: 33002551_K01_000_10

Glossary

HHTTP

Hypertext Transfer Protocol

II/O scanning

An I/O scan continuously polls I/O modules to collect data bits and status, error, and diagnostics information. This process monitors inputs and control outputs.

IEC 61131-3International standard: programmable logic controllers

Part 3: programming languages

ILIL is the abbreviation of Instruction List.

This language is a series of basic instructions.

It is very close to assembly language used to program processors.

Each instruction is made up of an instruction code and an operand.

INFUsed to indicate that a number exceeds the authorized limits.

For an integer, the value ranges (shown in gray) are as follows:

When a result is:

less than -3.402824e+38, the symbol -INF (for -infinity) is displayed;greater than +3.402824e+38, the symbol INF (for +infinity) is displayed;

INTINT is the abbreviation of single INTeger (encoded in 16 bits).

The upper/lower limits are as follows: -(2 to the power of 15) to (2 to the power of 15) - 1.

Example:

-32768, 32767, 2#1111110001001001, 16#9FA4.

33002551 10/2013 127

Page 128: 33002551_K01_000_10

Glossary

IODDTIODDT is the abbreviation of Input/Output Derived Data Type.

The term IODDT indicates a structured data type representing a module or a channel of a PLC module. Each expert module has its own IODDTs.

KKeyword

A keyword is a unique combination of characters used as a syntax element in a programming language (see the definition provided in appendix B of the IEC 61131-3 standard. All the keywords used in Unity Pro and included in the IEC 61131-3 standard appear in appendix C of that standard. Keywords cannot be used as identifiers [names of variables, sections, DFB types, etc.] in your program).

LLD

LD is the abbreviation of Ladder Diagram.

LD is a programming language that represents instructions to be executed as graphical diagrams very similar to electrical diagrams (contacts, coils, etc.).

Literal value in base 10A literal value in base 10 is used to represent a decimal integer value. This value may be preceded by the "+" and "-" signs. If the "_" character is used in the literal value, it is not significant.

Example:

-12, 0, 123_456, +986

Literal value in base 16A literal value in base 16 is used to represent a hexadecimal integer. The base is determined by the number "16" and the "#" sign. The "+" and "-" signs are prohibited. To make it easier to read, you can use the "_" sign between the bits.

Example:

16#F_F or 16#FF (decimal 255)

16#E_0 or 16#E0 (decimal 224)

Literal value in base 2A literal value in base 2 is used to represent a binary integer. The base is determined by the number "2" and the "#" sign. The "+" and "-" signs are prohibited. To make it easier to read, you can use the "_" sign between the bits.

Example:

2#1111_1111 or 2#11111111 (decimal 255)

2#1110_0000 or 2#11100000 (decimal 224)

128 33002551 10/2013

Page 129: 33002551_K01_000_10

Glossary

Literal value in base 8A literal value in base 8 is used to represent an octal integer. The base is determined by the number "8" and the "#" sign. The "+" and "-" signs are prohibited. To make it easier to read, you can use the "_" sign between the bits.

Example:

8#3_77 or 8#377 (decimal 255)

8#34_0 or 8#340 (decimal 224)

Literal value of a realA literal real value is a number expressed with one or more decimals.

Example:

-12,0, 0,0, +0,456, 3,14159_26

Literal value of a real with an exponentNumber that may be expressed using standard scientific notation. In that case the representation is as follows: mantissa + exponent.

Example:

-1.34E-12 or -1.34e-12

1.0E+6 or 1.0e+6

1.234E6 or 1.234e6

Literal value of an integerA literal value of an integer is used to enter integer values in the decimal system. Values may be preceded by the "+" and "-" signs. Underscore signs (_) separating numbers are not significant.

Example:

-12, 0, 123_456, +986

Literal value of timeThe TIME type has the following units: days (d), hours (h), minutes (m), seconds (s) and milliseconds (ms). A literal value of type TIME is represented by a combination of the preceding types prefixed with T#, t#, TIME# or time#.

Examples: T#25h15m, t#14,7S, TIME#5d10h23m45s3ms

MMultitoken

Operating mode of an SFC. In multitoken mode, the SFC can have several steps that are active simultaneously.

33002551 10/2013 129

Page 130: 33002551_K01_000_10

Glossary

NNaming conventions (identifier)

An identifier is a series of letters, digits, and underscores starting with a letter or an underscore (e.g. the name of a function block type, an instance, a variable, or a section). Accented letters (such as ö, ü, é and õ) may be used, except in names of projects and DFBs. Underscore signs are significant in identifiers. For example, A_BCD and AB_CD are interpreted as different identifiers. You cannot use several underscores in succession or at the start of an identifier.

Identifiers cannot contain spaces. They do not differentiate uppercase and lowercase characters. For example, ABCD and abcd are interpreted as the same identifier.

According to the IEC 61131-3 standard, leading digits are not authorized in identifiers. However, you can use them if, from the Tools → Project options dialog box, in the Language extensions tab, you check the Leading digits authorized box.

Identifiers cannot be keywords.

NANUsed to indicate that the result of an operation is not a number (NAN = Not A Number).

Example: calculating the square root of a negative number.

NOTE: The CEI 559 standard defines two classes of NAN: the silent NAN (QNAN) and the signaling NAN (SNAN). A QNAN is a NAN with a most significant fraction bit while an SNAN is a NAN without a most significant fraction bit (bit number 22). QNANs can be propagated via most arithmetic operations without throwing an exception. As for SNANs, they generally indicate an invalid operation when they are used as operands in arithmetic operations (see %SW17 and %S18).

NetworkThere are two meanings of the work "network".

In LD: a network is a set of interconnected graphic elements. The scope of a network is local, concerning the organizational unit (section) of the program containing the network.With expert communication modules: a network is a set of stations that intercommunicate. The term "network" is also used to define a group interconnected graphic elements. This group then makes up part of a program that may comprise a group of networks.

PPeer cop

Peer Cop service is a mechanism for automatic exchange between stations connected on the same Modbus Plus segment.

130 33002551 10/2013

Page 131: 33002551_K01_000_10

Glossary

ProcedureProcedures are technically functional views. The only difference with elementary functions is the fact that procedures can include more than one output and that they handle the VAR_IN_OUT data type. In appearance, procedures are no different from elementary functions.

Procedures are an extension to the IEC 61131-3 standard.

RREAL

The REAL type is encoded in a 32 bit format.

The possible value ranges are shown in the figure below:

When a result is:

between -1,175494e-38 and 1,175494e-38, it is considered to be a DEN;less than -3.402824e+38, the symbol -INF (for - infinity) is displayed;greater than +3.402824e+38, the symbol INF (for + infinity) is displayed;undefined (square root of a negative number), the symbolNAN is displayed.

NOTE: The IEC 559 standard defines two classes of NAN: the silent NAN (QNAN) and the signaling NAN (SNAN). A QNAN is a NAN with a most significant fraction bit while an SNAN is a NAN without a most significant fraction bit (bit number 22). QNANs can be propagated via most arithmetic operations without throwing an exception. As for SNANs, they generally indicate n invalid operation when they are used as operands in arithmetic operations (see %SW17 and %S18).

NOTE: When a DEN (non-standardized number) is used as an operand, the result is not significant.

SSFC

SFC is the abbreviation of Sequential Function Chart.

An SFC can be used to graphically represent in a structured manner the operation of a sequential PLC. This graphical description of the PLC’s sequential behavior and of the various resulting situations is created using simple graphic symbols.

33002551 10/2013 131

Page 132: 33002551_K01_000_10

Glossary

SILSafety Integrity Level

Safety functions are executed to achieve and maintain the safe state of a system. The IEC 61508 specifies 4 levels of safety performance for a safety function. These are called safety integrity levels (SIL), ranging from 1 (the lowest) to 4 (the highest). The Quantum Safety PLC is certified for use in SIL2 applications in which the de-energized state is the safe state, for example in an Emergency Shutdown (ESD) system.

You can use the Schneider safety products for creating a Hot Standby (HSBY) solution if you require high availability for a safety system.

Single tokenOperating mode for an SFC diagram in which only one step can be active at a given time.

SNMPSimple Network Management Protocol.

STST is the abbreviation of Structured Text.

The structured literal language is a developed language similar to computer programming languages. It can be used to organize a series of instructions.

STRINGA STRING variable is a series of ASCII characters. The maximum length of a string is 65,534 characters.

TTIME

The TIME type expresses a time in milliseconds. Encoded in 32 bits, this type can be used to obtain times from 0 to 2 32-1 milliseconds.

The TIME type has the following units: days (d), hours (h), minutes (m), seconds (s) and milliseconds (ms). A literal value of type TIME is represented by a combination of the preceding types prefixed with T#, t#, TIME# or time#.

Examples: T#25h15m, t#14,7S, TIME#5d10h23m45s3ms

TIME_OF_DAYSee TOD.

132 33002551 10/2013

Page 133: 33002551_K01_000_10

Glossary

TODTOD is the abbreviation of Time Of Day.

The TOD type, encoded in BCD in a 32 bit format, contains the following information:

the hour encoded in an 8 bit field;the minutes encoded in an 8 bit field;the seconds encoded in an 8 bit field.

NOTE: The 8 least significant bits are not used.

The TOD type must be entered as follows: TOD#<Hour>:<Minutes>:<Seconds>This table shows the upper/lower limits of each field:

Example: TOD#23:59:45.

TokenActive step in an SFC.

TOPO_ADDR_TYPEThis predefined type is used as an output for the READ_TOPO_ADDR function. This is an ARRAY[0..4] OF Int. You can find it in the library, in the same family as the EFs that use it.

UUDINT

UDINT is the abbreviation of Unsigned Double INTeger (encoded in 32 bits). The upper/lower limits are as follows: 0 to (2 to the power of 32) - 1.

Example:

0, 4294967295, 2#11111111111111111111111111111111, 8#37777777777, 16#FFFFFFFF.

UDPuser datagram protocol. UDP is a connectionless Internet communications protocol defined by IETF RFC 768. This protocol facilitates the direct transmission of datagrams on IP networks. UDP/IP messages do not expect a response, and are therefore ideal for applications in which dropped packets do not require retransmission (such as streaming video and networks that demand real-time performance).

Field Limits Comment

Hour [00,23] The leading 0 is displayed; it can be omitted during data entry.

Minute [00,59] The leading 0 is displayed; it can be omitted during data entry.

Second [00,59] The leading 0 is displayed; it can be omitted during data entry.

33002551 10/2013 133

Page 134: 33002551_K01_000_10

Glossary

UINTUINT is the abbreviation of the Unsigned INTeger format (encoded in 16 bits). The upper/lower limits are as follows: 0 to (2 to the power of 16) - 1.

Example:

0, 65535, 2#1111111111111111, 8#177777, 16#FFFF.

Unassigned variablesA variable whose position in the PLC memory cannot be known. A variable that is not linked to an address is called unassigned variable.

VVariable

Memory entity of type BOOL, WORD, DWORD, etc., whose contents can be modified by the program currently running.

WWORD

The type WORD is encoded in a 16 bit format and is used to perform processing on series of bits.

This table shows the upper/lower limits of each of the bases that can be used:

Examples of representation

Base Lower limit Upper limit

Hexadecimal 16#0 16#FFFF

Octal 8#0 8#177777

Binary 2#0 2#1111111111111111

Data Representation in one of the bases

0000000011010011 16#D3

1010101010101010 8#125252

0000000011010011 2#11010011

134 33002551 10/2013

Page 135: 33002551_K01_000_10

Unity ProIndex33002551 10/2013

Index

Aavailability of the instructions, 21

DDFB, 95

FFCT_ACCEPT, 53, 53FCT_BIND, 57, 57FCT_CLOSE, 61, 61FCT_CONNECT, 65, 65FCT_LISTEN, 69, 69FCT_RECEIVE, 71, 71FCT_SELECT, 73, 73FCT_SEND, 77, 77FCT_SETSOCKOPT, 81, 81FCT_SHUTDOWN, 85, 85FCT_SOCKET, 89, 89

Iinstructions

availability, 21

33002551 10/2013

TTCP Open - instructions

FCT_ACCEPT, 53FCT_BIND, 57FCT_CLOSE, 61FCT_CONNECT, 65FCT_LISTEN, 69FCT_RECEIVE, 71FCT_SELECT, 73FCT_SEND, 77FCT_SETSOCKOPT, 81FCT_SHUTDOWN, 85FCT_SOCKET, 89general information, 51

TCP_CNX, 95TCP_RECEIVE, 95TCP_SEND, 95

135

Page 136: 33002551_K01_000_10

Index

136 33002551 10/2013