0% found this document useful (0 votes)
53 views195 pages

PL7 Reference Manual[006 200]

Uploaded by

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

PL7 Reference Manual[006 200]

Uploaded by

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

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

You might also like

pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy