0% found this document useful (0 votes)
106 views

PL7 Reference Manual

This document provides a detailed description and overview of the PL7 software including: 1. An introduction to the single task and multitask structures and programming capabilities of PL7. 2. An overview of the sections that describe the ladder logic, instruction list, structured text, and Grafcet programming languages supported by PL7. 3. A table of contents that lists each section and sub-section along with the corresponding page numbers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

PL7 Reference Manual

This document provides a detailed description and overview of the PL7 software including: 1. An introduction to the single task and multitask structures and programming capabilities of PL7. 2. An overview of the sections that describe the ladder logic, instruction list, structured text, and Grafcet programming languages supported by PL7. 3. A table of contents that lists each section and sub-section along with the corresponding page numbers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 462

Description of PL7 software

A
Reference
manual Detailed description of instructions and functions
B
___________________________________________________________________________
B/2
A

Description of PL7 Contents


software Part A
___________________________________________________________________________

Section Page
1 General information A1/1

1.1 Presentation of PL7 software A1/1


1.1-1 Presentation A1/1
1.1-2 Single task structure A1/3
1.1-3 Multitask structure A1/3
1.1-4 Structured and modular programming A1/4
1.1-5 Structuring as function modules A1/5
1.1-6 Symbolic programming A1/6
1.1-7 PL7 instructions A1/8
1.1-8 User function blocks A1/9

1.2 Addressable objects A1/10


1.2-1 Definition of the main Boolean objects A1/10
1.2-2 Addressing TSX 37 I/O module objects A1/11
1.2-3 Addressing TSX/PMX/PCX 57 I/O module objects A1/13
1.2-4 Addressing words A1/16
1.2-5 Function block objects A1/20
1.2-6 Structured objects A1/21
1.2-7 Grafcet objects A1/23
1.2-8 DFB objects A1/23
1.2-9 Symbolization A1/24

1.3 User memory A1/26


1.3-1 General A1/26
1.3-2 Saving / retrieving internal words %MWi A1/28
1.3-3 Bit memory A1/29
1.3-4 Word memory A1/31
1.3-5 TSX 37-10/21/22 PLCs A1/32
1.3-6 TSX/PCX/PMX 57-10/20/25 PLCs A1/33
1.3-7 TSX/PCX 57-30/35 PLCs A1/34
1.3-8 PMX57-35/45 and TSX 57-40/45 PLCs A1/35

___________________________________________________________________________
A/1
A

Description of PL7 Contents


software Part A
________________________________________________________________

Section Page
1.4 Operating modes A1/36
1.4-1 Processing on power outage and power return A1/36
1.4-2 Processing on a warm restart A1/37
1.4-3 Processing on a cold start A1/38

1.5 Single task software structure A1/39


1.5-1 Presentation of the master task A1/39
1.5-2 Cyclic execution A1/41
1.5-3 Periodic execution A1/42
1.5-4 Monitoring the scan time A1/44

1.6 Multitask software structure A1/45


1.6-1 Description A1/45
1.6-2 Master task A1/47
1.6-3 Fast task A1/48
1.6-4 Assigning I/O channels to the master and fast tasks A1/49
1.6-5 Event-triggered tasks A1/50

2 Ladder language A2/1

2.1 Presentation of Ladder language A2/1


2.1-1 Principle A2/1
2.1-2 Graphic elements A2/2

2.2 Structure of a rung A2/5


2.2-1 General A2/5
2.2-2 Labels A2/6
2.2-3 Comments A2/6
2.2-4 Rungs A2/7
2.2-5 Rungs with function and operation blocks A2/10

2.3 Rules for executing rungs A2/13


2.3-1 Principle for executing a rung A2/13

___________________________________________________________________________
A/2
A

Description of PL7 Contents


software Part A
___________________________________________________________________________

Section Page

3 Instruction List language A3/1

3.1 Presentation of Instruction List language A3/1


3.1-1 Principle A3/1
3.1-2 Instructions A3/2

3.2 Program structure A3/4


3.2-1 General A3/4
3.2-2 Comments A3/4
3.2-3 Labels A3/4
3.2-4 Using parentheses A3/5
3.2-5 MPS, MRD and MPP instructions A3/7
3.2-6 Principles for programming predefined function blocks A3/8

3.3 Rules for executing Instruction List programs A3/9

4 Structured Text language A4/1

4.1 Presentation of Structured Text language A4/1


4.1-1 Principle A4/1
4.1-2 Instructions A4/2

4.2 Program structure A4/7


4.2-1 General A4/7
4.2-2 Comment A4/7
4.2-3 Label A4/8
4.2-4 Instructions A4/8
4.2-5 Control structures A4/9

4.3 Rules for executing a Structured Text program A4/15

___________________________________________________________________________
A/3
A

Description of PL7 Contents


software Part A
________________________________________________________________

Section Page

5 Grafcet language A5/1

5.1 Presentation of Grafcet language A5/1


5.1-1 Reminder of principles of Grafcet A5/1
5.1-2 Progressive analysis : macro-representations A5/2

5.2 Graphic symbols specific to Grafcet language A5/4

5.3 Objects specific to Grafcet A5/6

5.4 Grafcet language possibilities A5/7

5.5 Grafcet chart representation A5/9

5.6 Macro-steps A5/15


5.6-1 Principle A5/15
5.6-2 Characteristics A5/16
5.6-3 Initial steps A5/16

5.7 Actions associated with steps A5/17

5.8 Conditions associated with transitions A5/20

5.9 Organization of the Grafcet section A5/23


5.9-1 Description of the Grafcet section A5/23
5.9-2 Preprocessing A5/24
5.9-3 The use of system bits in preprocessing A5/25
5.9-4 Sequential processing A5/28
5.9-5 Post-processing A5/30

___________________________________________________________________________
A/4
A

Description of PL7 Contents


software Part A
___________________________________________________________________________

Section Page

6 DFBs A6/1

6.1 Presentation of DFBs A6/1


6.1-1 General A6/1
6.1-2 Setting up a DFB A6/2

6.2 Designing a DFB type A6/3


6.2-1 Creating a DFB type A6/3
6.2-2 Description of parameters and variables A6/3
6.2-3 DFB type code A6/5
6.2-4 Confirming the DFB type A6/6
6.2-5 DFB type properties A6/6
6.2-6 Descriptive file A6/7
6.2-7 DFB type properties A6/7
6.2-8 Importing/exporting a DFB type A6/7

6.3 Creating a DFB type instance A6/8


6.3-1 Principles A6/8

6.4 Using DFBs A6/9


6.4-1 General programming rules A6/9
6.4-2 Programming in Ladder language A6/10
6.4-3 Programming in Structured Text language or
Instruction List language A6/11
6.4-4 Accessing variables A6/12
6.4-5 Saving and restoring public variables A6/12
6.4-6 Executing DFBs A6/12

6.5 Example A6/13

___________________________________________________________________________
A/5
A

Description of PL7 Contents


software Part A
________________________________________________________________

Section Page
7 Function modules A7/1

7.1 Presentation of function modules A7/1


7.1-1 Definition of a function module A7/1
7.1-2 Representation of a function module in PL7 PRO A7/2
7.1-3 The concept of a function submodule A7/3
7.1-4 The attributes of a function module A7/3

7.2 Setting up function modules A7/4


7.2-1 Creating a function module A7/4
7.2-2 Modifying the architecture of function modules A7/4

7.3 Programming a function module A7/6


7.3-1 Adding / creating a section, an event or a macro-step in
a function module A7/6
7.3-2 Deleting a section, a macro-step or an event in a module A7/8
7.3-3 Adding / creating an animation table in a function module A7/9
7.3-4 Entering / modifying the descriptive file A7/9

7.4 Executing the program A7/10

7.5 Debugging the application A7/10

7.6 Application documentation file A7/10

7.7 Importing and exporting the source file for a function module A7/11
7.7-1 Exporting A7/11
7.7-2 Importing A7/11

___________________________________________________________________________
A/6
A
Section 1
PL7 general information 1
1 General information
1.1 Presentation of PL7 software
1.1-1 Presentation
PL7 Junior software is the programming software for TSX 37 and TSX/PMX/PCX 57
PLCs operating under Windows. PL7 Micro software can only be used to program
TSX 37 PLCs.
PL7 Pro software offers, in addition to the functions provided by PL7 Junior software,
the possibility of creating DFB (Derived Function Block) user function blocks, runtime
screens and function modules.
PL7 Prodyn software is an operating tool (control, diagnostics, maintenance) for
TSX 37 and TSX/PMX/PCX 57 PLCs. It cannot be used to create or modify an
application.

PL7 software (1) offers :


• A graphic language, Ladder language (LD), for transcribing Ladder diagrams, which
is particularly suitable for combinational processing. It offers the basic graphic
elements : contacts, coils and blocks. N umeric calculations can be written within
operation blocks.

• A Boolean language, Instruction List language (IL), which is a "machine" language for
writing logical and numerical processing operations.

(1) PL7 is used in the rest of this document to refer to PL7 Junior, PL7 Micro, PL7 Pro
or PL7 Prodyn.
___________________________________________________________________________
1/1
A

• A Structured Text language (ST) which is a "data processing" type language enabling
the structured writing of logical and numerical processing.

• A Grafcet language which is used to represent the operation of a sequential control


system in a graphic and structured way.

These languages use predefined function blocks (timers, counters, etc), which can be
supplemented by application-specific functions (analog, communication, counting,
etc) and specific functions (time management, character strings, etc).
The language objects can be symbolized using the variables editor or online in the
program editors.

PL7 software conforms to standard IEC 1131-3. The tables of conformity are
provided in the Appendix : part B section 6.

___________________________________________________________________________
1/2
A
PL7 general information 1

1.1-2 Single task structure


This is the default structure of the software. It comprises a single task, the master task.
Master task
This task can either be a periodic, said to be cyclic (the default choice), or periodic.
For cyclic operation, the tasks are linked one to the other, without pausing.
For periodic operation, tasks are linked at a period fixed by the user.

1.1-3 Multitask structure


The multitask structure of TSX 37 and TSX 57 PLCs enables better use which gives
high-performance realtime applications by associating a specific program with each
application. Each of these programs is controlled by a task.
These tasks are independent and executed in "parallel" by the main processor which
manages their priority as well as their execution.
The aim of this type of structure is to :
• Optimize use of processing power.
• Simplify design and debugging. Each task is written and debugged independently of
the others.
• Structure the application. Each task has a unique function.
• Optimize availability.
The multitask system offers a master task, a fast task and from 8 to 64 event-triggered
tasks depending on the processor.
Master Fast Event-triggered
task task tasks

- Priority +

Fast task
The fast task (optional), which is periodic, is used to perform short processing
operations with a higher priority than in the master task. When it is programmed, it is
automatically launched by the system during start-up. It can also be stopped and then
restarted by activating a system bit.

Event-triggered tasks
Unlike the tasks described above, these tasks are not linked to a period. They are
triggered by calls originating from certain modules. These tasks have the highest
priority. The processing they perform is deliberately short so that they do not interfere
with the execution of other tasks.

___________________________________________________________________________
1/3
A

1.1-4 Structured and modular programming


PL7 program tasks are made up of several parts (called sections) and subroutines.

Each of these sections can be programmed in the language which is most suitable for
the process to be executed.

MAST FAST

Chamber (LD) Alarm_Chamber (LD) EVT0

Oven_1(Grafcet) Monitor_Sec(LD)

PRL (LD)
Alarm_Oven(ST)
CHART

POST(LD) Alarm_Cleaning(ST) SR0

Drying (LD)
SR0

Cleaning(ST)

This division into sections means that a structured program can be created and program
modules can be generated or incorporated without difficulty.

The subroutines can be called from any section of the task to which they belong, or from
other subroutines in the same task.

___________________________________________________________________________
1/4
A
PL7 general information 1

1.1-5 Structuring as function modules


A function module is a group of program elements (sections, events, macro-steps,
animation tables, etc) used to perform a control system function.
A function module is defined by a certain number of attributes (name, comment,
programming, associated animation tables, etc).

A function module contains a program directory (made up of one or more code modules)
and an animation table directory.

A function module contains


the program and the
animation tables

A function module can itself be divided into lower level function modules which perform
one or more subfunctions of the main control system function.

The Mixer_1 module contains a submodule Adjust_1

PL7 PRO is the only product which can be used to set up function modules on
TSX/PMX/PCX57 PLCs.

___________________________________________________________________________
1/5
A

1.1-6 Symbolic programming


The user can enter or display objects :
• either by their address (for example : %Q2.5),
• or by a character string (32 characters max) known as a symbol (for example
Fc_door).
Note
The objects associated with the DFB user function block are purely symbolic objects.

Example : symbolic display of objects in Ladder language.

Addresses and symbols can be displayed simultaneously in Ladder language.

The language objects can be symbolized using the variables editor or online in the
program editors.

This symbols database, which is managed by the software VARIABLES editor, is global
to the PLC station.

Note
Some application-specific modules enable symbols to be allocated automatically to the objects
associated with them.
___________________________________________________________________________
1/6
A
PL7 general information 1

Symbols and comments stored in the TSX Premium PLC

• Function
Symbols and comments can be stored in a TSX Premium PLC (TSX/PMX/PCX 57202,
57302, 57402, 57452 V3.3) fitted with the following type of memory card :
• 128 Kword memory card : TSXMRP 2128P
• 256 Kword memory card : TSXMRP 3256P
When an application is saved on the PC, an *.STX file is created.
The application image in the form of the *.STX file includes, among other things,
symbols and comments.

The "Symbols and comments stored in the TSX Premium PLC" function provides the
PL7 user with the same ease of programming and operation with respect to symbols
and comments, whether an application image in STX form is available in the PLC or
not.

Notes
1. In online mode, modifications to symbols and comments made in the Variables
Editor are not fed back to the cartridge as they are made. A prompt to update the
database in the PLC is made on a disconnection request if there is a discrepancy
between the local database and the database in the PLC.
2. Freeing space in the symbols and comments database does not increase the size
of the program zone, because the symbols and comments are not stored in the same
place as the program part of the application.
3. The various PL7 editors (data, program, debug tool) use the symbols and comments
database available in the PC in online mode.
4. The Comparison function can be used to compare PC/PLC symbols.

___________________________________________________________________________
1/7
A

1.1-7 PL7 instructions


All PL7 languages use the same instruction set.

Part B of this document describes all the instructions in detail. For simplicity's sake,
these have been classified in 2 sets : basic instructions and advanced instructions.

Basic instructions
They include basic Boolean instructions, predefined function blocks and arithmetic
and logic instructions on integers.

Advanced instructions
These include instructions which meet the needs of advanced programming.
They are of 2 types :
• PL7 language : these increase language processing performance through specific
functions (manipulation of character strings, time management, etc),
• Applications : these offer functions which are specific to the application to be
processed. For example, functions for the communication application :
- PRINT to send a standard character string message to a terminal or printer.
- SEND to send a message to an application.
- PID : PID control function.

Function entry help


An entry help screen gives access to all the language functions. This screen is
accessible at all times, including during programming.

___________________________________________________________________________
1/8
A
PL7 general information 1

1.1-8 User function blocks


PL7 Pro software can be used to create DFB user function blocks for Premium PLCs.
These DFBs are created in Structured Text language, and can then be used in a section
or a subroutine whatever language is used (they can also be used with PL7 Junior
software).

Example of DFBs used in Ladder language.

The main components of a DFB are : DFB type name


• name
• input and output parameters
• public and private variables Inputs Outputs
• code in Structured Text language
A DFB can have a maximum of 15 inputs
and/or I/O and 15 outputs and/or I/O.

Once it has been created, each DFB can


be used several times in an application. I/O
The designer programs the model DFB
(known as the DFB type) and for each use, Public variables
the user defines an instance name using Private variables
the variables editor or using the entry help
Code in Structured Text
screen for the selected language.

___________________________________________________________________________
1/9
A

1.2 Addressable objects


1.2-1 Definition of the main Boolean objects
I/O bits
These bits are the "logical images" of the electrical state of the I/O. They are stored in
the data memory and are updated on each scan of the task in which they are configured.
Internal bits
Internal bits %Mi are used to store intermediate states during execution of the program.
Note : Unused I/O bits cannot be used as internal bits.

System bits
System bits %S0 to %S127 monitor correct operation of the PLC as well as progression
of the application program. The role and use of these bits are described in detail in
section 3.1 of part B.
Function block bits
Function block bits correspond to the outputs of blocks. These outputs can be either
wired directly, or used as objects.
Word extract bits
Using PL7 software it is possible to extract one of the 16 bits from a word object.
Grafcet step and macro-step status bits
Grafcet step status bits for steps %Xi, macro-steps %XMj and steps of macro-steps
%Xj.i (Xj.IN and Xj.OUT for input and output steps of macro-steps) are used to identify
the status of Grafcet step i, macro-step j or step i of macro-step j.
List of bit operands
The following table gives a list of all types of Boolean operands.

Type Address Access in See


(or value) write mode (1) Section Part
Immediate value 0 or 1 (False or True) – 1.2-4 A
Input bits %Ix.i or %IXx.i no 1.2-2 A
Output bits %Qx.i or %QXx.i yes 1.2-3
Internal bits %Mi or %MXi yes –
System bits %Si according to i 3.1 B
Function block eg : %TMi.Q no 1.2-5 A
bits %DRi.F.....
Grafcet bits %Xi, %XMj, %Xj.i... yes 5.2 A
Word extract bits eg : %MW10:X5 acc. to word type 1.2-4 A

(1) Written by program or in adjust mode via the terminal

___________________________________________________________________________
1/10
A
PL7 general information 1

1.2-2 Addressing TSX 37 I/O module objects


Addressing of the main word and bit objects in I/O modules is defined by the following
characters :

% I or Q X, W or D x . i

Symbol Type of object Format Position Channel


I = input X = Bool ean x = Position No.
Q = output W = word number in i = 0 to 127
D = double word the rack or MOD

• Type of object
I and Q : the physical inputs and outputs of modules exchange this information
implicitly on each scan of the task to which they are attached.
Note : Other types of data (status, command words, etc) can also be exchanged if
requested by the application.

• Format (Size)
For objects in Boolean format, the X can be omitted. Other types of format such as
byte, word and double word are defined in section 1.2-4.

• Channel position and number


The base modularity of the TSX 37 is 1/2 format. The positions for each type of TSX
37 PLC (base and extension) are shown in the diagrams below.

TSX 37-10 TSX 37-21/22

1 3 5 7 1 3 5 7 9

2 4 6 8 0
2 4 6 8 10

Base Extension Base Extension

Standard format modules are addressed as two superposed 1/2 format modules (see
table below).

For example, a 64 I/O module is viewed as two 1/2 format modules :


a 32 input 1/2 module located in position 5, and a 32 output 1/2 module located in
slot 6.

___________________________________________________________________________
1/11
A

Module 1/2 format Standard format


4Q 8Q 12 I 28 I/O 32 I 32 Q 64 I/O
Channel number : i 0 to 3 0 to 7 0 to 11 0 to 15 0 to 15 0 to 15 0 to 31

0 to 11 0 to 15 0 to 15 0 to 31
Position and ch. no. x.0 x.0 x.0 x.0 x.0 x.0 x.0
(x = position) to to to to to to to
x.3 x.7 x.11 x.15 x.15 x.15 x.31
(x+1).0 (x+1).0 (x+1).0 (x+1).0
to to to to
(x+1).11 (x+1).15 (x+1).15 (x+1).31

Note :
The channel number can be replaced by "MOD" to access data which is general to the module.

• Rank : an optional suffix can be added after the channel number. This is used to
distinguish different objects of the same type associated with the same channel.
ERR : indicates a module or channel fault.
Examples : %I4.MOD.ERR : information on fault in module 4
%I4.3.ERR : information on fault in channel 3 of module 4.
Note :
For an addressing operation across the network or for remote I/O addressing, the full access path
to the station is added to the position number in the rack.

Examples
%I1.5 input channel no. 5 of the module %I1.5 %I3.8 %I5.MOD.ERR
located at position no. 1.
%I3.8 input channel no. 8 of the normal %IW8.0
TSX 37-10
format module located in position
no. 3 and 4.
1 3 5 7
%Q4.5 output channel no. 5 of the
standard format module located
in position no. 3 and 4.
2 4 6 8
%I5.MOD.ERR Information on module
fault, of the module located in
position no. 5. Base Extension
%Q4.5
%IW8.0 input channel no. 0 of the 1/2
format module located in position
no. 8.

___________________________________________________________________________
1/12
A
PL7 general information 1

1.2-3 Addressing TSX/PMX/PCX 57 I/O module objects


Addressing of the main word and bit objects in I/O modules is defined as follows :

% I or Q X, W or D x y . i

Symbol Type of object Format Rack Module Channel No


I = input X = Bool ean address position i = 0 to 127
Q = output W = word x = 0 to 7 y = 00 to 10 or MOD
D = double word

• Type of object
I and Q : the physical inputs and outputs of modules exchange this information
implicitly on each scan of the task to which they are attached.
Note : Other types of data (status, command words, etc) can also be exchanged if
requested by the application.
• Format (Size)
For objects in Boolean format, the X can be omitted. Other types of format such as
byte, word and double word are defined in section 1.2-4.
• Channel addressing
Channel addressing depends on the rack address, the physical location of the
module in the rack and the channel number.

PS 00 01 02 03 04 05 06 07 08 09 10

00

PS 00 01 02 03 04 05 06 07 08 09 10

01

Notes :
• For the list of objects associated with a module, refer to the manual for the relevant application-
specific function.
• Remote I/O addressing is described in the application-specific functions manual, in the part
entitled "Common features of application-specific functions".

___________________________________________________________________________
1/13
A

Rack addresses (x) and module positions (y)

TSX racks RKY 6 RKY 8 RKY 12 RKY 4EX RKY 6EX RKY 8EX RKY 12EX
Rack address : x 0 0 0 0 to 7 0 to 7 0 to 7 0 to 7
Module position : y 00 to 04 00 to 06 00 to 10 00 to 02 00 to 04 00 to 06 00 to 10

Note :
The address of the rack supporting the processor is always 0.

Channel number (i)

Modules TSX DEY ..../DSY .... 64 I/O 32 I/O 16 I/O 8 I/O


Channel number : i 0 to 63 0 to 31 0 to 15 0 to 7

Note :
The channel number can be replaced by "MOD" to access general module information.

• Rank : an optional suffix can be added after the channel number. This is used to
distinguish between different objects of the same type which are associated with a
single channel.

ERR : indicates a module or a channel fault.

Examples :
- %I104.MOD.ERR : information on fault in the module in position 4 in rack at
address 1.
- %I104.3.ERR : information on fault in channel 3 of the module in position 4 in rack
at address 1.

Note :
For an addressing operation across the network or for remote I/O addressing, the full access path
to the station is added to the channel address.

Examples :

• %I102.5 : input channel 5 of the module located in position 2 in rack at


address 1.
• %Q307.2 : output channel 2 of the module located in position 7 in rack at
address 3.
• %I102.MOD.ERR : information on module fault, of the module located in position
2 in rack at address 1.

___________________________________________________________________________
1/14
A
PL7 general information 1

Use of extension racks

• Functions
Extension racks are used to configure a larger number of modules by using a larger
number of racks. This function is only available with processors version 3.3 or later.
These extension racks have the same functions for configuring their modules or their
power supplies as other racks.
They are added after the base rack if the base rack is extendable and has 8 slots or
less.
They are identified by the letters EX in the reference.
The first address for the first configurable module (excluding the power supply) is
always 8.

• Number of slots available


Extension racks must not have more than 8 slots.

Base rack Extension rack Total number


(type E or EX) (type EX) of slots
4 4 8
4 6 10
4 8 12
6 4 10
6 6 12
6 8 14
8 4 12
8 6 14
8 8 16
12 0 12

Example : base rack with 6 slots and extension rack with 6 slots
6-channel DEY 16A2 module
%I18.6 where rack no. = 1, position = 8, channel = 6

___________________________________________________________________________
1/15
A

1.2-4 Addressing words


Addressing I/O module words is defined in section 1.2-2 or 1.2-3. Other words used in
PL7 language (except network words and function block words) are addressed in the
following way :

% M, K or SS B, W, D or F i

Symbol Type of object Format Number


M = internal B = byte
K = constant W = word
S = system D = double word
F = floating point

• Type of object
M internal words which store values during execution of the program. They are stored
in the data zone within a single memory zone.

K constant words which store constant values or alphanumeric messages. Their


content can only be written or modified by the terminal. They are stored in the same
place as the program. They can therefore use the FLASH EPROM memory as their
support.

S system words. These words perform several functions :


- some provide information on the status of the system by reading %SWi words
(system and application operating time, etc).
- others are used to perform operations on the application (operating mode, etc).
System words are described in section 3, part B.

• Format
Word objects can be addressed by PL7 software using four different formats :
B byte : this format is used exclusively for operations on character strings.
W single length : these 16-bit words can contain an algebraic value between -32 768
and 32 767.
Bit rank
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16-bit format 0 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0

Most significant Least significant

___________________________________________________________________________
1/16
A
PL7 general information 1

D double length : these 32-bit words can contain an algebraic value between
- 2 147 483 648 and 2 147 483 647. These words are stored in the memory on two
consecutive single length words.
Least significant
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

32-bit format 0 1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 Rank n


0 0 1 1 0 1 1 0 0 1 0 1 0 0 1 0 Rank n+1

Most significant

F floating point : the floating point format used is that of IEEE Std 754-1985 (equivalent
to IEC 559). Words are 32 bits long, which corresponds to single length floating point
numbers.
Example of floating point values :
1285.28
12.8528E2

Overlapping between objects :


Bytes, single, double length and floating
%MW0 %MB1 %MB0
point words are stored within the data area %MD0
in the same memory zone. %MW1 %MB3 %MB2
%MD1
Thus, there is overlapping between : %MW2 %MB5 %MB4
• Double length word %MDi and single %MD2
%MW3 %MB7 %MB6
length words %MWi and %MWi+1 (word %MD3
%MWi containing the least significant
%MWi
bits and word %MWi+1 containing the %MDi
most significant bits of word %MDi). %MWi+1
• Single length word %MWi and bytes
%MBj and %MBj +1 (where j=2.i). %MWk
%MFk
• Between the floating point %MFk and %MWk+1
single length words %MWk and
%MWk+1.

Examples :
%MD0 corresponds to %MW0 and %MW1.
%MW3 corresponds to %MB7 and %MB6.
%KD543 corresponds to %KW543 and
%KW544.
%MF10 corresponds to %MW10 and
%MW11.
___________________________________________________________________________
1/17
A

Immediate values
These are algebraic values whose format is similar to that of single and double length
word (16 or 32 bits), which allow assignment of values to these words. They are stored
in the program memory and can take the following syntax :

Type Syntax Lower Upper


limit limit
Boolean 0 or 1 (FALSE or TRUE)
Base 10 integer single length 1506 -32768 +32767
double length 578963 -2 147 483 648 2 147 483 647
Base 2 integer single length 2#1000111011111011011 2#10...0 2#01...1
(binary) double length 2#1000111011111011011 2#10...0 2#01...1
1111111011111011111
Base 10 integer single length 16#AB20 16#0000 16#FFFF
(hexadecimal) double length 16#5AC10 16#000000000 16#FFFFFFFF
Floating point -1.32E12 -3.402824E+38 (1) -1.175494E-38 (1)
1.175494E-38 (1) 3.402824E+38 (1)
Character string 'aAbBcC'
(1) excluding limit values

Addressing words on the network


Addressing words on the network is described in the Communication manual.

However, networks use specific objects : common words. These are single length word
objects (16 bits) common to all the stations connected to the communication network.
Addressing : %NW{i.j}k
where : i = network no. 0 to 127, j = station no. 0 to 31 and k = word no. 0 to 3

Word extract bits


PL7 software can be used to extract one of the 16 bits from single length words. The rank
of the bit extracted is then added to the word address, following the syntax below :

WORD :X j
Position
j=0 to 15
Rank of bit
in the word

Examples : %MW10:X4 = bit no. 4 of internal word %MW10


%QW5.1:X10 = bit no. 10 of output word %QW5.1

Note : Word bits can also be extracted on indexed words.


___________________________________________________________________________
1/18
A
PL7 general information 1

Summary list of main word objects and associated bits


The notations used are R for read, and W for write.

Associated Type Addressing Limits Possibilities


words and bits
Internal words single length %MWi (1) R/W
double length %MDi (1) R/W
floating point %MFi (1) R/W
byte (2) %MBi (1) R/W
Constant words single length %KWi (1) R/W (3)
double length %KDi (1) R/W (3)
floating point %KFi (1) R/W (3)
byte (2) %KBi (1) R/W (3)
I/O module Input single length %IWxy.i 0≤i≤127 R
words Input double length %IDxy.i 0≤i≤126 R
Output single length %QWxy.i 0≤i≤127 R/W
Output double length %QDxy.i 0≤i≤126 R/W
Grafcet words single length %Xi.T 0≤i≤249 R
double length %Xj.i.T 0≤j≤63 0≤i≤249 R
Common words on network %NW{i.j}k 0≤i≤127 0≤j≤31 0≤k≤3 R/W
System words single length %SWi 0≤i≤255 R/W (4)
double length %SDi 0≤i≤254 R/W (4)
Word extract bit j of internal word %MWi:Xj 0≤j≤15 R/W
bits bit j of constant word %KWi:Xj 0≤j≤15 R/W (3)
bit j of input word %IWi:Xj 0≤j≤15 R
bit j of output word %QWi:Xj 0≤j≤15 R/W
bit j of system word %SWi:Xj 0≤j≤15 R/W (4)
bit j of common word %NW{j}k:Xm 0≤m≤15 R/W
network 0

(1) The maximum limit depends on the memory size available and the number of words declared
during software configuration.
(2) This object only exists in the start address of a character string %MBi:L or %KBi:L (see section
2.8-1, part B).
(3) Write by terminal only.
(4) Write according to i.

___________________________________________________________________________
1/19
A

1.2-5 Function block objects


Function blocks use specific bit and word objects.
• Bit objects :
These correspond to the outputs of
%Ci
blocks. These bits are accessible using
R E
Boolean test instructions.
S
• Word objects : C.P : 9999 D
These correspond : CU
- to the configuration parameters of the MODIF : Y
block. The program may (eg : preset CD F
parameter) or may not (eg : time base)
be used to access these parameters,
- to the current values (eg : %Ci.V current Up/down counter block
counter value).

List of function block bit and word objects accessible by program

Predefined Associated words and bits Address Access in See


function blocks write mode Part B
Timer Word Current value %TMi.V no sn1.3-2
%TMi (i=0 to 63) Preset value %TMi.P yes
(1) Bit Timer output %TMi.Q no
Up/down Word Current value %Ci.V no sn1.3-3
counter Preset value %Ci.P yes
%Ci (i=0 to 31) Bit Underflow output (empty) %Ci.E no
Preset reached output %Ci.D no
Overflow output (full) %Ci.F no
Monostable Word Current value %MNi.V no sn2.2-1
%MNi (i=0 to 7) Preset value %MNi.P yes
Bit Current monostable output %MNi.R no
Register Word Register input %Ri.I yes sn2.2-2
%Ri (i= 0 to 3) Register output %Ri.O yes
Bit Register full output %Ri.F no
Register empty output %Ri.E no
Drum Word Current step number %DRi.S yes sn2.2-3
controller Status of step j %DRi.Wj no
%DRi (i=0 to 7) Active time of the step %DRi.V no
Bit Last current step defined %DRi.F no
Series 7 Word Current value %Ti.V no sn2.2-4
timer Preset value %Ti.P yes
%T (i=0 to 63) (1) Bit Timer running output %Ti.R no
Timer done output %Ti.D no
(1) The total number of timers %TMi and %Ti is limited to 64 for a TSX 37, 255 for a TSX 57.
(2) The maximum number is given for a TSX 37, for a TSX 57 i = 0 to 254 for all function blocks.

___________________________________________________________________________
1/20
A
PL7 general information 1

1.2-6 Structured objects


Bit tables
Bit tables are sequences of adjacent bit objects of the same type and of a defined
length, L. %M10 %M11 %M12 %M13 %M14 %M15
Example of bit tables : %M10:6 nc by
Type Address Maximum size Access in write mode
Discrete input bits %Ix.i:L 1 < L < m (1) No
Discrete output bits %Qx.i:L 1 < L <m (1) Yes
Internal bits %Mi:L i+L < n (2) Yes
Grafcet bits %Xi:L, %Xj.i:L i+L < n (2) No

(1) m = modularity of the module (eg : 8 for an 8 input or 8 output module),


(2) n varies according to the size defined during configuration.

Word tables
%KW10 16 bits
Word tables are sequences of adjacent
words of the same type and of a defined
length, L.
%KW14
Example of word tables : %KW10:5

Type Format Address Maximum Access in


size write mode
Internal words Single length %MWi:L i+L < Nmax (2) Yes
Double length %MDi:L i+L <Nmax-1 (2) Yes
Floating point %MFi:L i+L < Nmax-1 (2) Yes
Constant words Single length %KWi:L i+L < Nmax (2) No
Double length %KDi:L i+L< Nmax-1 (2) No
Floating point %KFi:L i+L <Nmax-1 (2) No
Grafcet words Single length %Xi.T:L, %Xj.i.T:L i+L<Nmax-1 (2) No
System words Single length %SW50:4 (3) Yes

Character strings %MB10 8 bits


Character strings are sequences of
adjacent bytes of the same type and of a
defined length, L. %MB14
Example of character string : %MB10:5
Type Address Maximum size Access in write mode
Internal words %MBi:L (5) 1-i+L< Nmax (4) Yes
Constant words %KBi:L (5) 1-i+L< Nmax (4) Yes
(3) Only words %SW50 to %SW53 can be addressed in table form.
(4) Nmax = maximum number defined during software configuration.
(5) i must be even.
___________________________________________________________________________
1/21
A

Indexed objects
• Direct addressing
Addressing of objects is said to be direct when the address of these objects is fixed and
defined when the program is written.
Example : %MW26 (internal word at address 26)

• Indexed addressing
In indexed addressing, an index is added to the direct address of the object : the content
of the index is added to the address of the object. The index is defined by an internal
word %MWi, a constant word %KWi or an immediate value. The number of "index
words" is unlimited.
Example : %MW108[%MW2] : direct address word 108 + content of word %MW2.
If the content of word %MW2 is the value 12, writing %MW108[%MW2]
is therefore equivalent to writing %MW120.

Type Format Address Maximum Access in


size write mode
Input bit Boolean %Ii[index] 0<i+index<m (1) No
Output bit Boolean %Qi[index] 0<i+index<m (1) Yes
Internal bit Boolean %Mi[index] 0<i+index<Nmax (2) Yes
Grafcet bit Boolean %Xi[index] 0<i+index<Nmax (2) No
%Xj.i[index] 0<i+index<Nmax (2) No
Internal words Single length %MWi[index] 0<i+index<Nmax (2) Yes
Double length %MDi[index] 0<i+index<Nmax-1 (2) Yes
Floating point %MFi[index] 0<i+index<Nmax-1 (2) Yes
Constant words Single length %KWi[index] 0<i+index<Nmax (2) No
Double length %KDi[index] 0<i+index<Nmax-1 (2) No
Floating point %KFi[index] 0<i+index<Nmax-1 (2) No
Grafcet words Single length %Xi .T[index] 0<i+index<Nmax (2) No
%Xj.i.T[index] 0<i+index<Nmax (2) No
Word table <Object> [index]:L index[index]:L 0<i+index+L<Nmax (2) Yes
%MDi[index]:L 0<i+index+L<Nmax (2) Yes
%KWi[index]:L 0<i+index+L<Nmax (2) No
%KDi[index]:L 0<i+index+L<Nmax (2) No
(1) m = modularity of the I/O module (eg : 8 for an 8 input or 8 output module). Indexation is only
possible for discrete I/O modules.
(2) Nmax = maximum number defined during software configuration.
This type of addressing is used to run through a series of objects of the same type (internal words,
constant words etc) in succession. The content of the index is added to the object address.
Note :
Indexing double words (or floating point words).
Example : %MD6[%MW100] direct address double word 6 + 2 times the content of word %MW100.
If %MW100=10, the word addressed will be 6 + 2 x 10 -->%MD26.
___________________________________________________________________________
1/22
A
PL7 general information 1

• Index overrun, system bit %S20


Index overrun occurs as soon as the address of an indexed object exceeds the limits
of the zone including this same type of object, that is, when :
• object address + index content is lower than the value zero.
• object address + index content is higher than the maximum limit configured (see table
on the previous page).
In the event of index overrun, the system sets system bit %S20 to 1 and the object is
assigned an index value of 0.
Monitoring of overrun is the responsibility of the user : bit %S20 must be read by the user
program for any processing. Resetting it is the responsibility of the user.
%S20 (initial state = 0) :
• on index overrun : set to 1 by the system,
• overrun acknowledgment : set to 0 by the user after modification of the index.

1.2-7 Grafcet objects


Bit objects
The user has the following bit objects :
• %Xi associated with the steps which enable him to identify the status of step i of the
main chart.
• %XMj associated with the macro-steps which enable him to identify the status of
Grafcet macro-step j.
• %Xj.i associated with step i of macro-step j which enable him to identify the status of
Grafcet step i of macro-step j.
• %Xj.IN or %Xj.OUT associated with the input or output step of the macro-step.
These bits are set to 1 when the step or macro-step is active, and 0 when it is inactive.

Word objects
One word is associated with each step : %Xi.T, %Xj.i.T, %Xj.IN.T or %Xj.OUT.T. It
indicates the activity time of Grafcet step i. It is incremented every 100ms and takes a
value between 0 and 9999.

1.2-8 DFB objects


The DFB output parameters and public variables can be accessed by the program.
These objects are Boolean, numerical, or table objects (see section 6).
These objects are purely symbolic and are defined by the following syntax :
DFB_name.Parameter_name, where DFB_name is the name given to the DFB used
(32 characters maximum) and Parameter_name is the name given to the output
parameter or the public variable (8 characters maximum).

___________________________________________________________________________
1/23
A

1.2-9 Symbolization
Symbols
A symbol is a string of up to 32 alphanumeric characters, of which the first character is
alphabetical. A symbol starts with a capital letter, followed by letters in lower case (for
example : the symbol Burner_1). When it is entered, the symbol can be written in upper
or lower case (for example : BURNER_1). The software automatically puts the symbol
into its correct format.
The following characters can therefore be used :
• upper case alphabetical :
"A to Z" and accented letters "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏDÑÒÓÓÕÖØÙÚÛÜYp"
or lower case alphabetical :
" a to z", and accented letters : àáâãäåæçèéêëìíîïðñòóôõöØùúûüypßÿ
• numerical : digits 0 to 9 (they cannot be placed at the start of the symbol).
• the character "_" (this cannot be placed either at the beginning or end of the symbol).

A number of words are reserved by the language and cannot be used as symbols. See
full list in section 5 part B.

The symbols are defined and associated with language objects by the variables editor
(see section 5, part D). A comment of 508 characters can be associated with each
symbol. The symbols and their comments are saved to the terminal disk and not in the
PLC.

Objects which can be symbolized


All PL7 objects can be symbolized except table type structured objects and indexed
objects, but if the base object or the index is symbolized, the symbol is used in the
structured object.
Examples :
• if word %MW0 has "Temperature" as its symbol, the word table %MW0:12 is
symbolized by "Temperature:12"
• if word %MW10 has "Oven_1" as its symbol, the indexed word %MW0[%MW10] is
symbolized by "Temperature[oven_1]".

Word extract bit objects and function block bits or words can be symbolized, but if they
are not symbolized, they can take on the symbol of the base object.
Examples :
• if word %MW0 has " Pump_status" as its symbol and if the word extract bit %MW0:X1
is not symbolized, it takes on the symbol of the word. %MW0:X1 has as its symbol,
"Pump_status:X1".
• if function block %TM0 has "Oven1_timer" as its symbol and if output %TM0.D is not
symbolized, it takes on a symbol of the block. %TM0.D has as its symbol,
"Oven_timer.D".

___________________________________________________________________________
1/24
A
PL7 general information 1

Purely symbolic objects


DFB parameters only be accessed as symbols. These objects are defined by the
following syntax :
DFB_name.Parameter_name.
where DFB_name is the name given to the DFB used (32 characters maximum) and
Parameter_name is the name given to the output parameter or the public variable (8
characters maximum).

Presymbolized objects
Application-specific modules enable symbols to be allocated automatically to the
objects associated with them. The user gives the generic symbol for channel %CHxy.i
of the module, and all the symbols for the objects associated with this channel can then
be generated automatically on request.
These objects are symbolized using the following syntax :
User_prefix_Manufacturer_suffix
where
User_prefix is the generic symbol given by the user to channel %CHxy.i (12 characters
maximum),
Manufacturer_suffix is the part of the symbol which corresponds to the channel bit or
word given by the system (20 characters maximum).
In addition to the symbol, a manufacturer comment is generated automatically which
gives a brief description of the role of the object.

Example : Auxil_motor2_param where "Auxil_motor2" is the user prefix and "_param"


is the predefined manufacturer suffix.

___________________________________________________________________________
1/25
A

1.3 User memory


1.3-1 General
The memory space of TSX 37 PLCs, which is accessible to the user, is divided into two
distinct units :
• Bit memory :
RAM integrated in the processor module containing the image of 1280 bit objects.
• Word memory :
16-bit words (program, data and constants) supported by a RAM memory in the
processor module. This memory can be extended by a 32 or 64 K word RAM or
FLASH EPROM user memory card (on TSX 37-21/22).
A 16 K word FLASH EPROM memory integrated in the processor module can be used
to back up the application program (15 Kwords) and 1000 internal words (1 Kword)
(see paragraph 1.3-2).
A 32 K word FLASH EPROM backup card can also be used to update an application
in the internal RAM of the processor. This card contains the program part and the
constants but not the data.
The word memory can be organized in 2 different ways depending on whether or not
a memory card (PCMCIA) is used :
TSX 37-05/08/10 or
TSX 37-21/22 (no PCMCIA card) TSX 37-21/22 (with PCMCIA card)

Data Internal Data Internal Unusable


Internal RAM Flash zone
RAM Program EPROM

Constants %MW
backup
Program RAM or
and constants Program
Internal external
Flash backup Flash
EPROM (1) EPROM
%MW memory
backup card
Constants

Data : realtime application data and system data.


Program : descriptors and executable code of tasks.
Constants : constant words, initial values and I/O configuration.
Note
RAM memories can be backed up by Cadmium-nickel batteries, supported by the
processor module for the bit and internal RAM memory.
(1) The application is transferred automatically from the FLASH EPROM memory to the RAM
memory if the application in the RAM is lost (backup fault or absence of battery). A manual
transfer can also be requested, via a programming terminal.
___________________________________________________________________________
1/26
A
PL7 general information 1

The memory space of TSX/PMX/PCX 57 PLCs only has one single unit. The bit memory,
which is separate on the TSX 37, is integrated into the word memory (in the data zone).
It is limited to 4096 bits.
• Word memory :
16-bit words (program, data and constants) supported by a RAM memory in the
processor module. This memory can be extended by a 32, 64, 128 or 256 K word RAM
or FLASH EPROM user memory card (1).
A 32 K word FLASH EPROM backup card can also be used for updating an application
in the internal RAM of the processor. This card contains the program part and the
constants but not the data.
The memory can be organized in 2 different ways depending on whether or not a
memory card (PCMCIA) is present and how it is used :
TSX/PMX/PCX 57 TSX/PMX/PCX 57
(no memory card) (with memory card)

Internal Data Internal Data


RAM RAM
Program

Constants

RAM or
FLASH Program
EPROM
memory
card Constants

Data : realtime application data and system data (the system reserves a RAM
memory zone of 5 Kwords minimum).
Program : descriptors and executable code of tasks.
Constants : constant words, initial values and I/O configuration.
Symbols : TSX MRP 2128P and TSX MRP 3256 P cards contain a zone of
128 Kwords and 256 Kwords for storing application symbols.
Archive : TSX MRP 232P/264P/2128P/3256 P cards contain an archive zone
zone for data which can be accessed by read/write instructions (see section
2.13, part B).
There is no possibility either of data overflow on the memory card or of having a program
on the internal RAM and on the cartridge at the same time.
Note
RAM memories can be backed up by nickel-cadmium batteries.
(1)256 Kword memory cards are paged cards. One page of 128 Kwords receives the executable
code, the other page of 128 Kwords receives graphic information.
For further information, see section 8 part B.
___________________________________________________________________________
1/27
A

1.3-2 Saving / retrieving internal words %MWi


Saving internal words %MWi
In order to save adjustment data in the event of a power outage, when the processor
battery is faulty or missing, TSX 37 PLCs can copy 1000 internal words (%MW)
maximum to the internal Flash EPROM memory. This backup zone can be used at all
times, even if the PLC is fitted with a PCMCIA memory card (TSX 37-21/22).
To save internal words to the Flash EPROM, the application must be stopped. It is
triggered according to the choice made during configuration :
• by setting the discrete input %I1.9 to 1,
• from an adjustment panel, by setting bit 0 of %SW96 to 1.
The value of system word %SW97 defines the number of %MWi to be saved (1000
maximum).
At the end of the backup, the display block displays OK or NOK depending on the result
of the operation.
The internal words %MWi are always saved when the application program is
saved.
If system word %SW97 is initialized to 0, only the application program contained in the
internal RAM is transferred to the Flash EPROM (equivalent to a Backup program).
Warning : any saved %MWi are still erased.

Retrieving internal words %MWi


Saved %MWi are transferred from the internal Flash EPROM memory to the RAM
memory on a cold start caused by :
• loss of the internal RAM contents. In this case, if the application program backup is
valid, this is also transferred to the internal RAM (TSX 37-10 or TSX 37-20 without
PCMCIA application cartridge),
• pressing the RESET button, on the front panel of the PLC,
• setting bit %S0 to 1, in adjust mode,
• clicking on the "Cold start" button in the PL7 processor debug screen,
• transferring a program to the PLC (via terminal port, FIPWAY, etc),
• plugging in a PCMCIA application cartridge.
For the saved %MW to be retrieved to the internal RAM, the "Reset %MWi on cold start"
box must not be checked in the processor configuration screen.
For further information, refer to part A of the TSX Micro installation manual.

___________________________________________________________________________
1/28
A
PL7 general information 1

1.3-3 Bit memory


Composition
This memory contains 1280 bit objects, for all types of TSX 37 PLC. For the
TSX/PMX/PCX 57, this bit memory does not exist and its contents are found in the word
memory in the application data zone.

TSX TSX TSX/PMX TSX/PMX TSX/PMX


37-05/08/10 37-21/22 PCX 57-1• 57-2• PCX 57-3•
System bits %SI 128 128 128 128 128
I/O bits %I/Qx (1) (1) (1) (1) (1)
Internal bits %Mi 256 256 3962 (2) 8056 (2) 12152 (2)
Step bits %Xi (3) 96 128 1024 1024 1024
(1) Depends on the declared hardware configuration (I/O module, devices on the AS-i bus and
on the FIPIO bus)
(2) The number of internal bits can be set in the configuration. The default value (256 to 2048)
varies depending on the processor being used and on the presence of a memory cartridge. The
rest of the memory is available for application-specific functions.
(3) Total number of step bits and macro-step bits for TSX/PMX/PCX 57 PLCs.

Structure
Each bit object contained in the bit memory is stored using 3 bits assigned in the
following way :

F P C

Current state (only bit accessible


by the application program)
Previous state
Forcing state
When the bit memory is updated, the system performs the following :
• the transfer of the image of the current state to the previous state,
• the updating of the current state via the program, the system or the terminal (when
a bit is forced).
Rising or falling edge
This structure of the bit memory is used to test for a rising or falling edge on :
• I/O bits,
• internal bits.
Recommendations for the use of rising or falling edges
The rising or falling edge contact instructions only operate correctly in the following
conditions :
• In all cases, for a single object :
- input bit : process the edge contact in the task to which the input module has been assigned,
- output or internal bit : process reading and writing of it within the same task.
___________________________________________________________________________
1/29
A

• Write the coil of an object once only when an edge contact of this object is used in
a program.
• Do not perform a SET or RESET on an object where the edge is tested, because even
if the result of the equation conditioning the SET/RESET equals 0, the SET/RESET
action is not performed, but the object log is updated (loss of the edge).
• Do not test the edge of an I/O used in a event-triggered task, in a master or fast task.
• For internal bits : the detection of an edge is separate from the task scan. An edge on
internal bit %Mi is detected when it changes state between 2 read operations. This
front remains detected as long as this internal bit has not been scanned in the
action zone.
Thus, in the example opposite, if bit %M0
is forced to 1 in an animation table, the %M0
edge is permanently on. P INC%MW0

In order that the edge is only detected once, an intermediate internal bit must be used.

In this case the %M1 log is updated,


%M0 %M1
therefore the edge only occurs once.

%M1
P INC%MW0

Forcing states
When there is a forcing request via the terminal :
• forcing state F is set to 1
• current state C is set to :
- 1 if forcing to 1 is requested
- 0 if forcing to 0 is requested.

These states remain unchanged until :


• forcing is deactivated and the bit in question updated,
• inverse forcing is requested, in which case only the current state is modified.

___________________________________________________________________________
1/30
A
PL7 general information 1

1.3-4 Word memory


This 16-bit word memory is structured into 3 logical areas :

• Data Application data

• Program Application program


• Constants
Application constants

of which the size is defined by configuration.

Application data memory


The data memory contains the following zones :
• System words : fixed number
• Function blocks : correspond to the words and I/O of these blocks (current,
adjustment values, etc).
The number of each type of function block is fixed during configuration.
• Internal words : size defined by the number declared during configuration.
• I/O : correspond to the words associated with each module. Their number depends
on the modules configured.
• Network common words : 4 common words per PLC station (only available if
communication module present and configured for exchange of common words).

In the case of the TSX/PMX/PCX 57, the data memory also includes the bit data detailed
in the preceding paragraph.

Application program memory


This zone contains the executable program code, graphic data (Ladder language
rungs) and program comments.

Application constant memory


This zone contains the parameters of the function blocks and I/O modules defined
during configuration, and constant words %KW.

Note :
The symbols and comments associated with objects are not recorded in the PLC memory but
stored in the local application (hard disk on the terminal).

___________________________________________________________________________
1/31
A

1.3-5 TSX 37-05/08/10/21/22 PLCs


Size of the bit memory

Processor 37 05/08/10 37 21/22


Size available on processor 1280 1280
Type system bits %Si 128 128
of objects I/O bits %I/Qx.i (1) (1)
internal bits %Mi 256 256
step bits %Xi 96 128
(1) Depends on the declared hardware configuration (I/O module, devices on the AS-i bus)

Size of the word memory

Processor 3705/08 3710 3721 37 22


Cartridge - - 32K 64K - 32K 64K
Total size 9K 14K 20K 52K 84K 20K 52K 84K
Data(%MWi) 0.5K(1) 0.5K(1) 0.5K(1) 17.5K 17.5K 0.5K(1) 17.5K 17.5K
Program
100% Boolean
• LD language 1.6 Ki 3.8 Ki 6.6 Ki 13.7 Ki 28.5 Ki 6.3 Ki 13.6 Ki 28.4 Ki
• IL language 2 Ki 4.9 Ki 8.4 Ki 17.5 Ki 36.3 Ki 8.1 Ki 17.3 Ki 36.1 Ki
• ST language 1.3 Ki 3.3 Ki 5.6 Ki 11.7 Ki 24.2 Ki 5.4 Ki 11.5 Ki 24.1 Ki
Program
90% Boolean
• LD language 1.1 Ki 3.1 Ki 5.4 Ki 11.8 Ki 24.7 Ki 5.2 Ki 11.6 Ki 24.5 Ki
• IL language 1.4 Ki 3.8 Ki 6.6 Ki 14.3 Ki 30.0 Ki 6.3 Ki 14.2 Ki 29.8 Ki
• ST language 1.1 Ki 2.9 Ki 5.1 Ki 11.1 Ki 23.3 Ki 4.9 Ki 11.0 Ki 23.2 Ki
Program
65% Boolean
• LD language 0.9 Ki 2.2 Ki 4.0 Ki 9.1 Ki 18.9 Ki 3.9 Ki 8.9 Ki 18.8 Ki
• IL language 1.0 Ki 2.5 Ki 4.6 Ki 10.3 Ki 21.3 Ki 4.4 Ki 10.1 Ki 21.2 Ki
• ST language 1.0 Ki 2.5 Ki 4.6 Ki 10.3 Ki 21.3 Ki 4.4 Ki 10.1 Ki 21.2 Ki
Constants (1) 128 words 128 words128 words 256 words 512 words 128 words 256 words 512 words
K = Kwords Ki = Kinstructions
(1) Default size can be extended. However, this will adversely affect the size of the application program.

Note : the PLC/Memory Usage command in PL7 software provides the memory mapping of the
application in the PLC memory.

___________________________________________________________________________
1/32
A
PL7 general information 1

1.3-6 TSX/PCX/PMX 57-10/20/25 PLCs


These tables refer to TSX 57-10, PCX 57-10, PMX 57-10, TSX 57 -20, PMX 57-20 and
TSX 57-25 PLC5.
Size of the bit memory

Processor 57 10 57 20/25
Type system bits %Si 128 128
of objects I/O bits %I/Qx.i (1) (1)
internal bits %Mi 3962 8056
step bits %Xi 1024 1024
(1) Depends on the declared hardware configuration (I/O module, devices on the AS-i bus and on
the FIPIO bus)
Size of the word memory

Processor TSX-PCX57 10 / PMX 57 10 TSX-PMX 5720 / TSX 57 25


Cartridge - 32K 64K - 32K 64K 128K
Internal memory 32K/48K 32K/48K 32K/48K 48K/64K 48K/64K 48K/64K 48K/64K
Data (%MWi) 1K(1) 26K 26K 1K(1) 30.5K 30.5K 30.5K
Program
100% Boolean
• LD language 8.8/16.1 Ki 12.4/12.4 Ki 27.2/27.2 Ki 16.1/23.5 Ki 12.4/12.4 Ki 27.2/27.0 Ki 56.8/56.8 K
• IL language 11.2/20.6 Ki 15.8/15.8 Ki 34.7 /34.7Ki 20.5/29.9 Ki 15.8/15.8 Ki 34.7/34.4 Ki 72.4/72.4 K
• ST language 13.7 /13.7 Ki 10.6 /10.6 Ki 23.1/23.1 Ki 13.7/19.9 Ki 10.5/10.5 Ki 23.1/23.0 Ki 48.2/48.2 K
Program
90% Boolean
• LD language 5.3/11.6 Ki 8.8/8.8 K 21.6/21.6 Ki 11.6/17.6 K 8.7/8.7 Ki 21.6/21.6 Ki 47.7/47.5 K
• IL language 6.3/14.2 Ki 10.5/10.7 K 25.9 /26.3Ki 13.9/21.1 K 10.4/10.4 Ki 25.8/25.8 Ki 56.6/56.7 K
• ST language 5.0/11.0 Ki 8.4/8.3 K 20.7/20.4 Ki 11.1/16.9 K 8.4/8.4 Ki 20.7/20.7 Ki 45.4/45.4 K
Program
65% Boolean
• LD language 3.7/8.5 Ki 6.8/6.6K 16.9/16.5 Ki 8.7/13.7 Ki 6.8/6.8 Ki 16.8/16.8 Ki 37.0/37.0 Ki
• IL language 3.8/9.7 Ki 6.9/7.5 K 17.3 /18.7Ki 8.9/14.1 Ki 6.9/6.9 Ki 17.2/17.2 Ki 37.9/37.9 Ki
• ST language 4.4/9.7 Ki 8.0/7.5K 20.0/18.7 Ki 10.3/16.3 Ki 8.0/8.0 Ki 19.9/19.9 Ki 43.8/43.8 Ki
Constants (1) 128 words 128 words 256 words 512 words 128 words 256 words 512 words
K = Kwords Ki = Kinstructions
(1) Default size can be extended. However, this will adversely affect the size of the application program.
Notes :
• When this table gives 2 values for each characteristic separated by a "/", these values relate
respectively to the 2 types of processor (separated by a "/" in the table heading).
• The PLC/Memory Usage command in PL7 software provides the memory mapping of the
application in the PLC memory.
___________________________________________________________________________
1/33
A

1.3-7 TSX/PCX 57-30/35 PLCs


These tables refer to TSX 57-30, TSX 57-35 and PCX 57-35 PLCs.

Size of the bit memory

Processor 57 30/35
Type system bits %Si 128
of objects I/O bits %I/Qx.i (1)
internal bits %Mi 12152
step bits %Xi 1024
(1) Depends on the declared hardware configuration (I/O module, devices on the AS-i bus and
on the FIPIO bus)
Size of the word memory

Processor TSX 5730 / TSX and PCX 57 35


Cartridge - 32K 64K 128K 256K
Internal memory 64K / 80 K 64K / 80 K 64K / 80K 64K / 80K 64K / 80K
Data (%MWi) 1K(1) 30.5 K 30.5K 30.5K 30.5K
Program
100% Boolean
• LD language 23.5/30.8 Ki 12.4 Ki/12.4 Ki 27.2 Ki/27.2 Ki 56.8 Ki/56.8 Ki 90.5 Ki/90.5 Ki
• IL language 29.9/39.3 Ki 15.8 Ki/15.8 Ki 34.7Ki/34.7Ki 72.4 Ki/72.4 Ki 83.6 Ki/83.6 Ki
• ST language 19.9/26.2 Ki 10.5 Ki/10.5 Ki 23.1 Ki/23.1 Ki 48.2 Ki/48.2 Ki 74.6 Ki/74.6 Ki
Program
90% Boolean
• LD language 18.0/24.4 Ki 8.7 Ki/8.7 Ki 21.6 Ki/21.6 Ki 47.5 Ki/47.5 Ki 76.8 Ki/76.8 Ki
• IL language 21.5/29.2 Ki 10.4 Ki/10.4 Ki 25.8 Ki/25.8 Ki 56.7 Ki/56.7 Ki 73.9 Ki/73.9 Ki
• ST language 17.2/23.4 Ki 8.4 Ki/8.4 Ki 20.7 Ki/20.7 Ki 45.49 Ki/45.49Ki 76.0 Ki/76.0 Ki
Program
65% Boolean
• LD language 13.7/18.8 Ki 6.8 Ki/6.8 Ki 16.8 Ki/16.8 Ki 37.0 Ki/37.0 Ki 63.1 Ki/63.1 Ki
• IL language 14.1/19.2 Ki 6.9 Ki/6.9 Ki 17.2 Ki/17.2 Ki 37.9 Ki/37.9 Ki 61.4 Ki/61.4 Ki
• ST language 16.3/22.2 Ki 8.0 Ki/8.0 Ki 19.9 Ki/19.9 Ki 43.8 Ki/43.8 Ki 63.8 Ki/63.8 Ki
Constants (1) 256 words 256 words 256 words 1024 words 1024 words
K = Kwords Ki = Kinstructions
(1) Default size can be extended. However, this will adversely affect the size of the application program.
Notes :
• When this table gives 2 values for each characteristic separated by a "/", these values relate
respectively to the 2 types of processor (separated by a "/" in the table heading).
• The PLC/Memory Usage command in PL7 software provides the memory mapping of the
application in the PLC memory.
___________________________________________________________________________
1/34
A
PL7 general information 1

1.3-8 PMX57-35/45 and TSX 57-40/45 PLCs


These tables refer to PMX 57-35, PMX 57-45, TSX 57-40 and TSX 57-45 PLCs.

Size of the bit memory

Processor PMX 57 35/45 and TSX 57 40/45


Type system bits %Si 128
of objects I/O bits %I/Qx.i (1)
internal bits %Mi 12152
step bits %Xi 1024
(1) depends on the declared hardware cconfiguration (I/O module, devices on the AS-i bus and on the Fipio bus)
Size of the word memory

Processor PMX 57 35 / PMX 45 / TSX 57 40 and 45


Cartridge - 32K 64K 128K 256K
Internal memory 80K /96K / 96K 80K /96K / 96K 80K /96K / 96K 80K /96K / 96K 80K /96K / 96K
Data(%MWi) 1K(1) 30.5K 30.5K 30.5K 30.5K
Program
100% Boolean
• LD language 28.8/36.1/37.5 Ki 12.4 Ki 27.2 Ki 56.8 Ki 90.5 Ki
• IL language 36.7/46.1/47.8 Ki 15.8 Ki 34.7Ki 72.4 Ki 83.6 Ki
• ST language 24.5/30.7/31.9 Ki 10.5 Ki 23.1 Ki 48.2 Ki 74.6 Ki
Program
90% Boolean
• LD language 22.6/29.0/30.3 Ki 8.7 Ki 21.6 Ki 47.5 Ki 76.8 Ki
• IL language 27.1/34.7/36.1 Ki 10.4 Ki 25.8 Ki 56.7 Ki 73.9 Ki
• ST language 21.7 /27.8/29.0 Ki 8.4 Ki 20.7 Ki 45.49 Ki 76.0 Ki
Program
65% Boolean
• LD language 17.4/22.4/23.3 Ki 6.8 Ki 16.8 Ki 37.0 Ki 63.1 Ki
• IL language 17.8/22.9/23.9 Ki 6.9 Ki 17.2 Ki 37.9 Ki 61.4 Ki
• ST language 20.5 /26.5/27.6 Ki 8.0 Ki 19.9 Ki 43.8 Ki 63.8 Ki
Constants (1) 256 words 256 words 256 words 1024 words 1024 words
K = Kwords Ki = Kinstructions
(1) Default size can be extended. However, this will adversely affect the size of the application
program.
Notes :
• When this table gives several values for each characteristic separated by a "/", these values
relate respectively to each type of processor (separated by a "/" in the table heading).
• The PLC/Memory Usage command in PL7 software provides the memory mapping of the
application in the PLC memory.
___________________________________________________________________________
1/35
A

1.4 Operating modes

1.4-1 Processing on power outage and power return


When the power returns, the context saved is compared to the current one. This defines
the type of start to be performed :
• If the application context has changed (loss of the system context or new application),
the PLC initializes the application, that is, performs a cold start.
• If the application context is identical, the PLC performs a restart without data
initialization, that is, a warm restart.
If the period of the outage is shorter than the supply filter time (approximately 10 ms for
an AC power supply or 1 ms for a DC power supply), it is not seen by the program, which
is executed normally.

RUN
Application

Power failure

Await power

Power return

Outage Yes Save No


detected context OK

No Yes

Memory card No
identical

Yes

Normal program Warm Cold


execution restart start

Note :
A cold start can be activated :
• On return of power with loss of context (example : processor backup battery not operating).
• During the first execution of an application.
• By pressing the RESET button on the processor.
• By the program setting system bit %S0 to 1.
• Through initialization from PL7 by the terminal.
• When the PCMCIA memory card is inserted in its slot or when the handle is manipulated (except
on the PCX 57 PLC, where the PCMCIA card must not be inserted when powered up).
A warm restart can be activated :
• On return of power without loss of context.
• By the program setting system bit %S1 to 1.
• From PL7 by the terminal.

___________________________________________________________________________
1/36
A
PL7 general information 1

1.4-2 Processing on a warm restart

Read Stop processor


inputs Save application
context

Program execution
TOP
Power return

If %S1 = 1,
warm restart
processing possible
Configuration
self-tests

Power outage Yes


> micro-break
Set bit
No %S1 to 1
BOT

Set bit
%S1 to 0

Update
outputs

Restart program execution


Program execution restarts from the element at which power outage took place, without
updating outputs. The system then performs a restart cycle in which it takes into account
again all the input modules, relaunches the master task with bit %S1 set to 1 during one
scan of the task, and updates the outputs.
The system deactivates the fast and event-triggered tasks until the end of the first scan
of the master task.
Warm restart processing
In the event of warm restarts users who require a particular processing operation in
relation to the application must write the corresponding program by testing for %S1 at
1 at the beginning of the program of the master task.
Change in outputs
• As soon as a power outage is detected, the outputs are set to fallback state : either
set to fallback value or retain their current value, depending on the choice made
during configuration.
• On return of power, the outputs remain at zero until they are updated by the task.

___________________________________________________________________________
1/37
A

1.4-3 Processing on a cold start

Read
Stop processor
inputs
Save application
context

Program execution
TOP
Power return

If %S0 = 1,
process cold
restart Configuration
self-tests

Power outage Yes


> micro-break
No Initialization of
BOT the application

Set bit %S0 Set bit %S0


to 0 to 1

Update
outputs

Initialization of the data and the system, which corresponds to :


• Resetting the bits, the image of the I/O and the internal words (if the option to reset
internal words on a cold start is selected in the PLC Configuration screen, see section
1.3, part D). If the Reset option for %MW is not active and the %MWi are saved in the
Flash EPROM internal memory (TSX37), they are retrieved on a cold start.
• Initialization of system bits and words.
• Initialization of function blocks based on configuration data.
• The tasks, other than the master task, are deactivated until the end of the first scan
of the master task.
• Positioning of the Grafcet on the initial steps.
Cold start processing
To carry out an application processing operation after a cold start, bit %S10:X0 can be
tested by the program (if %S10:X0 = 1, there has been a cold start ). On a cold start, the
PLC either does or does not continue execution, depending on the choice defined
by the user during configuration (RUN AUTO parameter).
Change in outputs
• As soon as a power outage is detected, the outputs are set to fallback state. They are
either set to fallback value, or the current value is maintained, depending on the
choice made during configuration.
• On return of power, the outputs remain at zero until they are updated by the task.
___________________________________________________________________________
1/38
A
PL7 general information 1

1.5 Single task software structure


1.5-1 Presentation of the master task
The program of a single task application is associated with a single user task : the
master task, MAST.
The program associated with the master task is structured into a main processing
operation, made up of several sections and subroutines.

• Main processing (MAIN) divided into MAST


sections. Each section is programmed
as a separate entity in the appropriate Chamber(LD)
language (LD, IL, ST or Grafcet).
• Subroutine SRi (i=0 to 253) Oven_1(Grafcet)
The subroutine modules are also
programmed as separate entities in LD, PRL(LD)
IL or ST, with calls to subroutines being
CHART
performed during main processing or
from other subroutines (a maximum of 8 POST(IL)
subroutines can be nested).

Either cyclic or periodic execution of the Drying(LD)


master task can be chosen (during SR0
configuration). Cleaning(ST)

Function modules : see section 7


Presentation of a section
A section is characterized by :
• a name of 24 characters maximum,
• the language in which it is programmed,
• the task to which it belongs,
• an execution condition (optional). The
section is active if the condition is 1 and
inhibited if it is 0.
Objects authorized as conditions :
%M, %S, %X, indexed bit, extract bits, %I , %Q. All these objects can be forced from
the terminal except %S bits, indexed bits, extract bits, %I xy.i.ERR, and %I xy.MOD.ERR.
• a comment of 250 characters maximum.
• protection : write protection, read/write protection. Protection can be global or partial.

Note : when cold starting, execution conditions are at 0 and all the sections with which a condition
is associated are inhibited.

___________________________________________________________________________
1/39
A

A section is an autonomous entity. The


labels for identifying lines of instructions or
rungs are specific to the section (it is not Mast

possible to perform a program jump to Sections


another section). Chamber

Oven_1
Sections are executed in order of
Prl
programming, as they appear in the
browser window. Chart

Post
The master task in the example opposite
Drying
comprises :
• a section in ladder language LD, Cleaning
• a section in Grafcet,
• a section in Structured Text language SR
ST,
SR0
• a section in Instruction List language.
SR1

SR2

Grafcet section :
A Grafcet section comprises :
Pre-
• preprocessing (PRL) programmed in LD, processing
Subroutine
ST or IL. This is executed before the MAIN
SRi
Grafcet chart,
• the Grafcet chart (CHART) : transition
conditions associated with the transitions
and actions associated with the steps or Grafcet
CHART Transition conditions
macro-step steps are programmed in
page
the Grafcet pages, (8 pages) Actions
• post-processing (POST) programmed
in LD, ST or IL. This is executed after the Subroutine
SRi
Grafcet chart, Post-
• subroutines SRi (i = 0 to 253). Subroutine processing
POST Subroutine
modules are programmed separately, SRi
with calls to subroutines being made
during preprocessing or post-
processing, in the actions associated
with the steps or from other subroutines
(a maximum of 8 subroutines can be
nested).

___________________________________________________________________________
1/40
A
PL7 general information 1

1.5-2 Cyclic execution


This type of operation corresponds to normal execution of the PLC scan (default option).
It consists of consecutively linking the cycles of the master task (MAST). After updating
the outputs, the system performs its specific processing operations and then links to
another task scan.

Program Program
processing processing

%I %Q %I %Q
(1) (1)
I.P. I.P.

Scan n Scan n + 1

I.P. Internal processing : the system implicitly monitors the PLC (management of
system bits and words, updating current values of the realtime clock, updating
status indicator lamps, detection of RUN/STOP changes, etc) and processes
requests from the terminal (modifications and animation),
%I Read inputs : writes to memory the status of the information on the inputs of
discrete and application-specific modules associated with the task,
Program processing : execution of the application program, written by the user.
%Q Update outputs : writes output bits or words associated with discrete and
application-specific modules associated with the task depending on the status
defined by the application program.

Operating scan and scan monitoring


PLC in RUN : the processor performs, in
order, internal processing, reads the inputs,
Internal processing (1) processes the application program and
updates the outputs.

PLC in STOP : the processor performs


Read inputs • internal processing,
• reads the inputs,
RUN STOP • and depending on the configuration
chosen :
Program processing - fallback mode : the outputs are set to
"fallback" position,
- maintain mode : the outputs maintain
their current values.
Update outputs

Monitoring the scan time : the scan is


monitored by a watchdog. See section 1.5-4.
(1) In the case of the TSX/PMX/PCX 57, internal processing is carried out in parallel with I/O
processing.
___________________________________________________________________________
1/41
A

1.5-3 Periodic execution


In this operating mode, reading inputs, application program processing and updating
output is performed periodically according to a period of time defined during configuration
(from 1 to 255 ms).

At the start of the PLC scan, a timer, whose current value is initialized to the period
defined during configuration, starts to count down. The PLC scan must finish before
expiry of this timer, which then launches a new scan.

Program Program
processing processing
%I %Q %I %Q
(1) (1) (1) (1)
I.P. I.P. I.P. I.P.

Period Period

I.P. Internal processing : the system implicitly monitors the PLC (management of
system bits and words, updating current values of the realtime clock, updating
status indicator lamps, detection of RUN/STOP changes, etc) and processes
requests from the terminal (modifications and animation).
%I Read inputs : writes to memory the status of the information on the inputs of
discrete and application modules associated with the task.
Program processing : execution of the application program, written by the user.
%Q Update outputs : writes output bits or words associated with discrete and
application-specific modules, according to the status defined by the application
program.
(1) In the case of the TSX/PMX/PCX 57, internal processing is carried out in parallel with I/O
processing.

___________________________________________________________________________
1/42
A
PL7 general information 1

Operating scan and scan monitoring


PLC in RUN : the processor performs, in
order, internal processing, reads inputs,
Start of processes the application program and
period
updates outputs.
If the period is not yet over, the processor
completes its operating scan until the end
Internal processing (1) of the period, via internal processing.
If the operating time becomes longer than
that assigned to the period, the PLC
Read inputs
indicates a period overrun by setting system
bit %S19 of the task to 1, processing
RUN continues and is fully executed (it must
STOP
not, however, exceed the time limit of the
Program processing watchdog). The following scan is linked,
after implicit writing of the outputs in the
current scan.
PLC in STOP : the processor performs
Update outputs • internal processing,
• reads inputs,
• and depending on the configuration
chosen :
Internal processing (1)
- fallback mode : the outputs are set to
"fallback" position,
- maintain mode : the outputs maintain
their current values.
End of period
Scan monitoring :
2 controls are performed :
• period overrun,
• via the watchdog,
(see section 1.5-4).

(1) In the case of the TSX/PMX/PCX 57, internal processing is carried out in parallel with I/O
processing.

___________________________________________________________________________
1/43
A

1.5-4 Monitoring the scan time


Software watchdog (periodic or cyclic operation)
The execution time of the master task, whether in cyclic or periodic operation, is
controlled by the PLC (watchdog) and should not exceed the value Tmax defined during
configuration (250 ms default, 500 ms maximum).

In the event of an overrun, the application is declared faulty, which stops the PLC
immediately (on the TSX 37 the alarm output %Q2.0 is set to 0 if it has been configured,
on the TSX/PMX/PCX 57, the alarm relay on the supply is set to 0).

Bit %S11 is used to monitor execution of this task.

It indicates a watchdog overrun. It is set to 1 by the system when the scan time becomes
longer than the watchdog.

On the TSX/PMX/PCX 57, the watchdog value must be longer than the period.

In periodic operation, an additional control is used to detect period overrun :


• %S19 : indicates a period overrun. It is set to 1 by the system when the scan time
becomes longer than the task period.
• %SW0 : this word contains the value of the period (in ms). It is initialized on a cold start
by the value defined during configuration. It can be modified by the user.

Using the execution time of the master task


The following system words provide data on the scan time :
• %SW30 contains the execution time of the last scan.
• %SW31 contains the execution time of the longest scan.
• %SW32 contains the execution time of the shortest scan.

Note :
This data can also be accessed from the configuration editor if requested.

___________________________________________________________________________
1/44
A
PL7 general information 1

1.6 Multitask software structure


1.6-1 Description
The structure in tasks of such an application is as follows :
• The master task, MAST, which is always present and can be cyclic or periodic.
• The fast task, FAST, which is optional and always periodic.
• Event-triggered processing operations EVTi, called up by the system when an event
appears on an I/O module. This processing is optional and is used by applications
requiring short response times to perform operations on I/O.

Master Fast Event-triggered


task task tasks

- Priority +

Master and fast tasks are structured in sections (see the description of a section in
section 1.5).

Only the master task can include a Grafcet section.


Event-triggered tasks contain only one section the name of which cannot be modified.

MAST FAST

Chamber(LD) Alarm_Chamber(LD) EVT0

Oven_1(Grafcet) Monitor_Sec(LD)

PRL(LD)
Alarm_Oven(ST)
CHART

POST(IL) Alarm_Cleaning(ST) SR0

Drying(LD) SR0

Cleaning(ST)

Function modules : see section 7.


___________________________________________________________________________
1/45
A

Example of a multitask program structure

___________________________________________________________________________
1/46
A
PL7 general information 1

Management of tasks :
The master task is active by default. The fast task is active by default if it is programmed.
The event-triggered task is activated on appearance of the event with which it has been
associated.
If an event occurs, or at the start of the fast task scan, the task stops current execution
of lower priority tasks in order to execute its own processing. The interrupted task takes
over when processing of the priority task is completed.
The execution of fast and event-triggered tasks can be controlled by the program using
system bits :
• %S30 is used to activate or deactivate the master task, MAST.
• %S31 is used to activate or deactivate the fast task, FAST.
• %S38 is used to activate or deactivate event-triggered tasks, EVTi.

Example of multitask processing


• cyclic master task
• fast task with 20 ms period
• event-triggered task.

IPQ
Event
I PQ I PQ I PQ I PQ I PQ
Fast

Master I P P Q I P P Q I P

System
20 ms 20 ms 20 ms 20 ms

1.6-2 Master task


This task, which has the lowest priority, manages the majority of the application
program.
The MAST task is organized according to the model described in the previous section :
implicit reading of inputs, execution of the application program and implicit writing of
outputs.
Whether the operating mode is periodic or cyclic, the task is monitored by a watchdog
which is used to detect an abnormal duration of the application program. In the event
of an overrun, system bit %S11 is set to 1 and the application is declared as faulty, which
stops the PLC.
System bit %S30 enables or inhibits the master task.

___________________________________________________________________________
1/47
A

1.6-3 Fast task


This task, which is higher priority than the master task MAST, is periodic in order to leave
time for execution of the lower priority task.
In addition, the processing operations which are associated with it should therefore be
short, to avoid adversely affecting the master task. Like the master task, the associated
program consists of sections and subroutines.
The period of the fast task, FAST, is set during configuration, from 1 to 255 ms. This can
be defined as longer than that of the master task, MAST, in order to adapt it to periodic
processing operations which are slow but have higher priority. The program executed
should however remain short to avoid overrun of lower priority tasks.
The fast task is monitored by a watchdog which is used to detect an abnormal duration
of the application program. In the event of an overrun, system bit %S11 is set to 1 and
the application is declared as faulty, which stops the PLC.

Control of the fast task


System word %SW1 contains the value of the period. It is initialized on a cold start by
the value defined during configuration and can be modified by the user by program or
via the terminal.
System bits and words are used to monitor execution of this task :
• %S19 : indicates a period overrun. It is set to 1 by the system when the scan time
becomes longer than the task period.
• %S31 : is used to enable or inhibit the fast task. It is set to 0 by the system on a cold
start of the application, at the end of the first scan of the master task. It is set to 1 or
0 to enable or inhibit the fast task.

Display of the fast task execution times


The following system words provide data on scan times :
• %SW33 contains the execution time of the last scan.
• %SW34 contains the execution time of the longest scan.
• %SW35 contains the execution time of the shortest scan.

___________________________________________________________________________
1/48
A
PL7 general information 1

1.6-4 Assigning I/O channels to the master and fast tasks


In addition to the application program, the MAST and FAST tasks execute system
functions linked to the management of implicit I/O which are associated with them.
Associating a channel or a group of channels with a task is defined in the configuration
screen for the corresponding module. The default associated task is the MAST task.

Since the modularity of discrete modules is 8 consecutive channels (channels 0 to 7,


channels 8 to 15, etc), I/O can be assigned in groups of 8 channels, either to the MAST
or FAST task. For example, it is possible to assign the channels of a 28 I/O module in
the following way :
• Inputs 0 to 7 assigned to the MAST task.
• Inputs 8 to 15 assigned to the FAST task.
• Outputs 0 to 7 assigned to the MAST task.
• Outputs 8 to 11 assigned to the FAST task.

Each channel of a counter module can be assigned either to the MAST or FAST task.
For example, for a 2 channel counter module, it is possible to assign :
• channel 0 to the MAST task and,
• channel 1 to the FAST task.

The channels of TSX 37 analog input modules must be assigned to the MAST task.
However, it is possible to assign analog output channels to either the MAST or FAST
task, with 2 channel modularity. For example, for a module with 4 analog outputs, it is
possible to assign :
• channels 0 and 1 to the MAST task and,
• channels 2 and 3 to the FAST task.

The channels of TSX 57 analog I/O modules can be assigned to the MAST or FAST task.
Each channel of the isolated analog I/O modules (4 isolated channels) is assigned on
an individual basis. A 4-channel modularity is used for other modules.

___________________________________________________________________________
1/49
A

1.6-5 Event-triggered tasks


Event-triggered processing is used to reduce the response time of the software on
command events.

Command events
These are external events associated with applications. The appearance of such an
event diverts the application program to the processing operation associated with the
I/O channel which caused the event. The inputs (%I, %IW, %ID) associated with the I/O
channel which triggered the event are updated by the system before calling up event
processing. It is possible to configure :
• 8 events in a TSX 37-05/08/10 PLC (EVT1 to EVT8).
• 16 events in a TSX 37-21/22 PLC (EVT0 to EVT15).
• 32 events in a TSX/PMX/PCX 57-10 PLC (EVT0 to EVT31).
• 64 events in a TSX/PMX/PCX 57-20 PLC (EVT0 to EVT63).
The association between a channel and an event number is created in the channel
configuration screen.
On the TSX 37, event processing can be triggered by :
• Inputs 0 to 3 of module in position 1, on a rising or falling edge.
• The counter channel(s) of counter modules.
• The counter channels of module 1 (if this is configured as a counter).
• Reception of a telegram in a TSX 37-21/22 fitted with a TSX FPP20 module.
On the TSX/PMX/PCX 57, event processing can be triggered by :
• The inputs of DEY 16 FK, DMY 28 FK and DMY 28 RFK modules.
• The channels of counter modules.
• The channels of CAY axis control modules.
• The channels of CFY stepper motor control modules.
• Communication channels "FPP20".

Management of event-triggered tasks


Event-triggered processing can be globally enabled or inhibited by the application
program, using system bit %S38. If one or more events occur while they are inhibited,
the associated processing operations are lost.
Two PL7 language instructions MASKEVT() and UNMASKEVT(), used in the application
program, also allow masking or unmasking of event-triggered processing. If one or more
events occur while they are masked, they are saved by the system and the associated
processing will only be carried out after unmasking.
The 8 possible command events with a TSX 37-05/08/10 PLC all have the same level of
priority. Thus, one event processing operation cannot be interrupted by another. With
a TSX 37-21/22 or a TSX/PMX/PCX 57 PLC, there are 2 levels of priority for command
events : event 0 (EVT0) has higher priority than the other events.

___________________________________________________________________________
1/50
A
PL7 general information 1

I/O exchanges in event-triggered tasks


With each event-triggered task it is possible to use I/O channels other than those relating
to the event. Exchanges are then performed implicitly by the system before (%I) and
after (%Q) application processing. These exchanges can relate to a single channel
(example of counter module) or to a group of channels (discrete module). In the second
case, if the processing modifies, for example, outputs 2 and 3 of a discrete module, it
is the image of outputs 0 to 7 which will be transferred to the module.

Summary of exchanges and processing operations

IT Event The appearance of such an event diverts


processing
r

the application program towards the


(EVTi task) processing operation which is associated
with the I/O channel which caused the
event :

Implicit
reading of inputs • All the inputs associated with the channel
associated with which caused the event are read
the channel, origin automatically.
of the event

Implicit
reading of the • All the inputs declared by the user in
inputs declared task EVTi are read.
in task
EVTi

Event • Processing should be as short as


processing possible.

Implicit • All the outputs used by the user in task


update of the EVTi are updated. The outputs
outputs used associated with the channel which
in task caused the event should also be declared
EVTi so they can be updated.
Note :
In the case of TSX DEY16FK, TSX DMY28FK or TSX DMY28RFK discrete modules, the input
which triggered the event should not be tested in event processing (the value is not updated). The
test for the edge which triggered the event should be performed on the status word :
%IWxy.i:X0 = 1 --> rising edge
%IWxy.i:X1 = 1 --> falling edge

___________________________________________________________________________
1/51
A

Notes
On the TSX 37, analog input modules, which can only be used in the MAST task,
should not be exchanged in event processing.
The exchange of I/O, associated with the EVTi task and used by the program, is
performed channel by channel (for counter modules) or in groups of channels (for
discrete modules). For this reason, if processing modifies, for example, outputs
2 and 3 of a discrete module, it is the image of outputs 0 to 7 which will be transferred
to the module.
On the TSX 37, for each event-triggered processing operation, it is possible to
declare a maximum of exchanges for 2 input modules (before processing of the
event) and 2 output modules (after processing of the event).

The inputs exchanged (and the group of associated channels) during


event-triggered processing are updated (loss of log values and, consequently,
edges). Thus, edges should not be tested on these inputs in the master (MAST)
or fast (FAST) tasks.

On the TSX/PMX/PCX 57, depending on the processor used, the number of exchanges
used is limited :

No. of exchanges which can P57-1• (32 EVTs) P57-2•/3• (64 EVTs)
be used in EVTs by processor
Max. no. of discrete exchanges 32 exchanges 128 exchanges
Max. no. of analog exchanges 8 exchanges 16 exchanges
Max. no. of other application- 4 exchanges 16 exchanges
specific exchanges

For discrete I/O, an exchange involves a group of 8 channels. It is generated when the
inputs of a group of 8 channels are used (other than the group of channels which
generate the event) and when writing the outputs of a group of 8 channels.
For analog or other application-specific I/O, an exchange is generated when the inputs
of a channel are used (other than the channel which generates the event) and when
writing the outputs of a channel.

Display of the number of events processed


Word %SW48 shows the number of events processed. This word is initialized to 0 on
a cold start, then incremented by the system when an event is launched. This word can
be modified by the user.

%S39 indicates loss of event.


Note :
A summary of the operations to be performed to program events is given in part A, section 5.3
of the application-specific manual.
___________________________________________________________________________
1/52
A
LadderSection
language 22
2 Ladder language
2.1 Presentation of Ladder language
2.1-1 Principle
Programs written in Ladder language consist of a series of rungs which are executed
sequentially by the PLC.
A rung consists of a set of graphic elements bounded on the left and right by power rails.
They represent :
• The PLC I/O (pushbuttons, sensors, relays, indicator lamps, etc).
• Standard control system functions (timers, counters, etc).
• Arithmetic, logic and specific operations.
• The internal variables of the PLC.
The graphic elements are interconnected by horizontal and vertical links.
Each rung consists of a Ladder diagram EVT FAST MAST AUX

maximum of 16 lines and programming sheet MAIN SR PRE POST CHART

11 columns (for TSX/PMX/ %L


PCX 57 PLCs) or 7 lines %I1.0 %M12 %I3.7 %Q2.5
and 11 columns (for TSX
%TM4.Q %M17
37 PLCs) which are divided
into 2 zones :
%MW4<50
• The test zone which %I3.10 %Q4.3 %M27 %TM0 %M25 %MW0:X5
IN Q %MW15 : = %MW18+500
contains the conditions
TYP : TP
necessary to execute the TB : 100ms

actions. TM.P : 200


MODIF : Y

• The action zone which %I1.2 %I1.4 SR1


C
contains the actions to
be executed according
to the results of the test
zone.

___________________________________________________________________________
2/1
A

2.1-2 Graphic elements


Basic elements
They all occupy a single cell (1 line high, 1 column wide).
Designation Symbol Function

Test • Normally Contact closed when the bit object which


elements open contact controls it is at 1.
• Normally Contact closed when the bit object which
closed contact controls it is at 0.
• Edge P
Rising edge : contact closed when the bit
detection object which controls it changes from 0 to 1.
contacts
Falling edge : contact closed when the bit
N
object which controls it changes from 1 to 0.

Link • Horizontal Used to link test and action graphic elements


elements links between the two power rails in series.
• Vertical Used to link test and action graphic elements
links between the two power rails in parallel.
• Short-circuit Used to connect 2 objects using several
connections links.

Action • Direct Sets the associated bit object to the value of


elements coil the result of the test zone.
• Inverse Sets the associated bit object to the inverse
coil value of the result of the test zone.
• Set Sets the associated bit object to 1 when the
S
coil result of the test zone is at 1.
• Reset Resets the associated bit object to 0 when
R
coil the result of the test zone is at 1.
• Conditional ->> %Li Allows connection to a labeled rung, either
JUMP to upstream or downstream.
another rung Jumps are only effective within the same
programing entity (main program, subroutine,
etc).
If a jump is activated :
• Scanning of the current rung is interrupted.
• The requested labelled rung is executed.
• The part of the program between the jump
action and the designated rung is not
executed.
• Transition Offered in Grafcet language, used when
condition # programming conditions associated with
coil transitions, to move to the next step.

___________________________________________________________________________
2/2
A
Ladder language 2

Designation Symbol Function

Action • Subroutine Allows connection at the beginning of


C
elements call coil subroutines when the result of the test zone
(continued) (CALL) is at 1.
If a subroutine is called :
• Scanning of the current rung is interrupted.
• The subroutine is executed.
• Scanning of the interrupted rung is resumed.
• Subroutine Reserved for subroutines SR, allows return
return <RETURN> to the calling module when the result of the
test zone is at 1.
• Stop Stops execution of the program when the
<HALT>
program result of the test zone is at 1.

Standard function blocks

Designation Symbol Function

Test • Blocks : Each of the standard function blocks uses


elements Timer I/O which allow them to be linked to other
Counter graphic elements.
Monostable The functions of each block are described in
Register part B.
Drum controller Size : see section 2.2-5.

DFBs

Designation Symbol Function

Test • Programmable Each DFB uses inputs, outputs and I/O which
elements blocks can be used to link them to other graphic
elements for bit type objects or which can be
assigned to numeric objects or tables.

The functions of the DFB are described in


section 6.
Dimensions : see section 2.2-5

DFBs cannot be used on TSX37 PLCs.

___________________________________________________________________________
2/3
A

Operation blocks

Designation Symbol Function

Test • Vertical Allows comparison of 2 operands. Depending


elements comparison on the result, the corresponding output
block changes to 1.

Size : 2 columns/4 lines.


• Horizontal Allows comparison of 2 operands. The output
comparison changes to 1 when the result is checked.
block (A block can contain up to 4096 characters).
Size : 2 columns/1 line.

Action • Operation Performs arithmetic, logic operations etc and


elements block uses Structured text language syntax.
(A block can contain up to 4096 characters).
Size : 4 columns/1 line.

___________________________________________________________________________
2/4
A
Ladder language 2

2.2 Structure of a rung


2.2-1 General
A rung is located between two power rails and consists of a set of graphic elements
which are interconnected by horizontal or vertical links.
A rung contains up to 16 lines and 11 columns (for TSX/PMX/PCX 57 PLCs) or up to
7 lines and 11 columns (for TSX 37 PLCs) divided into two zones, the test zone and
the action zone.

Columns 1 2 3 4 5 6 7 8 9 10 11
Ladder diagram EVT FAST MAST AUX

programming sheet MAIN SR PRE POST CHART

%L
Lines
1

6
7
Power
8 rails
9

10

11

12

13

14

15

16

Test zone
Action zone
___________________________________________________________________________
2/5
A

2.2-2 Labels
Labels are used to identify a rung within a program entity (main program, subroutine,
etc), but are not compulsory.
Labels take the syntax %Li (i being 0 to 999) and are located at the top left before the
power rail.
Each label can only be
assigned to one rung within %M20 %L245

the same program entity.

However, a rung must be % L2 4 5


labelled to allow
%M3 %I1.6 %MW1:X2 %Q2.1
connection after a program
jump. %TM4.D

The system scans the rungs in the order in which they were entered, irrespective of the
order of the label numbers.

2.2-3 Comments
The comment is integrated into the rung and contains up to 222 alphanumeric
characters, framed at either end by the characters (* and *). It facilitates interpretation
of the rung to which it is assigned, but is not compulsory.

Comment zone
Comments are displayed in %L
the reserved zone in the %Q2.3 %I1.4 %MW2:X9 %I1.3 %Q4.7
upper part of the rung.
%M16 %M12 %TM3.Q SR4
If a rung is deleted, the C
%C8.E
comment associated with
it is also deleted. %Q2.0 %MW3:X0 %M3 %I5.2 %M155
S
%I1.3 %I3.1 %M13 %Q4.7

Comments are stored in the PLC and can be accessed at all times by the user. They
therefore use program memory.

___________________________________________________________________________
2/6
A
Ladder language 2

2.2-4 Rungs
The representation of a rung is similar to that of a relay diagram.
Simple test and action graphic elements each occupy a single line and column within
a rung.
All lines of contacts start on
%L
the left power rail and must
%Q2.3 %I1.4 %MW2:X9 %I1.3 %Q4.7
finish on the right power
rail. %M16 %M12 %TM3.Q SR4
C
Tests are always located %C8.E

on columns 1 to 10. %Q2.0 %MW3:X0 %M3 %I5.2 %M155


Actions are always located S
%I1.3 %I3.1 %M13 %Q4.7
on column 11.

The direction of current is


the following : %L

%M16 %T3.D
• for horizontal links, from
left to right, %I5.4
• for vertical links, in both
%C13.E
directions.

Test zone
This zone contains :
%L
• contacts, to which all the
%M9 %MN0 %I6.8 %C2.D
bit objects defined above S R
can be assigned, TB : 100ms %MW8:X4

• function blocks, MN.P : 80

• comparison blocks.

Rising and falling edges


can only be associated with %Q2.6 %M85

I/O bit objects and internal %S6


bits.

___________________________________________________________________________
2/7
A

Action zone
%L
This zone contains :
%M52
• direct, inverse, set and
reset coils, which can be %MW8:X1 %MW8:X10
/
assigned to any bit ob- %M8 %Q6.5
ject which can be written S
%M12
by the user. R
• operation blocks.
%MW2 := %MW0+1
• the other "coils" :
Call, Jump, Halt, Return.

Simple rungs
Control of a coil conditioned %I1.3 %Q4.12

by the state of a contact.

Use of up to 10 contacts in %M1 %I3.2 %MW18:X4 %Q4.2 %M15 %TM2.Q %I3.4 %MW1:X5 %M5 %C0.D %Q6.3
series on one line. /

A maximum of 16 contacts %L
(7 contacts for TSX 37) can
%M5 %Q6.2
be tested in parallel on one
column, and 16 coils (7 %I6.9 %M25

coils for TSX 37) placed in %MW15:X5 %MW8:X0


parallel. /
%C6.E SR9
C
%Q5.2 %L20

%I3.7 %M12
R
%S4 %Q2.6
S
%M8 %M30

%M9 %M31

%M10 %M32
/
%M11 %M33
C
%M12 %M34

%M13 %M35
R
%M14 %M36
S
%M15 %M37

%M16 %M38

___________________________________________________________________________
2/8
A
Ladder language 2

Rung using several lines of contacts

A rung can be divided into %L


several independent lines %L12
%I3.2 %MW6:X10 %M88
of contacts controlling
independent coils. %C2.E SRØ
C
%S4 %Q3.2

%I6.5 %Q3.3
16 independent lines of P /
contacts (7 lines for %M53 %MW3:X6

TSX 37). %MW8:X4 %M27

%M12 %M68
S
%M8 %M30
C
%M9 %M31

%M10 %M32
P /
%M11 %M33

%M12 %M34

%M13 %M35
S
%M14 %M36
C
%M15 %M37

%M16 %M38
P /

Rungs using the various


%L
principles which have been
described.
A C F

Symbols at logic state 1 are


B D
circled. The current can
pass from symbols A and C E G

to coil F. It cannot pass from


symbol C to symbols D and
E. Coil G is therefore not
activated.

___________________________________________________________________________
2/9
A

2.2-5 Rungs with function and operation blocks

• Function blocks are located in the test zone and are inserted in a rung.

%C4

Up/down counter 2 columns


"Vertical" comparison block 4 lines

%TM10
Timers 2 columns
Monostable 3 lines
Register
Drum controller

COMPARE
"Horizontal" comparison block 2 columns
1 line

Note :

Non-wired inputs for standard function blocks are set to 0.

___________________________________________________________________________
2/10
A
Ladder language 2

• Operation blocks are always located in the action zone. They are 1 line deep and 4
columns wide, are written in Structured Text language and are always directly linked
to the right power rail.

%MW10:X5
%MW22 : = %MW1+%MW9

• DFBs are located in the test zone and are inserted in a rung.
The size of the graphic depends on the number of inputs, outputs and I/O used :

The width is fixed, and is equal to 3 columns.

The height is the larger of the following two numbers, DFB


plus 1 :

• number of inputs and I/O


or
• number of outputs and I/O

Example :
The number of inputs and I/O is 4, the number of
outputs and I/O is 3, so the height of the block is 4+1=
5 columns.

The maximum height of a DFB is 16 lines.

Notes :
• A DFB must have at least one wired Boolean input.
• The digital inputs, outputs or I/O of the block are not
wired. The objects mentioned on the cell opposite
the pin are associated with these pins.
• Non-wired DFB inputs retain the value which
preceded the call or the initialization value if the
block has never been called with this input available
or wired.

___________________________________________________________________________
2/11
A

Function blocks can be "cascaded"


Like the contact type graphic elements, it is possible to combine function blocks.
Connecting function blocks in series :

%L

%I3.6 %MN1 %TM12 %Q6.3


S R IN Q
TB : 100ms TYP : TP
TB : 100ms
MN.P : 80 TM.P : 200
MODIF : Y

Function blocks and operation blocks can be mixed

%L

%I1.5 %TM10 %M28


%MW1>100 IN Q
%I1.2 TYP : TP
%MW2>500 TB : 1s %TM2.P := 3450
TM.P : 50
MODIF : Y

Others possible uses of function blocks


Irrespective of the type of function block used, its input must be linked to the left power
rail, either directly or via other graphic elements.
• Outputs left open : it is not necessary to link the outputs of function blocks to other
graphic elements.
• Testable outputs : the outputs of function blocks are accessible to the user in the form
of bit objects :

%TM12.Q %C5.E %Q4.12

Internal variables of blocks and graphic outputs can be used remotely from another part
of the program.

___________________________________________________________________________
2/12
A
Ladder language 2

2.3 Rules for executing rungs


2.3-1 Principle for executing a rung
Rungs are executed rung by rung, and each rung is executed from left to right.
A rung contains graphic elements which are interconnected by horizontal and vertical
links (apart from the power rail), but are independent from other graphic elements in
the rung (no vertical links to the top or bottom edges of the rung).

%M0 %M8 %Q2.5

%I2.5 %TM1
Rung 1
IN Q

Rung 2

%MØ %Q2.6

INIT %MØ

Rung 3

The rung in the top left-hand corner is the first rung to be evaluated.
A rung is evaluated following the direction of the equation : evaluation of the rung from
top to bottom, line by line, and in each line from left to right.
In cases where a vertical convergence link is found, the sub-rung associated with it is
evaluated (following the same logic) before continuing evaluation of the rung in which
it is included.
Following this order of execution, the system :
• Evaluates the logic state of each contact, according to the current value of the internal
objects of the application or of the state of the inputs of the I/O modules read at the
beginning of the scan.
• Executes the processing operations associated with the functions, function blocks
and subroutines.
• Updates the bit objects associated with coils, (outputs of I/O modules are updated
at the end of the scan).
• Goes to another labeled rung in the same program module (jumps to another rung
->>%Li), returns to the calling module <RETURN>, or stops the program <HALT>.
Note :
A rung must not contain nested rungs.

___________________________________________________________________________
2/13
A

Elements in this rung are executed in the following order :

• evaluation of the rung


%L
until the 1 st vertical
convergence link is A B C E H

found, contacts A, B and D


C,
F G
• evaluation of the 1 st
sub-rung, contact D,
• continued evaluation of
the rung until the 2 nd
vertical convergence link
is found, contact E,
• evaluation of the 2 nd
sub-rung, contacts F and
G,
• evaluation of coil H.

Example of a "Boolean" %L
rung
INIT %M7 %Q2.1
Order of evaluation :
%M5 %M4 UP_1
• coil 1 : INIT, %M5, %M7,
%Q2.1, %MW2:X1 INIT DOWN_1
• coil 2 : %M4, %MW2:X1,
AUTO
AUTO, UP_1,
• coil 3 : INIT, DOWN_1.

Example of a rung
%L
containing blocks
%MØ %M8 %Q2.9
Order of evaluation :
• coil 1 : %M0, %M8, %M2, %M2 %T1
E D
%T1, %Q2.9, %M9
• coil 2 : %T1.R, %T2, %M9, C R

• operation block.
%T1.D %T2
E D

C R %MW10 := %MW1+50

___________________________________________________________________________
2/14
A
Section 33
Instruction List language
3 Instruction List language
3.1 Presentation of Instruction List language
3.1-1 Principle
A program written in Instruction List language is composed of a series of instructions
executed sequentially by the PLC.

Example of an instruction : LD %I1.0

Instruction code Operand


Each instruction is composed of an instruction code and an operand.
These instructions act on :
• The I/O of the PLC (pushbuttons, detectors, relays, indicator lights etc).
• Standard control system functions (timers, counters etc).
• Arithmetic and logic operations and transfer operations.
• The internal variables of the PLC.
There are two types of instruction :
• Test instructions which contain the conditions necessary to execute an action,
eg : LD, AND, OR etc.
• Action instructions which validate the result following a test sequence,
eg : ST, STN, R, etc.

___________________________________________________________________________
3/1
A

3.1-2 Instructions
Basic instructions
(For further information on each instruction, see part B).
Designation Instructions Equivalent functions

Test • LD, LDN, LDR, LDF P N


instructions

• AND, ANDN,
ANDR, ANDF
P N

• OR, ORN, ORR, ORF


P N

• AND(, OR(
(8 levels of parentheses)

• XOR, XORN, XORR, XORF exclusive OR

• MPS
MRD
MPP

•N Negation

Action • ST, STN, S, R R


S
instructions
• JMP, JMPC, JMPCN Used to jump (unconditional, conditional
on a Boolean result at 1 or conditional on a Boolean
result at 0) to a labeled instruction, either upstream
or downstream.
• SRn Used to jump to the beginning of a subroutine.
RET, RETC, RETCN Subroutine return (unconditional,
conditional on a Boolean result at 1 or conditional
on a Boolean result at 0).
• END, ENDC, ENDCN End of program (unconditional, conditional on
a Boolean result at 1 or conditional on a Boolean
result at 0).
HALT Execution of the program is stopped.

___________________________________________________________________________
3/2
A
Instruction List language 3

Instructions on function blocks (see part B, section 1.3)


Designation Instructions Functions
Test • Blocks : There are instructions for controlling each of the
elements Timer standard function blocks. A structured form is
Counter used to directly "wire" the I/O of the function blocks.
Monostable
Register
Drum controller

Numeric instructions (see part B)

Designation Instructions Functions


Test • LD[.....] Used to compare two operands (see part B,
elements AND[.....] section 1.4-2). The output changes to 1 when
OR[.....] the result is checked.

Example :
LD[%MW10<1000] Result at 1 when %MW10<1000.
Action • [.......] Perform arithmetic, logic operations etc.
elements Use Structured Text language syntax (see part B).
Example :
[%MW10:=%MW0+100] The result of the operation %MW0+100 is placed
in internal word %MW10.

___________________________________________________________________________
3/3
A

3.2 Program structure


3.2-1 General
Like Ladder language, instructions are organized into sequences of instructions
(equivalent to a rung), called a sequence. Each sequence is composed of one or more
test instructions. The result of these instructions is applied to one or more action
instructions.
An instruction occupies up to one line.
Each sequence starts with an exclamation mark (generated automatically). It can
include a comment and be identified by a label.
! (*Waiting for drying*)
%L2:
LD %I0.1
AND %M10
ST %Q2.5

3.2-2 Comments
Comments can be integrated at the beginning of a sequence and can occupy up to 3
lines (ie. 222 alphanumeric characters), framed at either end by the characters(* and *).
They facilitate interpretation of the sequence to which they are assigned but are not
compulsory.
Comments are displayed only from the first line of the sequence.
If a sequence is deleted, its associated comment is also deleted.
Comments are stored in the PLC and can be accessed at all times by the user. They
therefore use program memory.

3.2-3 Labels
Labels are used to identify a sequence in a program entity (main program, subroutine,
etc) but are not compulsory.
Labels take the syntax %Li (where i is 0 to 999) and are located at the beginning of a
sequence.
A label can only be assigned to a single sequence within the same program entity.
However, a sequence must be labeled to achieve a connection following a program
jump.
The system scans the sequences in the order in which they were entered, irrespective
of the order of the label numbers.

___________________________________________________________________________
3/4
A
Instruction List language 3

3.2-4 Using parentheses


It is possible to use parentheses with the instructions AND and OR. These parentheses
are used for simple creation of Ladder diagrams. An opening parenthesis is associated
with the instruction AND or OR. A closing parenthesis represents an instruction and is
compulsory for each opening parenthesis.
Example : AND(

LD %I1.0
AND %I1.1
OR %I1.2
ST %Q2.0

LD %l1.0
AND( %I1.1
OR %l1.2
)
ST %Q2.0

Example : OR(
%I1.0 %I1.1 %Q2.0
LD %I1.0
AND %I1.1
%I1.2 %I1.3 OR(N %I1.2
AND %I1.3
)
ST %Q2.0

The following modifiers can be associated with parentheses :


• N negation, eg : AND(N or OR(N
• F Falling edge, eg : AND(F or OR(F
• R Rising edge, eg : AND (R or OR (R
• [ comparison

%I1.0 %I1.1 %Q2.0 LD %I1.0


AND %I1.1
%I1.3 OR( [%MW0>100]
%MW0>100 AND %I1.3
)
ST %Q2.0

___________________________________________________________________________
3/5
A

Nesting parentheses
Up to eight levels of parentheses can be nested.
Example

%Q2.0 LD %I1.0
%I1.0 %I1.1
AND( %I1.1
OR(N %I1.2
%I1.2 %M3 AND %M3
)
)
ST %Q2.0

Example

%I1.1 %I1.2 %I1.3 %I1.4 %Q2.0 LD %I1.1


AND( %I1.2
AND %I1.3
%I1.5 %I1.6 OR(N %I1.5
AND %I1.6
%I1.7 %I1.8 )
AND %I1.4
OR(N %I1.7
AND %I1.8
)
)
ST %Q2.0

Note :
• Each opening parenthesis must be followed by a closing parenthesis.
• The labels %Li: must not be placed in expressions between parentheses. This also applies to jump
instructions, JMP, and call subroutine instructions, SRi.
• Assignment instructions, ST, STN, S and R must not be programmed between parentheses.

___________________________________________________________________________
3/6
A
Instruction List language 3

3.2-5 MPS, MRD and MPP instructions


These three types of instruction are used to process the routing to the coils.
They use a buffer known as a stack which is capable of storing up to 3 Boolean data bits.
The instruction MPS (Memory PuSh) stores the result of the last test instruction at the
top of the stack and shifts the other values towards the bottom of the stack.
The instruction MRD (Memory ReaD) reads the top of the stack.
The instruction MPP (Memory PoP) reads and retrieves the top of the stack, and shifts
the other values towards the top of the stack.

Examples :

%I1.0 %M0 %I1.1 %Q2.0 LD %I1.0


AND %M0
MPS
MPS %I1.2 %Q2.1 AND %I1.1
ST %Q2.0
MRD
MRD %I1.3 %Q2.2 AND %I1.2
ST %Q2.1
MRD
MPP %I1.4 %Q2.3
AND %I1.3
ST %Q2.2
MPP
AND %I1.4
ST %Q2.3

%I1.0 %I1.1 %I1.3 %Q2.0



LD %I1.0

MPS

%M0 AND %I1.1


MPS
AND( %I1.3
%M1 %Q2.1 OR %M0
)

ST %Q2.0
%I1.4 %Q2.2 MPP

AND %M1
ST %Q2.1
%M10 %Q2.3 MRD

AND %I1.4

ST %Q2.2
MPP

AND %M10
ST %Q2.3

Note :
These instructions cannot be used in an expression between parentheses.
___________________________________________________________________________
3/7
A

3.2-6 Principles for programming predefined function blocks


Control system function blocks can be %CI
programmed in two different ways : R E
• with instructions specific to each function
block (eg : CU %Ci). This is the simplest S
and most direct way. C.P : 9999 D
CU
• with block structure instructions MODIF : Y
BLK,OUT_BLK and END_BLK. CD F

Up/down counter block

Principle of direct programming

%I1.1 %C8
LD %I1.1
R E
R %C8
S %Q2.0 LDN %I1.2
%I1.2 %M0 C.P : 9999 D ANDN %M0
CU
MODIF : Y CU %C8
CD F LD %C8.D
ST %Q2.0

The instructions control the inputs of the blocks (eg : CU).


The outputs can be accessed in the form of bits (eg : %C8.D).
Principle of structured programming
This type of programming uses a sequence of instructions framed by the following
instructions :
• BLK indicates the start of the block.
• OUT_BLK is used to directly wire the outputs of the block.
• END_BLK indicates the end of the block.

%I1.1 %C8 BLK %C8


R E LD %I1.1 Input
R
S %Q2.0 processing
%I1.2 %M0 C.P : 9999 D
LDN %I1.2
CU ANDN %M0
MODIF : Y CU
CD F OUT_BLK
LD D Output
ST %Q2.0 processing
END_BLK

Structured programming requires the additional instructions BLK, OUT_BLK and


END_BLK, and therefore needs more memory compared with direct programming.
It should, however, be used if similarity with reversible programs for TSX 07 nano PLCs
is required.
___________________________________________________________________________
3/8
A
Instruction List language 3

3.3 Rules for executing Instruction List programs


Instruction list programs are executed sequentially instruction by instruction.
The first instruction in a series of instructions must always be either an LD instruction
or an unconditional instruction (eg : JMP).
All instructions (except LD and the unconditional instructions) use the Boolean result of
the preceding instruction.
Example :
LD %I1.1 Boolean result = state of bit %I1.1.
AND %M0 Boolean result = AND of the preceding Boolean result and the state of
bit %M0.
OR %M10 Boolean result = OR of the preceding Boolean result and the state of
bit %M10.
ST %Q2.0 %Q2.0 takes the state of the preceding Boolean result.
Parentheses can be used to modify the order in which Boolean results are taken into account :
Example :
LD %I1.1 Boolean result = state of bit %I1.1.
AND %M0 Boolean result = AND of the preceding Boolean result and the state of bit
%M0.
OR( %M10 Boolean result = state of bit %M10.
AND %I1.2 Boolean result = AND of the preceding Boolean result and the state of bit
%I1.2.
) Boolean result = OR of the preceding Boolean result and of the
Boolean result of the instruction located before the instruction with
parentheses.
ST %Q2.0 %Q2.0 takes the state of the preceding Boolean result.
Sequencing of instructions can be modified by the jump (JMP) and call subroutine
instructions.

Example :
! LD %M0
JMPC %L10
! LD %I1.1
AND %M10 Jump to label %L10 if %M0=1
ST %Q2.0
! %L10 :
LD %I1.3
AND %M20
.........

___________________________________________________________________________
3/9
A

___________________________________________________________________________
3/10
A
Section 4
Structured Text language 4
4 Structured Text language
4.1 Presentation of Structured Text language
4.1-1 Principle
Structured Text language is used to create programs by writing programming lines made
up of alphanumeric characters.
This language can only be used by PL7 Junior and PL7 Pro software on
TSX/PMX/PCX 57 PLCs. In the PL7 Pro version, this language can be used to create DFB
user function blocks.
The ST statement constitutes the basic unit of Structured Text language, and a series of
statements is used to define a program.
The main instructions in Structured Text language are as follows :
• bit instructions,
• arithmetic and logic instructions on words and double words,
• arithmetic instructions on floating points,
• numerical comparisons on words, double words and floating points,
• numerical conversions,
• instructions on bit, word, double word and floating point tables,
• character string instructions,
• alphanumerical comparisons,
• time management instructions,
• program instructions,
• control instructions,
• standard function block instructions,
• explicit exchange instructions,
• application-specific instructions (communication, process control, etc).
Example :

___________________________________________________________________________
4/1
A

4.1-2 Instructions
Bit instructions

Description Function
:= Bit assignment
OR Boolean OR
AND Boolean AND
XOR Exclusive Boolean OR
NOT Inversion
RE Rising edge
FE Falling edge
SET Set to 1
RESET Reset to 0

Numerical comparisons on words, double words and floating points

Description Function
< Strictly less than
> Strictly greater than
<= Less than or equal to
>= Greater than or equal to
= Equal to
<> Different from

Bit tables

Description Function

Table := Table Assignment between two tables


Table := Word Assignment of a word to a table
Word := Table Assignment of a table to a word
Table := Double word Assignment of a double word to a table
Double word := Table Assignment of a table to a double word
COPY_BIT Copy a bit table to a bit table
AND_ARX AND between two tables
OR_ARX OR between two tables
XOR_ARX Exclusive OR between two tables
NOT_ARX Negation on a table
BIT_W Copy a bit table to a word table
BIT_D Copy a bit table to a double word table
W_BIT Copy a word table to a bit table
D_BIT Copy a double word table to a bit table
LENGTH_ARX Calculate the length of a table in number of elements

___________________________________________________________________________
4/2
A
Structured Text language 4

Integer arithmetic on words and double words


Description Function

+, -, *, / Addition, Subtraction, Multiplication, Division of an integer


REM Remainder of the integer division
SQRT Integer square root
ABS Absolute value
INC Incrementation
DEC Decrementation

Arithmetic on floating point values


Description Function
+, -, *, / Addition, Subtraction, Multiplication, Division
SQRT Square root
ABS Absolute value
TRUNC Part of integer
LOG Base 10 logarithm
LN Natural logarithm
EXP Natural exponential
EXPT Exponentiation of a real by an integer
COS Cosine of a value in radians
SIN Sine of a value in radians
TAN Tangent of a value in radians
ACOS Arc cosine (result between 0 and 2 π)
ASIN Arc sine (result between -π/2 and +π/2)
ATAN Arc tangent (result between -π/2 and +π/2)
DEG_TO_RAD Conversion of degrees into radians
RAD_TO_DEG Conversion of radians into degrees
Logic instructions on words and double words
Description Function
AND Logic AND
OR Logic OR
XOR Exclusive logic OR
NOT Logic complement
SHL Logic shift to left
SHR Logic shift to right
ROL Logic circular shift to left
ROR Logic circular shift to right

Program instructions
Description Function
HALT Stop program execution
JUMP Jump to a label
SRi Call subroutine
RETURN Return from subroutine
MASKEVT Mask events in the PLC
UNMASKEVT Unmask events in the PLC

___________________________________________________________________________
4/3
A

Numerical conversion instructions


Description Function
BCD_TO_INT BCD → Binary conversion
INT_TO_BCD Binary → BCD conversion
GRAY_TO_INT Gray → Binary conversion
INT_TO_REAL Conversion of a single format integer into a floating point value
DINT_TO_REAL Conversion of a double format integer into a floating point value
REAL_TO_INT Conversion of a floating point value into a single format integer
REAL_TO_DINT Conversion of a floating point value into a double format integer
DBCD_TO_DINT Conversion of 32-bit BCD number into 32-bit integer
DINT_TO_DBCD Conversion of 32-bit integer into 32-bit BCD number
DBCD_TO_INT Conversion of 32-bit BCD number into 16-bit integer
INT_TO_DBCD Conversion of 16-bit integer into 32-bit BCD number
LW Extraction of the least significant word from a double word
HW Extraction of the most significant word from a double word
CONCATW Concatenate 2 single words

Instructions on word and double word tables

Description Function
Table := Table Assignment between two tables
Table := Word Initialize a table
+, -, *, /, REM Arithmetic operations between tables
+, -, *, /, REM Arithmetic operations between expressions and tables
SUM Sum of the elements of a table
EQUAL Comparison of two tables
NOT Logic complement of a table
AND, OR, XOR Logic operations between two tables
AND, OR, XOR Logic operations between expressions and tables
FIND_EQW, FIND_EQD Find first element equal to a value
FIND_GTW, FIND_GTD Find first element greater than a value
FIND_LTW, FIND_LTD Find first element less than a value
MAX_ARW, MAX_ARD Find maximum value in a table
MIN_ARW, MIN_ARD Find minimum value in a table
OCCUR_ARW, OCCUR_ARD Number of occurrences of a value in a table
SORT_ARW, SORT_ARD Sort a table in ascending or descending order
ROL_ARW, ROL_ARD Circular shift left in a table
ROR_ARW, ROR_ARD Circular shift right in a table
FIND_EQWP,FIND_EQDP Find first element equal to a value from a particular row
LENGTH_ARW, LENGTH_ARD Calculate the length of a table

___________________________________________________________________________
4/4
A
Structured Text language 4

Instructions on floating point tables

Description Function
Table := Table Assignment between two tables
Table := Floating point Initialize a table
SUM_ARR Sum of the elements in a table
EQUAL_ARR Comparison of two tables
FIND_EQR Find first element equal to a value
FIND_GTR Find first element greater than a value
FIND_LTR Find first element less than a value
MAX_ARR Find maximum value in a table
MIN_ARR Find minimum value in a table
OCCUR_ARR Number of occurrences of a value in a table
SORT_ARR Sort a table in ascending or descending order
ROL_ARR Circular shift left in a table
ROR_ARR Circular shift right in a table
LENGTH_ARR Calculate the length of a table

Instruction on character strings

Description Function
STRING_TO_INT ASCII → Binary (single word format) conversion
STRING_TO_DINT ASCII → Binary (double word format) conversion
INT_TO_STRING Binary (single word format) → ASCII conversion
DINT_TO_STRING Binary (double word format) → ASCII conversion
STRING_TO_REAL ASCII → Floating point conversion
REAL_TO_STRING Floating point → ASCII conversion
<, >, <=, >=, =, <> Alphanumeric comparison
FIND Position of a substring
EQUAL_STR Position of first different character
LEN Length of a character string
MID Extract a substring
INSERT Insert a substring
DELETE Delete a substring
CONCAT Concatenate two strings
REPLACE Replace a string
LEFT Start of string
RIGHT End of string

___________________________________________________________________________
4/5
A

Time management instructions


Description Function
SCHEDULE Real-time clock function
RRTC Read system date
WRTC Update system date
PTC Read date and stop code
ADD_TOD Add a time period to a time of day
ADD_DT Add a time period to a date and time
DELTA_TOD Measure deviation between times of day
DELTA_D Measure deviation between dates (without time)
DELTA_DT Measure deviation between dates (with time)
SUB_TOD Subtract a time period from a time of day
SUB_DT Subtract a time period from a date and time
DAY_OF_WEEK Read current day of week
TRANS_TIME Convert duration to date
DATE_TO_STRING Convert date to character string
TOD_TO_STRING Convert time to character string
DT_TO_STRING Convert complete date to character string
TIME_TO_STRING Convert duration to character string

"Orphee" instructions
Description Function
WSHL_RBIT, DSHL_RBIT Shift word to left, with retrieval of shifted bits
WSHR_RBIT, DSHR_RBIT Shift word to right with sign extension and retrieval of
shifted bits
WSHRZ_C, DSHRZ_C Shift word to right, replacing with 0, with retrieval of
shifted bits
SCOUNT Up/down counting with indication of under/overflow
ROLW,ROLD Circular shift left
RORW,RORD Circular shift right

Time delay instructions


Description Function
FTON On-delay
FTOF Off-delay
FTP Pulse time delay
FPULSOR Square wave signal generator

All these functions and instructions are described in part B of this reference manual, as well
as instructions relating to standard function blocks.
Instructions and functions relating to explicit exchanges and the various applications are
described in the "Application-specific functions installation manual".
The control structures are described in section 4.2.-5 of this part.

___________________________________________________________________________
4/6
A
Structured Text language 4

4.2 Program structure


4.2-1 General
A Structured Text program is organized into statements. Each ST statement consists
of the following elements :
• label,
• comments,
• instructions.
Each of these elements is optional, ie. it is possible to have an empty statement, a
statement consisting only of comments or consisting only of a label. Each statement
begins with an exclamation mark (which is generated automatically).
Example :
! %L2 : (* Here is a statement with a label, comments *)
SET %M0; %MW4 := %MW2 + %MW9;
(* and several instructions *)
%MF12 := SQRT (%MF14);

4.2-2 Comment
A comment is enclosed at either end by the characters (* and *), it can be placed at any
point in a statement and there is no restriction on the number of comments per
statement. Its role is to facilitate the interpretation of the statement to which it is assigned,
but it is not compulsory.
• Any characters can be used in a comment.
• The number of characters is restricted to 256 per comment.
• Nested comments are not permitted.
• A comment may be several lines in length.
Comments are stored in the PLC and can be accessed at any moment by the user.
Because of this, they consume program memory.

___________________________________________________________________________
4/7
A

4.2-3 Label
A label is used to reference a statement in a program entity (main program, subroutine,
etc) but is not compulsory.
This label has the following syntax : %Li where i is between 0 and 999 and is located
at the beginning of the statement. A label reference can only be assigned to a single
statement within the same program entity (SR, Main, Program module).

On the other hand, a statement must be refenced in order to allow connection after a
program jump.
The label references can be in any order; it is the order in which the statements are
entered which is taken into account by the system during the scan.

4.2-4 Instructions
The program is made up of instructions. An ST statement can contain several
instructions. Each instruction must end with the character ';'.

___________________________________________________________________________
4/8
A
Structured Text language 4

4.2-5 Control structures


There are four control structures :
• the conditional action IF,
• the conditional iterative actions WHILE and REPEAT,
• the repetitive action FOR.
Each control structure is enclosed between key words, and it begins and ends in the
same statement. It is possible to nest control structures one inside the other, regardless
of their type. Control structures can be preceded or followed by any other language
instruction.
The conditional action IF ... END_IF;
Simple form (the instruction performs an action if a condition is true).

Syntax Operation
start of IF
IF condition THEN
not checked
CONDITION
actions ;
checked

END_IF; ACTIONS

end of IF

Example :

___________________________________________________________________________
4/9
A

General form

Syntax Operation

IF condition 1 THEN start of IF

action1; checked
CONDITION 1
not checked
ELSIF condition 2 THEN ACTION 1

checked
action2; CONDITION 2
not checked
ELSE ACTION 2 ACTION 3

action3; end of IF

END_IF;

Example :

• Conditions can be multiple.


• Each action represents a list of instructions.
• Several "IF" control structures can be nested.
• There is no restriction on the number of ELSIF instructions.
• There is a maximum of one ELSE part.

___________________________________________________________________________
4/10
A
Structured Text language 4

The conditional iterative action WHILE ... END_WHILE;


The instruction performs a repetitive action as long as a condition is checked.

Syntax Mode of operation


start of WHILE
WHILE condition DO not checked
CONDITION

action; checked

ACTION
END_WHILE; end of WHILE

Example :

• The condition can be multiple.


• The action represents a list of instructions.
• The condition is tested before executing the action. If, when the condition is first
evaluated, its value is false, the action is not executed.
• Several WHILE control structures can be nested.

___________________________________________________________________________
4/11
A

The conditional iterative action REPEAT ... END_REPEAT;


The instruction performs a repetitive action until a condition is checked.

Syntax Mode of operation


start of REPEAT

REPEAT ACTION

action;
CONDITION
not checked
checked
UNTIL conditionEND_REPEAT; end of REPEAT

Example :

• The condition can be multiple.


• The action represents a list of instructions.
• The condition is tested once the action has been executed. If, when the condition is
first evaluated, its value is false, the action is executed once again.
• Several REPEAT control structures can be nested.

___________________________________________________________________________
4/12
A
Structured Text language 4

The repetitive action FOR ... END_FOR;


The instruction performs a processing operation a certain number of times, incrementing
an index by 1 on each loop.

Syntax Operation
start of FOR
FOR index := initial value TO final value DO
INITIAL VALUE → INDEX
action;

INDEX > true end


END_FOR; FINAL VALUE of FOR
false
ACTION continue

INDEX + 1 → INDEX

Example :

• When the index is strictly greater than the final value, execution is continued at the
instruction following the END_FOR key word.
• The index is incremented automatically and is therefore not the responsibility of the
user.
• The action represents a list of instructions.
• The initial value and the final value must be word-type numerical expressions.
• The index must be a word-type object which is accessible in read mode.
• Several FOR control structures can be nested.

___________________________________________________________________________
4/13
A

Loop exit instruction EXIT


• The EXIT key word is used to stop execution of the loop and continue at the instruction
following the key word at the end of the loop.
• It can be used only in the actions of one of the three WHILE, REPEAT or FOR loops.
• It is assigned to the closest enclosing loop, ie. it does not stop the execution of all the
loops which surround it.

Example :

In this example, the EXIT key word is used to stop the REPEAT loop but not the WHILE
loop.

___________________________________________________________________________
4/14
A
Structured Text language 4

4.3 Rules for executing a Structured Text program


A Structured Text program is executed sequentially, instruction by instruction, while
respecting the control structures.
In the case of arithmetic or Boolean expressions consisting of several operators, rules
of priority have been defined between the various operators.

Operator priority rules


The table below gives the priority for evaluating a higher or lower priority expression.

Operator Symbol Priority


Parentheses (expression) Highest
Logic complement NOT
Inversion NOT
- on an operand -
+ on an operand +
Multiplication *
Division /
Modulo REM
Addition +
Subtraction -
Comparisons <, >, <=, >=
Comparison of equality =
Comparison of inequality <>
Logic AND AND
Boolean AND AND
Logic exclusive OR XOR
Boolean exclusive OR XOR
Logic OR OR Lowest
Boolean OR OR

Example :
NOT %MW3 * 25 AND %MW10 + %MW12

In this example, the NOT is performed on %MW3, then the result is multiplied by 25. The
sum of %MW10 and %MW12 is calculated, then a logic AND is performed between the
result of the multiplication and the addition.

___________________________________________________________________________
4/15
A

When there is conflict between two operators of the same priority, the first operator will
take precedence (evaluation is performed from left to right).
Example :
%MW34 * 2 REM 6
In this example, %MW34 is first multiplied by 2, then the result is used to
perform the modulo.

Use of parentheses
Parentheses are used to modify the order in which operators are evaluated, for example
to give an addition higher priority than a multiplication.
Example :
(%MW10 + %MW11) * %MW12
In this example, the addition will be performed before the multiplication.

Parentheses can be nested; there is no limit to the levels of nesting.


Parentheses can also be used to avoid incorrect interpretation of the program.
Example :
NOT %MW2 <> %MW4 + %MW6
By using operator priority rules, the following interpretation is obtained :

((NOT %MW2) <> (%MW4 + %MW6))

The user might well try to perform the following operation :

NOT (%MW2 <> (%MW4 + %MW6))

This example shows that parentheses can be used to clarify the program.

___________________________________________________________________________
4/16
A
Structured Text language 4

Implicit conversions
Implicit conversions relate to words and double words. The operators which are used
in arithmetic expressions and comparisons and the assignment operator perform these
implicit conversions (which are therefore not the responsibility of the user).
For an instruction of the form : <operand 1> <operator> <operand 2>, the possible
conversions are as follows :

Operand 1 Operand 2 Conversion Conversion Operation


of type : of type : Operand 1 Operand 2 of type :
Word Word No No Word
Word Double word Double word No Double word
Double word Word No Double word Double word
Double word Double word No No Double word

For an assignment of the form <left operand> := <right operand> , the left operand
imposes the type of operand which is expected in order to perform the operation, which
means that the right operand must be converted if necessary, according to the table :

Left operand Right operand Right operand


type type conversion
Word Word No
Word Double word Word
Double word Word Double word
Double word Double word No

Note :
Any operation between two immediately adjacent values is performed in double length.

___________________________________________________________________________
4/17
A

___________________________________________________________________________
4/18
A
Section 55
Grafcet language
5 Grafcet language
5.1 Presentation of Grafcet language
5.1-1 Reminder of principles of Grafcet
Grafcet language complies with "Sequential Function Chart" (SFC) language found in IEC
1131-3 standard.
Grafcet is used to represent the operation of a sequential control system in a graphic and
structured way.
This graphic description of the sequential operation of the control system, and the various
situations which occur, is performed using simple graphic symbols :

Initial step : defines the initial situation


1 of the PLC.
Transition : the associated transition
conditions indicate the logic conditions
necessary for clearing this transition.
2
Simultaneous activation of steps 3
and 7 (AND divergence). The step
sequences 3, 4, 5, 6 and 7, 8, 9
3 Actions 7 Actions constitute two sequences known as
simultaneous.
Sequence selection (OR divergence)
from step 3 to step 4 or step 5.
4 Actions 5 8 Actions
End of sequence selection (OR
convergence) from step 4 or step 5 to
step 6.
End of sequence step : enables
6 9 synchronization of the simultaneous
sequences.
Simultaneous deactivation of steps
6 and 9 (AND convergence).
10 Actions
Step : the associated actions are only
executed while this step is active.

Transitions and directed links represent in symbolic form the possible progressions of
active steps.
Actions associated with steps indicate in general terms "what is to be done" when they
are active. In particular they describe orders which are to be sent to the application
(process to be automated) or other automated systems. The set of active steps at any
given time defines the situation of the Grafcet chart.

___________________________________________________________________________
5/1
A

5.1-2 Progressive analysis : macro-representations


• Specification
An automated system enables three
products A, B, C to be mixed. A B C

Products A and B are measured out 0 0


by cumulative weight into a weigher
hopper B1. Product C is weighed and A
measured out into hopper B2.
B C
The consistency of the final product Weigher Weigher
Tremie
hopper Tremie
is obtained by kneading the three peseuse hopper
peseuse
B1
B1 B2
B2
components in a mixer for a period of Mixer
Mélangeur
time set by the operator.
Once this time has elapsed, the final
mixture can be discharged when an
Evacuation
Discharging
external authorization is given.
• Functional analysis
This application can be broken down
into 4 main sequences : Start
Début 1
- measuring out the 3 components,
- filling the mixer, cycle
cycle par
by cycle
- mixing the 3 products,
Measuring
Dosage 10 Measuring
Séquence sequence
Dosage
- discharging the final mixture.
The Grafcet chart oppositerepresents finend
de dosage
of measuring
the whole chain of sequences (macro-
Filling
Remplissage 20 Filling Remplissage
Séquence sequence
scopic representation of a first level
analysis). fin
enddeofremplissage
filling
The detailed analysis of each
sequence enables the second-level Mixing
Mélange 30 Mixing sequence
Séquence Mélange
or even third-level Grafcet charts to fin
enddeofmélange
mixing
be created, down to the most
elementary level so that the Discharging
Evacuation 40 Discharging sequence
Séquence Evacuation
application is described in its entirety.
fin
endd'évacuation
of discharging
• Macro-representations
The first-level Grafcet chart describing the chain of sequences provides greater
clarification of the structuring of the control part. Each sequence is associated with a
specific symbol for the step : the macro-step.
This idea of "macro-representation" enables the analysis to be organized into a
hierarchy. Each level can be completed or changed without affecting the other levels.
Macro-steps are available for TSX57 PLCs.

___________________________________________________________________________
5/2
A
Grafcet language 5

• Graphic representation
Macro-steps

Measuring sequence

Filling sequence

Main chart

Mixing sequence

Discharging sequence

___________________________________________________________________________
5/3
A

5.2 Graphic symbols specific to Grafcet language

Designation Symbol Functions

Initial steps Indicate the initial steps active at the start of


or i
i ou a cycle after an initialization or a cold restart.

Single steps Indicate that the control system is in a


i ou
or i stable state.
The maximum number of steps can be
configured :
- from 1 to 96 for a TSX 37-10,
- from 1 to 128 for a TSX 37-20,
- from 1 to 250 for a TSX 57.
The maximum number of simultaneously active
steps can be configured.
Macro-steps Indicates a macro-step : unique set of
i steps and transitions. The maximum
number of macro-steps can be configured
from 0 to 63 for the TSX 57 only.
Macro-step steps (1) Indicate the steps of a macro-step.
i or
ou i
The maximum number of steps for each
macro-step can be configured : from 0 to 250
for the TSX 57.
IN or OUT
One IN and OUT step per macro-step.

Transitions Used to change from one step to another. A


transition condition associated with this
transition is used to define the logic conditions
required to clear this transition.
The maximum number of transitions is 1024.
This cannot be configured.
The maximum number of transitions which can
be enabled simultaneously can be configured.
AND divergences Transition from one step to several steps.
Used to activate a maximum of 11 steps
simultaneously.
AND convergences Transition from several steps to one step.
Used to deactivate a maximum of 11 steps
simultaneously.

(1) The maximum number of steps (main chart steps + macro-step steps) in the Grafcet
section must not exceed 1024 on the TSX 57.

___________________________________________________________________________
5/4
A
Grafcet language 5

Designation Symbol Functions

OR divergences Transition from one step to several steps.


Used to perform a sequence selection to a
maximum of 11 steps.
OR convergences Transition from several steps to one step.
Used to end a sequence selection from a
maximum of 11 steps.
Source connector n 'n' is the number of the step from which control
has come (source step).

Destination connector 'n' is the number of the step to which control is


going (destination step).
n
Directed links : These links are used for sequence selection,
to jump over one or more steps, to repeat
• upwards steps (sequence).

• downwards

• to the right or left

___________________________________________________________________________
5/5
A

5.3 Objects specific to Grafcet


The user has available to him object bits associated with steps, system bits specific to
Grafcet language, word objects indicating the activity time of steps and system words
specific to Grafcet language.

Designation Address Description


Step bits %Xi State of step i of the main Grafcet chart
(1=active step) (i from 0 to n) (n depends on the processor)
%XMj State of macro-step j
(j from 0 to 63 for TSX/PMX/PCX 57)
%Xj.i State of step i of macro-step j
%Xj.IN State of input step of macro-step j
%Xj.OUT State of output step of macro-step j
Grafcet system bits (1) %S21 Initializes the Grafcet chart
%S22 Resets all Grafcet charts to zero
%S23 Freezes the Grafcet chart
%S24 Resets macro-steps to 0 according to system
words %SW22 to %SW25
%S26 Set to 1 on :
- table overflow (steps/transition),
- execution of an incorrect chart (destination
connector on a step which does not belong
to the chart).
Step words %Xi.T Active time of step i of main Grafcet chart
%Xj.i.T Active time of step i of macro-step j
%Xj.IN.T Active time of input step of macro-step j
%Xj.OUT.T Active time of output step of macro-step j
Grafcet system %SW20 Word indicating, for the current cycle, the
words number of active steps, to be activated and
deactivated.
%SW21 Word indicating, for the current cycle, the
number of enabled transitions, to be enabled
or disabled.
%SW22 to Set of 4 words designating the macro-steps
%SW25 to reset to 0 when bit %S24 is set to 1.

(1) Details of system bit usage can be found in section 6.8-3.

___________________________________________________________________________
5/6
A
Grafcet language 5

Bits assigned to steps %Xi, macro-steps %XMi, and macro-step steps %Xj.I, %Xj.IN
and %Xj.OUT
• These are at 1 when the steps are active.
• These bits can be tested in all tasks, but can only be written in preprocessing of the
master task (prepositioning of charts). These tests and actions are programmed in
Ladder language, Instruction List language, or Structured Text language.
• These bits cannot be indexed.

Active time words for steps %Xi.T and macro-step steps %Xj.I, %Xj.IN and %Xj.OUT
• These are incremented every 100 ms and have a value from 0 to 9999.
• Word incrementation : during the activity of the associated step.
• On deactivation of the step, the contents are frozen.
• On activation of the step, the contents are reset then incremented.
• The number of active time words cannot be configured, one word is reserved for each
step.
• These words cannot be indexed.

5.4 Grafcet language possibilities


These depend on the processor to be programmed and are summarized in the table
below :

Number TSX 37-10 TSX 37-20 TSX 57


Default Max Default Max Default Max
Main chart steps 96 96 128 128 128 250
Macro-steps 0 0 0 0 8 64
Macro-step steps 0 0 0 0 64 250
Total steps 96 96 128 128 640 1024
Steps active simultaneously 16 96 20 128 40 250
Transitions enabled simultaneously 20 192 24 256 48 400

The number of synchronous transitions (or number of AND convergences) must not
exceed 64. The total number of transitions is always 1024.

___________________________________________________________________________
5/7
A

Example for TSX 57 :


Sequential processing is structured into :
• 1 subset : Main chart,
• 64 subsets : Macro-steps
These subsets are themselves divided into pages (see diagram below).

Main chart Macro-step 0


8 pages
Page 8 8 pages Page 8 250 steps
250 steps maximum
maximum
+ IN step
Page 3 + Macro-steps Page 3
+ OUT step
Page 2 Page 2
+ Macro-
Page 1 Page 1 steps

Macro-step 12

Page 8
Maximum possibilities
offered by sequential
processing : 8 pages
1024 steps (steps of Page 3 250 steps
main chart + macro-step maximum
steps) Page 2
64 Macro-steps + IN step
Page 1
+ OUT step

Macro-step 63 + Macro-
steps
Page 8

8 pages
Page 3 250 steps
maximum
Page 2
+ IN step
Page 1
+ OUT step

+ Macro-
steps

___________________________________________________________________________
5/8
A
Grafcet language 5

5.5 Grafcet chart representation

The main chart can be programmed on 8 pages (pages 0 to 7). Each Grafcet page has
14 lines and 11 columns defining 154 cells. One graphic element can be entered in
each cell.

Write rules
• The first line is used to enter source connectors.
• The last line is used to enter destination connectors.
• The even lines (from 2 to 12) are step lines (for steps and destination connectors).
• The odd lines (from 3 to 13) are transition lines (for transitions and source connectors).
• Each step is numbered (from 0 to 127) in any order.
• Several charts can be represented on a single page.

___________________________________________________________________________
5/9
A

Sequence selection and end of sequence selection

• The number of transitions upstream of an end of sequence selection (OR convergence)


or downstream of a sequence selection (OR divergence) must not exceed 11.
• A sequence selection can be directed to the left or right.
• A sequence selection must, in general, conclude with an end of sequence selection.
• To avoid clearing several transitions simultaneously, the associated transition conditions
must be exclusive.

Simultaneous step activation and deactivation

• The number of steps downstream of a simultaneous activation (AND divergence) or


upstream of a simultaneous deactivation (AND convergence) must not exceed 11.
• A simultaneous activation of steps must, in general, conclude with a simultaneous
deactivation of steps.
• Simultaneous activation is always represented from left to right.
• Simultaneous deactivation is always represented from right to left.

___________________________________________________________________________
5/10
A
Grafcet language 5

The use of connectors


The purpose of connectors is to ensure the continuity of a Grafcet chart when the
directed link, either on one page or between two consecutive pages, cannot be drawn.
This continuity is provided by a destination connector which always has a corresponding
source connector.

• A chart can be looped-back using connectors (for example, looping from step 18 to
step 0).
• A sequence can be restarted using connectors (for example, step 10 to step 1 or step
8 to step 2).
• Connectors are used when a chart branch is longer than the page (for example, step
9 to step 10).

___________________________________________________________________________
5/11
A

Connectors for sequence selection and end of sequence selection


• For a sequence selection, the transitions
and the destination connectors must be
entered in the same page.

Page 1

• For an end of sequence selection, the Page 2


source connectors must be entered in
the same page as the destination step.

• For an end of sequence selection


followed by a destination connector, there Page 1
must be the same number of source
connectors as steps before the end of Page 2
sequence selection.

___________________________________________________________________________
5/12
A
Grafcet language 5

Connectors for simultaneous activation and deactivation of steps


• For simultaneous activation of steps,
the destination connectors must be on
the same page as the step and the
divergence transition.
Page 2

Page 3

• For simultaneous deactivation, the steps


and convergence transition must be on
the same page as the destination
connector.
When several steps converge on a single Page 4
transition, the source connector has the
number of the upstream step furthest Page 5
left.

Directed links
• Directed links connect a step to a
transition or a transition to a step.
They can be vertical or horizontal.
• Directed links can :
- cross 1, being different kinds,
- meet 2, being the same kind.
• A link cannot be crossed by a
simultaneous step activation or
deactivation.

1 2

___________________________________________________________________________
5/13
A

Comments
• In a Grafcet page, it is possible to
enter a comment in any cell. The
text of the comment is enclosed
by (* to the left and *) to the right.
Its maximum size is 64 characters.
• A comment occupies two adjacent
cells on a maximum of two lines. If
the display zone is too small, the
comment is shortened to fit the
display, but when printing the
document, the comment is shown
in full.
• The comment entered in a Grafcet
page is stored in the graphic data
loaded in the PLC.

___________________________________________________________________________
5/14
A
Grafcet language 5

5.6 Macro-steps
A macro-step is a unique representation of a set of steps and transitions known as an
expansion of the macro-step. This is characterized by an input step and an output step.

5.6-1 Principle
A macro-step is the graphic representation of a
sequence. IN

It can be distinguished from a step by two horizontal


lines. 1 1 11
The input step obeys the same rules as other steps.
The output step cannot have any associated actions. M1 2 12

2 13

3 OUT

1
When a macro-step is active, the Grafcet evolution
obeys the rules specified previously.
Macro-step M1 is activated when step 1 is active IN
and its downstream transition condition is true.
It is deactivated when its output step is active and the 1 11
transition condition M1>2 is true.
M1
Step 2 is then activated. 2 12

13

OUT

___________________________________________________________________________
5/15
A

5.6-2 Characteristics
Grafcet PL7 language authorizes 64 macro-steps M0 to M63 to be programmed.
The expansion of a macro-step, comprising one or more sequences, can be programmed
on 8 pages at most and has a maximum of 250 steps plus the IN step and the OUT step.
A macro-step can have one or more macro-steps.
This hierarchy is possible up to a limit of 64 levels.
The analysis of an application can be structured in such a way as to provide a more detailed
overall approach of the various operations to be performed.

0 IN IN

M0 M1 1 M4

1 1 M2 12

2 2

OUT OUT
More
Vers unedetailed analysis
analyse détaillée

5.6-3 Initial steps


The expansion of a macro-step can 1 2 3 4 5 6 7

contain one or more initial steps.


These initial steps are activated on
Initialization
power up or can be initialized by the
program. The macro-step is then 1 IN 22
displayed in the active state.
M3 11

12

13 21

___________________________________________________________________________
5/16
A
Grafcet language 5

5.7 Actions associated with steps

Each step has associated actions which can be programmed in Ladder, Instruction List,
or Structured Text language. These actions are only scanned if the step with which they
are associated is active. PL7 software authorizes three types of action :
• actions on activation : actions executed once the step with which they are associated
is activated.
• actions on deactivation : actions executed once the step with which they are
associated is deactivated.
• continuous actions: actions executed continuously as long as the step with which they
are associated is active.
These three types of action can be used for each step.
A single action can contain several programming elements (sequences, statements or
rungs).

Referencing actions
These actions are referenced as follows :
MAST - <Grafcet section name> - CHART (or MACROk)- PAGE n %Xi x
where : x = P1 Activation
= N1 Continuous
= P0 Deactivation
n = Page number
i = Step number
Example : MAST - Paint - CHART - PAGE 0 %X1 P1
Action on activation of step 1 of page 0 of the Paint section

Rules of use
• All the actions are considered as stored actions, consequently :
- an action which is governed by the duration of a step Xn must be reset on the
deactivation of step Xn or the activation of step Xn+1,
- an action affecting several steps is set to 1 on activation of step Xn and reset on
deactivation of step Xn+m.
• All the actions can be controlled by logic conditions, i.e. be conditional.
• The actions which are governed by safety interlocks must be programmed in post-
processing (processing performed with each scan, see section 5.2 "Organization of the
master task").

___________________________________________________________________________
5/17
A

Actions on activation or deactivation


These actions are pulsed and are executed on a single scan. They are used to call a
subroutine, increment a counter, etc.
Examples :

• Calling a subroutine :

• Incrementation of word %MW10, and resetting of %MW0 and %MW25 :

Continuous actions
• Conditional action
Example :
Bit %M10 is governed by input %I2.5 or internal bit %M9 and to input %I1.2.
As long as step 2 is active and these conditions are present, %M10 is set to 1. The
last state read on deactivation is stored in the memory because the associated
actions are no longer scanned.
It is therefore necessary to reset bit %M10 to 0, in the action on deactivation of the
step for example.

___________________________________________________________________________
5/18
A
Grafcet language 5

• Timed conditional action


This is a special case, in which the time is a logic condition. This link can be performed
simply by testing the active time associated with the step.
Example :
Bit %M12 is controlled as long as the active time of step 3 is less than 10 seconds (time
base : 100 ms).

• These actions can also be unconditional.

Order of execution of the actions


In the example below, on one scan, the order of execution of the actions is as follows :
When step 51 is activated, the actions are executed in the following order :
1. actions on deactivation of step 50,
2. actions on activation of step 51,
3. continuous actions of step 51.

50 Activation %X50 Continuous %X50 Deactivation %X50

51 Activation %X51 Continuous %X51 Deactivation %X51

When step 51 is deactivated, the associated continuous actions are no longer scanned.

___________________________________________________________________________
5/19
A

5.8 Conditions associated with transitions

• Each transition has an associated condition which can be programmed in Ladder,


Instruction List or Structured Text language.
• A transition condition is only scanned when the transition with which it is associated
is enabled.
• A transition condition corresponds to a rung, a list of instructions or a Structured Text
statement, comprising a series of tests on bits and/or words.
• A transition condition which is not programmed is always a false transition
condition.
Referencing the transition conditions
The transition conditions are referenced as follows :
MAST - <Grafcet section name> - CHART (or MACROk) - PAGE n %X(i) --> % X(j)
where : n = Page number
i = Upstream step number
j = Downstream step number
Example : MAST - Paint - CHART - PAGE 0 %X(0) --> %X(1)
Transition condition associated with step 0 and step 1 of page 0 of the Paint
section chart.
During simultaneous step activation or deactivation, the address indicated is that in the
column furthest to the left.

Rules for programming in Ladder language


The condition associated with the transition is programmed in the form of a rung
comprising a test zone and an action zone.
The structure of the rung is the same as that of a rung programmed in a program module.

Only the following elements can be used :


• graphic test elements : contacts (%Mi, %I, %Q, %TMi.D, etc), comparison blocks,
• graphic action elements : transition condition coil only (the other coils are not
significant in this case).

___________________________________________________________________________
5/20
A
Grafcet language 5

Rules for programming in Instruction List language


The transition condition is programmed in the form of a list of instructions containing only
test instructions.
The list of instructions for writing a transition condition differs from a standard list of
instructions as follows :
• general structure :
- no label (%L).
• list of instructions :
- no action instructions (bit objects, words or function blocks),
- no jumping, calling subroutines.

Rules for programming in Structured Text language


The transition condition is programmed in the form of a Boolean expression or an arithmetic
expression or a combination of the two.
The expression for writing a transition condition differs from a Structured Text language
programming line in :

• general structure :
- no label (%L),
- no action statement, conditional statement or iterative statement.

• list of instructions :
- no action on bit object,
- no jumping, calling subroutines,
- no transfer, no action instruction on blocks.

___________________________________________________________________________
5/21
A

Transition condition using the active time of a step


In certain applications, actions are controlled with no monitoring of feedback data (end of
travel, detector, etc). The duration of the step is conditioned by a time : PL7 language
enables the active time associated with each step to be used.

Example :
If the user wishes to remain in step 3 for 15 seconds, the condition for transition between
step 3 and step 4 will be (for example in Structured Text language) :

___________________________________________________________________________
5/22
A
Grafcet language 5

5.9 Organization of the Grafcet section


5.9-1 Description of the Grafcet section
A program written in Grafcet language has
three consecutive processing sections :
• preprocessing, Prl,
• sequential processing, Chart,
• post-processing, Post.
The macro-steps are executed in the order
in which they are scanned in sequential
processing.

The Grafcet section is programmed in the


MAST task.

The section is scanned in the following order :


Preprocessing : Grafcet section

Used to process :
• initializations on power failure or return,
• the prepositioning of the Grafcet chart,
Preprocessing
• the input logic.
Ladder, Instruction
List or Structured Text
language
Sequential processing :
Used to process the sequential structure of
the application and provides access to the Sequential processing
processing of transition conditions and Grafcet
actions directly associated with steps.

Post-processing
Post-processing : Ladder, Instruction
List or Structured Text
Used to process : language
• the output logic,
• the monitoring and safety interlocks
specific to outputs.

___________________________________________________________________________
5/23
A

5.9-2 Preprocessing
Entered in Ladder language, Instruction List language or Structured Text language,
preprocessing is scanned in its entirety from top to bottom.
Executed before the sequential and post-processing sections, it is used to process all
events which influence these :
• management of power returns and reinitializations,
• resetting or prepositioning of Grafcet charts.
It is, therefore, only in preprocessing that the bits associated with the steps will be used
(setting to 0 or 1 of step bits %Xi or %Xi.j by Set and Reset instructions).

Prepositioning the Grafcet chart


It may be necessary to preposition a Grafcet chart when changing from normal operation
to a specific mode of operation or on the occurrence of an incident (example : fault causing
degraded operation).
This operation affects the normal operation of the application scan, and should therefore
be used with caution. Prepositioning can be applied to all or part of sequential processing :
• by using the SET, RESET instructions,
• by a general reset (%S22) then, in the next scan, setting the steps to 1.

Note :
When resetting a step to zero, actions on deactivation of this step are not executed.

___________________________________________________________________________
5/24
A
Grafcet language 5

5.9-3 The use of system bits in preprocessing


As the system bits associated with the Grafcet chart are numbered in order of priority
(%S21 to %S24), when several of them are simultaneously set to 1 in preprocessing, they
are processed one by one in ascending order (only one is effective per scan cycle). These
bits are effective at the start of sequential processing.

Initializing the Grafcet chart : %S21


Normally at 0, setting %S21 to 1 causes :
• the deactivation of the active steps,
• the activation of the initial steps.

Set to 1 Reset to 0
• By setting %S0 to 1 • By the system at the start of
• By the user program sequential processing
• By the terminal (1) • By the user program
• By the terminal

• Use
When managed by the user program, %S21 must be set to 0 or 1 in preprocessing.

Resetting the Grafcet chart to zero : %S22


Normally at 0, setting %S22 to 1 causes the deactivation of the active steps of all sequential
processing.

Set to 1 Reset to 0
• By the user program • By the system at the end of
• By the terminal (1) post-processing

• Use
- this bit must be set to 1 in preprocessing,
- resetting %S22 to 0 is managed by the system; it need not, therefore, be reset to 0 by
the program or the terminal.
To restart sequential processing in a given situation, the application must contain a
procedure for initializing or prepositioning the Grafcet chart.

(1) In the Grafcet debug screen or in the animation table

___________________________________________________________________________
5/25
A

Freezing the Grafcet chart : %S23


Normally at 0, setting %S23 to 1 maintains the state of the Grafcet charts. Irrespective of
the value of the transition conditions downstream of the active steps, the Grafcet charts
do not change. This frozen state is maintained as long as bit %S23 is at 1.
Set to 1 Set to 0
• By the user program • By the user program
• By the terminal (1) • By the terminal (1)

(1) In the Grafcet debug screen or in the animation table.

• Use
- managed by the user program, this bit is set to 1 or 0 in preprocessing,
- bit %S23 associated with bits %S21 and %S22 is used to freeze sequential processing
at initial state or state 0. Similarly, the Grafcet chart can be prepositioned then frozen
by %S23.

On starting a new application or on losing the system context, the system performs a cold
start. Bit %S21 is set to 1 by the system before preprocessing is called and the Grafcet
chart positioned on the initial steps. If the user wants the application to be processed in a
particular way in the event of cold start, he can test %S0 which remains at 1 during the first
scan of the master task (MAST).
After a power outage without changing application, the system performs a warm restart,
restarting in the state preceding the power outage. If the user wants the application to be
processed in a particular way in the event of a warm restart, he can test %S1 in
preprocessing, and call the corresponding program.

___________________________________________________________________________
5/26
A
Grafcet language 5

Resetting macro-steps to zero : %S24


Normally at 0, setting %S24 to 1 resets to zero the macro-steps selected from a table of
4 system words (%SW22 to %SW25).

Set to 1 Reset to 0
• By the user program • By the system at the start of sequential
processing

• Use
- this bit should be set to 1 only in preprocessing,
- resetting %S24 to 0 is managed by the system; it must not, therefore, be reset to
0 by program or via the terminal.

Table of words %SW22 to %SW25


There is a macro-step corresponding to each bit in this table.
They are used as follows :
• loading the table of words %SW22 to %SW25 (bit to be set to 1 when the corresponding
macro-step should not be set to 0),
• enabling by %S24.

F %SW22 0

XM15 . . . . . . . . . . . . . . XM0
%SW23
%SW24
F %SW25 0

XM63 . . . . . . . . . . . . . . XM48

Example : ! IF %I4.2 AND %T3.D THEN


%SW22:=16#AF8F;
%SW23:=16#F3FF;
%SW24:=16#FFEF;
%SW25:=16#FFFF;
SET %S24

These four words are initialized to 16#FFFF if %S21 = 1.

___________________________________________________________________________
5/27
A

5.9-4 Sequential processing


This processing section is used to program the sequential structure of the application.
Sequential processing consists of :
• the main chart organized into 8 pages.
In the main chart, several unconnected Grafcet charts can be programmed and run
simultaneously.

Principle of evolution
The evolution of the Grafcet chart is managed as follows :

Phase 1 :
1. Evaluation of the condition of enabled transitions.
2. Request to deactivate associated upstream steps.
3. Request to activate relevant downstream steps.

Phase 2 :
Evolution of the state of the Grafcet chart as a function of the cleared transitions :
1. Deactivation of the steps upstream of the cleared transitions.
2. Activation of the steps downstream of the cleared transitions.
3. Disabling the cleared transitions.
4. Enabling the transitions downstream of the new activated steps.
The system updates two tables dedicated respectively to step activity and enabled
transitions :
• the step activity table stores, for the current scan, the active steps, the steps to be
activated and the steps to be deactivated,
• the enabled transitions table stores, for the current scan, the transitions located
downstream of the steps concerned with the preceding table.

Phase 3 :
The actions associated with the active steps are executed in the following order :
1. Actions on deactivation of the steps to be deactivated.
2. Actions on activation of the steps to be activated.
3. Continuous actions of the active steps.

___________________________________________________________________________
5/28
A
Grafcet language 5

Exceeding the possibilities


The number of elements in the step activity table and the enabled transitions table can
be configured. Exceeding the capacity of either table causes :
• the PLC to stop (execution of the application stops),
• system bit %S26 to change to 1 (capacity of one of the two tables exceeded),
• the ERR indicator lamp on the PLC to flash.
The system provides the user with two system words :
• %SW20 : word indicating, for the current scan, the number of steps active, to be
activated or deactivated.
• %SW21 : word indicating, for the current scan, the number of transitions enabled,
to be enabled or disabled.
In the event of a PLC blocking fault, system words %SW125 to %SW127 are used to
determine the nature of the fault.
• %SW125 = DEF7 (hex) Table overflow (steps/transitions).
• %SW125 = DEFE (hex) Execution of the incorrect Grafcet chart.
(problem of transition with unresolved destination
connector).

%SW125 %SW126 %SW127


DEF7 ≠0 =0 Step table overflow
DEF7 =0 ≠0 Transition table overflow
DEFE Step no. Macro-step no. (1) Incorrect execution of Gafcet

(1) or 64 for the main chart.

___________________________________________________________________________
5/29
A

5.9-5 Post-processing
Entered in Ladder language, Instruction List language or Structured Text language, post-
processing is scanned from top to bottom. This processing is the last executed before
activation of the outputs and is used to program the output logic.

Actions associated with the Grafcet chart


Post-processing is used to perform the actions generated in sequential processing by
integrating the operating and stop modes as well the safety interlocks specific to the action
into the equation of an output. It is also used to process an output activated several times
in sequential processing.
As a rule, it is advisable to program actions which directly affect the process in post-
processing.
Example :
• %I2.4 : safety interlock for controlling output %Q4.1.
• %M26 : internal bit resulting from the input logic controlling the operating and stop
modes.
• %I1.0 : push-button.
Output %Q4.1 is activated by steps 5, 8 and 59 of sequential processing.

___________________________________________________________________________
5/30
A
Grafcet language 5

Actions independent of the Grafcet chart


Post-processing is also used to program the outputs which are independent of
sequential processing.

Monitoring the execution of the Grafcet chart

In certain circumstances, it may be necessary to monitor the operation of the Grafcet


chart by testing the active time of certain steps.
This time is tested by comparing with either a minimum value or a maximum value
defined by the user. The use made of the fault indication is at the user's discretion
(indication, special operating procedure, transmission of a message).
Example : ! IF (%X2.T > 100 AND %X2) THEN
SET %Q4.0 ;
END_IF ;

___________________________________________________________________________
5/31
A

___________________________________________________________________________
5/32
A
Section
DFBs 66
A
6 DFBs
6.1 Presentation of DFBs
6.1-1 General
With PL7 Pro software, the user can create function blocks adapted to his application
requirements.

These user function blocks can be used to structure an application. They are used
whenever a program sequence is repeated several times in the application or to freeze
standard programming (for example : algorithm to control a motor which takes into
account local safety measures).

They can be shared by all programmers and used in the same application or in other
applications (export/import function).

The use of a DFB in an application offers :


• simplified design and entry of the program
• increased legibility of the program
• easier program debugging (all variables manipulated by the DFB can be identified
on its interface).
• reduced volume of code generated (the code corresponding to the DFB is only
loaded once, however many times the DFB is called in the program)

In relation to the subroutine, they allow :


• easier entry of processing parameters
• the use of internal DFB variables which are independent of the application
• the independent testing of the application
In Ladder language, the block can be displayed graphically to make programming and
debugging easier.
In addition, DFBs make use of remanent data.

A DFB is created using PL7 Pro software. A DFB can be used with PL7 Pro or PL7
Junior software on a TSX/PCX/PMX57 PLC.

DFBs (Derived Function Blocks) can be programmed in Structured Text and Ladder
languages by the designer and can be used in Ladder, Structured Text and
Instruction List languages.

___________________________________________________________________________
6/1
A

6.1-2 Setting up a DFB

DFBs are set up in 3 phases :


1 design of the model DFB (called the DFB type)
2 creation of an image of this block, called an instance, for each time it is used in the
application
3 use of the instance in the PL7 program

Designing a DFB type


DFB type name
A DFB type comprises :
• a name
• parameters : Inputs Outputs
- inputs
- outputs
- I/O
• variables
- public variables
- private variables I/O
• a code in Structured Text language
• a comment
• a descriptive file Public variables
Private variables

This information must be defined in the Structured Text code


DFB design phase. The DFB type is cre-
ated using the DFB editor.

Creating a DFB instance


Once the DFB type has been created, the
user defines a DFB instance using the
variables editor or when the function is
called in the program editor.

Using DFBs
This instance of the block is then used as Ladder à blocs - Exem ple
% C0
D efau t % Q2 .1
a standard Ladder language function block R E
Va nne _C 1
In it
or as an elementary function in Structured S D
Va nn e
Ope n Va l

% Q2 .5
Text or Instruction List language. It can be % Q2 .6
CU F C los e Tp s Te mpo raire
V olu me_C 1 % Q2 .7
Vo lume
programmed in the different tasks (except CD V ann e_ C1.Val

E xpres si on
Va l E rr

D iam Vo l % MW89
for event tasks) and application sections. C hro no _C1
R ayo n_C 1* 2

C hron o Ope ratio n


Te mpo raire Tp s D ep D epa ssem ent_tp s(Tp s_ref_

Tp s_re f_C 1 R ef

Example DFB : Valve_C1, Volume_C1, Chrono_C1


___________________________________________________________________________
6/2
A
DFBs 6
A

6.2 Designing a DFB type


6.2-1 Creating a DFB type
DFB types are created at the DFB type
directory level in the Application Browser.

Each DFB type is addressed by a name


with a maximum of 16 characters (1).

6.2-2 Description of parameters and variables

General characteristics
These objects are DFB internal data and are purely symbolic (no addresses apply). For
each parameter or variable used, the designer of the DFB type defines :
• a name with a maximum of 8 characters (1)
• an object type (see the table below)
• a comment (optional) with a maximum of 80 characters
• an initial value (except for I/O parameters)

Authorized object types


BOOL Boolean AR_X Bit table
EBOOL extended Boolean (edge management) AR_R Real table
REAL Real AR_W 16-bit integer table
WORD 16-bit integer AR_D 32-bit integer table
DWORD 32-bit integer STRING Character string
Notes :
• The EBOOL type manages the edges, making it possible to execute instructions on rising and
falling edges on this type of parameter or variable (example of PL7 language EBOOL type
object : %Mi,%Ixy.i,%Qxy.i). If edge management is not used in processing, the BOOL type
should be used (example of PL7 language BOOL type object : %MWi:Xj) which does not manage
edges but uses less memory.
• If an EBOOL type is to be associated with an I/O parameter when it is used, it must be an EBOOL
type in the DFB.
• Tables : the table length must be given for output parameters and public and private variables,
but it is not required for input and I/O parameters.
• Initial values can be defined for inputs (if they are not table type), outputs and public and private
variables.

(1) letters without accents, figures and the character "_" may be used. The first character
must be a letter. Key words and symbols must not be used.

___________________________________________________________________________
6/3
A

Description of parameters Control


• Inputs : (max. : 15 (1)) data to be supplied DWORD WORD
to the DFB by the application program. Diff Accel
In read-only mode, these parameters WORD BOOL
cannot be modified in the DFB code. Speed Error
BOOL
• Outputs : (max. : 15 (2)) data generated Enable
by the DFB towards the application pro-
gram. WORD
Actions
• I/O : (max. : 15 (1) and (2)) input Example of a block with :
parameters which can be modified in 3 inputs, 2 outputs, 1 I/O
the DFB code.

(1) where Number of Inputs + Number of I/O < 15


(2) where Number of Outputs + Number of I/O < 15

Note : every DFB must have at least one Boolean input.

Description of variables
• Public variables : (max. : 100) internal variables used during processing which can
be accessed by the user in adjust mode or by the application program outside the
DFB code (as a DFB instance public variable, see section 6.4-4).
In addition to the general characteristics, it is possible to specify read-only or read/
write rights, and to authorize the transfer of current values to initial values to be saved
(see section 6.4-5).

• Private variables : (max. : 100) internal variables in the function block code. These
variables are calculated and used within the DFB but are not used outside the DFB.
These variables are used for programming the block but are of no interest to the user
of the block (for example : intermediate variable for connecting one combinational
expression to another, the result of an intermediate calculation, etc)

Note : A DFB interface (public variables or parameters) can only be modified if it is not instantiated
and used in the application.

___________________________________________________________________________
6/4
A
DFBs 6
A

6.2-3 DFB type code

The code defines the processing which CHR_200:=CHR_100;


CHR_114:=CHR_104;
must be performed by the DFB according CHR_116:=CHR_106;
to the parameters declared. RESET RESTART;
(* Increment CHR_100 80 times*)
FOR CHR_102:=1 TO 80 DO
The DFB code is programmed in INC CHR_100;
WHILE((CHR_104-
Structured Text or Ladder language. CHR_114)<100)DO
IF(CHR_104>400)
THEN
In the case of ST language, the DFB EXIT;
END_IF;
consists of a single statement which can INC CHR_104;
REPEAT
be of any length. IF(CHR_106>300)
THEN
EXIT;
All language instructions and advanced END_IF;
functions are permitted, except : INC CHR_106;
UNTIL ((CHR_100-
• calling standard function blocks CHR_116)>100)
END_REPEAT;
• calling other DFBs END_WHILE;
• jumping to a label (JUMP) (* Loop CHR_106)
IF
• calling a subroutine (CHR_106=CHR_116)
• the HALT instruction THEN EXIT;
ELSE
• instructions using I/O module variables
CHR_114:=CHR_104;
(eg.: READ_STS, SMOVE, etc)
CHR_116:=CHR_106;
END_IF;
The code uses the DFB parameters and INC CHR_200;
END_FOR;
variables defined by the user.
The DFB code cannot use the I/O objects
(%I,%Q...) or the global application objects
(%MW,%KW...) except for system bits and
words %S and %SW.

Some functions have been specifically developed for use in user function blocks :
• FTON, FTOF, FTP and FPULSOR time delay functions which can be used instead
of timer function blocks
• LW, HW and COCATW instructions which can be used to handle words and double
words
• LENGTH_ARW, LENGTH_ARD and LENGTH_ARR instructions which can be used
to calculate table lengths
Note : Labels cannot be used.

___________________________________________________________________________
6/5
A

6.2-4 Confirming the DFB type

During confirmation, the DFB editor checks the syntax of the code and the best match
with the variables entered in the interface. In the case of an error, the first error is
displayed in reverse video.
Note : If the user wants to quit without confirming the code, the DFB must be exported
in order to be saved : delete the entire code before quitting.

6.2-5 DFB type properties


The following DFB type properties can be accessed from a dialog box in the DFB editor.

• "Information" zone, which manages :


- the amount of data
- the number of instances created
- the application ID (ensures that each DFB type is unique)
- the number of elements : parameters and variables

• "General" zone, which indicates :


- the version : incremented automatically each time the code, the parameters or the
DFB type variables are modified
- the date of the last modification
- the language : ST or LD (can be modified if the code is empty)
- 2 types of protection : modification protection which limits access to the DFB in read-
only mode, and know-how protection which prohibits access to the DFB type code
and its private variables. Protection is managed by a password.
- a comment, with a maximum of 128 characters. By default, the comment contains
the creation date and the author of the DFB type.

___________________________________________________________________________
6/6
A
DFBs 6
A
6.2-6 Descriptive file

The descriptive file is a free entry field with a maximum of 32,000 characters which is
used to describe a DFB type.

6.2-7 DFB type properties


This is used to access the DFB type properties :
• Display the number of DFBs in ST and LD present in the application
• Inhibit the "Save/Restore" function for all the DFBs
This function is used to inhibit all the Save/Restore flags chosen for the public variables
of all the DFB types.
This inhibit function has a "blanket" effect for all the DFBs since, when it is disabled, the
choices for each public variable of each DFB type are retained.

6.2-8 Importing/exporting a DFB type


The DFB types created in an application can be reused in any other application by the
import/export functions.

2 types of format are supported :


• source : this format can be edited
• binary : this format cannot be edited. A DFB imported in this format can be read or
modified depending on the degree of protection applied.
Using these source or binary files, the user can create his own library.

Notes :
Whenever a section is imported into an application, the DFB types used in that section must also
be imported.

___________________________________________________________________________
6/7
A

6.3 Creating a DFB type instance


6.3-1 Principles
Once the DFB type has been created (or imported), an instance must be generated for
this block before it can be used.
Every DFB instance is addressed by a name with a maximum of 32 characters (1) which
is defined by the user.

As many instances as required can be created (this is only limited by the size of the PLC
memory) from the same type of DFB.
The initial values of the public variables defined for the DFB type function blocks can
be modified for every instance.

These operations are carried out in the variables editor (DFB instances) or in the
program editor when the function is called. All DFB instances can be accessed in the
function library.

Monitor_oven
A DFB instance is a copy of a DFB type :
DFB Control
• it uses the DFB type code (the code is not
duplicated) DWORD WORD
Diff Accel
• it creates a data zone specific to this
instance, which is a copy of the DFB type WORD BOOL
Speed Error
parameters and variables. This zone is
situated in the application data area. BOOL
Enable

WORD
Actions

Example of the "Monitor_oven"


instance of the Control DFB
type

(1) The characters which may be used are identical to those for the symbols (see section
1.2-9)
___________________________________________________________________________
6/8
A
DFBs 6
A

6.4 Using DFBs

6.4-1 General programming rules


DFB instances can be used in all languages (Ladder, Structured Text and Instruction
List) and in all parts of the application : sections, subroutine, Grafcet module, (except
for event-triggered tasks).

The following rules must be followed whatever language is used :


• All the table type input parameters and the I/O parameters must be entered.
• Non-wired input parameters maintain the value of the previous call or the initialization
value if the block has never been called with this defined or wired input.
• All objects assigned to the input, output and I/O parameters must be of the same type
as those defined when the DFB type was created (for example : if the WORD type is
defined for the "speed" input parameter, %MDi and %KDi double words must not be
assigned).
The only exception concerns BOOL and EBOOL types for input or output parameters
(not for I/O parameters) which can be mixed : for example the "Enable" input
parameter can be defined as BOOL and associated with an internal EBOOL type bit
%Mi. The internal DFB type code will have BOOL type properties but will not manage
edges.

The table below summarizes the possible options :

Parameter Type Parameter assignment Assignment


Inputs Boolean Wired (1) optional (2)
Digital Object or expression optional
Table Object essential
I/O Boolean Object essential
Digital Object essential
Table Object essential
Outputs Boolean Wired (1) optional
Digital Object optional
Table Object optional

(1) Wired in Ladder language, or Boolean or Structured Text language object.


(2) In Ladder language, all DFBs must have at least one wired (binary) Boolean input.

___________________________________________________________________________
6/9
A

6.4-2 Programming in Ladder language

There are two ways of calling a DFB :


• a textual call in an operation block. The syntax and the limits on the parameters are
identical to those for Structured Text language (see the following section).
• a graphic call (see the example which follows).
Graphic DFBs have I/O which are assigned directly by objects or expressions. These
objects or expressions occupy one cell in the graphic rung.

2 DFBs connected in series must be separated by at least 2 columns.

1 DFB name
2 DFB type name
3 parameter effective from the first input
4 input parameters (name and type)
5 output parameters (name and type)
6 I/O parameters (name and type)

Comments :
• A DFB must have at least one wired Boolean input.
• Digital inputs, outputs or I/O are not wired. The objects in the cell next to the pin are
associated with this pin.

___________________________________________________________________________
6/10
A
DFBs 6
A

6.4-3 Programming in Structured Text language or Instruction List language

Calling a DFB is an action which can be inserted into a statement or sequence just like
any other language action.

Syntax in Structured Text language


DFB_Name (I1,...,In,IQ1,...,IQn,Q1,...,Qn)

Example : Cnt_lugs (%I2.0,%MD10,%I2.1,%Q1.0);

Syntax in Instruction List language


[DFB_Name (I1,...,In,IQ1,...,IQ,Q1,...,Qn)]

Example : Cnt_lugs (%I2.0,%MD10,%I2.1,%Q1.0);

where :
I1, ..., In : expressions (1), immediate objects or values serving as effective parameters
for input parameters.
IQ1, ..., IQn : effective parameters corresponding to I/O; these are always read/write
language objects.
Q1, ..., Qn : effective parameters corresponding to outputs; these are always read/write
language objects.

Assisted entry is offered in Structured Text and Instruction List languages.

(1) except for BOOL/EBOOL type objects

___________________________________________________________________________
6/11
A

6.4-4 Accessing variables


Only the output parameters and public variables can be accessed as objects in the
application program outside the body of the function block. Their syntax is as follows :
DFB_name.parameter_name

where DFB_name is the name given to the DFB instance used (32 characters
maximum) and parameter_name is the name given to the output parameter or the
public variable (8 characters maximum).

Example : Control.Diff for the Diff output of the DFB instance called Control.

6.4-5 Saving and restoring public variables


Public variables, modified by program or by adjustment, can be saved instead of the
initialization values (defined in the DFB instances) by setting system bit %S94 to 1. This
replacement is only possible if it has been authorized at the level of each DFB type
variable.
The values saved in this way are reapplied when system bit %S95 is set to 1 or when
the PLC is re-initialized.
Inhibition of the "Save/Restore" function for all the DFBs
refer to section 6.2-7.

6.4-6 Executing DFBs


A DFB instance is executed in the following order :
• The input and I/O parameters are loaded using the effective parameters. Each
undefined input takes the initial value defined in the DFB type on initialization or on
a cold start, then the current value of the parameter.
The input parameters (except for table type) are treated according to value.
The I/O parameters are treated according to address.
• The Structured Text code is executed.
• The output parameters are written.

PL7 software offers several tools for debugging the PL7 program and the DFBs :
• animation table : all the parameters and public variables are displayed and animated
in realtime. The required objects can be modified and forced.
• breakpoint, step-by-step and program diagnostics
• runtime screens : for debugging using a unified screen

___________________________________________________________________________
6/12
A
DFBs 6
A

6.5 Example

This example is given for the purpose of


clarification. The DFB programmed is a
counter. Cnt_items

Characteristics of a DFB type EBOOL BOOL


Reset Done
Name : Cnt_items
DWORD
Inputs : Preset
• Reset : counter reset EBOOL
• Preset : counter preset value Count

• Count : counter input


DWORD
Outputs Curr_V
• Done : preset output value reached
Public variable :
• Curr_V : current value incremented by
the Count input

Function of counter : this block counts the rising edges on the Count input. The result
is recorded in the Curr_V variable, and this value is reset to zero by a rising edge on
the Reset input. Counting is performed up to the preset value. When this value is
reached, the Done output is set to 1. It is reset to 0 on a rising edge of the Reset input.

Code

!(*Programming the Cnt_items DFB*)


IF RE Reset THEN
Curr_V:=0;
END_IF;
IF RE Count THEN
Curr_V:=Curr_V+1;
END_IF;
IF(Curr_V>=Preset) THEN
SET Done;
ELSE
RESET Done;
END_IF;

___________________________________________________________________________
6/13
A

Example of use
In this example, the DFB type created is used 3 times (3 DFB instances) for counting
3 types of item. When the number of items programmed (in words %MD10, %MD12,
and %MD14) is reached, the counter output controls the stopping of the system
supplying the items.

User program
DFB usage names for the Cnt_items DFB type :
• Cnt_lugs
• Cnt_nuts
• Cnt_screws

Cpt_boulons
Cnt_lugs
Cpt_pièces
Cnt_items
%I1.0 %Q2.1
BOOL BOOL
Reset
Raz Done

%MD1 0 DWOR D
Preset
Presel
% I1.1
BOOL
Count

Cnt_nuts
Cpt_écrous

Cpt_pièces
Cnt_items
%I1.2 %Q2.2
BOOL BOOL
Reset
Ra z Done

%M D12 DWORD
Presel
Preset
% I1.3
BOOL
Cou nt

Cnt_screws
Cpt_v is

Cpt_pi èces
Cnt_items
% I1.4 % Q2.3
BOOL BOOL
Reset
Raz Done

%MD14 DWORD
Presel
Preset
% I1.5
BOOL
Count

___________________________________________________________________________
6/14
A
FunctionSection
modules 7
7
A
7 Function modules
7.1 Presentation of function modules
7.1-1 Definition of a function module
A function module is a group of program elements (sections, events, macro-steps,
animation tables etc) used to perform a control system function.

A function module is defined by a number of attributes (name, comment, programming,


associated animation tables etc).

A function module comprises a program directory (containing one or more code


modules) and an animation table directory.

A function module contains


the program and the
animation tables

PL7 PRO is the only product which can be used to set up function modules on TSX/PMX/
PCX57 PLCs.
Function modules are used to structure the application into control system functions
and subfunctions.
___________________________________________________________________________
7/1
A

7.1-2 Representation of a function module in PL7 PRO


This software is used to display :
• A structural view of the application : This is the traditional view in the Application
Browser corresponding to the order of execution by the PLC.

• A functional view of the application : This is a view of the application divided into
function modules corresponding to the control system functions.

The Application Browser has 4 possible display options :


• The traditional and
functional view side by
side

• The traditional and functional view one


above the other
• The traditional view only
• The functional view only

___________________________________________________________________________
7/2
A
Function modules 7
A

7.1-3 The concept of a function submodule


A function module can itself be broken down into lower-level function modules which
perform one or more subfunctions of the main control system function.

Example

Module Mixer_1 has a submodule Adjust_1

7.1-4 The attributes of a function module


A function module consists of :
• a short name : 8
characters (example :
TR371) which must be
unique within the
application

• a long name : 16
characters (example :
Forward / Reverse for
BT371)

• function submodules : these are


lower-level function modules

• associated code modules : sections,


events, Grafcet module (Prl, Chart, Xm
macro-steps, Post)

• a descriptive file (unlimited number of


characters),not stored in the PLC but in
the application .STX file

• associated animation tables

___________________________________________________________________________
7/3
A

7.2 Setting up function modules


7.2-1 Creating a function module
Principle
A function module can be created in offline mode, with the
PLC in Stop or Run.
A function module can be created at Station level or at the
level of each existing function module.
A function module can be renamed.

Importing a function module


A function module can be imported in offline mode, with
the PLC in Stop.

7.2-2 Modifying the architecture of function modules


Moving a function module
A function module can be moved in offline mode, with the PLC in stop or run (this does
not affect the execution of the application).
Moving a module only corresponds to changing the functional architecture of the
application (a module is directly attached at Station level or to another function module).
To move a module, simply select and move it (using the Drag and Drop method).

Example

___________________________________________________________________________
7/4
A
Function modules 7
A

Detaching a function module


Detaching a function module consists of breaking the links between a function module
and the associated objects (code modules and animation tables).
- The sections contained in the module are not deleted, but merely detached.
- The animation tables associated with the modules are not deleted, but merely
detached from the module.
Deleting one or more function modules without deleting the code modules and
animation tables
To delete a function module without deleting the code modules and animation tables,
it is necessary to :
1. Detach the module and submodules.
2. Delete the module(s) in accordance with the procedure below.
Deleting a function module (with deletion of the code modules and animation tables)
Deleting the module will delete the submodules.
- The sections contained in the module are deleted.
- The animation tables associated with the modules are deleted.
Deleting all the function modules (with deletion of the code modules and animation
tables)
Deleting the module will delete the submodules.
Deleting a section, a macro-step or an event in a function module
Refer to section 7.3-2.

___________________________________________________________________________
7/5
A

7.3 Programming a function module


7.3-1 Adding / creating a section, an event or a macro-step in a function
module
1st case : the section, event or chart already exists in the structural view
The section has already been created in the structural view.
Simply drag and drop the section in the function module.

Example

Select the section and drag it to


the corresponding function mod-
ule.

The name of the function module is repeated


in the structural view.

___________________________________________________________________________
7/6
A
Function modules 7
A

2nd case : creating the section, event or chart from the functional view
When creating a section,
the associated task must
be specified.
It is possible to create a
section, an event or a
macro-step.

3rd case : creating the section, event or chart from the structural view
Here, the user creates the
functional architecture and
creates the sections from
the structural view.
In this case, the function
module which is to be as-
sociated must be specified.

Rules
1. A Grafcet section can only be created in offline mode, and only in the Mast task.
2. A macro-step or an event can only be created in offline mode.
3. The other actions are authorized in offline mode, with the PLC in Stop or Run.
4. The protection of a module applies to all the sections attached to the function
module.

___________________________________________________________________________
7/7
A

7.3-2 Deleting a section, a macro-step or an event in a module


It is possible to delete a section or a macro-step in a function module. It is then deleted
from the module and the associated task.
Deleting an event only detaches it from the function module, as an event cannot
be deleted in the application.

Example : deleting the Check_dfb section

The section has disappeared from both views.

Rules
1. Deletion is authorized in offline mode with the PLC in Stop, but is prohibited in Run.
2. A Grafcet section or a macro-step can only be deleted in offline mode.
3. A PRL, Chart or POST module cannot be deleted, only detached.

___________________________________________________________________________
7/8
A
Function modules 7
A

7.3-3 Adding / creating an animation table in a function module


1st case : the table already exists
The animation table has already been created in the structural view.
Simply drag and drop the section in the function module at Animation table level.

2nd case : the table needs to be created


The principle is identical to that for creation in the structural view.

Rules
1. An animation table can be created in offline mode, with the PLC in Stop or Run.
2. An animation table can be deleted in offline mode, with the PLC in Stop or Run.

7.3-4 Entering / modifying the descriptive file


The descriptive file is a free entry field which is used to describe the function module.
It can be modified at all times and is stored in the application, but not in the PLC.

___________________________________________________________________________
7/9
A

7.4 Executing the program

The organization of a function module and the distribution of the sections, events and
Grafcet modules in the various modules does not affect the execution of the program.
The program is executed in the order shown in the structural view.

7.5 Debugging the application

The user has functions enabling the incremental debugging of the application, function
module by function module.

Deactivating all the sections attached to a function module


This action consists of forcing all the activation conditions of the module sections to 0.

Activating all the sections attached to a function module


This action consists of forcing all the activation conditions of the module sections to 1.

Canceling forcing of all the sections attached to a function module


This action consists of unforcing all the activation conditions of the module sections.

7.6 Application documentation file

PL7 Pro is used to create the functional documentation file for the application,
comprising :
• the title page
• the contents
• the configuration
• the tree structure of the function modules (with reference to the attached sections,
events and Grafcet modules only)
• the program
• the cross references, with references to the function modules which use the variables
• the variables
• the footer

___________________________________________________________________________
7/10
A
Function modules 7
A

7.7 Importing and exporting the source file for a function module

7.7-1 Exporting
Exporting a function module involves :
• exporting the sections, events and Grafcet modules which make up the module
• exporting the function submodules which make up the function module
The short name and role name are exported and are therefore restored at the time of
import.
The function to export a function module can be accessed in offline mode and/or in
online mode, with the PLC in Stop.

Comment
Animation tables are not processed in the PL7 source file : for this reason, they are
neither exported nor imported, even if they are attached to a function module.

7.7-2 Importing
Importing a function module is similar to creation, involving :
• importing the sections, events and Grafcet modules which make up the module
• importing the function submodules which make up the function module
The short name and role name are exported and are therefore restored at the time of
import.
If a section, an event, a Grafcet module or a function submodule comprising the
imported function module already exists with the same name, the software allows the
user to enter a new name.
The import of a function module makes it possible to correct a code error or errors in
the sections, events and Grafcet modules associated with the module.
The function can be accessed in offline mode and/or in online mode, with the PLC in
Stop.
2 import procedures are available :
• import without reassignment
• import with reassignment
Importing with reassignment is used to modify various elements :
- the names of the modules, Section, Task, Grafcet chart and macro-steps, Evti
- the names of the Symbols (and associated comments) and Addresses
- the I/O module addresses
- DFB : comment field and the target name of all instances
- the target SR and macro-steps

___________________________________________________________________________
7/11
A

___________________________________________________________________________
7/12
Detailed description of instructions Contents B
and functions Part B
___________________________________________________________________________

Section Page
1 Description of basic instructions B1/1

1.1 Presentation of basic instructions B1/1


1.1-1 General B1/1

1.2 Boolean instructions B1/2


1.2-1 Presentation of Boolean instructions B1/2
1.2-2 Instruction format B1/3
1.2-3 Load instructions B1/4
1.2-4 Assignment instructions B1/5
1.2-5 Logic AND instructions B1/6
1.2-6 Logic OR instructions B1/7
1.2-7 Exclusive OR instructions B1/8

1.3 Predefined function blocks B1/9


1.3-1 Programming principles for predefined function blocks B1/9
1.3-2 Timer function block %TMi B1/10
1.3-3 Up/down counter function block %Ci B1/14

1.4 Numerical processing on integers B1/17


1.4-1 General B1/17
1.4-2 Comparison instructions B1/19
1.4-3 Assignment instructions B1/20
1.4-4 Arithmetic instructions on integers B1/23
1.4-5 Logic instructions B1/25
1.4-6 Numerical expressions B1/27

1.5 Program instructions B1/28


1.5-1 Subroutine call B1/28
1.5-2 Subroutine return B1/29
1.5-3 Program jumps B1/30
1.5-4 Program end instructions B1/32
1.5-5 Stop program B1/33
1.5-6 Event masking/unmasking instructions B1/34
1.5-7 NOP Instruction B1/34

___________________________________________________________________________
B/1
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________

Section Page

2 Description of advanced instructions B2/1

2.1 Presentation of advanced instructions B2/1


2.1-1 General B2/1

2.2 Advanced predefined function blocks B2/2


2.2-1 Monostable function block %MNi B2/2
2.2-2 Register function block %Ri B2/5
2.2-3 Drum controller function block %DRi B2/9
2.2-4 Timer function block %Ti (Series 7) B2/13

2.3 Vertical comparison blocks B2/17

2.4 Shift instructions B2/19

2.5 Floating point instructions B2/20


2.5-1 General B2/20
2.5-2 Floating point comparison instructions B2/22
2.5-3 Floating point assignment instructions B2/23
2.5-4 Floating point arithmetic instructions B2/24
2.5-5 Logarithmic and exponential instructions B2/25
2.5-6 Trigonometric instructions B2/26
2.5-7 Conversion instructions B2/28

2.6 Numeric conversion instructions B2/29


2.6-1 BCD <--> Binary conversion instructions B2/29
2.6-2 Integer <--> Floating point conversion instructions B2/31
2.6-3 Gray --> Integer conversion instructions B2/33
2.6-4 Word <--> double word conversion instructions B2/34

___________________________________________________________________________
B/2
Detailed description of instructions Contents B
and functions Part B
___________________________________________________________________________

Section Page
2.7 Word table instructions B2/35
2.7-1 General B2/35
2.7-2 Word table assignment B2/36
2.7-3 Arithmetic instructions on tables B2/38
2.7-4 Logic instructions on tables B2/39
2.7-5 Summing function on tables B2/40
2.7-6 Table comparison functions B2/41
2.7-7 Find functions on tables B2/43
2.7-8 Find maximum and minimum values function on tables B2/45
2.7-9 Number of occurrences of a value in a table B2/46
2.7-10 Circular shift function on tables B2/47
2.7-11 Sort function on tables B2/49
2.7-12 Table length calculation function B2/50

2.8 Character string instructions B2/51


2.8-1 Format of a string or table of characters B2/51
2.8-2 Character string assignment B2/52
2.8-3 Alphanumeric comparisons B2/53
2.8-4 Numeric <---> ASCII conversion functions B2/54
2.8-5 Binary --->ASCII conversion B2/54
2.8-6 ASCII ---> Binary conversion B2/56
2.8-7 Floating point ---> ASCII conversion B2/57
2.8-8 ASCII --> Floating point conversion B2/58
2.8-9 Concatenation of two strings B2/59
2.8-10 Deletion of a character substring B2/60
2.8-11 Insertion of a character substring B2/61
2.8-12 Replacement of a character substring B2/63
2.8-13 Extraction of a character substring B2/65
2.8-14 Extraction of characters B2/67
2.8-15 Comparison of two character strings B2/69
2.8-16 Search for a character substring B2/70
2.8-17 Length of a character string B2/71

___________________________________________________________________________
B/3
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________

Section Page
2.9 Time management instructions : Date, Time of day, Duration B2/72
2.9-1 Parameter format B2/72
2.9-2 Use of system bits and words - General B2/74
2.9-3 Realtime clock function B2/75
2.9-4 Read system date B2/77
2.9-5 Update system date B2/77
2.9-6 Read date and stop code B2/78
2.9-7 Read day of the week B2/79
2.9-8 Add / Remove a duration at a date B2/80
2.9-9 Add / Remove a duration at a time of day B2/81
2.9-10 Difference between two dates (no time) B2/83
2.9-11 Difference between two dates (with time) B2/84
2.9-12 Difference between two times B2/85
2.9-13 Convert a Date to a character string B2/86
2.9-14 Convert a complete Date to a character string B2/87
2.9-15 Convert a Duration to a character string B2/88
2.9-16 Convert a Time of day to a character string B2/89
2.9-17 Convert a Duration to HHHH:MM:SS B2/91

2.10 Bit table instructions B2/92


2.10-1 Copy one bit table to another bit table B2/92
2.10-2 Bit table logic instructions B2/93
2.10-3 Copy from a bit table to a word table B2/94
2.10-4 Copy from a word table to a bit table B2/96

2.11 "Orphee" functions : shift, counter B2/98


2.11-1 Shifts on words with retrieval of shifted bits B2/98
2.11-2 Up/down counting with indication of over/underflow B2/101
2.11-3 Circular shift operations B2/103

2.12 Time delay functions B2/105


2.12-1 General B2/105
2.12-2 FTON on-delay function B2/105
2.12-3 FTOF off-delay function B2/107
2.12-4 FTP pulse delay function B2/108
2.12-5 FPULSOR function for generating square wave signals B2/109

___________________________________________________________________________
B/4
Detailed description of instructions Contents B
and functions Part B
___________________________________________________________________________

Section Page
2.13 Data archiving functions B2/111
2.13-1 General B2/111
2.13-2 Initializing the archiving zone B2/112
2.13-3 Writing data to the archiving zone B2/114
2.13-4 Reading data from the archiving zone B2/116

3 System bits and words B3/1

3.1 System bits B3/1


3.1-1 List of system bits B3/1
3.1-2 Detailed description of system bits B3/3

3.2 System words B3/9


3.2-1 List of system words B3/9
3.2-2 Detailed description of system words B3/11

4 Differences between PL7-2/3 and PL7 Micro/Junior B4/1

4.1 Differences between PL7-2/3 and PL7-Micro/Junior B4/1

5 List of reserved words B5/1

5.1 Reserved words B5/1

6 Conformity to the IEC 1131-1 standard B6/1

6.1 Conformity to the IEC 1131-3 standard B6/1


6.1.1 Conformity tables B6/1

7 Quick reference guide B7/1

7.1 Quick reference guide B7/1

___________________________________________________________________________
B/5
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________

Section Page

8 Performance B8/1

8.1 General B8/1

8.2 TSX 37 performance B8/3


8.2.1 Boolean instructions B8/3
8.2.2 Function blocks B8/4
8.2.3 Integer and floating point arithmetic B8/6
8.2.4 Program instructions B8/8
8.2.5 Command structure B8/8
8.2.6 Numeric conversions B8/9
8.2.7 Bit string B8/9
8.2.8 Word, double word and floating point value tables B8/11
8.2.9 Time management B8/14
8.2.10 Character strings B8/15
8.2.11 Application-specific functions and Orphee function B8/16
8.2.12 Explicit I/O B8/17

8.3 TSX 57 performance B8/18


8.3.1 Boolean instructions B8/19
8.3.2 Function blocks B8/20
8.3.3 Integer and floating point arithmetic B8/22
8.3.4 Program instructions B8/24
8.3.5 Command structure B8/24
8.3.6 Numeric conversions B8/25
8.3.7 Bit string B8/25
8.3.8 Word, double word and floating point value tables B8/27
8.3.9 Time management B8/30
8.3.10 Timer function B8/30
8.3.11 Character strings B8/31
8.3.12 Word extraction B8/31
8.3.13 Application-specific functions and Orphee function B8/32
8.3.14 Explicit I/O B8/33
8.3.15 DFB function block B8/35

___________________________________________________________________________
B/6
Detailed description of instructions Contents B
and functions Part B
___________________________________________________________________________

Section Page
8.4 Size of the application B8/38
8.4.1 Description of the memory zones B8/38
8.4.2 Memory size of PL7 objects B8/39
8.4.3 Module memory size B8/39
8.4.4 Memory size of advanced functions B8/45

8.5 Appendix : method of calculating the number of instructions B8/52

9 OLE Automation Server B9/1

9.1 Presentation B9/1


9.1-1 Warning B9/1
9.1-2 Introduction B9/2
9.1-3 Execution context B9/3
9.1-4 Operating modes B9/3

9.2 Implementation B9/4


9.2-1 Installation B9/4
9.2-2 Starting the server in offline mode (COM mode) B9/4
9.2-3 Starting the server in remote mode (DCOM) B9/5
9.2-4 Setting up the server for remote mode B9/6

9.3 PL7 server execution modes B9/7

9.4 Input points : OLE function B9/8

9.5 Description of OLE functions B9/10


9.5-1 OpenStx B9/10
9.5-2 CloseStx B9/10
9.5-3 ExportScyFile B9/11
9.5-4 ExportFefFile B9/12
9.5-5 DisconnectPLC B9/12
9.5-6 ConnectPLC B9/13
9.5-7 SaveStx B9/14
9.5-8 DownloadToPLC B9/14
9.5-9 UploadfromPLC B9/15
___________________________________________________________________________
B/7
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________

Section Page
9.5-10 GetSymbol B9/16
9.5-11 SetServerIHM B9/17
9.5-12 GetPL7State B9/18
9.5-13 GetSTXAppIdentity B9/18
9.5-14 GetPLCAppIdentity B9/19
9.5-15 SendCommandToPLC B9/20
9.5-16 SetDriverAndAdresse B9/21
9.5-17 OpenTool B9/21
9.5-18 SetPosPL7Windows B9/22
9.5-19 ShowProgram B9/23
9.5-20 CloseProgram B9/23
9.5-21 ShowIOModule B9/24
9.5-22 CloseIOModule B9/25
9.5-23 ShowDFB B9/26
9.5-24 CloseDFB B9/26
9.5-25 GetMessageError B9/27
9.5-26 GetServerVersion B9/27

9.6 Mechanism for accessing the PL7 OLE Automation Server B9/28

___________________________________________________________________________
B/8
SectionDescription
1 Section 11
of basic instructions
1 Description of basic instructions
B
1.1 Presentation of basic instructions
1.1-1 General
The instructions described in this section comply with the main basic instructions
defined in IEC standard 1131.3.
These instructions always produce the same effect, irrespective of the language used.
Only their presentation in the program changes.
Example of a Boolean equation :
In Instruction List language : LD %I1.0
ST %Q2.0
%I1.0 %Q2.O
In Ladder language :

In Structured Text language : %Q2.0 := %I1.0 ;

These three Boolean equations are equivalent. Bit object %Q2.0 takes the value
(assignment instruction) of bit object %1.0 (load instruction).

Basic instructions include :


• Boolean instructions (processing on bits),
• Predefined control system timer and counter function blocks,
• Numerical instructions on integers (processing on words and double words),
• Program instructions.
The other instructions are described in section 2, "Description of advanced instructions".

___________________________________________________________________________
1/1
B
1.2 Boolean instructions
1.2-1 Presentation of Boolean instructions
Boolean instructions act on all bit type data (I/O bits, internal bits, etc).
• Test elements, example : N/O contact.
Contact closed when the bit object which controls it is at state 1.
%I1.0
LD %I1.0 %I1.0

• Action elements, example : direct coil.


The associated bit object takes the logic value of the logic result of the test element.
%Q2.0
ST %Q2.0 %Q2.0 :=

• Boolean equation :
The Boolean result of the test elements is applied to the action element.
LD %I1.0 %I1.0 %I1.1 %Q2.0
AND %I1.1
ST %Q2.0 %Q2.0 := %I1.0 AND %I1.1 ;

Rising and falling edges


Test instructions can be used to detect rising or falling edges on PLC I/O bits or internal bits.
Rising edge sensing contact : Falling edge sensing contact :
%I1.0 %I1.0
LDR %I1.0 P
RE %I1.0 LDF %I1.0 N
FE %I1.0

• For all inputs (discrete, counter, etc) : an edge is detected when the state of the bit
has changed between scan n-1 and the current scan n. It remains detected during
the current scan (see part A, section 1.3-2).
Rising edge : detects a change of the Falling edge : detects a change of the
controlling input from 0 to 1. controlling input from 1 to 0.

%I1.0 time time


%I1.0

Boolean 1 task scan Boolean 1 task scan


result result
time time

• For outputs or internal bits : detection of an edge is independent of the task scan.
A rising or falling edge on internal bit %Mi is detected when its state has changed
between two read operations. This rising or falling edge remains detected as long
as the internal bit is not scanned in the action zone.
• Do not perform a SET or RESET on an object whose rising or falling edge is being
tested (in Ladder language and Instruction List language).
___________________________________________________________________________
1/2
Description of basic instructions 1

B
1.2-2 Instruction format
Boolean instructions are described in the following way :

The instruction described appears in bold


type. Each equation is illustrated using the
different languages.

Load instructions
These instructions correspond to :
• N/O contacts : contact closed when the bit object which controls it is at state 1.
• ...
Ladder language Instruction List language

%I1.1 %Q2.3
LD %I1.1
ST %Q2.3
%M0 %Q2.2
LDN %M0
ST %Q2.2

Structured Text language

%Q2.3 := %I1.1 ;
%Q2.2 := NOT %M0 ;

Authorized operands Timing diagram

Code Operand
LD %I,%Q,%M,%S,%BLK,%•:Xk, %Xi LD LDN
LDN %I,%Q,%M,%S,%BLK,%•:Xk, %Xi
%I1.1 %M0

%Q2.3 %Q2.2

List of operands Timing diagram


0/1 immediate value 0 (false) or 1 (true) The 4 timing diagrams have been
%I PLC input %Ix.i grouped together.
%Q PLC output %Qx.i Timing diagram for
LD the LD instruction
%M internal bit %Mi
%S system bit %Si Input state
%BLK standard function block bit (eg : %I1.1
%TMi.Q) or DFB instance bit
%•:Xk word extract bit, eg : %MWi:Xk Output state
%Xi step bit, macro-step bit (%XMi) or
%Q2.3
step of macro-step bit (%Xj.i)
___________________________________________________________________________
1/3
B
1.2-3 Load instructions
These instructions correspond to :
• N/O contacts : contact closed when the bit object which controls it is at 1.
• N/C contacts : contact closed when the bit object which controls it is at 0.
• Rising edge contacts : detects a change of the controlling bit from 0 to 1.
• Falling edge contacts : detects a change of the controlling bit from 1 to 0.

Ladder language Instruction List language

%I1.1 %Q2.3
LD %I1.1
%M0 %Q2.2 ST %Q2.3
LDN %M0
ST %Q2.2
%I1.2 %Q2.4 LDR %I1.2
ST %Q2.4
P
LDF %I1.3
%I1.3 %Q2.5 ST %Q2.5
N

Structured Text language

%Q2.3 := %I1.1 ;
%Q2.2 := NOT %M0 ;
%Q2.4 := RE %I1.2 ;
%Q2.5 := FE %I1.3 ;

Authorized operands Timing diagram

Code Operand P N

LD %I,%Q,%M,%S,%BLK,%•:Xk, %Xi (1) LD LDN LDR LDF


LDN %I,%Q,%M,%S,%BLK,%•:Xk, %Xi (1)
P LDR %I,%Q,%M %I1.1 %M0 %I1.2 %I1.3
N LDF %I,%Q,%M

(1) True (1)/False (0) in Instruction List or %Q2.3 %Q2.2 %Q2.4 (2) %Q2.5 (2)
Structured Text language

(2) Set to 1 during 1 cycle


___________________________________________________________________________
1/4
Description of basic instructions 1

B
1.2-4 Assignment instructions
These instructions correspond to :
• Direct coils : the associated bit object takes the value of the result of the equation.
• Negated coils : the associated bit object takes the inverse value of the result of the
equation.
• Set (latch) coils : the associated bit object is set to 1 when the result of the equation is at 1.
• Reset (unlatch) coils : the associated bit object is set to 0 when the result of the
equation is at 1.

Ladder language Instruction List language

%I1.1 %Q2.3
LD %I1.1
ST %Q2.3
%Q2.2
STN %Q2.2
%Q2.4
S %Q2.4
S
%I1.2 %Q2.4 LD %I1.2
R R %Q2.4

Equivalent in Structured Text language

%Q2.3 := %I1.1 ;
%Q2.2 := NOT %I1.1 ;
IF %I1.1 THEN
SET %Q2.4 ;
END_IF ;
IF %I1.2 THEN
RESET %Q2.4 ;
END_IF ;

Authorized operands Timing diagram

Code Operand
S R
ST %I,%Q,%M,%S,%•:Xk
ST STN S R
STN %I,%Q,%M,%S,%•:Xk
S S %I,%Q,%M,%S,%•:Xk, %Xi (1)
%I1.1 %I1.1 %I1.1 %I1.2
R R %I,%Q,%M,%S,%•:Xk, %Xi (1)

(1) Only in preprocessing.


%Q2.3 %Q2.2 %Q2.4
___________________________________________________________________________
1/5
B
1.2-5 Logic AND instructions
These instructions perform :
• A logic AND between the operand and the Boolean result of the preceding instruction.
• A logic AND between the inverse of the operand and the Boolean result of the
preceding instruction.
• A logic AND between the rising edge of the operand and the Boolean result of the
preceding instruction.
• A logic AND between the falling edge of the operand and the Boolean result of the
preceding instruction.

Ladder language Instruction List language

%I1.1 %M1 %Q2.3 LD %I1.1


AND %M1
ST %Q2.3
%M2 %I1.2 %Q2.2 LD %M2
ANDN %I1.2
ST %Q2.2
%I1.3 %I1.4 %Q2.4 LD %I1.3
P ANDR %I1.4
ST %Q2.4
%M3 %I1.5 %Q2.5
LD %M3
N ANDF %I1.5
ST %Q2.5

Structured Text language

%Q2.3 := %I1.1 AND %M1 ;


%Q2.2 := %M2 AND (NOT %I1.2) ;
%Q2.4 := %I1.3 AND (RE %I1.4) ;
%Q2.5 := %M3 AND (FE %I1.5) ;

Note : The parentheses are optional but make the program easier to read.

Authorized operands Timing diagram

Code Operand P N
AND %I,%Q,%M,%S,%BLK,%•:Xk, %Xi (1)
AND ANDN ANDR ANDF
ANDN %I,%Q,%M,%S,%BLK,%•:Xk, %Xi (1)
P ANDR %I,%Q,%M %I1.1 %M2 %I1 .3 %M3

N ANDF %I,%Q,%M
%M1 %I1.2 %I1.4 %I1.5
(1) True (1)/False (0) in Instruction List or
Structured Text language %Q2.3 %Q2.2 %Q2.4 (2) %Q2.5 (2)

(2) Set to 1 during 1 cycle

___________________________________________________________________________
1/6
Description of basic instructions 1

B
1.2-6 Logic OR instructions
These instructions perform :
• A logic OR between the operand and the Boolean result of the preceding instruction.
• A logic OR between the inverse of the operand and the Boolean result of the
preceding instruction.
• A logic OR between the rising edge of the operand and the Boolean result of the
preceding instruction.
• A logic OR between the falling edge of the operand and the Boolean result of the
preceding instruction.

Ladder language Instruction List language


%I1.1 %Q2.3
LD %I1.1
OR %M1
%M1 ST %Q2.3
%M2 %Q2.2
LD %M2
ORN %I1.2
%I1.2 ST %Q2.2

%I1.3 %Q2.4 LD %I1.3


ORR %I1.4
%I1.4 ST %Q2.4
P
%M3 %Q2.5 LD %M3
ORF %I1.5
%I1.5 ST %Q2.5
N

Structured Text language


%Q2.3 := %I1.1 OR %M1 ;
%Q2.2 := %M2 OR (NOT %I1.2) ;
%Q2.4 := %I1.3 OR (RE %I1.4) ;
%Q2.5 := %M3 OR (FE %I1.5) ;

Note : The parentheses are optional but make the program easier to read.

Authorized operands Timing diagram


Code Operand
OR %I,%Q,%M,%S,%BLK,%•:Xk, P N
%Xi (1)
OR ORN ORR ORF
ORN %I,%Q,%M,%S,%BLK,%•:Xk,
%Xi (1)
%I1.1 %M2 %I1.3 %M3
ORR %I,%Q,%M
P
%M1 %I1.2 %I1.4 %I1.5
ORF %I,%Q,%M
N
%Q2.3 %Q2.2 %Q2.4 %Q2.5
(1) True (1)/False (0) in Instruction List or Structured Text language
___________________________________________________________________________
1/7
B
1.2-7 Exclusive OR instructions
These instructions perform :
• An exclusive OR between the operand and the Boolean result of the preceding
instruction.
• An exclusive OR between the inverse of the operand and the Boolean result of the
preceding instruction.
• An exclusive OR between the rising edge of the operand and the Boolean result of
the preceding instruction.
• An exclusive OR between the falling edge of the operand and the Boolean result of
the preceding instruction.

Note :
There are no specific graphic elements for the exclusive OR in Ladder language. However, the
exclusive OR can be programmed by using a combination of N/O and N/C contacts (see example
below).

Ladder language equivalent Instruction List language

%I1.1 %M 1 %Q2.3 LD %I1.1


XOR %M1
%M1 %I1.1 ST %Q2.3

%M2 %I1.2 %Q2.2 LD %M2


XORN %I1.2
%I1.2 %M2 ST %Q2.2

LD %I1.3
XORR %I1.4
Structured Text language ST %Q2.4

LD %M3
%Q2.3 := %I1.1 XOR %M1 ;
XORF %I1.5
%Q2.2 := %M2 XOR (NOT %I1.2) ;
ST %Q2.5
%Q2.4 := %I1.3 XOR (RE %I1.4) ;
%Q2.5 := %M3 XOR (FE %I1.5) ;

Note : The parentheses are optional but make the program easier to read.

Authorized operands Timing diagram

Code Operand XOR XORN XORR XORF


XOR %I,%Q,%M,%S,%BLK,%•:Xk, %Xi
%I1.1 %M2 %I1.3 %M3
XORN %I,%Q,%M,%S,%BLK,%•:Xk, %Xi
XORR %I,%Q,%M
%M1 %I1.2 %I1.4 %I1.5
XORF %I,%Q,%M

%Q2.3 %Q2.2 %Q2.4 %Q2.5


___________________________________________________________________________
1/8
Description of basic instructions 1

B
1.3 Predefined function blocks
1.3-1 Programming principles for predefined function blocks
The function blocks use bit objects and specific words.
Control system function blocks are %Ci
pre-programmed in the PLC and therefore
R E
occupy a particular zone of the user
memory. S
In order to optimize memory occupation, C.P : 9999 D
CU
the type and number of function blocks MODIF : Y
used must be defined at the outset, within CD F
the limits imposed by the system (via the
Configuration and Data editors). Up/down counter block

There are six types of control system function block :

Type of block Max TSX 37 Max TSX 57 See section


Timer %TMi 64 (1) 255 (1) 1.3-2
Up/down counter %Ci 32 255 1.3-3
Monostable %MNi 8 255 2.2-1
Register %Ri 4 255 2.2-2
Drum controller %DRi 8 255 2.2-3
Timer (Series 7) %Ti 64 (1) 255 (1) 2.2-4
(1) The total number of %TMi + %Ti timers must be less than or equal to 64 on the TSX 37 and
less than or equal to 255 on the TSX 57.

Each block contains :


• Inputs (eg : IN) which are used to control
it.
%I1.1 %TM1 %Q2.3
• Outputs (eg : Q) which indicate its state.
Each output has an associated output IN Q
bit (eg : %TM1.Q) which can be tested SR2
by the user program. In addition, each c
output can control one or more coils
(eg : %Q2.3 and SR2).
• Parameters which are used to adapt it to
the application (preset, time base etc).
The parameters of function blocks (preset, current value, etc) are displayed within the
block. In Instruction List language, predefined blocks are programmed using instructions
(see part A, section 3.2-6).

___________________________________________________________________________
1/9
B
1.3-2 Timer function block %TMi
Timers have three operating modes :
• TON : this mode is used to control
%TMi
on-delay actions. This delay is
IN Q programmable and can be modified via
MODE:TON
TB: 1mn the terminal.
• TOF : this mode is used to control
TM.P:9999 off-delay actions. This delay is
MODIF:Y
programmable and can be modified via
the terminal.
Timer block • TP : this mode is used to create a pulse
of an exact duration. This duration is
programmable and can be modified via
the terminal.

Characteristics

Timer number %TMi 0 to 63 for a TSX 37, 0 to 254 for a TSX 57


Mode TON • on-delay (default)
TOF • off-delay
TP • monostable
Time base TB 1min (default), 1s, 100ms, 10ms (max of
16 timers when 10ms). The smaller the time
base, the greater the accuracy of the timer.
Current value %TMi.V Word which increments from 0 to %TMi.P
when the timer is running. Can be read and
tested but not written by the program (1).
Preset value %TMi.P 0<%TMi.P<9999. Word which can be read,
tested and written by the program. It is set to
9999 by default. The time period or delay
generated is equal to %TMi.P x TB.
Adjust via the terminal Y/N Y : the preset value can be modified %TMi.P
(MODIF) in adjust mode.
N : no access in adjust mode.
Setting input IN The timer starts on a rising edge (TON or TP
(instruction) mode) or a falling edge (TOF mode).
Timer output Q Associated bit %TMi.Q is set to 1 depending
on the function performed TON, TOF or TP.

(1) %TMi.V can be modified via the terminal.

___________________________________________________________________________
1/10
Description of basic instructions 1

B
Using as an on-delay timer : TON mode
The timer is started on a rising edge at
input IN : its current value %TMi.V increases
from 0 to %TMi.P by one unit on each pulse
IN
of the time base TB. Output bit %TMi.Q
changes to 1 when the current value
reaches %TMi.P and then remains at 1 as Q
long as input IN is at 1.
%TMi.P
When input IN is at 0, the timer is stopped,
even if its value is still changing : %TMi.V %TMi.V
takes the value 0.

Using as an off-delay timer : TOF mode


The current value %TMi.V is set to 0 on a
rising edge at input IN (even if the timer is
still running). The timer is started on a
IN
falling edge at input IN.
The current value increases to %TMi.P by
one unit on each pulse of the time base TB. Q
Output bit %TMi.Q changes to 1 when a
rising edge is detected on input IN and the %TMi.P
timer returns to 0 when the current value %TMi.V
reaches %TMi.P.

Using as a monostable : TP mode


The timer is started on a rising edge at
input IN : (if the timer has not already
started) its current value %TMi.V increases
IN
from0 to %TMi.P by one unit on each pulse
of the time base TB. Output bit %TMi.Q
changes to 1 when the timer is started and Q
returns to 0 when the current value reaches
%TMi.P. %TMi.P
When input IN and output %TMi.Q are at %TMi.V
0, TMi.V takes the value 0.
This monostable cannot be reset.

___________________________________________________________________________
1/11
B
Programming and configuration
Timer function blocks are programmed in the same way, irrespective of the mode of use
selected. TON, TOF or TP mode can be chosen in the variables editor.

• Configuration
The following parameters must be entered in the variables editor :
- Mode : TON, TOF or TP.
- TB : 1min, 1s, 100ms or 10ms.
- %TMi.P : 0 to 9999.
- MODIF : Y or N.

• Programming
Ladder language Instruction List language

%TM1 LD %I1.1
%I1.1 %Q2.3
IN %TM1
IN Q
LD %TM1.Q
ST %Q2.3
TON

Structured Text language

IF RE %I1.1 THEN
START %TM1 ;
ELSIF FE %I1.1 THEN
DOWN %TM1 ;
END_IF ;
%Q2.3 := %TM1.Q ;

The START %TMi instruction generates a rising edge on the timer block input IN.
The DOWN %TMi instruction generates a falling edge on the timer block input IN.

___________________________________________________________________________
1/12
Description of basic instructions 1

B
Special cases
• Effect of a cold restart : (%S0=1) forces the current value to 0, sets output %TMi.Q
to 0 and the preset value is reset to the value defined during configuration.
• Effect of a warm restart : (%S1=1) has no effect on the current value of the timer
nor on the preset value. The current value does not change during a power outage.
• Effect of a PLC stop, de-activation of a task or execution of a break point : does
not freeze the current value.
• Effect of a program jump : the fact of not scanning the instructions where the timer
block is programmed does not freeze the current value %TMi.V, which continues to
increment to %TMi.P. Similarly, bit %TMi.Q associated with output Q of the timer block
maintains its normal operation and can thus be tested by another instruction.
However, the output wired directly to the block output is neither activated nor scanned
by the PLC.
• Testing bit %TMi.Q : it is advisable to test bit %TMi.Q once only in the program.
• Effect of modifying the preset %TMi.P : modifying the preset value via an instruction
or in adjust mode only takes effect when the timer is next activated : modifying the
preset value in the variables editor is only taken into account after a cold restart
(%S0=1).

___________________________________________________________________________
1/13
B
1.3-3 Up/down counter function block %Ci
The up/down counter function block is
used to upcount and downcount events. %Ci
These two operations can be simultaneous. R E

S
C.P : 9999 D
CU
MODIF : Y
CD F

Up/down counter block

Characteristics

Counter number %Ci 0 to 31 for a TSX 37, 0 to 254 for a TSX 57


Current value %Ci.V Word incremented or decremented according
to inputs CU and CD.
Can be read and tested but not written by the
program (1).
Preset value %Ci.P 0<%Ci.P<9999. Word can be read, tested and
written. (default value 9999)
Adjust via terminal Y/N Y : the preset value can be modified in
(MODIF) adjust mode.
N : no access in adjust mode.
Reset input R At state 1 : %Ci.V = 0.
(instruction)
Preset input S At state 1: %Ci.V = %Ci.P.
(instruction)
Upcount input CU Increments %Ci.V on a rising edge.
(instruction)
Downcount input CD Decrements %Ci.V on a rising edge.
(instruction)
Underflow output E (Empty) The associated bit %Ci.E=1 when downcounter
%Ci.V changes from 0 to 9999 (set to 1 when
%Ci.V reaches 9999, and reset to 0 if the
counter continues to downcount).(2)
Preset reached D (Done) The associated bit %Ci.D=1 when
output %Ci.V=%Ci.P.
Overflow output F (Full) The associated bit %Ci.F =1 when %Ci.V
changes from 9999 to 0 (set to 1 when %Ci.V
reaches 0, and reset to 0 if the counter
continues to upcount).

(1) %Ci.V can be modified via the terminal.


(2) When there is an upcount overflow or downcount underflow, bit %S18 changes to 1.
___________________________________________________________________________
1/14
Description of basic instructions 1

B
Operation
• Upcount : when a rising edge appears at the upcounting input CU, the current value
is incremented by one unit. When this value is equal to the preset value %Ci.P, the
"preset reached" output bit %Ci.D assigned to output D changes to state 1. Output
bit %Ci.F (upcount overflow) changes to state 1 when %Ci.V changes from 9999 to
0, and is reset to 0 if the counter continues to upcount.
• Downcount : when a rising edge appears at the downcounting input CD, the current
value %Ci.V is decremented by one unit. Output bit %Ci.E (downcount underflow)
changes to state 1 when %Ci.V changes from 0 to 9999, and is reset to 0 if the counter
continues to downcount.
• Up/down count : to use both the upcount and the downcount functions simultaneously,
the two corresponding inputs CU and CD must be controlled. These two inputs are
then scanned in succession. If they are both at 1 simultaneously, the current value
remains unchanged.
• Reset : when input R is set to state 1, the current value %Ci.V is forced to 0, and outputs
%Ci.E, %Ci.D and %Ci.F are at 0. The "reset" input has priority.
• Preset : if "preset" input S is at state 1 and the "reset" input R is at state 0, the current
value %Ci.V takes the value %Ci.P, and output %Ci.D is set to 1.

Note
On resetting (input R or instruction R) :
• In Ladder language, the logs of inputs CU and CD are updated with
the wired values.
• In Instruction List language and Structured Text language, the logs of inputs CU
and CD are not updated. Each one maintains the value it had before being called.

Special cases
• Effect of a cold restart : (%S0=1)
- The current value %Ci.V is set to zero.
- Output bits %Ci.E, %Ci.D and %Ci.F are set to zero.
- The preset value is initialized with the value defined during configuration.
• Effect of a warm restart (%S1=1), a PLC stop, de-activation of a task or execution
of a break point : this has no effect on the current value of the counter (%Ci.V).
• Effect of modifying the preset %Ci.P : modifying the preset value via an instruction
or in adjust mode takes effect when the block is processed by the application
(activation of one of the inputs).

___________________________________________________________________________
1/15
B
Configuration and programming
Counting of a number of items = 5000. Each pulse on input %I1.2 (when internal bit %M0
is at 1) increments the upcounter %C8 up to its final preset value (bit %C8.D=1). The
counter is reset by input %I1.1.

• Configuration
The following parameters must be entered via the variables editor :
- %Ci.P, set to 5000 in this example,
- MODIF : Y.

• Programming
Ladder language Instruction List language

%C8 LD %I1.1
%I1.1
R E R %C8
LD %I1.2
S AND %M0
%I1.2 %M0 C.P : 5000 D CU %C8
CU
LD %C8.D
MODIF : Y
CD F ST %Q2.0

%C8.D %Q2.0

Structured Text language

IF %I1.1 THEN
RESET %C8 ;
END_IF ;
%M1 := %I1.2 AND %M0 ;
IF RE %M1 THEN
UP %C8 ;
END_IF ;
%Q2.0 := %C8.D;

In Structured Text language, 4 instructions are used to program the up/down counter
function blocks :
• RESET %Ci : Resets the current value,
• PRESET %Ci : Loads the preset value into the current value,
• UP %Ci : Increments the current value,
• DOWN %Ci : Decrements the current value.
The CU and CD input logs are reset when the UP and DOWN instructions are used in
Structured Text language. The user must therefore manage the rising edges for these
two instructions.
___________________________________________________________________________
1/16
Description of basic instructions 1

B
1.4 Numerical processing on integers
1.4-1 General
The numerical instructions described in this section apply to objects of the following
type :
• bit tables,
• words,
• double words.
Instructions for other types of object are described in the section "Description of
instructions and advanced functions".

In Ladder language
Numerical instructions are entered in
blocks :
• located in the test zone for comparison
%Q2.2
blocks. %MW50>10
• located in the action zone for operation
blocks. %I1.0
%MW10:=%KW0+10
These blocks can contain :
%I1.2
• a simple expression, eg : N INC%MW100
OP3:=OP1+OP2,
• a complex expression, eg :
OP5:=(OP1+OP2)*OP3-OP4.

In Instruction List language


LD [%MW50>10]
Instructions are placed between square ST %Q2.2
brackets. LD %I1.0
They are executed if the Boolean result of [%MW10:=%KW0+10]
the test instruction preceding the numerical LDF %I1.2
instruction is at 1. [INC %MW100]

In Structured Text language %Q2.2 := %MW50 > 10 ;


Numerical instructions are entered IF %I1.0 THEN
directly. %MW10 := %KW0 + 10 ;
The conditional instruction IF enables END_IF ;
numerical instructions to be conditioned IF FE %I1.2 THEN
INC %MW100 ;
via a Boolean expression.
END_IF ;

___________________________________________________________________________
1/17
B
List of operands
List of bit tables
Abbreviations Full addressing Type of word Access
%M:L %Mi:L table of internal bits R/W
%I:L %Ixy.i:L table of input bits R/W
%Q:L %Qxy.i:L table of output bits R/W
%Xi:L %Xi:L or %Xj.i:L table of step bits R

List of single format words


Abbreviations Full addressing Type of word Access Indexed form
Immed. val. - immediate values R -
%MW %MWi internal word R/W %MWi[index]
%KW %KWi internal constant R %KWi[index]
%SW %SWi system word R/W (1) -
%IW %IWxy.i(.r) input word R -
%QW %QWxy.i(.r) output word R/W -
%NW %NW{j}k common word R/W -
%BLK eg : %TMi.P standard or DFB function R/W (2) -
block extract word
%Xi.T %Xi.T step activity time R %Xi.T [index]
(1) Write depending on i. (2) Write depending on the type of word, for example : preset values
(%Ci.P can be written, whereas the current values %Ci.V can only be read).
List of double words
Abbreviations Full addressing Type of double word Access Indexed form
Immed. val. - immediate values R -
%MD %MDi internal double word R/W %MDi[index]
%KD %KDi internal double constant R %KDi[index]
%SD %SDi system double word R/W (1) -
%ID %IDxy.i(.r) input double word R -
%QD %QDxy.i(.r) output double word R/W -
(1) Only double word %SD18.
Notes
There are other types of words and double words, such as %MWxy.i %KWxy.i and
%MDxy.i %KDxy.i associated with applications. These double words behave like the
words and double words %MWi %KWi and %MDi %KDi respectively.
Implicit conversion of words <--> double words
PL7 software allows mixing of operations using words and double words. Conversion to
one or other of the formats is performed implicitly. An operation involving a double word
or several immediate values is automatically performed internally in double format.
___________________________________________________________________________
1/18
Description of basic instructions 1

B
1.4-2 Comparison instructions
Comparison instructions are used to compare two operands.
> : test if operand 1 is greater than operand 2.
>= : test if operand 1 is greater than or equal to operand 2.
< : test if operand 1 is less than operand 2.
<= : test if operand 1 is less than or equal to operand 2.
= : test if operand 1 is equal to operand 2.
<> : test if operand 1 is different from operand 2.
The result is 1 when the comparison requested is true.
Structure
Ladder language Instruction List language
%Q2.3
%MW10>100 LD [%MW10 > 100]
ST %Q2.3
%M0 %Q2.2 LD %M0
AND [%MW20 < %KW35]
%MW20<%KW35 ST %Q2.2
LD %I1.2
%I1.2 %Q2.4 OR [%MW30 >= %MW40]
ST %Q2.4

%MW30>=%MW40

Comparison blocks are programmed in The comparison is executed inside square


the test zone. brackets following instructions LD, AND
and OR.
Structured Text language

%Q2.3 := %MW10 > 100 ;


%Q2.2 := %M0 AND (%MW20 < %KW35) ;
%Q2.4 := %I1.2 OR (%MW30 >= %MW40) ;

Note : The parentheses are optional but make the program easier to read.

Syntax
Operators : >,>=,<,<=,=,<> Op1 Operator Op2

___________________________________________________________________________
1/19
B
Operands
Type Operands 1 and 2 (Op1 and Op2)
Indexable words %MW,%KW
Non-indexable words Immed.val.,%IW,%QW,%SW,%NW,%BLK, %Xi.T
Numerical expr.
Indexable double words %MD,%KD
Non-indexable double words Immed.val.,%ID,%QD,%SD,Numerical expr.

Notes
• In Ladder language, comparisons can also be executed using the
vertical comparison block (see part B, section 2.3).
• In Instruction List language, comparison instructions can be used in parentheses.

1.4-3 Assignment instructions


These are used to load an Op2 operand into an Op1 operand.
Syntax : Op1:=Op2 <=> Op2->Op1

The following assignment operations can be performed :


• On bit tables
• On words or double words.
Several assignment instructions can be linked within the same block :
Op1:=Op2:=Op3:=Op4:=...
Assignment of bit tables (see bit table object, section 1.2-6, part A)
The following operations on bit tables can be performed :
• Bit table -> bit table example 1
• Bit table -> word or double word (indexed) example 2
• Word or double word (indexed) -> bit table example 3
Structure
Ladder language Instruction List language

LD TRUE
%Q2.0:8:=%M10:8
[%Q2.0:8:= %M10:8] example 1

%I3.2 LD %I3.2
%MW100:=%I1.0:16 [%MW100:= %I1.0:16 ] example 2

%I3.3 LDR %I3.3


P %M100:16:=%KW0 [%M100:16:=%KW0] example 3

___________________________________________________________________________
1/20
Description of basic instructions 1

B
Structured Text language

%Q2.0:8 := %M10:8 ; example 1


IF %I3.2 THEN
%MW100 := %I1.0:16 ; example 2
END_IF ;
IF RE %I3.3 THEN
%M100:16 := %KW0 ; example 3
END_IF ;

Syntax
Operator := Op1:=Op2

Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Bit table %M:L,%Q:L,%I:L %M:L,%Q:L,%I:L, %Xi:L
Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW Immed.val.,%IW,%QW,%SW
%BLK %NW,%BLK, %Xi.T, Num. expr.
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD, Immed.val.,%ID,%QD,%SD
Num. expr.

Rules for use


• The source and target bit tables are not necessarily the same length. If the source
table is longer than the target table, only the least significant bits will be transferred.
Otherwise the target table is completed with 0s.
• Example of assigning a bit table -> a word (or double word) : the bits in the table are
transferred into the word (the low order word for a double word) starting from the right
(first bit of the table to bit 0 of the word). The bits of the word which are not transferred
(length<16 or 32) are set to 0.
• Example of assigning a word -> bit table : the bits of the word are transferred starting
from the right (bit 0 of the word to the first bit of the table).

___________________________________________________________________________
1/21
B
Assignment of words
The following assignment operations on words can be performed :
• word (indexed) -> word (indexed) or double word (indexed) example 1
• double word (indexed) -> double word (indexed) or word (indexed) example 2
• immediate value -> word (indexed) or double word (indexed) example 3

Structure
Ladder language Instruction List language

LD TRUE
%SW112:=%MW100 [%SW112 := %MW100] example 1
LD %I3.2
[%MD0:= %KD0[%MW20] ] example 2
%I3.2
%MD0:=%KD0[%MW20]
Structured Text language
%I3.3
P %MW10:=100 IF RE %I3.3 THEN
%MW10 := 100 ; example 3
END_IF ;

Syntax
Operator := Op1:=Op2
Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW, Immed.val.,%IW,%QW,%SW
%BLK %NW,%BLK,%Xi.T, Num. expr.
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD, Immed.val.,%ID,%QD,%SD
Numerical expr.

Note
Word <--> double word conversions are performed implicitly during double word
--> word assignment. If the value of the double word cannot be contained in the
word, bit %S18 is set to 1.
It is possible to execute multiple assignments.
Example : %MW0 := %MW2 := %MW4
Note that in the example %MD14 := %MW10 := %MD12, it is not necessarily true
that %MD14 := %MD12, as the higher order word of the double word will be lost when
assignment to %MW10 occurs, due to the conversion from a double word to a singleword.

___________________________________________________________________________
1/22
Description of basic instructions 1

B
1.4-4 Arithmetic instructions on integers
These instructions are used to perform arithmetic operations between two operands
or on one operand.
+ : add two operands SQRT : square root of an operand
- : subtract two operands INC : increment of an operand
* : multiply two operands DEC : decrement of an operand
/ : divide two operands ABS : absolute value of an operand
REM : remainder of division of the two operands
Structure
Ladder language Instruction List language

LD %MW0
%M0 [%MW0 := %MW10 + 100]
%MW0:=%MW10+100
LD %I3.2
%I3.2 [%MW0 := SQRT(%MW10)]
%MW0:=SQRT(%MW10)
LDR %I3.3
%I3.3 [INC %MW100]
P INC %MW100

Structured Text language

IF %M0 THEN
%MW0 := %MW10 + 100 ;
END_IF ;
IF %I3.2 THEN
%MW0 := SQRT (%MW10) ;
END_IF ;
IF RE %I3.3 THEN
INC %MW100 ;
END_IF ;

Syntax
Operators
• +, -, *, /, REM Op1:=Op2 Operator Op3

• SQRT, ABS Op1:=Operator(Op2)

• INC, DEC Operator Op1

___________________________________________________________________________
1/23
B
Operands
Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)
Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW, Immed.val.,%IW,%QW,%SW
%BLK %NW,%BLK,%Xi.T, Num. expr.
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD, Immed.val.,%ID,%QD,%SD
Numerical expr.

Note :
The operations INC and DEC cannot be used in numerical expressions.

Rules for use


• Addition : Overflow during operation

If the result exceeds the limits :


-32768 or +32767 for a single length operand,
-2 147 483 648 or +2 147 483 647 for a double length operand,
bit %S18 (overflow) is set to 1. The result is therefore not significant. The user program
manages bit %S18.
Example :
Ladder language Instruction List language

%M0 LD %M0
%MW0:=%MW1+%MW2 [%MW0 := %MW1+ %MW2]
%S18 LDN %S18
%MW10:=%MW0 [%MW10 := %MW0 ]
LD %S18
%S18
[%MW10 := 32767 ]
%MW10:=32767 R %S18
%S18
R

Structured Text language

IF %M0 THEN
%MW0 := %MW1 + %MW2 ;
END_IF ;
IF %S18 THEN
%MW10 := 32767 ; RESET %S18 ;
ELSE
%MW10 := %MW0 ;
END_IF ;

Where %MW1 =23241 and %MW2=21853, the real result (45094) cannot be expressed in a
16-bit word. Bit %S18 is set to 1 and the result obtained (-20442) is incorrect. In this example,
when the result is greater than 32767, its value is set to 32767.
___________________________________________________________________________
1/24
Description of basic instructions 1

B
• Multiplication :
Overflow during operation.
If the result exceeds the capacity of the result word, bit %S18 (overflow) is set to 1 and
the result is not significant.
• Division/Remainder :
Division by 0.
If the divider is 0, division is impossible and system bit %S18 is set to 1. The result
is then incorrect.
Overflow during operation.
• Square root extraction :
Square root extraction is only performed on positive values. Thus, the result is always
positive. If the square root operand is negative, system bit %S18 is set to 1 and the
result is incorrect.

Note :
• When the result of an operation is not an integer (in the case of division or square root extraction),
the result is rounded down to the nearest integer.
• The sign of the remainder (REM) is that of the numerator.
• The user program is responsible for managing system bit %S18. It is set to 1 by the PLC and
must be reset by the program so that it can be re-used (see previous page for example).

1.4-5 Logic instructions


The associated instructions are used to perform a logic operation between two
operands or on one operand.

AND : AND (bit-wise) between two operands


OR : Logic OR (bit-wise) between two operands
XOR : Exclusive OR (bit-wise) between two operands
NOT : Logic complement (bit-wise) of an operand

Structure
Ladder language Instruction List language

%M0
LD %M0
[%MW0 := %MW10 AND 16#FF00]
%MW0:=%MW10 AND 16#FF00

LD TRUE
[%MW0 := %KW5 OR %MW10]
%MW0:=%KW5 OR %MW10
LD %I1.3
%I1.3 [%MW102:= NOT %MW100]
%MW102:=NOT %MW100

___________________________________________________________________________
1/25
B
Structured Text language

IF %M0 THEN
%MW0 := %MW10 AND 16#FF00 ;
END_IF ;
%MW0 := %KW5 OR %MW10 ;
IF %I1.3 THEN
%MW102 := NOT %MW100 ;
END_IF ;

Syntax
Operators

• AND, OR, XOR, Op1:=Op2 Operator Op3

• NOT, Op1:=NOT Op2

Operands

Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)


Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW, Immed. val.,%IW,%QW,%SW
%BLK %NW,%BLK,%Xi.T,Num. expr.
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD Immed. val.,%ID,%QD,%SD
Num. expr.

___________________________________________________________________________
1/26
Description of basic instructions 1

B
1.4-6 Numerical expressions
Numerical expressions are composed of several numerical operands and the arithmetic
and logic operators described above.
Example : %MW25 * 3 - SQRT(%MW10) + %KW8* (%MW15 + %MW18) AND 16#FF
The number of operators and operands in an arithmetic expression is not limited.
Numerical expressions on integer objects
Operands in the same numerical expression can be both single or double length.
Example : %MW6 * %MW15 + SQRT(%DW6) / (%MW149[%MW8]) + %KD29)
AND 16#FF
An operand or an operation to a single operand can be preceded by the sign + or - (by
default, the sign +).
Example : SQRT (%MW5) * - %MW9
All word objects can be used in arithmetic expressions. Certain words can be indexed.
Execution priority of instructions
In numerical expressions, priority of different instructions is observed. They are
executed in the order described below :

1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8


instruction to * + <,> = AND XOR OR
an operand / - <=,>= <>
REM

In the example below, the instructions are executed following the order of numbering :
SQRT (%MW3) + %MW5 * 7 AND %MW8 OR %MW5 XOR %MW10

1 2
3
4 5
6

Parentheses
Parentheses are used to modify the order in which priorities are executed. Their use
is recommended for structuring numerical expressions.
((%MW5 AND %MW6) + %MW7) * %MW8

1
2
3

___________________________________________________________________________
1/27
B
1.5 Program instructions
1.5-1 Subroutine call
Subroutine call instructions are used to call a subroutine module located in the same
task.

Structure
Ladder language Instruction List language

%M8 SR10 LD %M8


C SR10

Structured Text language

IF %M8 THEN
SR10 ;
END_IF ;

SRi represents the subroutine module called : i (number from 0 to 253).

Rules
• A subroutine can only be called if the subroutine module has already been created.
• A subroutine return is performed on the action immediately following the subroutine
call instruction.
• A subroutine can call another subroutine. The number of cascaded calls is limited
to 8.
• Subroutines are assigned to a task. They can only be called from within the same task.

Principle
Subroutine module Subroutine module
SR 10 SR 12
Call SR 10

Call SR 12

Call SR 10

___________________________________________________________________________
1/28
Description of basic instructions 1

B
1.5-2 Subroutine return
Subroutine return instructions are reserved for subroutine modules and are used to
return to the calling module, if the Boolean result of the preceding test instruction is 1.
Structure
Ladder language Instruction List language

%M8
LD %M8
<RETURN> RETC

Structured Text language

IF %M8 THEN
RETURN ;
END_IF ;

Rule for use


Subroutine return instructions are implicit at the end of each subroutine, but can be used
to return to the calling module before the end of the subroutine.
Example :
Ladder language Instruction List language

LD [%MW5>3]
%MW5>3 <RETURN> RETC
LD %M8
%M8 [%MD26:=%MW4*%KD6]
%MD26:=%MW4*%KD6

Structured Text language

IF (%M5 > 3) THEN


RETURN ;
END_IF ;
IF %M8 THEN
%MD26 := %MW4 * %KD6 ;
END_IF ;

Instruction List language includes the following additional instructions :

RETCN : subroutine return if the Boolean result of the preceding test instruction is 0.
RET : unconditional subroutine return.
___________________________________________________________________________
1/29
B
1.5-3 Program jumps
Jump instructions allow connection to a line of programming identified by a label %Li :
JMP : unconditional program jump,
JMPC : program jump if the Boolean result of the preceding test instruction is 1,
JMPCN : program jump if the Boolean result of the preceding test instruction is 0,
%Li represents the label of the line to which the connection is made (i numbered from
1 to 999 with up to 256 labels).

Structure
Ladder language Instruction List language
%M8 %L10
LD %M8
>> JMPC %L10
%I1.0 %Q2.5 LD %I1.0 Jump to label
ST %Q2.5 %L10 if %M8 is
.............. at 1.
%L10 :
%L10 LD %M20
%M20 %M5 ST %M5
LD %I1.0
AND %I1.2
%I1.0 %I1.2 %Q2.1 ST %Q2.1

Structured Text language


IF %M8 THEN
JUMP %L10 ;
END_IF ; Jump to label %L10,
%Q2.5 := %I1.0 ;
if %M8 is at 1.
%L10 :
%M5 := %M20 ;
%Q2.1 := %I1.0 AND %I1.2 ;

___________________________________________________________________________
1/30
Description of basic instructions 1

B
Ladder language Instruction List language
%M2 %L20
LD %M2
>> JMPCN %L20
%Q3.5 LDN %I2.0 Jump to label
%I2.0
ST %Q3.5 %L20 if %M2 is
.............. at 0.
%L20 :
%L20 LD %M30
%M30 %M6 ST %M6

Structured Text language


IF NOT %M2 THEN
JUMP %L20 ;
END_IF ; Jump to label %L20,
%Q3.5 := NOT %I2.0 ; if %M2 is at 0.
%L20 :
%M6 := %M30 ;

Ladder language Instruction List language

%L40
>> JMP %L40 Unconditional
%L20 :
jump to label
LD %I2.1
%L20
ST %Q3.5 %L40.
%I2.1 %Q3.5
..............
%L40 :
LD %M20
ST %M5
%L40
%M20 %M5

Structured Text language


JUMP %L40 ;

%L20 : Unconditional
%Q3.5 := %I2.1 ;
jump to label %L40,
%L40 :
%M5 := %M20 ;

___________________________________________________________________________
1/31
B
Rules
• A program jump is performed within the same programming entity (main module of
a master task (MAIN), subroutine %SRi, etc).
• A program jump is performed to a line of programming which is downstream or
upstream.
When the jump is upstream, attention must be paid to the program scan time :
the program scan time is then extended and can mean the task period including the
upstream jump is exceeded.

1.5-4 Program end instructions


The end of the execution of a program scan is defined using the instructions END, ENDC
and ENDCN :
END : unconditional end of program
ENDC : end of program if the Boolean result of the preceding test instruction is 1.
ENDCN : end of program if the Boolean result of the preceding test instruction is 0.
By default (normal mode), when the end of program is activated, the outputs are
updated and the next scan is started.
If scanning is periodic, the outputs are updated, the program waits for the end of the
period and the next scan is started.
Note :
These instructions can only be used in Instruction List language in the master task.

Example :
Instruction List language
LD %M1 LD %M1
ST %Q2.1 ST %Q2.1
LD %M2 LD %M2
ST %Q2.2 ST %Q2.2
..................... .....................
END LD %I1.2
ENDC If %I1.2 =1, end of
LD %M2 program scanning.
ST %Q2.2 If %I1.2 =0, continues
.................... program scanning until
END new END instruction.

___________________________________________________________________________
1/32
Description of basic instructions 1

B
1.5-5 Stop program
Execution of an application program can be stopped using the instruction HALT (stops
all tasks). This freezes the variable objects in this program.
A program stopped in this way must be initialized to restart it (using the PL7 command
INIT). Any instructions following the instruction HALT will therefore not be executed.

Structure
Ladder language Instruction List language

LD %M10
%M10
HALT
<HALT>

Structured Text language

IF %M10 THEN
HALT ;
END_IF ;

___________________________________________________________________________
1/33
B
1.5-6 Event masking/unmasking instructions
Event masking/unmasking instructions are used to mask or unmask all the events
which activate event-triggered tasks.
MASKEVT : masks all events. The events are stored by the PLC. However, the
associated event-triggered tasks remain inactive as long as the masking operation is
enabled (until the next UNMASKEVT instruction).
UNMASKEVT : unmasks all events. The events which were stored during the mask
period are processed. The event processing mechanism is operational until the next
MASKEVT instruction.
Structure
Ladder language Instruction List language

%M0
LD %M0
MASKEVT ( )
[MASKEVT()]
%M8
UNMASKEVT ( )
LD %M8
[UNMASKEVT()]

Structured Text language

IF %M0 THEN
MASKEVT ( ) ;
END_IF ;
IF %M8 THEN
UNMASKEVT ( ) ;
END_IF ;

1.5-7 NOP Instruction

The NOP instruction does not perform any operation. It is used for "reserving" lines in
a program which allow the user to insert instructions later without modifying the line
numbers.

___________________________________________________________________________
1/34
Section 22
Description of advanced instructions
2 Description of advanced instructions B
2.1 Presentation of advanced instructions
2.1-1 General
The instructions described in this section are suitable for advanced programming
requirements.
They have the same effect, irrespective of the language used. Only the syntax differs.
They are :
• Either basic instructions of the software.
• Or Functions considered as extensions of the software.
Extended Function type instructions are used to enhance the basic software using
special programming instructions.
• Operations on character strings, word tables, etc.
• Application-specific functions : Communication, Process control, Man-Machine
Interface, etc.
They include the following families :
• Character strings.
• Word tables.
• Management of Dates, times and time periods.
• Conversions.
• Bit tables.
• "Orphee" functions.

• Communication
• Process control ==> see the relevant application-specific function
• Man-Machine Interface
• Motion control

Notes on programming
Function type instructions require additional application memory occupation (only
when they are actually used in the program).
This memory occupation should be taken into account by the programmer for each
function, irrespective of the number used, and the maximum memory size of the
PLC used must be observed.

___________________________________________________________________________
2/1
B
2.2 Advanced predefined function blocks
2.2-1 Monostable function block %MNi

The monostable function block is used to %MNi


create a pulse of an exact duration. S R

This duration is programmable and can TB: 1mn


be modified via the terminal.
MN.P:9999
MODIF:Y

Monostable block

Characteristics

Number %MNi 0 to 7 for a TSX 37, 0 to 254 for a TSX 57


Time base TB 1min, 1s, 100ms, 10ms (1min by default).
Current value %MNi.V Word which decreases from %MNi.P to 0 when
the timer is running. Can be read and tested but
not written.
Preset value %MNi.P 0 < %MNi.P < 9999. Word which can be read,
tested and written. The duration of the pulse
(PRESET) is equal to : %MNi.P x TB.
Edit via terminal Y/N Y : possibility of changing the preset value in
MODIF adjustment mode.
N : no access in adjustment mode.
Start input S(Start) On a rising edge %MNi.V = %MNi.P then
(or instruction) %MNi.V decreases to 0.
Monostable output R(Running) The associated bit %MNi.R is at 1 if %MNi.V > 0
(monostable running)
%MNi.R = 0 if %MNi.V = 0.

Operation
When input S of the monostable is at 1 (rising edge), the current value %MNi.V takes
the preset value %MNi.P and decreases to 0 by one unit on each pulse of the time base
TB. Output bit %MNi.R (Running) assigned to output R changes to 1 when the current
value %MNi.V is other than 0.
When the current value %MNi.V = 0, output bit %MNi.R returns to 0.
Start input S :
S

%MNi.P
Current value %MNi.V : %MNi.V

Running output R : PRESET PRESET PRESET


___________________________________________________________________________
2/2
Description of advanced instructions 2

B
Programming and configuration

• Example of use : flashing at variable


cyclical periods : the preset value of
%Q3.0
each monostable defines the duration 5s 5s
of each pulse. 2s 2s

• Configuration
The following parameters must be entered in the variables editor :
- TB : 1min, 1s, 100ms, 10ms or 1ms (100ms in this example).
- %MNi.P : 0 to 9999 (%MN0.P=50 and %MN1.P=20 in this example).
- MODIF : Y or N.

• Programming
Ladder language Instruction List language

%MN1.R %MN0 %Q3.0


LDN %MN1.R
ANDN %Q3.0
S R
S %MN0
LD %MN0.R
ST %Q3.0
LDN %MN0.R
S %MN1

Structured Text language


%MN0.R %MN1
S R %M0:=NOT %MN1.R ;
IF RE %M0 THEN
START %MN0 ;
END_IF ;
%Q3.0 := %MN0.R ;
%M1 := NOT %MN0.R ;
IF RE %M1 THEN
START %MN1 ;
END_IF ;

In the example above, output %Q3.0 is set to 1 for 5s (%MN0.P) and reset to 0 for 2s
(%MN1.P).
In Structured Text language, the instruction START %Mni is used to start the
monostable function block. This instruction forces a rising edge on input S of the block
and thus reinitializes the function block. Activation of this instruction should therefore
be on a pulse.

___________________________________________________________________________
2/3
B
Note
The monostable function can also be performed by the function block %TMi in TP
mode (see part B, section 1.3-2).

Special cases
• Effect of a cold restart : (%S0 = 1) the preset value %MNi.P is loaded into the
current value %MNi.V. Since the preset value which may have been modified by the
terminal is lost, output %MNi.R is reset to 0.
• Effect of a warm restart : (%S1) has no effect on the current value of the
monostable (%MNi.V).
• Effect of a PLC stop, de-activation of the task and break point : a PLC stop, de-
activation of the current task or execution of a break point does not freeze the current
value.
• Effect of a program jump : the fact of not scanning the rung where the monostable
block is programmed does not freeze current value %MNi.V which continues to
decrease to 0.
Similarly, bit %MNi.R assigned to the monostable block output continues to operate
normally and can thus be tested in another rung.
However, the coils directly "connected" to the block output (eg %Q3.0) will not be
activated since they are not scanned by the PLC.
• Testing bit %MNi.R : the state of this bit can change during a scan.

___________________________________________________________________________
2/4
Description of advanced instructions 2

B
2.2-2 Register function block %Ri
A register is a memory block which is %Ri
used to archive up to 255 words of 16 bits
R E
in two different ways : MODE:LIFO
LEN:16
• Queue, known as FIFO stack (First In, I F
First Out).
O
• Stack, known as LIFO stack (Last In,
First Out).
Register block

Characteristics

Register number %Ri 0 to 3 for a TSX 37, 0 to 254 for a TSX 57


Mode FIFO Queue.
LIFO Stack (default selection).
Length LEN Number of 16-bit words (1- LEN- 255) in the
register memory block.
Input word %Ri.I Register input word. Can be read, tested and
written.
Output word %Ri.O Register output word. Can be read, tested
and written.
Archiving input I (In) On a rising edge, stores the contents of
word
(or instruction) %Ri.I in the register.
Retrieval input O (Out) On a rising edge, loads a data word into word
(or instruction) %Ri.O.
Reset input R (Reset) At state 1 initializes the register.
(or instruction)
Empty output E (Empty) The associated bit %Ri.E indicates that the
register is empty. Can be tested.
Full output F (Full) The associated bit %Ri.F indicates that the
register is full. Can be tested.

Note :
When the two inputs I and O are activated simultaneously, archiving is performed before
retrieval.

___________________________________________________________________________
2/5
B
FIFO (First In, First Out)
The first data item entered is the first to be
retrieved. Example :
When a archiving request is received (rising Archiving of the contents of %Ri.I
edge at input I or activation of instruction I), at the top of the stack.
the contents of input word %Ri.I (which 20
have already been loaded) are stored at the
%Ri.I 20
top of the stack (fig a).
When the stack is full (output F=1), no (a) 80
further archiving is possible and system bit 50
%S18 changes to 1.
When a retrieval request is received (rising Retrieval of the first data item which is
edge at input O or activation of instruction then loaded into %Ri.O.
O) the data word lowest in the stack is
loaded into output word %Ri.O and the 20 (b)
contents of the register are moved down %Ri.0
80
one place in the stack (fig.b).
When the register is empty (output E=1), no 50 50
further retrieval is possible. Output word
%Ri.O does not change and retains its value. 20
The stack can be reset at any time (state 1 80
at input R or activation of instruction R).

LIFO (Last In, First Out)


The last data item entered is the first to be Example :
retrieved. Archiving of the contents of %Ri.I
When a archiving request is received (rising at the top of the stack.
edge at the input or activation of instruction
20
I), the contents of input word %Ri.I (which
have already been loaded) are stored at the %Ri.I 20
top of the stack (fig c). (c) 80
When the stack is full (output F=1), no
50
further archiving is possible and system bit
%S18 changes to 1.
When a retrieval request is received (rising Retrieval of the data word highest in
the stack.
edge at input O or activation of instruction O)
the highest data word (last word to be entered) %Ri.0
is loaded into output word %Ri.O (fig.d). 20 20
When the register is empty (output E=1), no 80
further retrieval is possible. Output word (b)
50
%Ri.O does not change and retains its last
value. The stack can be reset at any time
(state 1 at input R or activation of instruction 80
R). The element indicated by the pointer is 50
then the highest in the stack.
___________________________________________________________________________
2/6
Description of advanced instructions 2

B
Programming and configuration
• Configuration
The following parameters must be entered in the configuration editor :
- Number : 1 to 4 for a TSX 37, 1 to 255 for a TSX 57,
- Length : 1 to 255.
The operating mode (FIFO or LIFO) must be entered in the variables editor.
• Programming
Ladder language Instruction List language

%R2 LD %M1
I %R2
R E LD %I1.3
%M1 O %R2
MOD : LD %I1.3
I LEN : F
ANDN %R2.E
%I1.3 [%MW20:=%R2.O]
O LD %I1.2
ANDN %R2.F
%I1.3 %R2.E [%R2.I:=%MW34]
ST %M1
%MW20:=%R2.O
%I1.2 %R2.F
%R2.I:=%MW34
%M1

Structured Text language


IF RE %M1 THEN
PUT %R2 ;
END_IF ;
IF RE %I1.3 THEN
GET %R2 ;
END_IF ;
IF (%I1.3 AND NOT %R2.E) THEN
%MW20 := %R2.O ;
END_IF ;
%M1 := %I1.2 AND NOT %R2.F ;
IF %M1 THEN
%R2.I := %MW34 ;
END_IF ;

The programming example shows word %MW34 being loaded into %R2.I at the
archiving request %I1.2, if register R2 is not full (%R2.F=0). The archiving request in
the register is made by %M1. The retrieval request is made by input %I1.3 and %R2.O
is loaded into %MW20 if the register is not empty (%R2.E=0).
___________________________________________________________________________
2/7
B
In Structured Text language, 3 instructions are used to program the register function
blocks :
• RESET %Ri : Initializes the register,
• PUT %Ri : Stores the contents of word %Ri.I in the register,
• GET %Ri : Loads a data word into word %Ri.O.
The PUT and GET instructions create a rising edge on inputs I and O respectively of
the function block. Activation of this instruction should therefore be on a pulse.

Special cases
• Effect of a cold restart : (%S0=1) initializes the contents of the register. The Output
bit %Ri.E assigned to output E is set to 1.
• Effect of a warm restart : (%S=1) has no effect on the contents of the register, nor
on the state of its output bits.
• When resetting to 0 (input R or instruction R)
- In Ladder language, the memorized values of inputs I and O are updated with the
actual values.
- In Instruction List language, the memorized values of inputs I and O are not
updated. Each one retains the value it had before being called.
- In Structured Text language, the memorized values of inputs I and O are updated
with 0.

___________________________________________________________________________
2/8
Description of advanced instructions 2

B
2.2-3 Drum controller function block %DRi
The drum controller operates on a similar
principle to an electromechanical drum
controller, which changes step according %DRi
to external events. On each step, the high R F
point of a cam gives an order which is %TB:1mn
executed by the control system. In the U
case of a drum controller, these high LEN:16
points are symbolized by state 1 for each
step and are assigned to output bits %Qi.j
or internal bits %Mi, known as control Drum controller block
bits.

Characteristics

Number %DRi 0 to 7 for a TSX 37, 0 to 254 for a TSX 57


Step number LEN 1 to 16 (default 16).
Time base TB 1min, 1s, 100ms, 10ms (default 1min).
Time envelope %DRi.V 0<%DRi.V<9999. Word is reset on each step
or time period of change. Can be read and tested but not
current step written. The duration is equal to %DRi.V x TB.
Current step %DRi.S 0<%DRi.S<15. Word which can be read and
number tested. Can only be written with an immediate
value.
Return to step 0 R (RESET) At state 1 initializes the drum controller to
input step 0.
Advanced U (UP) On a rising edge, causes the drum controller
input to advance by one step and updates the
control bits.
Output F (FULL) Indicates that the current step equals the last
step defined. The associated bit %DRi.F can
be tested (%DRi.F=1 if %DRi.S=configured
step number - 1).
State of a step %DRi.Wj 16-bit word defining the states of step j of drum
controller i. Can be read and tested but not
written.
Control bits Outputs or internal bits associated with the step
(16 control bits).

Note : Bit %S18 changes to 1, if a non-configured step is written.

___________________________________________________________________________
2/9
B
Operation
The drum controller comprises :
• A matrix of constant data (the cams) organized :
- in columns : in steps from 0 to N-1 (N is the step number configured). Each column
shows the states of the step in the form of 16 data bits numbered 0 to F.
• A list of control bits (1 per line) corresponding to either outputs %Qxy.i, or to internal
bits %Mi. During the current step, the control bits take on the binary states defined
for this step.
The table below summarizes the main characteristics of the drum controller (controller
configured with 16 steps).
Step

Control
Bit bits

In the above example, for step 1, control bits %Q2.1;%Q3.5; %Q2.8;%Q3.6;%M5 and
%M6 are set to state 1. The other control bits are set to 0.
The current step number is incremented on each rising edge at input U (or activation
of instruction U). This number can be modified by the program.
Operating diagram

Input U:

Input R:

Step no. %DRi.S 0 1 2 3 N-1 0 1 2 0 1

Output %DRi.F

Time %DRi.V
envelope

___________________________________________________________________________
2/10
Description of advanced instructions 2

B
Programming and configuration
In this example, the first 5 outputs %Q2.0 to %Q2.4 are activated in succession each
time input %I1.1 is set to 1.
Input I1.0 resets the outputs to step 0.
Configuration
The following information is defined in the variables editor :
• Step number : 5 (LEN:5).
• The state of the outputs (control bits) for each step of the drum controller.
Step Assignment of control bits
0 1 234
0: 1 0 000 %Q2.0
1: 0 1 000 %Q2.1
Bit 2: 0 0 100 %Q2.2
3: 0 0 010 %Q2.3
4: 0 0 001 %Q2.4
• Time base (TB:1 min).

Programming
Ladder language Instruction List language

LD %I1.0
%I1.0 %DR1 %Q2.8 R %DR1
LD %I1.1
R F
U %DR1
%I1.1 %TB:1 mn LD %DR1.F
U ST %Q2.8
LEN:5

Structured Text language

IF %I1.0 THEN
RESET %DR1 ;
END_IF ;
IF RE %I1.1 THEN
UP %DR1 ;
END_IF ;
%Q2.8 := %DR1.F ;

In Structured Text language, 2 instructions are used to program the drum controller
function blocks :
• RESET %DRi : Initializes the controller to step 0,
• UP %DRi : Advances the controller by one step and updates the control bits.
This instruction creates a rising edge on input U of the function block : activation of
this instruction should therefore be on a pulse.
___________________________________________________________________________
2/11
B
Note
When resetting to 0 (input R, instruction R or RESET instruction)
• In Ladder language, the memorized value of input U is updated with the actual
values.
• In Instruction List language, the memorized value of input U is not updated. It
retains the value it had before being called.
• In Structured Text language, the memorized value of input U is updated with 0.

Special cases
• Effect of a cold restart : (%S0=1) resets the drum controller to step 0 (with updating
of the control bits).
• Effect of a warm restart : (%S1=1) updates the control bits, according to the current
step.
• Effect of a program jump, de-activation of the task and break point : the fact of
not scanning the drum controller means that the control bits are not reset to 0.
• Updating the control bits : only occurs when there is a change of step or in the case
of a cold or warm restart.

___________________________________________________________________________
2/12
Description of advanced instructions 2

B
2.2-4 Timer function block %Ti (Series 7)
This timer function block, which is
compatible with Series 7 PL7-2/3 blocks %Ti
is used to provide control for time-delayed E D
actions. TB:1mn
The value of this delay is programmable C R
and can be modified via the terminal. T.P:9999
MODIF:Y

Timer block

Characteristics

Number %Ti 0 to 63 for a TSX 37, 0 to 254 for a TSX 57


Time base TB 1min, 1s, 100ms, 10ms (default 1min).
Current value %Ti.V Word which decreases from %Ti.P to 0 when the
timer is running. Can be read and tested but not
written.
Preset value %Ti.P 0 < %Ti.P < 9999. Word which can be read, tested
and written. It is set to value 9999 by default. The
duration is equal to %Ti.P*TB.
Adjust via terminal Y/N Y : the preset value can be modified in adjust
MODIF mode.
N : no access in adjust mode.
Setting input E(Enable) At state 0, resets the timer %Ti.V = %Ti.P.
Control input C(Control) At state 0, freezes the current value %Ti.V.
Timer output D(Done) Associated bit %Ti.D = 1, if timer done %Ti.V = 0
done
Timer running R(Running) Associated bit %Ti.R = 1 if timer %Ti.P > %Ti.V > 0
output and if input C is at 1.

Note :
%Ti function blocks cannot be programmed in Instruction List language. The objects of %Ti
blocks (%Ti.V, %Ti.P, %Ti.D and %Ti.R) can, however, be accessed.

The total number of %TMi + %Ti should be less than 64 on the TSX 37 and less than 255 on the
TSX 57.

___________________________________________________________________________
2/13
B
Operation
The timer changes when its two inputs (E
E
and C) are at 1. It behaves like a
downcounter. C
• Current value %Ti.V decreases from %Ti.P
the preset %Ti.P to 0, by one unit on %Ti.V
each pulse of the time base TB. %Ti.D
• Output bit %Ti.R (Timer running)
%Ti.R
assigned to output R is then at state 1
and output bit %Ti.D (Timer done) E 0 0 1 1
assigned to output D is at state 0. C 0 1 0 1
• When current value %Ti.V= 0, %Ti.D
%Ti.P %Ti.V %Ti.V %Ti.V %Ti.V
changes to 1 and %Ti.R returns to 0.
= = frozen decr. from
%Ti.V %Ti.P %Ti.P %Ti.P -> 0
Standard operations
%Ti.D 0 0 0 1 if Timer
The Timer function block can be
done
programmed to perform the following
functions : %Ti.R 0 0 0 1 if Timer
running
• On-time delay
Ladder language

%I1.0 = E,C
%I1.0 %T0 %Q2.0
E D R

TB =1mn PRESET PRESET


C R D = %Q2.0
%Ti.P = 3
MOD:N

Structured Text language

IF %I1.0 THEN
START %T0 ;
ELSE
PRESET %T0 ;
END_IF ;
%Q2.0 := %T0.D ;

___________________________________________________________________________
2/14
Description of advanced instructions 2

B
• Off-time delay
Ladder language

% I1.1
%I1.1 %T7 %Q2.1
E D E,C

R
TB =1s
C R PRESET
%Ti.P = 120 D
MOD:N
%Q2.1

Structured Text language

IF %1.1 THEN
PRESET %T7 ;
ELSE
START %T7 ;
END_IF ;
%Q2.1 := NOT %T7.D ;

• Cumulated on-time delay


Ladder language

% I1.2 = E

%I1.2 %T5 %Q2.4 %I1.3 = C


E D
%Q2.5 = R
%I1.3 TB =1mn %Q2.5 D1 D2 D3
C R
%Q2.4 =D
%Ti.P = 3
MOD:N PRESET = D1 + D2 + D3

Structured Text language

IF %I1.2 THEN
IF %I1.3 THEN
START %T5 ;
ELSE
STOP %T5 ;
END_IF ;
ELSE
PRESET %T5 ;
END_IF ;
%Q2.4 := %T5.D ;
%Q2.5 := %T5.R ;
___________________________________________________________________________
2/15
B
• Cumulated off-time delay
Ladder language

% I1.0
%I1.0 %T12 %Q2.4
E
E D
%I1.1
%I1.1 TB =10mn
C R C
%Ti.P = 40
MOD:Y
R
D1 D2 D3
D
Structured Text language
%Q2.1

IF %I1.0 THEN PRESET = D1 + D2 + D3


PRESET %T12 ;
ELSE
IF %I1.1 THEN
STOP %T12 ;
ELSE
START %T12 ;
END_IF ;
END_IF ;
%Q2.4 := NOT %T12.D ;

In Structured Text language, 3 instructions are used to program the timer function
blocks %Ti :
• PRESET %Ti : Resets the timer,
• START %Ti : Starts the timer running,
• STOP %Ti : Freezes the current value of the timer.

Special cases
• Effect of a cold restart : (%S0 = 1) the preset value (defined by the variables editor)
is loaded into the current value and output %Ti.D is set to 0, since the preset value
which may have been modified by the terminal is lost.
• Effect of a warm restart : (%S1) has no effect on the current value of the timer.
• Effect of a PLC stop : a PLC stop, de-activation of the current task or execution of
a break point does not freeze the current value.
• Effect of a program jump : the fact of not scanning the rung where the timer block
is programmed does not freeze current value %Ti.V which continues to decrease
to 0.
Similarly, bits %Ti.D and %Ti.R assigned to timer block outputs D and R continue
to operate normally and can thus be tested in another rung.
However, the coils directly "connected" to the block outputs will not be activated
since they are not scanned by the PLC.
• Testing bits %Ti.D and %Ti.R : the state of these bits can change during a scan.
___________________________________________________________________________
2/16
Description of advanced instructions 2

B
2.3 Vertical comparison blocks
Vertical comparison blocks are used to
compare two operands (OP). COMPARE
EN >
These two operands are either 16-bit
OP1 =
words (possibly indexed) or immediate
values. OP2 <

<>

The number of vertical comparison blocks is neither limited nor numbered.

Characteristics

Command input EN At state 1, compares the two operands.


Greater than output > Is at state 1 if the contents of OP1 are greater
than those of OP2.
Equal to output = Is at state 1 if the contents of OP1 are equal to
those of OP2.
Less than output < Is at state 1 if the contents of OP1 are less than
those of OP2.
Different from output <> Is at state 1 if the contents of OP1 are different
from those of OP2.
Operand no. 1 OP1 This operand is a single length word object (it can
be indexed).
Operand no. 2 OP2 This operand is a single length word object (it can
be indexed).

___________________________________________________________________________
2/17
B
Operation
When the command input is set to 1, the two operands are compared and the four
outputs are activated according to the result of the comparison. Setting the command
input to 0 resets the activated outputs.
• Example of use
The program below shows the comparison of word %MW2 indexed by word
%MW40 with the immediate value 150.
If the contents of %MW2[%MW40] are greater than 150 and %I1.3 = 1, coil %Q2.7
is activated.
If the contents are equal to 150, coil %MW10:X4 is activated. Coil %M5 is only
controlled if the contents are different from 150 (< or >).
Ladder language

%I1.3 %Q2.7
EN >
This function block does not exist in
%MW10:X4 Instruction List language or Structured
%MW2 = Text language. Use comparison
[%MW40] operations >, <, =, <>
<
150 %M5
<>

Special cases
• Effect of a cold restart : (%S0) operand OP1 and possibly OP2 (if OP2 is an internal
word) are reset and the outputs are activated according to the result of their
comparison with the new values.
• Effect of a warm restart : (%S1) has no effect on the comparison block.

___________________________________________________________________________
2/18
Description of advanced instructions 2

B
2.4 Shift instructions
Shift instructions consist of moving bits of a word or double word operand a certain
number of positions to the right or to the left.
• Logic shift :
- SHL(op2,i) logic shift of i positions to 15 (or 31) 0
the left.
- SHR(op2,i) logic shift of i positions to
%S17 0
the right.
• Circular shift :
- ROL(op2,i) circular shift of i positions %S17
to the left.
- ROR(op2,i) circular shift of i positions
to the right.
0
If the operand to be shifted is a single
length operand, the variable i will be
between 1 and 16. %S17
If the operand to be shifted is a double 15 (or 31) 0
length operand, the variable i will be
between 1 and 32.
The state of the last output bit is stored in %S17
bit %S17.
Structure
Ladder language Instruction List language

%I1.1 LDR %I1.1


P %MW0:=SHL(%MW10,5) [%MW0 := SHL(%MW10,5)]

%I1.2 Structured Text language


P %MW10:=ROR(%KW9,8)
IF RE %I1.2 THEN
%MW10 := ROR (%KW9,8) ;
END_IF ;
Syntax
Operators SHL,SHR,ROL,ROR Op1:=Operator(Op2,i)
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW, Immed.val.,%IW,%QW,%SW
%BLK %NW,%BLK, Num. expr.
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD, Immed.val.,%ID,%QD,%SD
Numeric expr.
___________________________________________________________________________
2/19
B
2.5 Floating point instructions
2.5-1 General
PL7 software is used to perform operations on floating point objects.
The floating point object format used is that of standard IEEE STD 734-1985
(equivalent to IEC 559). Words are 32 bits long, which corresponds to single length
floating point numbers.

Floating point values can be represented with or without exponent, they must always
contain a point (floating point).

Examples of floating point values :


without exponent : 1285.28
with exponent : 1.28528e3

Floating point values are between -3.402824e+38 and -1.175494e-38, and


1.175494e-38 and 3.402824e+38 (grayed out values on the diagram). They also have
the value 0 noted 0.0.
-1.#DN 1.#DN
-1.#INF 1.#INF

-3.402824e+38 -1.175494e-38 0 +1.175494e-38 +3.402824e+38

When the result of a calculation is between -1.175494e-38 and 1.175494e-38, it is


rounded to 0. A value between these limits cannot be entered as a floating point value
if it is entered in another format. In floating point, the symbol 1.#DN or - 1.#DN will be
displayed.
When the result of a calculation is :
• less than -3.402824e+38, the symbol -1.#INF (for - infinity) is displayed
• greater than +3.402824e+38, the symbol 1.#INF (for + infinity) is displayed
When the result of an operation is undefined (for example, a square root or negative
number) the symbol 1.#NAN or -1.#NAN is displayed.

System bit %S18 is set to 1 when the result is not within the valid limits. The bits of
status word %SW17 indicate the cause of a fault on a floating point operation:
%SW17:X0 = invalid operation, the result is not a number (1.#NAN or -1.#NAN)
%SW17:X1 = operand not standardized (between -1.175494e-38 and 1.175494e-38),
the result is rounded to 0.
%SW17:X2 = division by 0, the result is ±infinity (-1.#INF or 1.#INF)
%SW17:X3 = result is greater than +3.402824e+38 as an absolute value, the result
is ±infinity (-1.#INF or 1.#INF)
%SW17:X4 = result is less than 1.175494e-38, the result is 0.
%SW17:X5 = imprecise result
This word is reset to 0 by the system after a cold start and by program for reuse.

___________________________________________________________________________
2/20
Description of advanced instructions 2

B
Representation is accurate to 2-24 . When viewing floating point numbers, no more than
six digits can be displayed after the comma.
Notes
• The value "1285" is interpreted as an integer value. To be considered as a floating
point value it must be written : "1285.0",
• The conversion instructions Integer <--> Floating Point are used to change from
one format to the other.

Addressing floating point objects

Abbreviations Full Type of floating Access Indexed form


addressing point
Immed. val. - immediate values R -
%MF %MFi internal floating point val. R/W %MFi[index]
%KF %KFi floating point constant R %KFi[index]

Possibility of overlap between objects :


The single and double length and floating %MW0
%MF0
point words are stored within the data %MW1
area in a single memory zone. Thus, %MF1
%MW2
floating point word %MFi corresponds to %MF2
single length words %MWi and %MWi+1 %MW3
%MF3
(word %MWi containing the least
significant bits and word %MWi+1 %MWi
containing the most significant bits of %MFi
%MWi+1
word %MFi).

Examples :
%MF0 corresponds to %MW0 and %MW1
%KF543 corresponds to %KW543 and
%KW544.

___________________________________________________________________________
2/21
B
2.5-2 Floating point comparison instructions
Comparison instructions are used to compare two operands.
> : test if operand 1 is greater than operand 2.
>= : test if operand 1 is greater than or equal to operand 2.
< : test if operand 1 is less than operand 2.
<= : test if operand 1 is less than or equal to operand 2.
= : test if operand 1 is equal to operand 2.
<> : test if operand 1 is different from operand 2.
The result is 1 when the comparison requested is true.
Structure
Ladder language Instruction List language
%Q2.3
LD [%MF10 > 129.7]
%MF10>129.7 ST %Q2.3
LD %M0
AND [%MF20 < %KF35]
%M0 %Q2.2
ST %Q2.2
%MF20<%KF35 LD %I1.2
OR [%MF30 >= %MF40]
%I1.2 %Q2.4 ST %Q2.4

The comparison is executed inside square


%MF30>=%MF40 brackets following instructions LD, AND
and OR.

The comparison blocks are programmed Structured Text language


in the test zone.
%Q2.3 := %MF10 > 129.7 ;
%Q2.2 := (%MF20 < %KF35) AND %M0 ;
%Q2.4 := (%MF30 >= %MF40) OR %I1.2 ;
Syntax
Operators >,>=,<,<=,=,<> Op1 Operator Op2

Operands

Type Operands 1 and 2 (Op1 and Op2)


Indexable floating point objects %MF,%KF
Non-indexable floating point objects Floating point immediate value.
Floating point numeric expression.

Note
In Instruction List language, comparison instructions can be used in parentheses.

___________________________________________________________________________
2/22
Description of advanced instructions 2

B
2.5-3 Floating point assignment instructions
The following floating point assignment operations can be performed :
• floating point (indexed) -> floating point (indexed) example 1
• floating point immediate value -> floating point (indexed) example 2
Structure
Ladder language Instruction List language

LD TRUE
%MF10:=%KF100 [%MF10 := %KF100] example 1

LD %I3.2
%I3.2 [%MF5:= %KF0[%MW20] ] example 1
%MF5:=%KF0[%MW20]
LDR %I3.3
%I3.3 [%MF100:=150.25] example 2
P %MF100:=150.25

Structured Text language


%MF10 := %KF100 ; example 1
IF %I3.2 THEN
%MF5 := %KF0 [%MW20] ; example 1
END_IF ;
IF RE %I3.3 THEN
%MF100 := 150.25 ; example 2
END_IF ;

Syntax
Operator := Op1:=Op2
Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Indexable floating point values %MF %MF,%KF
Non-indexable floating point Floating point immediate value.
values Floating point numeric expr.
It is possible to execute multiple assignments.
Example : %MF0 := %MF2 := %MF4

___________________________________________________________________________
2/23
B
2.5-4 Floating point arithmetic instructions
These instructions are used to perform arithmetic operations between two operands
or on one operand.
+ : add two operands SQRT : square root of an operand
- : subtract two operands ABS : absolute value of an operand
* : multiply two operands TRUNC : integer part of a floating value
/ : divide two operands
Structure
Ladder language Instruction List language
%M0
LD %M0
%MF0:=%MF10+129.7 [%MF0 := %MF10 + 129.7]
%I3.2
LD %I3.2
%MF1:=SQRT(%MF10)
[%MF1 := SQRT(%MF10)]
%I3.3
LDR %I3.3
P
P %MF2:=ABS(%MF20)
[%MF2 := ABS(%MF20)]
%I3.5
LDR %I3.5
P %MD8:=TRUNC(%MF2) [%MD8 := TRUNC(%MF2)]

Structured Text language


IF %M0 THEN
%MF0 := %MF10 + 129.7 ;
END_IF ;
IF %I3.2 THEN
%MF1 := SQRT (%MF10) ;
END_IF ;
IF RE %I3.3 THEN
%MF2 := ABS (%MF20) ;
END_IF ;
IF RE %I3.5 THEN
%MD8 := TRUNC (%MF2) ;
END_IF ;

Syntax
Operators

• +,-,*,/ Op1:=Op2 Operator Op3

• SQRT, ABS, TRUNC Op1:=Operator(Op2)

___________________________________________________________________________
2/24
Description of advanced instructions 2

B
Operands
Type Operand 1 (Op1) Operands 2 and 3 (Op2 and 3)
Indexable words %MF (1) %MF,%KF
Non-indexable words Floating point immediate value.
Floating point numeric expression.
(1) %MD for the TRUNC instruction.

Rules for use


• Operations on floating point values and on integers cannot be directly mixed.
Conversion operations convert to one or other of these formats (see section 2.6,
part B).
• System bit %S18 is controlled in the same way as for integer operations (see section
1.4-4, part B), word %SW17 indicates the cause of the fault (see section 2.5-1, part B).

2.5-5 Logarithmic and exponential instructions


These instructions can be used to carry out logarithmic and exponential operations.
LOG : base 10 logarithm, EXP : natural exponential,
LN : natural logarithm, EXPT: exponentiation of an actual value by an integer,

Structure
Ladder language Instruction List language
LD %M0
%M0 [%MF0 := LOG(%MF10)]
%MF0:=LOG(%MF10)
LD %I3.2
%I3.2
[%MF2 := LN(%MF20)]
%MF2:=LN(%MF20)

%I3.3
LDR %I3.3
[%MF4 := EXP(%MF40)]
P %MF4:=EXP(%MF40)

%I3.4 LDR %I3.4


[%MF6 := EXPT(%MF50,5)]
P %MF6:=EXPT(%MF50,5)

Structured Text language


IF %M0 THEN
%MF0 := LOG(%MF10) ;
END_IF ;
IF %I3.2 THEN
%MF2 := LN(%MF20) ;
END_IF ;
IF RE %I3.3 THEN
%MF4 := EXP(%MF40) ;
END_IF ;
IF RE %I3.4 THEN
%MF6 := EXPT(%MF50,5) ;
END_IF ;
___________________________________________________________________________
2/25
B
Syntax
Operators
• LOG, EXP, LN Op1:=Operator(Op2)

• EXPT Op1:=Operator(Op2,Op3)
Operands
Type Operand 1 (Op1) Operand 2 (Op2) Operand 3 (Op3)
Indexable words %MF %MF,%KF %MW, %KW
Non-indexable words Fl. point immed. value Integer immed. value
Fl. point. num. expr. Integer numeric expr.

Rules of use
• When the operand of the function is an invalid value (for example, logarithm of a
negative number), it produces an indeterminate or infinite result and sets bit %S18
to 1. Word %SW17 indicates the cause of the fault (see section 2.5-1, part B).
• In the case of logarithm functions, for values close to 1.0 (between 0.99 and 1.0 or
1.0 and 1.01) the result will be 0, and bits %S18 and %SW17:X5 are set to 1.

2.5-6 Trigonometric instructions


These instructions can be used to carry out trigonometric operations.
SIN : sine of an angle expressed in radians ASIN : arc sine (result between -π/2 and π/2)
COS : cosine of an angle expressed in radians ACOS : arc cosine (result between 0 and π)
TAN: tangent of an angle expressed in radians ATAN : arc tangent (result between -π/2 and π/2)

Structure
Ladder language Instruction List language

LD %M0
%M0
[%MF0 := SIN(%MF10)]
%MF0:=SIN(%MF10)
%I3.2
LD %I3.2
[%MF2 := TAN(%MF10)]
%MF2:=TAN(%MF10)

%I3.3 LDR %I3.3


[%MF4 := ATAN(%MF20)]
P %MF4:=ATAN(%MF20)

___________________________________________________________________________
2/26
Description of advanced instructions 2

B
Structured Text language

IF %M0 THEN
%MF0 := SIN(%MF10) ;
END_IF ;
IF %I3.2 THEN
%MF2 := TAN(%MF10) ;
END_IF ;
IF RE %I3.3 THEN
%MF4 := ATAN(%MF20) ;
END_IF ;

Syntax
Operators
• SIN, COS, TAN Op1:=Operator(Op2)
ASIN, ACOS, ATAN
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MF %MF,%KF
Non-indexable words Floating point immediate value
Floating point numeric expression

Rules of use
• When the operand of the function is an invalid value (for example, arc cosine of a
number greater than 1), it produces an indeterminate or infinite result and sets bit
%S18 to 1. Word %SW17 indicates the cause of the fault (see section 2.5-1, part B).
• The SIN/COS/TAN functions accept an angle between -4096 π and 4096π as a
parameter but their precision decreases progressively for angles outside the range
-2 π and +2π due to the imprecision caused by modulo 2 π which is carried out on the
parameter before every operation.

___________________________________________________________________________
2/27
B
2.5-7 Conversion instructions
These instructions can be used to carry out conversion operations:
DEG_TO_RAD : conversion from degrees to radians, the result is the value of the angle between
0 and 2π
RAD_TO_DEG : conversion from radians to degrees, the result is the value of the angle between
0 and 360 degrees

Structure
Ladder language Instruction List language

LD %M0
[%MF0 := DEG_TO_RAD(%MF10)]

LD %M2
[%MF2 := RAD_TO_DEG(%MF20)]

Structured Text language

IF %M0 THEN
%MF0 := DEG_TO_RAD(%MF10) ;
END_IF ;
IF %I3.2 THEN
%MF2 := RAD_TO_DEG(%MF20) ;
END_IF ;

Syntax
Operators
• DEG_TO_RAD Op1:=Operator(Op2)
RAD_TO_DEG

Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MF %MF,%KF
Non-indexable words Floating point immediate value
Floating point numeric expression

Rules of use
• The angle to be converted must be between -737280.0 and +737280.0 (for DEG_TO_RAD
conversions) or between -4096π and 4096π (for RAD_TO_DEG conversions).
For values outside these limits, the result displayed will be + 1.#NAN, with bits %S18
and %SW17:X0 set to 1.
___________________________________________________________________________
2/28
Description of advanced instructions 2

B
2.6 Numeric conversion instructions
2.6-1 BCD <--> Binary conversion instructions
There are six types of conversion instruction :
• BCD_TO_INT : 16-bit BCD number --> 16-bit integer conversion.
• INT_TO_BCD : 16-bit integer --> 16-bit BCD number conversion.
• DBCD_TO_DINT : 32-bit BCD number --> 32-bit integer conversion.
• DINT_TO_DBCD : 32-bit integer --> 32-bit BCD number conversion.
• DBCD_TO_INT : 32-bit BCD number --> 16-bit integer conversion.
• INT_TO_DBCD : 16-bit integer --> 32-bit BCD number conversion.

Review of the BCD code :


The BCD (Binary Coded Decimal) code represents a decimal digit (0 to 9) by coding 4 bits. A
16-bit word object can thus contain a number expressed in 4 digits (0< N < 9999).
Decimal 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Example :
• Word %MW5 expresses the BCD value "2450" which corresponds to the binary
value : 0010 0100 0101 0000.
• Word %MW12 expresses the decimal value "2450" which corresponds to the binary
value : 0000 1001 1001 0010.
Word %MW5 is converted to word %MW12 using instruction BCD_TO_INT.
Word %MW12 is converted to word %MW5 using instruction INT_TO_BCD.

Structure
Conversion operations are performed as follows :

Ladder language Instruction List language

%MW0:=BCD_TO_INT(%MW10) LD TRUE
[%MW0 := BCD_TO_INT(%MW10)]
%I1.2
LD %I1.2
%MW10:=INT_TO_BCD(%KW9) [%MW10 := INT_TO_BCD(%KW9)]

Structured Text language

%MW0 := BCD_TO_INT (%MW10) ;


IF %I1.2 THEN
%MW10 := INT_TO_BCD (%KW9) ;
END_IF ;

___________________________________________________________________________
2/29
B
Syntax
Operators (conversion of a 16-bit number)
• BCD_TO_INT Op1:=Operator(Op2)
INT_TO_BCD
INT_TO_DBCD

Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Indexable words %MW %MW,%KW, %Xi.T
Non-indexable words %QW,%SW,%NW, %BLK Immed. val.,%IW,%QW,%SW
%NW,%BLK, Num. expr.
Indexable double words %MD
Non-indexable double words %QD, %SD

Syntax
Operators (conversion of a 32-bit number)
• DBCD_TO_DINT Op1:=Operator(Op2)
DINT_TO_DBCD
DBCD_TO_INT

Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Indexable words %MW
Non-indexable words %QW,%SW,%NW, %BLK

Indexable double words %MD %MD, %KD


Non-indexable double words %QD, %SD Immed. val.,%ID,%QD,%SD
Numeric expr.

Application examples
The BCD_TO_INT instruction is used to process a setpoint value at PLC inputs via
BCD encoded thumbwheels.
The INT_TO_BCD instruction is used to display numeric values (for example, the
result of a calculation or the current value of a function block) on BCD coded displays.

___________________________________________________________________________
2/30
Description of advanced instructions 2

B
Rules for use
• BCD-->Binary conversion
The BCD-->Binary conversion instructions ensure that the conversion operator is
applied to a BCD coded value. If the value is not a BCD coded value, system bit
%S18 is set to 1 and the result gives the value of the first faulty 4-bit byte.
Eg : BCD_TO_INT(%MW2) where %MW2=4660 gives a result of 1234.
However, %MW2=242 (16#00F2) sets %S18 to 1 and the result is 15.

For the DBCD_TO_INT instruction, if the BCD number is greater than 32767, system
bit %S18 is set to 1 and value -1 is loaded in the result.
• Binary--> BCD conversion
The INT_TO_BCD instruction ensures that the conversion operator is applied to a
value between 0 and 9999 (or 0 and 9999 9999). If this is not the case, system bit
%S18 is set to 1 and the result gives the value of the input parameter.
Eg : INT_TO_BCD(%MW2) where %MW2=2478 gives a result of 9336.
However, %MW2=10004 sets %S18 to 1 and the result is 10004.
For the INT_TO_DBCD instruction, if the input parameter is negative, system bit
%S18 is set to 1 and the result gives the value of the input parameter.

2.6-2 Integer <--> Floating point conversion instructions


There are four conversion instructions :
• INT_TO_REAL : integer word --> floating point word conversion.
• DINT_TO_REAL : integer double word --> floating point word conversion.
• REAL_TO_INT : floating point word --> integer word conversion (the result is the
nearest algebraic value).
• REAL_TO_DINT : floating point word --> integer double word conversion (the result
is the nearest algebraic value).
Structure
Ladder language Instruction List language

LD TRUE
%MFO:=INT_TO_REAL(%MW10) [%MF0 := INT_TO_REAL(%MW10)]

%I1.8 LD %I1.8
%MD4:=REAL_TO_DINT(%MF9) [%MD4 := REAL_TO_DINT(%MF9)]

Structured Text language

%MF0 := INT_TO_REAL (%MW10) ;


IF %I1.8 THEN
%MD4 := REAL_TO_DINT (%MF9) ;
END_IF ;

___________________________________________________________________________
2/31
B
Syntax
Operator Op1:=INT_TO_REAL(Op2)
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed. val.,%IW,%QW,%SW
%NW,%BLK,Num. expr.
Indexable floating point words %MF
Example : integer word --> floating point word conversion : 147 --> 1.47e+02

Operator Op1:=DINT_TO_REAL(Op2)

Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MD,%KD
Non-indexable words Val.imm.,%ID,%QD,%SD
Numeric expr.
Indexable floating point words %MF
Example : integer double word --> floating point word conversion : 68905 000 --> 6.8905e+07

Operator Op1:=REAL_TO_INT(Op2)
Op1:=REAL_TO_DINT(Op2)

Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MW
Non-indexable words %QW,%NW,%BLK
Indexable double words %MD
Non-indexable double words %QD
Indexable floating point words %MF,%KF
Non-indexable floating point words Floating point immed. value
Example : floating point word --> integer word conversion 5978.6 --> 5978
floating point word --> integer double word conversion -1235978.6 --> -1235979
Note : If, during conversion of a real word to an integer (or a real word to a whole double word),
the floating point value exceeds the limits of the word (or double word), bit %S18 is set to 1.

___________________________________________________________________________
2/32
Description of advanced instructions 2

B
2.6-3 Gray --> Integer conversion instructions
The instruction GRAY_TO_INT converts a word in Gray code to an integer (pure
binary code).
Review of Gray code : Gray or "reflected binary" code is used to code a changing
numeric value into a series of binary configurations which are distinguished from each
other by the change of state of a single bit. This code is used, for example, to avoid
the following random conditions : in pure binary code, the value 0111 changing to
1000 may generate random values between 0 and 1000 since the bits do not change
value at exactly the same time.

Decimal 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Gray 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101

Structure
Ladder language Instruction List language

LD TRUE
%MW0:=GRAY_TO_INT(%MW10) [%MW0 := GRAY_TO_INT(%MW10)]

Structured Text language

%MW0 := GRAY_TO_INT (%MW10) ;

Syntax
Operator Op1:=GRAY_TO_INT(Op2)
Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Indexable words %MW %MW,%KW
Non-indexable words %QW,%SW,%NW,%BLK Immed.val.,%IW,%QW,%SW
%NW,%BLK,%Xi.T,Num. expr.

___________________________________________________________________________
2/33
B
2.6-4 Word <--> double word conversion instructions
The instructions described below can be used for purely symbolic objects (eg DFB
function blocks). For addressable objects, overlap mechanisms (for example, double
word %MD0 comprises words %MW0 and %MW1) mean that these instructions
cannot be used.

• Instructions for extracting a low order word from a double word


The LW instruction extracts the low order word from a double word and transfers it
to a single word.
Syntax Op1:=LW(Op2)

Op1 = single length word (WORD type)


Op2 = double length word (DWORD type)

Example : Tank_pressure:=LW(Parameter_1)
if Parameter_1 = 16#FFFF1234, Tank_pressure = 16#1234

• Instructions for extracting a high order word from a double word


The HW instruction extracts the high order word from a double word and transfers
it to a single word.
Syntax Op1:=HW(Op2)

Op1 = single length word (WORD type)


Op2 = double length word (DWORD type)

Example : Tank_pressure:=LW(Parameter_1)
if Parameter_1 = 16#FFFF1234, Tank_pressure = 16#FFFF

• Instructions for the concatenation of 2 words


The CONCATW instruction concatenates 2 single words and transfers them to a
double word.
Syntax Op1:=CONCATW(Op2,Op3)

Op1 = double length word (DWORD type)


Op2 = single length word (WORD type)
Op3 = single length word (WORD type)

Example : Tank_pressure:=LW(Parameter_1,Parameter_2)
if Parameter_1 = 16#1234, Parameter_1 = 16#FFFF,
Tank_pressure = 16#FFFF1234

___________________________________________________________________________
2/34
Description of advanced instructions 2

B
2.7 Word table instructions
2.7-1 General
PL7 software is used to perform operations on tables of :
• words,
• double words,
• floating point words.
Word tables are sequences of adjacent %KW10 16 bits
words of the same type and of a defined
length, L.
%KW14
Example of word tables : %KW10:5

Type Format Maximum Size Write


address access
Internal words Single length %MWi:L i+L< Nmax (1) Yes
Double length %MDi:L i+L< Nmax-1 (1) Yes
Floating point %MFi:L i+L< Nmax-1 (1) Yes
Constant words Single length %KWi:L i+L< Nmax (1) No
Double length %KDi:L i+L< Nmax-1 (1) No
Floating point %KFi:L i+L< Nmax-1 (1) No
System words Single length %SW50:4 (2) - Yes

(1) Nmax = maximum number of words defined during software configuration.


(2) Only words %SW50 to %SW53 can be addressed in table form.

General rules for operations on tables


• Table operations are only performed on tables containing objects of the same type.
• Table operations can only be performed on a maximum of two tables.
• If the tables in an operation are of different sizes, the result table will correspond to
the smaller of the two tables.
• The user should avoid performing operations on tables which overlap (for example :
%MW100[20]:=%MW90[20]+%KW100[20]).
• Operations on two tables are performed on each element in the same row of the two
tables and the result is transferred to the element in the same row of the result table.
• If, during an operation between two elements, system bit %S18 is set to 1, the result
for this operation is incorrect, but operations on the following elements will be
performed correctly.
• If one of the operands is a numeric expression it must be placed in parentheses.
• The row of a word in a table corresponds to the position of the word in the table. The
first position corresponds to row 0.

___________________________________________________________________________
2/35
B
2.7-2 Word table assignment
The following can be assigned to word tables :
• immediate value -> word table (indexed) example 1
double format immediate value -> double word table (indexed)
floating point immediate value -> floating point table (indexed)
Example 1 : %MW0 :5:= 100

100 %MW0
100
100 100
100
100 %MW4

• word (indexed) -> word table (indexed) example 2


double word (indexed) -> double word table (indexed)
floating point (indexed) -> floating point table (indexed)
Example 2 : %MW0 :5:= %MW11

100 %MW0
%MW11 100
100 100
100
100 %MW4

• word table (indexed) -> word table (indexed) example 3


double word table (indexed) -> double word table (indexed)
floating point table (indexed) -> floating point table (indexed)
Example 3 : %MW0 :5:= %KW0:5

%KW0 100 100 %MW0


200 200
0 0
10 10
%KW4 100 100 %MW4

Note :
Multiple assignments are authorized in examples 1 and 2
(%MW0:4 := %MW10:6 := %MW100) but not in example 3.

___________________________________________________________________________
2/36
Description of advanced instructions 2

B
Structure
Ladder language Instruction List language

LD TRUE
%MW0:5:=100 [%MW0 :5:= 100] example 1

LD %I3.2
%I3.2
[%MW0:5 := %MW11] example 2
%MW0:5:=%MW11
Structured Text language
%I3.3
P %MW0:5:=%KW0:5 IF RE %I3.3 THEN
%MW0:5 := %KW0:5 ; example 3
END_IF ;

Syntax
Operator := Op1 := Op2
Word tables

Type Operand 1 (Op1) Operand 2 (Op2)


Tables of indexable words %MW:L %MW:L,%KW:L,%Xi.T:L
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed.val.,%IW,%QW,%SW
%NW,%BLK,Num. expr.

Double word tables

Type Operand 1 (Op1) Operand 2 (Op2)


Tables of indexable words %MD:L %MD:L,%KD:L
Indexable double words %MD,%KD
Non-indexable double words Immed.val.,%ID,%QD,
Numeric expr.

Floating point word tables

Type Operand 1 (Op1) Operand 2 (Op2)


Tables of floating point words %MF:L %MF:L,%KF:L
Indexable floating point words %MF,%KF
Non-indexable floating point Floating point immed.val.
words Floating point numeric expr.

Note :
Multiple assignments on tables are prohibited.

___________________________________________________________________________
2/37
B
2.7-3 Arithmetic instructions on tables
These instructions are used to perform an arithmetic operation between two word
table (or word and word table) type operands.
+ : add * : multiply
- : subtract / : divide
REM : remainder of division
Structure
Ladder language Instruction List language
%M0 LD %M0
%MW0:10:=%MW20:10+100 [%MW0:10:=%MW20:10+100]
%I3.2
LD %I3.2
%MD50:5:=%KD0:5+%MD0:5 [%MD50:5:=%KD0:5 + %MD0:5]
%I3.3
Structured Text language
P %MW0:10:=%KW0:10*%MW20

IF RE %I3.3 THEN
%MW0:10 := %KW0:10 * %MW20 ;
END_IF ;

Syntax

Operators

• +,-,*,/,REM Op1:=Op2 Operator Op3

Operands

Word tables

Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)


Tables of indexable words %MW:L %MW:L,%KW:L,%Xi.T:L
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed.val.,%IW,%QW,%SW
%NW,%BLK,Num. expr.

Double word tables

Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)


Tables of indexable words %MD:L %MD:L,%KD:L
Indexable double words %MD,%KD
Non-indexable double words Immed.val.,%ID,%QD,
Numeric expr.

___________________________________________________________________________
2/38
Description of advanced instructions 2

B
2.7-4 Logic instructions on tables
The associated instructions are used to perform a logic operation between two word
table (or word and word table) type operands.
AND : AND (bit-wise).
OR : Logic OR (bit-wise).
XOR : Exclusive OR (bit-wise).
NOT : Logic complement (bit-wise) of a table (only one operand).
Structure
Ladder language Instruction List language

%M0 LD %M0
%MW0:5:=%KW0:5AND16#FF00 [%MW0:5:=%KW0: 5 AND 16#FF00]

%I3.2 Structured Text language


%MD0:10:=%KD5:10OR%MD50:10

%I3.3 IF %I3.2 THEN


%MD0:10 := %KD5:10 OR %MD50:10 ;
P %MW100:50:=NOT%MW0:50 END_IF ;
IF RE%I3.3 THEN
%MW100:50 := NOT %MW0:50 ;
END_IF ;
Syntax
Operators

AND, OR, XOR Op1:=Op2 Operator Op3

NOT Op1:=NOT Op2

Operands

Word tables

Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)


Tables of indexable words %MW:L %MW:L,%KW:L,%Xi.T:L
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed.val.,%IW,%QW,%SW
%NW,%BLK,Num. expr.

Double word tables

Type Operand 1 (Op1) Operands 2 & 3 (Op2 and 3)


Tables of indexable words %MD:L %MD:L,%KD:L
Indexable double words %MD,%KD,%SD
Non-indexable double words Immed.val.,%ID,%QD,
Numeric expr.
___________________________________________________________________________
2/39
B
2.7-5 Summing function on tables
The SUM and SUM_ARR functions add together all the elements in a word table :
• If the table comprises single format words, the result is given in the form of a single
format word (SUM function).
• If the table comprises doubles words, the result is given in the form of a double word
(SUM function).
• If the table comprises floating point words, the result is given in the form of a floating
point word (SUM_ARR function).

Structure
Ladder language Instruction List language

%I3.2
LD %I3.2
%MW5:=SUM(%MW32:12)
[%MW5:=SUM(%MW32:12)]

Structured Text language


%MD50:=SUM(%KD50:20)
%MD50 := SUM (%KD50:20) ;

%MF0:=SUM_ARR(%KF8:5) %MF0 := SUM_ARR (%KF8:5) ;

Syntax
Function Res:=SUM(Tab) Res:=SUM_ARR(Tab)
Parameters

Type Result (Res) Table (Tab)


Tables of indexable words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW
Non-indexable words %QW,%SW,%NW
Tables of indexable double words %MD:L,%KD:L
Indexable double words %MD
Non-indexable double words %QD,%SD
Tables of indexable floating pt words %MF:L,%KF:L
Indexable floating point words %MF
Note : Bit %S18 is set to 1 when the result exceeds the limits of the word or double word format
depending on the table operand.

Example %MW5:=SUM(%MW30:4), with %MW30= 10, %MW31= 20,


%MW32= 30, %MW33= 40,%MW5=10+20+30+40=100

___________________________________________________________________________
2/40
Description of advanced instructions 2

B
2.7-6 Table comparison functions
The EQUAL (on an integer) and EQUAL _ARR(on a floating point) functions compare
two tables element by element.

If a difference is detected, the row of the first elements which are not the same is given
in the form of a word. Otherwise, the value given is equal to -1.

The third parameter provides the row from which the comparison begins (for example,
0 to start at the beginning). This third parameter is optional (it is not authorized for the
EQUAL_ARR function). If it is omitted, the comparison is performed on all of the table.

Structure
Ladder language Instruction List language
%I3.2 LD %I3.2
%MW5:=EQUAL(%MW20:7,%KW0:7,3) [%MW5:=EQUAL(%MW20:7,%KW0:7,3)]

%MW0:=EQUAL(%MD20:7,%KD0:7) Structured Text language

%MW0 := EQUAL (%MD20:7,%KD0:7)


%MF1:=EQUAL_ARR(%MF0:5,%KF0:5)
%MW1 := EQUAL_ARR(%MF0:5,%KF0:5)

Syntax

Function Res:=EQUAL(Tab1,Tab2,row)

Res:=EQUAL_ARR(Tab1,Tab2)

___________________________________________________________________________
2/41
B
Parameters
Type Result (Res) Table (Tab) Row
Tables of words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW %MW,%KW, %Xi.T
Non-indexable words %QW,%SW, Immed. val. %QW,
%NW %IW,%SW,%NW
Numeric expr.
Tables of double words %MD:L,%KD:L
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD Immed. val. %QD,
%ID,%SD
Numeric expr.
Tables of floating point words %MF:L,%KF:L
Floating point words %MF

Note :
• The tables must be the same length.
• If the row parameter is greater than the size of the tables, the result is then equal to this row.

Example %MW5:=EQUAL(%MW30:4,%KW0:4,1)

0 %MW30= 10 %KW0= 20
1 %MW31= 20 %KW1= 20
2 %MW32= 30 %KW2= 30
3 %MW33= 40 %KW3= 60 ==> %MW33 • %KW3==> %MW5= 3

___________________________________________________________________________
2/42
Description of advanced instructions 2

B
2.7-7 Find functions on tables
There are 11 find functions :
• FIND_EQW : find the position in a word table of the first element equal to a given
value.
• FIND_GTW : find the position in a word table of the first element greater than a given
value.
• FIND_LTW : find the position in a word table of the first element less than a given
value.
• FIND_EQD : find the position in a double word table of the first element equal to a
given value.
• FIND_GTD : find the position in a double word table of the first element greater than
a given value.
• FIND_LTD : find the position in a double word table of the first element less than a
given value.
• FIND_EQR: find the position in a floating point word table of the first element equal
to a given value.
• FIND_GTR : find the position in a floating point word table of the first element greater
than a given value.
• FIND_LTR : find the position in a floating point word table of the first element less
than a given value.
• FIND_EQWP : find the position in a word table of the first element equal to a value
given from a row.
• FIND_EQDP : find the position in a double word table of the first element equal to
a value given from a row.
The result of these instructions is the row of the first element found or -1 if the find is
unsuccessful.

Structure
Ladder language Instruction List language

%I3.2 LD %I3.2
%MW5:=FIND_EQW(%MW20:7,%KW0)
[%MW5:=FIND_EQW(%MW20:7,%KW0)]

Structured Text language


%I1.2
%MW0:=FIND_GTD(%MD20:7,%KD0) IF %I1.2 THEN
%MW0:=FIND_GTD(%MD20:7,%KD0) ;
END_IF ;

%MW1:=FIND_LTR(%MF40:5,%KF5) %MW1:=FIND_LTR(%MF40:5,%KF5) ;

%MW9:=FIND_EQWP(%MW30:8,%KF5,%MW4);

___________________________________________________________________________
2/43
B
Syntax
Function
FIND_EQW,FIND_GTW,FIND_LTW Res:=Function(Tab,Val)
FIND_EQD,FIND_GTD,FIND_LTD
FIND_EQR,FIND_GTR,FIND_LTR

FIND_EQWP,FIND_EQDP Res:=Function(Tab,Val,row)

Parameters
Tables of words (FIND_EQW,FIND_GTW,FIND_LTW,FIND_EQWP )
Type Result (Res) Table (Tab) Value (Val), row
Tables of indexable words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW %MW,%KW, %Xi.T
Non-indexable words %QW,%SW Immed. val.%QW,
%NW %IW,%SW,%NW,
Numeric expr.

Tables of double words (FIND_EQD,FIND_GTD,FIND_LTD,FIND_EQDP)

Type Result (Res) Table (Tab) Value (Val)


Tables of indexable words %MD:L,%KD:L
Indexable (double) words %MW %MD,%KD
Non-indexable (double) words %QW,%SW Immed. val. %QD,
%NW %ID,%SD
Numeric expr.
Note : for the row, see table of words (as for FIND_EQWP)

Tables of floating point words (FIND_EQR,FIND_GTR,FIND_LTR)

Type Result (Res) Table (Tab) Value (Val)


Tables of floating point words %MF:L,%KF:L
Indexable floating point words %MW %MF,%KF
Non-indexable floating point %QW,%SW Immed. val.
words %NW Numeric expr.

Example %MW5:=FIND_EQW(%MW30:4,%KW0)
Row
0 %MW30= 10
1 %MW31= 20
2 %MW32= 30 ==> %KW0= 30 ==>%MW5= 2
3 %MW33= 40
___________________________________________________________________________
2/44
Description of advanced instructions 2

B
2.7-8 Find maximum and minimum values function on tables
There are six find functions :
• MAX_ARW : find the maximum value in a word table.
• MIN_ARW : find the minimum value in a word table.
• MAX_ARD : find the maximum value in a double word table.
• MIN_ARD : find the minimum value in a double word table.
• MAX_ARR : find the maximum value in a floating point table.
• MIN_ARR : find the minimum value in a floating point table.
The result of these instructions is equal to the maximum (or minimum) value found in
the table.
Structure
Ladder language Instruction List language
%I3.2
LD %I3.2
%MW5:=MAX_ARW(%MW20:7) [%MW5:=MAX_ARW(%MW20:7)]

%I1.2 Structured Text language


%MD0:=MIN_ARD(%MD20:7)
IF %I1.2 THEN
%MD0 := MIN_ARD (%MD20:7) ;
END_IF ;
%MF8:=MIN_ARR(%MF40:5) %MF8 := MIN_ARR (%MF40:5) ;

Syntax

Function
MAX_ARW,MIN_ARW Res:=Function(Tab)
MAX_ARD,MIN_ARD
MAX_ARR,MIN_ARR
Parameters

Type Result (Res) Table (Tab)


Tables of indexable words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW
Non-indexable words %QW,%SW,%NW
Tables of indexable double words %MD:L,%KD:L
Indexable double words %MD
Non-indexable double words %QD,%SD
Tables of floating point values %MF:L,%KF:L
Indexable double words %MF

___________________________________________________________________________
2/45
B
2.7-9 Number of occurrences of a value in a table
There are three find functions :
• OCCUR_ARW : searches a word table for the number of elements equal to a given
value.
• OCCUR_ARD : searches a double word table for the number of elements equal to
a given value.
• OCCUR_ARR : searches a floating point table for the number of elements equal to
a given value.

Structure
Ladder language Instruction List language

%I3.2 LD %I3.2
%MW5:=OCCUR_ARW(%MW20:7,%KW0) [%MW5:=OCCUR_ARW(%MW20:7,%KW0)]

%I1.2
Structured Text language

%MW0:=OCCUR_ARD(%MD20:7,200) IF %I1.2 THEN


%MW0:=OCCUR_ARD(%MD20:7,200) ;
END_IF ;

Syntax
Function Res:= Function (Tab,Val)
OCCUR_ARW
OCCUR_ARD
OCCUR_ARR

Parameters

Type Result (Res) Table (Tab) Value (Val)


Tables of indexable words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW MW,%KW,%Xi.T
Non-indexable words %QW,%SW, %NW Immed. val. %QW,
%IW,%SW,%NW
Numeric expr.
Tables of indexable words %MD:L,%KD:L
Indexable (double) words %MW %MD,%KD
Non-indexable (double) words %QW,%SW, %NW Immed. val. %QD,
%ID,%SD
Numeric expr.
Tables of floating point words %MF:L,%KF:L
Indexable (floating point) words %MW %MF,%KF
Non-indexable (floating point) %QW,%SW, %NW Immed. val.
words Numeric expr.
___________________________________________________________________________
2/46
Description of advanced instructions 2

B
2.7-10 Circular shift function on tables
There are six shift functions :
• ROL_ARW : performs a circular shift of
elements in word tables by n positions 0
from top to bottom. 1
• ROL_ARD : performs a circular shift of 2
elements in double word tables by n 4
positions from top to bottom. 5
• ROL_ARR : performs a circular shift of
elements in floating point word tables
by n positions from top to bottom.
• ROR_ARW : performs a circular shift of
elements in word tables by n positions 0
from bottom to top. 1
• ROR_ARD : performs a circular shift of 2
elements in double word tables by n 4
positions from bottom to top. 5
• ROR_ARR : performs a circular shift of
elements in floating point word tables
by n positions from bottom to top.

Structure
Ladder language Instruction List language

%I3.2 LDR %I3.2


ROL_ARW(%KW0,%MW20:7) [ROL_ARW(%KW0,%MW20:7)]
P

Structured Text language


%I1.2
P ROR_ARD(2,%MD20:7) IF RE%I1.2 THEN
ROR_ARD (2,%MD20:7) ;
%I1.3 END_IF ;
IF RE%I1.3 THEN
P ROR_ARR(2,%MF40:5)
ROR_ARR (2,%MF40:5) ;
END_IF ;

___________________________________________________________________________
2/47
B
Syntax

Functions ROL_ARW,ROR_ARW Function(n,Tab)


Parameters
Word tables
Type Number of positions (n) Table (Tab)
Tables of indexable words %MW:L
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed. val.%QW,%IW,%SW
%NW,Numeric expr.

Functions ROL_ARD,ROR_ARD Function(n,Tab)


Parameters
Double word tables
Type Number of positions (n) Table (Tab)
Tables of indexable words %MD:L
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed. val.%QW,%IW,%SW
%NW,Numeric expr.

Functions ROL_ARR,ROR_ARR Function(n,Tab)


Parameters
Floating point word tables
Type Number of positions (n) Table (Tab)
Tables of indexable floating %MF:L
point words
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed. val.%QW,%IW,%SW
%NW,Numeric expr.

Note : If the value of n is negative or zero, no shift is performed.

___________________________________________________________________________
2/48
Description of advanced instructions 2

B
2.7-11 Sort function on tables
There are three sort functions :
• SORT_ARW : sorts the elements of the word table into ascending or descending
order and stores the result in the same table.
• SORT_ARD : sorts the elements of the double word table into ascending or
descending order and stores the result in the same table.
• SORT_ARR : sorts the elements of the floating point table into ascending or
descending order and stores the result in the same table.

Structure
Ladder language Instruction List language

%I3.2 LD %I3.2
SORT_ARW(%MW20,%MW0:6) [SORT_ARW(%MW20,%MW0:6)]

%I1.2 Structured Text language


SORT_ARD(-1,%MD20:6)
IF %I1.2 THEN
%I1.3 SORT_ARD (-1,%MD20:6) ;
END_IF ;
SORT_ARD(0,%MD40:8) IF %I1.3 THEN
SORT_ARR (0,%MF40:8) ;
END_IF ;

Syntax
Function Function (dir.,Tab)
SORT_ARW
SORT_ARD
SORT_ARR

• The "direction" parameter determines the order of the sort : if the direction is > 0, the
sort is performed in ascending order. If < 0, the sort is performed in descending order.
• The result (sorted table) is given in the Tab parameter (table to be sorted).
Parameters
Word tables

Type Direction of the sort Table (Tab)


Tables of words (SORT_ARW) %MW:L
Tables of doubles (SORT_ARD) %MD:L
Tables of floating point words (SORT_ARF) %MF:L
Indexable words %MW,%KW
Non-indexable words Immed. val.%QW,%IW,%SW
%NW,Numeric expr.
___________________________________________________________________________
2/49
B
2.7-12 Table length calculation function
There are four table length calculation functions, which can be used for programming
DFB function blocks when the table lengths have not been defined explicitly:
• LENGTH_ARW : calculates the length of a word table as a number of elements.
• LENGTH_ARD : calculates the length of a double word table as a number of
elements.
• LENGTH_ARR : calculates the length of a floating point table as a number of
elements.
• LENGTH_ARX :calculates the length of a bit table as a number of elements.
Structure
Ladder language Instruction List language

LD %I3.2
%I3.2
[LENGTH_ARW(tab_mot)]
LENGTH_ARW(tab_mot)

%I1.2 Structured Text language


LENGTH_ARD(tab_dmot) IF %I1.2 THEN
LENGTH_ARD(tab_dmot)]
%I1.3 END_IF ;
LENGTH_ARX(tab_bit) IF %I1.2 THEN
LENGTH_ARX(tab_bit)]
END_IF ;

Syntax
Function Result = Function (Tab)
LENGTH_ARW
LENGTH_ARD
LENGTH_ARR
LENGTH_ARX

Parameters
Tables of words

Type Table (Tab) Result (Res)


Tables (LENGTH_ARW) word
Tables (LENGTH_ARD) double word
Tables (LENGTH_ARR) floating point
Tables (LENGTH_ARX) bit
Indexable words %MW
Non-indexable words %QW,%SW,%NW
Note : the parameters of the table are purely symbolic objects.

___________________________________________________________________________
2/50
Description of advanced instructions 2

B
2.8 Character string instructions
2.8-1 Format of a string or table of characters
A character table is composed of a series of bytes in which a character string can be
stored. The size of the table is used to specify the maximum length of the character
string (up to 255 characters).
Example : %MB4:6 represents a table of 6 bytes
containing a string of up to 6 characters.
The first byte at the beginning of a table must be even (it is not possible to enter a byte
table which starts with an odd byte, eg :%MB5:6).
Byte tables use the same memory zone as words %MW and %MD. There is therefore
a risk of overlap : see section 1.2-4, part A.
The term character string represents all the characters between the start of the table
and the first string termination character encountered.
The NUL character (hexa code 00) is known as the String termination character. It is
symbolized by Ø throughout this section.

Examples :
• The following table (of 12 elements) contains the character string 'ABCDE' (5 characters
long).
'A' 'B' 'C' 'D' 'E' Ø 'J' 'K' 'L' 'M' 'N' 'O'

• The following table (of 10 elements) contains the character string 'ABCDEJKLMN'
(10 characters long).

'A' 'B' 'C' 'D' 'E' 'J' 'K' 'L' 'M' 'N'

The length of a character string is therefore determined either by the number of


characters before the string termination character Ø, or by the size of the table if no
string termination character is detected.
Notes :
System bit %S15 is set to 1 in the following cases :
• If, when writing a string in a table, the string is longer than the size of the table. (Impossible
to write the string termination character Ø).
• If the user attempts to access a character which is not in that string.
• Incorrect parameters :
Length to be deleted zero (DELETE function ), length to be extracted zero (MID function),
length to be replaced zero (REPLACE function), search for a substring which is longer than
the string (FIND function).

___________________________________________________________________________
2/51
B
2.8-2 Character string assignment
This function is used to transfer a character string to a byte table of length L.
Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MB30:12:= 'mise_en_run' [ %MB30:10 := 'set_to_run']

Structured Text language

%MB30:10:='set_to_run' ;

Example Transfer of the character string 'set_to_run' to a byte table 10


characters long

%MB 30 31 32 33 34 35 36 37 38 39
's' 'e' 't' '_' 't' 'o' '_' 'r' 'u' 'n'

Syntax

Operator Op1:=Op2

Operands

Type Operand 1 (Op1) Operand 2 (Op2)


Byte tables %MB:L %MB:L,%KB:L
Immediate value

___________________________________________________________________________
2/52
Description of advanced instructions 2

B
2.8-3 Alphanumeric comparisons
These operators are used to compare two character strings contained in the byte
tables provided as parameters. Comparison is performed character by character.
The result is a bit which equals 1 if both strings satisfy the conditions determined by
the operator, character by character. Otherwise, the bit equals 0.
The order of characters is determined by the ASCII code table (ISO 646). For example,
string 'Z' is larger than string 'AZ' which is larger than the string 'ABC'.
Structure
Ladder language Instruction List language

%M10
COMPARE
LD [ %MB20:12 < %MB40:12]
%MB20:12< %MB40:12
ST %M10

Comparison blocks are programmed in The comparison is executed inside square


the test zone. brackets after the instructions LD, AND
and OR.
• Structured Text language

%M10 := %MB20:12 < %MB40:12 ;

Example : %MB20:12 < %MB40:12 ==> YES The result equals 1


where
%MB 20 21 22 23 24 25 26 27 28 29 30 31
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'l' Ø 'k' 'w' 'z'

%MB 40 41 42 43 44 45 46 47 48 49 50 51
'a' 'b' 'c' 'd' 'e' 'f' 'h' 'l' Ø 'k' 'w' 'z'

The elements after the termination character are not taken into account.
Syntax
Operator
<, >, <=, >=, =, < > Op1 Operator Op2

Operands
Type Operand 1 (Op1) and Operand 2 (Op2)
Byte tables %MB:L,%KB:L, immediate value

___________________________________________________________________________
2/53
B
2.8-4 Numeric <---> ASCII conversion functions
These functions are used to convert a numeric (or floating point) value to a character
string in ASCII code or vice versa.
The result of the conversion must be transferred to a PL7 object via an assignment
operation : byte table, single or double length word, floating point.

The conversions possible are :


INT_TO_STRING Binary -->ASCII conversion
DINT_TO_STRING Binary -->ASCII conversion
STRING_TO_INT ASCII-->Binary conversion
STRING_TO_DINT ASCII-->Binary conversion
REAL_TO_STRING Floating point -->ASCII conversion
STRING_TO_REAL ASCII-->Floating point conversion
Review of floating point format : ==> See section 2.5, part B

Review of the ASCII code :


All 256 alphanumeric and control characters can be coded on 8 bits.
This code, known as ASCII (American Standard Code for Information Interchange),
is compatible with the notion of bytes. Any tables of n bytes can therefore be formed
by n ASCII codes defining n characters.

2.8-5 Binary --->ASCII conversion


These functions are used to convert a numeric value (single or double length word)
to a character string in ASCII code.
Each digit, as well as the sign of the value provided as a parameter, is coded in ASCII
in an element of the result byte table.
• INT_TO_STRING function : The contents of a single length word can be between
-32768 and +32767, that is, 5 digits plus the sign. The result will therefore be a table
of 6 characters plus the string termination character. The sign '+' or '-' is stored in the
first character, the units in the sixth character, the tens in the fifth, and so on.
• DINT_TO_STRING function : The contents of a double length word can be between
-2147483648 and +2147483647, that is, 10 digits plus the sign. The result will
therefore be a table of 12 characters plus the string termination character. The sign
'+' or '-' is stored in the first character, the unit in the twelfth character, the tens in the
eleventh, and so on. The second character is always '0'.

___________________________________________________________________________
2/54
Description of advanced instructions 2

B
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MB10:7:= INT_TO_STRING(%MW20)
[ %MB10:7 := INT_TO_STRING (%MW20)]

Structured Text language


OPERATE
%MB2:13:= DINT_TO_STRING(%MD30)
%MB2:13:=DINT_TO_STRING (%MD30) ;

Example : Binary ---> ASCII conversion


%MB10:7 := INT_TO_STRING (%MW20) where %MW20 = - 3782 in decimal
==> The result is stored in the following 7-byte table %MB10:7
%MB 10 11 12 13 14 15 16
'_' '0' '3' '7' '8' '2' Ø

Example : %MB2:13 := DINT_TO_STRING (%MD30) where %MD30 = - 234701084

%MB 2 3 4 5 6 7 8 9 10 11 12 13 14
'-' '0' '0' '2' '3' '4' '7' '1' '1' '0' '8' '4' Ø

Syntax
Operator result := INT_TO_STRING (value)
Operands

Type Result Value


6-byte tables %MB:7
+ string termination character
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immed. val., Num. expr.

Operator result := DINT_TO_STRING (value)


Operands
Type Result Value
12-byte tables %MB:13
+ string termination character
Indexable double words %MD, %KD
Non-indexable double words %ID,%QD,%SD,
Immed. val., Numeric expr.

___________________________________________________________________________
2/55
B
2.8-6 ASCII ---> Binary conversion
This function is used to convert a character string representing a numeric value into
binary code (result transferred to a single or double length word).
Each element of the table provided as a parameter represents the ASCII code of a
character. Authorized characters are digits and the characters '+' and '-'.
• STRING_TO_INT function : converts a string of 6 characters representing a
numeric value between -32768 and +32767. The first character must represent the
sign and the following characters the value. The second character represents the
tens of thousands, ..., and the sixth character the units. The value must be right-
justified in the string.
• STRING_TO_DINT function : converts a string of 12 characters representing a
numeric value between -2147483648 and +2147483647. The first character must
represent the sign and the following characters the value. The second is the
character '0', the third the thousands of millions,..., the twelfth the units. The value
must be right-justified in the string.
Structure

OPERATE LD TRUE
%MW13:= STRING_TO_INT(%MB20:7) [%MW13 := STRING_TO_INT (%MB20:7)]

Example : %MW13 := STRING_TO_INT (%MB20:7) where


%MB 20 21 22 23 24 25 26
'_' '0' '2' '3' '4' '7' Ø ==> result %MW13 = -2347 in decimal
Syntax
Operator result := STRING_TO_INT (string)
Operands
Type Result String
Indexable words %MW
Non-indexable words %QW,%SW,%NW.
6-byte tables %MB:7,%KB:7, Immed. val.
+ string termination character
Bit %S18 is set to 1 if the value described by the string is not between -32768 and +32767 or if
one of the 6 characters is incorrect.

Operator result := STRING_TO_DINT (string)


Operands
Type Result String
Indexable double words %MD
Non-indexable double words %QD,%SD
12-byte tables %MB:13,%KB:13, Immed. val.
+ string termination character
Bit %S18 is set to 1 if the value described by the string is not between -2147483648 and
+2147483647 or if one of the 12 characters is incorrect.
___________________________________________________________________________
2/56
Description of advanced instructions 2

B
2.8-7 Floating point ---> ASCII conversion
This function is used to convert a real numeric value contained in a floating point type
word to a character string coded in ASCII. The result is transferred to a table of 14 bytes
+ the string termination character.
Each digit in the value and the characters '+', '-', '.', 'e' and 'E' are coded in ASCII in
an element in the result table.
The sign of the value is located in the first character, the decimal point (.) in the third,
the exponent 'e' in the eleventh and the sign of the exponent in the twelfth.
Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MB20:15:=REAL_TO_STRING(%MF30) [ %MB20:15 := REAL_TO_STRING (%MF30)]

Structured Text language

%MB20:15 := REAL_TO_STRING (%MF30) ;

Example : %MB20:15 := REAL_TO_STRING (%MF30) where %MF30 = - 3.234718 e26


==> result

%MB 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
'-' '3' '.' '2' '3' '4' '7' '1' '8' '0' 'e' '+' '2' '6' Ø

Syntax

Operator result := REAL_TO_STRING (value)

Operands

Type Result Value


14-byte tables %MB:15
+ string termination character
Indexable words %MF, %KF
Non-indexable words Immediate val., Num. expr.

Bit %S18 is set to 1 if the floating point value provided as a parameter is not between
- 3.402824e+38 and -1.175494e-38 or +1.175494e-38 and +3.402824e+38. In this
case, the value of the result is incorrect.

___________________________________________________________________________
2/57
B
2.8-8 ASCII --> Floating point conversion
This function is used to convert a character string representing a real numeric value
to floating point (result transferred to a floating point type word).
Each element in the table provided as a parameter represents the ASCII code of one
character. Authorized characters are digits and the characters '+', '-', '.', 'e' and 'E'. The
string termination character is not used to determine the end of the string. This means
that the 14 characters of the table must all be correct.
The sign of the value must be located in the first character, the decimal point (.) in the
third, the 'e' in the eleventh and the sign of the exponent in the twelfth.
For example, the value 3.12 must be in the form '+3.1200000e+00'.
Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MF18:=STRING_TO_REAL(%MB20:14) [ %MF18 := STRING_TO_REAL (%MB20:14)]

Structured Text language

%MF18 := STRING_TO_REAL (%MB20:14) ;

Example : %MF18 := STRING_TO_REAL (%MB20:14)


where
%MB 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
'-' '3' '.' '2' '3' '4' '7' '1' '8' '0' 'e' '+' '2' '6' Ø

==> result %MF18 = - 3.234718e26

Syntax

Operator result := STRING_TO_REAL (string)

Operands

Type Result String


Indexable words %MF
14-byte tables %MB:14, %KB:14
Immediate value

Bit %S18 is set to 1 if the value described by the string is not between -3.402824e+38
and -1.175494e-38 or +1.175494e-38 and +3.402824e+38 or if one of the 14
characters is incorrect.
___________________________________________________________________________
2/58
Description of advanced instructions 2

B
2.8-9 Concatenation of two strings
This function allows concatenation of two character strings as defined by parameters.
The result is a byte table containing a character string.
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MB30:14:=CONCAT(%MB4:6,% MB14:9) [ %MB30:14 := CONCAT (%MB4:6, %MB14:9)]

Structured Text language

%MB30:14 := CONCAT (%MB4:6, %MB14:9) ;

Example : %MB30:14 := CONCAT (%MB4:6, %MB14:9)

%MB 4 5 6 7 8 9
'i' 'n' 'c' 'o' 'n' Ø

%MB 14 15 16 17 18 19 20 21 22
't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø

%MB 30 31 32 33 34 35 36 37 38 39 40 41 42 43
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø

Syntax
Operator result :=CONCAT (string1, string2)
Operands

Type Result String 1 and 2


Byte tables %MB:L %MB:L,%KB:L, Immed. val.

• If the result table is too short, the result is truncated and system bit %S15 is
set to 1. %MB30:10 := CONCAT (%MB4:6, %MB14:9)
%MB 30 31 32 33 34 35 36 37 38 39
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' ==> %S15 at 1

• If the result table is too long, termination characters Ø are added to the string.
%MB30:15 := CONCAT (%MB4:6, %MB14:9)
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø Ø
___________________________________________________________________________
2/59
B
2.8-10 Deletion of a character substring
This function is used to delete a number of characters (zone length L), from a given
row (position of the first character to be deleted) in the string defined as a parameter.
The result is a byte table containing a character string.
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MB14:9:=DELETE(%MB30:14,% MW2,%MW4) [%MB14: 9 := DELETE (%MB30:14, %MW2, %MW4)]

Structured Text language

%MB14:9 := DELETE (%MB30:14, %MW2, %MW4) ;

Example : %MB14: 9 := DELETE (%MB30:14, %MW2, %MW4)


with %MW2 = 5 (5 characters to be deleted) %MW4 = 3 (position =3)
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42 43
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø

%MB 14 15 16 17 18 19 20 21 22
'i' 'n' 's' 't' 'a' 'b' 'l' 'e' Ø
Syntax
Operator result :=DELETE (string, length, pos)
Operands

Type Result String Length


pos (position)
Byte tables %MB:L %MB:L,%KB:L
Immediate val.
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expr.

Notes :
Some parameters may overlap depending on the indices of PL7 objects :
• Table containing the source string.
• Table containing the result string.
• Word containing the length to be deleted.
• Word containing the position of the first character to be deleted .

A negative length or position is interpreted as being 0. The position parameter starts at the value
1 which corresponds to the first position in the character string.
___________________________________________________________________________
2/60
Description of advanced instructions 2

B
If the result table is too long, termination characters Ø are added to the string.
System bit %S15 is set to 1 in the following cases :
• The length to be deleted is zero, the output table is a copy of the source table.
• The position is greater than the length of the string, or the position of the first
termination character found is less than or equal to the position of the first character
to be deleted. The result is therefore an empty string.
• The position is equal to 0. The result table therefore contains an empty string.
• The result table is too short. It has therefore been truncated.

2.8-11 Insertion of a character substring


Insertion of the character substring defined by the second parameter (string2) in the
character string defined by the first parameter (string1).
The insertion is made in the first string, after the character in the location given by the
position parameter (Pos).
The result of the insertion is a new character string transferred to a byte table.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MB2:14:=INSERT(%MB20:9,%MB30:6,%MW40) [%MB2:14 := INSERT (%MB20:9, %MB30:6, %MW40)]

Structured Text language

%MB2:14 := INSERT (%MB20:9, %MB30:6, %MW40) ;

Example : %MB2:14 := INSERT (%MB20:9, %MB30:6, %MW40)


where %MW40 := position 2
%MB 20 21 22 23 24 25 26 27 28
'i' 'n' 's' 't' 'a' 'b' 'l' 'e' Ø

%MB 30 31 32 33 34 35
'c' 'o' 'n' 't' 'e' Ø

%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø
___________________________________________________________________________
2/61
B
Syntax
Operator result :=INSERT (string1, string2, pos)

Operands

Type Result String 1 and 2 Pos (position)


Byte tables %MB:L %MB:L,%KB:L
Immed. value
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expr.

Notes :
The position parameter starts at the value 1 which corresponds to the first position in the
character string.

It is impossible to insert at the beginning of a string. In order to do this, use the CONCAT function.

If the table is too long, termination type characters must be added.

System bit %S15 is set to 1 in the following cases :

The value of the position parameter is negative or equal to 0. In this case, it is interpreted as being
0 and the result table contains an empty string (composed of termination characters).

The position provided as a parameter is greater than or equal to the length of the source string.
The result table then contains an empty string (composed of termination characters).
If the result table is too short, truncation occurs.

___________________________________________________________________________
2/62
Description of advanced instructions 2

B
2.8-12 Replacement of a character substring
This function is used to replace a section of a character string defined in the source
table (string1) by a character substring defined in the replacement table (string2). The
replacement to be made is defined by the position (pos.) and length parameters. This
length corresponds to the length of the string which is removed and not to the
length of the substring which replaces it.

Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MB2: 13:=REPLACE(%MB20:12,% MB30:9, [ %MB2:13 := REPLACE (%MB20:12,
%MW40, %MW41) %MB30:9, %MW40, %MW41)]

Structured Text language

%MB2:13 := REPLACE (%MB20:12, %MB30:9, %MW40, %MW41) ;

Example : %MB2:13 := REPLACE (%MB20:12, %MB30:9, %MW40, %MW41)


where %MW40 = 3 (length=3) and %MW41 = 9 (position=9)
%MB 20 21 22 23 24 25 26 27 28 29 30 31
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 'r' 'u' 'n' Ø
String 1
%MB 30 31 32 33 34 35 36 37 38
's' 't' 'o' 'p' Ø 'r' 'u' 'n' Ø
String 2

%MB 2 3 4 5 6 7 8 9 10 11 12 13 14
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 's' 't' 'o' 'p' Ø

Syntax
Operator result := REPLACE (string1, string2, length, pos.)

Operands

Type Result String 1 and 2 Length


pos (position)
Byte tables %MB:L %MB:L,%KB:L
Immed. value
Indexable words %MW, %KW,%Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expr.

___________________________________________________________________________
2/63
B
Notes :
The position parameter starts at the value 1 which corresponds to the first position in the
character string.

If the output table is too long, termination type characters are added to the string.

System bit %S15 is set to 1 in the following cases :


• If the value of the position parameter is negative or equal to 0. In this case, it is interpreted as
being 0 and the result table contains an empty string (composed of termination characters).
• If the position provided as a parameter is greater than or equal to the length of the source string,
the result table then contains an empty string (composed of termination characters).
• If the result table is too short, truncation occurs.
• If the position of the first string termination character is less than or equal to the position of the
first character to be replaced, the output table is a copy of the source table up to the string
termination character and completed by termination characters.

___________________________________________________________________________
2/64
Description of advanced instructions 2

B
2.8-13 Extraction of a character substring
This function is used to extract a number of characters from a source string provided as
a parameter (string).
The position of the first character to be extracted is determined by the position parameter
(pos), and the number of characters to be extracted is given by the length parameter.
The extracted string is stored in a byte table (result).
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
[%MB14: 7 := MID (%MB30:13, %MW2, %MW4)]
%MB14:7:=MID(%MB30:13,% MW2,%MW4)

Structured Text language

%MB14:7 := MID (%MB30:13, %MW2, %MW4) ;

Example : %MB14: 7 := MID (%MB30:13, %MW2, %MW4)


where %MW2 = 4 (length), %MW4 = 9 (position)
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 's' 't' 'o' 'p' Ø

==> result
%MB 14 15 16 17 18 19 20
's' 't' 'o' 'p' Ø Ø Ø

Syntax

Operator result :=MID (string, length, pos)

Operands

Type Result String Length


pos (position)
Byte tables %MB:L %MB:L,%KB:L
Immed. value
Indexable words %MW,%KW,%Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expr.

___________________________________________________________________________
2/65
B
Notes :
The position parameter starts at value 1 which corresponds to the first position in the character
string.

If the output table is too long, termination type characters are added to the result string.
If the length provided as a parameter is greater than the size of the source string, the result table
then contains the source string.
If the last element of the table or the string termination character is reached before the number
of characters defined by the length parameter has been extracted, extraction stops at this point.
System bit %S15 is set to 1 in the following cases :
• If the value of the length parameter to be extracted is negative or equal to 0. In this case, it is
interpreted as being 0 and the result table contains an empty string (composed of termination
characters).
• If the value of the position parameter for the beginning of the extraction is zero or greater than
or equal to the length of the table, or greater than or equal to the position of the first termination
character. In this case, the result table contains an empty string (composed of termination
characters).
• If the result table is too short, truncation occurs.

___________________________________________________________________________
2/66
Description of advanced instructions 2

B
2.8-14 Extraction of characters
Extraction of a number of characters the furthest to the left (LEFT) or furthest to the
right (RIGHT) in a source string provided as a parameter (string).
The number of characters to be extracted is defined by the length parameter.
The extracted string is stored in a byte table (result).
Structure
Ladder language Instruction List language

LD TRUE
OPERATE [%MB10: 10 := LEFT (%MB30:13, %MW2)]
%MB10:10:=LEFT(%MB30:13,% MW2)

Structured Text language

%MB10:10 := LEFT (%MB30:13, MW2) ;

Example : %MB10: 10 := LEFT (%MB30:13, %MW2)


where %MW2 = 8 (length)

%MB 30 31 32 33 34 35 36 37 38 39 40 41 42
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 's' 't' 'o' 'p' Ø

==> result
%MB 10 11 12 13 14 15 16 17 18 19
'm' 'i' 's' 'e' '_' 'e' 'n' '_' Ø Ø

Syntax
Operator result :=LEFT (string, length)

result :=RIGHT (string, length)

Operands

Type Result String Length


Byte tables %MB:L %MB:L,%KB:L
Immed. value
Indexable words %MW,%KW,%Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expr.

___________________________________________________________________________
2/67
B
Notes :
If the output table is too long, termination type characters are added to the result string.
If the length provided as a parameter is greater than the size of the source string, the result table
then contains the source string.

System bit %S15 is set to 1 in the following cases :


• If the value of the length parameter to be extracted is negative or 0. In this case, the result table
contains an empty string (composed of termination characters).
• If the result table is too short, truncation occurs.

___________________________________________________________________________
2/68
Description of advanced instructions 2

B
2.8-15 Comparison of two character strings
This function is used to compare two character strings. The result is a word containing
the position of the first different character.
If the two character strings are exactly the same, the result is -1.
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MW2:=EQUAL_STR(%MB18:14,%MB50:14) [%MW2 := EQUAL_STR (%MB18:14, %MB50:14)]

Structured Text language

%MW2 := EQUAL_STR (%MB18:14, %MB50:14) ;

Example : %MW2 := EQUAL_STR (%MB18:14, %MB50:14) where


%MB 18 19 20 21 22 23 24 25 26 27 28 29 30 31
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'p' 'w' 'x' 'y' 'z'

%MB 50 51 52 53 54 55 56 57 58 59 60 61 62 63
'a' 'b' 'c' 'd' '?' 'f' 'g' 'h' Ø 'v' 'w' 'x' 'y' 'z'

==> MW2 := 5

Syntax
Operator result :=EQUAL_STR (string1, string2)

Operands

Type Result String 1 and 2


Indexable words %MW
Non-indexable words %QW,%SW,%NW.
Byte tables %MB:L,%KB:L
Immediate value

Note :
A negative length or position is interpreted as being equal to 0.

Upper case letters are different from lower case letters.

___________________________________________________________________________
2/69
B
2.8-16 Search for a character substring
This function is used to search for the character substring defined by the second
parameter in the character string defined by the first parameter.
The result is a word containing the position in the first string of the beginning of the
substring searched for.
If the search is not successful, the result is -1.
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MW2:= FIND(%MB18:14, %MB 50:4)
[ %MW2 := FIND (%MB18:14, %MB50:4)]

Structured Text language

%MW2 := FIND (%MB18:14, %MB50:4) ;

Example : %MW2 := FIND (%MB18:14, %MB50:4) where


%MB 18 19 20 21 22 23 24 25 26 27 28 29 30 31
'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' Ø 'w' 'x' 'y' 'z'

%MB 50 51 52 53
'f' 'g' 'h' Ø

==> MW2 := 6 Indicates that the beginning of the string searched for is located
from the sixth character onwards.

Syntax
Operator result :=FIND (string1, string2)

Operands

Type Result String 1 and 2


Indexable words %MW
Non-indexable words %QW,%SW,%NW.
Byte tables %MB:L,%KB:L
Immediate value

Note :
A negative length or position is interpreted as being equal to 0.
___________________________________________________________________________
2/70
Description of advanced instructions 2

B
2.8-17 Length of a character string
This function gives the length of the character string provided as a parameter, that is,
the number of characters located before the termination character.
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
[%MW2 := LEN (%MB20:14)]
%MW2:= LEN (%MB20:14)

Structured Text language

%MW2 := LEN (%MB20:14) ;

Example : %MW2 := LEN (%MB20:14) where

%MB 20 21 22 23 24 25 26 27 28 29 30 31
'a' 'b' 'c' 'd' 'e' 'f' 'g' Ø 'n' 'o' 'p' 'r'

==> %MW2 = 7

Syntax

Operator result := LEN (string)

Operands

Type Result String


Indexable words %MW
Non-indexable words %QW,%SW,%NW.
Byte tables %MB:L, %KB:L,
Immediate value

Note :
If no termination character is found, the function gives the size of the table (see section 2.8-1).

___________________________________________________________________________
2/71
B
2.9 Time management instructions : Date, Time of day, Duration
2.9-1 Parameter format
The Date, Time of day and Duration parameters used by these instructions correspond
to the standard formats defined by IEC standard 1131-3.

• Duration format (TIME type)


This format is used to code durations expressed in tenths of a second and
corresponds to the TIME format of the standard.
These values are displayed in the following way : sssssssss.d
which gives for example : 3674.3
for 1 hour, 1 minute, 14 seconds and 3 tenths of a second.
The value is coded on 32 bits (a double word) of which the limits are set at [0,
4294967295] tenths of a second, which represents approximately 13 years and
7 months.

• Data format (DATE type)


This format is used to code the year, the month and the day. It corresponds to the
DATE format of the standard.
The value is displayed in the following way : yyyy-mm-dd
which gives for example : 1984-06-25
The value is coded in BCD on 32 bits (a double word) with 3 fields :
31 16 8 0 Year : 4 digits
Year Month Day Month : 2 digits
Day : 2 digits
Example :
expressed in hexadecimal format
19h 84h 06h 25h = 1984-06-25

Only values within the time period [1990-01-01, 2099-12-31] are permitted.

___________________________________________________________________________
2/72
Description of advanced instructions 2

B
• Time of day format (TOD type)
This format is used to code the hour, the minutes and the seconds. It corresponds
to the TIME_OF_DAY format of the standard.
The value is displayed in the following way : hh:mm:ss
which gives for example : 23:12:34
The value is coded in BCD on 32 bits (a double word) with 3 fields :
31 24 16 8 0 Hours : 2 digits (high order word)
Hr Min Sec Minutes : 2 digits (high order word)
Seconds : 2 digits (low order word)
Example :
expressed in hexadecimal format
23h 12h 34h = 23:12:34

Only values within the time period [00:00:00, 23:59:59] are permitted.

• Date and time format (DT type)


This format is used to code the year, the month, the day, the hour, the minutes and
the seconds. It corresponds to the DATE_AND_TIME format of the standard.
The value is displayed in the following way : yyyy-mm-dd-hh:mm:ss
which gives for example : 1984-06-25-23:12:34
The value is coded in BCD on 64 bits (a 4-word table) :
64 48 40 32 24 16 8 0
Year Month Day Hr Min Sec

Example :
expressed in hexadecimal format
1984h 06h 25h 23h 12h 34h

Only values within the time period [1990-01-01-00:00:00, 2099-12-31- 23:59:59] are
permitted.

___________________________________________________________________________
2/73
B
• Hour, Minute, Second Format (HMS type)
This format, used exclusively by the function TRANS_TIME, is used to code
the hour, the minutes and the seconds.

The value is displayed in the following way : hh:mm:ss


which gives for example : 23:12:34

The value is coded in BCD on 32 bits (a double word) with 3 fields :


31 16 8 0 Hours : 4 digits (high order word)
Hr Min Sec Minutes : 2 digits (low order word)
Seconds : 2 digits (low order word)
Example :
expressed in hexadecimal format
23h 12h 34h = 23:12:34

2.9-2 Use of system bits and words - General


System bit %S17 is set in the following cases :
• Result of an operation outside the permitted time period values.
• An input parameter cannot be interpreted and is not consistent with the required format
(DAT, DT or TOD).
• Operation on a Time of day (TOD) format leading to a change in the day.
• Access clash to the real-time clock.
System bit %S15 is set to 1 if a string written in a table is longer than the size of that
table.
System words :
• %SD18 : absolute time counter is also used to perform time period calculations
(incremented every 1/10 of a second by the system).
• %SW49 to %SW53 can also be used to display dates (see section 3.2-2, part B).

___________________________________________________________________________
2/74
Description of advanced instructions 2

B
2.9-3 Realtime clock function

This function is used to control actions at predefined or calculated times and dates.
It sets the OUT output parameter to 1 if the date provided by the PLC clock when the
function is called is within the period set in the input parameters.

Syntax
Operator SCHEDULE (DBEG, DEND, WEEK, HBEG, HEND, OUT)

Parameter characteristics

Output OUT Bit containing the result of comparisons


carried out by the realtime clock function :
at 1 during the periods defined in the
parameters.
Start date DBEG Word encoding the period start date (month-
day) in BCD (limit values : 01-01 to 12-31)
End date DEND Word encoding the period end date (month-
day) in BCD (limit values : 01-01 to 12-31)
Day of the week WEEK Word encoding the day(s) of the week
included in the period defined in the DBEG
and DEND parameters.
The 7 least significant bits represent the 7
days of the week : bit 6 =Monday, bit 5 =
Tuesday,..., bit 0 = Sunday.
Start time HBEG Double word encoding the period start
time during the day (hours- minutes-
seconds) in BCD time of day format (type :
TOD). Limit values : 00:00:00, 23:59:59
End time HEND Double word encoding the period end time
during the day (hours- minutes- seconds)
in BCD time of day format (type : TOD).
Limit values : 00:00:00, 23:59:59

___________________________________________________________________________
2/75
B
Structure
Ladder language Instruction List language

LD TRUE
OPERATE
[SCHEDULE (%KW0,%KW1,%KW2,%KD3,
SCHEDULE (%KW0,%KW1,%KW2,%KD3,%KD5,%M0)
%KD5,%Q0.0)]

Structured Text language


SCHEDULE ( 16#0501, (* start date : May 1*)
16#1031, (* end date : October 31*)
2#0000000001111100, (* Monday to Friday*)
16#08300000, (* start time : 08:30*)
16#18000000, (* end time : 18:00*)
%Q0.0) ; (* result in : %Q0.0*)

Operands
SCHEDULE (DBEG, DEND, WEEK, HBEG, HEND, OUT)

Type DBEG,DEND,WEEK HBEG,HEND OUT


Indexable words %MW,%KW,%Xi.T
Non-indexable words %IW,%QW,%SW,%NW
Immediate value
Numeric expression
Indexable double words %MD,%KD
Non-indexable %ID,%QD
double words Immediate value
Numeric expression
Bits %I,%Q, %M, %S,
%BLK,%•:Xk, %X

Notes :
• The DBEG and DEND parameters define a range of days during the year. This range can be
staggered over two calendar years, for example : October 10 to April 7. February 29 can be
used during this period, but will be ignored in non-leap years.
• The HBEG and HEND parameters define a range of times during the day. This range can be
staggered over two days, for example : 22:00 to 06:10:20.
• If one of the DBEG and DEND dates or one of the HBEG and HEND times is incorrect, ie. does
not correspond to an actual date or time, the OUT output will be at 0 and bit %S17 will be set
to 1.
• If the target PLC does not have an internal clock (as is the case with the TSX37-10), the output
will be at 0 and the system bit %S17 will be set to 1.
• It is possible to lighten the load on the PLC processor if precision is not important by controlling
the SCHEDULE function call via system bit %S6 or %S7.
___________________________________________________________________________
2/76
Description of advanced instructions 2

B
2.9-4 Read system date
Reads the system date (Real-Time Clock) and transfers to the object given as a
parameter in the Date and time (DT) format.
Structure
Ladder language Instruction List language
LD %M6
%M6 OPERATE [RRTC (%MW2:4)]
RRTC (%MW2:4)

Structured Text language


IF %M6 THEN
RRTC (%MW2:4) ;
END_IF ;

Example : RRTC (%MW2:4)


The result is transferred to the table of internal words which is 4 words long : %MW2
to %MW5.
Syntax
Operator RRTC(date)
Operand

Type Date
4-word tables %MW:4
in date and time format

2.9-5 Update system date


Updates the system date (Real-Time Clock) and transfers to the object given as a
parameter in Date and time (DT) format.
Structure
Ladder language Instruction List language
%M7
OPERATE
LDR %M7
P %MW2:=16#4300 [%MW2:= 16#4300]
OPERATE
[%MW3:= 16#1732]
%MW3:=16#1732 [%MW4:= 16#1124]
OPERATE [%MW5:= 16#1995]
%MW4:=16#1124 [WRTC (%MW2:4)]
OPERATE
%MW5:=16#1995
OPERATE
WRTC (%MW2:4)

___________________________________________________________________________
2/77
B
Structured Text language
IF RE %M7 THEN
%MW2 := 16#4300 ;
%MW3 := 16#1732 ;
%MW4 := 16#1124 ;
%MW5 := 16#1995 ;
WRTC (%MW2:4) ;
END_IF ;

Example : The new date is loaded into an internal word table, %MW2:4, which is 4
words long and then sent to the system using the WRTC functions.
Syntax
Operator WRTC(date)
Operand
Type Date
4-word tables %MW:4, %KW:4
in date and time format

2.9-6 Read date and stop code


Reads the date of the last PLC stop and the code specifying the cause of the stop (in
the fifth word, equivalent to %SW58. See section 3.2-2, part B).
Structure
Ladder language Instruction List language
%M7 LD %M7
OPERATE
PTC (%MW4:5) [PTC (%MW4:5)]

Structured Text language


IF %M7 THEN
PTC (%MW4:5) ;
END_IF ;

Example : PTC (%MW4:5)


The result is transferred to the table of internal words which is 5 words long : %MW4
to %MW8.
Syntax
Operator PTC (date)
Operand
Type Date
5-word tables %MW:5
in date and time format
___________________________________________________________________________
2/78
Description of advanced instructions 2

B
2.9-7 Read day of the week
This function gives the current day of the week in the form of a digit from 1 to 7 which
is transferred to a word (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday,
5 = Friday, 6 = Saturday, 7 = Sunday).
Structure
Ladder language Instruction List language

%M7 LD %M7
OPERATE
%MW5:=DAY_OF_WEEK() [%MW5 := DAY_OF_WEEK()]

Structured Text language

IF %M7 THEN
%MW5 := DAY_OF_WEEK () ;
END_IF ;

Example : %MW5 := DAY_OF_WEEK() %MW5 := 4 corresponds to Thursday

Syntax

Operator result :=DAY_OF_WEEK()

Operand

Type Result
Indexable words %MW
Non-indexable words %QW, %SW, %NW

Note
If the function was unable to update the result following an access error to the
real-time clock, the result given is 0 and system bit %S17 is set to 1.

___________________________________________________________________________
2/79
B
2.9-8 Add / Remove a duration at a date
Adds or removes a duration (in tenths of a second) (In2) at a source date (In1). The
result is a new date, transferred to a table of 4 words.
ADD_DT () = Add a duration SUB_DT () = Remove a duration

Structure
Ladder language Instruction List language

%M7 LD %M7
OPERATE [RRTC (%MW2:4)]
RRTC (%MW2:4)
[%MD8 := 906]
OPERATE [%MW2:4:= ADD_DT(%MW2:4, %MD8)]
%MD8:=906 [WRTC (%MW2:4)]
OPERATE
%MW2:4:=ADD_DT(%MW2:4,%MD8)
OPERATE
WRTC (%MW2:4)

Structured Text language

IF %M7 THEN
RRTC (%MW2:4) ;
%MD8 := 906 ;
%MW2:4 := ADD_DT (%MW2:4, %MD8) ;
WRTC (%MW2:4) ;
END_IF ;

Example : %MW2:4 := ADD_DT(%MW2:4, %MD8)


%MW2:4 := Source date
%MD8 := 906 (906 tenths of a second rounded to 1 min. 31 s)
%MW2:4 := New date

Syntax
Operators result :=ADD_DT (In1, In2)

result :=SUB_DT (In1, In2)

___________________________________________________________________________
2/80
Description of advanced instructions 2

B
Operands
Type Result In1 (initial date) In2 (time period)
Table of four words in %MB:4 %MW4:4, %KW:4
the date and time format
Indexable double words %MD,%KD
Non-indexable double %ID,%QD
words Immediate value
Numeric expr.

Notes :
• The "duration" parameter (expressed in 1/10 of a second) will be rounded up or down so that
the date and time can be increased or decreased (precision to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0

• Provision must be made in the application to handle leap years.

• If the result of the operation is outside the permitted time period values, system bit %S17 is set
to 1 and the value of the result equals the minimum limit (for SUB_DT) or remains blocked at
the maximum (for ADD_DT).

• If the "source date" input parameter cannot be interpreted and is not consistent with the DT
(DATE_AND_TIME) format, system bit %S17 is set to 1 and the value of the result is
0001-01-01-000:00:00.

2.9-9 Add / Remove a duration at a time of day


Adds or removes a time period at a time of day. The result is a new time of day which
is transferred to a double word.
ADD_TOD () = Add a duration SUB_TOD () = Remove a duration
Structure
Ladder language Instruction List language

%M7 LD %M7
OPERATE
%MD8:= 906
[%MD8 := 906]
[%MD2 := ADD_TOD (%MD2, %MD8)]
OPERATE
%MD2:=ADD_TOD(%MD2,%MD8)

___________________________________________________________________________
2/81
B
Structured Text language

IF %M7 THEN
%MD8 := 906 ;
%MD2 := ADD_TOD (%MD2, %MD8) ;
END_IF ;

Example : %MD2 := ADD_TOD (%MD2, %MD8)


%MD2 := Initial time (eg. 12:30:00)
%MD8 := 906 (906 tenths of a second rounded to 1 min. 31 s)
%MD2 := New time (eg. 12:31:31)

Syntax

Operators result :=ADD_TOD (In1, In2)

result :=SUB_TOD (In1, In2)

Operands

Type Result In1 (initial time) and In2 (time period)


Indexable double words %MD %MD,%KD
Non-indexable double %QD %ID,%QD
words Immediate value, Numeric expression

result and In1 are in the TOD format and In2 is in the time period format.
Notes :
• The "time period" parameter (expressed in 1/10 of a second) will be rounded up or down so
that the date and time can be increased or decreased (precision to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0
• The day changes if the result of the operation is outside the permitted time period values. In
this case, system bit %S17 is set to 1 and the value of the result can be interpreted with a modulo
24:00:00.

• If the "time of day" input parameter cannot be interpreted in the TOD format, system bit %S17
is set to 1 and the result is 00:00:00.

___________________________________________________________________________
2/82
Description of advanced instructions 2

B
2.9-10 Difference between two dates (no time)
This function is used to calculate the difference in days between two dates. The result,
given as an absolute value, is transferred to a double word.
Structure
Ladder language Instruction List language

%M7 LD %M7
OPERATE
%MD10:=DELTA_D(%MD2,%MD4) [%MD10 := DELTA_D (%MD2, %MD4)]

Structured Text language

IF %M7 THEN
%MD10 := DELTA_D (%MD2, %MD4) ;
END_IF ;

Example : %MD10 := DELTA_D (%MD2, %MD4)


%MD2 := Date number1 (eg. 1994-05-01)
%MD4 := Date number2 (eg. 1994-04-05)
==> %MD10 = 22464000 (==> difference = 26 days)

Syntax
Operator result :=DELTA_D(Date1,Date2)

Operands

Type Result Date 1 and 2


Indexable double words %MD %MD,%KD
Non-indexable double %QD %ID,%QD
words Immediate value, Numeric expr.

result is in the TIME format and Date 1 and 2 are in the DATE format.
The TIME format is defined to be accurate to within one tenth of a second. The DATE
format is defined to be accurate to within one day. The time difference calculated will
therefore be a multiple of 864000 (= 1day = 24 h x 60 min x 60 s x 10 tenths of a second).

Warning
• Overflow occurs if the result exceeds the maximum value permitted for a
duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1.
• If one of the input parameters cannot be interpreted and is not consistent with
the DATE format, system bit %S17 is set to 1 and the result is 0.

___________________________________________________________________________
2/83
B
2.9-11 Difference between two dates (with time)
This function is used to calculate the time difference between two dates. The result,
given as an absolute value, is transferred to a double word.
Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MD10:= DELTA_D T(%MW2:4,%MW6:4) [%MD10 := DELTA_DT (%MW2:4, %MW6:4)]

Structured Text language

%MD10 := DELTA_DT (%MW2:4, %MW6:4) ;

Example : %MD10 := DELTA_DT (%MW2:4, %MW6:4)


%MW2:4 := Date number1 (eg. 1994-05-01-12:00:00)
%MW6:4 := Date number2 (eg. 1994-05-01-12:01:30)
==> %MD10 = 900 (==> difference = 1 minute and 30 seconds)
Syntax
Operator result :=DELTA_DT(Date1,Date2)

Operands

Type Result Date 1 and 2


Indexable double words %MD,
Non-indexable double %QD
words
4-word tables %MW:4, %KW:4
in DT format

result is in the TIME format and Date 1 and 2 are in the DT format.
The TIME format is defined to be accurate to within one tenth of a second. The DT
format is defined to be accurate to within one second. The time difference calculated
will therefore be a multiple of 10.

Warning
• Overflow occurs if the result exceeds the maximum value permitted for a
duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1.
• If one of the input parameters cannot be interpreted and is not consistent with
the DT format, system bit %S17 is set to 1 and the result is 0.

___________________________________________________________________________
2/84
Description of advanced instructions 2

B
2.9-12 Difference between two times
This function is used to calculate the time difference between two times of day. The
result is transferred to a double word as an absolute value, giving a duration.
Structure
Ladder language Instruction List language

OPERATE
LD TRUE
%MD10:= DELTA_TOD (%MD2,%MD4 ) [%MD10 := DELTA_TOD (%MD2, %MD4)]

Structured Text language

%MD10 := DELTA_TOD (%MD2, %MD4) ;

Example : %MD10 := DELTA_TOD (%MD2, %MD4)


%MD2 := Time1 (eg. 02:30:00)
%MD4 := Time2 (eg. 02:40:00)
==> %MD10 = 6600 (==> difference = 11 minutes)
Syntax
Operator result :=DELTA_TOD(Time1,Time2)

Operands

Type Result Time 1 and 2


Indexable double words %MD %MD,%KD
Non-indexable double %QD %ID,%QD
words Immediate value, Numeric expr.

result is in the TIME format and Time 1 and 2 are in the TOD format.

The TIME format is defined to be accurate to within one tenth of a second. The TOD
format is defined to be accurate to within one second. The time difference calculated
will therefore be a multiple of 10.

Attention
If one of the input parameters cannot be interpreted and is not consistent with the
TOD format, system bit %S17 is set to 1 and the result is 0.

___________________________________________________________________________
2/85
B
2.9-13 Convert a Date to a character string
This instruction converts a date to a character string (no time) in the format :
YYYY-MM-DD (10 characters). This string ends with the termination character Ø.
Each character Y,M,D represents a number.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE [%MB2:11 := DATE_TO_STRING (%MD40)]
%MB2:11:= DATE_TO_STRING(%MD40 )

Structured Text language


%MB2:11 := DATE_TO_STRING (%MD40) ;

Example : %MB2:11 := DATE_TO_STRING (%MD40)


%MD40 := DATE (eg. 1998-12-27)
%MB 2 3 4 5 6 7 8 9 10 11 12
==>
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' Ø

Syntax
Operator result :=DATE_TO_STRING(Date)
Operands

Type Result Date


11-byte tables %MB:11
Indexable double words %MD,%KD
Non-indexable double %ID,%QD
words Immediate value, Numeric expr.

Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DATE
format, system bit %S17 is set to 1 and the function returns the string : ' **** - ** - ** '. If the output
string is too short, truncation occurs and system bit %S15 is set to 1.
%MB2:8 := DATE_TO_STRING (%MD40)
==> %MB 2 3 4 5 6 7 8 9
'1' '9' '9' '8' '-' '1' '2' '-' ==> %S15 = 1

If the output string is too long, termination type characters Ø are added to the string.
%MB2:12 := DATE_TO_STRING (%MD40)

==> %MB 2 3 4 5 6 7 8 9 10 11 12 13
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' Ø Ø
___________________________________________________________________________
2/86
Description of advanced instructions 2

B
2.9-14 Convert a complete Date to a character string
This instruction converts a complete date (with time) to a character string in the format :
YYYY-MM-DD-HH:MM:SS (19 characters). This string ends with the termination
character Ø. Each character Y,M,D,H,M,S represents a number.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE [%MB2:20 := DT_TO_STRING (%MW50:4)]
%MB2:20:= DT_TO_STRING(%MW50:4 )

Structured Text language


%MB2:20 := DT_TO_STRING (%MW50:4) ;

Example : %MB2:20 := DT_TO_STRING (%MW50:4)


%MW50:4 := Date and time (type DT) (eg. 1998-12-27-23:14:37)
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' '-' '2' '3' ':' '1' '4' ':' '3 ' '7' Ø

Syntax
Operator result :=DT_TO_STRING(Date)

Operands

Type Result Date


20-byte tables %MB:20
4-word tables %MW:4, %KW:4
in DT format

Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DT
format (DATE_AND_TIME), system bit %S17 is set to 1 and the function returns the string ' ****
- ** -** - ** : ** : **'. If the output string is too short, truncation occurs and system bit %S15 is set
to 1.
%MB2:8 := DT_TO_STRING (%MW50:4)
==> %MB 2 3 4 5 6 7 8 9
'1' '9' '9' '8' '-' '1' '2' '-' ==> %S15 = 1

• If the output string is too long, termination type characters Ø are added to the string.
%MB2:21 := DT_TO_STRING (%MW50:4)
==>
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' '-' '2' '3' ':' '1' '4' ':' '3 ' '7' Ø Ø
___________________________________________________________________________
2/87
B
2.9-15 Convert a Duration to a character string
This instruction converts a time period (in the TIME format) to a character string.
The format of the result can be broken down into hours, minutes, seconds and tenths
of a second over 15 characters : HHHHHH:MM:SS.D. This string ends with the
termination character Ø. Each character H,M,S,D represents a number.
The maximum time period corresponds to 119304 hours, 38 minutes, 49 seconds and
5 tenths of a second.
Structure
Ladder language Instruction List language

OPERATE LD TRUE
%MB2:15:=TIME_TO_STRING(%MD40)
[%MB2:15 := TIME_TO_STRING (%MD40)]

Structured Text language

%MB2:15 := TIME_TO_STRING (%MD40) ;

Example : %MB2:15 := TIME_TO_STRING (%MD40)


where %MD40 := 27556330.3 (TIME format)
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
'0' '0' '7' '6' '5' '4' ':' '3' '2' ':' '1' '0' '.' '3' Ø

Syntax
Operator result :=TIME_TO_STRING(Duration)

Operands

Type Result Duration


15-byte tables %MB:15
Indexable double words %MD,%KD
Non-indexable double %ID,%QD
words Immediate value, Numeric expr.

Time period : is in the TIME format.


Note :
If the output string is too short, truncation occurs and system bit %S15 is set to 1.

%MB2:8 := TIME_TO_STRING (%MD40)


==> %MB 2 3 4 5 6 7 8 9
'0' '0' '7' '6' '5' '4' ':' '3' ==> %S15 = 1

___________________________________________________________________________
2/88
Description of advanced instructions 2

B
If the output string is too long, termination type characters Ø are added to the string.
%MB2:16 := TIME_TO_STRING (%MD40)
==>
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
'0' '0' '7' '6' '5' '4' ':' '3' '2' ':' '1' '0' '.' '3' Ø Ø

2.9-16 Convert a Time of day to a character string


This instruction converts a time of day (in the format TOD - TIME_OF_DAY) to a
character string in the format HH:MM:SS on 8 characters plus a termination character
Ø. Each character H,M,S represents a number.

Structure
Ladder language Instruction List language

OPERATE
LD TRUE
%MB2:9:=TOD_TO_STRING(%MD40)
[%MB2:9 := TOD_TO_STRING (%MD40)]

Structured Text language

%MB2:9 := TOD_TO_STRING (%MD40) ;

Example : %MB2:9 := TOD_TO_STRING (%MD40)


where %MD40 := 23:12:27 (TOD format)
==> %MB 2 3 4 5 6 7 8 9 10
'2' '3' ':' '1' '2' ':' '2' '7' Ø

Syntax
Operator result :=TOD_TO_STRING(time)

Operands

Type Result Time of day


9-byte tables %MB:9
Indexable double words %MD,%KD
Non-indexable double %ID,%QD
words Immediate value, Numeric expr.

time : is in the TOD format.

___________________________________________________________________________
2/89
B
Note :
If the output string is too short, truncation occurs and system bit %S15 is set to 1.
%MB2:8 := TOD_TO_STRING (%MD40) (where %MD40 := 23:12:27)
==> %MB 2 3 4 5 6 7 8 9
'2' '3' ':' '1' '2' ':' '2' '7' ==> %S15 = 1

If the output string is too long, termination type characters Ø are added to the string.
%MB2:10 := TOD_TO_STRING (%MD40) (where %MD40 := 23:12:27)
==> %MB 2 3 4 5 6 7 8 9 10 11
'2' '3' ':' '1' '2' ':' '2' '7' Ø Ø

___________________________________________________________________________
2/90
Description of advanced instructions 2

B
2.9-17 Convert a Duration to HHHH:MM:SS
This instruction converts a duration (in the TIME format) to a number of hours-minutes-
seconds, HHHH:MM:SS. The limit values are [0000:00:00, 9999:59:59].

Structure
Ladder language Instruction List language

OPERATE
LD TRUE
%MD100:=TRANS_TIME(%MD2) [%MD100 := TRANS_TIME (%MD2)]

Structured Text language

%MD100 := TRANS_TIME (%MD2) ;

Example : %MD100 := TRANS_TIME (%MD2)


where %MD2 := 86324873 tenths of a second
31 16 8 0
==> MD2
2397 54 47
values expressed in hexadecimal format

Syntax
Operator result :=TRANS_TIME(Duration)

Operands

Type Result Time period


Indexable double words %MD %MD,%KD
Non-indexable double %QD %ID,%QD
words Immediate value, Numeric expr.

result : is in the HMS format.


duration : is in the TIME format.

Notes :
The "duration" parameter (expressed in 1/10 of a second) will be rounded up or down to allow
conversion (accuracy to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0

The maximum converted time period can reach 10000 hours. This means that if the value of the
duration (TIME) provided as a parameter is greater than or equal to 360000000, it cannot be
converted. System bit %S15 is set to 1 and the result is 0000:00:00.
___________________________________________________________________________
2/91
B
2.10 Bit table instructions
2.10-1 Copy one bit table to another bit table
This function copies one bit table into another bit table bit-wise.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%M10:5:=COPY_BIT(%M20:5) [%M10:5 := COPY_BIT (%M20:5)]

Structured Text language

%M10:5 := COPY_BIT (%M20:5) ;

Syntax
Operator result :=COPY_BIT (Tab)

Operands

Type Result Table (tab)


Bit table %M:L, %Q:L, %I:L %M:L, %Q:L, %I:L, %Xi:L

Notes :
• The tables can be of different sizes. In this case, the result table contains the result of the
function executed on a length which is equivalent to the smallest table size, and the rest of the
result table is not modified.
• Beware of overlapping between the input table and the result table.

___________________________________________________________________________
2/92
Description of advanced instructions 2

B
2.10-2 Bit table logic instructions
Associated functions are used to execute a bit-wise logic operation between two bit
tables and load the result into another bit table.
• AND_ARX : logic AND (bit-wise).
• OR_ARX : logic OR (bit-wise).
• XOR_ARX : exclusive OR (bit-wise).
• NOT_ARX : logic complement (bit-wise) of a table.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%M10:7:= AND_ARX(%M20:7, %M30:7) [%M10:7 := AND_ARX (%M20:7,
%M30:7)]
OPERATE
%M50:10:=NOT_ARX(%M60:10) LD TRUE
[%M50:10 := NOT_ARX (%M60:10)]

Structured Text language

%M10:7 := AND_ARX (%M20:7, %M30:7) ;


%M50:10 := NOT_ARX (%M60:10) ;

Syntax
Operator result := AND_ARX (Tab 1, Tab 2)
result := OR_ARX (Tab 1, Tab 2)
result := XOR_ARX (Tab 1, Tab 2)
result := NOT_ARX (Tab 1)

Operands

Type Result Table 1 and 2 (tab)


Bit table %M:L, %Q:L, %I:L %M:L, %Q:L, %I:L, %Xi:L

Notes :
• The tables can be of different sizes. In this case, the result table contains the result of the
function executed on a length which is equivalent to the smallest table size, and the rest of the
result table is not modified.
• Beware of overlapping between the input table and the result table.

___________________________________________________________________________
2/93
B
2.10-3 Copy from a bit table to a word table
This function copies bits from a bit table or part of a bit table to a word table (or double
word table).
Copying from the bit table is from a certain row (brow) for a number of bits (nbit).
Copying to the word table (or double word table) is from the row (wrow or drow)
beginning with the least significant bit of each word.
• BIT_W : Copies from a bit table to a word table.
• BIT_D : Copies from a bit table to a double word table.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%MW10:7:= BIT_W(%M20:29, 3, 22, 2)
[%MW10:7 := BIT_W (%M20:29, 3, 22, 2)]

LD TRUE
OPERATE
[%MD10:4 := BIT_D (%M20:29, 3, 22, 1)]
%MD10:4:=BIT_D(%M20:29, 3, 22, 1)

Structured Text language

%MW10:7 := BIT_W (%M20:29, 3, 22, 2) ;


%MD10:4 := BIT_D (%M20:29, 3, 22, 1) ;

Example : %MW10:7 := BIT_W (%M20:29, 3, 22, 2) ;

%M20:29
row 0
%MW10:7
row 3 (brow)
bit 15 bit 0
row 0

row 2

Number of bits (nbit) :


16 + 6

___________________________________________________________________________
2/94
Description of advanced instructions 2

B
Syntax
Operator result := BIT_W (Tab, brow, nbit, wrow)
result := BIT_D (Tab, brow, nbit, drow)

Operands

Type Result Table (tab) brow - nbit


wrow or drow
Word tables %MW:L
Double word tables %MD:L
Bit tables %M:L, %Q:L, %I:L,
%Xi.L
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW, %QW,
%SW, %NW,
Immediate value
Numeric expr.

Notes :
• If the number of bits to be processed is greater than the number of bits remaining in the table
from the row (brow), the function copies up to the last element in the table.
• If the number of bits to be copied is greater than the number of bits constituting the words
remaining in the result table, the function stops copying at the last element in the word table
(or double word table).
• A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.

___________________________________________________________________________
2/95
B
2.10-4 Copy from a word table to a bit table
This function copies bits constituting all or part of a word table (or double word table)
to a bit table.
Copying from the word table (or double word table) is from a certain row word (wrow
or drow) for a number of words (nwd).
Copying to the bit table is from the row (brow) beginning with the least significant bit
of each word.
• W_BIT : Copies from a word table to a bit table.
• D_BIT : Copies from a double word table to a bit table.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
%M20:36:=W_BIT(%MW10:7,2,2,3)
[%M20:36 := W_BIT (%MW10:7, 2, 2, 3)]

LD TRUE
OPERATE
[%M20:36 := D_BIT (%MD10:4, 1, 1, 3)]
%M20:36:=D_BIT(%MD10:4,1,1,3)

Structured Text language

%M20:36 := W_BIT (%MW10:7, 2, 2, 3) ;


%M20:36 := D_BIT (%MD10:4, 1, 1, 3) ;

Example : %M20:36 := W_BIT (%MW10:7, 2, 2, 3) ;

%M20:36
row 0
%MW10:7 row 3 (brow)
row 19
bit 15 bit 0
row 0

(wrow) row 2

___________________________________________________________________________
2/96
Description of advanced instructions 2

B
Syntax
Operator result := W_BIT (Tab, wrow, nwd, brow)
result := D_BIT (Tab, drow, nwd, brow)

Operands

Type Result Table (tab) wrow or drow


nwd - brow
Bit tables %M:L,%Q:L,%I:L
Word tables %MW:L,%KW:L
Double word tables %MD:L,%KD:L
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW, %QW,
%SW, %NW,
Immediate value
Numeric expr.

Notes :
• If the number of bits to be processed is greater than the number of bits remaining in the table
from the row (wrow), the function copies up to the last element in the table.
• If the number of bits to be copied is greater than the number of bits remaining in the result table,
the function stops copying at the last element in the table.
• A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.

___________________________________________________________________________
2/97
B
2.11 "Orphee" functions : shift, counter
2.11-1 Shifts on words with retrieval of shifted bits
These functions execute arithmetical shifts to the left or right for a number of shifts
(nbit) on a word or a double word (a).

After a shift operation, the value is loaded into (result) and the shifted bits are loaded
into (rest).
• WSHL_RBIT : Shift to left on a word with retrieval of shifted bits.
• DSHL_RBIT : Shift to left on a double word with retrieval of shifted bits.
• WSHRZ_C : Shift to right on a word with filling of spaces by 0 and retrieval of
shifted bits.
• DSHRZ_C : Shift to right on a double word with filling of spaces by 0 and
retrieval of shifted bits.
• WSHR_RBIT : Shift to right on a word with extension of sign and retrieval of shifted
bits.
• DSHR_RBIT : Shift to right on a double word with extension of sign and retrieval
of shifted bits.

Structure
Ladder language Instruction List language

LD TRUE
OPERATE
WSHL_RBIT(%MW20,%MW30,%MW21,%MW10) [WSHL_RBIT(%MW20,%MW30,%MW21,%MW10)]

LD TRUE
OPERATE
[WSHRZ_C(%MW20,%MW30,%MW21,%MW10)]
WSHRZ_C(%MW20,%MW30,%MW21,%MW10)

LD TRUE
OPERATE
[DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)]
DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)

Structured Text language

WSHL_RBIT (%MW20,%MW30,%MW21,%MW10) ;

WSHRZ_C (%MW20,%MW30,%MW21,%MW10) ;

DSHR_RBIT (%MD30,%MW40,%MD20,%MD10) ;

___________________________________________________________________________
2/98
Description of advanced instructions 2

B
Example :
WSHL_RBIT(%MW20,%MW30,%MW21,%MW10) where %MW30 = 4
rest = %MW10 A = %MW20
0000 0000 0000 0001 0001 1111 0110 1000

Copy shifted bits


res = %MW21
1111 0110 1000 0000

Fill bits using zero

WSHRZ_C(%MW20,%MW30,%MW21,%MW10) where %MW30 = 4


a = %MW20 rest = %MW10
1000 0000 1111 0001 0001 0000 0000 0000

Copy shifted bits


res = %MW21
0000 1000 0000 1111

Fill bits using zero

DSHR_RBIT(%MD30,%MW40,%MD20,%MD10) where %MW40 = 6


a = %MD30 rest = %MD10
MSB 1000 0000 1111 0001 0000 0000 0000 0000 MSB

LSB 0000 0000 11 00 1111 0000 0000 00 00 1111 LSB


Copy shifted bits

res = %MD20
keep sign 1 111 11 10 0000 0011 MSB

1100 0100 0000 0011 LSB

propagate sign bit in


bits freed by shift operation

Syntax
Operator WSHL_RBIT (a, nbit, result, rest)
WSHRZ_C (a, nbit, result, rest)
WSHR_RBIT (a, nbit, result, rest)
Operands
Type a nbit result
rest
Indexable words %MW,%KW %MW,%KW, %Xi.T %MW
Non-indexable words %IW, %QW, %IW, %QW, %QW, SW, %NW
%SW, %NW %SW, %NW
Immediate value Immediate value
Numeric expr. Numeric expr.
___________________________________________________________________________
2/99
B
Syntax
Operator DSHL_RBIT (a, nbit, result, rest)
DSHRZ_C (a, nbit, result, rest)
DSHR_RBIT (a, nbit, result, rest)

Operands

Type a nbit result


rest
Indexable double words %MD,%KD %MD
Non-indexable double words %ID,%QD,%SD %QD,%SD
Immediate value
Numeric expr.
Indexable words %MW, %KW, %Xi.T
Non-indexable words %IW, %QW,
%SW, %NW
Immediate value
Numeric expr.

Notes :
• If the parameter (nbit) is not between 1 and 16 for shifts on words, or between 1 and 32 for
shifts on double words, the outputs (result) and (rest) are not significant and system bit %S18 is
set to 1.

___________________________________________________________________________
2/100
Description of advanced instructions 2

B
2.11-2 Up/down counting with indication of over/underflow
This function executes up/down counting with an indication of an over/underflow. The
function is only executed when the enable input (en) is at 1.
Two independent inputs (cu and cd) are used to upcount and downcount events.
Output (Qmin) is set to 1 when the minimum threshold (min) is reached and output
(Qmax) is set to 1 when the maximum threshold (max) is reached.
The initial counter value is fixed by parameter (pv) and the current counter value is
given by parameter (cv).
A 16-bit word (mwd) is used to archive the state of the cu and cd inputs (bit 0 to archive
cu and bit 1 to archive cd).

Structure
Ladder language Instruction List language

OPERATE LD TRUE
SCOUNT (%M9,%MW10,%M11,%M12,%MW11, [SCOUNT(%M9,%MW10,%M11,%M12,%MW11,
%MW12,%M16,%M10,%MW15,%MW20) %MW12,%M16,%M10,%MW15,%MW20)]

Structured Text language

SCOUNT(%M9,%MW10,%M11,%M12,%MW11,%MW12,%M16,%M10,%MW15,%MW20) ;

Example :
SCOUNT (%M9,%MW10,%M11,%M12,%MW11,%MW12,%M16,%M10,%MW15,%MW20)
where %MW10 (pv) = 5, %MW11 (min) = 0, %MW12 (max) = 7

en : %M9

cd : %M12

mcd : %MW20:X1

cu : %M11

mcu : %MW20:X0

Qmax : %M10

Qmin : %M16

cv = %MW15 5 4 5 65 6 7 5
___________________________________________________________________________
2/101
B
Syntax
Operator SCOUNT (en, pv, cu, cd, min, max, Qmin, Qmax, cv, mwd)

Operands
Type en, cu, cd Qmin, Qmax pv, min, max cv, mwd
Bits %I,%Q,%M,%S, %I,%Q,%M
%BLK,%.:Xk
Indexable words %MW,%KW, %Xi.T %MW
Non-indexable words %IW, %QW, %QW,%SW
%SW, %NW, %NW
Immed. val.
Numeric expr.

Notes :
• If (en) = 0 then the function is no longer enabled and on each call, there is :
Qmin = Qmax = 0
mcu = mcd = 0
cv = pv
• If max > min then :
cv > max ---> Qmax = 1 and Qmin = 0
min < cv < max ---> Qmax = Qmin = 0
cv < min ---> Qmax = 0 and Qmin = 1
• If max < min then :
max < cv - min ---> Qmax = 1 and Qmin = 0
cv < max ---> Qmax = 0 and Qmin = 1
cv > min ---> Qmax = 1 and Qmin = 0
• If max = min then :
cv < min and max ---> Qmax = 0 and Qmin = 1
cv > min and max ---> Qmax = 1 and Qmin = 0
• Modifying parameter (pv) with (en) at 1 has no effect on operation.
• A negative value for parameters (pv) and (min) is interpreted as a zero value.
• A value less than 1 for parameter (max) is interpreted as 1.

___________________________________________________________________________
2/102
Description of advanced instructions 2

B
2.11-3 Circular shift operations
This function carries out circular shift operations to the left or the right on a word or a
double word.
• ROLW : circular shift to the left on a word with a calculated number of shifts
• RORW : circular shift to the right on a word with a calculated number of shifts
• ROLD : circular shift to the left on a double word with a calculated number of shifts
• RORD : circular shift to the right on a double word with a calculated number of shifts

Structure

Ladder language Instruction List language

%M0 LD %M0
[%MW0 := ROLW(%MW10,%MW5)]
%MW0:=ROLW(%MF10,%MW5)

%I3.2 LD %I3.2
[%MD10 := RORD(%MD100,%MW5)]
%MD8:=RORD(%MD50,%MW5)

Structured Text language

IF %M0 THEN
%MW0 := ROLW(%MW10,%MW5) ;
END_IF ;
IF %I3.2 THEN
%MD10 := RORD(%MD100,%MW5) ;
END_IF ;

___________________________________________________________________________
2/103
B
Syntax
Operators
• ROLW, RORW, ROLD, RORD Op1:=Operator(Op2,n)

Operands ROLW, RORW,

Type Operand 1 (Op1) Operand 2 (Op2) Position number (n)


Indexable words %MW %MW,%KW,%Xi.T %MW,%KW,%Xi.T
Non-indexable words Imm. val.,%IW,%QW, Imm. val.,%IW,%QW,
%SW,%NW,%BLK %SW,%NW,%BLK
Num. expr. Num. expr.

Operands ROLD, RORD

Type Operand 1 (Op1) Operand 2 (Op2) Position number (n)


Indexable double words %MD %MD,%KD %MW,%KW,%Xi.T
Non-indexable words %QD,%SD, Imm. val.,%ID,%QD, Imm. val.,%IW,%QW,
%SD, Num. expr. %SW,%NW,%BLK
Num. expr.

Note
For preference, use the standard instructions ROL and ROR when the shift number
is static, as these instructions offer the best performance.

___________________________________________________________________________
2/104
Description of advanced instructions 2

B
2.12 Time delay functions

2.12-1 General

Unlike predefined function blocks, these time delay functions are unlimited in number
and can be used in the code for DFB function blocks.
There are four time delay functions.
• FTON : On-delay
• FTOF : Off-delay
• FTP : Pulse time delay
• FPULSOR : square wave signal

2.12-2 FTON on-delay function

This function is used to manage on-delays. The delay can be programmed.

Syntax
Operator FTON (EN, PT, Q, ET, PRIV)

Characteristics
"Enable" EN Triggers delay on rising edge
input
Preset value PT Input word which determines the duration (in
hundredths of a second) of the delay. It can be
used to define a maximum of 5 min and 27 s
with a precision of 10 ms. (1)
"Timer" output Q Output set to 1 at the end of the delay.
Current value ET Output word which increases from 0 to PT
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with this double word
(1) modifications to this word are taken into account during the delay.

___________________________________________________________________________
2/105
B
On a rising edge of input EN, the timer is
launched : its current value ET increases
from 0 to PT (in hundredths of a second). EN
Output bit Q changes to 1 when the cur-
rent value reaches PT and remains at 1
Q
as long as EN is at 1.
When input EN is at 0, the timer is PT
stopped even if it was changing : ET takes ET
value 0.

Structure
Ladder language Instruction List language
%I1,2
OPERATE LD %I1.2
FTON (%I3.0,1000,%Q4.0,%MW2,%MD8)
[FTON (%I3.0,1000,%Q4.0,%MW2,%MD8)]

Structured Text language

IF %I1.2 THEN
FTON (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
END_IF ;

Operands
FTON (EN, PT, Q, ET, PRIV)

Type EN PT Q ET PRIV
Indexable words %MW,%KW,%Xi.T %MW
Non-indexable %IW,%QW,%SW %IW,%QW
words Immed. val.,
Num. expr.,%NW
Indexable %MD
double words
Bits %I,%Q, %M, %S %I,%Q, %M,
%BLK,%•:Xk,%X %S,%•:Xk,%X

___________________________________________________________________________
2/106
Description of advanced instructions 2

B
2.12-3 FTOF off-delay function
This function is used to manage off-delays. The delay can be programmed.

Syntax
Operator FTOF (EN, PT, Q, ET, PRIV)

Characteristics
"Enable" EN Triggers delay on falling edge
input
Preset value PT Input word which determines the duration (in
hundredths of a second) of the delay. It can be
used to define a maximum duration of 5 min and
27 s with a precision of 10 ms. (1)
"Timer" output Q Output set to 1 on a rising edge of EN and set
to 0 at the end of the delay.
Current value ET Output word which increases from 0 to PT
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with this double word.
(1) modifications to this word are taken into account during the delay.

On a rising edge of input EN, current


value ET is set to 0, (even if the timer is
changing). On a falling edge of input EN, EN
the timer is launched.
The current value then increases from 0
to PT (in hundredths of a second). Output Q
bit Q is set to 1 as soon as a rising edge
PT
is detected on input EN and falls to 0
ET
when the current value reaches PT.

Structure
Ladder language Structured Text language
IF %I1.2 THEN
%I1,2 FTOF (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
OPERATE
FTOF (%I3.0,1000,%Q4.0,%MW2,%MD8) END_IF ;

Operands see FTON function (previous section).


___________________________________________________________________________
2/107
B
2.12-4 FTP pulse delay function

This function is used to generate a pulse of a precise duration. The duration can be
programmer.

Syntax
Operator FTP (EN, PT, Q, ET, PRIV)

Characteristics

"Enable" EN Triggers delay on rising edge


input
Preset value PT Input word which determines the duration (in
hundredths of a second) of the delay. It can be
used to define a maximum delay of 5 min and
27 s with a precision of 10 ms. (1)
"Timer" output Q Output set to 1 at the end of the delay.
Current value ET Output word which increases from 0 to PT
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with the double word.
(1) modifications to this word are taken into account during the delay.

On a rising edge of input EN, the delay is


launched (if the timer is not already
changing). The current value ET then
increases from 0 to PT (in hundredths of EN

a second). Output bit Q changes to 1 as


soon as the timer is launched and falls to Q
0 when the current value reaches PT.
When input EN and output Q are at 0, PT PT
takes the value 0. ET
This monostable cannot be reactivated.

Structure
Ladder language Structured Text language
IF %I1.2 THEN
%I1,2 FTP (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
OPERATE
FTP (%I3.0,1000,%Q4.0,%MW2,%MD8) END_IF ;

Operands see FTON function (previous section).


___________________________________________________________________________
2/108
Description of advanced instructions 2

B
2.12-5 FPULSOR function for generating square wave signals
This function is used to generate a periodic square wave signal. Its pulse width can
be set to 1 or 0 via the program using 2 timers :
• TON : on-delay (for pulse at 1).
• TOFF : off-delay (for pulse at 0).

Syntax
Operator FPULSOR (EN, TON, TOFF, Q, ET, PRIV)

Characteristics

"Enable" EN Triggers the generation of a square wave signal


input on rising edge.
Preset value TON Input word which determines the duration (in
(pulse at 1) hundredths of a second (pulse set to 1)) of the
delay. It can be used to define a maximum
duration of 5 min and 27 s with a precision of 10
ms. (1)
Preset value TOFF Input word which determines the duration (in
(pulse at 0) hundredths of a second (pulse set to 0)) of the
delay. It can be used to define a maximum
duration of 5 min and 27 s with a precision of 10
ms. (1)
Square signal output Q Pulse output set to 0 during TOFF, to 1 during
TON.
Current value ET Output word which increases from 0 to TON+TOFF
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with this double word.
(1) Any modifications made to these words will be taken into account during the delay.
TOFF+TON has a total maximum duration of 5 min and 27 s.

On a rising edge of input EN, the square


wave signal is generated (if the signal is
not already changing). The current value
TOFF TOFF TOFF
ET then increases from 0 to TON+TOFF
(in hundredths of a second). Output bit Q TON+TOFF
TON TON

remains at 0 while delay TOFF is effective;


it changes to 1 and remains at 1 during
delay TON, then changes back to 0 while
delay TOFF is effective, etc, until input EN
returns to 0.

___________________________________________________________________________
2/109
B
Structure
Ladder language Instruction List language

LD True
OPERATE
PULSOR (%I3.0,500,200,%Q4.0,%MW2,%MD8)
[FPULSOR (%I3.0,500,200,%Q4.0,%MW2,
%MD8)]

Structured Text language

IF %I1.2 THEN
FPULSOR (%I3.0,500,200,%Q4.0,%MW2,%MD8) ;
END_IF ;

Operands
FPULSOR (EN, TON, TOFF, Q, ET, PRIV)

Type EN TON,TOFF Q ET PRIV


Indexable words %MW,%KW,%Xi.T %MW
Non-indexable %IW,%QW,%SW %IW,%QW
words Imm. val.
Num. expr.,%NW
Indexable %MD
double words
Bits %I,%Q, %M, %S %I,%Q, %M,
%BLK,%•:Xk,%X %S,%•:Xk,%X

___________________________________________________________________________
2/110
Description of advanced instructions 2

B
2.13 Data archiving functions

2.13-1 General
These functions can be used to archive data via the program in a dedicated zone in
the user memory card.

Application examples :
• automatic archiving of application data (status logging, logs, etc) in the PLC user
memory card and remote transmission of data (via modem) to the mainframe
• back-up of production tests in the PLC user memory card

References for memory cards which provide the additional data archiving function :

References Type/Capacity Compatibility with processors

Application Archiving TSX P57 102 TSX P57 2i2 TSX P57 3i2
program zone TPMX P57 102 TPMX P57 202 TSX P57 4i2
zone (RAM TPCX 57 1012 TPMX P57 352
type) TSX 37 21/22 TPMX P57 452
TPCX 57 3512
TSX MRP 232P RAM/32 K16 128K16 Yes Yes Yes

TSX MRP 264P RAM/64 K16 128K16 Yes Yes Yes

TSX MRP 2128P RAM/128 K16 128K16 No Yes Yes

TSX MRP 3256P RAM/256 K16 640K16 No Yes Yes


TSX MFP 232P Flash Eprom/ 128K16 Yes Yes Yes
32 K16

TSX MFP 264P Flash Eprom/ 128K16 Yes Yes Yes


64 K16

Note: 10 words in the dedicated archiving zone are reserved by the system.

3 functions can be used to archive and retrieve data :


• SET_PCMCIA to initialize all or part of the archiving zone of the memory card at a
set value
• WRITE_PCMCIA to write data to the archiving zone of the memory card
• READ_PCMCIA to read data from the archiving zone of the memory card

Note: data stored in the archiving zone of the memory card can only be accessed by the
application resident in the PLC using these 3 basic functions. A remote station cannot directly
access the data via a network or communication bus.

___________________________________________________________________________
2/111
B
2.13-2 Initializing the archiving zone
The SET_PCMCIA function can be used to initialize all or part of the archiving zone of
the user memory card at a specified value.

This function uses 4 parameters :


• address : archiving zone address at which the initialization is executed
• no_words : number of words to be initialized
• value : initialization value
• status : code giving the result of the execution of the initialization command

User memory card

1500
100
100

SET_PCMCIA
100
100 1529

In the above example :


• address = %MD0, %MD0 contains the value 1500
• no_words = %MW5, %MW5 contains the value 30
• source = %MW10, %MW10 contains the value 100

Structure
Ladder language Instruction List language

%I1,3 LDR %I1.3


OPERATE
P SET_PCMCIA(%MD0, %MW5, %MW10,%MW2) [SET_PCMCIA (%MD0, %MW5,
%MW10,%MW2)]

Structured Text language


IF RE %I1.3 THEN
SET_PCMCIA (%MD0, %MW5,
%MW10,%MW2);
END_IF;

___________________________________________________________________________
2/112
Description of advanced instructions 2

B
Syntax
Function SET_PCMCIA (address, no_words, value, status)

Parameters
Type Address No_words Value Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.

Non-indexable words %QW,%SW,%NW


Indexable double words %MD,
Immed. val.

Non-indexable double words %QD,%SD

Status parameter code returned after execution of the initialization command


Value (in hexadecimal) Meaning
0000 Initialization executed correctly
0201 No file zone in the memory card
0202 Memory card fault
0204 Memory card write-protected
0241 Negative address
0242 Address + No_words-1 > highest address of memory card
0401 No_words = 0 or negative

___________________________________________________________________________
2/113
B
2.13-3 Writing data to the archiving zone
The WRITE_PCMCIA function is used to transfer data from the RAM memory of the PLC
(%MW words) to the archiving zone of the user memory card.
This function uses 4 parameters :

WRITE_PCMCIA (des_ad, no_words, source, status)

• des_ad : archiving zone address from which data is stored


• no_words : number of words to be stored
• source : word containing the address of the start of the zone to be transferred to the
memory card
• status : code giving the result of the write command

PLC RAM memory User memory card

%MW40
WRITE_PCMCIA

%MW69
1500

1529

In the above example :


• des_ad = %MD0, %MD0 contains the value 1500
• no_words = %MW5, %MW5 contains the value 30
• source = %MW20 contains the value 40

Structure
Ladder language Instruction List language

%I1,3 LDR %I1.3


OPERATE
P WRITE_PCMCIA(%MD0, %MW5, %MW20,%MW2)
[WRITE_PCMCIA (%MD0, %MW5,
%MW20,%MW2)]

Structured Text language

IF RE %I1.3 THEN
WRITE_PCMCIA (%MD0, %MW5,
%MW20,%MW2);
END_IF;

___________________________________________________________________________
2/114
Description of advanced instructions 2

B
Syntax
Function WRITE_PCMCIA (des_ad, no_words, source, status)

Parameters
Type Des_ad No_words Source Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.

Non-indexable words %QW,%SW,%NW


Indexable double words %MD,
Immed. val.

Non-indexable double words %QD,%SD

Status parameter code returned after execution of the write command :


Value (in hexadecimal) Meaning
0000 Write executed correctly
0102 Source + No_words-1 > maximum number of %MW
declared in the PLC
0104 No valid application or no %MW in the PLC
0201 No file zone in the memory card
0202 Memory card fault
0204 Memory card write-protected
0241 Des_ad < 0
0242 Des_ad + No_words-1 > highest address in the memory
card
0401 No_words = 0

___________________________________________________________________________
2/115
B
2.13-4 Reading data from the archiving zone
The READ_PCMCIA function is used to transfer data from the archiving zone of the user
memory card to the RAM memory of the PLC (%MW words).
This function uses 4 parameters :

READ_PCMCIA (source_ad, no_words, dest, status)

• source_ad : archiving zone address at which the data to be read is stored


• no_words : number of words to be read
• dest : word containing the address of the start of the zone to be transferred by the
memory card
• status : code giving the result of the read command
PLC RAM memory User memory card

%MW40 READ_PCMCIA

%MW69
1500

1529

In the above example :


• source_ad = %MD0, %MD0 contains the value 1500
• no_words = %MW5, %MW5 contains the value 30
• dest = %MW20 contains the value 40

Structure
Ladder language Instruction List language

%I1,4 LDR %I1.4


OPERATE
P READ_PCMCIA(%MD0, %MW5, %MW20,%MW2) [READ_PCMCIA (%MD0, %MW5,
%MW20,%MW2)]

Structured Text language

IF RE %I1.4 THEN
READ_PCMCIA (%MD0, %MW5,
%MW20,%MW2);
END_IF;

___________________________________________________________________________
2/116
Description of advanced instructions 2

B
Syntax
Function READ_PCMCIA (source_ad, no_words, dest, status)

Parameters
Type Source_ad No_words Dest Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.

Non-indexable words %QW,%SW,%NW


Indexable double words %MD,
Immed. val.

Non-indexable double words %QD,%SD

Status parameter code returned after execution of the read command :


Value (in hexadecimal) Meaning
0000 Read executed correctly
0102 Dest + No_words-1 > maximum number of %MW declared in
the PLC
0104 No valid application or no %MW in the PLC
0201 No file zone in the memory card
0202 Memory card fault
0204 Memory card write-protected
0241 Source_ad < 0
0242 Source_ad + No_words-1 > highest address in the
memory card
0401 No_words = 0

___________________________________________________________________________
2/117
B

___________________________________________________________________________
2/118
Section
System bits and words 33
3 System bits and words
B
3.1 System bits
3.1-1 List of system bits

Bit Function Init. state Control (1)

%S0 1 = cold start (power return 0 S or U->S B


with loss of data)

%S1 1 = warm restart (power return no 0 S or U->S


loss of data)

%S4,%S5,
%S6,%S7 Time base 10ms, 100ms, 1s, 1mn - S

%S8 (2) Wiring test 1 U


(can be used on a non-configured TSX 37 PLC)

%S9 1 = force PLC outputs into fallback position 0 U

%S10 0 = I/O fault 1 S

%S11 1 = watchdog overflow 0 S

%S13 1 = first scan after setting to RUN - S

%S15 1 = character string fault 0 S->U

%S16 0 = task I/O fault 1 S->U

%S17 1 = overflow 0 S->U

%S18 1 = overflow or arithmetic error 0 S->U

%S19 1 = task period overflow 0 S->U

%S20 1 = index overflow 0 S->U

%S21 1 = Grafcet initialization 0 S or U->S

%S22 1 = Grafcet resetting 0 U->S

%S23 1 = Grafcet preposition and freeze 0 U->S

%S24 (3) 1 = reset macro-steps to 0 according to %SW22 to 25 0 S

%S26 1 = table overflow (steps/transitions) 0 S

%S30 1 = activation of the master task 1 U

%S31 1 = activation of the fast task 1 U

%S38 1 = enable events 1 U

%S39 1 = saturation of event processing 0 S->U

%S40 to %S47 1 = I/O fault of a TSX 57 rack (3) 1 S

%S49 1 = reset tripped solid state outputs 0 U

%S50 1 = set real-time clock 0 U


___________________________________________________________________________
(1) (2) and (3) see next page. 3/1
B
Bit Function Init. state Control (1)

%S51 1 = loss of real-time clock time 0 S or U->S

%S59 1 = enable adjustment of current date 0 U

%S60 Redundant architecture control 0 U or U->S

%S66 (2) 1 = battery indicator always off 0 U

%S67 0 = memory cartridge battery operating - S

%S68 0 = backup battery (processor) operating - S


%S69 (2) 1 = enable WORD memory display 0 U
mode on displays
%S70 1 = update data on As-i bus or TSX Nano link 0 S->U

%S73 (2) 1 = switch to protected mode on AS-i bus 0 U->S

%S74 (2) 1 = save configuration on AS-i bus 0 U->S

%S80 1 = reset message counters 0 S->U

%S90 1 = update common words 0 S->U

%S92 1 = switch to communciation function performance 0 U


measurement mode

%S94 (3) 1 = save DFB adjustment values 0 U->S

%S95 (3) 1 = restore DFB adjustment values 0 U->S

%S96 (2) 0 = application program backup invalid 0 S->U


1 = application program backup valid

%S97 (2) 0 = %MW backup invalid - S


1 = %MW backup valid

%S98 (2) 1 = replace TSX SAZ 10 module pushbutton 0 U


with discrete input

%S99 (2) 1 = replace centralized display block pushbutton 0 U


with discrete input

%S100 1 = restore DFB adjustment values - S


%S101 1 = diagnostic buffer configured - S
%S102 1 = diagnostic buffer full - S
%S118 0 = FIPIO I/O fault 1 S

%S119 0 = in-rack I/O fault 1 S

(1) S = controlled by the system, U = controlled by the user, U->S = set to 1 by the user, reset to
0 by the system, S->U = set to 1 by the system, reset to 0 by the user.
(2) only on TSX 37.
(3) only on TSX/PMX/PCX 57.
___________________________________________________________________________
3/2
System bits and words 3

B
3.1-2 Detailed description of system bits
TSX 37 and TSX 57 PLCs have %Si system bits which indicate the status of the PLC or
enable the user to intervene in its operation.
These bits can be tested in the user program in order to detect any operating event which
requires special processing. Some of them must be rest to their initial or normal state by B
the program. However, the system bits which have been reset to their initial or normal state
by the system must not be reset by the program or the terminal.
System Function Description
bits

%S0 Cold Normally at 0. It is set to 1 by :


start • A power return with loss of data (battery fault).
• The user program.
• The terminal.
• Changing a cartridge.
• Pressing the RESET button.
This bit is set to 1 during the first complete scan. It is reset to 0
before the next scan.
Operation : see part A, section 1.4.
%S1 Warm Normally at 0. It is set to 1 by :
restart • A power return with saving of data.
• The user program.
• The terminal.
It is reset to 0 by the system at the end of the first complete scan
and before the outputs are updated.
Operation : see part A, section 1.4.
Time Changes in the state of these bits are controlled by an internal
base clock. They are not synchronized with the PLC scan.
%S4 10ms
%S5 100ms
%S6 1s Example : %S4
%S7 1min
5ms 5ms
%S8 Wiring Normally at 1, this bit is used to test the wiring when the TSX 37
test PLC is in the "not configured" state.
• At state 1 the outputs are forced to 0.
• At state 0 the outputs can be modified by an adjustment terminal.

%S9 Placing outputs Normally at 0. It can be set to 1 by the program or by the terminal :
in fallback • At state 1 PLC outputs are forced into fallback position (bus X,
position on FIPIO, AS-i, etc).
all buses • At state 0 outputs are updated normally.

%S10 I/O Normally at 1. It is set to 0 when an I/O fault is detected on an in-


fault rack module or a remote module (FIPIO) (configuration fault,
exchange fault, hardware fault). Bit %S10 is reset to 1 when the
fault disappears.

___________________________________________________________________________
3/3
B
System Function Description
bits

%S11 Watchdog Normally at 0. It is set to 1 by the system when the execution of a


overflow task exceeds the maximum execution time (watchdog) declared
during configuration.
Watchdog overflow causes the PLC to change to STOP and the
application stops in error mode (ERR indicator lamp flashing).
%S13 First Normally at 0. It is set to 1 by the system during the first scan
scan after the PLC has been set to RUN.
%S15 Character Normally at 0. It is set to 1 when the destination zone of a
string fault character string transfer is not sufficiently large to receive that
character string. This bit must be reset to 0 by the user.
%S16 Task I/O Normally at 1. It is set to 0 by the system if a fault occurs in an
fault in-rack or remote I/O module on FIPIO. This bit must be reset to 1
by the user. This task controls its own %S16 bit.
%S17 Output bit on Normally at 0. It is set to 1 by the system :
shift or • During a shift operation. It contains the state of the last bit.
arithmetic • If overflow occurs in a non-signed arithmetic operation (dates).
carry This bit must be reset to 0 by the user.
%S18 Arithmetic Normally at 0. It is set to 1 in the case of overflow during a
overflow or 16-bit operation, where :
error • Result is greater than + 32767 or less than - 32768 for single
length operations.
• Result is greater than + 2 147 483 647 or less than
- 2 147 483 648 for double length operations.
• Result is greater than +3.402824E+38 or less than
-3.402824E+38 for floating point operations (software version > 1.0).
• Capacity overflow in DCB.
• Division by 0.
• The square root of a negative number.
• Forcing to a non-existent step on a drum controller.
• Stacking a full register and unstacking an 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 an
overflow occurs.

%S19 Task Normally at 0. It is set to 1 by the system in the event of a scan


period period overrun (task scan time greater than the period defined by
overrun the user during configuration or programmed in word %SW
(periodic associated with the task).
scan) This bit is reset to 0 by the user.
Each task controls its own %S19 bit.

___________________________________________________________________________
3/4
System bits and words 3

B
System Function Description
bits
%S20 Index Normally at 0. It is set to 1 when the address of the indexed object
overflow becomes less than 0 or exceeds the number of objects declared
during configuration. B
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 an overflow
occurs.
%S21 Grafcet This bit is controlled by the user to initialize the Grafcet (preferably
initialization set to 1 during preprocessing). It is reset to 0 by the system after
Grafcet initialization (at the end of preprocessing, during
assessment of the new Grafcet state). Grafcet initialization
involves deactivating all active steps and activating initial steps.
On a cold start, this bit is set to 1 by the system during
preprocessing.
%S22 Resetting Normally at 0, this bit can only be set to 1 by the program during
Grafcet preprocessing.
At state 1, it causes all Grafcet steps to deactivate. It is reset to 0 by
the system after acknowledgment of the end of the preprocessing.
%S23 Grafcet Normally at 0, setting %S23 to 1 causes the Grafcet state
freezing to be maintained. Whatever the value of the transition conditions
upstream of the active steps, the Grafcet chart does not change.
Freeze is maintained as long as bit %S23 is set to 1.
This bit is controlled by the user program. It is set to 1 or 0 only
during preprocessing.
%S24 Resetting Normally at 0, setting %S24 to 1 resets the selected macro-steps in
macro steps a table of 4 system words %SW22 to %SW25 to 0. It is reset to 0
to 0 by the system after acceptance at the end of the preprocessing.
%S26 Table Normally at 0, it is set to 1 by the system when activation
overflow capacities (steps or transitions) are exceeded or when trying to
(steps/ execute an incorrectly defined chart (such as a destination
transitions) connector to a step which is not part of the chart). An overflow
causes the PLC to STOP.
This bit is reset to 0 when the terminal is initialized.
%S30 Master task Normally at 1. If it is set to 0 by the user, the master task is
activation/ deactivated.
deactivation
%S31 Fast task Normally at 1. If it is set to 0 by the user, the fast task is
activation deactivated.
%S38 Enable/ Normally at 1. If it is set to 0 by the user, events are disabled.
disable
events
%S39 Saturation This bit is set to 1 by the system to show that one or more events
of event cannot be processed due to saturation of the stacks.
processing This bit is reset to 0 by the user.

___________________________________________________________________________
3/5
B
System Function Description
bits
%S40 I/O fault Bits %S40 to %S47 are assigned to racks 0 to 7 respectively.
to (racks) (1) Normally at 1, each of these bits is set to 0 should
%S47 an I/O fault occur on the corresponding rack.
The bit is reset to 1 when the fault has cleared.
%S49 Reactivate Normally at state 0. This bit can be set to 1 by the user to
outputs (2) request a reactivation every 10s from the occurrence of a solid
state output fault triggered by an over-current or a short-circuit.
%S50 Updating Normally at 0. This bit can be set to 1 or to 0 by the program or by
the date the terminal.
and time • At 0 it accesses the date and time by reading system words
using words %SW50 to 53.
%SW50 to 53 • At 1 it updates the date and time by writing system words
%SW50 to 53.
%S51 Loss of This bit, which is managed by the system, signals at 1 either that
real-time the real-time clock is missing or that the system words relating to
clock the real-time clock are not significant. In this case, the clock should
time be set.
Setting the time automatically changes the bit to 0.
%S59 Updating Normally at 0. This bit can be set to 1 or to 0 by the program or by
the date the terminal.
and time • At 0 the system does not control system word %SW59.
using word • At 1 the system controls the rising and falling edges on word
%SW59 %SW59 to adjust the current date and time (in increments).
%S60 Redundant System bit used when installing a redundant architecture
architecture (see description and use in the "Redundant Premium
command architecture" manual).

%S66 Control of Normally at 0. This bit can be set to 1 or to 0 by the program or by


battery the terminal. It is used to switch the battery indicator on or off, if
the indicator backup battery is faulty or missing :
• At 0 the battery indicator lights up if the battery is faulty or missing
• At 1 the battery indicator is always off
On a cold start, %S66 is reset to 0 by the system.
%S67 State of This bit is used to check operation of the backup battery for the RAM
cartridge memory cartridge.
battery • At 0 the battery is present and operating.
• At 1 the battery is absent or not operating.
%S68 State of This bit is used to check operation of the backup battery for
processor program and data in the RAM memory.
battery • At 0 the battery is present and operating.
• At 1 the battery is absent or not operating.

(1) only on TSX/PMX/PCX 57 PLCs.


(2) only on TSX37 PLCs.

___________________________________________________________________________
3/6
System bits and words 3

B
System Function Description
bits
%S69 Display of Normally at 0. This bit can be set to 1 or to 0 by the program or by
user data the terminal.
on PLC • At 0 the state of the I/O are displayed on the PLC indicator lamps B
displays (WRD indicator lamp off).
• At 1 user data is displayed (WRD indicator lamp on).
(see words %SW67,68 and 69).
%S70 Update data This bit is set to 1 by the system at the end of each TSX Nano or
on AS-i bus AS-i bus scan. On power-up, it indicates that all the data has been
or TSX Nano refreshed at least once and that it is therefore significant. This bit is
link reset to 0 by the user.
%S73 Switch to Normally at 0. This bit is set to 1 by the user to change to
protected mode protected mode on AS-i bus. Bit %S74 must first be at 1. This
on AS-i bus bit is only used in a wiring test, and has no application in the PLC.
%S74 Save Normally at 0. This bit is set to 1 by the user to save the
configuration configuration present on the AS-i bus. This bit is only used in a
present wiring test, and has no application in the PLC.
on AS-i bus
%S80 Reset Normally at 0. This bit can be set to 1 by the user in order to reset
message message counters %SW80 to %SW86.
counters
%S90 Refresh Normally at 0. This bit is set to 1 when common words are received
common from another station on the network. This bit can be set to 0 by the
words program or by the terminal to check the exchange cycle of common words.
%S92 Switch to Normally at 0, this bit can be set to 1 by the user to set the
communication communication functions in performance measurement mode.
function The communication function Time-out parameter then displays the
meas. mode exchange loop-back time in tenths of ms (if this time<10, otherwise
insignificant.)
%S94 Save DFB Normally at 0, this bit can be set to 1 by the user to save the
adjustments adjustment values of user function blocks.
%S95 Restore DFB Normally at 0, this bit can be set to 1 by the user to save the
adjustments restore values of user function blocks.
%S96 Validity of 0 -> application program backup invalid,
application 1 -> application program backup valid.
program This bit can be read at any time (by the program or in adjust
backup mode) and in particular after a cold or warm restart.
It is relevant to a Backup application created using PL7 in the
internal Flash EPROM.
%S97 Validity of 0 -> %MW backup invalid,
%MW backup 1 -> %MW backup valid.
This bit can be read at any time (by the program or in adjust mode)
and in particular after a cold start or warm restart.
%S98 Locate Normally at 0. This bit is managed by the user :
pushbutton 0 -> pushbutton on TSX SAZ 10 module active,
on TSX SAZ 10 1 -> pushbutton on TSX SAZ 10 module replaced by a discrete
module remotely input (see %SW98).
___________________________________________________________________________
3/7
B
System Function Description
bits
%S99 Locate Normally at 0. This bit is managed by the user :
pushbutton 0 -> pushbutton on centralized display block active,
on display 1 -> pushbutton on centralized display block replaced by a discrete
block remotely input (see %SW99).
%S100 Terminal Set to 0 or 1 by the system depending on the state of the INL/DPT
port shunt on the terminal port.
protocol • If the shunt is absent (%S100=0), UNI-TELWAY master
protocol is used.
• If the shunt is present (%S100=1), the protocol used is that
indicated by the application configuration.
%S101 Diagnostic This bit is set to 1 by the system when the diagnostic option is
buffer configured, and a diagnostic buffer designed to store errors
configured sent by diagnostic DFBs is then reserved.
%S102 Diagnostic This bit is set to 1 by the system when the buffer receiving errors
buffer from diagnostic function blocks is full.
full
%SW118 General FIPIO Normally at 0, this bit is set to 0 by the system if a fault occurs on
I/O fault a device connected to the FIPIO bus. When the fault disappears,
this bit is reset to 1 by the system.
%SW119 General I/O Normally at 1, this bit is set to 0 by the system if a fault occurs on
in-rack fault an in-rack I/O module. When the fault disappears, this bit is reset
to 1 by the system.

___________________________________________________________________________
3/8
System bits and words 3

B
3.2 System words
3.2-1 List of system words
Word Function Control
%SW0 Value of master task period (periodic task) U
%SW1 Value of fast task period U B
%SW8 Control input acquisition of each task U
%SW9 Control output updating of each task U
%SW10 First scan after cold restart S
%SW11 Watchdog time S
%SW12 UNI-TELWAY terminal port address S
%SW13 Main address of the station S
%SW17 Fault status on floating point operation S and U
%SD18 Absolute time counter S and U
%SW20 Number of steps active, to activate or to deactivate S
%SW21 Number of transitions validated, to validate and to devalidate S
%SW22 to Table of 4 words used for designating macro-steps to be reset to 0 U
%SW25 (2) when bit %S24 is set to 1
%SW31 Maximum time of master task scan S
%SW31 Maximum time of master task scan S
%SW32 Minimum time of master task scan S
%SW33 Execution time of last fast task scan S
%SW34 Maximum time of fast task scan S
%SW35 Minimum time of fast task scan S
%SW48 Number of events processed S and U
%SW49 (1) Real-time clock function : words containing the current S and U
%SW50 (1) date and time values (in BCD)
%SW51 (1) %SW49 =day of the week (type of day)
%SW52 (1) %SW50 = seconds %SW51 = hours and minutes
%SW53 (1) %SW52 = month and day %SW53= century and year
%SW54 (1) Real-time clock function : words containing the date and time of the S
%SW55 (1) last power failure or PLC stop (in BCD)
%SW56 (1) %SW54 = seconds and fault code %SW55 = hour and minute
%SW57 (1) %SW56 = month and day %SW57= century and year
%SW58 Identification code of last stop and day of the week (type of day) S
%SW59 Incremental adjustment of the current date and time U
%SW60 to Redundant PLC diagnostics S
%SW66
%SW67 Control "Display" mode, S and U
%SW68 %SW67: read pushbuttons
%SW69 %SW68: current and maximum indices of "displayed objects"
%SW69: number of the first object in the zone displayed
%SW80 No of messages transmitted by the system to the terminal port S and U
%SW81 No of messages received by the system from the terminal port
%SW82 No of messages transmitted by the system to the PCMCIA card
%SW83 No of messages received by the system from the PCMCIA card
%SW84 No of telegrams transmitted by the system
%SW85 No of telegrams received by the system
%SW86 No of messages refused by the system
(1) S = managed by the system, U = managed by the user.
(2) only on TSX 57.
(3) only on TSX 37-21/22 and TSX 57.
___________________________________________________________________________
3/9
B
Word Function Supervisor(1)
%SW87 Number of requests processed by the synchronous server per S
master task cycle (MAST).
%SW88 Number of requests processed by the asynchronous server per S
master task cycle (MAST).
%SW89 Number of requests processed by the server functions per master S
task cycle (MAST).
%SW96 (2) Control / diagnostics of the save / retrieve application program S and U
and %MW function
%SW97 (2) Number of %MW to be saved U
%SW98 (2) Module/channel geographical address of the discrete input replacing U
the pushbutton on the TSX SAZ 10 module
%SW99 (2) Module/channel geographical address of the discrete input replacing U
the pushbutton on the centralized display block
%SW108 No. of bits forced S
%SW109 Count number of analog channels forced to 0 S
%SW116 Remote I/O on FIPIO fault S
%SW124 Type of last CPU fault found S
%SW125 Type of blocking fault S
%SW126 Address of blocking fault instruction S
%SW127
%SW128 to FIPIO connection point fault S
%SW143
%SW144 Operating mode of the bus arbitrator and producer/consumer U
on the FIPIO bus
%SW145 Modification of the bus arbiter parameters U and S
%SW146 Visualisation of the bus arbiter function and producer/consumer S
on the FIPIO bus
%SW147 Value of bus cycle time of the task in FREE mode S
%SW148 Value of bus cycle time of the task in SLAVE mode S
%SW149 reserved at 0 S
%SW150 Number of FIPIO frames sent S
%SW151 Number of FIPio frames received S
%SW152 Number of FIPIO frames repeated S
%SW155 Number of explicit exchanges being processed S
%SW160 Result of the last registration S
%SW161 Result of the last deregistration S
%SW162 Number of errors in the diagnostic buffer S
(1) S = controlled by the system, U = controlled by the user,
(2) only on TSX 37.

___________________________________________________________________________
3/10
System bits and words 3

B
3.2-2 Detailed description of system words
System Function Description
words
%SW0 Master Modifies the master task scan period defined during B
task configuration via the user program or the terminal.
scan The period is expressed in ms (1..255ms). %SW0=0 during
period cyclic operation.
On a cold restart : takes the value defined by configuration.
%SW1 Fast Modifies the fast task scan period defined during
task configuration via the user program or the terminal.
scan The period is expressed in ms (1..255ms).
period On a cold restart : takes the value defined by configuration.
%SW8 Control for Normally at 0, this bit can be set to 1 or 0 by program or via
reading the terminal.
tasks inputs Inhibits the phase for reading the inputs for each task.
%SW8:X0 1= inhibition in the master task
%SW8:X1 1= inhibition in the fast task
%SW9 Control for Normally at 0, this bit can be set to 1 or 0 by program or via
updating the terminal.
task outputs Inhibits the updating phase of the outputs for each task.
%SW9:X0 1= inhibition in the master task
%SW9:X1 1= inhibition in the fast task
%SW10 First scan If the bit of the current task is at 0, this means that it is
after a performing its first scan after a cold restart.
cold %SW10:X0 : is assigned to the master task, MAST.
restart %SW10:X1 : is assigned to the fast task, FAST.
%SW11 Watchdog Reads the watchdog time defined during configuration.
time It is expressed in ms (10...500ms).
%SW12 UNI-TELWAY UNI-TELWAY terminal port address (in slave mode)
terminal port defined in configuration and loaded in this word
address during a cold restart.
%SW13 Main Indicates for the main network :
address • The station number (low-order byte) from 0 to 127.
of the • The network number (high-order byte) from 0 to 63.
station (position of dip switch on the PCMCIA card)

___________________________________________________________________________
3/11
B
System Function Description
words
%SW17 Fault status On detecting a fault in a floating point arithmetic operation,
on floating point bit %S18 is set to 1 and the %SW17 fault status is
operation updated in line with the following code :
%SW17:X0 = Invalid operation/the result is not a number
%SW17:X1 = Non-standard operand / the result is correct
%SW17:X2 = Division by 0 / the result is ± ∞
%SW17:X3 = Overflow / the result is ± ∞
%SW17:X4 = Underflow / the result is ± 0
%SW17:X5 = Imprecise result
This word is reset to 0 by the system during a cold restart
and by the program for reuse.
%SD18 Absolute This double word is used to calculate time periods.
time It is incremented every 1/10th of a second by the
counter system (even if the PLC is in STOP). It can be read and
written by the user program or by the terminal.
%SW20 Grafcet This word contains the number of steps active, to activate
activity and deactivate for the current scan. It is updated by the
level system every time the Grafcet chart changes.
%SW21 Table of enabled This word contains the number of chart transitions
Grafcet enabled, to enable and to disable the current scan.
transitions It is updated by the system every time the Grafcet
chart changes.
%SW22 Macro-step A macro-step with %SW22:X0 for XM0...%SW25:X16 for
to reset to 0 table XM63 corresponds to each bit in this table.
%SW25 Macro-steps whose associated bit in the table is at 0 will
be reset when bit %S24 is set to 1.
%SW30 Master task Indicates the scan time of the last master task scan
scan (in ms).
time (1)
%SW31 Master task Indicates the longest scan time of the master task
maximum since the last cold restart (in ms).
scan
time (1)

(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end
(update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks
as well as processing of terminal requests.

___________________________________________________________________________
3/12
System bits and words 3

B
System Function Description
words
%SW32 Master task Indicates the shortest scan time of the master task
minimum since the last cold restart (in ms).
scan B
time (1)
%SW33 Fast task Indicates the scan time of the last fast task scan (in
scan ms).
time (1)
%SW34 Fast task Indicates the longest scan time of the fast task
maximum since the last cold restart (in ms).
scan
time (1)
%SW35 Fast task Indicates the shortest scan time of the fast task
minimum since the last cold restart (in ms).
scan
time (1)
%SW48 Number Indicates the number of events processed since the last
of events cold restart (in ms). This word can be written by the program
or by the terminal.
%SW49 Real-time System words containing the current date and time in BCD :
%SW50 clock function %SW49 : day of the week (1 for Monday to 7
%SW51 (2) for Sunday).
%SW52 %SW50 : Seconds (SS00)
%SW53 %SW51 : Hours and Minutes (HHMM)
%SW52 : Month and Day (MMDD)
%SW53 : Year (YYYY)
These words are controlled by the system when bit
%S50 is at 0.
These words can be written by the user program or by
the terminal when bit %S50 is set to 1.
%SW54 Real-time System words containing the date and time of the last
%SW55 clock function power failure or PLC stop (in BCD) :
%SW56 (2) %SW54 : Seconds (00SS),
%SW57 %SW55 : Hours and Minutes (HHMM),
%SW58 %SW56 : Month and Day (MMDD),
%SW57 : Year (YYYY).
%SW58 : high order byte containing the day of the week
(1 for Monday to 7 for Sunday)

(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end
(update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks
as well as processing of terminal requests.
(2) Only on TSX 37-21/22 and TSX 57 PLCs.

___________________________________________________________________________
3/13
B
System Function Description
bits
%SW58 Code of The low order byte contains the code of the last stop.
last stop 1= Change from RUN to STOP by terminal
2= Stop on software fault (PLC scan overshoot)
4= Power outage
5= Stop on hardware fault
6= Stop on HALT instruction
%SW59 Adjust Contains two sets of 8 bits to adjust the current date.
current The operation is always performed on a rising edge of the bit.
date This word is enabled by bit %S59.
Increment Decrement Parameter
bit 0 bit 8 Day of the week
bit 1 bit 9 Seconds
bit 2 bit 10 Minutes
bit 3 bit 11 Hours
bit 4 bit 12 Days
bit 5 bit 13 Months
bit 6 bit 14 Years
bit 7 bit 15 Centuries
%SW60 Redundant System words used when setting up a redundant architecture
to PLC (see description and use in the "Redundant Premium
%SW69 diagnostics architecture" manual).
%SW66 7-segment Contains the Hexadecimal/BCD value that the user wishes to
(1) display see displayed on the optional 7-segment display.
management The display appears when bit %S66 is at 1.
%SW67 Management When %S69=1, these words enable the display block (PLC front
%SW68 of "WORD" panel) to be used in WORD mode :
%SW69 mode • %SW67 : control and status of WORD mode.
• %SW68 : maximum index and current index.
• %SW69 : number of the first object in the zone displayed.
For more information on these system words see part F,
section 1.5 (installation manual).
%SW80
c Management No of messages sent by the system to the terminal port.
%SW81 of messages No of messages received by the system from the terminal port.
%SW82 and No of messages sent by the system to the PCMCIA card.
%SW83 telegrams No of messages received by the system from the PCMCIA card.
%SW84 No of telegrams sent by the system.
%SW85 No of telegrams received by the system.
%SW86 No of messages refused by the system.
%SW87 Management Number of requests processed by the synchronous server per
of communication master task cycle (MAST).
%SW88 flow Number of requests processed by the asynchronous server per
(1) master task cycle (MAST).
%SW89 Number of requests processed by the server functions
(immediate) per master task cycle (MAST).

(1) words only available on TSX/PCX/PMX 57, version V3.3 or later.


___________________________________________________________________________
3/14
System bits and words 3

B
System Function Description
words

%SW96 Control/ Control and/or diagnostics of the application program and %MW
diagnostics save/retrieve function : B
of the save/ bit 0 : request to transfer to the save zone. This bit
retrieve function is active on a rising edge. It is reset to 0 by the system once
the rising edge is taken into account.
bit 1 : when this bit is at 1, this signifies that the save function
is complete. This bit is reset to 0 by the system once the
rising edge is taken into account.
bit 2 : report of the save :
0 -> save with no errors,
1 -> error during save.
bits 3 to 5 : reserved.
bit 6 : validity of the application program backup (identical to
%S96).
bit 7 : validity of the %MW backup (identical to %S97).
bits 8 to 15 : this byte is only significant if the report bit is at 1
(bit 2 = 1, error during save).
1 -> number of %MW to be saved greater than the number of
%MW configured,
2 -> number of %MW to be saved greater than 1000 or less than
0,
3 -> number of %MW to be retrieved greater than the number of
%MW configured,
4 -> size of the application in the internal RAM greater than 15
Kwords (remember that the %MW are always saved when the
application program is saved in the internal Flash EPROM),
5 -> operation prohibited in RUN,
6 -> Backup cartridge present in the PLC,
7 -> writing fault in Flash EPROM..
%SW97 Number of Is used to set the parameters for the number of %MW to be
%MW to be saved. When this word is between 1 and 1000, the first 1000
saved %MW are transferred to the internal Flash EPROM.
When this word is 0, only the application program contained in
the internal RAM is transferred to the internal Flash EPROM.
Any saved %MW are then erased.
On a cold restart, this word is initialized to -1 if the internal
Flash EPROM does not contain any %MW backup. Otherwise,
it is initialized to the value of the number of saved words.
%SW98 Discrete input When bit %S98 = 1, this word indicates the geographical
address address (module / channel) of the discrete input which replaces
the pushbutton of the TSX SAZ 10 module :

High order Low order


Module number Channel number

___________________________________________________________________________
3/15
B
System Function Description
words
%SW99 Discrete input When bit %S99 = 1, this word indicates the geographical address
address (module / channel) of the discrete input which replaces the
pushbutton on the centralized display block :
High order Low order
Module number Channel number

%SW108 No. of Indicates the number of forced bits in the application.


forced bits Normally at 0, it is updated by the bit forcing and unforcing
system in the application memory.
%SW109 Forced Indicates the number of forced analog channels.
analog
channel
counter
%SW116 FIPIO fault Normally at 0, each bit in this word represents a FIPIO exchange
in the task status in the task in which it is tested.
This word is reset to 0 by the user.
%SW 116 :
x0 = 1 explicit exchange error (the variable is not exchanged on
the bus)
x1 = 1 timeout on an explicit exchange (no response at the end of
the timeout)
x2 = 1 maximum number of simultaneous explicit exchanges
x3 = 1 incorrect MPS status (the contents of the variable are invalid)
x4 = 1 length of a received variable is greater than the declared
length
x5 = reserved at 0
x6 =1 invalid PDU code (the variable must be ignored by the
channel manager), the agent is initialized
x7 = 1 asynchronous promptness timeout : the time taken by the
agent to produce the variable has been exceeded, indicating the
absence of a configured device on the FIPIO bus
x8 = 1 channel fault
x9 = reserved at 0
x10 to x14 = reserved at 0
x15 =1 global fault (OR bits 3, 4, 6, 7, 8).
%SW124 Type of The system writes in this word the last type of CPU fault found
CPU (these codes are not changed on a cold restart) :
fault 16#30 : system code fault
16#60 to 64 : stack overflow
16#90 : system interrupt fault : IT not anticipated
16#53 : time out fault during I/O exchanges

___________________________________________________________________________
3/16
System bits and words 3

B
System Function Description
words
%SW125 Type of The system writes in this word the last type of blocking fault
blocking found :
fault 16#DB0 : watchdog overflow B
16#2258 : execution of the HALT instruction
16#DEF8 : execution of a JMP instruction to an undefined
label
16#2XXX : execution of a CALL instruction to an undefined
subroutine
16#0XXX : execution of an unknown function
16#DEFE : Grafcet with source or destination connector
undefined
16#DEFF : floating point not implemented
16#DEF0 : division by 0, (1-->%S18)
16#DEF1 : error when transferring a character string
(1-->%S15)
16#DEF2 : capacity overflow, (1-->%S18)
16#DEF3 : index overflow (1-->%S20)
%SW126 Address of Address of the instruction which generated the application
%SW127 blocking fault blocking fault.
instruction %SW126 contains the offset of this address
%SW126 contains the base of this address
%SW128 FIPIO Each bit in this group of words represents a device connected
to connection on the FIPIO bus.
%SW143 point fault Normally at 1, if one of these bits is at 0, a connection
fault has occurred.
%SW128 represents addresses 0 to 15
%SW128:X0 --> @0, %SW128:X1-->@1,.....,
%SW128:X15-->@15,
%SW129 represents addresses 16 to 31
%SW129:X0 --> @16, %SW129:X1-->@17,.....,
%SW129:X15-->@31,
........
%SW143 represents addresses 240 to 255
%SW143:X0 --> @240, %SW143:X1-->@241,.....,
%SW143:X15-->@255,
When the fault disappears, the bit is reset to 1 by the system
Note : @ = connection point
%SW144 FIPIO bus Caution : modifying this system word can cause the
arbiter station to stop
function This system word is used to start and stop the bus arbiter
operating function and the producer/ consumer function.
mode It is used to modify the bus starting mode, automatic and
manual, if it stops.
For further details see the communication manual.

___________________________________________________________________________
3/17
B
System Function Description
words
%SW145 Modification of Caution : modifying this system word can cause the
FIPIO bus station to stop
arbiter This system word is used to modify FIPIO bus arbiter
parameters parameters.
For further details, see the communication manual.

%SW146 Display of This word displays the bus arbiter and producer/consumer
FIPIO bus functions on the FIPIO bus.
arbiter For further details, see the communication manual.
function

%SW147 MAST network MAST task network cycle time value.


cycle time A value other than zero indicates the value of the network
cycle time (TCR-FAST) of the MAST task, in ms.
%SW148 FAST network FAST task network cycle time value.
cycle time A value other than zero indicates the value of the network
cycle time (TCR-FAST) of the FAST task, in ms.

%SW149 reserved at 0

%SW150 Number of This word indicates the number of frames sent by the FIPIO
frames sent channel manager.
%SW151 Number of This word indicates the number of frames received by the FIPIO
frames received channel manager.

%SW151 Number of This word indicates the number of messages repeated


messages by the FIPIO channel manager.
repeated
%SW155 Number of Number of explicit exchanges being processed
explicit
exchanges
%SW160 Result of the last registration (diagnostic function).
%SW161 Result of the last deregistration (diagnostic function).
%SW162 Number of current errors in the diagnostic buffer.

___________________________________________________________________________
3/18
Section
Differences between PL7-2/3 and PL7 Micro 44
4 Differences between PL7-2/3 and PL7 Micro/Junior
B
4.1 Differences between PL7-2/3 and PL7-Micro/Junior
Immediate values
Objects PL7-2/3 PL7 Micro/Junior
Base 10 integer 1234 1234 B
Base 2 integer L'10011110' 2#10011110
Base 16 integer H'ABCD' 16#ABCD
Floating point -1.32e12 (PL7-3) -1.32e12
Character string M'aAbBcB' 'aAbBcC'

Labels
Label Li i = 0 to 999 %Li i = 0 to 999

Bits
Objects PL7-2/3 PL7 Micro/Junior
Input bit in rack Ixy,i %Ixy.i
Indexed input bit in rack Ixy,i (Wj) (PL7-3) %Ixy.i[%MWj]
Remote input bit RIx,y,i (PL7-3) %I\<path>\<mod>.<channel>
Indexed remote input bit RIx,y,i (Wj) (PL7-3)
Output bit in rack Oxy,i %Qxy.i
Indexed output bit in rack Oxy,i (Wj) (PL7-3) %Qxy.i[%MWj]
Remote output bit ROx,y,i (PL7-3) %Q\<path>\<mod>.<channel>
Indexed remote output bit ROx,y,i (Wj) (PL7-3)
I/O fault bit in rack
• module fault bit Ixy,S / Oxy,S %Ixy.MOD.ERR
• channel fault bit %Ixy.i.ERR
Remote I/O fault bit (PL7-3)
• module fault bit %I\<path>\<mod>.MOD.ERR
• channel fault bit RDx,y,i / ERRORx,y,i %I\<path>\<mod>.<channel>.ERR
• output channel trip bit TRIPx,y,i
• output channel reset bit RSTx,y,i
Internal bit Bi %Mi
Indexed internal bit Bi(Wj) (PL7-3) %Mi[%MWj]
System bit SYi %Si
Step bit Xi %Xi
Macro-step bit XMj (PL7-3) %XMj
Step bit i of macro-step j Xj,i (PL7-3) %Xj.i
Input step bit of macro-step j Xj,I (PL7-3) %Xj.IN
Output step bit of macro-step j Xj,O (PL7-3) %Xj.OUT
Bit j of internal word i Wi,j %MWi:Xj
Bit j of indexed internal word i Wi(Wk),j(PL7-3) %MWi[%MWk]:Xj
___________________________________________________________________________
4/1
B
Bit j of constant word i CWi,j %KWi:Xj
Bit j of indexed constant word i CWi(Wk),j (PL7-3) %KWi[%MWk]:Xj
Bit j of register i I/OWxy,i,j %IW/%QWxy.i:Xj
Bit k of common word j COMi,j,k %NWi.j:Xk
of station i COMXi,j,k (X = B, C, D) %NXWi.j:Xk
Bit j of system word i SWi,j %SWi:Xj

Words
Objects PL7-2/3 PL7 Micro/Junior
Single length internal word Wi %MWi
Indexed single length internal word Wi(Wj) (PL7-3) %MWi[%MWj]
Double length internal word DWi (PL7-3) %MDi
Indexed double length internal word DWi(Wj) (PL7-3) %MDi[%MWj]
Real internal word %MFi
Indexed real internal word %MFi[%MWj]
Single length constant word CWi %KWi
Indexed single length constant word CWi(Wj) %KWi[%MWj]
Double length constant word CDWi (PL7-3) %KDi
Indexed double length constant word CDWi(Wj) (PL7-3) %KDi[%MWj]
Real constant word %KFi
Indexed real constant word %KFi[%MWj]
Single length input register word IWxy,i %IWxy.i
Double length input register word %IDxy.i
Single length output register word OWxy,i %QWxy.i
Double length output register word %QDxy.i
Remote input register word RIWx,y,i (PL7-3) %IW\<path>\<mod>.<channel>
Remote output register word ROWx,y,i (PL7-3) %QW\<path>\<mod>.<channel>
System word SWi %SWi
Common word j of station i COMi,j %NW{i}j
COMXi,j (where X = B, C, D) %NW{[r.]i}j
r = network no.
Status word of a remote discrete module STATUSAx,y,i (PL7-3)
STATUSBx,y,i (PL7-3)
Status word of a remote discrete module channel STSx,y,i(PL7-3) %IW\<path>\<mod>.<channel>.ERR
Active time of Grafcet steps Xi,V %Xi.T
Active time of step i of macro-step j Xj,i,V (PL7-3) %Xj.i.T

___________________________________________________________________________
4/2
Differences between PL7-2/3 and PL7 Micro 4

B
Active time of input step Xj,I,V (PL7-3) %Xj.IN.T
of macro-step j
Active time of output step Xj,O,V (PL7-3) %Xj.OUT.T
of macro-step j

B
Function blocks
Objects PL7-2/3 PL7 Micro/Junior
Timer Ti %Ti
• preset value (word) Ti,P %Ti.P
• current value (word) Ti,V %Ti.V
• timer running (bit) Ti,R %Ti.R
• timer done (bit) Ti,D %Ti.D
Monostable Mi %MNi
• preset value (word) Mi,P %MNi.P
• current value (word) Mi,V %MNi.V
• monostable running (bit) Mi,R %MNi.R
Up/down counter Ci %Ci
• preset value (word) Ci,P %Ci.P
• current value (word) Ci,V %Ci.V
• upcounting overrun (bit) Ci,E %Ci.E
• preset done (bit) Ci,D %Ci.D
• downcounting overrun (bit) Ci,F %Ci.F
Register Ri %Ri
• input word (word) Ri,I %Ri.I
• output word (word) Ri,O %Ri.O
• register full (bit) Ri,F %Ri.F
• register empty (bit) Ri,E %Ri.E
Text TXTi no text block
Drum controller Di (PL7-2) %DRi
• number of active step (word) Di,S %DRi.S
• active time of current step (word) Di,V %DRi.V
• 16 command bits (word) Di,Wj %DRi.Wj
• last step in progress (bit) Di,F %DRi.F
Fast Counter / Timer FC (PL7-2) -
• preset value (word) FC,P -
• current value (word) FC,V -
• external reset (bit) FC,E -
• preset done (bit) FC,D -
• counting in progress (bit) FC,F -
Real-time clock H (PL7-2) -
• "WEEK" or "YEAR" type
day selection MTWTFSS (word) VD -
• start of active time period (word) BGN -
• end of active time period (word) END -
• current value < setpoint (bit) < -
• current value = setpoint (bit) = -
• current value > setpoint (bit) > -
___________________________________________________________________________
4/3
B
Bit and word tables
Objects PL7-2/3 PL7 Micro/Junior
Bit strings
• Internal bit string Bi[L] %Mi:L
• Input bit string Ixy,i[L] (PL7-3) %Ixy.i:L
• Output bit string Oxy.i[L] (PL7-3) %Qxy.i:L
• Grafcet step bit string Xi[L] (PL7-3) %Xi:L
• macro-step bit string XMi[L] (PL7-3)
Character strings %MBi:L (1)
(where i is even)
Word tables
• internal word table Wi[L] %MWi:L
• indexed internal word table Wi(Wj)[L] %MWi[%MWj]:L
• internal double word table DWi[L] (PL7-3) %MDi:L
• indexed internal double word table DWi(Wj)[L] (PL7-3) %MDi[%MWj]:L
• constant word table CWi[L] %KWi:L
• indexed constant word table CWi(Wj)[L] %KWi[%MWj]:L
• constant double word table CDWi[L] (PL7-3) %KDi:L
• indexed constant double word table CDWi(Wj)[L] (PL7-3) %KDi[%MWj]:L
• real table %MFi:L
• indexed real table %MFi[%MWj]:L
• constant real table %KFi:L
• indexed constant real table %KFi[%MWj]:L
• remote input element table RIx,y,i[L] (PL7-3)
• remote output element table ROx,y,i[L] (PL7-3)
• remote input indexed element table RIx,y,i(Wj)[L] (PL7-3)
• remote output indexed element table ROx,y,i(Wj)[L] (PL7-3)

Optional function blocks


Objects PL7-3 PL7 Micro/Junior
Optional function block <OFB>i
OFB element <OFB>i, <element>
Indexed OFB element <OFB>i,<element>(Wj)
OFB element table <OFB>i,<element>[L]
Indexed OFB element table <OFB>i,<element>(Wj)[L]

___________________________________________________________________________
4/4
Differences between PL7-2/3 and PL7 Micro 4

B
Instructions
Objects PL7-2 PL7-3 PL7 Micro/Junior
Instructions on bits
• Reverse logic NOT NOT
• AND AND • AND B
• OR OR + OR
• Exclusive OR XOR XOR
• Rising edge RE RE
• Falling edge FE FE
• Set to 1 SET SET
• Reset to 0 RESET RESET
Instructions on words and double words
• Addition + + +
• Subtraction - - -
• Multiplication * * *
• Division / / /
• Comparisons >, >=, <, <=, =, <> >, >=, <, <=, =, <>
• Division remainder MOD REM REM
• Square root SQRT SQRT
• Absolute value ABS
• Logic AND AND AND AND
• Logic OR OR OR OR
• Exclusive logic OR XOR XOR XOR
• Logic complement CPL CPL NOT
• Incrementation INC INC
• Decrementation DEC DEC
• Logic shift to left SHL SHL
• Logic shift to right SHR SHR
• Circular shift to left SLC SLC ROL
• Circular shift to right SRC SRC ROR
Floating point instructions (1)
• Addition ADDF +
• Subtraction SUBF -
• Multiplication MULF *
• Division DIVF /
• Square root SQRTF SQRT
• Absolute value ABS
• Equality test EQUF =
• Strict superiority test SUPF >
• Strict inferiority test INFF <
• Other tests >=, <=, <>

___________________________________________________________________________
4/5
B
Instructions (continued)
Objects PL7-2 PL7-3 PL7 Micro/Junior
Instructions on byte strings
• Circular shift SLCWORD
Conversion instructions
• BCD to binary conversion BCD DTB BCD_TO_INT
• Binary to BCD conversion BIN BTD INT_TO_BCD
• ASCII to binary conversion ATB ATB STRING_TO_INT or
STRING_TO_DINT
• Binary to ASCII conversion BTA BTA INT_TO_STRING or
DINT_TO_STRING
• Gray to binary conversion GTB GRAY_TO_INT
• Floating point to integer conversion FTB REAL_TO_INT or
REAL_TO_DINT
• Integer to floating point conversion FTF INT_TO_REAL or
DINT_TO_REAL
• BCD to floating point conversion DTF BCD_TO_REAL
• Floating point to BCD conversion FTD REAL_TO_BCD
• ASCII to floating point conversion ATF STRING_TO_REAL
• Floating point to ASCII conversion FTA REAL_TO_STRING
Instructions on tables
• Arithmetic operations +, -, *, /, REM +, -, *, /, REM
• Logic operations AND, OR, XOR AND, OR, XOR, NOT
• Addition of words in a table + SUM
• Search for 1st different word EQUAL EQUAL
• Search for 1st equal word SEARCH FIND_EQU
Instructions on program
• Jump JUMP Li JUMP %Li
• Call for sub-routine CALL SRi SRi
• Return from sub-routine RET RETURN
• Stop application HALT HALT
• Conditional phrase IF/THEN/ELSE IF/THEN/ELSE/END_IF
• Iterative phrase WHILE/DO WHILE/DO/END_WHILE
Instructions on interruptions
• Test READINT
• Masking MASKINT MASKEVT
• Unmasking DMASKINT UNMASKEVT
• Acknowledgment ACKINT
• Generation of an IT to module SETIT
Explicit I/O instructions
• Read discrete inputs READBIT
• Write discrete outputs WRITEBIT
• Read registers READREG
• Write registers WRITEREG
• Read words READEXT
• Write words WRITEEXT

___________________________________________________________________________
4/6
Differences between PL7-2/3 and PL7 Micro 4

B
Instructions (continued)
Objects PL7-3 PL7 Micro/Junior
Instructions on functions blocks
• Preset PRESET Ti / Ci PRESET %Ti / %Ci
• Start START Ti / Mi START %Ti / %MNi B
• Activate task START CTRLi
• Reset RESET Ci / Ri / TXTi RESET %Ci / %Ri
• Deactivate task RESET CTRLi
• Upcounting UP Ci UP %Ci
• Downcounting DOWN Ci DOWN %Ci
• Store in a register PUT Ri PUT %Ri
• Retrieve from a register GET Ri GET %Ri
• Receive a message INPUT TXTi
• Transmit a message OUTPUT TXTi
• Transmit/Receive message EXCHG TXTi
• Execute an OFB EXEC <OFBi>
• Read telegrams READTLG

Delimiters
Objects PL7-2/3 PL7 Micro/Junior
Assignment -> :=
Left parenthesis for indexing ( [
Right parenthesis for indexing ) ]
Length of table [length] :length

___________________________________________________________________________
4/7
B

___________________________________________________________________________
4/8
Section
List of reserved words 55
5 List of reserved words
B
5.1 Reserved words
The following reserved words should not be used as symbols.

*_TO_* * = Letter BLOCK DELTA_D


SRi DELTA_DT
AUXi
BODY B
BOOL DELTA_TOD
EVTi BOTTOM DINT
XMi BTI DINT_TO_REAL
i = entier BTR DINT_TO_STRING
BY DISPLAY_ALRM
ABS BYTE DISPLAY_GRP
ACCEPT C DISPLAY_MSG
ACOS CAL DIV
ACTION CALC DMOVE
ACTIVATE_PULSE CALCN DO
ACTIVE_TIME CALL DOWN
ADD CALL_COIL DR
ADDRESS CANCEL DRUM
ADD_DT CASE DS
ADD_TOD CD DSHL_RBIT
ADR CHART DSHRZ_C
AND CH_M DSHR_RBIT
ANDF CLK DSORT_ARD
ANDN CLOSE DSORT_ARW
ANDR CLOSED_CONTACT DT
AND_ARX COIL DTS
ANY COMMAND DWORD
ANY_BIT COMMENTS D_BIT
ANY_DATE COMP4 E
ANY_INT COMPCH EBOOL
ANY_NUM CONCAT ELSE
ANY_REAL CONF ELSIF
ARRAY CONFIGURATION EMPTY
AR_D CONSTANT EMPTY_LINE
AR_DINT CONTROL_LEDS END
AR_F COPY_BIT ENDC
AR_INT COS ENDCN
AR_R CTD END_ACTION
AR_W CTU END_BLK
AR_X CTUD END_BLOCK
ASIN CU END_CASE
ASK D END_COMMENTS
ASK_MSG DATE END_CONFIGURATION
ASK_VALUE DATE_AND_TIME END_FOR
ASSIGN_KEYS DAT_FMT END_FUNCTION
AT DAY_OF_WEEK END_FUNCTION_BLOCK
ATAN DA_TYPE END_IF
AUX DEACTIVATE_PULSE END_MACRO_STEP
BCD_TO_INT DEC END_PAGE
BIT_D DELETE END_PHRASE
BIT_W END_PROG
BLK
___________________________________________________________________________
5/1
B
END_PROGRAM GET LENGTH_ARR
END_REPEAT GET_MSG LENGTH_ARW
END_RESOURCE GET_VALUE LENGTH_ARX
END_RUNG GLOBAL_COMMENT LIFO
END_STEP GR7 LIMIT
END_STRUCT GRAY_TO_INT LINT
END_TRANSITION GT LIST
END_TYPE GTI LIT
END_VAR H LN
END_WHILE HALT LOCATION
EQ HALT_COIL LOG
EQUAL HASH_COIL LREAL
EQUAL_ARR HW LT
ERR H_COMPARE LW
EVT H_LINK LWORD
EXCHG I M
EXCH_DATA IF MACRO_STEP
EXIT IL MAIN
EXP IN MASKEVT
EXPT INC MAST
F INCJUMP MAX
FALSE INDEX_CH MAX_ARD
FAST INFO MAX_ARR
FBD INITIAL_STEP MAX_ARW
FE INIT_BUTTONS MAX_PAGES
FIFO INPUT MAX_STEP
FIND INPUT_CHAR MCR
FIND_EQ INSERT MCR_COIL
FIND_EQD INT MCS
FIND_EQDP INTERVAL MCS_COIL
FIND_EQR INT_TO_BCD MID
FIND_EQW INT_TO_REAL MIN
FIND_EQWP INT_TO_STRING MIN_ARD
FIND_GTD ITB MIN_ARR
FIND_GTR ITS MIN_ARW
FIND_GTW JMP MOD
FIND_LTD JMPC MONO
FIND_LTR JMPCN MOVE
FIND_LTW JUMP MPP
FOR JUMP_COIL MPS
FPULSOR L MRD
FROM LAD MS
FTOF LANGAGE MUL
FTON LANGUAGE MUX
FTP LD M_CH
FUNC LDF M_MACRO_STEP
FUNCTION LDN N
FUNCTION_BLOCK LDR N1
F_B LE NAME
F_EDGE LEFT NB_ACTIVE_STEPS
F_TRIG LEN NB_ACTIVE_TIME
GE LENGTH_ARD
___________________________________________________________________________
5/2
List of reserved words 5

B
NB_BLOCKS PERIOD RETC
NB_COMMON_WORDS PHRASE RETCN
NB_CONSTANT_WORDS PHRASE_COMMENT RETURN
NB_CPT PID RET_COIL
NB_DRUM PID_MMI RIGHT B
NB_INTERNAL_BITS PLC ROL
NB_INTERNAL_WORDS POST ROLD
NB_MACRO_STEPS PRESET ROLW
NB_MONO PRINT ROL_ARD
NB_PAGES PRINT_CHAR ROL_ARR
NB_REG PRIO0 ROL_ARW
NB_TIMER PRIO1 ROL_DWORD
NB_TM PRIORITY ROL_WORD
NB_TRANSITIONS PRL ROR
NE PROG ROR_ARD
NIL PROGRAM ROR_ARR
NO PROG_LANGAGE ROR_ARW
NON_STORED PROG_LANGUAGE ROR_DWORD
NOP PT ROR_WORD
NOT PTC RRTC
NOT_ARX PUT RS
NOT_COIL PV RTB
NOT_READABLE PWM RTC
NO_GR7 P_CONTACT RTS
NO_PERIOD Q RUNG
N_CONTACT QUERY R_EDGE
O R R_TRIG
OCCUR R1 S
OCCUR_ARD RCV_TLG S1
OCCUR_ARR RE SAVE
OCCUR_ARW READ SAVE_PARAM
OF READ_EVT_UTW SCHEDULE
ON READ_ONLY SD
OPEN READ_PARAM SEARCH
OPEN_CONTACT READ_STS SECTION
OPERATE READ_VAR SEL
OR READ_WRITE SEMA
ORF REAL SEND
ORN REAL_TO_DINT SENDER
ORR REAL_TO_INT SEND_ALARM
OR_ARX REAL_TO_STRING SEND_MBX_ALARM
OTHERS REG SEND_MBX_MSG
OUT REM SEND_MSG
OUTIN_CHAR REPEAT SEND_REQ
OUTPUT REPLACE SEND_TLG
OUT_BLK REQ SERVO
P RESET SET
P0 RESET_COIL SET_COIL
P1 RESOURCE SFC
PAGE RESTORE_PARAM SHIFT
PAGE_COMMENT RET
PANEL_CMD RETAIN
___________________________________________________________________________
5/3
B
SHL TO XM_MULTI
SHOW_ALARM TOD XOR
SHOW_MSG TOF XORF
SHOW_PAGE TOFF XORN
SHR TON XORR
SHRZ TOP XOR_ARX
SIN TP YES
SINGLE TRANSITION
SINT TRANS_TIME
SL TRUE
SLCWORD TRUNC
SMOVE TYPE
SOFT_CONFIGURATION TYPES
SORT T_S_AND_LINK
SORT_ARD T_S_OR_LINK
SORT_ARW U
SQRT UDINT
SR UINT
ST ULINT
STANDARD UNMASKEVT
START UNTIL
STD UP
STEP USINT
STI USORT_ARD
STN USORT_ARW
STOP UTIN_CHAR
STR VAR
STRING VAR_ACCESS
STRING_TO_DINT VAR_EXTERNAL
STRING_TO_INT VAR_GLOBAL
STRING_TO_REAL VAR_INPUT
STRUCT VAR_IN_OUT
SUB VAR_OUTPUT
SUB_DT VERSION
SUB_TOD V_COMPARE
SUM V_LINK
SU_TYPE W
SWAP WHILE
S_T_AND_LINK WITH
S_T_OR_LINK WORD
T WRITE
TAN WRITE_CMD
TASK WRITE_PARAM
TASKS WRITE_VAR
THEN WRTC
TIME WSHL_RBIT
TIMER WSHRZ_C
TIME_OF_DAY WSHR_RBIT
TM W_BIT
TMAX XM
TMOVE XM_MONO
___________________________________________________________________________
5/4
Section 66
Conformity to the IEC 1131-1 standard
6 Conformity to the IEC 1131-1 standard B
6.1 Conformity to the IEC 1131-3 standard
IEC standard 1131-3 "PLCs - Part 3 : Programming languages" defines the syntax and
semantics of the software elements used to program PLCs.

This standard describes 2 textual languages, IL (Instruction List) and ST (Structured Text), B
2 graphic languages, LD (Ladder Diagram) and FBD (Function Block Diagram) and a
graphic chart, SFC (Sequential Function Chart), used to structure the internal organization
of a programmed sequence.

PL7 programming software is used to program a PLC conforming to the IEC standard : PL7
implements a subset of language elements defined in the standard and defines extensions
which are authorized within this standard.

IEC standard 1131-3 does not define the rules of interaction of software supplied by a
manufacturer claiming to conform to the standard, leaving a greater flexibility of presentation
and programming element entry for the convenience of the user.

The elements of the standard implemented in PL7, the specific implementation information
and the cases of detected errors are summarized in the conformity tables below.

6.1.1 Conformity tables


This system conforms to the recommendations of IEC 1131-3, as far as the following
language characteristics are concerned :

Common elements

Table no. Characteristic no. Description of characteristics


1 1 Required character set
see paragraph 2.1.1 of 1131-3
1 2 Lower case characters
1 3a Number sign (#)

___________________________________________________________________________
6/1
B
1 4a Dollar sign ($)
1 5a Vertical bar (|)
1 6a Subscript delimiters : Left and right brackets "[]"
2 1 Upper case and numbers
2 2 Upper and lower case, numbers, embedded
underlines
3 1 Comments
4 1 Integer literals (Note 1)
4 2 Real literals (Note 1)
4 3 Real literals with exponents
4 4 Base 2 literals (Note 1)
4 6 Base 16 literals (Note 1)
4 7 Boolean Zero and One
4 8 Boolean TRUE and FALSE
5 1 Character string literal features
6 2 $$ Dollar sign
6 3 $’ Single quote
6 4 $L or $l Line feed
6 5 $N or $n New line
6 6 $P or $p Form feed (page)
6 7 $R or $r Carriage return

___________________________________________________________________________
6/2
Conformity to the IEC 1131-1 standard 6

B
6 8 $T or $t Tab
7 1a Duration literals with short prefix t# (Note 2)
10 1 BOOL -1 bit- B
10 10 REAL -32 bits-
10 12 TIME -32 bits- (Note 3)
10 13 DATE -32 bits- (Note 3)
10 14 TIME_OF_DAY -32 bits- (Note 3)
10 15 DATE_AND_TIME -64 bits- (Note 3)
10 16 STRING
10 17 BYTE -8 bits-
10 18 WORD -16 bits-
10 19 DWORD -32 bits-
15 1 I prefix for Input location
2 Q prefix for Output location
3 M prefix for Memory location
15 4 X prefix, single bit size
5 None prefix, single bit size
6 B prefix, byte size (8 bits)
7 W prefix, word size (16 bits)
8 D prefix, double word size (32 bits)

___________________________________________________________________________
6/3
B

16 VAR Keywords (Note 4)


VAR_INPUT
VAR_OUTPUT
VAR_IN_OUT
VAR_EXTERNAL
VAR_GLOBAL
CONSTANT
AT
17 2 Declaration of directly represented non volatile
variables (address) (Note 4)
17 3 Declaration of slots for symbolic variables
(symbol or address) (Note 4)
17 5 Automatic memory assignment of symbolic
variables (function block variables) (Note 4)
18 2 Initialization of directly represented non volatile
variables (address) (Note 4)
18 3 Assignment of slots and initial values
for symbolic variables (symbols on addresses)
(Note 4)
18 5 Initialization of symbolic variables (function block
variables) (Note 4)
21 1 The PL7 overloaded functions are as follows :
ABS, EQUAL, ROL, ROR, SHL, SHR, SQRT, SUM
21 2 In general, PL7 functions belong to
this category.
22 1 Type conversion functions :
DINT_TO_STRING, INT_TO_STRING,
STRING_TO_DINT, STRING_TO_INT,
DATE_TO_STRING, DT_TO_STRING,
TIME_TO_STRING, TOD_TO_STRING,
REAL_TO_STRING, STRING_TO_REAL,
REAL_TO_INT, REAL_TO_DINT,
INT_TO_REAL, DINT_TO_REAL (Note 5)

___________________________________________________________________________
6/4
Conformity to the IEC 1131-1 standard 6

B
22 2 TRUNC function: truncation of a REAL type to 0
22 3 BCD_TO_INT conversion function (Note 6)
22 4 INT_TO_BCD conversion function (Note 6) B
23 1 ABS function: absolute value
23 2 SQRT function: square root
23 3 LN function: natural logarithm
23 4 LOG function: base 10 logarithm
23 5 EXP function: natural exponential
23 6 SIN function: sine in radians
23 7 COS function: cosine in radians
23 8 TAN function: tangent in radians
23 9 ASIN function: arc sine
23 10 ACOS function: arc cosine
23 11 ATAN function: arc tangent
25 1 SHL function: shift left
25 2 SHR function: shift right
25 3 ROR function: rotate right
25 4 ROL function: rotate left
29 1 LEN function: string length
29 2 LEFT function: leftmost n characters
29 3 RIGHT function: rightmost n characters
29 4 MID function: n characters from a given
position
29 5 CONCAT function: extensible concatenation (Note7)
29 6 INSERT function: insert one string into another
29 7 DELETE function: deletes characters
___________________________________________________________________________
6/5
B
29 8 REPLACE function: replaces characters
29 9 FIND function: find one string inside another
32 Input read (Note 8)
Input write
Output read
Output write
33 1 RETAIN qualifier on internal variables of the
function blocks (Note 9) (Note 4)
33 2 RETAIN qualifier on outputs of the function
blocks (Note 9) (Note 4)
33 4a Declaration of function block I/O
(Structured Text) (Note 4)
37 1 Pulse timer: TP (Note 10)
37 2a On-delay timer: TON (Note 10)
37 3a Off-delay timer: TOF (Note 10)
38 timing
diagrams TP, TON, TOF
39 19 Use of directly represented variables
(address)
40 1 Step, graphical form
Note: A step number replaces a step
identifier
40 2 Step, textual form used in the source form of
Grafcet only
41 1 Condition of transition in ST language
41 2 Condition of transition in LD language
42 2l Declarations of actions in LD language
43 1 Action block
43 2 Concatenated action blocks

___________________________________________________________________________
6/6
Conformity to the IEC 1131-1 standard 6

B
45 2 Action qualifier N (not stored)
45 11 Action qualifier P1 (Pulse rising edge)
B
45 12 Action qualifier P0 (Pulse falling edge)
46 1 Single sequence, alternation step/transition
46 2c "Or" divergence: user ensures that the transition
conditions are mutually exclusive
46 3 "Or" convergence
46 4 "And" divergence, "And" convergence
46 5c Sequence jump in an "or" divergence
46 6c Sequence loop: return to a previous step
46 7 Directional arrows
Note: Directional arrows point up and down

48 40 Grafcet language meets the conditions for the


41 minimum level of 1131-3 SFC conformity
42
43 Graphic representation
45
46
57
49 3 RESOURCE...ON...END_RESOURCE construction
49 5a Periodic TASK construction in RESOURCE
49 6a PROGRAM declaration with
PROGRAM-to-TASK association
49 7 Declaration of variables directly represented
in VAR_GLOBAL
50 5b Preemptive scheduling with the multi-tasks
model

___________________________________________________________________________
6/7
B
Note 1: The underline characters (_) inserted between the digits of a numerical literal are
not accepted.
Note 2 : These literals are only visible in the application source, to show the time of
configured tasks.
Note 3: These types of data are not yet implemented in a manner visible to the user. This
table defines, however, the memory occupation of their internal representation.
Note 4 : These key words are only used in the sources generated by PL7 and by the PL7-2
and PL7-3 application conversion tool.
Note 5 : Effects of conversions to limits:
DINT_TO_STRING: If the string accepting the result is less than 13 characters, truncation
occurs and %S15 is set.
INT_TO_STRING: If the string accepting the result is less than 7 characters, truncation
occurs and %S15 is set.
STRING_TO_DINT et STRING_TO_INT: If the string cannot be converted to an integer,
the result is indeterminate and %S18 is set.
DATE_TO_STRING: If the string accepting the result is less than 11 characters,
truncation occurs and %S15 is set.
DT_TO_STRING: If the string accepting the result is less than 20 characters, truncation
occurs and %S15 is set.
TIME_TO_STRING: If the string accepting the result is less than 15 characters, truncation
occurs and %S15 is set.
TOD_TO_STRING: If the string accepting the result is less than 9 characters, truncation
occurs and %S15 is set.
REAL_TO_STRING: If the string accepting the result is less than 15 characters,
truncation occurs and %S15 is set.
STRING_TO_REAL: If the string cannot be converted to a real value, the value of the result
is «1.#NAN» (16#FFC0_0000) and %S18 is set.
REAL_TO_INT: If the real cannot be converted within the limits [-32768, +32767], the value
of the result is -32768 and %S18 and %SW17:X0 are set.
REAL_TO_DINT: If the real cannot be converted within the limits [-2147483648,
+2147483647], the value of the result is -2147483648 and %S18 and %SW17:X0 are set.
INT_TO_REAL: Conversion is always possible.
DINT_TO_REAL: Conversion is always possible.
Note 6 : As the type INT is not formally implemented, even though it is still used, these
functions enable the coding format of a WORD to be changed.
Note 7 : Limit the CONCAT function to the concatenation of 2 strings.
Note 8 : This paragraph applies to the predefined PL7 function blocks.
Note 9 : The RETAIN qualifier is implicit.
Note 10 : The timers TP, TON, TOF respect the timing diagrams of table 38, but have a
different I/O interface from that of 1131-3.

___________________________________________________________________________
6/8
Conformity to the IEC 1131-1 standard 6

B
IL language elements
Table no. Characteristic no. Description of characteristics
51 Instruction Label, operator, operand, comment
B
fields
52 1 LD
52 2 ST
52 3 S and R
52 4 AND
6 OR
7 XOR
52 18 JMP
52 20 RET
52 21 )
53 3 Use of input operators for launching
function blocks in IL language
54 11 IN (Note 11)
54 12 IN (Note 11)
54 13 IN (Note 11)

Note 11 : The operator PT is not implemented.

ST language elements (Note 12)


Table no. Characteristic no. Description of characteristics
55 1 Place in parentheses
55 2 Function evaluation
55 4 - Negate
55 5 NOT Complement

___________________________________________________________________________
6/9
B

55 6 * Multiply
7 / Divide
55 9 + Add
10 - Subtract
55 11 <, >, <=, >= Comparison
55 12 = Equality
55 13 <> Inequality
55 15 Boolean AND
55 16 XOR Boolean Exclusive or
55 17 Boolean or
56 1 := Assignment
56 3 RETURN structure
56 4 IF structure "if... then... elsif... then... else...
end_if"
56 6 FOR structure "for... to... do... end_for" (Note 13)
56 7 WHILE structure "while... do... end_while"
56 8 REPEAT structure "repeat ... until... end_repeat"
56 9 EXIT structure

Note 12 : This language is used entirely in ST modules. An ST subset is


also used in the OPERATE and COMPARE blocks of IL and LD languages.

Note 13 : Implementation of the FOR loop with an implicit step of 1 (by 1).

___________________________________________________________________________
6/10
Conformity to the IEC 1131-1 standard 6

B
Common graphic elements
Table no. Characteristic no.Description of characteristics
57 2 Graphic horizontal lines B
57 4 Graphic vertical lines
57 6 Graphic horizontal/vertical line connection
57 8 Graphic crossing of lines without connection
57 10 Graphic connected and non-connected corners
57 12 Blocks with graphic connected lines
58 2 Unconditional jump: LD language
58 4 Conditional jump: LD language
58 5 Conditional return: LD language
58 8 Unconditional return: LD language

LD language elements
Table no. Characteristic no. Description of characteristics
59 1 Left power rail
59 2 Right power rail
60 1 Horizontal link
60 2 Vertical link
61 1 Open contact
61 3 Closed contact
61 5 Positive transition-sensing contact
61 7 Negative transition-sensing contact
62 1 Coil
62 2 Negated coil
62 3 SET (latch) coil
62 4 RESET (unlatch) coil
___________________________________________________________________________
6/11
B
Implementation-dependent parameters
Parameter PL7 limitations and behavior

Procedure for processing errors Numerous errors are


indicated on execution with
system bits and words.

National characters used ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔ


ÕÖØÙÚÛÜÝÞàáâãäåæçèéêëìí
îïðñòóôõöøùúûüýþßÿ
#, $, |
Maximum length of identifiers 32
Maximum length of comment 222
Range of values of duration (Note 14)
Range of values for variables of type TIME (Note 14)
Precision of representation of seconds (Note 15)
in types TIME_OF_DAY and
DATE_AND_TIME
Maximum number of array subscripts 1 (Note 16)
Maximum number of array Depending on the indexed area
(Note 16)
Default maximum length of STRING variables Not applicable
Maximum permitted length of 255
STRING variables
Maximum number of hierarchical levels 3
Logical or physical mapping Logical mapping
Maximum range of subscript values Depending on the indexed area
(Note 16)

___________________________________________________________________________
6/12
Conformity to the IEC 1131-1 standard 6

Initialization of system inputs The variables are initialized


by the system:
- to the initial value specified
by the user, if applicable B
- if not, to zero
Effects of type conversions on See table 22, feature 1
accuracy
Maximum number of types and instances No maximum number
of function block (the limits are connected to the
volume of the application)
Program size limit Maximum volume of a
program code = 64 KB
Precision on time elapsed associated with 100ms
a step
Maximum number of steps per chart 96 on 3710 PLC
128 on 3720 PLC
1024 on 57xx V3.0 PLC
Maximum number of transitions per chart 1024 transitions per chart
and per step
11 transitions per step
Action control mechanism P0, P1 and N1 qualifiers
Maximum number of action blocks per step 3 actions are possible: on
activation (P1), continuous (N1)
and on deactivation (P0)
Graphic indication of step status Active step in reverse video
Transition clearing time Clearing time is variable
(deactivation of upstream steps and and is never zero
activation of downstream steps)

___________________________________________________________________________
6/13
B
Depth of divergent and convergent Limit given by the entry grid
construction
List of PLC which can be programmed by TSX 3710, 3720,
PL7 TSX 5710, 5720, 5725, 5730,
5735, 5740, 57 45
PMX 5710, 5720, 5735, 5745,
PCX 5710, 5735
Maximum number of tasks 1 periodic or cyclic task
1 periodic task
8 event-triggered tasks
for 37 10 PLCs
16 event-triggered tasks
for 37 20 PLCs
32 event-triggered tasks
for 57 10 PLCs
64 event-triggered tasks
for 57 20/30 PLCs
Task interval range from 1 ms to 255 ms
Preemptive or non-preemptive scheduling Preemptive scheduling
Maximum length of an expression Variable
Partial evaluation of Boolean No
expressions
Maximum length of control structures Variable
in ST
Value of control variable after The value of the control variable
complete execution of a FOR loop equals the value of the limit
+ 1 (since the step is 1)
Graphic/semi-graphic representation Graphic representation
Restrictions on network topology An LD network can occupy a
maximum of 16 columns and 7
lines

___________________________________________________________________________
6/14
Conformity to the IEC 1131-1 standard 6

B
Note 14 : These types of data are not yet implemented in a manner visible to
the user. This table, however, defines their ranges of values in IEC 1131-3
format.
TIME: from T#0 to T#429496729.5s
TIME_OF_DAY: from TOD#0:0:0 to TOD#23:59:59 B
DATE_AND_TIME: from DT#1990-01-01:0:0:0 to DT#2099-12-31:23:59:59
DATE: from D#1990-01-01 to D#2099-12-31

Note 15 : Rounding is performed as follows: x.0 s to x.4 s are rounded to x s


and x.5 s to x.9 s are rounded to x+1 s.

Note 16 : It is possible to index all types of directly represented variables


positively and negatively within the limit of their respective maximum number
defined in configuration.

___________________________________________________________________________
6/15
B

Error conditions
Error conditions PL7 limits and behavior

Type conversion errors Indicated during the execution


with a system bit: See
table Common elements:
table 22, feature 1
Numerical result exceeds range for Indicated during the execution
data type with system bit %S18

Invalid character position specified Indicated during the execution


with system bit %S18

Result exceeds maximum string length Indicated during the execution


with system bit %S15

Overflow errors during evaluation of a Detected during programming


transition
Execution deadlines not met Indicated on execution
with system bit %S19
Other task scheduling conflicts Detected during configuration
Division by zero Detected during programming
if possible, otherwise indicated
Type of data invalid for an operation on execution with system bit
%S18
Failure of a FOR or WHILE iteration The PLC goes to watchdog
to finish overflow fault and the CPU
involved is indicated

___________________________________________________________________________
6/16
Section
Quick reference 7
guide 7
7 Quick reference guide B
7.1 Quick reference guide
Boolean LD IL
instructions
Accumulator or
rung initialization LD TRUE B
Test (read) LD
direct, negated, LDN
rising edge, LDR
P N
falling edge LDF

Logic AND P N AND ANDN ANDR ANDF

P N
AND( AND(N AND(RAND(F

Logic OR OR ORN ORR ORF


direct, negated, P N
rising edge,
falling edge P N OR( OR(N OR(R OR(F

Inversion N
Exclusive logic OR XOR XORN
(direct, negated, rising XORR XORF
edge, falling edge
Write ST
( ) ( / )
(direct, negated) STN
Set to 1 S
(S ) (R )
Set to 0 R
Operation block OPERATE
(for contents see action [action]
following pages)
Horizontal comparison LD [comparison]
block AND [comparison]
COMPARE
(for contents see AND( [comparison]
comparison
comparaison
following pages) OR [comparison]
OR( [comparison]
XOR [comparison]
Vertical comparison COMPARE
block EN >
=
<
<>

Memory PusH MPS


Memory ReaD MRD
Memory PoP MPP

___________________________________________________________________________
7/1
B
b
Instructions ST
Assignment :=
Boolean OR OR
Boolean AND AND
Boolean exclusive OR XOR
Negation NOT
Rising, falling edge RE, FE
Set to 1, set to 0 SET, RESET

Function blocks LD IL
IEC timer %TMi IN
IN Q
BLK..END_BLK structure
PL7-3 timer %Ti
E D

C R

Up/down counter % Ci R
R E
S
S D CU
CU F CD
CD BLK..END_BLK structure
%MNi
Monostable S
S R
BLK..END_BLK structure
%Ri
Register R
R F
I
I E O
O BLK..END_BLK structure
Drum % D Ri R
R F U
U
BLK..END_BLK structure

Function blocks ST
IEC timer START %TMi
DOWN %TMi
PL7-3 timer PRESET %Ti
START %Ti
STOP %Ti
Up/down counter RESET %Ci
PRESET %Ci
UP %Ci, DOWN %Ci
Monostable START %MNi
register RESET %Ri
PUT %Ri
GET %Ri
Drum RESET %DRi
UP %DRi
___________________________________________________________________________
7/2
Quick reference guide 7

B
Control structure ST
Conditional action IF...THEN... ELSIF...THEN... ELSE...END_IF;
Conditional iterative action WHILE...DO...END_WHILE;
Conditional iterative action REPEAT...UNTIL...END_REPEAT;
Repetitive action FOR...DO...END_FOR; B
Loop output instruction EXIT
Arithmetic operations on integers LD/IL/ST
(single and double length)
Transfer or initialization :=
Comparisons = <> <= “ >=
Addition, subtraction, multiplication, + - * / REM
division, remainder
AND, OR, exclusive OR, complement AND OR XOR NOT
Absolute value, square root ABS, SQRT
Increment INC
Decrement DEC
Shift to the left SHL
Shift to the right SHR
Circular shift to the left ROL
Circular shift to the right ROR
Arithmetic operations on floating points LD/IL/ST
Transfer or intialization :=
Comparisons = <> <= “ >=
Addition, subtraction, multiplication, + - * / TRUNC
division, integer part
Absolute value, square root ABS, SQRT
Logarithm, exponentials LOG, LN, EXPT, EXP
Sine, cosine, tangent SIN, COS, TAN
Arc sine, arc cosine, arc tangent ASIN, ACOS, ATAN
Degree <--> radian conversion DEG_TO_RAD, RAD_TO_DEG

Numeric conversions LD/IL/ST


Convert BCD to single length integer BCD_TO_INT
Convert GRAY to single length integer GRAY_TO_INT
Convert single length integer to BCD INT_TO_BCD
Convert single length integer to floating point value INT_TO_REAL
Convert double length integer to floating point value DINT_TO_REAL
Convert floating point value to single length integer REAL_TO_INT
Convert floating point value to double length integer REAL_TO_DINT
Convert 32-bit BCD to 32-bit integer DBCD_TO_DINT
Convert 32-bit integer to 32-bit BCD DINT_TO_DBCD
Convert 32-bit BCD to 16-bit integer DBCD_TO_INT
Convert 16-bit integer to 32-bit BCD INT_TO_DBCD
Extract a low order word from a double word LW
Extract a high order word from a double word HW
Concatenate 2 single words CONCATW
___________________________________________________________________________
7/3
B
Bit table LD/IL/ST
Transfer or intialization :=
Copy a bit table into a bit table COPY_BIT
AND between two tables AND_ARX
OR between two tables OR_ARX
Exclusive OR between two tables XOR_ARX
Negation on a table NOT_ARX
Copy a bit table into a word table BIT_W
Copy a bit table into a double word table BIT_D
Copy a word table into a bit table W_BIT
Copy a double word table into a bit table D_BIT
Calculate the length of a table LENGTH_ARX

Instructions on tables LD/IL/ST


Transfer and initialization :=
Arithmetic operations between tables + - * / REM
Logic operations between tables AND OR XOR
Arithmetic operations between a table and an integer + - * / REM
Logic operations between a table and an integer AND OR XOR
Complement of the elements of a table NOT
Sum of all the elements of a table SUM
Comparison of two tables EQUAL
Find 1st element in a table equal to a value FIND_EQW, FIND_EQD
Find 1st element in a table equal to a value from a row FIND_EQWP, FIND_EQDP
Find 1st element in a table greater than a value FIND_GTW, FIND_GTD
Find 1st element in a table less than a value FIND_LTW, FIND_LTD
Find highest value in a table MAX_ARW, MAX_ARD
Find lowest value in a table MIN_ARW, MIN_ARD
Number of occurrences of a value in a table OCCUR_ARW, OCCUR_ARD
Circular shift left in a table ROL_ARW, ROL_ARD
Circular shift right in a table ROR_ARW, ROL_ARW
Sort a table (ascending or descending order) SORT_ARW, SORT_ARD
Calculate the length of a table LENGTH_ARW, LENGTH_ARD
Instructions on floating point tables LD/IL/ST
Transfer and initialization :=
Sum of all the elements of a table SUM_ARR
Comparison of two tables EQUAL_ARR
Find 1st element in a table equal to a value FIND_EQR
Find 1st element in a table greater than a value FIND_GTR
Find 1st element in a table less than a value FIND_LTR
Find highest value in a table MAX_ARR
Find lowest value in a table MIN_ARR
Number of occurrences of a value in a table OCCUR_ARR
Circular shift left in a table ROL_ARR
Circular shift right in a table ROR_ARR
Sort a table (ascending or descending order) SORT_ARR
Calculate the length of a table LENGHT_ARR

___________________________________________________________________________
7/4
Quick reference guide 7

B
«Orphee» instructions LD/IL/ST
Shift to the left on word with retrieval of shifted WSHL_RBIT, DSHL_RBIT
bits
Shift to the right on word with sign extension and WSHR_RBIT, DSHR_RBIT
retrieval of shifted bits B
Shift to the right on word with filling of spaces WSHRZ_C, DSHRZ_C
with 0 and retrieval of shifted bits
Up/down counting with indication of SCOUNT
overshoot
Circular shift to the left ROLW, ROLD
Circular shift to the right RORW, RORD
Explicit exchanges LD/IL/ST
Read %M parameters of a logical channel READ_PARAM
Read status %M of a logical channel READ_STS
Restore %M parameters of a logical channel RESTORE_PARAM
Save %M parameters of a logical channel SAVE_PARAM
Write control %M of a logical channel WRITE_CMD
Write %M parameters of a logical channel WRITE_PARAM
Time management instructions LD/IL/ST
Realtime clock SCHEDULE
Comparisons = <> <= “ >=
Transfer :=
Read date and code of last PLC stop PTC
Read system date RRTC
Update system date WRTC
Add a time to a full date ADD_DT
Add a time to a time of day ADD_TOD
Convert date to string DATE_TO_STRING
Day of the week DAY_OF_WEEK
Difference between two dates DELTA_D
Difference between two full dates DELTA_DT
Difference between two times of day DELTA_TOD
Convert full date to string DT_TO_STRING
Subtract a duration from a full date SUB_DT
Subtract a duration from a time of day SUB_TOD
Convert duration to string TIME_TO_STRING
Convert time of day to string TOD_TO_STRING
Change duration to hours-min-sec format TRANS_TIME
Time delay instructions LD/IL/ST
On-delay FTON
Off-delay FTOF
Pulse time delay FTP
Square wave signal generator FPULSOR
Data archiving instructions LD/IL/ST
Initialize archiving zone on PCMCIA card SET_PCMCIA
Write data to PCMCIA card WRITE_PCMCIA
Read data from PCMCIA card READ_PCMCIA

___________________________________________________________________________
7/5
B
Instructions on character strings LD/IL/ST
Comparisons = <> <= “ >=
Transfer :=
Convert double integer to string DINT_TO_STRING
Convert single integer to string INT_TO_STRING
Convert string to double integer STRING_TO_DINT
Convert string to single integer STRING_TO_INT
Convert string to floating point value STRING_TO_REAL
Convert floating point value to string REAL_TO_STRING
Concatenation of two chains CONCAT
Delete substring DELETE
Find first different character EQUAL_STR
Find substring FIND
Insert substring INSERT
Extract left part of a string LEFT
Length of a string LEN
Extract substring MID
Replace substring REPLACE
Extract right part of a string RIGHT

Multitasks and events LD/IL/ST


Task activation / deactivation %Si position
Adjust task scan time %SWi position

Global masking of events MASKEVT


Global unmasking of events UNMASKEVT

Communication LD/IL/ST
Request to stop a function in progress CANCEL
Send and/or receive data DATA_EXCH
Request to read character string INPUT_CHAR
Send and/or request to receive a character string OUT_IN_CHAR
Send character string PRINT_CHAR
Receive telegram RCV_TLG
Read basic language objects READ_VAR
Send/receive UNI-TE requests SEND_REQ
Send telegram SEND_TLG
Write basic language objects WRITE_VAR
Circular shift one byte to the right in a table ROR1_ARB
Swap bytes in a word table SWAP
Read common Modbus+ data READ_GDATA
Write common Modbus+ data WRITE_GDATA
Management of the modem card connection CALL_MODEM
Immediate server SERVER
Write 1 K message WRITE_ASYN
Read 1 K message READ_ASYN

___________________________________________________________________________
7/6
Section 88
Performance
8 Performance
B
8.1 General

This section calculates for TSX 37/57 PLCs :


• the execution time of the application program,
• the memory size of the application program. B

Execution time of the application program

The execution time of the program is calculated using the tables on the following pages,
by adding up the time taken for each program instruction.

Note : the time obtained is a maximum time. In fact, an operate block or a subroutine
will only be processed if the execution condition (logic equation conditioning the
execution of the block or subroutine) is true. It may be, therefore, that the actual time
is much less than the maximum time calculated.

Calculating the complete cycle time involves parameters which are specific to the PLC
(overhead time, duration of I/O exchange, etc.). Please refer to the PLC installation
manual (performance section) for the complete calculation procedure.

Application memory size

The size of the application is the sum of the following elements :

Element Calculation method


• Program Add up each of the program instructions, (see
tables in sections 8.2 and 8.3) and multiply by the
coefficient which corresponds to the language used
(see next page)
• Advanced functions See section 8.4.4
• Configured PL7 objects See section 8.4.2
• Configured I/O module See section 8.4.3

___________________________________________________________________________
8/1
B
In the tables on the following pages, information on sizes refers to the volume of
instruction codes. In order to find out the total size of an instruction or a program, it is
necessary to use a multiplication coefficient which takes account of information that is
typical to a language (for example : graphic information in the case of Ladder language).

• Ladder language : Total volume = 1.7 x Code volume

• Structured Text language : Total volume = 1.6 x Code volume

• Instruction List language :


- for TSX37 PLCs : Total volume = 1.4 x Code volume
- for TSX57 PLCs : Total volume = 1.6 x Code volume

• Grafcet language :
The volume associated with the chart itself is as follows :
Chart volume (in words) = 214 + 17 * no. of chart steps + 2 * total no. of configured
steps + 4 * no. of programmed actions

Note : program comments occupy 1 byte per character.

Comment
The figures shown in the following tables are average estimations obtained from a
typical application. It is not possible to provide exact data, since PL7 optimizes
memory use according to the contents and structure of the application.

Section 8.4.1 describes the various memory zones occupied by the application.

___________________________________________________________________________
8/2
Performance 8

B
8.2 TSX 37 performance
8.2.1 Boolean instructions
LD IL ST Objects Execution time Size
(µs) (words)
3705 3720 3720 37xx B
08/10 ram cart
0.25 0.13 0.19 1

LD, %M1 (1) 0.25 0.13 0.19 1

LDN
%M1[%MW2] 13.10 12.85 12.85 7
%MW0:X0 (2) 6.06 5.75 5.75 4
%IWi.j:Xk (3) 77.04 69.25 69.25 8
%MW0[%MW10]:X0 16.29 15.55 15.55 8
%KW0[%MW10]:X0 87.27 79.05 79.05 12
LDR, %M1 0.50 0.25 0.38 2

LDF
%M1[%MW2] 13.01 12.75 12.75 7
AND, idem LD, LDN

ANDN , AND (, AND (N , idem OR


ANDR, ANDF, AND (R, AND (F, idem OR idem LDR LDF

XOR, XORN %M1 1.25 0.63 0.94 5


%M1[%MW2] 26.9426.08 26.26 13
%MW0:X0 12.8611.88 12.06 10
%IWi.j:Xk 83.8475.38 75.56 14
%MW0[%MW10]:X0 33.3331.48 31.66 14
%KW0[%MW10]:X0 104.3194.98 95.16 18
1
XORR, XORF %M1 2.25 1.13 1.69 9
%M1[%MW2] 27.28 26.13 26.44 19
ST, STN, %M1 0.50 0.25 0.38 2

S, R
%M1[%MW2] 13.10 12.85 12.85 7
%MW0:X0 5.88 5.60 5.60 4
%NW{i}j:Xk (3) 76.86 69.10 69.10 8
%MW0[%MW10]:X0 16.41 15.65 15.65 8
multiple coils in Ladder, «cost» of the 2nd and subsequent coils 0.25 0.13 0.19 1
operation block [ action] block executed 0.74 0.75 0.75 1
not executed 5.55 5.40 5.40 1

(1) This concerns all the bit objects which can be forced : %I, %Q, %X, %M, %S
(2) Other objects of the same type : output bits of function block %TMi.Q ..., system
word extract bits %SWi:Xj
(3) Other objects of the same type : common word extract bits %NW{i}j:Xk, I/O word
extract bits %IWi.j.Xk, %QWi.j.Xk, %KW extract bits, fault bits %Ii.j.ERR

___________________________________________________________________________
8/3
B
LD IL ST Objects Execution time Size
(µs) (words)
3705 3720 3720 37xx
08/10 ram cart
horizontal comparison LD time in addition to the 0.00 0.00 0.00 0
block [comparison] comparison
vertical comparison between 2 %MWi 12.38 11.85 11.85 4
block
convergence ) ) 0.25 0.13 0.19 1
divergence not followed ladder, 1 divergence 0.25 0.13 0.19 1
by a convergence
MPS, MPP, list MPS+MPP 0.75 0.38 0.56 3
MRD list MRD 0.25 0.13 0.19 1

8.2.2 Function blocks


LD IL ST objects/conditions Execution time Size
(µs) (words)
03705/08/10 3720 37xx

IE timer
rising edge on IN IN %TM1 START %TM1 start timer 43.39 41.11 3
(rising edge)
falling edge on IN IN %TM1 DOWN %TM1 stop timer 17.47 17.01
(falling
edge)
IN =1 IN %TM1 (=1) timer on 18.74 17.99

IN =0 IN %TM1 (=0) timer off 17.40 16.67

PL7-3 timer
START %T1 enable 3

STOP %T1 freeze 12.63 12.15

E=0 RESET %T1 reset 12.94 12.15

timer on 17.55 17.00

timer off

Up/down counter
reset, R=1 R %C8 (=1) RESET %C8 reset 18.69 17.92 3

preset, S=1 S %C9 (=1) PRESET %C9 preset 20.42 19.73

rising edge on CU CU %C8 UP %C8 up 19.92 19.10


(rising edge)

rising edge on CD CD %C9 DOWN %C9 down 19.92 19.10


(rising edge)

inactive inputs R/S/CU/CD inactive bit no action 13.27 12.81

___________________________________________________________________________
8/4
Performance 8

B
Function blocks (continued)
LD IL ST objects/conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx

B
Monostable
rising edge on S S %MN0, START %MN0 start 35.08 33.16 3
rising edge
S=1 S %MN0, active monostable 11.64 11.17
S=1/0

Register
edge on I I %R2 (edge) PUT %R2 store 21.90 21.27 3

edge on O O %R2 (edge) GET %R2 retrieve 21.90 21.27

R=1 R %R1 (=1) RESET %R2 reset 16.90 16.02

inactive inputs I/O/R, inactive no action 12.61 12.19


bit

Drum
edge on U U %DR0 UP %DR1 up, fixed 181.37 169.13 3

by control bit 19.30 19.30

R=1 R %DR1 RESET %DR2 reset, fixed 174.15 162.03

by control bit 19.30 19.30

inactive inputs R/U, inactive bit no action, fixed 175.92 164.00

by control bit 19.30 19.30

___________________________________________________________________________
8/5
B
8.2.3 Integer and floating point arithmetic

Corrections according to object type


The times and volumes in these pages are given for %MW0, %MD0 or %MF0

Execution time Size


(µs) (words)
3705/08/10 3720 37xx

• Value to remove for immediate values


16#1234/%MW0 1.20 1.10 0
16#12345678 / 1.21 0.75 1
%MD0 or
%MF/0

• Value to add for indexed words/double words/floating point words


%MW2[%MW0] last object the := 10.52 10.05 4
or
%MD2[%MW0]
or
%MF2[%MW0]
1st operation : the 11.20 10.60 5
1st operand not being
indexed, or assignment

2nd operand if the 13.37 12.60 5


1st operand is also
indexed

• Value to add for objects of the following type :


%KWi, %KWi[%MW0], %KDi, %KFi, common words, I/O words

70.98 63.50 2

Correction according to the context of the operation


• Value to add if the operation is in at least the 2nd position in the statement, example *%MW2
in := %MW0 * %MW1 * %MW2, concerns the following operations
%MW0 0.69 0.55 0
%MD0 and %MF0 0.99 0.75 0

• Value to add for an operation with the result of an operation in parentheses or of a higher prior-
ity, example : %MW0 + %MW2 + (...)
%MW0 2.86 2.55 1

%MD0 and %MF0 3.60 3.15 1

___________________________________________________________________________
8/6
Performance 8

B
ST Objects Conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx
object after the := %MW0 4.81 4.50 2
%MD0,%MF0 6.45 5.70 2
:= %MW0 4.46 4.30 2
B
%MD0 5.15 4.85 2
et %MF0
=, <>, <=, <, >, >= %MW0 8.94 8.50 4
%MD0 10.71 10.26 4
%MF0 29.06 28.39 4
AND, OR, XOR %MW0 7.29 6.90 3
%MD0 9.21 8.55 3
+, - %MW0 7.29 6.90 3
%MD0 9.21 8.55 3
%MF0 62.83 61.20 3
* %MW0 9.75 9.10 3
%MD0 39.63 36.50 3
%MF0 58.26 56.90 3
/, REM %MW0 10.69 10.08 3
%MD0 205.21 201.38 3
/ %MF0 62.47 60.25 3
ABS, -object %MW0 7.20 6.95 3
%MD0 9.97 9.53 3
%MF0 13.01 12.50 3
NOT %MW0 6.69 6.45 3
%MD0 7.80 7.40 3
SQRT %MW0 17.02 16.70 3
%MD0 85.73 85.25 3
%MF0 165.04 158.40 3
INC, DEC %MW0 4.86 4.40 2
%MD0 5.20 4.75 2
SHL, SHR, ROL, ROR %MW0 for 1 bit 17.74 17.05 5
%MD0 for 1 bit 20.58 19.15 5
per additional bit 0.063

LN %MF0 1371.60 1270.00 3


LOG %MF0 1458.00 1350.00 3
EXP %MF0 1155.60 1070.00 3
EXPT %MF0 2988.00 2490.00 3
TRUNC %MF0 204.00 170.00 3
COS %MF0 2829.60 2620.00 3
SIN %MF0 2840.40 2630.00 3
TAN %MF0 2937.60 2720.00 3
ACOS %MF0 4082.40 3780.00 3
ASIN %MF0 4082.40 3780.00 3
ATAN %MF0 2786.40 2580.00 3
DEG_TO_RAD %MF0 852.00 710.00 3
RAD_TO_DEG %MF0 720.00 600.00 3

___________________________________________________________________________
8/7
B
8.2.4 Program instructions
ST Objects Conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx
Jump %Li 41.93 38.20 3
Maskevt 12.21 10.80 1
Unmaskevt 40.27 37.10 1
SRi 48.68 42.88 3
Return 42.18 38.33 3

8.2.5 Command structure


ST Execution time Volume
(µs) (words)
3705/08/10 3720 37xx
<cond> condition evaluation
forceable bit see Boolean instruction LD %M1
comparison see comparisons =,<,> ...
if <cond > then <action> the times and volumes indicated below should
end_if; be added to those of the action contained in the structure
true condition 3.60 3.30 2

false condition (jump) 5.55 5.40


If <cond> then <action1>
else <action2> end_if;
true condition 9.15 8.70 4

false condition 5.55 5.40


while <cond> do.<action>
end_while
go to loop with loop-back 9.15 8.70 2

exit loop 5.55 5.40


repeat <action> until
<cond> end_repeat
go to loop with loop-back 5.55 5.40 2

last pass 3.60 3.30


for <word1:=word2>to <word3>
do <action> end_for
entry to the for command,
executed once only 8.58 8.25 15
go to loop with 29.38 27.35
loop-back
exit loop 20.42 19.40

___________________________________________________________________________
8/8
Performance 8

B
8.2.6 Numeric conversions
ST Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

BCD_TO_INT 25.03 24.55 24.55 3 B


INT_TO_BCD 21.66 21.15 21.15 3

GRAY_TO_INT 36.98 36.55 36.55 3

INT_TO_REAL 40.90 40.75 40.75 3

DINT_TO_REAL 33.32 32.55 32.55 3

REAL_TO_INT 58.75 58.55 58.55 3

REAL_TO_DINT 44.59 44.05 44.05 3

DBCD_TO_DINT 1 324.85 1 065.15 1 134.70 5

DBCD_TO_INT 1 265.54 925.70 986.15 5

DINT_TO_DBCD 1 124.85 825.15 879.10 5

INT_TO_DBCD 564.85 445.15 474.40 5

8.2.7 Bit string


ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Initializing a bit table


%M30:8 := 0 8 bits 19.38 18.88 18.88 6
%M30:16 := 1 16 bits 20.38 19.88 19.88 6
%M30:24 := 2 24 bits 24.25 23.35 23.35 6
%M30:32 := 2 32 bits 25.25 24.35 24.35 6

___________________________________________________________________________
8/9
B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Copying a bit table to a bit table


%M30:8 := %M20:8 8 bits 25.54 24.79 24.79 6
%M30:16 := %M20:16 16 bits 26.16 25.41 25.41 6
%M30:24 := %M20:24 24 bits 33.41 32.26 32.26 6
%M30:32 := %M20:32 32 bits 35.91 34.76 34.76 6
%M30:16 := COPY_BIT(%M20:16) 16 bits 281.63 230.00 244.95 9
32 bits 440.82 360.00 383.40 9
128 bits 1 261.22 1 030.00 1 096.95 9

Logic instructions on bit tables


AND_ARX, OR_ARX, XOR_ARX
%M0:16 := AND_ARX(%M30:16,%M50:16) 16 bits 397.42 320.00 340.80 12
%M0:32 := AND_ARX(%M30:32,%M50:32) 32 620.97 500.00 532.50 12
%M0:128 := AND_ARX(%M30:128,%M50:128) 128 1 887.74 1 520.00 1 618.80 12
NOT_ARX
%M0:16 := NOT_ARX(%M30:16) 16 bits 281.63 230.00 244.95 9
32 440.82 360.00 383.40 9
128 1 261.22 1 030.00 1 096.95 9

Copying a bit table to a word table


%MW1 := %M30:8 8 bits 14.84 14.36 14.36 5
%MW1 := %M30:16 16 bits 16.34 15.86 15.86 5
%MD2 := %M30:24 24 bits 14.54 14.23 14.23 5
%MD2 := %M30:32 32 bits 16.04 15.73 15.73 5
%MW1:4 := BIT_W(%M40:80.0,17.2) 17 bits 501.43 390.00 415.35 16
%MD1:4 := BIT_D(%M30:80.0,33.0) 33 bits 379.53 530.00 564.45 16

Copying a word table to a bit table


%M30:8 := %MW1 8 bits 19.28 18.68 18.68 5
%M30:16 := %MW2 16 bits 20.28 19.68 19.68 5
%M30:24 := %MD1 24 bits 21.20 20.37 20.37 5
%M30:32 := %MD3 32 bits 22.20 21.37 21.37 5
%M30:32 := W_BIT(%MW200:2.0,2.0) 32 bits 488.68 370.00 394.05 16
%M30:32 := D_BIT(%MD0:1.0,2.0) 32 bits 567.33 460.00 489.90 16

___________________________________________________________________________
8/10
Performance 8

B
8.2.8 Word, double word and floating point value tables
ST conditions Execution time volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Initializing a word table with a word


%MW0:10 := %MW100 10 words 47.46 42.15 42.15 7
B
per word 0.34 0.20 0.20
%MD0:10 := %MD100 10 double words 81.27 74.45 74.45 7
per double word 2.87 2.65 2.65

Copying a word table to a word table


%MW0:10:=%MW20:10; 10 words 95.80 85.35 85.35 9
per word 0.77 0.50 0.50
%MD0:10:=%MD20:10; 10 double words 111.13 97.65 97.65 9
per double word 1.54 1.00 1.00

Arithmetic and logic instructions between two word tables


+, -
%MW0:10 :=%MW10:10 + %MW20:10; 10 words 168.04 151.95 151.95 14
per word 7.13 6.35 6.35
%MD0:10:=%MD10:10+%MD20:10; 10 double words 239.17 214.40 214.40 14
per double word 13.84 12.25 12.25
*
%MW0:10:=%MW10:10 * %MW20:10; 10 words 189.32 175.40 175.40 14
per word 9.27 8.70 8.70
%MD0:10:=%MD10:10 * %MD20:10; 10 double words 710.35 603.80 603.80 14
per double word 61.64 51.20 51.20
/, REM
%MW0:10:=%MW10:10 / %MW20:10; 10 words 224.76 181.40 181.40 14
per word 13.14 9.30 9.30
%MD0:10:=%MD10:10 / %MD20:10; 10 double words 2 192.38 2 157.35 2 157.35 14
per double word 209.16 206.55 206.55
AND, OR, XOR
%MW0:10:=%MW10:10 AND %MW20:10; 10 words 163.69 147.40 147.40 14
per word 6.66 5.85 5.85
%MD0:10:=%MD10:10 AND %MD20:10; 10 double words 240.14 215.90 215.90 14
per double word 13.94 12.40 12.40

___________________________________________________________________________
8/11
B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Arithmetic and logic instructions between 1 word table and 1 word


+, -
%MW0:10 :=%MW10:10 + %MW20; 10 words 119.12 108.55 108.55 12
or %MW0:10 := %MW20 + %MW10:10 per word 2.87 2.65 2.65
%MD0:10 :=%MD10:10 + %MD20; 10 double words 159.68 147.45 147.45 12
per double word 6.57 6.25 6.25

*
%MW0:10 :=%MW20*%MW10:10; 10 words 166.86 132.45 132.45 12
per word 7.94 5.05 5.05
%MD0:10:=%MD20*%MD10:10; 10 double words 587.01 522.95 522.95 12
per double word 49.18 43.80 43.80
/, REM
%MW0:10 :=%MW10:10 / %MW30; 10 words 196.69 155.85 155.85 12
per word 10.86 7.30 7.30
%MD0:10:=%MD10:10 / %MD30; 10 double words 2 230.17 2 173.95 2 173.95 12
per double word 213.66 208.90 208.90
AND, OR, XOR
%MW0:10 :=%MW10:10 AND %MW20; 10 words 117.20 106.45 106.45 12
per word 2.64 2.40 2.40
%MD0:10:=%MD20*%MD10:10; 10 double words 587.01 522.95 522.95 12
per double word 6.47 6.15 6.15
NOT
%MW0:10 :=NOT(%MW10:10); 10 words 110.28 100.25 100.25 9
per word 2.96 2.75 2.75
%MD0:10:=NOT(%MD10:10); 10 double words 126.39 114.00 114.00 9
per double word 4.50 4.05 4.05

Table summing function


%MW20:=SUM(%MW0:10); 10 words 74.30 69.00 69.00 10
per word 2.44 2.35 2.35
%MD20:=SUM(%MD0:10); 10 double words 83.58 76.90 76.90 10
per double word 3.17 2.95 2.95
%MF20:=SUM_ARR(%MF0:10); 10 double words 1634 1257 1257 10
per double word

___________________________________________________________________________
8/12
Performance 8

B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Comparison of tables function


%MW20:=EQUAL(%MW0:10;%MW10:10); 10 words 103.78 93.50 93.50 11
B
per word 1.13 0.90 0.90
%MD20:=EQUAL(%MD0:10;%MD10:10); 10 double words 116.17 103.40 103.40 11
per double word 2.23 1.75 1.75
%MF20:=EQUAL_ARR(%MF0:10;%MF10:10); 10 double words 741 570 607 11
per double word

Find
%MW20 := FIND_EQW(%MW0:10,%KW0) 10 words, max. 340.00 250.00 266.25 15
instance
%MD20 := FIND_EQD(%MD0:10, %KD0) 10 double words, 350.00 260.00 276.90 16
max. instance
%MF20 := FIND_EQR(%MF0:10, %KF0) 10 double words 833 648 690.12 15
%MF20 := FIND_EQRP(%MF0:10, %KF0) 10 double words 845 650 692.25 15
%MD20 := FIND_GTR(%MF0:10, %KF0) 10 double words 836 643 684.79 15
%MD20 := FIND_LTR(%MF0:10, %KF0) 10 double words 836 643 684.79 15

Finding max. and min. values


%MW20 := MAX_ARW(%MW0:10) 10 words 350.00 260.00 276.90 9
%MD20 := MAX_ARD(%MD0:10) 10 double words 410.00 300.00 319.50 9
%MF20 := MAX_ARR(%MF0:10) 10 double words 1366 1051 1119.31 9
%MF20 := MIN_ARR(%MF0:10) 10 double words 1270 977 1040.50 9

Number of occurrences
%MW20 := OCCUR_ARW(%MW0:10, %KW0) 10 words 350.00 250.00 266.25 15
%MD20 := OCCUR_ARD(%MD0:10, %KD0) 10 double words 370.00 270.00 287.55 16
%MF20 := OCCUR_ARR(%MF0:10, %KF0) 10 double words 1265 973 1036.24 16

Circular shift
ROL_ARW(word or value, %MWj:10) 10 words 550.00 400.00 426.00 9
ROL_ARD(%MDi,%MDj:10) 10 double words 590.00 430.00 457.95 9
ROL_ARR(%MFi,%MFj:10) 10 double words 585 450 479.25 9

Sort
SORT_ARW(%MWi,%MWj:10) 10 words, max. 970.00 700.00 745.50 9
instance
SORT_ARD(%MDi,%MDj:10) 5 double words, max. 610.00 450.00 479.25 9
instance
SORT_ARR(%MFi,%MFj:10) 10 double words 1863 1433 1526.14 9

___________________________________________________________________________
8/13
B
8.2.9 Time management
ST Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

Date, time and duration OF


%MW2:4 := ADD_DT(%MW2:4,%MD8) 4 400.00 3 300.00 3 514.50 13

%MD2 := ADD_TOD(%MD2,%MD8) 2 100.00 1 550.00 1 650.75 9

%MB2:11 := DATE_TO_STRING(%MD40) 1 370.00 900.00 958.50 9

%MW5 := DAY_OF_WEEK() 220.00 280.00 298.20 5

%MD10 := DELTA_D(%MD2, %MD4) 1 520.00 1 130.00 1 203.45 9

%MD10 := DELTA_DT(%MD2:4,%MW6:4) 3 170.00 2 300.00 2 449.50 13

%MD10 := DELTA_TOD(%MD2,%MD4) 2 330.00 1 700.00 1 810.50 9

%MB2:20 := DT_TO_STRING(%MW50:4) 2 050.00 1 450.00 1 544.25 11

%MW2:4 := SUB_DT(%MW2:4,%MD8) 4 750.00 3 500.00 3 727.50 13

%MD2 := SUB_TOD(%MD2,%MD8) 2 330.00 1 700.00 1 810.50 9

%MB2:15 := TIME_TO_STRING(%MD40) 1 560.00 1 200.00 1 278.00 9

%MB2:9 := TOD_TO_STRING(%MD40) 1 270.00 800.00 852.00 9

%MD100 := TRANS_TIME(%MD2) 500.00 500.00 532.50 7

Access real-time clock


RRTC(%MW0:4) 93.60 84.80 84.80 5

WRTC(%MW0:4) 248.61 230.85 230.85 5

PTC(%MW0:5) 97.98 88.60 88.60 5


SCHEDULE(%MW0,%MW1,%MW2, 1430 1100 1171.5 5
%MD10,%MD12,%M0)

___________________________________________________________________________
8/14
Performance 8

B
8.2.10 Character strings
ST Conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx

B
Character string assignment, feedback
%MB0:8:=%MB10:8 8 characters 105.16 93.80 93.80 9
per character 1.65 1.30 1.30
%MB0:8:=’abcdefg’ 8 characters 120.72 110.20 110.20 11
per character 4.15 3.85 3.85 0.5

Word <-> character string conversions


%MW1:=STRING_TO_INT(%MB0:7) 97.69 91.95 91.95 7
%MB0:7:=INT_TO_STRING(%MW0) 104.36 96.70 96.70 7

Double word <-> character string conversions


%MD1:=STRING_TO_DINT(%MB0:13) 1 070.53 965.62 965.62 7
%MB0:13:=DINT_TO_STRING(%MD0) 322.29 295.35 295.35 7

Floating point value <-> character string conversions


%MF1:=STRING_TO_REAL(%MB0:15) 1 783.70 1 634.53 1 634.53 7
%MB0:15:=REAL_TO_STRING(%MF0) 741.75 681.20 681.20 7

String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) 1 170.00 770.00 820.05 15
%MB10:20 := DELETE(%MB10:22.2,3); 950.00 600.00 639.00 15
%MW0 := EQUAL_STR(%MB10:20,%MB30:20); the 5th character 860.00 520.00 553.80 13
is different
%MW0 := FIND(%MB10:20,%MB30:10); 1 610.00 1 000.00 1 065.00 13
%MB10:20 := INSERT(%MB30:10,%MB50:10.4); 1 270.00 800.00 852.00 17
%MB10:20 := LEFT(%MB30:30,20); 920.00 570.00 607.05 13
%MW0 := LEN(%MB10:20); 770.00 340.00 362.10 9
%MB10:20 := MID(%MB30:30,20,10); 1 080.00 700.00 745.50 15
%MB10:20 : 1 450.00 870.00 926.55 19
= REPLACE(%MB30:20,%MB50:10,10,10);
%MB10:20 := RIGHT(%MB30:30,20); 1 480.00 950.00 1 011.75 13

___________________________________________________________________________
8/15
B
8.2.11 Application-specific functions and Orphee function
ST Conditions Execution time Volume
(µs) (words)
3705/ 3720 3720 37xx
08/10 ram cart

Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10,%MW30:4) 2182 1818 1936 21
SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 1636 1364 1452 15

Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2208 19
SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2208 19
GET_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
GET_VALUE(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) 2 240 2 000 2 208 23
ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) 2 240 2 000 2 208 21
DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19

Process control
PID(“PIDS1”,’Unit’,%IW3.5,%MW12,%M16,%MW284:43) deval_mmi=0 1320 1100 1172 24
deval_mmi=1 1080 900 958.5
PWM(%MW11,%Q2.1,%MW385:5) 600 500 532.5 11
SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3,%MW284:43, 960 800 852 19
%MW390:10)
PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1140 950 1012 20

___________________________________________________________________________
8/16
Performance 8

B
ST Conditions Execution time Volume
(µs) (words)
3705/ 3720 3720 37xx
08/10 ram cart

Orphee function
DSHL_RBIT(%MD102,16,%MD204,%MD206) read 10 words 440 320 341 13 B
DSHR_RBIT(%MD102,16,%MD204,%MD206) write 10 words 660 480 511 13
DSHRZ_C(%MD102,16,%MD204,%MD206) mirror req.10 words 410 310 330 13
WSHL_RBIT(%MW102,8,%MW204,%MW206) exchange 10 words 300 220 234 13
WSHR_RBIT(%MW102,8,%MW204,%MW206) 20 bytes 390 280 298 13
WSHRZ_C(%MW102,8,%MW204,%MW206) 20 bytes 300 220 234 13
SCOUNT(%M100,%MW100,%M101,%M102,%MW101, 20 bytes 510 410 437 25
%MW102,%M200,%M201,%MW200,%MW201)

8.2.12 Explicit I/O


Read_Sts %CHi.MOD
Any application except for the processor communication 30 30 32 2
channel
Read_Sts %CHi
Analog input 180 180 216 6
Analog output 90 70 74
CTZ counter module 110 95 104
Write_Param %CHi
Analog input 790 570 790 6
CTZ counter module 1127 1080 1083
Read_Param %CHi
Analog input 260 290 316 6
CTZ counter module 338 295 300
Save_Param %CHi
Analog input 1234 1220 1240 6
CTZ counter module 1370 1220 1240
Restore_Param %CHi
Analog input 550 510 535 6
CTZ counter module 1160 1080 1097
Write_Cmd %CHi
Discrete output 50 47 52 6

___________________________________________________________________________
8/17
B
8.3 TSX 57 performance
A more convenient method of displaying the processors has been used in the rest of this
document, by grouping them into 3 families :

Reference Processors
A TSX 57 10 and PCX 57 10
B TSX 57 20, TSX 57 25, TSX 57 30, TSX 57 35
PMX 57 10, PCX 57 35
C TSX 57 40, TSX 57 45
PMX 57 20, PMX 57 35, PMX 57 45

Note : in the rest of this document, the 3 families are shown at the foot of each page as a
reminder.

___________________________________________________________________________
8/18
Performance 8

B
8.3.1 Boolean instructions
LD IL ST Objects Execution time Size
(µs) (words)
A A B/C B/C B/C B/C 57xx
> 4K ram ram cart cart

0.29 0.12
> 4K
0.21
> 4K
1
B

LD, %M1 (1) 0.58 0.25 0.37 0.37 0.58 1

LDN
%M1[%MW2] 2.33 1.00 1.00 1.58 1.58 6
%MW0:X0 (2) 1.46 0.62 0.62 1.00 1.00 4
%IWi.j:Xk (3) 2.33 1.00 1.00 1.58 1.58 6
%MW0[%MW10]:X0 3.50 1.50 1.50 2.37 2.37 9
%KW0[%MW10]:X0 3.50 1.50 1.50 2.37 2.37 9
LDR, %M1 0.87 0.37 0.50 0.58 0.79 2

LDF
%M1[%MW2] 2.62 1.12 1.12 1.79 1.79 7
AND, idem LD, LDN

ANDN , AND (, AND (N , idem OR


ANDR, ANDF, AND (R, AND (F, idem OR idem LDR, LDF

XOR, XORN %M1 2.04 0.87 1.12 1.37 1.79 5


%M1[%MW2] 5.54 2.37 1.62 3.79 2.62 13
%MW0:X0 4.08 1.75 1.37 2.83 2.25 10
%IWi.j:Xk 4.96 2.12 1.75 3.42 2.83 14
%MW0[%MW10]:X0 7.87 3.37 2.25 5.37 3.62 14
%KW0[%MW10]:X0 7.87 3.37 2.25 5.37 3.62 18
XORR, XORF %M1 2.25 1.13 1.62 1.69 2.62 9
%M1[%MW2] 27.28 26.13 2.87 26.44 4.62 19
ST, STN, %M1 1.17 0.50 0.62 0.75 0.96 2

S, R
%M1[%MW2] 2.62 1.12 1.12 1.75 1.75 7
%MW0:X0 1.75 0.75 0.75 1.17 1.17 4
%NW{i}j:Xk (3) 2.62 1.12 1.12 1.75 1.75 8
%MW0[%MW10]:X0 3.79 1.25 1.25 2.54 2.54 8
multiple coils in Ladder, «cost» of the 2nd and subsequent coils 0.87 0.37 0.50 0.54 0.75 1
operation block [ action] block executed 0.58 0.25 0.25 0.42 0.42 1
not executed 0.71 0.37 0.37 0.54 0.54 1

(1) This refers to all bit objects which can be forced : %I, %Q, %X, %M, %S
(2) Other objects of the same type : output bits of function block %TMi.Q ..., system word extract
bits %SWi:Xj, %KW extract bits, fault bits %Ii.j.ERR
(3) Other objects of the same type : common word extract bits %NW{i}j:Xk, I/O word extract bits
%IWi.j.Xk, %QWi.j.Xk

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45

___________________________________________________________________________
8/19
B
LD IL ST Objects Execution time Size
(µs) (words)
A A B/C B/C B/C B/C 57xx
> 4K ram ram cart cart
> 4K > 4K
horizontal LD [comparison] time in addition to 0.00 0.00 0.00 0.00 0.00 0.00 0
comparison block the comparison
vertical between 2 %MWi 2.04 2.04 0.87 0.87 1.37 1.37 5
comparison block
convergence ) ) 0.29 0.29 0.12 0.12 0.21 0.21 1
divergence not followed ladder, 1 divergence 0.29 0.29 0.12 0.12 0.21 0.21 1
by a convergence
MPS, MPP, list MPS+MPP 0.87 0.87 0.37 0.37 0.62 0.62 3
MRD list MRD 0.29 0.29 0.12 0.12 0.21 0.21 1

8.3.2 Function blocks


LD IL ST objects/conditions Execution time Size
(µs) (words)
A B C 57xx

IE timer
rising edge on IN IN %TM1 START %TM1 start timer 67.87 46.92 13.52 3
(rising edge)
falling edge on IN IN %TM1 DOWN %TM1 stop timer 27.84 19.50 5.01
(falling edge)
IN =1 IN %TM1 (=1) timer on 32.15 22.66 5.80
IN =0 IN %TM1 (=0) timer off 28.60 20.18 5.40

PL7-3 timer
START %T1 enable 3
STOP %T1 freeze 23.08 16.16 5.13
E=0 RESET %T1 reset 23.46 16.26 5.85
timer on 30.40 21.51 5.78
timer off

Up/down counter
reset, R=1 R %C8 (=1) RESET %C8 reset 30.38 21.26 6.11 3
preset, S=1 S %C9 (=1) PRESET %C9 preset 33.99 23.55 6.25
rising edge on CU CU %C8 UP %C8 up 33.81 23.49 6.50
(rising edge)
rising edge on CD CD %C9 DOWN %C9 down 33.81 23.49 6.50
rising edge)
inactive steps R/S/CU/CD inactive bit no action 22.37 16.22 4.58

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/20
Performance 8

B
Function blocks (continued)
LD IL ST objects/conditions Execution time Size
(µs) (words)
A B C 57xx

B
Monostable
rising edge on S S %MN0, START %MN0 start 57.42 40.65 11.88 3
rising edge
S=1 S %MN0, active monostable 20.38 14.11 4.04
S=1/0

Register
edge on I I %R2 (front) PUT %R2 store 35.69 24.92 6.72 3
edge on O O %R2 (front) GET %R2 retrieve 35.69 24.92 6.72
R=1 R %R1 (=1) RESET %R2 reset 26.83 18.80 6.11
inactive inputs I/O/R, inactive no action 20.71 15.50 4.62
bit

Drum
edge on U U %DR0 UP %DR1 up, fixed 268.69 185.41 58.68 3
per control bit 25.00 25.00 25.00
R=1 R %DR1 RESET %DR2 reset, fixed 257.01 176.06 57.00
per control bit 25.00 25.00 25.00
inactive inputs R/U, inactive bit no action, fixed 259.07 179.06 56.82
per control bit 25.00 25.00 25.00

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/21
B
8.3.3 Integer and floating point arithmetic
Corrections according to object type
The time and volumes on the following pages are given for %MW0, %MD0 or %MF0

Execution time Size


(µs) (words)
A B ram B cart C ram C cart 57xx

• Value to remove for immediate values


16#1234 / %MW0 0.29 0.12 0.17 0.12 0.17 0

16#12345678 / %MD0 or %MF0 0.29 0.12 0.12 0.12 0.12 1

• Value to add for indexed words/double words/floating point values


%MW2[%MW0] object following the := 2.04 0.87 1.37 0.87 1.37 5
or %MD2[%MW0]
or %MF2[%MW0]
1st operation, assignment 2.04 0.87 1.37 0.87 1.37 5
2nd operation (or 1st 2.04 0.87 1.37 0.87 1.37 5
indexed operand)

• Value to add for objects of the following type :


Common words, I/O words 0.87 0.37 0.58 0.37 0.58 2

Correction according to the context of the operation


• Value to add if the operation is in at least the 2nd position in the statement, example
*%MW2 in := %MW0 * %MW1 * %MW2, concerns the following operations : *,/,REM on words
and double words, or all operations on floating point values
%MW0 0.58 0.25 0.37 0.25 0.37 1
%MD0 and %MF0 0.87 0.37 0.54 0.37 0.54 1

• Value to add for an operation in parentheses, or of a higher priority, example : %MW0 +


%MW2 + (...)
%MW0 0.29 0.12 0.17 0.12 0.17 1
%MD0 and %MF0 0.58 0.25 0.33 0.25 0.33 1

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/22
Performance 8

B
ST objects conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
object after the := %MW0 0.87 0.37 0.58 0.37 0.58 2
%MW0+(..., or before *, /, REM 1.17 0.50 0.75 0.50 0.75 2
%MD0 1.17 0.50 0.75 0.50 0.75 2 B
%MD0+(..., or before *, /, REM 1.75 0.75 1.08 0.75 1.08 2
%MF0 1.75 0.75 1.08 0.75 1.08 2
:= %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 and %MF0 1.17 0.50 0.75 0.50 0.75 2
=, <>, <=, <, >, >= %MW0 1.17 0.50 0.79 0.50 0.79 4
%MD0 1.46 0.62 1.04 0.62 1.04 4
%MF0 48.36 33.88 34.13 4.17 4.42 4
AND, OR, XOR %MW0 0.87 0.37 0.58 0.37 0.58 3
%MD0 1.17 0.50 0.75 0.50 0.75 3
+, - %MW0 0.87 0.37 0.58 0.37 0.58 3
%MD0 1.17 0.50 0.75 0.50 0.75 3
%MF0 99.42 71.51 71.76 4.42 4.67 3
* %MW0 10.83 9.14 9.35 4.65 4.86 3
%MD0 55.31 42.71 42.96 15.26 15.51 3
%MF0 87.60 63.61 63.86 4.42 4.67 3
/, REM %MW0 11.93 9.99 10.20 4.94 5.15 3
%MD0 333.15 226.54226.79 49.38 49.63 3
/ %MF0 95.83 68.51 68.76 5.72 5.97 3
ABS, -object %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 1.17 0.54 0.75 0.54 0.75 2
%MF0 18.82 13.01 13.26 3.67 3.92 2
NOT %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 1.17 0.54 0.75 0.54 0.75 2
SQRT %MW0 22.20 16.24 16.45 5.53 5.74 3
%MD0 111.29 89.66 89.91 16.14 16.39 3
%MF0 233.62 173.01173.26 5.10 5.35 3
INC, DEC %MW0 1.17 0.50 0.75 0.50 0.75 2
%MD0 1.75 0.75 1.08 0.75 1.08 2
SHL, SHR, ROL, ROR %MW0 for 1 bit 2.92 1.25 1.96 1.25 1.96 10
%MD0 for 1 bit 3.21 1.37 2.12 1.37 2.12 10
per additional bit 0.042 0.042 0.042 0.042 0.042

LN %MF0 1711 1270 1270 4.53 4.78 3


LOG %MF0 1819 1350 1350 4.53 4.78 3
EXP %MF0 1442 1070 1070 12.03 12.28 3
EXPT %MF0 3412 2624 2775 98.70 98.70 3
TRUNC %MF0 215 165 175 52.40 52.40 3
COS %MF0 3530 2620 2620 4.53 4.78 3
SIN %MF0 3544 2630 2630 4.53 4.78 3
TAN %MF0 3665 2720 2720 4.53 4.78 3
ACOS %MF0 5093 3780 3780 5.33 5.58 3
ASIN %MF0 5093 3780 3780 6.73 6.98 3
ATAN %MF0 3476 2580 2580 4.33 4.58 3
DEG_TO_RAD %MF0 814 626 662 139.90139.90 3
RAD_TO_DEG %MF0 791 608 643 140.20140.20 3
___________________________________________________________________________
8/23
B
8.3.4 Program instructions
ST Objects Conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Jump %Li 2.58 1.25 1.71 1.25 1.71 3


Maskevt 33.98 23.96 23.96 9.59 9.59 1
Unmaskevt 34.54 24.41 24.41 9.77 9.77 1
SRi 3.92 1.75 2.42 1.75 2.42 2
Return 1.00 0.50 0.71 0.50 0.71 2

8.3.5 Command structure


ST Execution time Volume
(µs) (words)
A B/C B/C 57xx
ram cart
<cond> condition evaluation
forceable bit see Boolean instruction LD %M1
comparison see comparisons =,<,> ...
if <cond > then <action> the times and volumes indicated below should
end_if; be added to those of the action contained
in the structure
true condition 0.58 0.25 0.42 2
false condition (jump) 0.71 0.37 0.54
If <cond> then <action1>
<action2> end_if;
true condition 1.29 0.62 0.96 4
false condition 0.71 0.37 0.54
while <cond> do.<action>
end_while
go to loop with loop-back 1.29 0.62 0.96 2

exit loop 0.71 0.37 0.54


<cond> end_repeat
repeat <action> until
go to loop with loop-back 0.71 0.37 0.54 2

last pass 0.58 0.25 0.42


for <word1:=word2>to <word3>
<action> end_for
entry to the for command, 1.75 0.75 1.17 15
execute once only
go to loop with loop-back 5.08 2.12 3.29

exit loop 2.46 1.12 1.71

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/24
Performance 8

B
8.3.6 Numeric conversions
ST Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
BCD_TO_INT 30.33 24.44 24.65 4.75 4.96 3
INT_TO_BCD 24.48 20.19 20.40 4.51 4.72 3 B
GRAY_TO_INT 59.73 40.79 41.00 5.82 6.02 3
INT_TO_REAL 60.35 40.64 40.85 3.25 3.46 3
DINT_TO_REAL 49.14 34.76 35.01 3.67 3.92 3
REAL_TO_INT 91.59 60.86 61.11 3.38 3.63 3
REAL_TO_DINT 68.84 48.31 48.56 3.67 3.92 3
DBCD_TO_DINT 1 625.73 1 069.50 1 192.30 378.40 378.15 5
DBCD_TO_INT 1 379.53 909.63 1 014.07 323.83 323.62 5
DINT_TO_DBCD 1 251.05 819.50 913.55 314.88 314.63 5
INT_TO_DBCD 620.01 439.50 489.85 168.73 168.48 5

8.3.7 Bit string


ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Initializing a bit table


%M30:8 := 0 8 bits 6.71 2.87 4.12 2.87 4.12 7
%M30:16 := 1 16 bits 11.37 4.87 6.79 4.87 6.79 7
%M30:24 := 2 24 bits 24.47 15.31 16.81 15.31 16.81 12
%M30:32 := 2 32 bits 29.13 17.31 19.48 17.31 19.48 12

Copying a bit table to a bit table


%M30:8 := %M20:8 8 bits 13.71 5.87 8.17 5.87 8.17 8
%M30:16 := %M20:16 16 bits 16.62 7.12 9.83 7.12 9.83 8
%M30:24 := %M20:24 24 bits 45.46 24.31 28.85 24.31 28.85 13
%M30:32 := %M20:32 32 bits 57.13 29.31 35.52 29.31 35.52 13
%M30:16 := COPY_BIT(%M20:16) 16 bits 322.00 230.00 256.45 99.20 99.20 17
32 bits 490.00 350.00 390.25 153.20 153.20 17
128 bits 1 526.00 1 090.001 215.35470.20 470.20 17

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/25
B
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Logic instructions on bit tables


AND_ARX, OR_ARX, XOR_ARX
%M0:16 := AND_ARX(%M30:16,%M50:16) 16 bits 434.00 310.00 345.65 136.10 136.10 24
%M0:32 := AND_ARX(%M30:32,%M50:32) 32 686.00 490.00 546.35 213.00 213.00 24
%M0:128 := AND_ARX(%M30:128,%M50:128) 128 2 198.00 1 570.00 1 750.55 674.40 674.40 24
NOT_ARX
%M0:16 := NOT_ARX(%M30:16) 16 bits 322.00 230.00 256.45 99.20 99.20 17
32 490.00 350.00 390.25 153.20 153.20 17
128 1 526.00 1 090.00 1 215.35 470.20 470.20 17

Copying a bit table to a word table


%MW1 := %M30:8 8 bits 8.75 3.75 5.25 3.75 5.25 6
%MW1 := %M30:16 16 bits 15.75 6.75 9.25 6.75 9.25 6
%MD2 := %M30:24 24 bits 23.04 10.54 13.83 10.54 13.83 6
%MD2 := %M30:32 32 bits 30.04 13.54 17.83 13.54 17.83 6
%MW1:2 := BIT_W(%M40:17,0,17,0) 17 bits 518.00 370.00 412.55 150.50 150.50 23
%MD1:2 := BIT_D(%M30:33,0,33,0) 33 bits 728.00 520.00 579.80 200.00 200.00 23

Copying a word or a word table to a bit table


%M30:8 := %MW1 8 bits 6.71 2.87 4.08 2.87 4.08 6
%M30:16 := %MW2 16 bits 11.37 4.87 6.75 4.87 6.75 6
%M30:24 := %MD1 24 bits 24.76 16.11 17.36 16.11 17.36 11
%M30:32 := %MD3 32 bits 29.42 18.11 20.02 18.11 20.02 11
%M30:32 := W_BIT(%MW0:2,0,2,0) 32 bits 518.00 370.00 412.55 142.31 142.31 23
%M30:32 := D_BIT(%MD0:1,0,2,0) 32 bits 616.00 440.00 490.60 169.23 169.23 23

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/26
Performance 8

B
8.3.8 Word, double word and floating point value tables

ST conditions Execution time Volume


(µs) (words)
A B ram B cart C ram C cart 57xx
B
Initializing a word table with a word
%MW0:10 := %MW100 10 words 74.48 50.16 51.12 27.04 28.00 10
per word 0.47 0.25 0.25 0.37 0.37
%MD0:10 := %MD100 10 words 115.45 78.29 79.29 33.59 34.59 10
per word 4.41 2.95 2.95 0.90 0.90

Copying a word table to a word table


%MW0:10:=%MW20:10; 10 words 139.71 93.76 95.26 45.65 47.14 15
per word 0.95 0.50 0.50 0.74 0.74
%MD0:10:=%MD20:10; 10 words 151.18 102.46 103.96 53.75 55.25 15
per word 2.02 1.30 1.30 1.54 1.54

Arithmetical and logic instructions between 2 word tables


+, -
%MW0:10 :=%MW10:10 + %MW20:10; 10 words 236.81 162.54 164.79 71.59 73.84 23
per word 10.05 7.15 7.15 3.07 3.07
%MD0:10:=%MD10:10+%MD20:10; 10 words 325.79 229.79 232.04 104.03 106.28 23
per word 18.41 13.55 13.55 6.12 6.12
*
%MW0:10:=%MW10:10 * %MW20:10; 10 words 246.52 184.99 187.24 76.30 78.55 23
par word 11.03 9.40 9.40 3.55 3.55
%MD0:10:=%MD10:10 * %MD20:10; 10 words 881.77 658.44 660.69 241.22 243.47 23
per word 74.04 56.40 56.40 19.82 19.82
/, REM
%MW0:10:=%MW10:10 / %MW20:10; 10 words 249.44 192.64 194.89 77.99 80.24 23
per word 11.35 10.15 10.15 3.71 3.71
%MD0:10:=%MD10:10 / %MD20:10; 10 words 3 669.10 2 501.99 2 504.24 544.65 546.90 23
per word 352.83 240.75 240.75 50.19 50.19
AND, OR, XOR
%MW0:10:=%MW10:10 AND %MW20:10; 10 words 235.38 160.14 162.39 71.15 73.40 23
per word 9.94 6.90 6.90 3.02 3.02
%MD0:10:=%MD10:10 AND %MD20:10; 10 words 322.35 231.09 233.34 104.96 107.21 23
per word 18.05 13.65 13.65 6.20 6.20

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/27
B
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Arithmetic and logic instructions between 1 word table and 1 word


+, -
%MW0:10 :=%MW10:10 + %MW20; 10 words 170.69 115.14 116.85 48.99 50.70 18
or %MW0:10 := %MW20 + %MW10:10 per word 4.37 2.85 2.85 0.88 0.88
%MD0:10 :=%MD10:10 + %MD20; 10 double words 230.52 156.91 158.66 67.61 69.36 18
per double word 9.92 6.75 6.75 2.62 2.62
*
%MW0:10 :=%MW20*%MW10:10; 10 words 180.13 137.04 138.75 53.64 55.35 18
per word 5.31 5.05 5.05 1.35 1.35
%MD0:10:=%MD20*%MD10:10; 10 double words 747.33 568.16 569.91 205.84 207.59 18
per double word 61.59 47.85 47.85 16.43 16.43
/, REM
%MW0:10 :=%MW10:10 / %MW30; 10 words 212.87 166.39 168.10 65.15 66.86 18
per word 8.48 7.90 7.90 2.42 2.42
%MD0:10:=%MD10:10 / %MD30; 10 double words 3 536.66 2 418.56 2 420.31 509.41 511.16 18
per double word 340.51 232.90 232.90 46.82 46.82
AND, OR, XOR
%MW0:10 :=%MW10:10 AND %MW20; 10 words 170.89 115.59 117.30 49.09 50.79 18
per word 4.39 2.90 2.90 0.89 0.89
%MD0:10:=%MD20*%MD10:10; 10 double words 747.33 568.16 569.91 205.84 207.59 18
per double word 9.81 6.50 6.50 2.57 2.57
NOT
%MW0:10 :=NOT(%MW10:10); 10 words 161.71 109.06 110.56 46.70 48.20 15
per word 4.37 2.85 2.85 0.88 0.88
%MD0:10:=NOT(%MD10:10); 10 double words 184.14 125.51 127.01 55.34 56.84 15
per double word 6.61 4.50 4.50 1.75 1.75

Table summing function


%MW20:=SUM(%MW0:10); 10 words 111.87 76.61 77.57 29.61 30.57 16
per word 3.40 2.40 2.40 0.53 0.53
%MD20:=SUM(%MD0:10); 10 double words 130.74 87.74 88.74 34.03 35.03 16
per double word 4.96 3.30 3.30 0.93 0.93
%MF20:=SUM_ARR(%MF0:10); 10 double word 1905 1270.00 1313.82 303.20 303.20 16
per double word

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/28
Performance 8

B
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Comparison of tables function B


%MW20:=EQUAL(%MW0:10;%MW10:10); 10 words 142.90 99.14 100.85 47.31 49.02 17
per word 1.14 0.95 0.95 0.83 0.83
%MD20:=EQUAL(%MD0:10;%MD10:10); 10 double words 155.56 110.06 111.81 56.02 57.77 17
per double word 2.33 2.00 2.00 1.69 1.69
%MF20:=EQUAL_ARR 10 double words 825 550.00 568.98 137.50 137.50 17
(%MF0:10;%MF10:10); per double word

Find
%MW20 := FIND_EQW(%MW0:10,%KW0) 10 words 374.68 240.00 267.60 97.00 97.00 14
%MD20 := FIND_EQD(%MD0:10, %KD0) 10 double words 394.40 260.00 289.90 100.00 100.00 15
%MF20 := FIND_EQR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MF20 := FIND_EQRP(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MD20 := FIND_GTR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MD20 := FIND_LTR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15

Finding max. and min. values


%MW20 := MAX_ARW(%MW0:10) 10 words 404.26 260.00 289.90 100.00 100.00 12
%MD20 := MAX_ARD(%MD0:10) 10 double words 483.14 310.00 345.65 119.23 119.23 12
%MF20 := MAX_ARR(%MF0:10) 10 double words 1555 1037.001072.78 261.20 261.20 12
%MD20 := MIN_ARR(%MF0:10) 10 double words 1443 962.00 995.19 240.50 240.50 12

Number of occurrences
%MW20:=OCCUR_ARW(%MW0:10,%KW0) 10 words 394.40 260.00 289.90 100.00 100.00 14
%MD20:=OCCUR_ARD(%MD0:10,%KD0) 10 double words 423.98 280.00 312.20 107.69 107.69 15
%MF20 := OCCUR_ARR(%MF0:10, %KF0) 10 double words 1435 957.00 990.02 239.25 293.25 15

Circular shift
ROL_ARW(word or value, %MWj:10) 10 words 621.18 400.00 446.00 153.85 153.85 12
ROL_ARD(%MDi,%MDj:10) 10 double words 670.48 430.00 479.45 165.38 165.38 12
ROL_ARR(%MFi,%MFj:10) 10 double words 654 436.00 451.04 109.00 109.00 12

Sort
SORT_ARW(%MWi,%MWj:10) 10 words 1 133.90 720.00 802.80 276.92 276.92 12
SORT_ARD(%MDi,%MDj:10) 10 double words 700.06 440.00 490.60 169.23 169.23 12
SORT_ARR(%MFi,%MFj:10) 10 double words 2150 1433.00 1482.44 358.25 358.25 12

Length calculation
LENGTH_ARW(tab_word) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARD(tab_dword) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARW(tab_real) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARX(tab_bit) 71.42 50 55.74 19.28 19.28 12

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/29
B
8.3.9 Time management
ST Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Date, time and duration OF


%MW2:4 := ADD_DT(%MW2:4,%MD8) 5 176.50 3 500.00 3 902.50 1203.20 1203.20 19
%MD2 := ADD_TOD(%MD2,%MD8) 2 435.42 1 640.00 1 828.60 630.77 630.77 9
%MB2:11 := DATE_TO_STRING(%MD40) 1 429.70 970.00 1 081.55 373.08 373.08 12
%MW5 := DAY_OF_WEEK() 552.16 390.00 434.85 108.45 108.45 5
%MD10 := DELTA_D(%MD2, %MD4) 1 725.50 1 170.00 1 304.55 450.00 450.00 9
%MD10 := DELTA_DT(%MD2:4,%MW6:4) 3 549.60 2 410.00 2 687.15 926.92 926.92 19
%MD10 := DELTA_TOD(%MD2,%MD4) 2 632.62 1 780.00 1 984.70 684.62 684.62 9
%MB2:20 := DT_TO_STRING(%MW50:4) 2 297.38 1 550.00 1 728.25 596.15 596.15 17
%MW2:4 := SUB_DT(%MW2:4,%MD8) 5 492.02 3 750.00 4 181.25 1203.20 1203.20 19
%MD2 := SUB_TOD(%MD2,%MD8) 2 622.76 1 780.00 1 984.70 684.62 684.62 9
%MB2:15 := TIME_TO_STRING(%MD40) 1 922.70 1 270.00 1 416.05 488.46 488.6 12
%MB2:9 := TOD_TO_STRING(%MD40) 1 281.80 830.00 925.45 319.23 319.23 12
%MD100 := TRANS_TIME(%MD2) 788.80 530.00 590.95 203.85 203.85 7

Access real-time clock


RRTC(%MW0:4) 164.81 111.44 112.19 46.43 47.18 8
WRTC(%MW0:4) 152.94 103.79 104.54 43.47 44.22 8
PTC(%MW0:5) 165.36 111.79 112.54 46.45 47.20 8
SCHEDULE(%MW0,%MW1,%MW2, 1500 1070 1190 411 411 8
%MD10,%MD12,%M0)

8.3.10 Timer function

FTON 80.1 53.40 53.40 35.10 35.10


FTOF 80.1 53.40 53.40 35.10 35.10
FTP 80.1 53.40 53.40 35.10 35.10
FPULSOR 406 290.4 323 112 112

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/30
Performance 8

B
8.3.11 Character strings
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

B
Character string assignment, feedback
%MB0:8:=%MB10:8 8 characters 147.75 103.56 103.56 51.96 51.96 15
per character 1.64 1.25 1.25 1.21 1.21
%MB0:8:=’abcdefg’ 8 characters 193.86 136.88 136.88 56.53 56.53 14
per character 5.94 4.35 4.35 1.69 1.69 0.5

Word <-> character string conversions


%MW1:=STRING_TO_INT(%MB0:7) 145.69 104.31 104.52 37.93 38.14 10
%MB0:7:=INT_TO_STRING(%MW0) 149.67 109.21 109.42 35.52 35.73 10

Double word <-> character string conversions


%MD1:=STRING_TO_DINT(%MB0:13) 1 408.43 1 061.01 1 061.01 364.71 364.71 10
%MB0:13:=DINT_TO_STRING(%MD0) 411.64 317.69 317.94 97.35 97.60 10

Floating point value <-> character string conversions


%MF1:=STRING_TO_REAL(%MB0:15) 2 606.63 1 815.08 1 815.33 635.96 635.96 10
%MB0:15:=REAL_TO_STRING(%MF0) 1 084.46 752.94 753.27 389.47 389.81 10

String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) 1 106.00 790.00 880.85 303.85 303.85 24
%MB10:20 := DELETE(%MB10:22,2,3); 896.00 640.00 713.60 246.15 246.15 21
%MW0 := EQUAL_STR(%MB10:20,%MB30:20); 756.00 540.00 602.10 207.69 207.69 19
%MW0 := FIND(%MB10:20,%MB30:10); 1 456.00 1 040.00 1 159.60 400.00 400.00 19
%MB10:20 := INSERT(%MB30:10,%MB50:10,4); 1 162.00 830.00 925.45 319.23 319.23 26
%MB10:20 := LEFT(%MB30:30,20); 826.00 590.00 657.85 226.92 226.92 19
%MW0 := LEN(%MB10:20); 490.00 350.00 390.25 134.62 134.62 12
%MB10:20 := MID(%MB30:30,20,10); 994.00 710.00 791.65 273.08 273.08 21
%MB10:20 :=
REPLACE(%MB30:20,%MB50:10,10,10); 1 246.00 890.00 992.35 342.31 342.31 28
%MB10:20 := RIGHT(%MB30:30,20); 1 358.00 970.00 1 081.55 373.08 373.08 19

8.3.12 Word extraction

LW 72 51.40 51.40 24.70 24.70


HW 72 51.40 51.40 24.70 24.70
CONCATW 72 51.40 51.40 24.70 24.70

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/31
B
8.3.13 Application-specific functions and Orphee function

ST Conditions Execution time Volume


(µs) (words)
A B ram B cart C ram C cart 57xx

Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10, 2 800 2 000 2 230 33
%MW30:4)
SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 2 100 1 500 1 673 24

Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
GET_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
GET_VALUE(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) 2 800 2 000 2 230 800 32
ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) 2 800 2 000 2 230 800 27
DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25

Process control
PID(“PIDS1”,’Unit’,%IW3.5,%MW12,%M16, deval_mmi=0 1700 1100 1227 32
%MW284:43)
deval_mmi=1 1500 900 1004
PWM(%MW11,%Q2.1,%MW385:5) 700 500 557.5 17
SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3, 1000 800 892 31
%MW284:43,%MW390:10)
PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1400 1000 1115 30

Data archiving
SET_PCMCIA (for 1600 words) 6000 8000 24
WRITE_PCMCIA (for 1600 words) 6000 7000 24
READ_PCMCIA (for 1600 words) 4000 7000 24

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/32
Performance 8

B
ST Conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Orphee function B
DSHL_RBIT(%MD102,16,%MD204,%MD206) read 10 words 493 320 357 123 17
DSHR_RBIT(%MD102,16,%MD204,%MD206) write 10 words 749 510 569 196 17
DSHRZ_C(%MD102,16,%MD204,%MD206) mirror req. 10 words 493 310 346 119 17
WSHL_RBIT(%MW102,8,%MW204,%MW206) exchange 10 words 365 220 245 85 17
WSHR_RBIT(%MW102,8,%MW204,%MW206) 20 bytes 424 290 323 112 17
WSHRZ_C(%MW102,8,%MW204,%MW206) 20 bytes 365 220 245 85 17
SCOUNT(%M100,%MW100,%M101,%M102, 20 bytes 670 420 468 162 38
%MW101,%MW102,%M200,%M201,%MW200,
%MW201)

Diagnostic function block


IO_DIA 111.5 119.5 37.5
ALRM_DIA 110 133 37.5
EV_DIA 129 138 56
MV_DIA 430 117.5 450
ASI_DIA 111.5 119.5 37.5
NEPO_DIA 111.5 119.5 37.5

TEPO_DIA 111.5 119.5 37.5

8.3.14 Explicit I/O

Read_Sts %CHi.MOD
Whatever the application, except for the 997 712 748 316.4 316.4 2
processor communication channel
Read_Sts %CHi
Discrete input 462 330 347 147 147 6
Discrete output 630 450 473 201 201
Analog input 510 380 390 170 170 6
Analog output 500 370 380 165 165
CTY 518 370 389 165 165
CFY 756 540 567 241 241
CAY 532 380 399 170 170
Write_Param %CHi
Analog input 860 620 630 277 277 6
Analog output 810 580 600 259 259
CTY 1 134 810 851 362 362
CFY 1 064 760 798 339 339
CAY 784 560 588 250 250

A TSX5710andPCX5710 B TSX5720/25/30/35,PMX5710andPCX5735 C TSX5740/45andPMX5720/35/45


___________________________________________________________________________
8/33
B
ST Conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx

Read_Param %CHi
Analog input 180 120 130 54 54 6
Analog output 180 120 130 54 54
CTY 532 380 399 170 170
CFY 644 460 483 205 205
CAY 630 450 473 201 201
Save_Param %CHi
Analog input 1 300 880 890 393 393 6
Analog output 1 300 890 900 397 397
CTY 1722 1230 1292 549 549
CFY 700 500 525 223 223
CAY 700 500 525 223 223
Restore_Param %CHi
Analog input 800 570 590 254 254 6
Analog output 800 570 590 254 254
CTY 1148 820 861 366 366
CFY 1092 780 819 348 348
CAY 826 590 620 263 263
Write_Cmd %CHi
Discrete output 448 320 336 143 143 6
Analog input
. input forcing 200 140 150 63 63
. input forcing 1 390 1 020 1 040 455 455
Analog output : output forcing
Discrete output 210 150 150 67 67
Smove %CHi
CFY 1176 840 882 375 375 19
CAY 1148 820 861 366 366

A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/34
Performance 8

B
8.3.15 DFB function block
Size occupied by DFB type

Size of DFB type = Size of DFB variables and parameters + size of DFB code
• Size of DFB variables and parameters =
B
110 + Sum of the variable and parameter descriptors + Sum of the sizes occupied by
each variable or parameter
Descriptor of a variable or a parameter = 5.5 + (Number of characters in the name
of the variable or parameter)/2
Size occupied by each variable or parameter :
Type IN IN/OUT OUT PUBLIC PRIVATE
EBOOL 0.5 2 0.5 0.5 0.5
BOOL 0.5 2 0.5 0.5 0.5
WORD 1 2 1 1 1
DWORD 2 2 2 2 2
REAL 2 2 2 2 2
AR_X 3 3 0.5*N 0.5*N 0.5*N
AR_W 3 3 N N N
AR_D 3 3 2*N 2*N 2*N
AR_R 3 3 2*N 2*N 2*N
STRING 3 3 0.5*N 0.5*N 0.5*N
N = number of elements in the table or length of the character string (STRING)
• Size of DFB code = 11 + Sum of the size of each of the instructions (1)
(1) Add the following volumes to the size of the instructions according to the variable
or parameter contained in the instruction :
Non-indexed object
Description Type Volume
IN EBOOL 0.5
BOOL, WORD, DWORD, REAL 0
AR_X,AR_W,AR_D,AR_R,STRING 3
IN/OUT EBOOL 3
BOOL, WORD, DWORD, REAL 3
AR_X,AR_W,AR_D,AR_R,STRING 3
OUT, PUBLIC EBOOL 0.5
PRIVATE BOOL, WORD, DWORD, REAL 0
AR_X,AR_W,AR_D,AR_R,STRING 0
___________________________________________________________________________
8/35
B
Indexed object
Description Type Volume
IN AR_X,AR_W,AR_D,AR_R, 7
IN/OUT AR_X,AR_W,AR_D,AR_R, 7
OUT, PUBLIC AR_X,AR_W,AR_D,AR_R, 6
PRIVATE

Size occupied by the DFB user

• call a DFB instance with no parameters : 6 words


• calculation for a parameter :

Description Type Volume


IN EBOOL,BOOL,WORD,DWORD,REAL idem := assignment
AR_X,AR_W,AR_D,AR_R,STRING 14
IN/OUT EBOOL,WORD,DWORD,REAL 10
BOOL,AR_X,AR_W,AR_D,AR_R, 14
OUT All types idem := assignment

• using a variable of an instance : add 1 word with respect to %M.

___________________________________________________________________________
8/36
Performance 8

B
Execution time

Total execution time of the DFB = DFB code threshold + Sum of access times to DFB
variables and parameters + DFB call (no parameters) + Sum of access times to each
parameter B
Execution time (µs)
A B ram B cart C ram C cart
Threshold for DFB code 16.24 7.00 8.00 7.00 8.00

Accessing a DFB variable or parameter (1)


Indexed objects

• IN
- EBOOL 0.290 0.125 0.208 0.125 0.208
- BOOL,WORD,DWORD,REAL 0 0 0 0 0
- AR_X,AR_W,AR_D,AR_R,STRING 1.739 0.750 1.282 0.750 1.282
• IN/OUT (all types) 1.739 0.750 1.282 0.750 1.282

• OUT,PUBLIC,PRIVATE
- EBOOL 0.290 0.125 0.208 0.125 0.208
- BOOL,WORD,DWORD,REAL 0 0 0 0 0
- AR_X,AR_W,AR_D,AR_R,STRING 0 0 0 0 0

Non-indexed objects

• IN, IN/OUT
- AR_X,AR_W,AR_D,AR_R, 3.496 1.5 1.472 1.5 1.472
• OUT,PUBLIC,PRIVATE
- AR_X,AR_W,AR_D,AR_R, 2.616 1.125 1.931 1.125 1.931

DFB call (no parameters) 4.770 2.125 3.018 2.125 3.018

Calculation per parameter (1)


• IN
- EBOOL idem :=
- BOOL,WORD,DWORD,REAL idem :=
- AR_X,AR_W,AR_D,AR_R,STRING4.393 2.125 3.269 2.125 3.269
• IN/OUT
- EBOOL,WORD,DWORD,REAL 3.48 1.5 2.318 1.5 2.318
- BOOL,AR_X,AR_W,AR_D,AR_R,STRING 4.393 2.125 3.269 2.125 3.269

• OUT all types idem :=

(1) value to add in relation to operations applying to %M type objects

A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/37
B
8.4 Size of the application
8.4.1 Description of the memory zones

The application is divided into several memory zones :

• bit memory zone :


- this zone is specific to TSX 37 PLCs and is limited to 1280 bits,
- this zone is part of the data memory zone for TSX 57 PLCs,

• data memory zone (words),

• application memory zone, comprising :


- the configuration,
- the program,
- the constants.

The bit and data memory zones are always stored in the internal RAM, the application
memory zone can be stored in the internal RAM or on a memory card.
The memory structure is described in section 1.3. part A.

A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/38
Performance 8

B
8.4.2 Memory size of PL7 objects

Bit memory Data Application


(in words) (in words) (in words)
Grafcet steps (%Xi, %Xi.T) 0.5 1
%Mi 0.5 B
Numeric objects (%MWi) 1
Constants (%KWi) 1.25
%NWi 1
%Ti 4 2
%TMi 5 2
%MNi 4 2
%Ci 3 1
%Ri (length lg) 6+lg 2
%DRi 6 49

Grafcet interpreter data = 355 + 2 x No active steps configured + (No. of valid transitions
configured) / 2

8.4.3 Module memory size


Note
This information is given for a particular processor version. It may be subject to slight
variations as the product develops.

For each module type, the following tables provide the size occupied in each of the zones
as well as a fixed size which should be added to the power consumption table the first time
an application-specific function is used.

Module memory power consumption table, on TSX 37

Processors Bit memory Data Application


(words) (words) zone
(words)
TSX 37-05/08/10 70 1560 920
TSX 37-21 70 1570 930
TSX 37-22 70 2110 1280
Use of FAST task (TSX 37) 260
Use of first event (TSX 37) 520

___________________________________________________________________________
8/39
B
Discrete family Bit memory Data Application
(words) (words) zone
(words)
8 discrete inputs 4 12 40
16 discrete inputs 8 12 50
4 discrete outputs 2 12 40
8 discrete outputs 4 12 40
8 discrete inputs/8 discrete outputs 4 12 40
16 discrete inputs/12 discrete outputs 16 20 100
32 discrete inputs/32 discrete outputs 32 20 142

4 ANA input family Bit memory Data Application


(words) (words) zone
(words)
AEZ414 0 156 56
Additional amount of 1st module in 120
4 ANA input family
8 ANA input family Bit memory Data Application
(words) (words) zone
(words)
AEZ801/AEZ802 0 212 72
Additional amount of 1st module in 120
8 ANA input family
ANA output family Bit memory Data Application
(words) (words) zone
(words)
ASZ200 0 52 40
ASZ401 0 100 59
Additional amount of 1st module in 120
ANA output family
Counter family Bit memory Data Application
(words) (words) zone
(words)
CTY1A 16 108 64
CTY2A 32 212 106
Add. amount of 1st Upcounter channel 144
Add. amount of 1st Downcounter channel 144
Additional amount of 1st Up/Down 144
counter channel

Communication family Bit memory Data Application


(words) (words) zone (words)
STZ010 0 36 168
SCP111/ SCP112/ SCP114 0 40 763
on UTW CPU)
FPP 20 on CPU (Channel 0 UTW) 0 40 755
MDM 10 0 2528 12880
___________________________________________________________________________
8/40
Performance 8

B
Module memory power consumption table, on TSX/PCX/PMX 57
Processors Bit memory Data Application
(words) (words) zone
(words)
TSX/PCX/PMX 57-10 70 4714 1720
TSX 57-20/25/30/35/40/45 70 4714 1784 B
PCX 57-10/35
PMX 57-10/20/35/45
Use of FAST task (TSX 57) 520
Add. amount of 1st module in config. 600

PMX processors : control loop Bit memory Data Application


(words) (words) zone
(words)
PMX 57-10 : per loop 500
Add. amount of 1st loop 25000
PMX 57-20/35/45 : per loop 500
Add. amount of 1st loop 5000

Single discrete input family Bit memory Data Application


(words) (words) zone (words)
8 discrete inputs 4 100 100
16 discrete inputs 8 130 110
32 discrete inputs 16 230 120
64 discrete inputs 32 430 190
Add. amount of 1st single discrete 610
input family module

Single discrete output family Bit memory Data Application


(words) (words) zone(words)
8 discrete outputs 4 110 100
16 discrete outputs 8 160 110
32 discrete outputs 16 280 120
64 discrete outputs 32 550 190
Add. amount of 1st single discrete 570
output family module

Event-triggered discrete input Bit memory Data Application


family (words) (words) zone (words)
16 discrete inputs (DEY 16FK) 8 220 130
Add. amount of 1st EVT discrete input 680
family module

Emergency stop input/output Bit memory Data Application


family (PAY) (words) (words) zone (words)
12 discrete inputs/4 discrete outputs 16 128 200
or 12 discrete inputs/2discrete outputs
Add. amount of 1st discrete input/ 680
output family module
___________________________________________________________________________
8/41
B
Mixed discrete I/O family Bit memory Data Application
(words) (words) zone
(words)
16 inputs/12 outputs (DMY 28FK) 16 304 152
Add. amount of 1st mixed discrete 1432
family module
16 in/12 out reflex(DMY 28RFK) 32 976 656
Add. amount of 1st mixed discrete 5596
family module

Analog input family Bit memory Data Application


(words) (words) zone
(words)
AEY414 4 430 160
AEY800 8 840 240
AEY1600 16 1670 430
Add. amount of 1st analog input family 2990
module (AEY 414/800/1600)
AEY810 8 888 248
AEY1614 16 1768 432
Add. amount of 1st analog input family 3056
module (AEY 810/1614)
AEY420 4 476 168
Add. amount of 1st analog input family 2080
module (AEY 810/1614)

Analog output family Bit memory Data Application


(words) (words) zone
(words)
ASY410 4 430 160
Add. amount of 1st analog output 1700
family module ASY410
ASY800 8 744 248
Add. amount of 1st analog output 1760
family module ASY800

Counter family Bit memory Data Application


(words) (words) zone
(words)
CTY2A module 32 410 170
CTY4A module 64 800 250
Add. amount of 1st configured counter 1740
channel
CTY2C module 48 672 184
Add. amount of 1st configured counter 1992
channel

___________________________________________________________________________
8/42
Performance 8

B
Servo-Motor family Bit memory Data Application
(words) (words) zone
(words)
CAY•1 78 1050 280
CAY•2 78 376 232
B
CAY33 3rd channel 78 264 170
Add. amount of 1st channel 2130
configured CAY •1
Add. amount of 1st channel 3600
configured CAY •2
Add. amount of 1st channel 3 3600
configured CAY33

Stepper motor family Bit memory Data Application


(words) (words) zone
(words)
CFY11 29 323 104
CFY21 58 646 152
Add. amount of 1st configured 2368
stepper motor channel

Communication module family Bit memory Data Application


(words) (words) zone (words)
SCY21600 (Channel 0 UTW) 1 230 80
SCP111/ SCP112 / SCP114 (UTW) 1 450 40
on SCY21600 (Channel 1 UTW)
Add. amount of 1st channel configured 1280
as UTW
ETY 110 1 431 256
Add. amount of 1st ETY 110 chan. config. 1984
ETY 120 1 48 136
Add. amount of 1st ETY 120 chan. config. 1368
ETY 210 1 434 400
Add. amount of 1st ETY 210 chan. config. 3424
IBY 100 1 450 40

CPU communication sub-module Bit memory Data Application


family (words) (words) zone (words)
SCP111/ SCP112/ SCP114 (UTW) 1 60 580
on CPU (Channel 0 UTW)
FPP 20 on CPU (Channel 0 UTW) 1 60 580
FPP 10 on CPU (Channel 0 UTW) 1 40 870

ASI module family Bit memory Data Application


(words) (words) zone (words)
SAY 3 373 176
Add. amount of 1st configured ASi 2272
channel
___________________________________________________________________________
8/43
B
Weighing family Bit memory Data Application
(words) (words) zone
(words)
AWY001 1 170 120
Add. amount of 1st weighing channel 3920
configured

TBX family Bit memory Data Application


(words) (words) zone
(words)
Discrete inputs 8 152 88
Additional amount of 1st configured 1400
sub-base
Discrete outputs 8 176 88
Additional amount of 1st configured 1320
sub-base
Programmable 8 160 88
Additional amount of 1st configured 2304
sub-base
Latching 8 160 88
Additional amount of 1st configured 1400
sub-base
AES 400 2 270 104
ASS 200 2 270 104
AMS 620 4 508 112
Additional amount of 1st configured 3968
sub-base

Momentum family Bit memory Data Application


(words) (words) zone
(words)
Inputs 16 96 72
Additional amount of 1st configured 1384
sub-base
Output 16 112 72
Additional amount of 1st configured 1256
sub-base
Mixed 16 104 72
Additional amount of 1st configured 1424
sub-base

Bus X remote family Bit memory Data Application


(words) (words) zone
(words)
TSX REY 200 module 0 0 56
___________________________________________________________________________
8/44
Performance 8

B
8.4.4 Memory size of advanced functions
The following tables show for each advanced function (OF), the size of the code embedded
in the application (application zone) when an advanced function is called.
The functions in the same family share the code (common code). This common code is
embedded in the PLC on the first call of a function for that family. The code specific to a
function is embedded on the first call for that function. B
Example :
• First call of a function of the Numeric conversions family, ie DBCD_TO_DINT
Code embedded in the application zone :
- Common code = 154 words
- OF code DBCD_TO_INT = 149 words
• Call of another function of the Numeric conversions family, ie DINT_TO_DBCD
Code engaged in the application zone :
- OF code DINT_TO_DBCD = 203 words
Call of a function of the Numeric conversions family which has already been called
(DBCD_TO_DINT or DINT_TO_DBCD) : no code embedded

Numeric conversions OF code size


(in words)
Conversion of a 32-bit BCD number to a 32-bit integer DBCD_TO_DINT 145
Conversion of a 32-bit BCD number to a 16-bit integer DBCD_TO_INT 149
Conversion of a 32-bit integer to a 32-bit BCD number DINT_TO_DBCD 203
Conversion of a 16-bit integer to a 32-bit BCD number INT_TO_DBCD 75
Extract low order word from a double word LW 33
Extract high order word from a double word HW 33
Form a double word from 2 words CONCATW 33
common code 154

___________________________________________________________________________
8/45
B
Bit strings OF code size
(in words)
Logic AND between two tables AND_ARX 209
Copy of a bit table to a double word table BIT_D 248
Copy of a bit table to a word table BIT_W 205
Copy of a bit table to a bit table COPY_BIT 146
Copy of a double word table to a bit table D_BIT 196
One’s complement in a table NOT_ARX 157
Logic OR between two tables OR_ARX 209
Copy a word table to a bit table W_BIT 195
Exclusive OR between two tables XOR_ARX 209
Length in number of elements LENGTH_ARX 20
common code 427

Word table instructions OF code size


(in words)
Find 1st element in a table equal to a value FIND_EQW 75
Find 1st element in a table greater than a value FIND_GTW 75
Find 1st element in a table less than a value FIND_LTW 78
Find the maximum value in a table MAX_ARW 78
Find the minimum value in a table MIN_ARW 74
Number of occurrences of a value in a table OCCUR_ARW 145
Circular shift left in a table ROL_ARW 150
Circular shift right in a table ROR_ARW 144
Sort a table (ascending or descending order) SORT_ARW 164
Partial search in a table for 1st element equal to a value FIND_EQWP 77
Length in number of elements LENGTH_ARW 20
common code 162

___________________________________________________________________________
8/46
Performance 8

Double word table instructions OF code size


(in words)
Find 1st element in a table equal to a value FIND_EQD 79
Find 1st element in a table greater than a value FIND_GTD 80 B
Find 1st element in a table less than a value FIND_LTD 95
Find the maximum value in a table MAX_ARD 95
Find the minimum value in a table MIN_ARD 78
Number of occurrences of a value in a table OCCUR_ARD 163
Circular shift left in a table ROL_ARD 170
Circular shift right in a table ROR_ARD 178
Sort a table (ascending or descending order) SORT_ARD
Partial search in a table for 1st element equal to a value FIND_EQWP 77
Length in number of elements LENGTH_ARW 20
common code 162

Floating point word table instructions OF code size


(in words)
Sum of elements in a real table SUM_ARR 152
Find 1st element in a table equal to a value FIND_EQR 134
Find 1st element in a table equal to a value FIND_EQRP 135
from a row
Find 1st element in a table greater than a value FIND_GTR 134
Find 1st element in a table less than a value FIND_LTR 134
Find the maximum value in a table MAX_ARR 161
Find the minimum value in a table MIN_ARR 162
Number of occurrences of a value in a table OCCUR_ARR 132
Circular shift left in a table ROL_ARR 167
Circular shift right in a table ROR_ARR 173
Sort a table (ascending or descending order) SORT_ARR 271
Comparison of two real tables EQUAL_ARR 173
Length in number of elements LENGTH_ARR 20
common code 124

___________________________________________________________________________
8/47
B
Date, time and time periods OF code size
(words)
Add a duration to a complete date ADD_DT 519
Add a duration to a time of day ADD_TOD 188
Convert a date to a string DATE_TO_STRING 150
Day of the week DAY_OF_WEEK 99
Difference between two dates DELTA_D 374
Difference between two complete dates DELTA_DT 547
Difference between two times of day DELTA_TOD 110
Convert a complete date to a string DT_TO_STRING 266
Remove a duration from a complete date SUB_DT 548
Remove a duration from a time of day SUB_TOD 186
Convert a duration to a string TIME_TO_STRING 413
Convert a time of day to a string TOD_TO_STRING 156
Format a duration as hours-minutes-seconds TRANS_TIME 211
Realtime clock function SCHEDULE 700
common code 1703

Character string instructions OF code size


(words)
Concatenation of two strings CONCAT 224
Delete a substring DELETE 279
Find first different character EQUAL_STR 212
Find a substring FIND 225
Insert a substring INSERT 287
Extract from the left part of the string LEFT 38
Length of a string LEN 70
Extract a substring MID 44
Replace a substring REPLACE 365
Extract from the right part of the string RIGHT 55
common code 418

Orphee Functions OF code size


(words)
Shift to left on 32 with retrieval of shifted bits DSHL_RBIT 152
Shift to right on 32 with sign extension, retrieval of shifted DSHR_RBIT 152
bits
Shift to right on 32 with filling of spaces by 0, retrieval of DSHRZ_C 133
shifted bits
Shift to left on 16 with retrieval of shifted bits WSHL_RBIT 91
Shift to right on 16 with sign extension, retrieval of shifted WSHR_RBIT 103
bits
Shift to right on 16 with filling of spaces by 0, retrieval of WSHRZ_C 90
shifted bits
common code 173
Up/down counting with indication of an under/overflow SCOUNT 617
Rotate one word to the left ROLW 41
Rotate one word to the right RORW 41
Rotate one double word to the left ROLD 49
Rotate one double word to the right RORD 49
___________________________________________________________________________
8/48
Performance 8

B
Time-delay functions OF code size
(in words)
Pulse output FPULSOR 215
Off-delay FTOF 272 B
On-delay FTON 217
Pulse time-delay FTP 245

Logarithm, exponential and OF code size


trigonometrical functions (in words)
Natural logarithm LN 0
Decimal logarithm LOG 0
Exponential EXP 0
Exponentiation of a real by an integer EXPT 523
Part of integer TRUNC 128
Cosine of an angle in radians COS 0
Sine of an angle in radians SIN 0
Tangent of an angle in radians TAN 0
Arc cosine (result between 0 and pi) ACOS 0
Arc sine (result between -pi/2 and pi/2) ASIN 0
Arc tangent (result between -pi/2 and pi/2) ATAN 0
Convert degrees to radiansDEG_TO_RAD 257
Convert radians to degrees RAD_TO_DEG 247
common code 392

Application-specific functions

Process control functions OF code size


(in words)
Mixed PID controller PID 1800
Pulse width modulation of a numeric value PWM 600
PID output stage for control of discrete valve SERVO 1200
Management of CCX17 dedicated MMI function for PID_MMI 4400
controlling PID loops
common code 573

___________________________________________________________________________
8/49
B
Man-Machine Interface functions OF code size
(in words)
Blocking entry of a variable on CCX17 ASK_MSG, 46.5
Blocking entry of a variable on message contained in ASK_VALUE, 46.5
CCX17
Dynamic assignment of keys ASSIGN_KEYS, 46.5
LED control command CONTROL_LEDS, 46.5
Display an alarm contained in CCX17 DISPLAY_ALARM, 46.5
Display a group of messages contained in CCX17 DISPLAY_GRP, 46.5
Display a message contained in CCX17 DISPLAY_MSG, 46.5
Multiple entry of a variable on CCX17 GET_MSG, 46.5
Multiple entry of a variable on message contained in GET_VALUE, 46.5
CCX17
Send a command to CCX17 PANEL_CMD, 46.5
Display an alarm message contained in the PLC SEND_ALARM, 46.5
memory
Display a message contained in the PLC memory SEND_MSG 46.5
common code 573

Communication functions OF code size


(in words)
Read base language objects READ_VAR 617
Write base language objects WRITE_VAR 500
Send/receive UNI-TE requests SEND_REQ 438
Send and/or receive data DATA_EXCH 375
Send a character string PRINT_CHAR 476
Request read of a character string INPUT_CHAR 625
Send and/or receive a character string OUT_IN_CHAR 531
Send a telegram SEND_TLG 219
Receive a telegram RCV_TLG 172
Request to stop a communication function in progress CANCEL 133
common code 506
Shift 1 byte to the right in a byte table ROR1_ARB 235

Movement control functions OF code size


(in words)
1 axis automatic movement control SMOVE 0

Data archiving(1) OF code size


(in words)
Initialize archiving zone on PCMCIA card SET_PCMCIA 24
Write data to PCMCIA card WRITE_PCMCIA 24
Read data from PCMCIA card READ_PCMCIA 24
common code 288
(1) specific OF, the code is included in the volume of the I/O module.

___________________________________________________________________________
8/50
Performance 8

B
Explicit exchange functions (1) OF code size
(in words)
Read status parameters READ_STS 0
Read adjustment parameters READ_PARAM 0
Update adjustment parameters WRITE_PARAM 0 B
Save adjustment parameters SAVE_PARAM 0
Restore adjustment parameters RESTORE_PARAM 0
Update command parameters WRITE_CMD 0
(1) Specific OF, the code is included in the volume of the I/O module.

Diagnostic DFB
The following table indicates the code size built into the application (in program zone) for
each type of diagnostic DFB and the size taken up in each case in the data zone and
the program zone.

The first time a diagnostic DFB is programmed, 200 words are reserved in the application
program zone.

Diagnostic DFB Size of Code size Data size


(size in words) DFB type per instance per instance
IO_DIA 800 64 72
ALRM_DIA 608 40 48
NEPO_DIA 15184 128 136
TEPO_DIA 10896 128 136
EV_DIA 1144 48 56
MV_DIA 2616 80 88
ASI_DIA 7912 304 312

___________________________________________________________________________
8/51
B
8.5 Appendix : method of calculating the number of instructions

This method is used to calculate the number of basic Boolean or numerical instructions
(assembler code).

Note : this is the method which was used to calculate the performance information given
in section 1.3 part A.

Calculating the number of Boolean instructions


The number of each of the following elements is taken into account :
• Boolean operations : load (LD), AND, OR, XOR,ST, etc
• closing parentheses (or ladder convergences : vertical convergence links)
• comparison (AND[...], OR[...], etc) and operate ([...]) blocks

Do not count the NOT, RE and FE operators as Boolean instructions.

Example :
LD %M0
AND( %M1
OR %M2
)
ST %M3
= 5 Boolean instructions

Calculating the number of numerical instructions


The number of each of the following elements is taken into account :
• assignments (:=)
• loading of first value after :=
• arithmetic instructions (+, -, *, /, <, =, etc), operations on words or word tables, double
words, floating point values
• logic instructions on words
• (OF, EQUAL, etc) functions regardless of the number of parameters
• function blocks (or function block instruction)

Example : %MW0:=(%MW1+%MW2)*%MW3;
instructions counted :
:=
%MW1 (corresponds to the load instruction in the accumulator)
+
*
ie. 4 instructions.

___________________________________________________________________________
8/52
Performance 8

B
Example of application which is 65% Boolean and 35% numerical :

___________________________________________________________________________
8/53
B

___________________________________________________________________________
8/54
Performance 8

___________________________________________________________________________
8/55
B

(1):%MW0:=%MW1+%MW2+%MW3+%MW4+%MW5+%MW6+%MW7+%MW8+%MW9+%MW10+1

Result
Number of
instructions %
Boolean without edge 187 54.05% 64.16%
Boolean with edge 4 1.16%
Operation block 31 8.96%
Function block 3 0.87% 35.84%
Single arithmetic (+,-,:=,AND,...) 111 32.08%
Indexed arithmetic 4 1.16%
*,/ 6 1.73%
Immediate values 24
Total number 346 100.00%

___________________________________________________________________________
8/56
Section
OLE Automation Server 99
9 OLE Automation Server
B
9.1 Presentation

9.1-1 Warning
Knowledge of one of the following languages is required when creating a client
application for the OLE server for OLE Automation programming :
• Microsoft Visual Basic, version 5.0 or later
• Microsoft Visual C++, version 4.2 or later
• Microsoft VBA in Excel, version 5.0 or later

___________________________________________________________________________
9/1
B
9.1-2 Introduction
The OLE Automation Server PL7 function provides the possibility of "controlling" the
execution of a PL7 in a programmed manner, which is not interactive (without
intervention by the operator), for applications external to PL7. The client application
terminology of the PL7 OLE Automation server is used.

PLC

Client Server

Automation
Client
Automation

OLE
Applications PL7
OLE

*.STX

Completely in line with the standard defined by Microsoft, in its OLE offer designed to
meet this requirement, PL7 now has a standard interface which is public, distributed,
separate and independent of the programming language of the client application.
The main characteristics are as follows :
• automation of repetitive tasks,
• delegation to PL7 of processing which can only be executed by PL7,
• access to information about the applications contained in the *.STX files,
• more generally, the development of functions of a higher level than PL7, of the
integrator type, whilst encapsulating the implementation details which are specific
to PL7.

___________________________________________________________________________
9/2
OLE Automation Server 9

B
9.1-3 Execution context

The PL7 OLE Automation server function is integrated in PL7 Pro. It is installed and
executed under the same installation and execution conditions as PL7.
The PL7 OLE Automation server is based on Microsoft OLE Automation run-time
provided with Windows 95, 98 and NT.

9.1-4 Operating modes


In addition to the PL7 operating mode known to date, which is referred to as "interactive"
and in which the PL7 responds exclusively to operator entries, there is now the OLE
Automation server operating mode in which PL7 also responds to commands sent by
an OLE client application.

The choice of operating mode depends on the PL7 start procedure. Interactive mode
is initialized when PL7 is started via Windows (Start/Programs/Modicon Telemecanique/
PL7 Pro menu).
Server mode is chosen if the PL7 OLE Automation server is called in the programming
of an OLE client application. An instance cannot change mode while it is in progress.

Each time a client application calls the PL7 OLE Automation server, a specific instance
of PL7 is started, independently of other instances which may already have been
started. Any number of PL7 instances in server or interactive mode may be executed
on the same station. The instances are completely independent of one another, and
each can be executed in its own context.

For all these instances, the same exclusion rules regarding concurrent access to an
STX application or a PLC apply, namely : an STX application or a PLC may only be
manipulated by one instance at a time.

This rule has been adapted for the PL7 OLE Automation server, which may open an
STX application which is already open but which cannot be saved. Likewise, in
response to an explicit request, it can carry out a PLC —> PC transfer from a PLC
reserved elsewhere.
A client application may instantiate several "PL7 OLE Automation servers" at the same
time.

___________________________________________________________________________
9/3
B
9.2 Implementation
9.2-1 Installation
The installation of the PL7 OLE Automation Server product is transparent for the user,
and is performed implicitly during the installation of PL7.
The installation comprises :

1. Four examples of OLE Automation client, complete with source code, and a README
file are provided in the software.
These examples correspond to :
• a "minimum" Visual C++ 4.2 client : the minimum required in order to write an OLE
client,
• a "complete" Visual C++ 4.2 client which uses all the available input points,
• a Visual Basic 5.0 client which uses all the available input points,
• an Excel client.
2. An *.h file which defines the value of the error codes returned by the server.
3. A TLB interface file for a Visual C++ client.

9.2-2 Starting the server in offline mode (COM mode)


COM mode (Component Object Model) defines an interface for communication
between applications. It provides independence in relation to the development tools.
To communicate with the server application, the client application declares an “A”
object.
It is then sufficient to execute the Createdispatch function on the “A” object of the client
application in order to instantiate the server application.

The server is located transparently for the client application in the Createdispatch by
interrogating the register base.

The link between the client application and the server application is created if the latter
is referenced in the register base. In order to ensure that the PL7 Pro application
operates correctly in server mode, when installing the product it is necessary to save
it as an OLE server in the register base.

The client application is now able to interrogate the server application via the interface
accessible from the “A” object.
Example :
A.OpenStx(“C:\appli.stx”)

___________________________________________________________________________
9/4
OLE Automation Server 9

B
9.2-3 Starting the server in remote mode (DCOM)

The PL7 server is executed according to the information present in the register base.
It can be located on the client machine or on a remote machine.

DCOM mode is in fact an extension of COM mode (Component Object Model). COM
mode is used for communication between a client application and a server application
on the same machine.
DCOM mode is used for communication between two remote machines. It replaces
inter-process communication protocols with network protocols.

COM COM
Client Component
run-time run-time

Security DCE RPC Security DCE RPC


provider provider

Protocol stack Protocol stack

DCOM network
protocol

To establish communication between two machines, we use a configuration utility


known as “DCOMCNFG.EXE”.
By default, the “DCOMCNFG.EXE” utility is not present under Windows 95. The user
must connect to the internet at address “http://www.microsoft.com/com/dcom95/relnotes-
f.htm” and download this utility in order for the server to operate in DCOM under
Windows 95.

___________________________________________________________________________
9/5
B
9.2-4 Setting up the server for remote mode
Example of use :
A machine A (Windows NT 4) installed with PL7 Pro server.
The user of the machines must connect under an “administrator” account in order to
manage the access rights.
The client is machine B (Windows 95).
Procedure :
On machine B, start DCOMCNFG.EXE :
• Select the "Default Properties" tab in order to display the following information :
[X] «Enable Distributed COM on this computer
Default Authentication Level: CONNECT
Default Impersonation Level: Identify
• On the "Default Security" tab, check the option :
[X] Enable remote connection

• On the "Application" tab :


Select the PL7 Pro server “PL7 server”, then “Properties”.
On the new screen, define its network location.

On machine A, start DCOMCNFG :


• Select the "Default Properties" tab in order to display the following information :
[X] «Enable Distributed COM on this computer
Default Authentication Level: CONNECT
Default Impersonation Level: Identify

"Client" machine B can control "PL7 Pro Server" located on machine A.


Select the "Default Security" tab, and add the users who will have write privileges on
the machine.

Note :
For more information :
There is a newsgroup where it is possible to ask questions about DCOM :
“http://www.microsoft.com/support/news/win32.htm”

___________________________________________________________________________
9/6
OLE Automation Server 9

B
9.3 PL7 server execution modes

The PL7 OLE Automation Server has two execution modes, which can be selected
dynamically during execution (see SetIHMServer ) :

• Execution mode without HMI. The PL7 is started as a “background task”, with no
display or possibility of operator entry. This mode is typically used, for example,
to automate repetitive tasks or to access data about an application contained in
an stx file.

• Execution mode with HMI. PL7 is started as an "interactive" PL7 with display and the
possibility of operator entry, but it remains receptive to commands sent by its client
application. This mode has been developed in order to display program or configu-
ration elements of an application contained in an stx file, from external tools such as
DIAG Viewer.

Notes :
Services regarding the display of programs, tools or modules can only be executed in the mode
with HMI.
In its mode with HMI, the PL7 OLE Automation Server is subject to user rights checks. It is
positioned in the “Read Only” user rights profile, which corresponds to its role of displaying PL7
I/O code and modules.
In its mode without HMI, the PL7 OLE Automation Server is not subject to user rights checks,
but the services offered do not allow the application to be modified.

___________________________________________________________________________
9/7
B
9.4 Input points : OLE function
The input points are organized into four types :
• Execution context

Name Description
OpenStx Opens an application
SaveStx Saves the active application
CloseStx Closes the active application
SetDriverAndAddress Modifies the address and driver of the PLC being accessed
SetServerIHM Makes the PL7 OLE Automation Server interactive or not
GetPL7State Gives the status : application open or closed, offline/online mode,
PLC status
GetMessageError Reads the error message associated with the error code

• PLC control :

Name Description
ConnectPLC Enters online mode
DisconnectPLC Exits online mode
SendCommandToPLC Sends a command to the PLC (RUN, STOP, INIT)
DownloadToPLC Downloads the active application to a PLC
UploadFromPLC Copies a PLC application to the active application

• Data reading :

Name Description
ExportScyFile Exports symbols to the active application in the form of an scy file
ExportFefFile Exports the active application in the form of an fef type file
GetSymbol Reads the symbol and comment associated with an address
GetSTXAppIdentity Reads the general information about an application contained in
an STX file
GetPLCAppIdentity Reads the general information about an application contained in a PLC
GetServerVersion Reads the server version

___________________________________________________________________________
9/8
OLE Automation Server 9

B
• Displaying an application element

Name Description
SetPosPL7Window Modifies the PL7 display characteristics (position and form)
ShowProgram Opens an editor on a given program module
CloseProgram Closes a program editor
ShowIOModule Opens an editor on a given I/O module
CloseIOModule Closes an I/O module editor
ShowDFB Opens an editor on the code of a given DFB
CloseDFB Closes an editor on the code of a DFB
OpenTool Opens any MDI tool without context

Note:
The input points relating to the display of application elements do not function if the server is in the
mode without HMI.

___________________________________________________________________________
9/9
B
9.5 Description of OLE functions
9.5-1 OpenStx
This function is used to open an stx application file.
Syntax : integer OpenStx(String lpAppPathName).
• Input :
Enter the character string containing the name of the file the user wishes to open.
• Function called :
OpenStation : Station management function (gesta.dll).
• Nominal context
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_FILENOTFOUND : The file has not been found.
SRV_ERR_OPEN_BADZIP : File decompression problem.
SRV_ERR_OPEN_BADFILE : Problem reading the stx file
SRV_ERR_OPEN_NOK_COMPATIBLE : The processor is not compatible
with the open PL7.
SRV_ERR_OPEN_OPEN : An application is already open.
SRV_ERR_GEN_PARAM_EMPTY : The path name is empty.
SRV_ERR_GEN_ACTION : Error opening the application.
SRV_ERR_GEN_DRIVE FULL : No more free space on the disk
for opening the application.
• Output :
Short type return code. Either 0 if the application has been opened successfully, or
an error code.

9.5-2 CloseStx
This function is used to close the current application.
Syntax : integer CloseStx(integer p_bWithoutSave).
• Input :
If the application has been modified, it is possible to close it without warning the user
(p_bWithoutSave a TRUE)
• Function called :
CloseStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active, an application is open.

___________________________________________________________________________
9/10
OLE Automation Server 9

B
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_CLOSE_NOTSAVE: The application has been modified, it must be
saved in order to exit.
• Output :
Short type return code. Either 0 if the application has been closed successfully, or
an error code.

9.5-3 ExportScyFile
This function is used to export the symbols contained in the active application in the
form of an scy file.
Syntax : integer ExportScyFile(String p_psScyFile)
• Input:
Enter the character string containing the name of the scy file.
• Function called :
ExportScyFile : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the creation of the symbol
source file.
SRV_ERR_GEN_NOTOPEN: No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_ psScyFile is empty
SRV_EXPORT_ERRFILE Error writing the source file.
• Output :
Short type return code. Either 0 in the case of a successful export, or an error code.

___________________________________________________________________________
9/11
B
9.5-4 ExportFefFile
This function is used to export the active application in the form of an fef file.
Syntax : integer ExportFefFile(String p_psNamefile)
• Input :
Enter the character string containing the name of the fef file.
• Function called :
ExportFefFile : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the creation of the application
source file.
SRV_ERR_GEN_NOTOPEN: No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_psNamefile is empty.
SRV_EXPORT_ERRFILE Error writing the source file.

• Output :
Short type return code. Either 0 in the case of a successful export, or an error code.

9.5-5 DisconnectPLC

This function is used for disconnecting the PLC and PL7.


Syntax : integer DisconnectPLC ()

• Function called :
DisconnectStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• Output :
Short type return code. Either 0 in the case of a successful disconnection, or an error
code (SRV_ERR_GEN_ACTION).

___________________________________________________________________________
9/12
OLE Automation Server 9

B
9.5-6 ConnectPLC
This function is used for connecting to a PLC.
Syntax : integer ConnectPLC(String p_lpDriver, String p_lpAddress)
• Input :
Enter two character strings containing the driver and address of the PLC.
• Function called :
ConnectStation : Station management function (gesta.dll).
• Nominal context
The PL7 server is active.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.
• In the event of an error :
SRV_ERR_GEN_CONNECT : Connection was not possible.
SRV_ERR_GEN_COMMUNICATION : Communication problem between PL7 Pro
and the PLC.
SRV_ERR_GEN_RESERVED : The PLC is reserved; it is therefore
impossible to connect to it.
SRV_ERR_PLC_BLANK : The PLC does not contain an application;
connection is therefore impossible.
SRV_ERR_PC_BLANK : No application is open; connection
is therefore impossible.
SRV_ERR_DIFFERENCE_PLC_STX : The open application and the application
contained in the PLC are different;
connection is therefore impossible.
SRV_ERR_GEN_ADDRESS : The address parameter is incorrect.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_GEN_DRIVER: The driver parameter is incorrect.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PROTECTEDAPPLI : Protected application.
SRV_COMPATIBLE_PLC : Compatibility problem with the PLC.

• Output
Short type return code. Either 0 in the case of successful connection, or an error code.

___________________________________________________________________________
9/13
B
9.5-7 SaveStx
This function is used to save the open application.
Syntax : integer SaveStx(String p_lpStxFile)
• Input :
Enter a character string containing the path and name of the backup file.
• Function called :
SaveStx : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open, PL7 is in offline mode.
• In the event of an error :
SRV_ERR_SAVEDENIED : Access to file refused.
SRV_ERR_SAVEERRZIP : Error when compressing the application.
SRV_ERR_SAVEERRREN : Renaming refused.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_ lpStxFile is empty.
SRV_ERR_GEN_ACTION : Error saving the application.
SRV_ERR_PLC_CONNECT : Saving can only be carried out in
offline mode.
• Output :
Short type return code. Either 0 if the application has been saved successfully, or an
error code.

9.5-8 DownloadToPLC
This function is used to download an application to the PLC memory.
Syntax : integer DownloadToPLC(String p_lpDriver, String p_lpAdresse)
• Input :
Enter two character strings containing the driver and address of the PLC.
• Function called :
DownloadStation: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open, PL7 is in offline mode.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.

___________________________________________________________________________
9/14
OLE Automation Server 9

B
• In the event of an error :
SRV_ERR_DOWNLOAD_CART : Memory card compatibility problem
between the open application and the PLC.
SRV_ERR_COMPATIBLE_PLC : Compatibility problem between the open
application and the PLC.
SRV_ERR_GEN_ADDRESS : The p_lpAdresse parameter is incorrect.
SRV_ERR_GEN_DRIVER : The p_lpDriver parameter is incorrect.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_RESERVED : The PLC is reserved.
SRV_ERR_GEN_COMMUNICATION : Communication problem.
SRV_ERR_PLC_CONNECT : The PLC is already connected.
SRV_ERR_PLC_ACTION : Download error.

• Output
Short type return code. Either 0 in the case of a successful download, or an error code.

9.5-9 UploadfromPLC
This function is used to copy an application contained in a PLC to the memory.
Syntax : integer UploadFromPLC(String p_lpDriver, String p_lpAdresse, integer
p_iReservedMode)
• Input :
Enter two character strings containing the driver and address of the PLC.
An integer (p_iReservedMode) making it possible to carry out an Upload on a
reserved PLC.
• Function called :
UploadStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
No application is open, and PL7 is in offline mode.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.

___________________________________________________________________________
9/15
B
• In the event of an error :
SRV_ERR_UPLOAD_TRANSFER : Problem transferring the application
contained in the PLC.
SRV_ERR_UPLOAD_ABORT : Suspension of the transfer.
SRV_ERR_UPLOAD_RESERVED : Application reserved.
SRV_ERR_UPLOAD_NOAPPLI : No application on PLC.
SRV_ERR_GEN_ADDRESS : Incorrect address.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_PLC_CONNECT : Connection error.
SRV_ERR_GEN_DRIVER : Incorrect driver.
SRV_ERR_GEN_COMMUNICATION : Communication error.
SRV_ERR_PLC_CONNECT : The PLC is in online mode.
SRV_OPEN_NOT_COMPATIBLE : Compatibility problem.

• Output :
Short type return code. Either 0 in the case of a successful upload, or an error code.

9.5-10 GetSymbol
This function is used to provide the symbol and comment associated with an address.
Syntax : integer GetSymbol(String p_lpRepere, String* p_bsSymbole, String*
p_bsComment)
• Input :
Enter the character string containing the address to be modified or entered.
• Function called :
GetSymbol : Station management function (gesta.dll).

• Nominal context :
The PL7 server is active.
An application is open and in offline mode.
• In the event of an error :
SRV_ERR_ADDRESSSYNTAX : The character string entered as a parameter
does not correspond to an address.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_lpRepere is empty.
SRV_ERR_GEN_ACTION : Error during the execution of the function.

___________________________________________________________________________
9/16
OLE Automation Server 9

B
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
- Two character strings :
The associated symbol (p_bsSymbole).
The associated comment (p_bsComment).

9.5-11 SetServerIHM
This function is used to display or hide the PL7 server. It performs the transition from
one operating mode to the other, namely from a PL7 Pro server without HMI to a PL7
Pro server with HMI and vice versa.
Syntax : integer SetServerIHM (integer p_bIHM)
• Input :
A Boolean (stating whether to display HMI or not).
• Function called :
SetIHMServer : Function of the Windows application (sawinapp.cpp).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_ACTION: Error during the execution of the function.
SRV_ERR_GEN_MODIFAPPLI : Application being modified.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

___________________________________________________________________________
9/17
B
9.5-12 GetPL7State
This function provides the state of the server.
Syntax : integer GetPL7State(String* p_lpStation, String * p_lpConnection)

• Function called :
GetPL7State : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the execution of the function.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
Two character strings provide the user with information about :
- The station state (open or closed).
- The mode state (offline or online). In online mode, the PLC status (run or stop) is
indicated.

9.5-13 GetSTXAppIdentity
This function is used to find out the general information about an application.
Syntax : integer GetSTXAppIdentity(String p_lpNameStx, VARIANT FAR* p_pVarInfo)
• Input :
Enter the character string ( p_lpNameStx) containing the name of the application.
• Function called :
FicheIdentAppli: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : p_ lpNameStx is empty.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_APPLIINFO_NOK : Incorrect information.

___________________________________________________________________________
9/18
OLE Automation Server 9

B
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
Information displayed :
1 The station name,
2 Date and time of creation,
3 The station ID,
4 The ID for the configuration of the local I/O,
5 The ID for the configuration of the remote I/O,
6 The ID for the PL7 code,
7 The ID for Grafcet,
8 The ID for the constants,
9 The ID for the symbols,
10 The ID for the reservation,
11 The comment associated with the application.

9.5-14 GetPLCAppIdentity
This function is used to find out the general information about an application contained
in a PLC.
Syntax : integer GetPLCAppIdentity(String p_lpDriver, String p_lpAdresse, VARIANT
FAR* p_pvInfoAppli)
• Input :
Enter the two character strings containing the driver and address of the PLC.
• Function called :
FicheIdentAppliOnAutomate : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active and in offline mode.
• In the event of an error :
SRV_ERR_APPLIINFO_NOK : Incorrect information.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_GEN_ADDRESS : Incorrect address.
SRV_ERR_COMPATIBLE_PLC : Compatibility problem between the PLC and the
PL7 software.
SRV_ERR_PLC_BLANK : There is no application in the PLC.
SRV_ERR_GEN_ACTION : Problem saving the application data.
SRV_ERR_GEN_DRIVER : The p_lpDriver parameter is incorrect.
SRV_ERR_GEN_COMMUNICATION : Communication error.

___________________________________________________________________________
9/19
B
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.
Information displayed :
1 The station name,
2 Date and time of creation,
3 The station ID,
4 The ID for the configuration of the local I/O,
5 The ID for the configuration of the remote I/O,
6 The ID for the PL7 code,
7 The ID for Grafcet,
8 The ID for the constants,
9 The ID for the symbols,
10 The ID for the reservation,
11 The comment associated with the application.

9.5-15 SendCommandToPLC
This function is used to send a command to the PLC.
Syntax : integer SendCommandToPLC(integer p_iCommand)

• Input :
The type of command the user wishes to execute.
There are 3 possible types :
SRV_COMMAND_INIT : PLC initialization command
SRV_COMMAND_STOP : Stop command
SRV_COMMAND_RUN : Run command

• Function called :
StationCommand : Station management function (gesta.dll).

• Nominal context
The PL7 server is active. An application is open; PL7 is in online mode, in STOP.
• In the event of an error :
SRV_ERR_GEN_ACTION : Incorrect command.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_COMMAND_NOTINLOCAL : The server is in offline mode.
SRV_COMMAND_ERRINIT : The INIT function is impossible, the PLC is in RUN.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

___________________________________________________________________________
9/20
OLE Automation Server 9

B
9.5-16 SetDriverAndAdresse
This function is used to change the driver and address of the current station.
Syntax : integer SetDriverAndAdresse(String p_lpDriver, String p_lpAdresse)

• Input :
Enter the two character strings containing the driver and address of the PLC.
• Function called :
DriverAndAdresse: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open and in offline mode.
If the parameters are not entered or are incorrect, the current values remain
unchanged.
• In the event of an error :
SRV_ERR_GEN_ADDRESS : The address entered as a parameter is incorrect.
SRV_ERR_GEN_DRIVER : The driver entered as a parameter is incorrect.
SRV_ERR_PLC_CONNECT : The server is in online mode.
SRV_ERR_PLC_ACTION : Error during the execution of the function.
SRV_ERR_PARAM_EMPTY : The parameters are empty.

• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

9.5-17 OpenTool
This function is used to open the tools present in the character string entered as a
parameter.
Syntax : integer OpenTool(String p_lpListTool))

• Input :
Character strings containing the list of tools which the server must open.
Format example : tools1;tools2;tools3

• Function called :
OpenTool : Station management function (gesta.dll).

___________________________________________________________________________
9/21
B
• Nominal context :
The PL7 server with HMI is active.
An application is open.

• In the event of an error :


SRV_ERR_GEN_ACTION : Impossible to open the tool.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
SRV_ERR_GEN_OPENEDTVDATA : The "Animation table" tool cannot be opened.

• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

9.5-18 SetPosPL7Windows
This function is used to size the PL7 window.
Syntax : integer PosPL7Windows(integer CoordX, integer CoordY, integer CoordCX,
integer CoordCY)

• Input :
The x, y coordinates of the window.
• Function called :
MoveWindow : Mfc function.

• Nominal context :
The PL7 server with HMI is active.

• In the event of an error :


SRV_ERR_GEN_ACTION : Command failed.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output :
Short type return code.

___________________________________________________________________________
9/22
OLE Automation Server 9

B
9.5-19 ShowProgram
This function is used to open the programs present in the character string entered as
a parameter.
Syntax : integer ShowProgram(String p_lpListProgram)
• Input :
Enter the character strings containing the list of programs which the server must open.
Format example : mast\lad1;mast\lit2;evt\evt0;sr1;mast\prl
• Function called :
ShowProgram : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Command failed.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
SRV_ERR_GEN_SHOWPROGRAM : Impossible to open the module.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
• Limitations :
This function is not capable of opening an uninstantiated DFB. To display the code
of an uninstantiated DFB, use the ShowDFB function.

9.5-20 CloseProgram
This function is used to close the programs present in the character string entered as
a parameter.
Syntax : integer CloseProgram(String p_lpListProgram)
• Input :
Character strings containing the list of programs which the server must close.
Format example : mast\lad1;mast\lit2;evt\evt0;sr1;mast\prl.

___________________________________________________________________________
9/23
B
• Function called :
CloseProgram : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Close failed.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
SRV_ERR_GEN_CLOSEPROGRAMM : Impossible to close the module.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

• Limitations :
This function is not capable of closing an open DFB.

9.5-21 ShowIOModule
This function is used to open the I/O modules present in the character string entered
as a parameter.
• Input :
Character strings containing the list of modules which the server must open.
The format of the character string is rack,module;rack,module
Format example : 0,0;0,1;1,2
• Function called :
ShowIOModule : Station management function (gesta.dll).
• Nominal context :
The PL7 Pro server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ACTION_NOK : Problem with activating the user rights.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
___________________________________________________________________________
9/24
OLE Automation Server 9

B
in HMI mode.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

• Limitations :
An I/O module is opened in offline mode; the module configuration screen is open.
If the user changes from offline mode to online mode, the server does not change from
the configuration screen to the debug screen. The user can either operate directly
on the PL7 Pro, or open/close the module using the client.

9.5-22 CloseIOModule
This function is used to close the I/O modules present in the character string entered
as a parameter.
Syntax : integer CloseIOModule(String p_lpListIOModule).
• Input :
Character strings containing the list of modules which the server must open.
Format example : 0,0;0,1;1,2

• Function called :
CloseIOModule : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Close command failed.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.

• Limitations :
This function does not close the configuration editor opened using the function
ShowIOModule.

___________________________________________________________________________
9/25
B
9.5-23 ShowDFB
This function is used to display the code of one or more DFBs present in the character
string entered as a parameter. Opening a DFB via this function does not require
instantiation.
Syntax : integer ShowDFB(String p_lpListeDFB).
• Input :
Character strings containing the list of DFBs which the server must open.
• Function called :
ShowDFB : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Problem opening a DFB.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.

9.5-24 CloseDFB
This function is used to close one or more DFBs present in the character string entered
as a parameter.
Syntax : integer CloseDFB(String p_lpListeDFB)
• Input :
Character strings containing the list of DFBs which the server must close.
• Function called :
CloseDFB : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.

___________________________________________________________________________
9/26
OLE Automation Server 9

B
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Problem closing a DFB.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.

9.5-25 GetMessageError
This function is used to associate an error message depending on the error code
entered as a parameter.
Syntax : String GetMessageError(integer p_iCodeError)
• Input :
The error code of one of the services to be returned.
• Nominal context :
The PL7 server is active.
• Output :
A character string corresponding to the name of the error.

9.5-26 GetServerVersion
This function is used to find out the version number of the PL7 Pro server.
String GetServerVersion()

• Nominal context
The PL7 server is active.
• Output
A character string corresponding to the name of the version number of the PL7 Pro
server.

___________________________________________________________________________
9/27
B
9.6 Mechanism for accessing the PL7 OLE Automation Server
There are two methods of accessing the services provided by the PL7 OLE Automation
Server.

• Access in offline mode.


The client application program and PL7 OLE Automation Server are on the same station.

• Access in remote mode via DCOM.


The client application and the PL7 OLE Automation Server are on separate stations,
connected by the TCP/IP network :

Client station Server station

DCOM

___________________________________________________________________________
9/28
INDEX
Index 9
10 Index B
Symbols B
%Ci B 1/14 BCD <--> Binary conversion B 2/29
%DRi B 2/9 Binary --->ASCII conversion B 2/54
%Li B 1/30 Bit memory A 1/26, A 1/29
%MNi B 2/2 Bit tables A 1/21, B 2/92
%Ri B 2/5 BIT_D B 2/94
%Ti B 2/13 BIT_W B 2/94
%TMi B 1/10 Bits A 1/10
* B 1/23 BLK A 3/8
+ B 1/23 Boolean instructions B 1/2
- B 1/23 Byte A 1/16
/ B 1/23
:= B 1/20 C
< B 1/19
<= B 1/19 CALL A 2/3
<> B 1/19 Character string A 1/21, B 2/51
= B 1/19 Circular shift B 2/19
> B 1/19 Cold restart A 1/38
>= B 1/19 Comments A 2/6, A 3/4, A 4/7, A 5/14
Common words A 1/18
A Comparison B 1/19
Complement B 1/25
ABS B 1/23 CONCAT B 2/59
Absolute value B 1/23 Concatenation of two strings B 2/59
ACOS B 2/26 CONCATW B 2/34
Action zone A 2/1 Constant A 1/16
Actions A 5/17 Control structures A 4/9
ADD_DT B 2/80 Conversion B 2/28, B 2/29
ADD_TOD B 2/81 Conversions ASCII ---> Binaire B 2/112
Addition B 1/23 COPY_BIT B 2/92
Addressing A 1/11 COS B 2/26
Addressing TSX 37 objects A 1/11 Cyclic execution A 1/41
Addressing TSX 57 objects A 1/13
Alphanumeric comparisons B 2/53 D
AND B 1/6, B 1/25
AND convergences A 5/4 D_BIT B 2/96
AND divergences A 5/4 DATE_TO_STRING B 2/86
AND_ARX B 2/93 Dates B 2/72
ANDF B 1/6 DAY_OF_WEEK B 2/79
ANDN B 1/6 DEC B 1/23
ANDR B 1/6 Decrement B 1/23
Arithmetic on integers B 1/23 DEG_TO_RAD B 2/28
ASCII ---> Binary conversion B 2/56 DELETE B 2/60
ASCII --> Floating point conversion B 2/58 DELTA_D B 2/83
ASIN B 2/26 DELTA_DT B 2/84
Assignment B 1/20 DELTA_TOD B 2/85
ATAN B 2/26 Destination connector A 5/5
DFB A 1/9, A6/1

___________________________________________________________________________
10/1
B
DFB instance A6/8 FIND_LTW B 2/43
DFB objects A6/3 Floating point A 1/17, B 2/20
DFB type A6/3 Floating point ---> ASCII conversion B 2/57
DINT_TO_REAL B 2/32 Floating point instructions B 2/20
DINT_TO_STRING B 2/54 FOR ... END_FOR A 4/13
Direct coils B 1/5 Forcing A 1/30
Directed links A 5/5, A 5/13 FPULSOR B 2/109
Division B 1/23 Freezing the Grafcet chart A 5/26
Double length A 1/17 FTOF B 2/107
DOWN B 1/12, B 1/16 FTON B 2/105
Downcounter B 1/14 FTP B 2/108
Drum controller B 2/9 Function block objects A 1/20
DSHL_RBIT B 2/98 Function blocks B 1/9
DSHR_RBIT B 2/98 Functions on tables B 2/40
DSHRZ_C B 2/98
DT_TO_STRING B 2/87 G
Durations B 2/72
GET B 2/8
E Grafcet language A 5/1
Grafcet objects A 1/23, A 5/6
Edges A 1/29, B 1/2 Grafcet section A 5/23
END B 1/32 Graphic elements, Grafcet A 5/4
End of program B 1/32 Graphic elements, Ladder language A 2/2
END_BLK A 3/8 Gray --> Integer conversion B 2/33
ENDC B 1/32 GRAY_TO_INT B 2/33, B 2/34
ENDCN B 1/32
EQUAL B 2/41 H
EQUAL_ARR B 2/41
EQUAL_STR B 2/69 HALT B 1/33
Event masking/unmasking B 1/34 HW B 2/34
Event-triggered tasks A 1/50
Exclusive OR B 1/8
I
EXIT A 4/14 IF ... END_IF A 4/9
EXP B 2/25 Immediate values A 1/18
Exponential instructions B 2/25 INC B 1/23
EXPT B 2/25 Increment B 1/23
Index overrun A 1/23
F Indexation A 1/22
Falling edge contacts B 1/4 Indexed objects A 1/22
FAST A 1/48 INSERT B 2/61
Fast task A 1/48 Instruction List language A 3/1
FIFO stack B 2/5 INT_TO_REAL B 2/32
FIND B 2/70 INT_TO_STRING B 2/54
Find in tables B 2/43 Integer <--> Floating point conversion B 2/31
FIND_EQD B 2/43 Internal words A 1/16
FIND_EQW B 2/43 Inverse coils B 1/5
FIND_GTD B 2/43
FIND_GTW B 2/43
FIND_LTD B 2/43
___________________________________________________________________________
10/2
Index 9

B
J NOT_ARX B 2/93
Numerical expression B 1/27
JMP B 1/30
JMPC B 1/30 O
JMPCN B 1/30
Objects which can be symbolized A 1/24
Jump B 1/30
OCCUR_ARD B 2/46
L OCCUR_ARR B 2/46
OCCUR_ARW B 2/46
Label A 2/6, A 3/4, A 4/8 OLE B9/2
Ladder language A 2/1 OLE server B9/2
LD B 1/4 Operating modes A 5/1
LDF B 1/4 OR B 1/7, B 1/25
LDN B 1/4 OR convergences A 5/5
LDR B 1/4 OR_ARX B 2/93
LEFT B 2/67 ORF B 1/7
LEN B 2/71 ORN B 1/7
LENGTH_ARR B 2/50 ORR B 1/7
LIFO stack B 2/5 OUT_BLK A 3/8
LN B 2/25 Overflow B 1/24
LOG B 2/25
Logarithms B 2/25 P
Logic AND B 1/6
Logic OR B 1/7, B 1/25 Parentheses A 3/5
Logic shift B 2/19 PCMCIA B 2/111
Periodic execution A 1/42
LW B 2/34
Post-processing A 5/30
M Pre-processing A 5/24
PRESET B 1/16
Macro-step A 5/15 Presymbolization A 1/25
MASKEVT B 1/34 Private variables A6/4
Master task A 1/47 Program instructions B 1/28
MAX_ARD B 2/45 PTC B 2/78
MAX_ARW B 2/45 Public variables A6/4
Memory card A 1/26 PUT B 2/8
MID B 2/65
MIN_ARD B 2/45 R
MIN_ARW B 2/45
Monostable B 1/11, B 2/2 R B 1/5
RAD_TO_DEG B 2/28
MPP A 3/7
MPS A 3/7 Read day of the week B 2/79
MRD A 3/7 Read system date B 2/77
READ_PCMCIA B 2/116
Multiplication B 1/23
Multitask A 1/45 REAL_TO_DINT B 2/32
REAL_TO_INT B 2/32
N Realtime clock B 2/75
Register B 2/5
N/C contacts B 1/4 REM B 1/23
N/O contacts B 1/4 REPEAT ... END_REPEAT A 4/12
NOT B 1/25 REPLACE B 2/63
___________________________________________________________________________
10/3
B
RESET B 1/16, B 2/8, B 2/11 Subroutine return B 1/29
Reset coils B 1/5 Subtraction B 1/23
RET B 1/29 SUM B 2/40
RETCN B 1/29 SUM_ARR B 2/40
RIGHT B 2/67 Symbol A 1/6, A 1/24
Rising edge contacts B 1/4 System bits B 3/1
ROL_ARD B 2/47 System words B 3/9
ROL_ARW B 2/47
ROR_ARD B 2/47 T
ROR_ARR B 2/47 Table comparisons B 2/41
ROR_ARW B 2/47 TAN B 2/26
RRTC B 2/77 Test zone A 2/1
Rung A 2/5 Time B 2/72
Rungs, execution A 2/13 Time delay B 2/105
Time of day B 2/72
S TIME_TO_STRING B 2/88
S B 1/5 Timer B 1/10, B 2/13, B 2/105, B 2/107
SCHEDULE B 2/75 B2/108, B 2/109
SCOUNT B 2/101 TOD_TO_STRING B 2/89
Section A 1/4, A 1/39 TRANS_TIME B 2/91
Sequence A 3/4 Transition conditions A 5/20
Sequence selection A 5/10 Transitions A 5/4
Sequential processing A 5/28 Trigonometric functions B 2/26
Set coils B 1/5 TRUNC B 2/24
SET_PCMCIA B 2/112
Simultaneous step activation A 5/10 U
SIN B 2/26 UNMASKEVT B 1/34
Single task A 1/39 UP B 2/11
Sort function on tables B 2/49, B 2/50 Upcounter B 1/14
SORT_ARD B 2/49 Update system date B 2/77
SORT_ARR B 2/49 User function blocks A 1/9
SORT_ARW B 2/49 User memory A 1/26
Source connector A 5/5
SQRT B 1/23 V
Square root B 1/23
SRi A 1/39 Vertical comparison B 2/17
ST B 1/5
START B 1/12, B 2/3 W
Steps A 5/4 W_BIT B 2/96
STN B 1/5
Warm restart A 1/37
Stop code B 2/78
Watchdog A 1/44
STRING_TO_DINT B 2/56 WHILE ... END_WHILE A 4/11
STRING_TO_INT B 2/56
Word extract bits A 1/18
STRING_TO_REAL B 2/58 Word memory A 1/26, A 1/27, A 1/31
Structured data B 4/4
Word tables A 1/21, B 2/35
Structured Text language A 4/1
WRITE_PCMCIA B 2/114
SUB_DT B 2/80 WRTC B 2/78
SUB_TOD B 2/81
WSHL_RBIT B 2/98, B 2/103
Subroutine A 1/39, B 1/28
___________________________________________________________________________
10/4
Index 9

B
WSHR_RBIT B 2/98
WSHRZ_C B 2/98

X
XOR B 1/8, B 1/25
XOR_ARX B 2/93
XORF B 1/8
XORN B 1/8
XORR B 1/8

___________________________________________________________________________
10/5
B

___________________________________________________________________________
10/6

You might also like