0% found this document useful (0 votes)
551 views124 pages

Unity TCP Open Block Library Users Manual

This document describes different block types used in the TCP Open library including elementary functions, elementary function blocks, derived function blocks, and procedures. It also discusses the FFB structure and the use of EN and ENO inputs.

Uploaded by

georgel1605
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
551 views124 pages

Unity TCP Open Block Library Users Manual

This document describes different block types used in the TCP Open library including elementary functions, elementary function blocks, derived function blocks, and procedures. It also discusses the FFB structure and the use of EN and ENO inputs.

Uploaded by

georgel1605
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 124

Unity Pro

TCP Open
Block Library

33002551.01

September 2004

Table of Contents

About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Part I General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Chapter 1

Block types and their applications . . . . . . . . . . . . . . . . . . . . . . 11


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Block types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FFB Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EN and ENO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Chapter 2

11
12
13
16

Availability of the blocks on the various


hardware platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Part II Introduction to Open TCP . . . . . . . . . . . . . . . . . . . . . . . . 21


At a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Chapter 3

General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
General points and principles of Open TCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Chapter 4

Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Notes and Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Chapter 5

Description of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
At a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Operating Rules for Open TCP EFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Principle governing socket operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
General Structure of an Open TCP communication EF . . . . . . . . . . . . . . . . . . .
Structure of Open TCP management parameters. . . . . . . . . . . . . . . . . . . . . . . .
Management parameters: communication and operation reports. . . . . . . . . . . .
The client/server model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example of client/server applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

27
28
29
31
32
34
36
38

Chapter 6

Operating modes and performance . . . . . . . . . . . . . . . . . . . . . 43


At a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Operating modes of the network module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Debugging and diagnostics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Part III Advanced . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Chapter 7

FCT_ACCEPT: Accepts a connection request . . . . . . . . . . . . 51

Chapter 8

FCT_BIND: Binds a socket number


to an IP address and a port . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Chapter 9

FCT_CLOSE: Deletes the specified socket . . . . . . . . . . . . . . . 59

Chapter 10

FCT_CONNECT: Establishes a connection


with an IP address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Chapter 11

FCT_LISTEN: Configuration of a socket await


connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Chapter 12

FCT_RECEIVE: Retrieves data available on a socket . . . . . . 69

Chapter 13

FCT_SELECT: Multiplexes requests over sockets . . . . . . . . . 73

Chapter 14

FCT_SEND: Sending data to a specified socket . . . . . . . . . . . 77

Chapter 15

FCT_SETSOCKOPT: Sets the options associated


with the socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Chapter 16

FCT_SHUTDOWN: Disables transmission on the socket . . . 85

Chapter 17

FCT_SOCKET: Creation of a new socket . . . . . . . . . . . . . . . . 89

Appendices

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Appendix A

System objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
At a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
System bit introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Description of system bits %S15 to %S21 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Description of system words %SW12 to %SW18 . . . . . . . . . . . . . . . . . . . . . . . 100

Glossary

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Index

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

About the Book

At a Glance
Document Scope

This document describes the functions and function blocks of the TCP Open library.
This document is valid for Unity Pro Version 2.0.

Validity Note

The data and illustrations found in this document are not binding. We reserve the
right to modify our products in line with our policy of continuous product development. The information in this document is subject to change without notice and
should not be construed as a commitment by Schneider Electric.

About the Book

Product Related
Warnings

Schneider Electric assumes no responsibility for any errors that may appear in this
document. 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 ensure compliance
with documented system data, only the manufacturer should perform repairs to
components.
When controllers are used for applications with technical safety requirements,
please follow the relevant instructions.
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 product related warning can result in injury or equipment
damage.

User Comments

We welcome your comments about this document. You can reach us by e-mail at
TECHCOMM@modicon.com

General

I
Introduction
Overview

This section contains general information about the TCP Open library.

What's
in this Part?

This part contains the following chapters:


Chapter

Chapter Name

Page

Block types and their applications

11

Availability of the blocks on the various hardware platforms

19

General

10

Block types and their applications

1
Introduction
Overview

This chapter describes the different block types and their applications.

What's
in this Chapter?

This chapter contains the following topics:


Topic

Page

Block types

12

FFB Structure

13

EN and ENO

16

11

Block types and their applications

Block types
Block types

Different block types are used in Unity Pro. The general term for all block types is
FFB.
There are the following types of block:
l Elementary Function (EF)
l Elementary Function Block (EFB)
l Derived Function Block (DFB)
l Procedure

Elementary
Function

Elementary functions (EF) have no internal status.. If the input values are the same,
the value at the output is the same for all executions of the function, e.g. the addition
of two values gives the same result at every execution.
An elementary function is represented in the graphical languages (FDB and LD) as
a block frame with inputs and an output. The inputs are always represented on the
left and the outputs always on the right of the frame The name of the function, i.e.
the function type, is shown in the center of the frame.
The number of inputs can be increased with some elementary functions.

Elementary
function block

Elementary function blocks (EFB) have an internal status. If the inputs have the
same values, the value on the output 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 (FDB and
LD) as a block frame with inputs and outputs. The inputs are always represented on
the left and the outputs always on the right of the frame The name of the function
block, i.e. the function block type, is shown in the center of the frame. The instance
name is displayed above the frame.

Derived
function block

Derived 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.

Procedure

Procedures are technical functions.


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.

12

Block types and their applications

FFB Structure
Structure

Each FFB is made up of an operation (name of the FFB), the operands 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:
Instance name

Operation

Operand

(FFB name)

Formal
parameter

Actual
parameter

MY_TON
TON
ENABLE
EXAMP
TIME1

EN
IN
PT

ENO
Q
ET

ERROR
OUT
TIME2

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


Operands
Instance name
Formal parameters (inputs)

Formal parameters (outputs)

MY_TON (EN:=ENABLE, IN:=EXAMP, PT:=TIME1, ENO=>ERROR, Q=>OUT, ET=>TIME2);

Actual parameters (inputs)

Actual parameters (outputs)

Operands

13

Block types and their applications

Operation

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

Operand

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

Formal/actual
parameters

Inputs and outputs are required to give values to the FFB or to take values from the
FFB. These are called formal parameters.
Objects are connected to the formal parameters which contain the current process
states. These are called actual parameters.
During program runtime, the actual parameters are used to pass the process values
to the FFB and output them 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, for which the
data types are determined by the actual parameters. If all actual parameters are
literals, the correct data type for the function block will be selected.

FFB Call in IL/ST

In 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: Take note that the use of EN and ENO is only possible for formal calls.

14

Block types and their applications

VAR_IN_OUT
variable

FFBs are often used to read a variable on an input (input variables), to process them
and output the changed value of the same variable again (output variables).
This is special case for an input/output variable and is also called 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:
MY_EXAMP1
EXAMP1
Input1
Input2
Comb_IN_OUT

IN1
IN2
IO1

OUT1
OUT2
IO1

Output1
Output2
Comb_IN_OUT

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:
l VAR_IN_OUT variables absolutely must be assigned to as variable.
l The same variable/variable components must be assigned to the VAR_IN_OUT
input and the VAR_IN_OUT output.
l In the graphic languages (FBD and LD), graphic connections cannot be made on
VAR_IN_OUT inputs/outputs.
l Literals or constants cannot be assigned to VAR_IN_OUT inputs/outputs.
l In the graphic languages (FBD and LD), negations cannot be used on
VAR_IN_OUT inputs/outputs.

15

Block types and their applications

EN and ENO
Description

An EN input and an ENO output can be configured for all FFBs.


If the value of EN is "0" when the FFB is called up, the algorithms defined by the FFB
are not executed and ENO is set to "0".
If the value of EN is "1" when the FFB is called up, the algorithms defined by the FFB
are executed. After the algorithms have been executed successfully, the value of
ENO is set to "1". If an error occurs when executing these algorithms, ENO is set
to "0".
If ENO is set to "0" (caused by EN=0 or an error during execution):
l Function blocks
l EN/ENO-handling with function blocks that (only) have one connection as
output parameter:
FunctionBlock_1
EN
IN1
IN2

FunctionBlock_2

ENO
OUT

EN
IN1
IN2

ENO
OUT

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.
l EN/ENO-handling with function blocks that have one variable and one
connection as output parameters:
FunctionBlock_1
EN
IN1
IN2

ENO
OUT

FunctionBlock_2
OUT1

EN
IN1
IN2

ENO
OUT

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 connection are saved independently from one another.

16

Block types and their applications

l Functions/Procedures
As defined in IEC61131-3, the outputs from deactivated functions (EN-input set
to "0") is undefined. (The same applies for procedures.)
Nevertheless here is an explanation of the output statuses for this case:
l EN/ENO-handling with function/procedure blocks that (only) have one
connection as output parameter:
Function/Procedure_1
EN
IN1
IN2

Function/Procedure_2

ENO
OUT

ENO
OUT

EN
IN1
IN2

If EN from Function/Procedure_1 is set to "0", the output connection OUT


from Function/Procedure_1 is also set to "0".
l EN/ENO-handling with function/procedure blocks that have one variable and
one connection as output parameters:
Function/Procedure_1
EN
IN1
IN2

ENO
OUT

Function/Procedure_2
OUT1

EN
IN1
IN2

ENO
OUT

If EN from Function/Procedure_1 is set to "0", the output connection OUT


from Function/Procedure_1 is also set to "0", however the variable OUT1
on the same pin retains its previous value. In this way it is possible that the
variable and the connection have different values.
The output behavior of the FFBs does not depend on whether the FFBs are called
up without EN/ENO or with EN=1.
Conditional/
Unconditional
FFB Call

"Unconditional" or "conditional" calls are possible with each FFB. The condition is
realized by pre-linking the input EN.
l EN connected
conditional calls (the FFB is only processed if EN = 1)
l EN not used or set to TRUE
unconditional calls (FFB is always processed)

17

Block types and their applications

Note for FBD

If the EN input is used, it must be connected to logic (conditional call) or permanently


set to TRUE (unconditional call) because otherwise the FFB will never be
processed.

Note for LD

In LD, each FFB must be connected with the left power rail using a Boolean input.
Normally, the EN input is used for this purpose.
If the EN input is not connected to the left power rail, it cannot be used or it must be
permanently set to TRUE because otherwise the FFB will never be processed.

Note for IL
and ST

The 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.

18

Availability of the blocks


on the various hardware platforms

Availability of the blocks on the various hardware platforms


Introduction

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

Advanced

Availability of the blocks:


Block name

Block type

Premium

Quantum

FCT_ACCEPT

Procedure

FCT_BIND

Procedure

FCT_CLOSE

Procedure

FCT_CONNECT

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

19

Availability of the Blocks

20

Introduction to Open TCP

II
At a Glance
Subject
of this Part

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

What's
in this Part?

This part contains the following chapters:


Chapter

Chapter Name

Page

General

23

Warnings

25

Description of Operation

27

Operating modes and performance

43

21

Introduction to Open TCP

22

General

3
General points and principles of Open TCP
At a Glance

Open TCP for Premium is a set of Elementary Functions (EFs) and Derived Function
Blocks (DFB) in order to 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 Open TCP is available on the following modules:

l TSX ETY 110WS


l TSX 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.

23

General

24

Warnings

4
Notes and Warnings
At a Glance

Implementing TCP/IP services using Open TCP 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.

Notes

To use the Open TCP 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.

WARNING
Prerequisites for implementation of Open TCP EFs.
The implementation and maintenance of Open TCP 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 this precaution can result in death, serious injury,
or equipment damage.

25

Warnings

Responsibilities

Schneider Electric is not liable for:


WARNING
Schneider Electric is not liable for:

l The design and validation of the communication system architecture


(client/server operating modes and protocols, performances, etc.)

l The implementation of appropriate EFs (or reuse of example EFs


included in the Open TCP kit)

l The testing and the validation of EFs integrated into the


communication system architecture

l The maintenance and fault diagnostics


Failure to follow this precaution can result in death, serious injury,
or equipment damage.

26

Description of Operation

5
At a Glance
Subject
of this Chapter

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

What's
in this Chapter?

This chapter contains the following topics:


Topic

Page

Operating Rules for Open TCP EFs

28

Principle governing socket operation

29

General Structure of an Open TCP communication EF

31

Structure of Open TCP management parameters

32

Management parameters: communication and operation reports

34

The client/server model

36

Example of client/server applications

38

27

Operation

Operating Rules for Open TCP EFs


Execution of a
Open TCP EF

Open TCP 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 Supplied

The number of Open TCP 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 FCT_SOCKET: Creation of a new socket, p. 89) function.

28

Operation

Principle governing socket operation


At a Glance

The 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: In the Premium architecture, the socket descriptors are assigned numbers 1
to 32. Numbers 1 to 16 are assigned to listening sockets. Numbers 17 to 32 are
assigned to connected sockets.
A socket is created by the FCT_SOCKET (See FCT_SOCKET: Creation of a
new socket, p. 89) function which returns a number. This number is then used
to access this socket.

Establishing
a Connection

The following table describes the different steps that need to be created on the
server in order to establish a connection.
Step

Action

Create a socket using the FCT_SOCKET function

Associate the created socket with an address (Port number and IP address)
using the FCT_BIND (See FCT_BIND: Binds a socket number to an
IP address and a port, p. 55 ) function.

Set up the socket to accept connections using the FCT_LISTEN (See


FCT_LISTEN: Configuration of a socket await connection,
p. 67) function.
Note: the PLC acts as TCP server, the initial socket listens, and receives client
socket connections.

Apply the FCT_ACCEPT (See FCT_ACCEPT: Accepts a connection


request, p. 51 ) 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.

29

Operation

Exchanging
Data over a
TCP Connection

Once a connection has been established, data can be transferred. Transfers are
carried out using the FCT_SEND (See FCT_SEND: Sending data to a
specified socket, p. 77) and FCT_RECEIVE (See FCT_RECEIVE:
Retrieves data available on a socket, p. 69) functions. The diagram
below shows how these exchanges work.
Connection
Application

Managing
Sockets

TCP

TCP

Send
buffers

Receive
buffers

Receive
buffers

Send
buffers

Application

Other functions can be used to act on sockets:

l FCT_SETSOCKOPT (See FCT_SETSOCKOPT: Sets the options


associated with the socket, p. 81): associates options with a socket.
These options modify the behavior of the socket.
l FCT_SELECT (See FCT_SELECT: Multiplexes requests over
sockets, p. 73): used to test events on sockets.
l FCT_SHUTDOWN (See FCT_SHUTDOWN: Disables transmission on the
socket, p. 85): disables transmission on the socket.
l FCT_CLOSE (See FCT_CLOSE: Deletes the specified socket,
p. 59): frees the socket descriptor when it is no longer used.

30

Operation

General Structure of an Open TCP communication EF


At a Glance

Communication 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 an Open TCP communication function are the following:

l An interface number
l Specific parameters
l Management parameters.

Interface Number

This interface number is coded over one integer. It corresponds to the slot number
of the ETY module in the main rack.
Note: only rack 0 can take an Ethernet module which uses Open TCP
communication functions.

Specific
Parameters

These 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
Parameters

The management parameters consist of an array of 4 integers also known as the


Management table (See Structure of Open TCP management parameters, p. 32). It
is identical to the management table for standard communication EFs except for the
exchange number which is not managed and the Time out.

31

Operation

Structure of Open TCP management parameters


At a Glance

The 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.

Structure

Activity bit

The table below describes the data structure of the communication management
table:
Word order

Most significant byte

Least significant byte

Reserved

Activity bit

operation report

communication report

Reserved

Length

This 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.

32

Operation

Operation Report

It is described on the following pages.

Communication
Report

It is described on the following pages.

Length

The length parameter is used with the FCT_SEND (See FCT_SEND: Sending
data to a specified socket, p. 77) and FCT_RECEIVE (See
FCT_RECEIVE: Retrieves data available on a socket, p. 69)
functions.
You must indicate the number of bytes to send when you use the FCT_SEND
function and when you are receiving data (FCT_RECEIVE function), the system
writes the number of bytes received.

33

Operation

Management parameters: communication and operation reports


At a Glance

Communication and operation reports are part of the management parameters.


Note: You are recommended to 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
Report

This 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:
Value

Communication report (least significant byte)

16#00

Exchange successful

16#01

Exchange stopped on timeout

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 refused

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.

34

Operation

Operation Report

This 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:

l 16#00 (exchange successful),


l 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

35

Operation

The client/server model


At a Glance

The 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.

Description

36

The 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.

l
l
l
l

Operation

Illustration

Illustration of how the client/server model works


Client (IP_b, Port_b)

Server (IP_a, Port_a)

FCT_SOCKET()

FCT_SOCKET()

FCT_BIND(Si)

FCT_BIND(Si)

FCT_CONNECT()
FCT_LISTEN(Si)

FCT_SEND()

FCT_RECEIVE()

FCT_ACCEPT(Si)

FCT_SELECT()

FCT_RECEIVE(Sj)

Processing
FCT_SEND(Sj)
NO

End?
Processing
YES

FCT_CLOSE()

Key:
Si is assigned to the address: IP_a, Port_a
Sj is assigned to the external socket with the address: IP_b, Port_b

37

Operation

Example of client/server applications


At a Glance

Connections 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.

38

Operation

Example 1

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

Client1 (IP_b, Port_b)

Server (IP_a, Port_a)

FCT_SOCKET()
FCT_SOCKET()
FCT_BIND(Si)

FCT_BIND(Si)

FCT_CONNECT()

FCT_SEND()

FCT_LISTEN(Si)

FCT_SELECT()

FCT_ACCEPT(Si)

FCT_RECEIVE(Sj)

FCT_RECEIVE(Sj)

FCT_SEND(Sj)

FCT_SEND(Sj)

FCT_RECEIVE(Sk)

FCT_SELECT(Sj)

FCT_SEND(Sk)

FCT_RECEIVE()

Processing

NO

End

Client2 (IP_c, Port_c)


FCT_SOCKET()

YES
FCT_CLOSE()

FCT_BIND(Si)

FCT_CONNECT()

NO

FCT_SEND()

FCT_RECEIVE()

Event
on Si

YES
Processing

NO

FCT_ACCEPT(Si)

NO
END?

YES
FCT_CLOSE(Sj)
FCT_CLOSE(Sk)

End
YES

FCT_CLOSE()

Key:
Si is assigned to the address: IP_a, Port_a
Sj is assigned to the external socket with the
address: IP_b, Port_b
Sk is assigned to the address IP_c, Port_c

39

Operation

Example 2

40

The 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.

Operation

Client1 (IP_b, Port_b)

Server (IP_a, Port_a)

FCT_SOCKET()

FCT_SOCKET()

FCT_BIND(Si)
FCT_BIND(Si)
FCT_CONNECT()

FCT_SEND()

Power outage and


restoral

FCT_LISTEN(Si)

FCT_SELECT()

FCT_ACCEPT(Si)

FCT_RECEIVE(Sk)

Client1 (IP_b, Port_b)


FCT_SOCKET()

FCT_RECEIVE(Sj)

FCT_BIND(Si)

FCT_CONNECT()

FCT_SELECT()
FCT_SEND()

FCT_SEND(Sk)

FCT_RECEIVE()

NO
Evt or
socket +1

END?

Processing

NO

YES

YES

End
FCT_ACCEPT(Si)

FCT_CLOSE(Sk)

YES
FCT_CLOSE()

FCT_CLOSE(Sj)

Key: Si is assigned to the address: IP_a, Port_a


Sj is assigned to the external socket with the address: IP_b, Port_b
Sk is assigned to the address IP_b, Port_b, a new socket is created on receiving the second request from the client.

41

Operation

Example 3

The 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.

Client1 (IP_b, Port_b)

Server (IP_a, Port_a)

FCT_SOCKET()

FCT_SOCKET()

FCT_BIND(Si)
FCT_CONNECT()

FCT_SEND()

Power outage and


restoral

FCT_LISTEN(Si)

FCT_ACCEPT(Si)

FCT_SELECT()

FCT_ACCEPT(Si)

FCT_RECEIVE(Sj)

FCT_RECEIVE(Sk)

FCT_SEND(Sj)

FCT_SEND(Sk)

Client1 (IP_b, Port_b)


FCT_SOCKET()

FCT_CONNECT()

Evt

FCT_SELECT()

FCT_SEND()

FCT_RECEIVE()

NO

FCT_CLOSE(Sj)

END?

Processing

NO

FCT_SELECT()

YES
End

Evt

FCT_CLOSE(Sk)

YES
YES
FCT_CLOSE()

Key:
Si is assigned to the address: IP_a, Port_a
Sj is assigned to the external socket with the address: IP_b, Port_b
Sk is assigned to the address IP_b, Port_b, a new socket is created on receiving the second request from the client.
42

Operating modes
and performance

At a Glance
Subject
of this Chapter

This 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 Open TCP functions).

What's
in this Chapter?

This chapter contains the following topics:


Topic
Operating modes of the network module

Page
44

Performance

46

Debugging and diagnostics

47

43

Operating modes and performance

Operating modes of the network module


At a Glance

The TSX ETY 5103 module has four operating states:


power off,
self-test running,
configured,
not configured.

l
l
l
l

The self-tests are performed on power-up.


The module does not work with the 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 Open TCP functions.

Sending the
configuration
to the module

44

The configuration is sent to the module in the following cases:


when an application is downloaded,
when the PLC is powered up,
when the module is connected to the rack when the power is on,
on a warm or cold restart,
when the Premium is reset.

l
l
l
l
l

Operating modes and performance

Operating
mode after
configuration

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

Action

The module resets the communication in progress.


Result: exchanges in progress are ended, open TCP connections are closed
and all sockets are deleted.

The module reconfigures itself.

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

WARNING
Pay attention to restart management.
The 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.
Failure to follow this precaution can result in death, serious injury,
or equipment damage.

45

Operating modes and performance

Performance
Number of
simultaneous
connections

The maximum number of simultaneous TCP/IP connections to a TSX ETY 5103 is


64 + 16 Open TCP connections.

Data Exchanges

The 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.
As a result, if you wish to transfer a message of 8 Kbytes, you have to breakdown
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, meaning that it will take 35 PLC cycles in total
(8*1024/240).
Example: for a PLC cycle of 50 ms, this will take 1.75 seconds.

Note: these calculations are based on 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 or
FCT_RECEIVE functions executed in the same PLC cycle.
These performances 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.).

46

Operating modes and performance

Debugging and diagnostics


Debug Screen

In online mode, Unity Proware 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:

l the number of connections displayed includes:

l open profile connections (Open TCP),


l private profile connections (address declared in configuration),
l the IP addresses of open profiles cannot be seen in this screen.

IP
Communication
Tests

You 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.

47

Operating modes and performance

48

Advanced

III
Introduction
Overview

This section describes the elementary functions and elementary function blocks of
the Advanced family.

What's
in this Part?

This part contains the following chapters:


Chapter

Chapter Name

Page

FCT_ACCEPT: Accepts a connection request

51

FCT_BIND: Binds a socket number to an IP address and a port

55

FCT_CLOSE: Deletes the specified socket

59

10

FCT_CONNECT: Establishes a connection with an IP address

63

11

FCT_LISTEN: Configuration of a socket await connection

67

12

FCT_RECEIVE: Retrieves data available on a socket

69

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

49

Advanced

50

FCT_ACCEPT: Accepts
a connection request

Description
Function
Description

The 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, the socket must be set up to receive a connection
request by issuing the FCT_LISTEN call. The FCT_ACCEPT function:
l extracts the first connection request in the queue of pending connections;
l creates a connected socket with the same properties as the original socket;
l completes the connection between the foreign socket and the new socket;
l and 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

Representation:
FCT_ACCEPT
Module_Number
Socket_Number
Clie_Index
Gest_Index
Management_Param

INTE
SOCK
ICLIE
IGST
GEST

CLIE

Client_Address

GEST

Management_Param

51

FCT_ACCEPT

Representation
in LD

Representation:
FCT_ACCEPT
EN
Module_Number

INTE

Socket_Number

SOCK

Clie_Index

ICLIE

Gest_Index

IGST

Management_Param

GEST

ENO
CLIE

Client_Address

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_ACCEPT Socket_Number, Clie_Index, Gest_Index,
Management_Param, Client_Address

Representation
in ST

Representation:
FCT_ACCEPT(Module_Number, Socket_Number, Clie_Index,
Gest_Index, Management_Param, Client_Address);

52

FCT_ACCEPT

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the output parameters:


Parameter

Type

Client_Address

ARRAY [0... 3] Array of 4 words containing the service socket


OF INT
number, the port number and the IP address of the
client:
l Client_Address[0]: connected socket
number.
l Client_Address[1]: client port number.
l Client_Address[2]: least significant word of
the client IP address.
l Client_Address[3]: most significant word of
the client IP address.

Comment

The following table describes the input/output parameters:


Parameter

Type

Management_Param

ARRAY [0... 3] Function management array (See Structure of


OF INT
Open TCP management parameters, p. 32)
The operation report can have the following values:
l 16#00: no error.
l 16#09: the socket number is invalid.
l 16#16: the FCT_LISTEN function must be
called before FCT_ACCEPT.
l 16#23: no connection request.

Comment

53

FCT_ACCEPT

54

FCT_BIND: Binds a socket


number to an IP address
and a port

Description
Function
Description

The 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:

l
l
l
l
l
l
l
l
l
l

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.

55

FCT_BIND

Representation
in FBD

Representation:
FCT_BIND
Module_Number
Socket_Number
Port_Number
Gest_Index
Management_Param

Representation
in LD

INTE
SOCK
PORT
IGST
GEST

GEST

Management_Param

Representation:
FCT_BIND
EN
Module_Number

INTE

Socket_Number

SOCK

Port_Number

PORT

Gest_Index

IGST

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_BIND Socket_Number, Port_Number, Gest_Index,
Management_Param

Representation
in ST

Representation:
FCT_BIND(Module_Number, Socket_Number, Port_Number,
Gest_Index, Management_Param);

56

FCT_BIND

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00 : no error.
l 16#09 : the socket number is invalid.
l 16#16 : the socket is already bound.
l 16#30 : the specified port is already in use.
l 16#37 : the specified port number is not
available.

57

FCT_BIND

58

FCT_CLOSE: Deletes
the specified socket

Description
Function
Description

The 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

Representation:
FCT_CLOSE
Module_Number
Socket_Number
Gest_Index
Management_Param

INTE
SOCK
IGST
GEST

GEST

Management_Param

59

FCT_CLOSE

Representation
in LD

Representation:
FCT_CLOSE
EN
Module_Number

INTE

Socket_Number

SOCK

Gest_Index

IGST

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_CLOSE Socket_Number, Gest_Index, Management_Param

Representation
in ST

Representation:
FCT_CLOSE(Module_Number, Socket_Number, Gest_Index,
Management_Param);

60

FCT_CLOSE

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3] Function management array (See Structure of


OF INT
Open TCP management parameters, p. 32)
The operation report can have the following values:
l 16#00: no error.
l 16#16: the socket number is invalid.

61

FCT_CLOSE

62

FCT_CONNECT: Establishes
a connection with an IP address

10

Description
Function
Description

The 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:
FCT_CONNECT
Module_Number
Socket_Number

INTE
SOCK

Serv_Index
Gest_Index
Server_Address
Management_Param

ISRV
IGST
SERV
GEST

SERV
GEST

Server_Address
Management_Param

63

FCT_CONNECT

Representation
in LD

Representation:
FCT_CONNECT
EN
Module_Number

INTE

Socket_Number

SOCK

ENO

Serv_Index

ISRV

Gest_Index

IGST

Server_Address

SERV

SERV

Server_Address

Management_Param

GEST

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_CONNECT Socket_Number, Serv_Index,
Gest_Index,Server_Address, Management_Param

Representation
in ST

Representation:
FCT_CONNECT(Module_Number, Socket_Number, Serv_Index,
Gest_Index,Server_Address, Management_Param);

64

FCT_CONNECT

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the input/output parameters:


Parameter

Type

Comment

Server_Address

ARRAY [0... 2]
OF INT

Array of three words containing the port number


and IP address of the server.

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00 : correct operation,
l 16#09 : invalid socket number,
l 16#16 : invalid parameter,
l 16#20 : connection is cut,
l 16#24 : connection in progress,
l 16#38 : socket already connected,
l 16#24 : connection refused.

65

FCT_CONNECT

66

FCT_LISTEN: Configuration
of a socket await connection

11

Description
Function
Description

The 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:
FCT_LISTEN
Module_Number
Socket_Number
Gest_Index
Management_Param

INTE
SOCK
IGST
GEST

GEST

Management_Param

67

FCT_LISTEN

Representation
in LD

Representation:
FCT_LISTEN
EN
Module_Number

INTE

Socket_Number

SOCK

Gest_Index

IGST

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_LISTEN Socket_Number, Gest_Index, Management_Param

Representation
in ST

Representation:
FCT_LISTEN(Module_Number, Socket_Number, Gest_Index,
Management_Param);

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

Socket_Number

INT

Socket number

Gest_Index

INT

Index of first word in Management_Param array.

The following table describes the input/output parameters:

68

Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00: no error.
l 16#09: the socket number is invalid.

FCT_RECEIVE: Retrieves data


available on a socket

12

Description
Function
Description

The 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 received; this value should always be tested because
this is the only way to check the actual number of data bytes stored in the user
buffer.

Note: it is not possible to receive out of band data.


The additional parameters EN and ENO may be configured.
Representation
in FBD

Representation:
FCT_RECEIVE
Module_Number
Socket_Number
Pbuf_Index
Gest_Index
Management_Param

INTE
SOCK
IBUF
IGST
GEST

PBUF

Received_Data

GEST

Management_Param

69

FCT_RECEIVE

Representation
in LD

Representation:
FCT_RECEIVE
EN
Module_Number

INTE

Socket_Number

SOCK

Pbuf_Index

IBUF

Gest_Index

IGST

Management_Param

GEST

ENO
PBUF

Received_Data

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_RECEIVE Socket_Number, Pbuf_Index, Gest_Index,
Management_Param, Received_Data

Representation
in ST

Representation:
FCT_RECEIVE(Module_Number, Socket_Number, Pbuf_Index,
Gest_Index, Management_Param, Received_Data);

70

FCT_RECEIVE

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the output parameters:


Parameter

Type

Received_Data

ARRAY [0... n] Array of maximum of 240 bytes containing the data


OF INT
read on the socket.

Comment

The following table describes the input/output parameters:


Parameter

Type

Management_Param

ARRAY [0... 3] Function management array (See Structure of


OF INT
Open TCP management parameters, p. 32)
The operation report can have the following values:
l 16#00 : no error.
l 16#09 : the socket number is invalid.
l 16#23 : no data to read.
l 16#36 : the connection has been reset by peer.
l 16#39 : the socket is not connected (listening
socket).
l 16#3C: the keep alive timed out on broken
connection.
l 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.

Comment

71

FCT_RECEIVE

72

FCT_SELECT: Multiplexes
requests over sockets

13

Description
Function
Description

The 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 two integers.
In the TSX premium architecture, the socket descriptors are assigned a number
from 1 to 32:
l Numbers 1 from 16 are assigned to sockets created by the socket function. They
are listening sockets.
l Numbers 17 from 32 are assigned to sockets created by the accept function.
They are connected sockets.
The first word of the array corresponds to the listening sockets (bit 0 corresponds to
socket 0) and the second word corresponds to the connected sockets.
The additional parameters EN and ENO may be configured.

Representation
in FBD

Representation:
FCT_SELECT
Module_Number
Mask_Index
Gest_Index
Management_Param

INTE
IMASK
IGST
GEST

MASK

GEST

Socket_Activity

Management_Param

73

FCT_SELECT

Representation
in LD

Representation:
FCT_SELECT
EN
Module_Number
Mask_Index

INTE

ENO
MASK

Socket_Activity

IMASK

Gest_Index

IGST

Management_Param

GEST

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_SELECT Mask_Index, Gest_Index, Management_Param,
Socket_Activity

Representation
in ST

Representation:
FCT_SELECT(Module_Number, Mask_Index, Gest_Index,
Management_Param, Socket_Activity);

74

FCT_SELECT

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

Mask_Index

INT

Index of first word in the Socket_Activity


array.

Gest_Index

INT

Index of first word in Management_Param array.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
For this function, the operation report always
returns the value 16#00 indicating that no error
has occurred.

The following table describes the output parameters:


Parameter

Type

Comment

Socket_Activity

ARRAY [0... 1]
OF INT

Status of each socket. Each bit set to 1 indicates


an event on the socket which corresponds to this
bit. For example:
l if bit 3 of the second word has the value 1,
socket 20 shall be read by the FCT_RECEIVE
function.
l if bit 5 of the first word has the value 1, socket
6 shall be read by the FCT_ACCEPT function.
If a bit is set to 1 on a listening socket, this means
that a connection request has been placed in the
queue. If a bit has been set to 1 on an output
socket, this means that data is queued on the
socket or that communication has been interrupted.

75

FCT_SELECT

76

FCT_SEND: Sending data


to a specified socket

14

Description
Function
Description

The 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

Representation:
FCT_SEND
Module_Number
Socket_Number

INTE
SOCK

Pbuf_Index
Gest_Index
Data_to_Send
Management_Param

IBUF
IGST
PBUF
GEST

GEST

Management_Param

77

FCT_SEND

Representation
in LD

Representation:
FCT_SEND
EN
Module_Number

INTE

Socket_Number

SOCK

Pbuf_Index

IBUF

Gest_Index

IGST

Data_to_Send

PBUF

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_SEND Socket_Number, Pbuf_Index, Gest_Index,Data_to_Send,
Management_Param

Representation
in ST

Representation:
FCT_SEND(Module_Number, Socket_Number, Pbuf_Index,
Gest_Index,Data_to_Send, Management_Param);

78

FCT_SEND

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

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.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00: no error.
l 16#09: the socket number is invalid.
l 16#23: the socket is full.
l 16#36: the connection has been reset by peer.
l 16#39: the socket is not connected (listening
socket).
l 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.

79

FCT_SEND

80

FCT_SETSOCKOPT: Sets
the options associated
with the socket

15

Description
Function
Description

The 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 FCT_SOCKET: Creation of a new socket, p. 89) function.
The following options are available:

l DONT_ROUTE: indicates that the outgoing data should not be routed. Packets
directed at unconnected nodes are dropped.

l RESET_DONT_ROUTE: resets DONT_ROUTE.


l KEEP_ALIVE: ensures a connection is kept active by regularly and automatically
sending packets on the socket.

l RESET_KEEP_ALIVE: resets KEEP_ALIVE.


These options are selected by assigning a number in the Option_Type variable
described in the following table.
The additional parameters EN and ENO may be configured.
Representation
in FBD

Representation:
FCT_SETSOCKOPT
Module_Number
Socket_Number

INTE
SOCK

Option_Type
Gest_Index
Management_Param

OPT
IGST
GEST

GEST

Management_Param

81

FCT_SETSOCKOPT

Representation
in LD

Representation:
FCT_SETSOCKOPT
EN
Module_Number

INTE

Socket_Number

SOCK

Option_Type

OPT

Gest_Index

IGST

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_SETSOCKOPT Socket_Number, Option_Type, Gest_Index,
Management_Param

Representation
in ST

Representation:
FCT_SETSOCKOPT(Module_Number, Socket_Number, Option_Type,
Gest_Index, Management_Param);

82

FCT_SETSOCKOPT

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

Socket_Number

INT

Socket number

Option_Type

INT

Type of option to be associated with socket. The


values which can be assigned to this word are as
follows:
l 1 for DONT_ROUTE,
l 2 for RESET_DONT_ROUTE,
l 3 for KEEP_ALIVE,
l 4 for RESET_KEEP_ALIVE.

Gest_Index

INT

Index of first word in Management_Param array.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3] Function management array (See Structure of


OF INT
Open TCP management parameters, p. 32)
The operation report can have the following values:
l 16#00 : no error.
l 16#09 : the socket number is invalid.
l 16#16 : invalid option.
The fourth word of the array should contain the
number of bytes stored in the buffer.

83

FCT_SETSOCKOPT

84

FCT_SHUTDOWN: Disables
transmission on the socket

16

Description
Function
Description

The 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
will not be 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

Representation:
FCT_SHUTDOWN
Module_Number
Socket_Number
Shutdown_Option
Gest_Index
Management_Param

INTE
SOCK
HOW
IGST
GEST

GEST

Management_Param

85

FCT_SHUTDOWN

Representation
in LD

Representation:
FCT_SHUTDOWN
EN
Module_Number

INTE

Socket_Number

SOCK

Shutdown_Option

HOW

Gest_Index

IGST

Management_Param

GEST

ENO

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_SHUTDOWN Socket_Number, Shutdown_Option, Gest_Index,
Management_Param

Representation
in ST

Representation:
FCT_SHUTDOWN(Module_Number, Socket_Number, Shutdown_Option,
Gest_Index, Management_Param);

86

FCT_SHUTDOWN

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

Socket_Number

INT

Socket number

Shutdown_Option

INT

Disable transmission option:


l 0: no further receives are allowed on the
socket,
l 1: no further sends are allowed on the socket,
an END message is sent,
l 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.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00: no error.
l 16#09: the socket number is invalid.
l 16#16: an argument is not valid.
l 16#39: the socket is not connected.

87

FCT_SHUTDOWN

88

FCT_SOCKET: Creation
of a new socket

17

Description
Function
Description

The 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:

l 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.

l 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.
l KEEP_ALIVE. The connection is kept active by regularly and automatically
sending packets on the socket.
l 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

Representation:
FCT_SOCKET
Module_Number
Gest_Index
Management_Param

INTE
IGST
GEST

SOCK
GEST

Socket_Number
Management_Param

89

FCT_SOCKET

Representation
in LD

Representation:
FCT_SOCKET
EN
Module_Number

INTE

Gest_Index

IGST

Management_Param

GEST

ENO
SOCK

Socket_Number

GEST

Management_Param

Representation
in IL

Representation:
LD Module_Number
FCT_SOCKET Gest_Index,Management_Param, Socket_Number

Representation
in ST

Representation:
FCT_SOCKET(Module_Number, Gest_Index, Management_Param,
Socket_Number);

90

FCT_SOCKET

Description
of Parameters

The following table describes the input parameters:


Parameter

Type

Comment

Module_Number

INT

Module number of network module in rack 0.

Gest_Index

INT

Index of first word in Management_Param array.

The following table describes the output parameters:


Parameter

Type

Comment

Socket_Number

INT

Number of socket created if no error has occurred.

The following table describes the input/output parameters:


Parameter

Type

Comment

Management_Param

ARRAY [0... 3]
OF INT

Function management array (See Structure of


Open TCP management parameters, p. 32)
The operation report can have the following
values:
l 16#00: no error.
l 16#37: the maximum number of sockets has
been reached.

91

FCT_SOCKET

92

Appendices

Introduction
Overview

This section contains the appendicies.

What's in this
Appendix?

The appendix contains the following chapters:


Chapter

Chapter Name

System objects

Page
95

93

Appendices

94

System objects

A
At a Glance
Subject
of this Chapter

This 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's
in this Chapter?

This chapter contains the following topics:


Topic
System bit introduction
Description of system bits %S15 to %S21
Description of system words %SW12 to %SW18

Page
96
97
100

95

System objects

System bit introduction


General

96

The Premium, Atrium and Quantum 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.

System objects

Description of system bits %S15 to %S21


Detailed
description

Description of system bits %S15 to %S21:

Bit
Symbol

Function

Description

Initial
state

Quantum Premium
Atrium

%S15
STRINGERROR

Character
string fault

Normally set to 0, this is set to 1 when the


destination zone for a character string
transfer is not of sufficient size 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.

YES

YES

%S16
IOERRTSK

Task input/
output fault

Normally set to 1, this is set to 0 by the


system when a fault occurs on an in-rack I/O
module or a Fipio device configured in the
task.
This bit must be reset to 1 by the user.

YES

YES

%S17
CARRY

Rotate shift
output

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

YES

YES

97

System objects

Bit
Symbol

Function

Description

%S18
OVERFLOW

Overflow or
arithmetic
error

Normally set to 0, this is set to 1 in the event


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

YES

YES

%S19
OVERRUN

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.

YES

YES

98

Initial
state

Quantum Premium
Atrium

System objects

Bit
Symbol

Function

Description

Initial
state

Quantum Premium
Atrium

%S20
INDEXOVF

Index
overflow

Normally set to 0, this 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.

YES

YES

%S21
1RSTTASKRUN

First task
cycle

Tested in a task (Mast, Fast, Aux0, Aux1,


Aux2 Aux3), the bit %S21 indicates the first
cycle of this task. %S21 is set to 1 at the start
of the cycle and reset to zero at the end of the
cycle.
Notes: the bit %S21 does not have the same
meaning in PL7 as in Unity Pro.

YES

YES

CAUTION
%S16 for Quantum PLCs
On Quantum, communication errors from modules (NOM, NOE, NWM,
CRA, CRP) and MMS modules are not reported on bits %S10 and
%S16.
It is entirely your responsibility to ensure that these system bits are used
correctly
Failure to follow this precaution can result in injury or equipment
damage.

99

System objects

Description of system words %SW12 to %SW18


Detailed
description

Description of system words %SW12 to %SW18:

Word
Symbol

Function

Description

%SW12
UTWPORTADDR

Uni-Telway
terminal
port
address

Uni_Telway address of terminal port (in


slave mode) as defined in the configuration
and loaded into this word on cold start.
Note: The modification of the value of this
word is not taken into account by the
system

%SW13
XWAYNETWADDR

Main
address of
the station

%SW14
OSCOMMVERS

Initial
state

NO

YES

254
Indicates the following for the main network
(16#00FE)
(Fipway or Ethway):
l the station number (least significant
byte) from 0 to 127,
l the network number (most significant
byte) from 0 to 63,
(value of the micro-switches on the
PCMCIA card).

NO

YES

Commercia
l version of
PLC
processor

This word contains the commercial version


of the PLC processor.
Example: 16#0135
version: 01
issue number: 35

YES

YES

%SW15
OSCOMMPATCH

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

%SW16
OSINTVERS

Firmware
version of
PLC
processor

This word contains the Firmware version of


the PLC processor.
Example: 16#0143
version: 01
issue number: 43

YES

YES

100

Quantum Premium
Atrium

System objects

Word
Symbol

Function

Description

%SW17
FLOATSTAT

Error status On detection of an error in a floating


on floating arithmetic operation, bit %SW18 is set to 1
operation
and %SW17 error status is updated
according to the following coding:
l %SW17.0 = Invalid operation / result is
not a number
l %SW17.1 = Non-standardized operand
/ result is acceptable
l %SW17.2 = Division by 0 / result is
infinity
l %SW17.3 = Overflow / result is infinity
l %SW17.4 = Underflow / result is 0
l %SW17.5 to 15 = not used
This word is reset to 0 by the system on
cold start, and also by the program for reusage purposes.

YES

YES

%SD18
100MSCOUNTER

Absolute
time
counter

YES

YES

This double word is used to calculate


duration.

Initial
state

Quantum Premium
Atrium

It is incremented every 1/10th of a second


by the system (even when PLC is in STOP,
it is no longer incremented if the PLC is
powered down). It can be read and written
by the user program or by the terminal.

101

System objects

102

Glossary

%I

According to the IEC standard, %I indicates a discrete input-type language object.

%IW

According to the IEC standard, %IW indicates an analog input -type language object.

%KW

According to the IEC standard, %KW indicates a constant word-type language object.

%M

According to the IEC standard, %M indicates a memory bit-type language object.

%MW

According to the IEC standard, %MW indicates a memory word-type language object.

%Q

According to the IEC standard, %Q indicates a discrete output-type language object.

%QW

According to the IEC standard, %QW indicates an analog output-type language


object.

103

Glossary

ADDR_TYPE

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

ANL_IN

ANL_IN is the abbreviation of Analog Input data type and is used when processing
analog values. The %IW adresses for the configured analog input module, which
were specified in the I/O component list, are automatically assigned data types and
should therefore only be occupied with Unlocated Variables.

ANL_OUT

ANL_OUT is the abbreviation of Analog Output data type and is used when
processing analog values. The %MW adresses for the configured analog input
module, which were specified in the I/O component list, are automatically assigned
data types and should therefore only be occupied with Unlocated Variables.

104

Glossary

ANY

There is a hierarchy between the different types of data. In the DFB, it is sometimes
possible to declare which variables can contain several types of values. Here, we
use ANY_xxx types.
The following diagram shows the hierarchically-ordered structure:
ANY
ANY_ELEMENTARY
ANY_MAGNITUDE_OR_BIT
ANY_MAGNITUDE
ANY_NUM
ANY_REAL
REAL
ANY_INT
DINT, INT, UDINT, UINT
TIME
ANY_BIT
DWORD, WORD, BYTE, BOOL
ANY_STRING
STRING
ANY_DATE
DATE_AND_TIME, DATE, TIME_OF_DAY
EBOOL
ANY_DERIVED
ANY_ARRAY
ANY_ARRAY_ANY_EDT
ANY_ARRAY_ANY_MAGNITUDE
ANY_ARRAY_ANY_NUM
ANY_ARRAY_ANY_REAL
ANY_ARRAY_REAL
ANY_ARRAY_ANY_INT
ANY_ARRAY_DINT
ANY_ARRAY_INT
ANY_ARRAY_UDINT
ANNY_ARRAY_UINT
ANY_ARRAY_TIME
ANY_ARRAY_ANY_BIT
ANY_ARRAY_DWORD
ANY_ARRAY_WORD
ANY_ARRAY_BYTE
ANY_ARRAY_BOOL
ANY_ARRAY_ANY_STRING
ANY_ARRAY_STRING
ANY_ARRAY_ANY_DATE
ANY_ARRAY_DATE_AND_TIME
ANY_ARRAY_DATE
ANY_ARRAY_TIME_OF_DAY
ANY_ARRAY_EBOOL
ANY_ARRAY_ANY_DDT
ANY_STRUCTURE
ANY_DDT
ANY_IODDT
ANY_FFB
ANY_EFB
ANY_DFB

105

Glossary

ARRAY

An ARRAY is a table of elements of the same type.


The syntax is as follows: ARRAY [<terminals>] OF <Type>
Example:
ARRAY [1..2] OF BOOL is a one-dimensional table made up of two BOOL-type
elements.
ARRAY [1..10, 1..20] OF INT is a two-dimensional table made up of 10x20
INT-type elements.

Base 10 literals

A literal value in base 10 is used to represent a decimal integer value. This value can
be preceded by the signs "+" and "-". If the character "_" is employed in this literal
value, it is not significant.
Example:
-12, 0, 123_456, +986

Base 16 Literals

An literal value in base 16 is used to represent an integer in hexadecimal. The base


is determined by the number "16" and the sign "#". The signs "+" and "-" are not
allowed. For greater clarity when reading, you can use the sign "_" between bits.
Example:
16#F_F or 16#FF (in decimal 255)
16#F_F or 16#FF (in decimal 224)

Base 2 Literals

A literal value in base 2 is used to represent a binary integer. The base is determined
by the number "2" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
2#1111_1111 or 2#11111111 (in decimal 255)
2#1110_0000 or 2#11100000 (in decimal 224)

Base 8 Literals

A literal value in base 8 is used to represent an octal integer. The base is determined
by the number "8" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
8#3_77 or 8#377 (in decimal 255)
8#34_0 or 8#340 (in decimal 224)

106

Glossary

BCD

BCD is the abbreviation of Binary Coded Decimal format


BCD is used to represent decimal numbers between 0 and 9 using a group of four
bits (half-byte).
In this format, the four bits used to code the decimal numbers have a range of
unused combinations.
Example of BCD coding:
l the number 2450
l is coded: 0010 0100 0101 0000

BOOL

BOOL is the abbreviation of Boolean type. This is the elementary data item in
computing. A BOOL type variable has a value of either: 0 (FALSE) or 1 (TRUE).
A BOOL type word extract bit, for example: %MW10.4.

BYTE

When 8 bits are put together, this is callad a BYTE. A BYTE is either entered in
binary, or in base 8.
The BYTE type is coded in an 8 bit format, which, in hexadecimal, ranges from
16#00 to 16#FF

DATE

The DATE type coded in BCD in 32 bit format contains the following information:

l the year coded in a 16-bit field,


l the month coded in an 8-bit field,
l the day coded in an 8-bit field.

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


This table shows the lower/upper limits in each field:
Field

Limits

Comment

Year

[1990,2099]

Year

Month

[01,12]

The left 0 is always displayed, but can be omitted at the


time of entry

Day

[01,31]

For the months 01\03\05\07\08\10\12

[01,30]

For the months 04\06\09\11

[01,29]

For the month 02 (leap years)

[01,28]

For the month 02 (non leap years)

107

Glossary

DATE_AND_
TIME

see DT

DBCD

Representation of a Double BCD-format double integer.


The Binary Coded Decimal (BCD) format is used to represent decimal numbers
between 0 and 9 using a group of four bits.
In this format, the four bits used to code the decimal numbers have a range of
unused combinations.
Example of DBCD coding:
l the number 78993016
l is coded: 0111 1000 1001 1001 0011 0000 0001 0110

DDT

DDT is the abbreviation of Derived Data Type.


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

DFB

DFB is the abbrevation of Derived Function Block.


DFB types are function blocks that can be programmed by the user ST, IL, LD or
FBD.
By using DFB types in an application, it is possible to:
l simplify the design and input of the program,
l increase the legibility of the program,
l facilitate the debugging of the program,
l reduce the volume of the generated code.

DINT

DINT is the abbrevation of Double Integer format (coded on 32 bits).


The lower and upper limits are as follows: -(2 to the power of 31) to (2 to the power
of 31) - 1.
Example:
-2147483648, 2147483647, 16#FFFFFFFF.

108

Glossary

DT

DT is the abbreviation of Date and Time.


The DT type coded in BCD in 64 bit format contains the following information:
l The year coded in a 16-bit field,
l the month coded in an 8-bit field,
l the day coded in an 8-bit field,
l the hour coded in a 8-bit field,
l the minutes coded in an 8-bit field,
l the seconds coded in an 8-bit field.
Note: The 8 least significant bits are unused.
The DT type is entered as follows:
DT#<Year>-<Month>-<Day>-<Hour>:<Minutes>:<Seconds>
This table shows the lower/upper limits in each field:
Field

Limits

Comment

Year

[1990,2099]

Year

Month

[01,12]

The left 0 is always displayed, but can be omitted at


the time of entry

Day

[01,31]

For the months 01\03\05\07\08\10\12

[01,30]

For the months 04\06\09\11

[01,29]

For the month 02 (leap years)

[01,28]

For the month 02 (non leap years)

Hour

[00,23]

The left 0 is always displayed, but can be omitted at


the time of entry

Minute

[00,59]

The left 0 is always displayed, but can be omitted at


the time of entry

Second

[00,59]

The left 0 is always displayed, but can be omitted at


the time of entry

109

Glossary

DWORD

DWORD is the abbreviation of Double Word.


The DWORD type is coded in 32 bit format.
This table shows the lower/upper limits of the bases which can be used:
Base

Lower limit

Upper limit

Hexadecimal

16#0

16#FFFFFFFF

Octal

8#0

8#37777777777

Binary

2#0

2#11111111111111111111111111111111

Representation examples:
Data content

Representation in one of the bases

00000000000010101101110011011110

16#ADCDE

00000000000000010000000000000000

8#200000

00000000000010101011110011011110

2#10101011110011011110

EBOOL

EBOOL is the abbrevation of Extended Boolean type. It can be used to manage rising
or falling edges, as well as forcing.
An EBOOL type variable takes up one byte of memory.

EF

Is the abbreviation of Elementary Function.


This is a block which is used in a program, and which performs a predefined
software function.
A function has no internal status information. Multiple invocations of the same
function using the same input parameters always supply the same output values.
Details of the graphic form of the function invocation can be found in the "[Functional
block (instance)] ". In contrast to the invocation of the function blocks, function
invocations only have a single unnamed output, whose name is the same as the
function. In FBD each invocation is denoted by a unique [number] via the graphic
block, this number is automatically generated and can not be altered.
You position and set up these functions in your program in order to carry out your
application.
You can also develop other functions using the SDKC development kit.

110

Glossary

EFB

Is the abbreviation for Elementary Function Block.


This is a block which is used in a program, and which performs a predefined
software function.
EFBs have internal statuses and parameters. Even where the inputs are identical,
the output values may be different. For example, a counter has an output which
indicates that the preselection value has been reached. This output is set to 1 when
the current value is equal to the preselection value.

Elementary
Function

see EF

EN

EN means ENable, this is an optional block input. When EN is activated, an ENO


output is automatically drafted.
If EN = 0, the block is not activated, its internal program is not executed and ENO ist
set to 0.
If EN = 1, the internal program of the block is executed, and ENO is set to 1 by the
system. If an error occurs, ENO is set to 0.

ENO

ENO means Error NOtification, this is the output associated to the optional input EN.
If ENO is set to 0 (caused by EN=0 or in case of an execution error),
l the outputs of function blocks remain in the status they were in for the last correct
executed scanning cycle and
l the output(s) of functions and procedures are set to "0".

FBD

FBD is the abbreviation of Function Block Diagram.


FBD is a graphic programming language that operates as a logic diagram. In
addition to the simple logic blocks (AND, OR, etc.), each function or function block of
the program is represented using this graphic form. For each block, the inputs are
located to the left and the outputs to the right. The outputs of the blocks can be linked
to the inputs of other blocks to form complex expressions.

FFB

Collective term for EF (Elementary Function), EFB (Elementary Function Block) and
DFB (Derived Function block)

Function

see EF

Function Block
Diagram

see FBD

111

Glossary

GRAY

Gray or "reflected binary" code is used to code a numerical value being developed
into a chain of binary configurations that can be differentiated by the change in
status of one and only one bit.
This code can be used, for example, to avoid the following random event: in pure
binary, the change of the value 0111 to 1000 can produce random numbers between
0 and 1000, as the bits do not change value altogether simultaneously.
Equivalence between decimal, BCD and Gray:
Decimal

BCD

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Gray

0000 0001 0011 0010 0110 0111 0101 0100 1100 1101

IEC 61131-3

International standard: Programmable Logic Controls


Part 3: Programming languages.

IL

IL is the abbreviation of Instruction List.


This language is a series of basic instructions.
This language is very close to the assembly language used to program processors.
Each instruction is composed of an instruction code and an operand.

INF

Used to indicate that a number overruns the allowed limits.


For a number of Integers, the value ranges (shown in gray) are as follows:

-INF
-3.402824e+38

INF
-1.1754944e-38

When a calculation result is:

0.0

1.1754944e-38

3.402824e+38

l less than -3.402824e+38, the symbol -INF (for -infinite) is displayed,


l greater than +3.402824e+38, the symbol INF (for +infinite) is displayed.
112

Glossary

INT

INT is the abbreviation of single integer format (coded on 16 bits).


The lower and upper 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.

Integer Literals

Integer literal are used to enter integer values in the decimal system. The values can
have a preceding sign (+/-). Individual underlines (_ ) between numbers are not
significant.
Example:
-12, 0, 123_456, +986

IODDT

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


The term IODDT designates a structured data type representing a module or a
channel of a PLC module. Each application expert module possesses its own
IODDTs.

Keyword

A keyword is a unique combination of characters used as a syntactical programming


language element (See annex B definition of the IEC standard 61131-3. All the key
words used in Unity Pro and of this standard are listed in annex C of the IEC
standard 61131-3. These keywords cannot be used as identifiers in your program
(names of variables, sections, DFB types, etc.)).

LD

LD is the abbreviation of Ladder Diagram.


LD is a programming language, representing the instructions to be carried out in the
form of graphic diagrams very close to a schematic electrical diagram (contacts,
coils, etc.).

Located
variables

A located variable is a variable for which it is possible to know its position in the PLC
memory. For example, the variable Water_pressure, is associated with%MW102.
Water_pressure is said to be localized.

113

Glossary

Multiple Token

Operating mode of an SFC. In multitoken mode, the SFC may possess several
active steps at the same time.

Naming
conventions
(Identifier)

An identifier is a sequence of letters, numbers and underlines beginning with a letter


or underline (e.g. name of a function block type, an instance, a variable or a section).
Letters from national character sets (e.g: ,, , ) can be used except in project and
DFB names. Underlines are significant in identifiers; e.g. A_BCD and AB_CD are
interpreted as different identifiers. Multiple leading underlines and consecutive
underlines are invalid.
Identifiers cannot contain spaces. Not case sensitive; e.g. ABCD and abcd are
interpreted as the same identifier.
According to IEC 61131-3 leading digits are not allowed in identifiers. Nevertheless,
you can use them if you activate in dialog Tools Project settings in tab
Language extensions the ceck box Leading digits.
Identifiers cannot be keywords.

NAN

Used to indicate that a result of an operation is not a number (NAN = Not A Number).
Example: calculating the square root of a negative number.
Note: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs
are allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).

114

Glossary

Network

There are two meanings for Network.

l In LD:

A network is a set of interconnected graphic elements. The scope of a network is


local to the program organization unit (section) in which the network is located.
l With communication expert modules:
A network is a group of stations which communicate among one another. The
term network is also used to define a group of interconnected graphic elements.
This group forms then a part of a program which may be composed of a group of
networks.

Procedure

Procedures are functions view technically. The only difference to elementary


functions is that procedures can take up more than one output and they support data
type VAR_IN_OUT. To the eye, procedures are no different than elementary
functions.
Procedures are a supplement to IEC 61131-3.

115

Glossary

REAL

Real type is a coded type in 32 bits.


The ranges of possible values are illustrated in gray in the following diagram:
-INF
-3.402824e+38

INF
-1.1754944e-38

0.0

1.1754944e-38

3.402824e+38

When a calculation result is:


between -1.175494e-38 and 1.175494e-38 it is considerd as a DEN,
less than -3.402824e+38, the symbol -INF (for - infinite) is displayed,
greater than +3.402824e+38, the symbol INF (for +infinite) is displayed,
undefined (square root of a negative number), the symbol NAN or NAN is
displayed.

l
l
l
l

Note: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs
are allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).

Note: when an operand is a DEN (Denormalized number) the result is not


significant.
Real Literals

An literal real value is a number expressed in one or more decimals.


Example:
-12.0, 0.0, +0.456, 3.14159_26

Real Literals
with Exponent

An Literal decimal value can be expressed using standard scientific notation.


The representation is as follows: mantissa + exponential.
Example:
-1.34E-12 or -1.34e-12
1.0E+6 or 1.0e+6
1.234E6 or 1.234e6

116

Glossary

SFC

SFC is the abbreviation of Sequential Function Chart.


SFC enables the operation of a sequential automation device to be represented
graphically and in a structured manner. This graphic description of the sequential
behavior of an automation device, and the various situations which result from it, is
performed using simple graphic symbols.

Single Token

Operating mode of an SFC chart for which only a single step can be active at any
one time.

ST

ST is the abbreviation of Structured Text language.


Structured Text language is an elaborated language close to computer
programming languages. It enables you to structure series of instructions.

STRING

A variable of the type STRING is an ASCII standard character string. A character


string has a maximum length of 65534 characters.

TIME

The type TIME expresses a duration in milliseconds. Coded in 32 bits, this type
makes it possible to obtain periods from 0 to 2 32-1 milliseconds.
The units of type TIME are the following: the days (d), the hours (h), the minutes (m),
the seconds (s) and the milliseconds (ms). A literal value of the type TIME is
represented by a combination of previous types preceded by T#, t#, TIME# or
time#.
Examples: T#25h15m, t#14.7S, TIME#5d10h23m45s3ms

Time literals

The units of type TIME are the following: the days (d), the hours (h), the minutes (m),
the seconds (s) and the milliseconds (ms). A literal value of the type TIME is
represented by a combination of previous types preceded by T#, t#, TIME# or
time#.
Examples: T#25h15m, t#14.7S, TIME#5d10h23m45s3ms

TIME_OF_DAY

see TOD

117

Glossary

TOD

TOD is the abbreviation of Time of Day.


The TOD type coded in BCD in 32 bit format contains the following information:
l the hour coded in a 8-bit field,
l the minutes coded in an 8-bit field,
l the seconds coded in an 8-bit field.
Note: The 8 least significant bits are unused.
The Time of Day type is entered as follows: TOD#<Hour>:<Minutes>:<Seconds>
This table shows the lower/upper limits in each field:
Field

Limits

Comment

Hour

[00,23]

The left 0 is always displayed, but can be omitted at the time of


entry

Minute

[00,59]

The left 0 is always displayed, but can be omitted at the time of


entry

Second

[00,59]

The left 0 is always displayed, but can be omitted at the time of


entry

Example: TOD#23:59:45.
Token

An active step of an SFC is known as a token.

TOPO_ADDR_
TYPE

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

118

Glossary

UDINT

UDINT is the abbreviation of Unsigned Double Integer format (coded on 32 bits)


unsigned. The lower and upper limits are as follows: 0 to (2 to the power of 32) - 1.
Example:
0, 4294967295, 2#11111111111111111111111111111111, 8#37777777777,
16#FFFFFFFF.

UINT

UINT is the abbreviation of Unsigned integer format (coded on 16 bits). The lower
and upper limits are as follows: 0 to (2 to the power of 16) - 1.
Example:
0, 65535, 2#1111111111111111, 8#177777, 16#FFFF.

Unlocated
variable

An unlocated variable is a variable for which it is impossible to know its position in


the PLC memory. A variable which have no address assigned is said to be
unlocated.

Variable

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

119

Glossary

WORD

The WORD type is coded in 16 bit format and is used to carry out processing on bit
strings.
This table shows the lower/upper limits of the bases which can be used:
Base

Lower limit

Upper limit

Hexadecimal

16#0

16#FFFF

Octal

8#0

8#177777

Binary

2#0

2#1111111111111111

Representation examples

120

Data content

Representation in one of the bases

0000000011010011

16#D3

1010101010101010

8#125252

0000000011010011

2#11010011

B
AC

Index

Symbols

%S15, 97
%S16, 97
%S17, 97
%S18, 98
%S19, 98
%S20, 99
%S21, 99
%SD18, 101
%SW12, 100
%SW13, 100
%SW14, 100
%SW15, 100
%SW16, 100
%SW17, 101

Accepts a connection request


FCT_ACCEPT, 51
Advanced
FCT_ACCEPT, 51
FCT_BIND, 55
FCT_CLOSE, 59
FCT_CONNECT, 63
FCT_LISTEN, 67
FCT_RECEIVE, 69
FCT_SELECT, 73
FCT_SEND, 77
FCT_SETSOCKOPT, 81
FCT_SHUTDOWN, 85
FCT_SOCKET, 89

Numerics

100MSCOUNTER, 101
1RSTTASKRUN, 99

Block types, 12

C
CARRY, 97
Client/server example
Open TCP, 38
Client/server model
Open TCP, 36
Conditional FFB Call, 17
Configuration of a socket to await connection
FCT_LISTEN, 67
Creation of a socket
FCT_SOCKET, 89
121

Index

Debugging
Open TCP, 47
Deletes the socket
FCT_CLOSE, 59
Derived function block, 12
Diagnostics
Open TCP, 47
Disables transmission on the socket
FCT_SHUTDOWN, 85

Management parameters
Open TCP, 32
Management table
Open TCP, 32
Multiplexes requests over sockets
FCT_SELECT, 73

E
Elementary Function, 12
Elementary function block, 12
EN, 16
ENO, 16
Establishes IP connection
FCT_CONNECT, 63

F
FCT_ACCEPT, 51
FCT_BIND, 55
FCT_CLOSE, 59
FCT_CONNECT, 63
FCT_LISTEN, 67
FCT_RECEIVE, 69
FCT_SELECT, 73
FCT_SEND, 77
FCT_SETSOCKOPT, 81
FCT_SHUTDOWN, 85
FCT_SOCKET, 89
FLOATSTAT, 101

O
Open TCP
Client/server example, 38
Client/server model, 36
Debugging, 47
Diagnostics, 47
Management table, 32
Operating modes of the network module,
44
Performance, 46
Report, 32
Reports, 34
Operating modes of the network module
Open TCP, 44
OSCOMMPATCH, 100
OSCOMMVERS, 100
OSINTVERS, 100
OVERFLOW, 98
OVERRUN, 98

P
Performance
Open TCP, 46
Procedure, 12

INDEXOVF, 99
IOERRTSK, 97

Report
Open TCP, 32
Reports
Open TCP, 34
Retrieves data from a socket
FCT_RECEIVE, 69

122

Index

S
Sending data to a specified socket
FCT_SEND, 77
Sets the socket options
FCT_SETSOCKOPT, 81
Socket/IP binding
FCT_BIND, 55
STRINGERROR, 97

U
Unconditional FFB Call, 17
UTWPORTADDR, 100

X
XWAYNETWADDR, 100

123

Index

124

You might also like