PL7 Reference Manual
PL7 Reference Manual
A
Reference
manual Detailed description of instructions and functions
B
___________________________________________________________________________
B/2
A
Section Page
1 General information A1/1
___________________________________________________________________________
A/1
A
Section Page
1.4 Operating modes A1/36
1.4-1 Processing on power outage and power return A1/36
1.4-2 Processing on a warm restart A1/37
1.4-3 Processing on a cold start A1/38
___________________________________________________________________________
A/2
A
Section Page
___________________________________________________________________________
A/3
A
Section Page
___________________________________________________________________________
A/4
A
Section Page
6 DFBs A6/1
___________________________________________________________________________
A/5
A
Section Page
7 Function modules A7/1
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.
• 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.
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
- 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
Each of these sections can be programmed in the language which is most suitable for
the process to be executed.
MAST FAST
Oven_1(Grafcet) Monitor_Sec(LD)
PRL (LD)
Alarm_Oven(ST)
CHART
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
A function module contains a program directory (made up of one or more code modules)
and an animation table directory.
A function module can itself be divided into lower level function modules which perform
one or more subfunctions of the main control system function.
PL7 PRO is the only product which can be used to set up function modules on
TSX/PMX/PCX57 PLCs.
___________________________________________________________________________
1/5
A
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
• 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
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.
___________________________________________________________________________
1/8
A
PL7 general information 1
___________________________________________________________________________
1/9
A
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.
___________________________________________________________________________
1/10
A
PL7 general information 1
% I or Q X, W or D x . i
• 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.
1 3 5 7 1 3 5 7 9
2 4 6 8 0
2 4 6 8 10
Standard format modules are addressed as two superposed 1/2 format modules (see
table below).
___________________________________________________________________________
1/11
A
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
% I or Q X, W or D x y . i
• 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
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.
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.
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 :
___________________________________________________________________________
1/14
A
PL7 general information 1
• 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.
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
% M, K or SS B, W, D or F i
• 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.
• 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
___________________________________________________________________________
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
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
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 :
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 :X j
Position
j=0 to 15
Rank of bit
in the word
(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/20
A
PL7 general information 1
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
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.
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/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.
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
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.
___________________________________________________________________________
1/25
A
Constants %MW
backup
Program RAM or
and constants Program
Internal external
Flash backup Flash
EPROM (1) EPROM
%MW memory
backup card
Constants
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)
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/28
A
PL7 general information 1
Structure
Each bit object contained in the bit memory is stored using 3 bits assigned in the
following way :
F P C
• 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.
%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.
___________________________________________________________________________
1/30
A
PL7 general information 1
In the case of the TSX/PMX/PCX 57, the data memory also includes the bit data detailed
in the preceding paragraph.
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
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
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 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
RUN
Application
Power failure
Await power
Power return
No Yes
Memory card No
identical
Yes
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
Program execution
TOP
Power return
If %S1 = 1,
warm restart
processing possible
Configuration
self-tests
Set bit
%S1 to 0
Update
outputs
___________________________________________________________________________
1/37
A
Read
Stop processor
inputs
Save application
context
Program execution
TOP
Power return
If %S0 = 1,
process cold
restart Configuration
self-tests
Update
outputs
Note : when cold starting, execution conditions are at 0 and all the sections with which a condition
is associated are inhibited.
___________________________________________________________________________
1/39
A
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
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.
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
(1) In the case of the TSX/PMX/PCX 57, internal processing is carried out in parallel with I/O
processing.
___________________________________________________________________________
1/43
A
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).
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.
Note :
This data can also be accessed from the configuration editor if requested.
___________________________________________________________________________
1/44
A
PL7 general information 1
- Priority +
Master and fast tasks are structured in sections (see the description of a section in
section 1.5).
MAST FAST
Oven_1(Grafcet) Monitor_Sec(LD)
PRL(LD)
Alarm_Oven(ST)
CHART
Drying(LD) SR0
Cleaning(ST)
___________________________________________________________________________
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.
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/47
A
___________________________________________________________________________
1/48
A
PL7 general information 1
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
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".
___________________________________________________________________________
1/50
A
PL7 general information 1
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
___________________________________________________________________________
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).
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.
___________________________________________________________________________
2/1
A
___________________________________________________________________________
2/2
A
Ladder language 2
DFBs
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.
___________________________________________________________________________
2/3
A
Operation blocks
___________________________________________________________________________
2/4
A
Ladder language 2
Columns 1 2 3 4 5 6 7 8 9 10 11
Ladder diagram EVT FAST MAST AUX
%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 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
%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
• comparison blocks.
___________________________________________________________________________
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
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
%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
%I6.5 %Q3.3
16 independent lines of P /
contacts (7 lines for %M53 %MW3:X6
%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 /
___________________________________________________________________________
2/9
A
• Function blocks are located in the test zone and are inserted in a rung.
%C4
%TM10
Timers 2 columns
Monostable 3 lines
Register
Drum controller
COMPARE
"Horizontal" comparison block 2 columns
1 line
Note :
___________________________________________________________________________
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 :
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.
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
%L
%L
Internal variables of blocks and graphic outputs can be used remotely from another part
of the program.
___________________________________________________________________________
2/12
A
Ladder language 2
%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
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.
___________________________________________________________________________
3/1
A
3.1-2 Instructions
Basic instructions
(For further information on each instruction, see part B).
Designation Instructions Equivalent functions
• AND, ANDN,
ANDR, ANDF
P N
• AND(, OR(
(8 levels of parentheses)
• MPS
MRD
MPP
•N Negation
___________________________________________________________________________
3/2
A
Instruction List language 3
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-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
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
___________________________________________________________________________
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
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
Examples :
MPS
∆
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
%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
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
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
___________________________________________________________________________
4/2
A
Structured Text language 4
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
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
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
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
"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
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-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
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
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 :
___________________________________________________________________________
4/10
A
Structured Text language 4
action; checked
ACTION
END_WHILE; end of WHILE
Example :
___________________________________________________________________________
4/11
A
REPEAT ACTION
action;
CONDITION
not checked
checked
UNTIL conditionEND_REPEAT; end of REPEAT
Example :
___________________________________________________________________________
4/12
A
Structured Text language 4
Syntax Operation
start of FOR
FOR index := initial value TO final value DO
INITIAL VALUE → INDEX
action;
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
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
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.
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 :
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 :
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 :
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/2
A
Grafcet language 5
• Graphic representation
Macro-steps
Measuring sequence
Filling sequence
Main chart
Mixing sequence
Discharging sequence
___________________________________________________________________________
5/3
A
(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
• downwards
___________________________________________________________________________
5/5
A
___________________________________________________________________________
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.
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
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
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
___________________________________________________________________________
5/10
A
Grafcet language 5
• 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
Page 1
___________________________________________________________________________
5/12
A
Grafcet language 5
Page 3
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
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
12
13 21
___________________________________________________________________________
5/16
A
Grafcet language 5
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
• Calling a subroutine :
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
When step 51 is deactivated, the associated continuous actions are no longer scanned.
___________________________________________________________________________
5/19
A
___________________________________________________________________________
5/20
A
Grafcet language 5
• 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
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
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).
Note :
When resetting a step to zero, actions on deactivation of this step are not executed.
___________________________________________________________________________
5/24
A
Grafcet language 5
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.
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.
___________________________________________________________________________
5/25
A
• 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
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.
F %SW22 0
XM15 . . . . . . . . . . . . . . XM0
%SW23
%SW24
F %SW25 0
XM63 . . . . . . . . . . . . . . XM48
___________________________________________________________________________
5/27
A
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
___________________________________________________________________________
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.
___________________________________________________________________________
5/30
A
Grafcet language 5
___________________________________________________________________________
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).
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
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
Tp s_re f_C 1 R ef
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)
(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 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
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
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/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.
Notes :
Whenever a section is imported into an application, the DFB types used in that section must also
be imported.
___________________________________________________________________________
6/7
A
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
(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/9
A
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
Calling a DFB is an action which can be inserted into a statement or sequence just like
any other language action.
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.
___________________________________________________________________________
6/11
A
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.
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
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
___________________________________________________________________________
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.
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
• A functional view of the application : This is a view of the application divided into
function modules corresponding to the control system functions.
___________________________________________________________________________
7/2
A
Function modules 7
A
Example
• a long name : 16
characters (example :
Forward / Reverse for
BT371)
___________________________________________________________________________
7/3
A
Example
___________________________________________________________________________
7/4
A
Function modules 7
A
___________________________________________________________________________
7/5
A
Example
___________________________________________________________________________
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
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
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/9
A
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.
The user has functions enabling the incremental debugging of the application, function
module by function module.
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
___________________________________________________________________________
B/1
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________
Section Page
___________________________________________________________________________
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
___________________________________________________________________________
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
___________________________________________________________________________
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
___________________________________________________________________________
B/5
B Detailed description of instructions Contents
and functions Part B
___________________________________________________________________________
Section Page
8 Performance B8/1
___________________________________________________________________________
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
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 :
These three Boolean equations are equivalent. Bit object %Q2.0 takes the value
(assignment instruction) of bit object %1.0 (load instruction).
___________________________________________________________________________
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
• 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 ;
• 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.
• 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 :
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
%Q2.3 := %I1.1 ;
%Q2.2 := NOT %M0 ;
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
%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
%Q2.3 := %I1.1 ;
%Q2.2 := NOT %M0 ;
%Q2.4 := RE %I1.2 ;
%Q2.5 := FE %I1.3 ;
Code Operand P N
(1) True (1)/False (0) in Instruction List or %Q2.3 %Q2.2 %Q2.4 (2) %Q2.5 (2)
Structured Text language
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.
%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
%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 ;
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)
Note : The parentheses are optional but make the program easier to read.
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)
___________________________________________________________________________
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.
Note : The parentheses are optional but make the program easier to read.
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).
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.
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
___________________________________________________________________________
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
___________________________________________________________________________
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.
___________________________________________________________________________
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
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
Characteristics
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
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.
___________________________________________________________________________
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
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
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.
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
___________________________________________________________________________
1/20
Description of basic instructions 1
B
Structured Text language
Syntax
Operator := Op1:=Op2
Operands
___________________________________________________________________________
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
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
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
___________________________________________________________________________
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.
%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
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).
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
Operands
___________________________________________________________________________
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 :
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
IF %M8 THEN
SR10 ;
END_IF ;
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
IF %M8 THEN
RETURN ;
END_IF ;
LD [%MW5>3]
%MW5>3 <RETURN> RETC
LD %M8
%M8 [%MD26:=%MW4*%KD6]
%MD26:=%MW4*%KD6
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
___________________________________________________________________________
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
%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
%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.
Example :
Instruction List language
LD %M1 LD %M1
ST %Q2.1 ST %Q2.1
LD %M2 LD %M2
ST %Q2.2 ST %Q2.2
..................... .....................
END LD %I1.2
ENDC If %I1.2 =1, end of
LD %M2 program scanning.
ST %Q2.2 If %I1.2 =0, continues
.................... program scanning until
END new END instruction.
___________________________________________________________________________
1/32
Description of basic instructions 1
B
1.5-5 Stop program
Execution of an application program can be stopped using the instruction HALT (stops
all tasks). This freezes the variable objects in this program.
A program stopped in this way must be initialized to restart it (using the PL7 command
INIT). Any instructions following the instruction HALT will therefore not be executed.
Structure
Ladder language Instruction List language
LD %M10
%M10
HALT
<HALT>
IF %M10 THEN
HALT ;
END_IF ;
___________________________________________________________________________
1/33
B
1.5-6 Event masking/unmasking instructions
Event masking/unmasking instructions are used to mask or unmask all the events
which activate event-triggered tasks.
MASKEVT : masks all events. The events are stored by the PLC. However, the
associated event-triggered tasks remain inactive as long as the masking operation is
enabled (until the next UNMASKEVT instruction).
UNMASKEVT : unmasks all events. The events which were stored during the mask
period are processed. The event processing mechanism is operational until the next
MASKEVT instruction.
Structure
Ladder language Instruction List language
%M0
LD %M0
MASKEVT ( )
[MASKEVT()]
%M8
UNMASKEVT ( )
LD %M8
[UNMASKEVT()]
IF %M0 THEN
MASKEVT ( ) ;
END_IF ;
IF %M8 THEN
UNMASKEVT ( ) ;
END_IF ;
The NOP instruction does not perform any operation. It is used for "reserving" lines in
a program which allow the user to insert instructions later without modifying the line
numbers.
___________________________________________________________________________
1/34
Section 22
Description of advanced instructions
2 Description of advanced instructions B
2.1 Presentation of advanced instructions
2.1-1 General
The instructions described in this section are suitable for advanced programming
requirements.
They have the same effect, irrespective of the language used. Only the syntax differs.
They are :
• Either basic instructions of the software.
• Or Functions considered as extensions of the software.
Extended Function type instructions are used to enhance the basic software using
special programming instructions.
• Operations on character strings, word tables, etc.
• Application-specific functions : Communication, Process control, Man-Machine
Interface, etc.
They include the following families :
• Character strings.
• Word tables.
• Management of Dates, times and time periods.
• Conversions.
• Bit tables.
• "Orphee" functions.
• Communication
• Process control ==> see the relevant application-specific function
• Man-Machine Interface
• Motion control
Notes on programming
Function type instructions require additional application memory occupation (only
when they are actually used in the program).
This memory occupation should be taken into account by the programmer for each
function, irrespective of the number used, and the maximum memory size of the
PLC used must be observed.
___________________________________________________________________________
2/1
B
2.2 Advanced predefined function blocks
2.2-1 Monostable function block %MNi
Monostable block
Characteristics
Operation
When input S of the monostable is at 1 (rising edge), the current value %MNi.V takes
the preset value %MNi.P and decreases to 0 by one unit on each pulse of the time base
TB. Output bit %MNi.R (Running) assigned to output R changes to 1 when the current
value %MNi.V is other than 0.
When the current value %MNi.V = 0, output bit %MNi.R returns to 0.
Start input S :
S
%MNi.P
Current value %MNi.V : %MNi.V
B
Programming and configuration
• Configuration
The following parameters must be entered in the variables editor :
- TB : 1min, 1s, 100ms, 10ms or 1ms (100ms in this example).
- %MNi.P : 0 to 9999 (%MN0.P=50 and %MN1.P=20 in this example).
- MODIF : Y or N.
• Programming
Ladder language Instruction List language
In the example above, output %Q3.0 is set to 1 for 5s (%MN0.P) and reset to 0 for 2s
(%MN1.P).
In Structured Text language, the instruction START %Mni is used to start the
monostable function block. This instruction forces a rising edge on input S of the block
and thus reinitializes the function block. Activation of this instruction should therefore
be on a pulse.
___________________________________________________________________________
2/3
B
Note
The monostable function can also be performed by the function block %TMi in TP
mode (see part B, section 1.3-2).
Special cases
• Effect of a cold restart : (%S0 = 1) the preset value %MNi.P is loaded into the
current value %MNi.V. Since the preset value which may have been modified by the
terminal is lost, output %MNi.R is reset to 0.
• Effect of a warm restart : (%S1) has no effect on the current value of the
monostable (%MNi.V).
• Effect of a PLC stop, de-activation of the task and break point : a PLC stop, de-
activation of the current task or execution of a break point does not freeze the current
value.
• Effect of a program jump : the fact of not scanning the rung where the monostable
block is programmed does not freeze current value %MNi.V which continues to
decrease to 0.
Similarly, bit %MNi.R assigned to the monostable block output continues to operate
normally and can thus be tested in another rung.
However, the coils directly "connected" to the block output (eg %Q3.0) will not be
activated since they are not scanned by the PLC.
• Testing bit %MNi.R : the state of this bit can change during a scan.
___________________________________________________________________________
2/4
Description of advanced instructions 2
B
2.2-2 Register function block %Ri
A register is a memory block which is %Ri
used to archive up to 255 words of 16 bits
R E
in two different ways : MODE:LIFO
LEN:16
• Queue, known as FIFO stack (First In, I F
First Out).
O
• Stack, known as LIFO stack (Last In,
First Out).
Register block
Characteristics
Note :
When the two inputs I and O are activated simultaneously, archiving is performed before
retrieval.
___________________________________________________________________________
2/5
B
FIFO (First In, First Out)
The first data item entered is the first to be
retrieved. Example :
When a archiving request is received (rising Archiving of the contents of %Ri.I
edge at input I or activation of instruction I), at the top of the stack.
the contents of input word %Ri.I (which 20
have already been loaded) are stored at the
%Ri.I 20
top of the stack (fig a).
When the stack is full (output F=1), no (a) 80
further archiving is possible and system bit 50
%S18 changes to 1.
When a retrieval request is received (rising Retrieval of the first data item which is
edge at input O or activation of instruction then loaded into %Ri.O.
O) the data word lowest in the stack is
loaded into output word %Ri.O and the 20 (b)
contents of the register are moved down %Ri.0
80
one place in the stack (fig.b).
When the register is empty (output E=1), no 50 50
further retrieval is possible. Output word
%Ri.O does not change and retains its value. 20
The stack can be reset at any time (state 1 80
at input R or activation of instruction R).
B
Programming and configuration
• Configuration
The following parameters must be entered in the configuration editor :
- Number : 1 to 4 for a TSX 37, 1 to 255 for a TSX 57,
- Length : 1 to 255.
The operating mode (FIFO or LIFO) must be entered in the variables editor.
• Programming
Ladder language Instruction List language
%R2 LD %M1
I %R2
R E LD %I1.3
%M1 O %R2
MOD : LD %I1.3
I LEN : F
ANDN %R2.E
%I1.3 [%MW20:=%R2.O]
O LD %I1.2
ANDN %R2.F
%I1.3 %R2.E [%R2.I:=%MW34]
ST %M1
%MW20:=%R2.O
%I1.2 %R2.F
%R2.I:=%MW34
%M1
The programming example shows word %MW34 being loaded into %R2.I at the
archiving request %I1.2, if register R2 is not full (%R2.F=0). The archiving request in
the register is made by %M1. The retrieval request is made by input %I1.3 and %R2.O
is loaded into %MW20 if the register is not empty (%R2.E=0).
___________________________________________________________________________
2/7
B
In Structured Text language, 3 instructions are used to program the register function
blocks :
• RESET %Ri : Initializes the register,
• PUT %Ri : Stores the contents of word %Ri.I in the register,
• GET %Ri : Loads a data word into word %Ri.O.
The PUT and GET instructions create a rising edge on inputs I and O respectively of
the function block. Activation of this instruction should therefore be on a pulse.
Special cases
• Effect of a cold restart : (%S0=1) initializes the contents of the register. The Output
bit %Ri.E assigned to output E is set to 1.
• Effect of a warm restart : (%S=1) has no effect on the contents of the register, nor
on the state of its output bits.
• When resetting to 0 (input R or instruction R)
- In Ladder language, the memorized values of inputs I and O are updated with the
actual values.
- In Instruction List language, the memorized values of inputs I and O are not
updated. Each one retains the value it had before being called.
- In Structured Text language, the memorized values of inputs I and O are updated
with 0.
___________________________________________________________________________
2/8
Description of advanced instructions 2
B
2.2-3 Drum controller function block %DRi
The drum controller operates on a similar
principle to an electromechanical drum
controller, which changes step according %DRi
to external events. On each step, the high R F
point of a cam gives an order which is %TB:1mn
executed by the control system. In the U
case of a drum controller, these high LEN:16
points are symbolized by state 1 for each
step and are assigned to output bits %Qi.j
or internal bits %Mi, known as control Drum controller block
bits.
Characteristics
___________________________________________________________________________
2/9
B
Operation
The drum controller comprises :
• A matrix of constant data (the cams) organized :
- in columns : in steps from 0 to N-1 (N is the step number configured). Each column
shows the states of the step in the form of 16 data bits numbered 0 to F.
• A list of control bits (1 per line) corresponding to either outputs %Qxy.i, or to internal
bits %Mi. During the current step, the control bits take on the binary states defined
for this step.
The table below summarizes the main characteristics of the drum controller (controller
configured with 16 steps).
Step
Control
Bit bits
In the above example, for step 1, control bits %Q2.1;%Q3.5; %Q2.8;%Q3.6;%M5 and
%M6 are set to state 1. The other control bits are set to 0.
The current step number is incremented on each rising edge at input U (or activation
of instruction U). This number can be modified by the program.
Operating diagram
Input U:
Input R:
Output %DRi.F
Time %DRi.V
envelope
___________________________________________________________________________
2/10
Description of advanced instructions 2
B
Programming and configuration
In this example, the first 5 outputs %Q2.0 to %Q2.4 are activated in succession each
time input %I1.1 is set to 1.
Input I1.0 resets the outputs to step 0.
Configuration
The following information is defined in the variables editor :
• Step number : 5 (LEN:5).
• The state of the outputs (control bits) for each step of the drum controller.
Step Assignment of control bits
0 1 234
0: 1 0 000 %Q2.0
1: 0 1 000 %Q2.1
Bit 2: 0 0 100 %Q2.2
3: 0 0 010 %Q2.3
4: 0 0 001 %Q2.4
• Time base (TB:1 min).
Programming
Ladder language Instruction List language
LD %I1.0
%I1.0 %DR1 %Q2.8 R %DR1
LD %I1.1
R F
U %DR1
%I1.1 %TB:1 mn LD %DR1.F
U ST %Q2.8
LEN:5
IF %I1.0 THEN
RESET %DR1 ;
END_IF ;
IF RE %I1.1 THEN
UP %DR1 ;
END_IF ;
%Q2.8 := %DR1.F ;
In Structured Text language, 2 instructions are used to program the drum controller
function blocks :
• RESET %DRi : Initializes the controller to step 0,
• UP %DRi : Advances the controller by one step and updates the control bits.
This instruction creates a rising edge on input U of the function block : activation of
this instruction should therefore be on a pulse.
___________________________________________________________________________
2/11
B
Note
When resetting to 0 (input R, instruction R or RESET instruction)
• In Ladder language, the memorized value of input U is updated with the actual
values.
• In Instruction List language, the memorized value of input U is not updated. It
retains the value it had before being called.
• In Structured Text language, the memorized value of input U is updated with 0.
Special cases
• Effect of a cold restart : (%S0=1) resets the drum controller to step 0 (with updating
of the control bits).
• Effect of a warm restart : (%S1=1) updates the control bits, according to the current
step.
• Effect of a program jump, de-activation of the task and break point : the fact of
not scanning the drum controller means that the control bits are not reset to 0.
• Updating the control bits : only occurs when there is a change of step or in the case
of a cold or warm restart.
___________________________________________________________________________
2/12
Description of advanced instructions 2
B
2.2-4 Timer function block %Ti (Series 7)
This timer function block, which is
compatible with Series 7 PL7-2/3 blocks %Ti
is used to provide control for time-delayed E D
actions. TB:1mn
The value of this delay is programmable C R
and can be modified via the terminal. T.P:9999
MODIF:Y
Timer block
Characteristics
Note :
%Ti function blocks cannot be programmed in Instruction List language. The objects of %Ti
blocks (%Ti.V, %Ti.P, %Ti.D and %Ti.R) can, however, be accessed.
The total number of %TMi + %Ti should be less than 64 on the TSX 37 and less than 255 on the
TSX 57.
___________________________________________________________________________
2/13
B
Operation
The timer changes when its two inputs (E
E
and C) are at 1. It behaves like a
downcounter. C
• Current value %Ti.V decreases from %Ti.P
the preset %Ti.P to 0, by one unit on %Ti.V
each pulse of the time base TB. %Ti.D
• Output bit %Ti.R (Timer running)
%Ti.R
assigned to output R is then at state 1
and output bit %Ti.D (Timer done) E 0 0 1 1
assigned to output D is at state 0. C 0 1 0 1
• When current value %Ti.V= 0, %Ti.D
%Ti.P %Ti.V %Ti.V %Ti.V %Ti.V
changes to 1 and %Ti.R returns to 0.
= = frozen decr. from
%Ti.V %Ti.P %Ti.P %Ti.P -> 0
Standard operations
%Ti.D 0 0 0 1 if Timer
The Timer function block can be
done
programmed to perform the following
functions : %Ti.R 0 0 0 1 if Timer
running
• On-time delay
Ladder language
%I1.0 = E,C
%I1.0 %T0 %Q2.0
E D R
IF %I1.0 THEN
START %T0 ;
ELSE
PRESET %T0 ;
END_IF ;
%Q2.0 := %T0.D ;
___________________________________________________________________________
2/14
Description of advanced instructions 2
B
• Off-time delay
Ladder language
% I1.1
%I1.1 %T7 %Q2.1
E D E,C
R
TB =1s
C R PRESET
%Ti.P = 120 D
MOD:N
%Q2.1
IF %1.1 THEN
PRESET %T7 ;
ELSE
START %T7 ;
END_IF ;
%Q2.1 := NOT %T7.D ;
% I1.2 = E
IF %I1.2 THEN
IF %I1.3 THEN
START %T5 ;
ELSE
STOP %T5 ;
END_IF ;
ELSE
PRESET %T5 ;
END_IF ;
%Q2.4 := %T5.D ;
%Q2.5 := %T5.R ;
___________________________________________________________________________
2/15
B
• Cumulated off-time delay
Ladder language
% I1.0
%I1.0 %T12 %Q2.4
E
E D
%I1.1
%I1.1 TB =10mn
C R C
%Ti.P = 40
MOD:Y
R
D1 D2 D3
D
Structured Text language
%Q2.1
In Structured Text language, 3 instructions are used to program the timer function
blocks %Ti :
• PRESET %Ti : Resets the timer,
• START %Ti : Starts the timer running,
• STOP %Ti : Freezes the current value of the timer.
Special cases
• Effect of a cold restart : (%S0 = 1) the preset value (defined by the variables editor)
is loaded into the current value and output %Ti.D is set to 0, since the preset value
which may have been modified by the terminal is lost.
• Effect of a warm restart : (%S1) has no effect on the current value of the timer.
• Effect of a PLC stop : a PLC stop, de-activation of the current task or execution of
a break point does not freeze the current value.
• Effect of a program jump : the fact of not scanning the rung where the timer block
is programmed does not freeze current value %Ti.V which continues to decrease
to 0.
Similarly, bits %Ti.D and %Ti.R assigned to timer block outputs D and R continue
to operate normally and can thus be tested in another rung.
However, the coils directly "connected" to the block outputs will not be activated
since they are not scanned by the PLC.
• Testing bits %Ti.D and %Ti.R : the state of these bits can change during a scan.
___________________________________________________________________________
2/16
Description of advanced instructions 2
B
2.3 Vertical comparison blocks
Vertical comparison blocks are used to
compare two operands (OP). COMPARE
EN >
These two operands are either 16-bit
OP1 =
words (possibly indexed) or immediate
values. OP2 <
<>
Characteristics
___________________________________________________________________________
2/17
B
Operation
When the command input is set to 1, the two operands are compared and the four
outputs are activated according to the result of the comparison. Setting the command
input to 0 resets the activated outputs.
• Example of use
The program below shows the comparison of word %MW2 indexed by word
%MW40 with the immediate value 150.
If the contents of %MW2[%MW40] are greater than 150 and %I1.3 = 1, coil %Q2.7
is activated.
If the contents are equal to 150, coil %MW10:X4 is activated. Coil %M5 is only
controlled if the contents are different from 150 (< or >).
Ladder language
%I1.3 %Q2.7
EN >
This function block does not exist in
%MW10:X4 Instruction List language or Structured
%MW2 = Text language. Use comparison
[%MW40] operations >, <, =, <>
<
150 %M5
<>
Special cases
• Effect of a cold restart : (%S0) operand OP1 and possibly OP2 (if OP2 is an internal
word) are reset and the outputs are activated according to the result of their
comparison with the new values.
• Effect of a warm restart : (%S1) has no effect on the comparison block.
___________________________________________________________________________
2/18
Description of advanced instructions 2
B
2.4 Shift instructions
Shift instructions consist of moving bits of a word or double word operand a certain
number of positions to the right or to the left.
• Logic shift :
- SHL(op2,i) logic shift of i positions to 15 (or 31) 0
the left.
- SHR(op2,i) logic shift of i positions to
%S17 0
the right.
• Circular shift :
- ROL(op2,i) circular shift of i positions %S17
to the left.
- ROR(op2,i) circular shift of i positions
to the right.
0
If the operand to be shifted is a single
length operand, the variable i will be
between 1 and 16. %S17
If the operand to be shifted is a double 15 (or 31) 0
length operand, the variable i will be
between 1 and 32.
The state of the last output bit is stored in %S17
bit %S17.
Structure
Ladder language Instruction List language
Floating point values can be represented with or without exponent, they must always
contain a point (floating point).
System bit %S18 is set to 1 when the result is not within the valid limits. The bits of
status word %SW17 indicate the cause of a fault on a floating point operation:
%SW17:X0 = invalid operation, the result is not a number (1.#NAN or -1.#NAN)
%SW17:X1 = operand not standardized (between -1.175494e-38 and 1.175494e-38),
the result is rounded to 0.
%SW17:X2 = division by 0, the result is ±infinity (-1.#INF or 1.#INF)
%SW17:X3 = result is greater than +3.402824e+38 as an absolute value, the result
is ±infinity (-1.#INF or 1.#INF)
%SW17:X4 = result is less than 1.175494e-38, the result is 0.
%SW17:X5 = imprecise result
This word is reset to 0 by the system after a cold start and by program for reuse.
___________________________________________________________________________
2/20
Description of advanced instructions 2
B
Representation is accurate to 2-24 . When viewing floating point numbers, no more than
six digits can be displayed after the comma.
Notes
• The value "1285" is interpreted as an integer value. To be considered as a floating
point value it must be written : "1285.0",
• The conversion instructions Integer <--> Floating Point are used to change from
one format to the other.
Examples :
%MF0 corresponds to %MW0 and %MW1
%KF543 corresponds to %KW543 and
%KW544.
___________________________________________________________________________
2/21
B
2.5-2 Floating point comparison instructions
Comparison instructions are used to compare two operands.
> : test if operand 1 is greater than operand 2.
>= : test if operand 1 is greater than or equal to operand 2.
< : test if operand 1 is less than operand 2.
<= : test if operand 1 is less than or equal to operand 2.
= : test if operand 1 is equal to operand 2.
<> : test if operand 1 is different from operand 2.
The result is 1 when the comparison requested is true.
Structure
Ladder language Instruction List language
%Q2.3
LD [%MF10 > 129.7]
%MF10>129.7 ST %Q2.3
LD %M0
AND [%MF20 < %KF35]
%M0 %Q2.2
ST %Q2.2
%MF20<%KF35 LD %I1.2
OR [%MF30 >= %MF40]
%I1.2 %Q2.4 ST %Q2.4
Operands
Note
In Instruction List language, comparison instructions can be used in parentheses.
___________________________________________________________________________
2/22
Description of advanced instructions 2
B
2.5-3 Floating point assignment instructions
The following floating point assignment operations can be performed :
• floating point (indexed) -> floating point (indexed) example 1
• floating point immediate value -> floating point (indexed) example 2
Structure
Ladder language Instruction List language
LD TRUE
%MF10:=%KF100 [%MF10 := %KF100] example 1
LD %I3.2
%I3.2 [%MF5:= %KF0[%MW20] ] example 1
%MF5:=%KF0[%MW20]
LDR %I3.3
%I3.3 [%MF100:=150.25] example 2
P %MF100:=150.25
Syntax
Operator := Op1:=Op2
Operands
___________________________________________________________________________
2/23
B
2.5-4 Floating point arithmetic instructions
These instructions are used to perform arithmetic operations between two operands
or on one operand.
+ : add two operands SQRT : square root of an operand
- : subtract two operands ABS : absolute value of an operand
* : multiply two operands TRUNC : integer part of a floating value
/ : divide two operands
Structure
Ladder language Instruction List language
%M0
LD %M0
%MF0:=%MF10+129.7 [%MF0 := %MF10 + 129.7]
%I3.2
LD %I3.2
%MF1:=SQRT(%MF10)
[%MF1 := SQRT(%MF10)]
%I3.3
LDR %I3.3
P
P %MF2:=ABS(%MF20)
[%MF2 := ABS(%MF20)]
%I3.5
LDR %I3.5
P %MD8:=TRUNC(%MF2) [%MD8 := TRUNC(%MF2)]
Syntax
Operators
___________________________________________________________________________
2/24
Description of advanced instructions 2
B
Operands
Type Operand 1 (Op1) Operands 2 and 3 (Op2 and 3)
Indexable words %MF (1) %MF,%KF
Non-indexable words Floating point immediate value.
Floating point numeric expression.
(1) %MD for the TRUNC instruction.
Structure
Ladder language Instruction List language
LD %M0
%M0 [%MF0 := LOG(%MF10)]
%MF0:=LOG(%MF10)
LD %I3.2
%I3.2
[%MF2 := LN(%MF20)]
%MF2:=LN(%MF20)
%I3.3
LDR %I3.3
[%MF4 := EXP(%MF40)]
P %MF4:=EXP(%MF40)
• EXPT Op1:=Operator(Op2,Op3)
Operands
Type Operand 1 (Op1) Operand 2 (Op2) Operand 3 (Op3)
Indexable words %MF %MF,%KF %MW, %KW
Non-indexable words Fl. point immed. value Integer immed. value
Fl. point. num. expr. Integer numeric expr.
Rules of use
• When the operand of the function is an invalid value (for example, logarithm of a
negative number), it produces an indeterminate or infinite result and sets bit %S18
to 1. Word %SW17 indicates the cause of the fault (see section 2.5-1, part B).
• In the case of logarithm functions, for values close to 1.0 (between 0.99 and 1.0 or
1.0 and 1.01) the result will be 0, and bits %S18 and %SW17:X5 are set to 1.
Structure
Ladder language Instruction List language
LD %M0
%M0
[%MF0 := SIN(%MF10)]
%MF0:=SIN(%MF10)
%I3.2
LD %I3.2
[%MF2 := TAN(%MF10)]
%MF2:=TAN(%MF10)
___________________________________________________________________________
2/26
Description of advanced instructions 2
B
Structured Text language
IF %M0 THEN
%MF0 := SIN(%MF10) ;
END_IF ;
IF %I3.2 THEN
%MF2 := TAN(%MF10) ;
END_IF ;
IF RE %I3.3 THEN
%MF4 := ATAN(%MF20) ;
END_IF ;
Syntax
Operators
• SIN, COS, TAN Op1:=Operator(Op2)
ASIN, ACOS, ATAN
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MF %MF,%KF
Non-indexable words Floating point immediate value
Floating point numeric expression
Rules of use
• When the operand of the function is an invalid value (for example, arc cosine of a
number greater than 1), it produces an indeterminate or infinite result and sets bit
%S18 to 1. Word %SW17 indicates the cause of the fault (see section 2.5-1, part B).
• The SIN/COS/TAN functions accept an angle between -4096 π and 4096π as a
parameter but their precision decreases progressively for angles outside the range
-2 π and +2π due to the imprecision caused by modulo 2 π which is carried out on the
parameter before every operation.
___________________________________________________________________________
2/27
B
2.5-7 Conversion instructions
These instructions can be used to carry out conversion operations:
DEG_TO_RAD : conversion from degrees to radians, the result is the value of the angle between
0 and 2π
RAD_TO_DEG : conversion from radians to degrees, the result is the value of the angle between
0 and 360 degrees
Structure
Ladder language Instruction List language
LD %M0
[%MF0 := DEG_TO_RAD(%MF10)]
LD %M2
[%MF2 := RAD_TO_DEG(%MF20)]
IF %M0 THEN
%MF0 := DEG_TO_RAD(%MF10) ;
END_IF ;
IF %I3.2 THEN
%MF2 := RAD_TO_DEG(%MF20) ;
END_IF ;
Syntax
Operators
• DEG_TO_RAD Op1:=Operator(Op2)
RAD_TO_DEG
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MF %MF,%KF
Non-indexable words Floating point immediate value
Floating point numeric expression
Rules of use
• The angle to be converted must be between -737280.0 and +737280.0 (for DEG_TO_RAD
conversions) or between -4096π and 4096π (for RAD_TO_DEG conversions).
For values outside these limits, the result displayed will be + 1.#NAN, with bits %S18
and %SW17:X0 set to 1.
___________________________________________________________________________
2/28
Description of advanced instructions 2
B
2.6 Numeric conversion instructions
2.6-1 BCD <--> Binary conversion instructions
There are six types of conversion instruction :
• BCD_TO_INT : 16-bit BCD number --> 16-bit integer conversion.
• INT_TO_BCD : 16-bit integer --> 16-bit BCD number conversion.
• DBCD_TO_DINT : 32-bit BCD number --> 32-bit integer conversion.
• DINT_TO_DBCD : 32-bit integer --> 32-bit BCD number conversion.
• DBCD_TO_INT : 32-bit BCD number --> 16-bit integer conversion.
• INT_TO_DBCD : 16-bit integer --> 32-bit BCD number conversion.
Example :
• Word %MW5 expresses the BCD value "2450" which corresponds to the binary
value : 0010 0100 0101 0000.
• Word %MW12 expresses the decimal value "2450" which corresponds to the binary
value : 0000 1001 1001 0010.
Word %MW5 is converted to word %MW12 using instruction BCD_TO_INT.
Word %MW12 is converted to word %MW5 using instruction INT_TO_BCD.
Structure
Conversion operations are performed as follows :
%MW0:=BCD_TO_INT(%MW10) LD TRUE
[%MW0 := BCD_TO_INT(%MW10)]
%I1.2
LD %I1.2
%MW10:=INT_TO_BCD(%KW9) [%MW10 := INT_TO_BCD(%KW9)]
___________________________________________________________________________
2/29
B
Syntax
Operators (conversion of a 16-bit number)
• BCD_TO_INT Op1:=Operator(Op2)
INT_TO_BCD
INT_TO_DBCD
Operands
Syntax
Operators (conversion of a 32-bit number)
• DBCD_TO_DINT Op1:=Operator(Op2)
DINT_TO_DBCD
DBCD_TO_INT
Operands
Application examples
The BCD_TO_INT instruction is used to process a setpoint value at PLC inputs via
BCD encoded thumbwheels.
The INT_TO_BCD instruction is used to display numeric values (for example, the
result of a calculation or the current value of a function block) on BCD coded displays.
___________________________________________________________________________
2/30
Description of advanced instructions 2
B
Rules for use
• BCD-->Binary conversion
The BCD-->Binary conversion instructions ensure that the conversion operator is
applied to a BCD coded value. If the value is not a BCD coded value, system bit
%S18 is set to 1 and the result gives the value of the first faulty 4-bit byte.
Eg : BCD_TO_INT(%MW2) where %MW2=4660 gives a result of 1234.
However, %MW2=242 (16#00F2) sets %S18 to 1 and the result is 15.
For the DBCD_TO_INT instruction, if the BCD number is greater than 32767, system
bit %S18 is set to 1 and value -1 is loaded in the result.
• Binary--> BCD conversion
The INT_TO_BCD instruction ensures that the conversion operator is applied to a
value between 0 and 9999 (or 0 and 9999 9999). If this is not the case, system bit
%S18 is set to 1 and the result gives the value of the input parameter.
Eg : INT_TO_BCD(%MW2) where %MW2=2478 gives a result of 9336.
However, %MW2=10004 sets %S18 to 1 and the result is 10004.
For the INT_TO_DBCD instruction, if the input parameter is negative, system bit
%S18 is set to 1 and the result gives the value of the input parameter.
LD TRUE
%MFO:=INT_TO_REAL(%MW10) [%MF0 := INT_TO_REAL(%MW10)]
%I1.8 LD %I1.8
%MD4:=REAL_TO_DINT(%MF9) [%MD4 := REAL_TO_DINT(%MF9)]
___________________________________________________________________________
2/31
B
Syntax
Operator Op1:=INT_TO_REAL(Op2)
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MW,%KW,%Xi.T
Non-indexable words Immed. val.,%IW,%QW,%SW
%NW,%BLK,Num. expr.
Indexable floating point words %MF
Example : integer word --> floating point word conversion : 147 --> 1.47e+02
Operator Op1:=DINT_TO_REAL(Op2)
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MD,%KD
Non-indexable words Val.imm.,%ID,%QD,%SD
Numeric expr.
Indexable floating point words %MF
Example : integer double word --> floating point word conversion : 68905 000 --> 6.8905e+07
Operator Op1:=REAL_TO_INT(Op2)
Op1:=REAL_TO_DINT(Op2)
Operands
Type Operand 1 (Op1) Operand 2 (Op2)
Indexable words %MW
Non-indexable words %QW,%NW,%BLK
Indexable double words %MD
Non-indexable double words %QD
Indexable floating point words %MF,%KF
Non-indexable floating point words Floating point immed. value
Example : floating point word --> integer word conversion 5978.6 --> 5978
floating point word --> integer double word conversion -1235978.6 --> -1235979
Note : If, during conversion of a real word to an integer (or a real word to a whole double word),
the floating point value exceeds the limits of the word (or double word), bit %S18 is set to 1.
___________________________________________________________________________
2/32
Description of advanced instructions 2
B
2.6-3 Gray --> Integer conversion instructions
The instruction GRAY_TO_INT converts a word in Gray code to an integer (pure
binary code).
Review of Gray code : Gray or "reflected binary" code is used to code a changing
numeric value into a series of binary configurations which are distinguished from each
other by the change of state of a single bit. This code is used, for example, to avoid
the following random conditions : in pure binary code, the value 0111 changing to
1000 may generate random values between 0 and 1000 since the bits do not change
value at exactly the same time.
Decimal 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Gray 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101
Structure
Ladder language Instruction List language
LD TRUE
%MW0:=GRAY_TO_INT(%MW10) [%MW0 := GRAY_TO_INT(%MW10)]
Syntax
Operator Op1:=GRAY_TO_INT(Op2)
Operands
___________________________________________________________________________
2/33
B
2.6-4 Word <--> double word conversion instructions
The instructions described below can be used for purely symbolic objects (eg DFB
function blocks). For addressable objects, overlap mechanisms (for example, double
word %MD0 comprises words %MW0 and %MW1) mean that these instructions
cannot be used.
Example : Tank_pressure:=LW(Parameter_1)
if Parameter_1 = 16#FFFF1234, Tank_pressure = 16#1234
Example : Tank_pressure:=LW(Parameter_1)
if Parameter_1 = 16#FFFF1234, Tank_pressure = 16#FFFF
Example : Tank_pressure:=LW(Parameter_1,Parameter_2)
if Parameter_1 = 16#1234, Parameter_1 = 16#FFFF,
Tank_pressure = 16#FFFF1234
___________________________________________________________________________
2/34
Description of advanced instructions 2
B
2.7 Word table instructions
2.7-1 General
PL7 software is used to perform operations on tables of :
• words,
• double words,
• floating point words.
Word tables are sequences of adjacent %KW10 16 bits
words of the same type and of a defined
length, L.
%KW14
Example of word tables : %KW10:5
___________________________________________________________________________
2/35
B
2.7-2 Word table assignment
The following can be assigned to word tables :
• immediate value -> word table (indexed) example 1
double format immediate value -> double word table (indexed)
floating point immediate value -> floating point table (indexed)
Example 1 : %MW0 :5:= 100
100 %MW0
100
100 100
100
100 %MW4
100 %MW0
%MW11 100
100 100
100
100 %MW4
Note :
Multiple assignments are authorized in examples 1 and 2
(%MW0:4 := %MW10:6 := %MW100) but not in example 3.
___________________________________________________________________________
2/36
Description of advanced instructions 2
B
Structure
Ladder language Instruction List language
LD TRUE
%MW0:5:=100 [%MW0 :5:= 100] example 1
LD %I3.2
%I3.2
[%MW0:5 := %MW11] example 2
%MW0:5:=%MW11
Structured Text language
%I3.3
P %MW0:5:=%KW0:5 IF RE %I3.3 THEN
%MW0:5 := %KW0:5 ; example 3
END_IF ;
Syntax
Operator := Op1 := Op2
Word tables
Note :
Multiple assignments on tables are prohibited.
___________________________________________________________________________
2/37
B
2.7-3 Arithmetic instructions on tables
These instructions are used to perform an arithmetic operation between two word
table (or word and word table) type operands.
+ : add * : multiply
- : subtract / : divide
REM : remainder of division
Structure
Ladder language Instruction List language
%M0 LD %M0
%MW0:10:=%MW20:10+100 [%MW0:10:=%MW20:10+100]
%I3.2
LD %I3.2
%MD50:5:=%KD0:5+%MD0:5 [%MD50:5:=%KD0:5 + %MD0:5]
%I3.3
Structured Text language
P %MW0:10:=%KW0:10*%MW20
IF RE %I3.3 THEN
%MW0:10 := %KW0:10 * %MW20 ;
END_IF ;
Syntax
Operators
Operands
Word tables
___________________________________________________________________________
2/38
Description of advanced instructions 2
B
2.7-4 Logic instructions on tables
The associated instructions are used to perform a logic operation between two word
table (or word and word table) type operands.
AND : AND (bit-wise).
OR : Logic OR (bit-wise).
XOR : Exclusive OR (bit-wise).
NOT : Logic complement (bit-wise) of a table (only one operand).
Structure
Ladder language Instruction List language
%M0 LD %M0
%MW0:5:=%KW0:5AND16#FF00 [%MW0:5:=%KW0: 5 AND 16#FF00]
Operands
Word tables
Structure
Ladder language Instruction List language
%I3.2
LD %I3.2
%MW5:=SUM(%MW32:12)
[%MW5:=SUM(%MW32:12)]
Syntax
Function Res:=SUM(Tab) Res:=SUM_ARR(Tab)
Parameters
___________________________________________________________________________
2/40
Description of advanced instructions 2
B
2.7-6 Table comparison functions
The EQUAL (on an integer) and EQUAL _ARR(on a floating point) functions compare
two tables element by element.
If a difference is detected, the row of the first elements which are not the same is given
in the form of a word. Otherwise, the value given is equal to -1.
The third parameter provides the row from which the comparison begins (for example,
0 to start at the beginning). This third parameter is optional (it is not authorized for the
EQUAL_ARR function). If it is omitted, the comparison is performed on all of the table.
Structure
Ladder language Instruction List language
%I3.2 LD %I3.2
%MW5:=EQUAL(%MW20:7,%KW0:7,3) [%MW5:=EQUAL(%MW20:7,%KW0:7,3)]
Syntax
Function Res:=EQUAL(Tab1,Tab2,row)
Res:=EQUAL_ARR(Tab1,Tab2)
___________________________________________________________________________
2/41
B
Parameters
Type Result (Res) Table (Tab) Row
Tables of words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW %MW,%KW, %Xi.T
Non-indexable words %QW,%SW, Immed. val. %QW,
%NW %IW,%SW,%NW
Numeric expr.
Tables of double words %MD:L,%KD:L
Indexable double words %MD %MD,%KD
Non-indexable double words %QD,%SD Immed. val. %QD,
%ID,%SD
Numeric expr.
Tables of floating point words %MF:L,%KF:L
Floating point words %MF
Note :
• The tables must be the same length.
• If the row parameter is greater than the size of the tables, the result is then equal to this row.
Example %MW5:=EQUAL(%MW30:4,%KW0:4,1)
0 %MW30= 10 %KW0= 20
1 %MW31= 20 %KW1= 20
2 %MW32= 30 %KW2= 30
3 %MW33= 40 %KW3= 60 ==> %MW33 • %KW3==> %MW5= 3
___________________________________________________________________________
2/42
Description of advanced instructions 2
B
2.7-7 Find functions on tables
There are 11 find functions :
• FIND_EQW : find the position in a word table of the first element equal to a given
value.
• FIND_GTW : find the position in a word table of the first element greater than a given
value.
• FIND_LTW : find the position in a word table of the first element less than a given
value.
• FIND_EQD : find the position in a double word table of the first element equal to a
given value.
• FIND_GTD : find the position in a double word table of the first element greater than
a given value.
• FIND_LTD : find the position in a double word table of the first element less than a
given value.
• FIND_EQR: find the position in a floating point word table of the first element equal
to a given value.
• FIND_GTR : find the position in a floating point word table of the first element greater
than a given value.
• FIND_LTR : find the position in a floating point word table of the first element less
than a given value.
• FIND_EQWP : find the position in a word table of the first element equal to a value
given from a row.
• FIND_EQDP : find the position in a double word table of the first element equal to
a value given from a row.
The result of these instructions is the row of the first element found or -1 if the find is
unsuccessful.
Structure
Ladder language Instruction List language
%I3.2 LD %I3.2
%MW5:=FIND_EQW(%MW20:7,%KW0)
[%MW5:=FIND_EQW(%MW20:7,%KW0)]
%MW1:=FIND_LTR(%MF40:5,%KF5) %MW1:=FIND_LTR(%MF40:5,%KF5) ;
%MW9:=FIND_EQWP(%MW30:8,%KF5,%MW4);
___________________________________________________________________________
2/43
B
Syntax
Function
FIND_EQW,FIND_GTW,FIND_LTW Res:=Function(Tab,Val)
FIND_EQD,FIND_GTD,FIND_LTD
FIND_EQR,FIND_GTR,FIND_LTR
FIND_EQWP,FIND_EQDP Res:=Function(Tab,Val,row)
Parameters
Tables of words (FIND_EQW,FIND_GTW,FIND_LTW,FIND_EQWP )
Type Result (Res) Table (Tab) Value (Val), row
Tables of indexable words %MW:L,%KW:L,%Xi.T:L
Indexable words %MW %MW,%KW, %Xi.T
Non-indexable words %QW,%SW Immed. val.%QW,
%NW %IW,%SW,%NW,
Numeric expr.
Example %MW5:=FIND_EQW(%MW30:4,%KW0)
Row
0 %MW30= 10
1 %MW31= 20
2 %MW32= 30 ==> %KW0= 30 ==>%MW5= 2
3 %MW33= 40
___________________________________________________________________________
2/44
Description of advanced instructions 2
B
2.7-8 Find maximum and minimum values function on tables
There are six find functions :
• MAX_ARW : find the maximum value in a word table.
• MIN_ARW : find the minimum value in a word table.
• MAX_ARD : find the maximum value in a double word table.
• MIN_ARD : find the minimum value in a double word table.
• MAX_ARR : find the maximum value in a floating point table.
• MIN_ARR : find the minimum value in a floating point table.
The result of these instructions is equal to the maximum (or minimum) value found in
the table.
Structure
Ladder language Instruction List language
%I3.2
LD %I3.2
%MW5:=MAX_ARW(%MW20:7) [%MW5:=MAX_ARW(%MW20:7)]
Syntax
Function
MAX_ARW,MIN_ARW Res:=Function(Tab)
MAX_ARD,MIN_ARD
MAX_ARR,MIN_ARR
Parameters
___________________________________________________________________________
2/45
B
2.7-9 Number of occurrences of a value in a table
There are three find functions :
• OCCUR_ARW : searches a word table for the number of elements equal to a given
value.
• OCCUR_ARD : searches a double word table for the number of elements equal to
a given value.
• OCCUR_ARR : searches a floating point table for the number of elements equal to
a given value.
Structure
Ladder language Instruction List language
%I3.2 LD %I3.2
%MW5:=OCCUR_ARW(%MW20:7,%KW0) [%MW5:=OCCUR_ARW(%MW20:7,%KW0)]
%I1.2
Structured Text language
Syntax
Function Res:= Function (Tab,Val)
OCCUR_ARW
OCCUR_ARD
OCCUR_ARR
Parameters
B
2.7-10 Circular shift function on tables
There are six shift functions :
• ROL_ARW : performs a circular shift of
elements in word tables by n positions 0
from top to bottom. 1
• ROL_ARD : performs a circular shift of 2
elements in double word tables by n 4
positions from top to bottom. 5
• ROL_ARR : performs a circular shift of
elements in floating point word tables
by n positions from top to bottom.
• ROR_ARW : performs a circular shift of
elements in word tables by n positions 0
from bottom to top. 1
• ROR_ARD : performs a circular shift of 2
elements in double word tables by n 4
positions from bottom to top. 5
• ROR_ARR : performs a circular shift of
elements in floating point word tables
by n positions from bottom to top.
Structure
Ladder language Instruction List language
___________________________________________________________________________
2/47
B
Syntax
___________________________________________________________________________
2/48
Description of advanced instructions 2
B
2.7-11 Sort function on tables
There are three sort functions :
• SORT_ARW : sorts the elements of the word table into ascending or descending
order and stores the result in the same table.
• SORT_ARD : sorts the elements of the double word table into ascending or
descending order and stores the result in the same table.
• SORT_ARR : sorts the elements of the floating point table into ascending or
descending order and stores the result in the same table.
Structure
Ladder language Instruction List language
%I3.2 LD %I3.2
SORT_ARW(%MW20,%MW0:6) [SORT_ARW(%MW20,%MW0:6)]
Syntax
Function Function (dir.,Tab)
SORT_ARW
SORT_ARD
SORT_ARR
• The "direction" parameter determines the order of the sort : if the direction is > 0, the
sort is performed in ascending order. If < 0, the sort is performed in descending order.
• The result (sorted table) is given in the Tab parameter (table to be sorted).
Parameters
Word tables
LD %I3.2
%I3.2
[LENGTH_ARW(tab_mot)]
LENGTH_ARW(tab_mot)
Syntax
Function Result = Function (Tab)
LENGTH_ARW
LENGTH_ARD
LENGTH_ARR
LENGTH_ARX
Parameters
Tables of words
___________________________________________________________________________
2/50
Description of advanced instructions 2
B
2.8 Character string instructions
2.8-1 Format of a string or table of characters
A character table is composed of a series of bytes in which a character string can be
stored. The size of the table is used to specify the maximum length of the character
string (up to 255 characters).
Example : %MB4:6 represents a table of 6 bytes
containing a string of up to 6 characters.
The first byte at the beginning of a table must be even (it is not possible to enter a byte
table which starts with an odd byte, eg :%MB5:6).
Byte tables use the same memory zone as words %MW and %MD. There is therefore
a risk of overlap : see section 1.2-4, part A.
The term character string represents all the characters between the start of the table
and the first string termination character encountered.
The NUL character (hexa code 00) is known as the String termination character. It is
symbolized by Ø throughout this section.
Examples :
• The following table (of 12 elements) contains the character string 'ABCDE' (5 characters
long).
'A' 'B' 'C' 'D' 'E' Ø 'J' 'K' 'L' 'M' 'N' 'O'
• The following table (of 10 elements) contains the character string 'ABCDEJKLMN'
(10 characters long).
'A' 'B' 'C' 'D' 'E' 'J' 'K' 'L' 'M' 'N'
___________________________________________________________________________
2/51
B
2.8-2 Character string assignment
This function is used to transfer a character string to a byte table of length L.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MB30:12:= 'mise_en_run' [ %MB30:10 := 'set_to_run']
%MB30:10:='set_to_run' ;
%MB 30 31 32 33 34 35 36 37 38 39
's' 'e' 't' '_' 't' 'o' '_' 'r' 'u' 'n'
Syntax
Operator Op1:=Op2
Operands
___________________________________________________________________________
2/52
Description of advanced instructions 2
B
2.8-3 Alphanumeric comparisons
These operators are used to compare two character strings contained in the byte
tables provided as parameters. Comparison is performed character by character.
The result is a bit which equals 1 if both strings satisfy the conditions determined by
the operator, character by character. Otherwise, the bit equals 0.
The order of characters is determined by the ASCII code table (ISO 646). For example,
string 'Z' is larger than string 'AZ' which is larger than the string 'ABC'.
Structure
Ladder language Instruction List language
%M10
COMPARE
LD [ %MB20:12 < %MB40:12]
%MB20:12< %MB40:12
ST %M10
%MB 40 41 42 43 44 45 46 47 48 49 50 51
'a' 'b' 'c' 'd' 'e' 'f' 'h' 'l' Ø 'k' 'w' 'z'
The elements after the termination character are not taken into account.
Syntax
Operator
<, >, <=, >=, =, < > Op1 Operator Op2
Operands
Type Operand 1 (Op1) and Operand 2 (Op2)
Byte tables %MB:L,%KB:L, immediate value
___________________________________________________________________________
2/53
B
2.8-4 Numeric <---> ASCII conversion functions
These functions are used to convert a numeric (or floating point) value to a character
string in ASCII code or vice versa.
The result of the conversion must be transferred to a PL7 object via an assignment
operation : byte table, single or double length word, floating point.
___________________________________________________________________________
2/54
Description of advanced instructions 2
B
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MB10:7:= INT_TO_STRING(%MW20)
[ %MB10:7 := INT_TO_STRING (%MW20)]
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14
'-' '0' '0' '2' '3' '4' '7' '1' '1' '0' '8' '4' Ø
Syntax
Operator result := INT_TO_STRING (value)
Operands
___________________________________________________________________________
2/55
B
2.8-6 ASCII ---> Binary conversion
This function is used to convert a character string representing a numeric value into
binary code (result transferred to a single or double length word).
Each element of the table provided as a parameter represents the ASCII code of a
character. Authorized characters are digits and the characters '+' and '-'.
• STRING_TO_INT function : converts a string of 6 characters representing a
numeric value between -32768 and +32767. The first character must represent the
sign and the following characters the value. The second character represents the
tens of thousands, ..., and the sixth character the units. The value must be right-
justified in the string.
• STRING_TO_DINT function : converts a string of 12 characters representing a
numeric value between -2147483648 and +2147483647. The first character must
represent the sign and the following characters the value. The second is the
character '0', the third the thousands of millions,..., the twelfth the units. The value
must be right-justified in the string.
Structure
OPERATE LD TRUE
%MW13:= STRING_TO_INT(%MB20:7) [%MW13 := STRING_TO_INT (%MB20:7)]
B
2.8-7 Floating point ---> ASCII conversion
This function is used to convert a real numeric value contained in a floating point type
word to a character string coded in ASCII. The result is transferred to a table of 14 bytes
+ the string termination character.
Each digit in the value and the characters '+', '-', '.', 'e' and 'E' are coded in ASCII in
an element in the result table.
The sign of the value is located in the first character, the decimal point (.) in the third,
the exponent 'e' in the eleventh and the sign of the exponent in the twelfth.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MB20:15:=REAL_TO_STRING(%MF30) [ %MB20:15 := REAL_TO_STRING (%MF30)]
%MB 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
'-' '3' '.' '2' '3' '4' '7' '1' '8' '0' 'e' '+' '2' '6' Ø
Syntax
Operands
Bit %S18 is set to 1 if the floating point value provided as a parameter is not between
- 3.402824e+38 and -1.175494e-38 or +1.175494e-38 and +3.402824e+38. In this
case, the value of the result is incorrect.
___________________________________________________________________________
2/57
B
2.8-8 ASCII --> Floating point conversion
This function is used to convert a character string representing a real numeric value
to floating point (result transferred to a floating point type word).
Each element in the table provided as a parameter represents the ASCII code of one
character. Authorized characters are digits and the characters '+', '-', '.', 'e' and 'E'. The
string termination character is not used to determine the end of the string. This means
that the 14 characters of the table must all be correct.
The sign of the value must be located in the first character, the decimal point (.) in the
third, the 'e' in the eleventh and the sign of the exponent in the twelfth.
For example, the value 3.12 must be in the form '+3.1200000e+00'.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MF18:=STRING_TO_REAL(%MB20:14) [ %MF18 := STRING_TO_REAL (%MB20:14)]
Syntax
Operands
Bit %S18 is set to 1 if the value described by the string is not between -3.402824e+38
and -1.175494e-38 or +1.175494e-38 and +3.402824e+38 or if one of the 14
characters is incorrect.
___________________________________________________________________________
2/58
Description of advanced instructions 2
B
2.8-9 Concatenation of two strings
This function allows concatenation of two character strings as defined by parameters.
The result is a byte table containing a character string.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MB30:14:=CONCAT(%MB4:6,% MB14:9) [ %MB30:14 := CONCAT (%MB4:6, %MB14:9)]
%MB 4 5 6 7 8 9
'i' 'n' 'c' 'o' 'n' Ø
%MB 14 15 16 17 18 19 20 21 22
't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42 43
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø
Syntax
Operator result :=CONCAT (string1, string2)
Operands
• If the result table is too short, the result is truncated and system bit %S15 is
set to 1. %MB30:10 := CONCAT (%MB4:6, %MB14:9)
%MB 30 31 32 33 34 35 36 37 38 39
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' ==> %S15 at 1
• If the result table is too long, termination characters Ø are added to the string.
%MB30:15 := CONCAT (%MB4:6, %MB14:9)
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø Ø
___________________________________________________________________________
2/59
B
2.8-10 Deletion of a character substring
This function is used to delete a number of characters (zone length L), from a given
row (position of the first character to be deleted) in the string defined as a parameter.
The result is a byte table containing a character string.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MB14:9:=DELETE(%MB30:14,% MW2,%MW4) [%MB14: 9 := DELETE (%MB30:14, %MW2, %MW4)]
%MB 14 15 16 17 18 19 20 21 22
'i' 'n' 's' 't' 'a' 'b' 'l' 'e' Ø
Syntax
Operator result :=DELETE (string, length, pos)
Operands
Notes :
Some parameters may overlap depending on the indices of PL7 objects :
• Table containing the source string.
• Table containing the result string.
• Word containing the length to be deleted.
• Word containing the position of the first character to be deleted .
A negative length or position is interpreted as being 0. The position parameter starts at the value
1 which corresponds to the first position in the character string.
___________________________________________________________________________
2/60
Description of advanced instructions 2
B
If the result table is too long, termination characters Ø are added to the string.
System bit %S15 is set to 1 in the following cases :
• The length to be deleted is zero, the output table is a copy of the source table.
• The position is greater than the length of the string, or the position of the first
termination character found is less than or equal to the position of the first character
to be deleted. The result is therefore an empty string.
• The position is equal to 0. The result table therefore contains an empty string.
• The result table is too short. It has therefore been truncated.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MB2:14:=INSERT(%MB20:9,%MB30:6,%MW40) [%MB2:14 := INSERT (%MB20:9, %MB30:6, %MW40)]
%MB 30 31 32 33 34 35
'c' 'o' 'n' 't' 'e' Ø
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15
'i' 'n' 'c' 'o' 'n' 't' 'e' 's' 't' 'a' 'b' 'l' 'e' Ø
___________________________________________________________________________
2/61
B
Syntax
Operator result :=INSERT (string1, string2, pos)
Operands
Notes :
The position parameter starts at the value 1 which corresponds to the first position in the
character string.
It is impossible to insert at the beginning of a string. In order to do this, use the CONCAT function.
The value of the position parameter is negative or equal to 0. In this case, it is interpreted as being
0 and the result table contains an empty string (composed of termination characters).
The position provided as a parameter is greater than or equal to the length of the source string.
The result table then contains an empty string (composed of termination characters).
If the result table is too short, truncation occurs.
___________________________________________________________________________
2/62
Description of advanced instructions 2
B
2.8-12 Replacement of a character substring
This function is used to replace a section of a character string defined in the source
table (string1) by a character substring defined in the replacement table (string2). The
replacement to be made is defined by the position (pos.) and length parameters. This
length corresponds to the length of the string which is removed and not to the
length of the substring which replaces it.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MB2: 13:=REPLACE(%MB20:12,% MB30:9, [ %MB2:13 := REPLACE (%MB20:12,
%MW40, %MW41) %MB30:9, %MW40, %MW41)]
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 's' 't' 'o' 'p' Ø
Syntax
Operator result := REPLACE (string1, string2, length, pos.)
Operands
___________________________________________________________________________
2/63
B
Notes :
The position parameter starts at the value 1 which corresponds to the first position in the
character string.
If the output table is too long, termination type characters are added to the string.
___________________________________________________________________________
2/64
Description of advanced instructions 2
B
2.8-13 Extraction of a character substring
This function is used to extract a number of characters from a source string provided as
a parameter (string).
The position of the first character to be extracted is determined by the position parameter
(pos), and the number of characters to be extracted is given by the length parameter.
The extracted string is stored in a byte table (result).
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
[%MB14: 7 := MID (%MB30:13, %MW2, %MW4)]
%MB14:7:=MID(%MB30:13,% MW2,%MW4)
==> result
%MB 14 15 16 17 18 19 20
's' 't' 'o' 'p' Ø Ø Ø
Syntax
Operands
___________________________________________________________________________
2/65
B
Notes :
The position parameter starts at value 1 which corresponds to the first position in the character
string.
If the output table is too long, termination type characters are added to the result string.
If the length provided as a parameter is greater than the size of the source string, the result table
then contains the source string.
If the last element of the table or the string termination character is reached before the number
of characters defined by the length parameter has been extracted, extraction stops at this point.
System bit %S15 is set to 1 in the following cases :
• If the value of the length parameter to be extracted is negative or equal to 0. In this case, it is
interpreted as being 0 and the result table contains an empty string (composed of termination
characters).
• If the value of the position parameter for the beginning of the extraction is zero or greater than
or equal to the length of the table, or greater than or equal to the position of the first termination
character. In this case, the result table contains an empty string (composed of termination
characters).
• If the result table is too short, truncation occurs.
___________________________________________________________________________
2/66
Description of advanced instructions 2
B
2.8-14 Extraction of characters
Extraction of a number of characters the furthest to the left (LEFT) or furthest to the
right (RIGHT) in a source string provided as a parameter (string).
The number of characters to be extracted is defined by the length parameter.
The extracted string is stored in a byte table (result).
Structure
Ladder language Instruction List language
LD TRUE
OPERATE [%MB10: 10 := LEFT (%MB30:13, %MW2)]
%MB10:10:=LEFT(%MB30:13,% MW2)
%MB 30 31 32 33 34 35 36 37 38 39 40 41 42
'm' 'i' 's' 'e' '_' 'e' 'n' '_' 's' 't' 'o' 'p' Ø
==> result
%MB 10 11 12 13 14 15 16 17 18 19
'm' 'i' 's' 'e' '_' 'e' 'n' '_' Ø Ø
Syntax
Operator result :=LEFT (string, length)
Operands
___________________________________________________________________________
2/67
B
Notes :
If the output table is too long, termination type characters are added to the result string.
If the length provided as a parameter is greater than the size of the source string, the result table
then contains the source string.
___________________________________________________________________________
2/68
Description of advanced instructions 2
B
2.8-15 Comparison of two character strings
This function is used to compare two character strings. The result is a word containing
the position of the first different character.
If the two character strings are exactly the same, the result is -1.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MW2:=EQUAL_STR(%MB18:14,%MB50:14) [%MW2 := EQUAL_STR (%MB18:14, %MB50:14)]
%MB 50 51 52 53 54 55 56 57 58 59 60 61 62 63
'a' 'b' 'c' 'd' '?' 'f' 'g' 'h' Ø 'v' 'w' 'x' 'y' 'z'
==> MW2 := 5
Syntax
Operator result :=EQUAL_STR (string1, string2)
Operands
Note :
A negative length or position is interpreted as being equal to 0.
___________________________________________________________________________
2/69
B
2.8-16 Search for a character substring
This function is used to search for the character substring defined by the second
parameter in the character string defined by the first parameter.
The result is a word containing the position in the first string of the beginning of the
substring searched for.
If the search is not successful, the result is -1.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MW2:= FIND(%MB18:14, %MB 50:4)
[ %MW2 := FIND (%MB18:14, %MB50:4)]
%MB 50 51 52 53
'f' 'g' 'h' Ø
==> MW2 := 6 Indicates that the beginning of the string searched for is located
from the sixth character onwards.
Syntax
Operator result :=FIND (string1, string2)
Operands
Note :
A negative length or position is interpreted as being equal to 0.
___________________________________________________________________________
2/70
Description of advanced instructions 2
B
2.8-17 Length of a character string
This function gives the length of the character string provided as a parameter, that is,
the number of characters located before the termination character.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
[%MW2 := LEN (%MB20:14)]
%MW2:= LEN (%MB20:14)
%MB 20 21 22 23 24 25 26 27 28 29 30 31
'a' 'b' 'c' 'd' 'e' 'f' 'g' Ø 'n' 'o' 'p' 'r'
==> %MW2 = 7
Syntax
Operands
Note :
If no termination character is found, the function gives the size of the table (see section 2.8-1).
___________________________________________________________________________
2/71
B
2.9 Time management instructions : Date, Time of day, Duration
2.9-1 Parameter format
The Date, Time of day and Duration parameters used by these instructions correspond
to the standard formats defined by IEC standard 1131-3.
Only values within the time period [1990-01-01, 2099-12-31] are permitted.
___________________________________________________________________________
2/72
Description of advanced instructions 2
B
• Time of day format (TOD type)
This format is used to code the hour, the minutes and the seconds. It corresponds
to the TIME_OF_DAY format of the standard.
The value is displayed in the following way : hh:mm:ss
which gives for example : 23:12:34
The value is coded in BCD on 32 bits (a double word) with 3 fields :
31 24 16 8 0 Hours : 2 digits (high order word)
Hr Min Sec Minutes : 2 digits (high order word)
Seconds : 2 digits (low order word)
Example :
expressed in hexadecimal format
23h 12h 34h = 23:12:34
Only values within the time period [00:00:00, 23:59:59] are permitted.
Example :
expressed in hexadecimal format
1984h 06h 25h 23h 12h 34h
Only values within the time period [1990-01-01-00:00:00, 2099-12-31- 23:59:59] are
permitted.
___________________________________________________________________________
2/73
B
• Hour, Minute, Second Format (HMS type)
This format, used exclusively by the function TRANS_TIME, is used to code
the hour, the minutes and the seconds.
___________________________________________________________________________
2/74
Description of advanced instructions 2
B
2.9-3 Realtime clock function
This function is used to control actions at predefined or calculated times and dates.
It sets the OUT output parameter to 1 if the date provided by the PLC clock when the
function is called is within the period set in the input parameters.
Syntax
Operator SCHEDULE (DBEG, DEND, WEEK, HBEG, HEND, OUT)
Parameter characteristics
___________________________________________________________________________
2/75
B
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
[SCHEDULE (%KW0,%KW1,%KW2,%KD3,
SCHEDULE (%KW0,%KW1,%KW2,%KD3,%KD5,%M0)
%KD5,%Q0.0)]
Operands
SCHEDULE (DBEG, DEND, WEEK, HBEG, HEND, OUT)
Notes :
• The DBEG and DEND parameters define a range of days during the year. This range can be
staggered over two calendar years, for example : October 10 to April 7. February 29 can be
used during this period, but will be ignored in non-leap years.
• The HBEG and HEND parameters define a range of times during the day. This range can be
staggered over two days, for example : 22:00 to 06:10:20.
• If one of the DBEG and DEND dates or one of the HBEG and HEND times is incorrect, ie. does
not correspond to an actual date or time, the OUT output will be at 0 and bit %S17 will be set
to 1.
• If the target PLC does not have an internal clock (as is the case with the TSX37-10), the output
will be at 0 and the system bit %S17 will be set to 1.
• It is possible to lighten the load on the PLC processor if precision is not important by controlling
the SCHEDULE function call via system bit %S6 or %S7.
___________________________________________________________________________
2/76
Description of advanced instructions 2
B
2.9-4 Read system date
Reads the system date (Real-Time Clock) and transfers to the object given as a
parameter in the Date and time (DT) format.
Structure
Ladder language Instruction List language
LD %M6
%M6 OPERATE [RRTC (%MW2:4)]
RRTC (%MW2:4)
Type Date
4-word tables %MW:4
in date and time format
___________________________________________________________________________
2/77
B
Structured Text language
IF RE %M7 THEN
%MW2 := 16#4300 ;
%MW3 := 16#1732 ;
%MW4 := 16#1124 ;
%MW5 := 16#1995 ;
WRTC (%MW2:4) ;
END_IF ;
Example : The new date is loaded into an internal word table, %MW2:4, which is 4
words long and then sent to the system using the WRTC functions.
Syntax
Operator WRTC(date)
Operand
Type Date
4-word tables %MW:4, %KW:4
in date and time format
B
2.9-7 Read day of the week
This function gives the current day of the week in the form of a digit from 1 to 7 which
is transferred to a word (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday,
5 = Friday, 6 = Saturday, 7 = Sunday).
Structure
Ladder language Instruction List language
%M7 LD %M7
OPERATE
%MW5:=DAY_OF_WEEK() [%MW5 := DAY_OF_WEEK()]
IF %M7 THEN
%MW5 := DAY_OF_WEEK () ;
END_IF ;
Syntax
Operand
Type Result
Indexable words %MW
Non-indexable words %QW, %SW, %NW
Note
If the function was unable to update the result following an access error to the
real-time clock, the result given is 0 and system bit %S17 is set to 1.
___________________________________________________________________________
2/79
B
2.9-8 Add / Remove a duration at a date
Adds or removes a duration (in tenths of a second) (In2) at a source date (In1). The
result is a new date, transferred to a table of 4 words.
ADD_DT () = Add a duration SUB_DT () = Remove a duration
Structure
Ladder language Instruction List language
%M7 LD %M7
OPERATE [RRTC (%MW2:4)]
RRTC (%MW2:4)
[%MD8 := 906]
OPERATE [%MW2:4:= ADD_DT(%MW2:4, %MD8)]
%MD8:=906 [WRTC (%MW2:4)]
OPERATE
%MW2:4:=ADD_DT(%MW2:4,%MD8)
OPERATE
WRTC (%MW2:4)
IF %M7 THEN
RRTC (%MW2:4) ;
%MD8 := 906 ;
%MW2:4 := ADD_DT (%MW2:4, %MD8) ;
WRTC (%MW2:4) ;
END_IF ;
Syntax
Operators result :=ADD_DT (In1, In2)
___________________________________________________________________________
2/80
Description of advanced instructions 2
B
Operands
Type Result In1 (initial date) In2 (time period)
Table of four words in %MB:4 %MW4:4, %KW:4
the date and time format
Indexable double words %MD,%KD
Non-indexable double %ID,%QD
words Immediate value
Numeric expr.
Notes :
• The "duration" parameter (expressed in 1/10 of a second) will be rounded up or down so that
the date and time can be increased or decreased (precision to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0
• If the result of the operation is outside the permitted time period values, system bit %S17 is set
to 1 and the value of the result equals the minimum limit (for SUB_DT) or remains blocked at
the maximum (for ADD_DT).
• If the "source date" input parameter cannot be interpreted and is not consistent with the DT
(DATE_AND_TIME) format, system bit %S17 is set to 1 and the value of the result is
0001-01-01-000:00:00.
%M7 LD %M7
OPERATE
%MD8:= 906
[%MD8 := 906]
[%MD2 := ADD_TOD (%MD2, %MD8)]
OPERATE
%MD2:=ADD_TOD(%MD2,%MD8)
___________________________________________________________________________
2/81
B
Structured Text language
IF %M7 THEN
%MD8 := 906 ;
%MD2 := ADD_TOD (%MD2, %MD8) ;
END_IF ;
Syntax
Operands
result and In1 are in the TOD format and In2 is in the time period format.
Notes :
• The "time period" parameter (expressed in 1/10 of a second) will be rounded up or down so
that the date and time can be increased or decreased (precision to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0
• The day changes if the result of the operation is outside the permitted time period values. In
this case, system bit %S17 is set to 1 and the value of the result can be interpreted with a modulo
24:00:00.
• If the "time of day" input parameter cannot be interpreted in the TOD format, system bit %S17
is set to 1 and the result is 00:00:00.
___________________________________________________________________________
2/82
Description of advanced instructions 2
B
2.9-10 Difference between two dates (no time)
This function is used to calculate the difference in days between two dates. The result,
given as an absolute value, is transferred to a double word.
Structure
Ladder language Instruction List language
%M7 LD %M7
OPERATE
%MD10:=DELTA_D(%MD2,%MD4) [%MD10 := DELTA_D (%MD2, %MD4)]
IF %M7 THEN
%MD10 := DELTA_D (%MD2, %MD4) ;
END_IF ;
Syntax
Operator result :=DELTA_D(Date1,Date2)
Operands
result is in the TIME format and Date 1 and 2 are in the DATE format.
The TIME format is defined to be accurate to within one tenth of a second. The DATE
format is defined to be accurate to within one day. The time difference calculated will
therefore be a multiple of 864000 (= 1day = 24 h x 60 min x 60 s x 10 tenths of a second).
Warning
• Overflow occurs if the result exceeds the maximum value permitted for a
duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1.
• If one of the input parameters cannot be interpreted and is not consistent with
the DATE format, system bit %S17 is set to 1 and the result is 0.
___________________________________________________________________________
2/83
B
2.9-11 Difference between two dates (with time)
This function is used to calculate the time difference between two dates. The result,
given as an absolute value, is transferred to a double word.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MD10:= DELTA_D T(%MW2:4,%MW6:4) [%MD10 := DELTA_DT (%MW2:4, %MW6:4)]
Operands
result is in the TIME format and Date 1 and 2 are in the DT format.
The TIME format is defined to be accurate to within one tenth of a second. The DT
format is defined to be accurate to within one second. The time difference calculated
will therefore be a multiple of 10.
Warning
• Overflow occurs if the result exceeds the maximum value permitted for a
duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1.
• If one of the input parameters cannot be interpreted and is not consistent with
the DT format, system bit %S17 is set to 1 and the result is 0.
___________________________________________________________________________
2/84
Description of advanced instructions 2
B
2.9-12 Difference between two times
This function is used to calculate the time difference between two times of day. The
result is transferred to a double word as an absolute value, giving a duration.
Structure
Ladder language Instruction List language
OPERATE
LD TRUE
%MD10:= DELTA_TOD (%MD2,%MD4 ) [%MD10 := DELTA_TOD (%MD2, %MD4)]
Operands
result is in the TIME format and Time 1 and 2 are in the TOD format.
The TIME format is defined to be accurate to within one tenth of a second. The TOD
format is defined to be accurate to within one second. The time difference calculated
will therefore be a multiple of 10.
Attention
If one of the input parameters cannot be interpreted and is not consistent with the
TOD format, system bit %S17 is set to 1 and the result is 0.
___________________________________________________________________________
2/85
B
2.9-13 Convert a Date to a character string
This instruction converts a date to a character string (no time) in the format :
YYYY-MM-DD (10 characters). This string ends with the termination character Ø.
Each character Y,M,D represents a number.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE [%MB2:11 := DATE_TO_STRING (%MD40)]
%MB2:11:= DATE_TO_STRING(%MD40 )
Syntax
Operator result :=DATE_TO_STRING(Date)
Operands
Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DATE
format, system bit %S17 is set to 1 and the function returns the string : ' **** - ** - ** '. If the output
string is too short, truncation occurs and system bit %S15 is set to 1.
%MB2:8 := DATE_TO_STRING (%MD40)
==> %MB 2 3 4 5 6 7 8 9
'1' '9' '9' '8' '-' '1' '2' '-' ==> %S15 = 1
If the output string is too long, termination type characters Ø are added to the string.
%MB2:12 := DATE_TO_STRING (%MD40)
==> %MB 2 3 4 5 6 7 8 9 10 11 12 13
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' Ø Ø
___________________________________________________________________________
2/86
Description of advanced instructions 2
B
2.9-14 Convert a complete Date to a character string
This instruction converts a complete date (with time) to a character string in the format :
YYYY-MM-DD-HH:MM:SS (19 characters). This string ends with the termination
character Ø. Each character Y,M,D,H,M,S represents a number.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE [%MB2:20 := DT_TO_STRING (%MW50:4)]
%MB2:20:= DT_TO_STRING(%MW50:4 )
Syntax
Operator result :=DT_TO_STRING(Date)
Operands
Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DT
format (DATE_AND_TIME), system bit %S17 is set to 1 and the function returns the string ' ****
- ** -** - ** : ** : **'. If the output string is too short, truncation occurs and system bit %S15 is set
to 1.
%MB2:8 := DT_TO_STRING (%MW50:4)
==> %MB 2 3 4 5 6 7 8 9
'1' '9' '9' '8' '-' '1' '2' '-' ==> %S15 = 1
• If the output string is too long, termination type characters Ø are added to the string.
%MB2:21 := DT_TO_STRING (%MW50:4)
==>
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
'1' '9' '9' '8' '-' '1' '2' '-' '2' '7' '-' '2' '3' ':' '1' '4' ':' '3 ' '7' Ø Ø
___________________________________________________________________________
2/87
B
2.9-15 Convert a Duration to a character string
This instruction converts a time period (in the TIME format) to a character string.
The format of the result can be broken down into hours, minutes, seconds and tenths
of a second over 15 characters : HHHHHH:MM:SS.D. This string ends with the
termination character Ø. Each character H,M,S,D represents a number.
The maximum time period corresponds to 119304 hours, 38 minutes, 49 seconds and
5 tenths of a second.
Structure
Ladder language Instruction List language
OPERATE LD TRUE
%MB2:15:=TIME_TO_STRING(%MD40)
[%MB2:15 := TIME_TO_STRING (%MD40)]
Syntax
Operator result :=TIME_TO_STRING(Duration)
Operands
___________________________________________________________________________
2/88
Description of advanced instructions 2
B
If the output string is too long, termination type characters Ø are added to the string.
%MB2:16 := TIME_TO_STRING (%MD40)
==>
%MB 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
'0' '0' '7' '6' '5' '4' ':' '3' '2' ':' '1' '0' '.' '3' Ø Ø
Structure
Ladder language Instruction List language
OPERATE
LD TRUE
%MB2:9:=TOD_TO_STRING(%MD40)
[%MB2:9 := TOD_TO_STRING (%MD40)]
Syntax
Operator result :=TOD_TO_STRING(time)
Operands
___________________________________________________________________________
2/89
B
Note :
If the output string is too short, truncation occurs and system bit %S15 is set to 1.
%MB2:8 := TOD_TO_STRING (%MD40) (where %MD40 := 23:12:27)
==> %MB 2 3 4 5 6 7 8 9
'2' '3' ':' '1' '2' ':' '2' '7' ==> %S15 = 1
If the output string is too long, termination type characters Ø are added to the string.
%MB2:10 := TOD_TO_STRING (%MD40) (where %MD40 := 23:12:27)
==> %MB 2 3 4 5 6 7 8 9 10 11
'2' '3' ':' '1' '2' ':' '2' '7' Ø Ø
___________________________________________________________________________
2/90
Description of advanced instructions 2
B
2.9-17 Convert a Duration to HHHH:MM:SS
This instruction converts a duration (in the TIME format) to a number of hours-minutes-
seconds, HHHH:MM:SS. The limit values are [0000:00:00, 9999:59:59].
Structure
Ladder language Instruction List language
OPERATE
LD TRUE
%MD100:=TRANS_TIME(%MD2) [%MD100 := TRANS_TIME (%MD2)]
Syntax
Operator result :=TRANS_TIME(Duration)
Operands
Notes :
The "duration" parameter (expressed in 1/10 of a second) will be rounded up or down to allow
conversion (accuracy to within one second).
- sssssssss.0 to sssssssss.4 rounded to sssssssss.0
- sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0
The maximum converted time period can reach 10000 hours. This means that if the value of the
duration (TIME) provided as a parameter is greater than or equal to 360000000, it cannot be
converted. System bit %S15 is set to 1 and the result is 0000:00:00.
___________________________________________________________________________
2/91
B
2.10 Bit table instructions
2.10-1 Copy one bit table to another bit table
This function copies one bit table into another bit table bit-wise.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%M10:5:=COPY_BIT(%M20:5) [%M10:5 := COPY_BIT (%M20:5)]
Syntax
Operator result :=COPY_BIT (Tab)
Operands
Notes :
• The tables can be of different sizes. In this case, the result table contains the result of the
function executed on a length which is equivalent to the smallest table size, and the rest of the
result table is not modified.
• Beware of overlapping between the input table and the result table.
___________________________________________________________________________
2/92
Description of advanced instructions 2
B
2.10-2 Bit table logic instructions
Associated functions are used to execute a bit-wise logic operation between two bit
tables and load the result into another bit table.
• AND_ARX : logic AND (bit-wise).
• OR_ARX : logic OR (bit-wise).
• XOR_ARX : exclusive OR (bit-wise).
• NOT_ARX : logic complement (bit-wise) of a table.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%M10:7:= AND_ARX(%M20:7, %M30:7) [%M10:7 := AND_ARX (%M20:7,
%M30:7)]
OPERATE
%M50:10:=NOT_ARX(%M60:10) LD TRUE
[%M50:10 := NOT_ARX (%M60:10)]
Syntax
Operator result := AND_ARX (Tab 1, Tab 2)
result := OR_ARX (Tab 1, Tab 2)
result := XOR_ARX (Tab 1, Tab 2)
result := NOT_ARX (Tab 1)
Operands
Notes :
• The tables can be of different sizes. In this case, the result table contains the result of the
function executed on a length which is equivalent to the smallest table size, and the rest of the
result table is not modified.
• Beware of overlapping between the input table and the result table.
___________________________________________________________________________
2/93
B
2.10-3 Copy from a bit table to a word table
This function copies bits from a bit table or part of a bit table to a word table (or double
word table).
Copying from the bit table is from a certain row (brow) for a number of bits (nbit).
Copying to the word table (or double word table) is from the row (wrow or drow)
beginning with the least significant bit of each word.
• BIT_W : Copies from a bit table to a word table.
• BIT_D : Copies from a bit table to a double word table.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%MW10:7:= BIT_W(%M20:29, 3, 22, 2)
[%MW10:7 := BIT_W (%M20:29, 3, 22, 2)]
LD TRUE
OPERATE
[%MD10:4 := BIT_D (%M20:29, 3, 22, 1)]
%MD10:4:=BIT_D(%M20:29, 3, 22, 1)
%M20:29
row 0
%MW10:7
row 3 (brow)
bit 15 bit 0
row 0
row 2
___________________________________________________________________________
2/94
Description of advanced instructions 2
B
Syntax
Operator result := BIT_W (Tab, brow, nbit, wrow)
result := BIT_D (Tab, brow, nbit, drow)
Operands
Notes :
• If the number of bits to be processed is greater than the number of bits remaining in the table
from the row (brow), the function copies up to the last element in the table.
• If the number of bits to be copied is greater than the number of bits constituting the words
remaining in the result table, the function stops copying at the last element in the word table
(or double word table).
• A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.
___________________________________________________________________________
2/95
B
2.10-4 Copy from a word table to a bit table
This function copies bits constituting all or part of a word table (or double word table)
to a bit table.
Copying from the word table (or double word table) is from a certain row word (wrow
or drow) for a number of words (nwd).
Copying to the bit table is from the row (brow) beginning with the least significant bit
of each word.
• W_BIT : Copies from a word table to a bit table.
• D_BIT : Copies from a double word table to a bit table.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
%M20:36:=W_BIT(%MW10:7,2,2,3)
[%M20:36 := W_BIT (%MW10:7, 2, 2, 3)]
LD TRUE
OPERATE
[%M20:36 := D_BIT (%MD10:4, 1, 1, 3)]
%M20:36:=D_BIT(%MD10:4,1,1,3)
%M20:36
row 0
%MW10:7 row 3 (brow)
row 19
bit 15 bit 0
row 0
(wrow) row 2
___________________________________________________________________________
2/96
Description of advanced instructions 2
B
Syntax
Operator result := W_BIT (Tab, wrow, nwd, brow)
result := D_BIT (Tab, drow, nwd, brow)
Operands
Notes :
• If the number of bits to be processed is greater than the number of bits remaining in the table
from the row (wrow), the function copies up to the last element in the table.
• If the number of bits to be copied is greater than the number of bits remaining in the result table,
the function stops copying at the last element in the table.
• A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.
___________________________________________________________________________
2/97
B
2.11 "Orphee" functions : shift, counter
2.11-1 Shifts on words with retrieval of shifted bits
These functions execute arithmetical shifts to the left or right for a number of shifts
(nbit) on a word or a double word (a).
After a shift operation, the value is loaded into (result) and the shifted bits are loaded
into (rest).
• WSHL_RBIT : Shift to left on a word with retrieval of shifted bits.
• DSHL_RBIT : Shift to left on a double word with retrieval of shifted bits.
• WSHRZ_C : Shift to right on a word with filling of spaces by 0 and retrieval of
shifted bits.
• DSHRZ_C : Shift to right on a double word with filling of spaces by 0 and
retrieval of shifted bits.
• WSHR_RBIT : Shift to right on a word with extension of sign and retrieval of shifted
bits.
• DSHR_RBIT : Shift to right on a double word with extension of sign and retrieval
of shifted bits.
Structure
Ladder language Instruction List language
LD TRUE
OPERATE
WSHL_RBIT(%MW20,%MW30,%MW21,%MW10) [WSHL_RBIT(%MW20,%MW30,%MW21,%MW10)]
LD TRUE
OPERATE
[WSHRZ_C(%MW20,%MW30,%MW21,%MW10)]
WSHRZ_C(%MW20,%MW30,%MW21,%MW10)
LD TRUE
OPERATE
[DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)]
DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)
WSHL_RBIT (%MW20,%MW30,%MW21,%MW10) ;
WSHRZ_C (%MW20,%MW30,%MW21,%MW10) ;
DSHR_RBIT (%MD30,%MW40,%MD20,%MD10) ;
___________________________________________________________________________
2/98
Description of advanced instructions 2
B
Example :
WSHL_RBIT(%MW20,%MW30,%MW21,%MW10) where %MW30 = 4
rest = %MW10 A = %MW20
0000 0000 0000 0001 0001 1111 0110 1000
res = %MD20
keep sign 1 111 11 10 0000 0011 MSB
Syntax
Operator WSHL_RBIT (a, nbit, result, rest)
WSHRZ_C (a, nbit, result, rest)
WSHR_RBIT (a, nbit, result, rest)
Operands
Type a nbit result
rest
Indexable words %MW,%KW %MW,%KW, %Xi.T %MW
Non-indexable words %IW, %QW, %IW, %QW, %QW, SW, %NW
%SW, %NW %SW, %NW
Immediate value Immediate value
Numeric expr. Numeric expr.
___________________________________________________________________________
2/99
B
Syntax
Operator DSHL_RBIT (a, nbit, result, rest)
DSHRZ_C (a, nbit, result, rest)
DSHR_RBIT (a, nbit, result, rest)
Operands
Notes :
• If the parameter (nbit) is not between 1 and 16 for shifts on words, or between 1 and 32 for
shifts on double words, the outputs (result) and (rest) are not significant and system bit %S18 is
set to 1.
___________________________________________________________________________
2/100
Description of advanced instructions 2
B
2.11-2 Up/down counting with indication of over/underflow
This function executes up/down counting with an indication of an over/underflow. The
function is only executed when the enable input (en) is at 1.
Two independent inputs (cu and cd) are used to upcount and downcount events.
Output (Qmin) is set to 1 when the minimum threshold (min) is reached and output
(Qmax) is set to 1 when the maximum threshold (max) is reached.
The initial counter value is fixed by parameter (pv) and the current counter value is
given by parameter (cv).
A 16-bit word (mwd) is used to archive the state of the cu and cd inputs (bit 0 to archive
cu and bit 1 to archive cd).
Structure
Ladder language Instruction List language
OPERATE LD TRUE
SCOUNT (%M9,%MW10,%M11,%M12,%MW11, [SCOUNT(%M9,%MW10,%M11,%M12,%MW11,
%MW12,%M16,%M10,%MW15,%MW20) %MW12,%M16,%M10,%MW15,%MW20)]
SCOUNT(%M9,%MW10,%M11,%M12,%MW11,%MW12,%M16,%M10,%MW15,%MW20) ;
Example :
SCOUNT (%M9,%MW10,%M11,%M12,%MW11,%MW12,%M16,%M10,%MW15,%MW20)
where %MW10 (pv) = 5, %MW11 (min) = 0, %MW12 (max) = 7
en : %M9
cd : %M12
mcd : %MW20:X1
cu : %M11
mcu : %MW20:X0
Qmax : %M10
Qmin : %M16
cv = %MW15 5 4 5 65 6 7 5
___________________________________________________________________________
2/101
B
Syntax
Operator SCOUNT (en, pv, cu, cd, min, max, Qmin, Qmax, cv, mwd)
Operands
Type en, cu, cd Qmin, Qmax pv, min, max cv, mwd
Bits %I,%Q,%M,%S, %I,%Q,%M
%BLK,%.:Xk
Indexable words %MW,%KW, %Xi.T %MW
Non-indexable words %IW, %QW, %QW,%SW
%SW, %NW, %NW
Immed. val.
Numeric expr.
Notes :
• If (en) = 0 then the function is no longer enabled and on each call, there is :
Qmin = Qmax = 0
mcu = mcd = 0
cv = pv
• If max > min then :
cv > max ---> Qmax = 1 and Qmin = 0
min < cv < max ---> Qmax = Qmin = 0
cv < min ---> Qmax = 0 and Qmin = 1
• If max < min then :
max < cv - min ---> Qmax = 1 and Qmin = 0
cv < max ---> Qmax = 0 and Qmin = 1
cv > min ---> Qmax = 1 and Qmin = 0
• If max = min then :
cv < min and max ---> Qmax = 0 and Qmin = 1
cv > min and max ---> Qmax = 1 and Qmin = 0
• Modifying parameter (pv) with (en) at 1 has no effect on operation.
• A negative value for parameters (pv) and (min) is interpreted as a zero value.
• A value less than 1 for parameter (max) is interpreted as 1.
___________________________________________________________________________
2/102
Description of advanced instructions 2
B
2.11-3 Circular shift operations
This function carries out circular shift operations to the left or the right on a word or a
double word.
• ROLW : circular shift to the left on a word with a calculated number of shifts
• RORW : circular shift to the right on a word with a calculated number of shifts
• ROLD : circular shift to the left on a double word with a calculated number of shifts
• RORD : circular shift to the right on a double word with a calculated number of shifts
Structure
%M0 LD %M0
[%MW0 := ROLW(%MW10,%MW5)]
%MW0:=ROLW(%MF10,%MW5)
%I3.2 LD %I3.2
[%MD10 := RORD(%MD100,%MW5)]
%MD8:=RORD(%MD50,%MW5)
IF %M0 THEN
%MW0 := ROLW(%MW10,%MW5) ;
END_IF ;
IF %I3.2 THEN
%MD10 := RORD(%MD100,%MW5) ;
END_IF ;
___________________________________________________________________________
2/103
B
Syntax
Operators
• ROLW, RORW, ROLD, RORD Op1:=Operator(Op2,n)
Note
For preference, use the standard instructions ROL and ROR when the shift number
is static, as these instructions offer the best performance.
___________________________________________________________________________
2/104
Description of advanced instructions 2
B
2.12 Time delay functions
2.12-1 General
Unlike predefined function blocks, these time delay functions are unlimited in number
and can be used in the code for DFB function blocks.
There are four time delay functions.
• FTON : On-delay
• FTOF : Off-delay
• FTP : Pulse time delay
• FPULSOR : square wave signal
Syntax
Operator FTON (EN, PT, Q, ET, PRIV)
Characteristics
"Enable" EN Triggers delay on rising edge
input
Preset value PT Input word which determines the duration (in
hundredths of a second) of the delay. It can be
used to define a maximum of 5 min and 27 s
with a precision of 10 ms. (1)
"Timer" output Q Output set to 1 at the end of the delay.
Current value ET Output word which increases from 0 to PT
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with this double word
(1) modifications to this word are taken into account during the delay.
___________________________________________________________________________
2/105
B
On a rising edge of input EN, the timer is
launched : its current value ET increases
from 0 to PT (in hundredths of a second). EN
Output bit Q changes to 1 when the cur-
rent value reaches PT and remains at 1
Q
as long as EN is at 1.
When input EN is at 0, the timer is PT
stopped even if it was changing : ET takes ET
value 0.
Structure
Ladder language Instruction List language
%I1,2
OPERATE LD %I1.2
FTON (%I3.0,1000,%Q4.0,%MW2,%MD8)
[FTON (%I3.0,1000,%Q4.0,%MW2,%MD8)]
IF %I1.2 THEN
FTON (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
END_IF ;
Operands
FTON (EN, PT, Q, ET, PRIV)
Type EN PT Q ET PRIV
Indexable words %MW,%KW,%Xi.T %MW
Non-indexable %IW,%QW,%SW %IW,%QW
words Immed. val.,
Num. expr.,%NW
Indexable %MD
double words
Bits %I,%Q, %M, %S %I,%Q, %M,
%BLK,%•:Xk,%X %S,%•:Xk,%X
___________________________________________________________________________
2/106
Description of advanced instructions 2
B
2.12-3 FTOF off-delay function
This function is used to manage off-delays. The delay can be programmed.
Syntax
Operator FTOF (EN, PT, Q, ET, PRIV)
Characteristics
"Enable" EN Triggers delay on falling edge
input
Preset value PT Input word which determines the duration (in
hundredths of a second) of the delay. It can be
used to define a maximum duration of 5 min and
27 s with a precision of 10 ms. (1)
"Timer" output Q Output set to 1 on a rising edge of EN and set
to 0 at the end of the delay.
Current value ET Output word which increases from 0 to PT
when the time delay has elapsed.
Calculation variable PRIV Double word for storing internal states.
Associate an application variable exclusively
reserved for this purpose with this double word.
(1) modifications to this word are taken into account during the delay.
Structure
Ladder language Structured Text language
IF %I1.2 THEN
%I1,2 FTOF (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
OPERATE
FTOF (%I3.0,1000,%Q4.0,%MW2,%MD8) END_IF ;
This function is used to generate a pulse of a precise duration. The duration can be
programmer.
Syntax
Operator FTP (EN, PT, Q, ET, PRIV)
Characteristics
Structure
Ladder language Structured Text language
IF %I1.2 THEN
%I1,2 FTP (%I3.0,1000,%Q4.0,%MW2,%MD8) ;
OPERATE
FTP (%I3.0,1000,%Q4.0,%MW2,%MD8) END_IF ;
B
2.12-5 FPULSOR function for generating square wave signals
This function is used to generate a periodic square wave signal. Its pulse width can
be set to 1 or 0 via the program using 2 timers :
• TON : on-delay (for pulse at 1).
• TOFF : off-delay (for pulse at 0).
Syntax
Operator FPULSOR (EN, TON, TOFF, Q, ET, PRIV)
Characteristics
___________________________________________________________________________
2/109
B
Structure
Ladder language Instruction List language
LD True
OPERATE
PULSOR (%I3.0,500,200,%Q4.0,%MW2,%MD8)
[FPULSOR (%I3.0,500,200,%Q4.0,%MW2,
%MD8)]
IF %I1.2 THEN
FPULSOR (%I3.0,500,200,%Q4.0,%MW2,%MD8) ;
END_IF ;
Operands
FPULSOR (EN, TON, TOFF, Q, ET, PRIV)
___________________________________________________________________________
2/110
Description of advanced instructions 2
B
2.13 Data archiving functions
2.13-1 General
These functions can be used to archive data via the program in a dedicated zone in
the user memory card.
Application examples :
• automatic archiving of application data (status logging, logs, etc) in the PLC user
memory card and remote transmission of data (via modem) to the mainframe
• back-up of production tests in the PLC user memory card
References for memory cards which provide the additional data archiving function :
Application Archiving TSX P57 102 TSX P57 2i2 TSX P57 3i2
program zone TPMX P57 102 TPMX P57 202 TSX P57 4i2
zone (RAM TPCX 57 1012 TPMX P57 352
type) TSX 37 21/22 TPMX P57 452
TPCX 57 3512
TSX MRP 232P RAM/32 K16 128K16 Yes Yes Yes
Note: 10 words in the dedicated archiving zone are reserved by the system.
Note: data stored in the archiving zone of the memory card can only be accessed by the
application resident in the PLC using these 3 basic functions. A remote station cannot directly
access the data via a network or communication bus.
___________________________________________________________________________
2/111
B
2.13-2 Initializing the archiving zone
The SET_PCMCIA function can be used to initialize all or part of the archiving zone of
the user memory card at a specified value.
1500
100
100
∇
SET_PCMCIA
100
100 1529
Structure
Ladder language Instruction List language
___________________________________________________________________________
2/112
Description of advanced instructions 2
B
Syntax
Function SET_PCMCIA (address, no_words, value, status)
Parameters
Type Address No_words Value Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.
___________________________________________________________________________
2/113
B
2.13-3 Writing data to the archiving zone
The WRITE_PCMCIA function is used to transfer data from the RAM memory of the PLC
(%MW words) to the archiving zone of the user memory card.
This function uses 4 parameters :
%MW40
WRITE_PCMCIA
%MW69
1500
∇
1529
Structure
Ladder language Instruction List language
IF RE %I1.3 THEN
WRITE_PCMCIA (%MD0, %MW5,
%MW20,%MW2);
END_IF;
___________________________________________________________________________
2/114
Description of advanced instructions 2
B
Syntax
Function WRITE_PCMCIA (des_ad, no_words, source, status)
Parameters
Type Des_ad No_words Source Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.
___________________________________________________________________________
2/115
B
2.13-4 Reading data from the archiving zone
The READ_PCMCIA function is used to transfer data from the archiving zone of the user
memory card to the RAM memory of the PLC (%MW words).
This function uses 4 parameters :
%MW40 READ_PCMCIA
∇
%MW69
1500
1529
Structure
Ladder language Instruction List language
IF RE %I1.4 THEN
READ_PCMCIA (%MD0, %MW5,
%MW20,%MW2);
END_IF;
___________________________________________________________________________
2/116
Description of advanced instructions 2
B
Syntax
Function READ_PCMCIA (source_ad, no_words, dest, status)
Parameters
Type Source_ad No_words Dest Status
Indexable words %MW %MW %MW
Immed. val. Immed. val.
___________________________________________________________________________
2/117
B
___________________________________________________________________________
2/118
Section
System bits and words 33
3 System bits and words
B
3.1 System bits
3.1-1 List of system bits
%S4,%S5,
%S6,%S7 Time base 10ms, 100ms, 1s, 1mn - S
(1) S = controlled by the system, U = controlled by the user, U->S = set to 1 by the user, reset to
0 by the system, S->U = set to 1 by the system, reset to 0 by the user.
(2) only on TSX 37.
(3) only on TSX/PMX/PCX 57.
___________________________________________________________________________
3/2
System bits and words 3
B
3.1-2 Detailed description of system bits
TSX 37 and TSX 57 PLCs have %Si system bits which indicate the status of the PLC or
enable the user to intervene in its operation.
These bits can be tested in the user program in order to detect any operating event which
requires special processing. Some of them must be rest to their initial or normal state by B
the program. However, the system bits which have been reset to their initial or normal state
by the system must not be reset by the program or the terminal.
System Function Description
bits
%S9 Placing outputs Normally at 0. It can be set to 1 by the program or by the terminal :
in fallback • At state 1 PLC outputs are forced into fallback position (bus X,
position on FIPIO, AS-i, etc).
all buses • At state 0 outputs are updated normally.
___________________________________________________________________________
3/3
B
System Function Description
bits
___________________________________________________________________________
3/4
System bits and words 3
B
System Function Description
bits
%S20 Index Normally at 0. It is set to 1 when the address of the indexed object
overflow becomes less than 0 or exceeds the number of objects declared
during configuration. B
It must be tested by the user program after each operation where
there is a risk of overflow, then reset to 0 by the user if an overflow
occurs.
%S21 Grafcet This bit is controlled by the user to initialize the Grafcet (preferably
initialization set to 1 during preprocessing). It is reset to 0 by the system after
Grafcet initialization (at the end of preprocessing, during
assessment of the new Grafcet state). Grafcet initialization
involves deactivating all active steps and activating initial steps.
On a cold start, this bit is set to 1 by the system during
preprocessing.
%S22 Resetting Normally at 0, this bit can only be set to 1 by the program during
Grafcet preprocessing.
At state 1, it causes all Grafcet steps to deactivate. It is reset to 0 by
the system after acknowledgment of the end of the preprocessing.
%S23 Grafcet Normally at 0, setting %S23 to 1 causes the Grafcet state
freezing to be maintained. Whatever the value of the transition conditions
upstream of the active steps, the Grafcet chart does not change.
Freeze is maintained as long as bit %S23 is set to 1.
This bit is controlled by the user program. It is set to 1 or 0 only
during preprocessing.
%S24 Resetting Normally at 0, setting %S24 to 1 resets the selected macro-steps in
macro steps a table of 4 system words %SW22 to %SW25 to 0. It is reset to 0
to 0 by the system after acceptance at the end of the preprocessing.
%S26 Table Normally at 0, it is set to 1 by the system when activation
overflow capacities (steps or transitions) are exceeded or when trying to
(steps/ execute an incorrectly defined chart (such as a destination
transitions) connector to a step which is not part of the chart). An overflow
causes the PLC to STOP.
This bit is reset to 0 when the terminal is initialized.
%S30 Master task Normally at 1. If it is set to 0 by the user, the master task is
activation/ deactivated.
deactivation
%S31 Fast task Normally at 1. If it is set to 0 by the user, the fast task is
activation deactivated.
%S38 Enable/ Normally at 1. If it is set to 0 by the user, events are disabled.
disable
events
%S39 Saturation This bit is set to 1 by the system to show that one or more events
of event cannot be processed due to saturation of the stacks.
processing This bit is reset to 0 by the user.
___________________________________________________________________________
3/5
B
System Function Description
bits
%S40 I/O fault Bits %S40 to %S47 are assigned to racks 0 to 7 respectively.
to (racks) (1) Normally at 1, each of these bits is set to 0 should
%S47 an I/O fault occur on the corresponding rack.
The bit is reset to 1 when the fault has cleared.
%S49 Reactivate Normally at state 0. This bit can be set to 1 by the user to
outputs (2) request a reactivation every 10s from the occurrence of a solid
state output fault triggered by an over-current or a short-circuit.
%S50 Updating Normally at 0. This bit can be set to 1 or to 0 by the program or by
the date the terminal.
and time • At 0 it accesses the date and time by reading system words
using words %SW50 to 53.
%SW50 to 53 • At 1 it updates the date and time by writing system words
%SW50 to 53.
%S51 Loss of This bit, which is managed by the system, signals at 1 either that
real-time the real-time clock is missing or that the system words relating to
clock the real-time clock are not significant. In this case, the clock should
time be set.
Setting the time automatically changes the bit to 0.
%S59 Updating Normally at 0. This bit can be set to 1 or to 0 by the program or by
the date the terminal.
and time • At 0 the system does not control system word %SW59.
using word • At 1 the system controls the rising and falling edges on word
%SW59 %SW59 to adjust the current date and time (in increments).
%S60 Redundant System bit used when installing a redundant architecture
architecture (see description and use in the "Redundant Premium
command architecture" manual).
___________________________________________________________________________
3/6
System bits and words 3
B
System Function Description
bits
%S69 Display of Normally at 0. This bit can be set to 1 or to 0 by the program or by
user data the terminal.
on PLC • At 0 the state of the I/O are displayed on the PLC indicator lamps B
displays (WRD indicator lamp off).
• At 1 user data is displayed (WRD indicator lamp on).
(see words %SW67,68 and 69).
%S70 Update data This bit is set to 1 by the system at the end of each TSX Nano or
on AS-i bus AS-i bus scan. On power-up, it indicates that all the data has been
or TSX Nano refreshed at least once and that it is therefore significant. This bit is
link reset to 0 by the user.
%S73 Switch to Normally at 0. This bit is set to 1 by the user to change to
protected mode protected mode on AS-i bus. Bit %S74 must first be at 1. This
on AS-i bus bit is only used in a wiring test, and has no application in the PLC.
%S74 Save Normally at 0. This bit is set to 1 by the user to save the
configuration configuration present on the AS-i bus. This bit is only used in a
present wiring test, and has no application in the PLC.
on AS-i bus
%S80 Reset Normally at 0. This bit can be set to 1 by the user in order to reset
message message counters %SW80 to %SW86.
counters
%S90 Refresh Normally at 0. This bit is set to 1 when common words are received
common from another station on the network. This bit can be set to 0 by the
words program or by the terminal to check the exchange cycle of common words.
%S92 Switch to Normally at 0, this bit can be set to 1 by the user to set the
communication communication functions in performance measurement mode.
function The communication function Time-out parameter then displays the
meas. mode exchange loop-back time in tenths of ms (if this time<10, otherwise
insignificant.)
%S94 Save DFB Normally at 0, this bit can be set to 1 by the user to save the
adjustments adjustment values of user function blocks.
%S95 Restore DFB Normally at 0, this bit can be set to 1 by the user to save the
adjustments restore values of user function blocks.
%S96 Validity of 0 -> application program backup invalid,
application 1 -> application program backup valid.
program This bit can be read at any time (by the program or in adjust
backup mode) and in particular after a cold or warm restart.
It is relevant to a Backup application created using PL7 in the
internal Flash EPROM.
%S97 Validity of 0 -> %MW backup invalid,
%MW backup 1 -> %MW backup valid.
This bit can be read at any time (by the program or in adjust mode)
and in particular after a cold start or warm restart.
%S98 Locate Normally at 0. This bit is managed by the user :
pushbutton 0 -> pushbutton on TSX SAZ 10 module active,
on TSX SAZ 10 1 -> pushbutton on TSX SAZ 10 module replaced by a discrete
module remotely input (see %SW98).
___________________________________________________________________________
3/7
B
System Function Description
bits
%S99 Locate Normally at 0. This bit is managed by the user :
pushbutton 0 -> pushbutton on centralized display block active,
on display 1 -> pushbutton on centralized display block replaced by a discrete
block remotely input (see %SW99).
%S100 Terminal Set to 0 or 1 by the system depending on the state of the INL/DPT
port shunt on the terminal port.
protocol • If the shunt is absent (%S100=0), UNI-TELWAY master
protocol is used.
• If the shunt is present (%S100=1), the protocol used is that
indicated by the application configuration.
%S101 Diagnostic This bit is set to 1 by the system when the diagnostic option is
buffer configured, and a diagnostic buffer designed to store errors
configured sent by diagnostic DFBs is then reserved.
%S102 Diagnostic This bit is set to 1 by the system when the buffer receiving errors
buffer from diagnostic function blocks is full.
full
%SW118 General FIPIO Normally at 0, this bit is set to 0 by the system if a fault occurs on
I/O fault a device connected to the FIPIO bus. When the fault disappears,
this bit is reset to 1 by the system.
%SW119 General I/O Normally at 1, this bit is set to 0 by the system if a fault occurs on
in-rack fault an in-rack I/O module. When the fault disappears, this bit is reset
to 1 by the system.
___________________________________________________________________________
3/8
System bits and words 3
B
3.2 System words
3.2-1 List of system words
Word Function Control
%SW0 Value of master task period (periodic task) U
%SW1 Value of fast task period U B
%SW8 Control input acquisition of each task U
%SW9 Control output updating of each task U
%SW10 First scan after cold restart S
%SW11 Watchdog time S
%SW12 UNI-TELWAY terminal port address S
%SW13 Main address of the station S
%SW17 Fault status on floating point operation S and U
%SD18 Absolute time counter S and U
%SW20 Number of steps active, to activate or to deactivate S
%SW21 Number of transitions validated, to validate and to devalidate S
%SW22 to Table of 4 words used for designating macro-steps to be reset to 0 U
%SW25 (2) when bit %S24 is set to 1
%SW31 Maximum time of master task scan S
%SW31 Maximum time of master task scan S
%SW32 Minimum time of master task scan S
%SW33 Execution time of last fast task scan S
%SW34 Maximum time of fast task scan S
%SW35 Minimum time of fast task scan S
%SW48 Number of events processed S and U
%SW49 (1) Real-time clock function : words containing the current S and U
%SW50 (1) date and time values (in BCD)
%SW51 (1) %SW49 =day of the week (type of day)
%SW52 (1) %SW50 = seconds %SW51 = hours and minutes
%SW53 (1) %SW52 = month and day %SW53= century and year
%SW54 (1) Real-time clock function : words containing the date and time of the S
%SW55 (1) last power failure or PLC stop (in BCD)
%SW56 (1) %SW54 = seconds and fault code %SW55 = hour and minute
%SW57 (1) %SW56 = month and day %SW57= century and year
%SW58 Identification code of last stop and day of the week (type of day) S
%SW59 Incremental adjustment of the current date and time U
%SW60 to Redundant PLC diagnostics S
%SW66
%SW67 Control "Display" mode, S and U
%SW68 %SW67: read pushbuttons
%SW69 %SW68: current and maximum indices of "displayed objects"
%SW69: number of the first object in the zone displayed
%SW80 No of messages transmitted by the system to the terminal port S and U
%SW81 No of messages received by the system from the terminal port
%SW82 No of messages transmitted by the system to the PCMCIA card
%SW83 No of messages received by the system from the PCMCIA card
%SW84 No of telegrams transmitted by the system
%SW85 No of telegrams received by the system
%SW86 No of messages refused by the system
(1) S = managed by the system, U = managed by the user.
(2) only on TSX 57.
(3) only on TSX 37-21/22 and TSX 57.
___________________________________________________________________________
3/9
B
Word Function Supervisor(1)
%SW87 Number of requests processed by the synchronous server per S
master task cycle (MAST).
%SW88 Number of requests processed by the asynchronous server per S
master task cycle (MAST).
%SW89 Number of requests processed by the server functions per master S
task cycle (MAST).
%SW96 (2) Control / diagnostics of the save / retrieve application program S and U
and %MW function
%SW97 (2) Number of %MW to be saved U
%SW98 (2) Module/channel geographical address of the discrete input replacing U
the pushbutton on the TSX SAZ 10 module
%SW99 (2) Module/channel geographical address of the discrete input replacing U
the pushbutton on the centralized display block
%SW108 No. of bits forced S
%SW109 Count number of analog channels forced to 0 S
%SW116 Remote I/O on FIPIO fault S
%SW124 Type of last CPU fault found S
%SW125 Type of blocking fault S
%SW126 Address of blocking fault instruction S
%SW127
%SW128 to FIPIO connection point fault S
%SW143
%SW144 Operating mode of the bus arbitrator and producer/consumer U
on the FIPIO bus
%SW145 Modification of the bus arbiter parameters U and S
%SW146 Visualisation of the bus arbiter function and producer/consumer S
on the FIPIO bus
%SW147 Value of bus cycle time of the task in FREE mode S
%SW148 Value of bus cycle time of the task in SLAVE mode S
%SW149 reserved at 0 S
%SW150 Number of FIPIO frames sent S
%SW151 Number of FIPio frames received S
%SW152 Number of FIPIO frames repeated S
%SW155 Number of explicit exchanges being processed S
%SW160 Result of the last registration S
%SW161 Result of the last deregistration S
%SW162 Number of errors in the diagnostic buffer S
(1) S = controlled by the system, U = controlled by the user,
(2) only on TSX 37.
___________________________________________________________________________
3/10
System bits and words 3
B
3.2-2 Detailed description of system words
System Function Description
words
%SW0 Master Modifies the master task scan period defined during B
task configuration via the user program or the terminal.
scan The period is expressed in ms (1..255ms). %SW0=0 during
period cyclic operation.
On a cold restart : takes the value defined by configuration.
%SW1 Fast Modifies the fast task scan period defined during
task configuration via the user program or the terminal.
scan The period is expressed in ms (1..255ms).
period On a cold restart : takes the value defined by configuration.
%SW8 Control for Normally at 0, this bit can be set to 1 or 0 by program or via
reading the terminal.
tasks inputs Inhibits the phase for reading the inputs for each task.
%SW8:X0 1= inhibition in the master task
%SW8:X1 1= inhibition in the fast task
%SW9 Control for Normally at 0, this bit can be set to 1 or 0 by program or via
updating the terminal.
task outputs Inhibits the updating phase of the outputs for each task.
%SW9:X0 1= inhibition in the master task
%SW9:X1 1= inhibition in the fast task
%SW10 First scan If the bit of the current task is at 0, this means that it is
after a performing its first scan after a cold restart.
cold %SW10:X0 : is assigned to the master task, MAST.
restart %SW10:X1 : is assigned to the fast task, FAST.
%SW11 Watchdog Reads the watchdog time defined during configuration.
time It is expressed in ms (10...500ms).
%SW12 UNI-TELWAY UNI-TELWAY terminal port address (in slave mode)
terminal port defined in configuration and loaded in this word
address during a cold restart.
%SW13 Main Indicates for the main network :
address • The station number (low-order byte) from 0 to 127.
of the • The network number (high-order byte) from 0 to 63.
station (position of dip switch on the PCMCIA card)
___________________________________________________________________________
3/11
B
System Function Description
words
%SW17 Fault status On detecting a fault in a floating point arithmetic operation,
on floating point bit %S18 is set to 1 and the %SW17 fault status is
operation updated in line with the following code :
%SW17:X0 = Invalid operation/the result is not a number
%SW17:X1 = Non-standard operand / the result is correct
%SW17:X2 = Division by 0 / the result is ± ∞
%SW17:X3 = Overflow / the result is ± ∞
%SW17:X4 = Underflow / the result is ± 0
%SW17:X5 = Imprecise result
This word is reset to 0 by the system during a cold restart
and by the program for reuse.
%SD18 Absolute This double word is used to calculate time periods.
time It is incremented every 1/10th of a second by the
counter system (even if the PLC is in STOP). It can be read and
written by the user program or by the terminal.
%SW20 Grafcet This word contains the number of steps active, to activate
activity and deactivate for the current scan. It is updated by the
level system every time the Grafcet chart changes.
%SW21 Table of enabled This word contains the number of chart transitions
Grafcet enabled, to enable and to disable the current scan.
transitions It is updated by the system every time the Grafcet
chart changes.
%SW22 Macro-step A macro-step with %SW22:X0 for XM0...%SW25:X16 for
to reset to 0 table XM63 corresponds to each bit in this table.
%SW25 Macro-steps whose associated bit in the table is at 0 will
be reset when bit %S24 is set to 1.
%SW30 Master task Indicates the scan time of the last master task scan
scan (in ms).
time (1)
%SW31 Master task Indicates the longest scan time of the master task
maximum since the last cold restart (in ms).
scan
time (1)
(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end
(update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks
as well as processing of terminal requests.
___________________________________________________________________________
3/12
System bits and words 3
B
System Function Description
words
%SW32 Master task Indicates the shortest scan time of the master task
minimum since the last cold restart (in ms).
scan B
time (1)
%SW33 Fast task Indicates the scan time of the last fast task scan (in
scan ms).
time (1)
%SW34 Fast task Indicates the longest scan time of the fast task
maximum since the last cold restart (in ms).
scan
time (1)
%SW35 Fast task Indicates the shortest scan time of the fast task
minimum since the last cold restart (in ms).
scan
time (1)
%SW48 Number Indicates the number of events processed since the last
of events cold restart (in ms). This word can be written by the program
or by the terminal.
%SW49 Real-time System words containing the current date and time in BCD :
%SW50 clock function %SW49 : day of the week (1 for Monday to 7
%SW51 (2) for Sunday).
%SW52 %SW50 : Seconds (SS00)
%SW53 %SW51 : Hours and Minutes (HHMM)
%SW52 : Month and Day (MMDD)
%SW53 : Year (YYYY)
These words are controlled by the system when bit
%S50 is at 0.
These words can be written by the user program or by
the terminal when bit %S50 is set to 1.
%SW54 Real-time System words containing the date and time of the last
%SW55 clock function power failure or PLC stop (in BCD) :
%SW56 (2) %SW54 : Seconds (00SS),
%SW57 %SW55 : Hours and Minutes (HHMM),
%SW58 %SW56 : Month and Day (MMDD),
%SW57 : Year (YYYY).
%SW58 : high order byte containing the day of the week
(1 for Monday to 7 for Sunday)
(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end
(update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks
as well as processing of terminal requests.
(2) Only on TSX 37-21/22 and TSX 57 PLCs.
___________________________________________________________________________
3/13
B
System Function Description
bits
%SW58 Code of The low order byte contains the code of the last stop.
last stop 1= Change from RUN to STOP by terminal
2= Stop on software fault (PLC scan overshoot)
4= Power outage
5= Stop on hardware fault
6= Stop on HALT instruction
%SW59 Adjust Contains two sets of 8 bits to adjust the current date.
current The operation is always performed on a rising edge of the bit.
date This word is enabled by bit %S59.
Increment Decrement Parameter
bit 0 bit 8 Day of the week
bit 1 bit 9 Seconds
bit 2 bit 10 Minutes
bit 3 bit 11 Hours
bit 4 bit 12 Days
bit 5 bit 13 Months
bit 6 bit 14 Years
bit 7 bit 15 Centuries
%SW60 Redundant System words used when setting up a redundant architecture
to PLC (see description and use in the "Redundant Premium
%SW69 diagnostics architecture" manual).
%SW66 7-segment Contains the Hexadecimal/BCD value that the user wishes to
(1) display see displayed on the optional 7-segment display.
management The display appears when bit %S66 is at 1.
%SW67 Management When %S69=1, these words enable the display block (PLC front
%SW68 of "WORD" panel) to be used in WORD mode :
%SW69 mode • %SW67 : control and status of WORD mode.
• %SW68 : maximum index and current index.
• %SW69 : number of the first object in the zone displayed.
For more information on these system words see part F,
section 1.5 (installation manual).
%SW80
c Management No of messages sent by the system to the terminal port.
%SW81 of messages No of messages received by the system from the terminal port.
%SW82 and No of messages sent by the system to the PCMCIA card.
%SW83 telegrams No of messages received by the system from the PCMCIA card.
%SW84 No of telegrams sent by the system.
%SW85 No of telegrams received by the system.
%SW86 No of messages refused by the system.
%SW87 Management Number of requests processed by the synchronous server per
of communication master task cycle (MAST).
%SW88 flow Number of requests processed by the asynchronous server per
(1) master task cycle (MAST).
%SW89 Number of requests processed by the server functions
(immediate) per master task cycle (MAST).
B
System Function Description
words
%SW96 Control/ Control and/or diagnostics of the application program and %MW
diagnostics save/retrieve function : B
of the save/ bit 0 : request to transfer to the save zone. This bit
retrieve function is active on a rising edge. It is reset to 0 by the system once
the rising edge is taken into account.
bit 1 : when this bit is at 1, this signifies that the save function
is complete. This bit is reset to 0 by the system once the
rising edge is taken into account.
bit 2 : report of the save :
0 -> save with no errors,
1 -> error during save.
bits 3 to 5 : reserved.
bit 6 : validity of the application program backup (identical to
%S96).
bit 7 : validity of the %MW backup (identical to %S97).
bits 8 to 15 : this byte is only significant if the report bit is at 1
(bit 2 = 1, error during save).
1 -> number of %MW to be saved greater than the number of
%MW configured,
2 -> number of %MW to be saved greater than 1000 or less than
0,
3 -> number of %MW to be retrieved greater than the number of
%MW configured,
4 -> size of the application in the internal RAM greater than 15
Kwords (remember that the %MW are always saved when the
application program is saved in the internal Flash EPROM),
5 -> operation prohibited in RUN,
6 -> Backup cartridge present in the PLC,
7 -> writing fault in Flash EPROM..
%SW97 Number of Is used to set the parameters for the number of %MW to be
%MW to be saved. When this word is between 1 and 1000, the first 1000
saved %MW are transferred to the internal Flash EPROM.
When this word is 0, only the application program contained in
the internal RAM is transferred to the internal Flash EPROM.
Any saved %MW are then erased.
On a cold restart, this word is initialized to -1 if the internal
Flash EPROM does not contain any %MW backup. Otherwise,
it is initialized to the value of the number of saved words.
%SW98 Discrete input When bit %S98 = 1, this word indicates the geographical
address address (module / channel) of the discrete input which replaces
the pushbutton of the TSX SAZ 10 module :
___________________________________________________________________________
3/15
B
System Function Description
words
%SW99 Discrete input When bit %S99 = 1, this word indicates the geographical address
address (module / channel) of the discrete input which replaces the
pushbutton on the centralized display block :
High order Low order
Module number Channel number
___________________________________________________________________________
3/16
System bits and words 3
B
System Function Description
words
%SW125 Type of The system writes in this word the last type of blocking fault
blocking found :
fault 16#DB0 : watchdog overflow B
16#2258 : execution of the HALT instruction
16#DEF8 : execution of a JMP instruction to an undefined
label
16#2XXX : execution of a CALL instruction to an undefined
subroutine
16#0XXX : execution of an unknown function
16#DEFE : Grafcet with source or destination connector
undefined
16#DEFF : floating point not implemented
16#DEF0 : division by 0, (1-->%S18)
16#DEF1 : error when transferring a character string
(1-->%S15)
16#DEF2 : capacity overflow, (1-->%S18)
16#DEF3 : index overflow (1-->%S20)
%SW126 Address of Address of the instruction which generated the application
%SW127 blocking fault blocking fault.
instruction %SW126 contains the offset of this address
%SW126 contains the base of this address
%SW128 FIPIO Each bit in this group of words represents a device connected
to connection on the FIPIO bus.
%SW143 point fault Normally at 1, if one of these bits is at 0, a connection
fault has occurred.
%SW128 represents addresses 0 to 15
%SW128:X0 --> @0, %SW128:X1-->@1,.....,
%SW128:X15-->@15,
%SW129 represents addresses 16 to 31
%SW129:X0 --> @16, %SW129:X1-->@17,.....,
%SW129:X15-->@31,
........
%SW143 represents addresses 240 to 255
%SW143:X0 --> @240, %SW143:X1-->@241,.....,
%SW143:X15-->@255,
When the fault disappears, the bit is reset to 1 by the system
Note : @ = connection point
%SW144 FIPIO bus Caution : modifying this system word can cause the
arbiter station to stop
function This system word is used to start and stop the bus arbiter
operating function and the producer/ consumer function.
mode It is used to modify the bus starting mode, automatic and
manual, if it stops.
For further details see the communication manual.
___________________________________________________________________________
3/17
B
System Function Description
words
%SW145 Modification of Caution : modifying this system word can cause the
FIPIO bus station to stop
arbiter This system word is used to modify FIPIO bus arbiter
parameters parameters.
For further details, see the communication manual.
%SW146 Display of This word displays the bus arbiter and producer/consumer
FIPIO bus functions on the FIPIO bus.
arbiter For further details, see the communication manual.
function
%SW149 reserved at 0
%SW150 Number of This word indicates the number of frames sent by the FIPIO
frames sent channel manager.
%SW151 Number of This word indicates the number of frames received by the FIPIO
frames received channel manager.
___________________________________________________________________________
3/18
Section
Differences between PL7-2/3 and PL7 Micro 44
4 Differences between PL7-2/3 and PL7 Micro/Junior
B
4.1 Differences between PL7-2/3 and PL7-Micro/Junior
Immediate values
Objects PL7-2/3 PL7 Micro/Junior
Base 10 integer 1234 1234 B
Base 2 integer L'10011110' 2#10011110
Base 16 integer H'ABCD' 16#ABCD
Floating point -1.32e12 (PL7-3) -1.32e12
Character string M'aAbBcB' 'aAbBcC'
Labels
Label Li i = 0 to 999 %Li i = 0 to 999
Bits
Objects PL7-2/3 PL7 Micro/Junior
Input bit in rack Ixy,i %Ixy.i
Indexed input bit in rack Ixy,i (Wj) (PL7-3) %Ixy.i[%MWj]
Remote input bit RIx,y,i (PL7-3) %I\<path>\<mod>.<channel>
Indexed remote input bit RIx,y,i (Wj) (PL7-3)
Output bit in rack Oxy,i %Qxy.i
Indexed output bit in rack Oxy,i (Wj) (PL7-3) %Qxy.i[%MWj]
Remote output bit ROx,y,i (PL7-3) %Q\<path>\<mod>.<channel>
Indexed remote output bit ROx,y,i (Wj) (PL7-3)
I/O fault bit in rack
• module fault bit Ixy,S / Oxy,S %Ixy.MOD.ERR
• channel fault bit %Ixy.i.ERR
Remote I/O fault bit (PL7-3)
• module fault bit %I\<path>\<mod>.MOD.ERR
• channel fault bit RDx,y,i / ERRORx,y,i %I\<path>\<mod>.<channel>.ERR
• output channel trip bit TRIPx,y,i
• output channel reset bit RSTx,y,i
Internal bit Bi %Mi
Indexed internal bit Bi(Wj) (PL7-3) %Mi[%MWj]
System bit SYi %Si
Step bit Xi %Xi
Macro-step bit XMj (PL7-3) %XMj
Step bit i of macro-step j Xj,i (PL7-3) %Xj.i
Input step bit of macro-step j Xj,I (PL7-3) %Xj.IN
Output step bit of macro-step j Xj,O (PL7-3) %Xj.OUT
Bit j of internal word i Wi,j %MWi:Xj
Bit j of indexed internal word i Wi(Wk),j(PL7-3) %MWi[%MWk]:Xj
___________________________________________________________________________
4/1
B
Bit j of constant word i CWi,j %KWi:Xj
Bit j of indexed constant word i CWi(Wk),j (PL7-3) %KWi[%MWk]:Xj
Bit j of register i I/OWxy,i,j %IW/%QWxy.i:Xj
Bit k of common word j COMi,j,k %NWi.j:Xk
of station i COMXi,j,k (X = B, C, D) %NXWi.j:Xk
Bit j of system word i SWi,j %SWi:Xj
Words
Objects PL7-2/3 PL7 Micro/Junior
Single length internal word Wi %MWi
Indexed single length internal word Wi(Wj) (PL7-3) %MWi[%MWj]
Double length internal word DWi (PL7-3) %MDi
Indexed double length internal word DWi(Wj) (PL7-3) %MDi[%MWj]
Real internal word %MFi
Indexed real internal word %MFi[%MWj]
Single length constant word CWi %KWi
Indexed single length constant word CWi(Wj) %KWi[%MWj]
Double length constant word CDWi (PL7-3) %KDi
Indexed double length constant word CDWi(Wj) (PL7-3) %KDi[%MWj]
Real constant word %KFi
Indexed real constant word %KFi[%MWj]
Single length input register word IWxy,i %IWxy.i
Double length input register word %IDxy.i
Single length output register word OWxy,i %QWxy.i
Double length output register word %QDxy.i
Remote input register word RIWx,y,i (PL7-3) %IW\<path>\<mod>.<channel>
Remote output register word ROWx,y,i (PL7-3) %QW\<path>\<mod>.<channel>
System word SWi %SWi
Common word j of station i COMi,j %NW{i}j
COMXi,j (where X = B, C, D) %NW{[r.]i}j
r = network no.
Status word of a remote discrete module STATUSAx,y,i (PL7-3)
STATUSBx,y,i (PL7-3)
Status word of a remote discrete module channel STSx,y,i(PL7-3) %IW\<path>\<mod>.<channel>.ERR
Active time of Grafcet steps Xi,V %Xi.T
Active time of step i of macro-step j Xj,i,V (PL7-3) %Xj.i.T
___________________________________________________________________________
4/2
Differences between PL7-2/3 and PL7 Micro 4
B
Active time of input step Xj,I,V (PL7-3) %Xj.IN.T
of macro-step j
Active time of output step Xj,O,V (PL7-3) %Xj.OUT.T
of macro-step j
B
Function blocks
Objects PL7-2/3 PL7 Micro/Junior
Timer Ti %Ti
• preset value (word) Ti,P %Ti.P
• current value (word) Ti,V %Ti.V
• timer running (bit) Ti,R %Ti.R
• timer done (bit) Ti,D %Ti.D
Monostable Mi %MNi
• preset value (word) Mi,P %MNi.P
• current value (word) Mi,V %MNi.V
• monostable running (bit) Mi,R %MNi.R
Up/down counter Ci %Ci
• preset value (word) Ci,P %Ci.P
• current value (word) Ci,V %Ci.V
• upcounting overrun (bit) Ci,E %Ci.E
• preset done (bit) Ci,D %Ci.D
• downcounting overrun (bit) Ci,F %Ci.F
Register Ri %Ri
• input word (word) Ri,I %Ri.I
• output word (word) Ri,O %Ri.O
• register full (bit) Ri,F %Ri.F
• register empty (bit) Ri,E %Ri.E
Text TXTi no text block
Drum controller Di (PL7-2) %DRi
• number of active step (word) Di,S %DRi.S
• active time of current step (word) Di,V %DRi.V
• 16 command bits (word) Di,Wj %DRi.Wj
• last step in progress (bit) Di,F %DRi.F
Fast Counter / Timer FC (PL7-2) -
• preset value (word) FC,P -
• current value (word) FC,V -
• external reset (bit) FC,E -
• preset done (bit) FC,D -
• counting in progress (bit) FC,F -
Real-time clock H (PL7-2) -
• "WEEK" or "YEAR" type
day selection MTWTFSS (word) VD -
• start of active time period (word) BGN -
• end of active time period (word) END -
• current value < setpoint (bit) < -
• current value = setpoint (bit) = -
• current value > setpoint (bit) > -
___________________________________________________________________________
4/3
B
Bit and word tables
Objects PL7-2/3 PL7 Micro/Junior
Bit strings
• Internal bit string Bi[L] %Mi:L
• Input bit string Ixy,i[L] (PL7-3) %Ixy.i:L
• Output bit string Oxy.i[L] (PL7-3) %Qxy.i:L
• Grafcet step bit string Xi[L] (PL7-3) %Xi:L
• macro-step bit string XMi[L] (PL7-3)
Character strings %MBi:L (1)
(where i is even)
Word tables
• internal word table Wi[L] %MWi:L
• indexed internal word table Wi(Wj)[L] %MWi[%MWj]:L
• internal double word table DWi[L] (PL7-3) %MDi:L
• indexed internal double word table DWi(Wj)[L] (PL7-3) %MDi[%MWj]:L
• constant word table CWi[L] %KWi:L
• indexed constant word table CWi(Wj)[L] %KWi[%MWj]:L
• constant double word table CDWi[L] (PL7-3) %KDi:L
• indexed constant double word table CDWi(Wj)[L] (PL7-3) %KDi[%MWj]:L
• real table %MFi:L
• indexed real table %MFi[%MWj]:L
• constant real table %KFi:L
• indexed constant real table %KFi[%MWj]:L
• remote input element table RIx,y,i[L] (PL7-3)
• remote output element table ROx,y,i[L] (PL7-3)
• remote input indexed element table RIx,y,i(Wj)[L] (PL7-3)
• remote output indexed element table ROx,y,i(Wj)[L] (PL7-3)
___________________________________________________________________________
4/4
Differences between PL7-2/3 and PL7 Micro 4
B
Instructions
Objects PL7-2 PL7-3 PL7 Micro/Junior
Instructions on bits
• Reverse logic NOT NOT
• AND AND • AND B
• OR OR + OR
• Exclusive OR XOR XOR
• Rising edge RE RE
• Falling edge FE FE
• Set to 1 SET SET
• Reset to 0 RESET RESET
Instructions on words and double words
• Addition + + +
• Subtraction - - -
• Multiplication * * *
• Division / / /
• Comparisons >, >=, <, <=, =, <> >, >=, <, <=, =, <>
• Division remainder MOD REM REM
• Square root SQRT SQRT
• Absolute value ABS
• Logic AND AND AND AND
• Logic OR OR OR OR
• Exclusive logic OR XOR XOR XOR
• Logic complement CPL CPL NOT
• Incrementation INC INC
• Decrementation DEC DEC
• Logic shift to left SHL SHL
• Logic shift to right SHR SHR
• Circular shift to left SLC SLC ROL
• Circular shift to right SRC SRC ROR
Floating point instructions (1)
• Addition ADDF +
• Subtraction SUBF -
• Multiplication MULF *
• Division DIVF /
• Square root SQRTF SQRT
• Absolute value ABS
• Equality test EQUF =
• Strict superiority test SUPF >
• Strict inferiority test INFF <
• Other tests >=, <=, <>
___________________________________________________________________________
4/5
B
Instructions (continued)
Objects PL7-2 PL7-3 PL7 Micro/Junior
Instructions on byte strings
• Circular shift SLCWORD
Conversion instructions
• BCD to binary conversion BCD DTB BCD_TO_INT
• Binary to BCD conversion BIN BTD INT_TO_BCD
• ASCII to binary conversion ATB ATB STRING_TO_INT or
STRING_TO_DINT
• Binary to ASCII conversion BTA BTA INT_TO_STRING or
DINT_TO_STRING
• Gray to binary conversion GTB GRAY_TO_INT
• Floating point to integer conversion FTB REAL_TO_INT or
REAL_TO_DINT
• Integer to floating point conversion FTF INT_TO_REAL or
DINT_TO_REAL
• BCD to floating point conversion DTF BCD_TO_REAL
• Floating point to BCD conversion FTD REAL_TO_BCD
• ASCII to floating point conversion ATF STRING_TO_REAL
• Floating point to ASCII conversion FTA REAL_TO_STRING
Instructions on tables
• Arithmetic operations +, -, *, /, REM +, -, *, /, REM
• Logic operations AND, OR, XOR AND, OR, XOR, NOT
• Addition of words in a table + SUM
• Search for 1st different word EQUAL EQUAL
• Search for 1st equal word SEARCH FIND_EQU
Instructions on program
• Jump JUMP Li JUMP %Li
• Call for sub-routine CALL SRi SRi
• Return from sub-routine RET RETURN
• Stop application HALT HALT
• Conditional phrase IF/THEN/ELSE IF/THEN/ELSE/END_IF
• Iterative phrase WHILE/DO WHILE/DO/END_WHILE
Instructions on interruptions
• Test READINT
• Masking MASKINT MASKEVT
• Unmasking DMASKINT UNMASKEVT
• Acknowledgment ACKINT
• Generation of an IT to module SETIT
Explicit I/O instructions
• Read discrete inputs READBIT
• Write discrete outputs WRITEBIT
• Read registers READREG
• Write registers WRITEREG
• Read words READEXT
• Write words WRITEEXT
___________________________________________________________________________
4/6
Differences between PL7-2/3 and PL7 Micro 4
B
Instructions (continued)
Objects PL7-3 PL7 Micro/Junior
Instructions on functions blocks
• Preset PRESET Ti / Ci PRESET %Ti / %Ci
• Start START Ti / Mi START %Ti / %MNi B
• Activate task START CTRLi
• Reset RESET Ci / Ri / TXTi RESET %Ci / %Ri
• Deactivate task RESET CTRLi
• Upcounting UP Ci UP %Ci
• Downcounting DOWN Ci DOWN %Ci
• Store in a register PUT Ri PUT %Ri
• Retrieve from a register GET Ri GET %Ri
• Receive a message INPUT TXTi
• Transmit a message OUTPUT TXTi
• Transmit/Receive message EXCHG TXTi
• Execute an OFB EXEC <OFBi>
• Read telegrams READTLG
Delimiters
Objects PL7-2/3 PL7 Micro/Junior
Assignment -> :=
Left parenthesis for indexing ( [
Right parenthesis for indexing ) ]
Length of table [length] :length
___________________________________________________________________________
4/7
B
___________________________________________________________________________
4/8
Section
List of reserved words 55
5 List of reserved words
B
5.1 Reserved words
The following reserved words should not be used as symbols.
B
NB_BLOCKS PERIOD RETC
NB_COMMON_WORDS PHRASE RETCN
NB_CONSTANT_WORDS PHRASE_COMMENT RETURN
NB_CPT PID RET_COIL
NB_DRUM PID_MMI RIGHT B
NB_INTERNAL_BITS PLC ROL
NB_INTERNAL_WORDS POST ROLD
NB_MACRO_STEPS PRESET ROLW
NB_MONO PRINT ROL_ARD
NB_PAGES PRINT_CHAR ROL_ARR
NB_REG PRIO0 ROL_ARW
NB_TIMER PRIO1 ROL_DWORD
NB_TM PRIORITY ROL_WORD
NB_TRANSITIONS PRL ROR
NE PROG ROR_ARD
NIL PROGRAM ROR_ARR
NO PROG_LANGAGE ROR_ARW
NON_STORED PROG_LANGUAGE ROR_DWORD
NOP PT ROR_WORD
NOT PTC RRTC
NOT_ARX PUT RS
NOT_COIL PV RTB
NOT_READABLE PWM RTC
NO_GR7 P_CONTACT RTS
NO_PERIOD Q RUNG
N_CONTACT QUERY R_EDGE
O R R_TRIG
OCCUR R1 S
OCCUR_ARD RCV_TLG S1
OCCUR_ARR RE SAVE
OCCUR_ARW READ SAVE_PARAM
OF READ_EVT_UTW SCHEDULE
ON READ_ONLY SD
OPEN READ_PARAM SEARCH
OPEN_CONTACT READ_STS SECTION
OPERATE READ_VAR SEL
OR READ_WRITE SEMA
ORF REAL SEND
ORN REAL_TO_DINT SENDER
ORR REAL_TO_INT SEND_ALARM
OR_ARX REAL_TO_STRING SEND_MBX_ALARM
OTHERS REG SEND_MBX_MSG
OUT REM SEND_MSG
OUTIN_CHAR REPEAT SEND_REQ
OUTPUT REPLACE SEND_TLG
OUT_BLK REQ SERVO
P RESET SET
P0 RESET_COIL SET_COIL
P1 RESOURCE SFC
PAGE RESTORE_PARAM SHIFT
PAGE_COMMENT RET
PANEL_CMD RETAIN
___________________________________________________________________________
5/3
B
SHL TO XM_MULTI
SHOW_ALARM TOD XOR
SHOW_MSG TOF XORF
SHOW_PAGE TOFF XORN
SHR TON XORR
SHRZ TOP XOR_ARX
SIN TP YES
SINGLE TRANSITION
SINT TRANS_TIME
SL TRUE
SLCWORD TRUNC
SMOVE TYPE
SOFT_CONFIGURATION TYPES
SORT T_S_AND_LINK
SORT_ARD T_S_OR_LINK
SORT_ARW U
SQRT UDINT
SR UINT
ST ULINT
STANDARD UNMASKEVT
START UNTIL
STD UP
STEP USINT
STI USORT_ARD
STN USORT_ARW
STOP UTIN_CHAR
STR VAR
STRING VAR_ACCESS
STRING_TO_DINT VAR_EXTERNAL
STRING_TO_INT VAR_GLOBAL
STRING_TO_REAL VAR_INPUT
STRUCT VAR_IN_OUT
SUB VAR_OUTPUT
SUB_DT VERSION
SUB_TOD V_COMPARE
SUM V_LINK
SU_TYPE W
SWAP WHILE
S_T_AND_LINK WITH
S_T_OR_LINK WORD
T WRITE
TAN WRITE_CMD
TASK WRITE_PARAM
TASKS WRITE_VAR
THEN WRTC
TIME WSHL_RBIT
TIMER WSHRZ_C
TIME_OF_DAY WSHR_RBIT
TM W_BIT
TMAX XM
TMOVE XM_MONO
___________________________________________________________________________
5/4
Section 66
Conformity to the IEC 1131-1 standard
6 Conformity to the IEC 1131-1 standard B
6.1 Conformity to the IEC 1131-3 standard
IEC standard 1131-3 "PLCs - Part 3 : Programming languages" defines the syntax and
semantics of the software elements used to program PLCs.
This standard describes 2 textual languages, IL (Instruction List) and ST (Structured Text), B
2 graphic languages, LD (Ladder Diagram) and FBD (Function Block Diagram) and a
graphic chart, SFC (Sequential Function Chart), used to structure the internal organization
of a programmed sequence.
PL7 programming software is used to program a PLC conforming to the IEC standard : PL7
implements a subset of language elements defined in the standard and defines extensions
which are authorized within this standard.
IEC standard 1131-3 does not define the rules of interaction of software supplied by a
manufacturer claiming to conform to the standard, leaving a greater flexibility of presentation
and programming element entry for the convenience of the user.
The elements of the standard implemented in PL7, the specific implementation information
and the cases of detected errors are summarized in the conformity tables below.
Common elements
___________________________________________________________________________
6/1
B
1 4a Dollar sign ($)
1 5a Vertical bar (|)
1 6a Subscript delimiters : Left and right brackets "[]"
2 1 Upper case and numbers
2 2 Upper and lower case, numbers, embedded
underlines
3 1 Comments
4 1 Integer literals (Note 1)
4 2 Real literals (Note 1)
4 3 Real literals with exponents
4 4 Base 2 literals (Note 1)
4 6 Base 16 literals (Note 1)
4 7 Boolean Zero and One
4 8 Boolean TRUE and FALSE
5 1 Character string literal features
6 2 $$ Dollar sign
6 3 $’ Single quote
6 4 $L or $l Line feed
6 5 $N or $n New line
6 6 $P or $p Form feed (page)
6 7 $R or $r Carriage return
___________________________________________________________________________
6/2
Conformity to the IEC 1131-1 standard 6
B
6 8 $T or $t Tab
7 1a Duration literals with short prefix t# (Note 2)
10 1 BOOL -1 bit- B
10 10 REAL -32 bits-
10 12 TIME -32 bits- (Note 3)
10 13 DATE -32 bits- (Note 3)
10 14 TIME_OF_DAY -32 bits- (Note 3)
10 15 DATE_AND_TIME -64 bits- (Note 3)
10 16 STRING
10 17 BYTE -8 bits-
10 18 WORD -16 bits-
10 19 DWORD -32 bits-
15 1 I prefix for Input location
2 Q prefix for Output location
3 M prefix for Memory location
15 4 X prefix, single bit size
5 None prefix, single bit size
6 B prefix, byte size (8 bits)
7 W prefix, word size (16 bits)
8 D prefix, double word size (32 bits)
___________________________________________________________________________
6/3
B
___________________________________________________________________________
6/4
Conformity to the IEC 1131-1 standard 6
B
22 2 TRUNC function: truncation of a REAL type to 0
22 3 BCD_TO_INT conversion function (Note 6)
22 4 INT_TO_BCD conversion function (Note 6) B
23 1 ABS function: absolute value
23 2 SQRT function: square root
23 3 LN function: natural logarithm
23 4 LOG function: base 10 logarithm
23 5 EXP function: natural exponential
23 6 SIN function: sine in radians
23 7 COS function: cosine in radians
23 8 TAN function: tangent in radians
23 9 ASIN function: arc sine
23 10 ACOS function: arc cosine
23 11 ATAN function: arc tangent
25 1 SHL function: shift left
25 2 SHR function: shift right
25 3 ROR function: rotate right
25 4 ROL function: rotate left
29 1 LEN function: string length
29 2 LEFT function: leftmost n characters
29 3 RIGHT function: rightmost n characters
29 4 MID function: n characters from a given
position
29 5 CONCAT function: extensible concatenation (Note7)
29 6 INSERT function: insert one string into another
29 7 DELETE function: deletes characters
___________________________________________________________________________
6/5
B
29 8 REPLACE function: replaces characters
29 9 FIND function: find one string inside another
32 Input read (Note 8)
Input write
Output read
Output write
33 1 RETAIN qualifier on internal variables of the
function blocks (Note 9) (Note 4)
33 2 RETAIN qualifier on outputs of the function
blocks (Note 9) (Note 4)
33 4a Declaration of function block I/O
(Structured Text) (Note 4)
37 1 Pulse timer: TP (Note 10)
37 2a On-delay timer: TON (Note 10)
37 3a Off-delay timer: TOF (Note 10)
38 timing
diagrams TP, TON, TOF
39 19 Use of directly represented variables
(address)
40 1 Step, graphical form
Note: A step number replaces a step
identifier
40 2 Step, textual form used in the source form of
Grafcet only
41 1 Condition of transition in ST language
41 2 Condition of transition in LD language
42 2l Declarations of actions in LD language
43 1 Action block
43 2 Concatenated action blocks
___________________________________________________________________________
6/6
Conformity to the IEC 1131-1 standard 6
B
45 2 Action qualifier N (not stored)
45 11 Action qualifier P1 (Pulse rising edge)
B
45 12 Action qualifier P0 (Pulse falling edge)
46 1 Single sequence, alternation step/transition
46 2c "Or" divergence: user ensures that the transition
conditions are mutually exclusive
46 3 "Or" convergence
46 4 "And" divergence, "And" convergence
46 5c Sequence jump in an "or" divergence
46 6c Sequence loop: return to a previous step
46 7 Directional arrows
Note: Directional arrows point up and down
___________________________________________________________________________
6/7
B
Note 1: The underline characters (_) inserted between the digits of a numerical literal are
not accepted.
Note 2 : These literals are only visible in the application source, to show the time of
configured tasks.
Note 3: These types of data are not yet implemented in a manner visible to the user. This
table defines, however, the memory occupation of their internal representation.
Note 4 : These key words are only used in the sources generated by PL7 and by the PL7-2
and PL7-3 application conversion tool.
Note 5 : Effects of conversions to limits:
DINT_TO_STRING: If the string accepting the result is less than 13 characters, truncation
occurs and %S15 is set.
INT_TO_STRING: If the string accepting the result is less than 7 characters, truncation
occurs and %S15 is set.
STRING_TO_DINT et STRING_TO_INT: If the string cannot be converted to an integer,
the result is indeterminate and %S18 is set.
DATE_TO_STRING: If the string accepting the result is less than 11 characters,
truncation occurs and %S15 is set.
DT_TO_STRING: If the string accepting the result is less than 20 characters, truncation
occurs and %S15 is set.
TIME_TO_STRING: If the string accepting the result is less than 15 characters, truncation
occurs and %S15 is set.
TOD_TO_STRING: If the string accepting the result is less than 9 characters, truncation
occurs and %S15 is set.
REAL_TO_STRING: If the string accepting the result is less than 15 characters,
truncation occurs and %S15 is set.
STRING_TO_REAL: If the string cannot be converted to a real value, the value of the result
is «1.#NAN» (16#FFC0_0000) and %S18 is set.
REAL_TO_INT: If the real cannot be converted within the limits [-32768, +32767], the value
of the result is -32768 and %S18 and %SW17:X0 are set.
REAL_TO_DINT: If the real cannot be converted within the limits [-2147483648,
+2147483647], the value of the result is -2147483648 and %S18 and %SW17:X0 are set.
INT_TO_REAL: Conversion is always possible.
DINT_TO_REAL: Conversion is always possible.
Note 6 : As the type INT is not formally implemented, even though it is still used, these
functions enable the coding format of a WORD to be changed.
Note 7 : Limit the CONCAT function to the concatenation of 2 strings.
Note 8 : This paragraph applies to the predefined PL7 function blocks.
Note 9 : The RETAIN qualifier is implicit.
Note 10 : The timers TP, TON, TOF respect the timing diagrams of table 38, but have a
different I/O interface from that of 1131-3.
___________________________________________________________________________
6/8
Conformity to the IEC 1131-1 standard 6
B
IL language elements
Table no. Characteristic no. Description of characteristics
51 Instruction Label, operator, operand, comment
B
fields
52 1 LD
52 2 ST
52 3 S and R
52 4 AND
6 OR
7 XOR
52 18 JMP
52 20 RET
52 21 )
53 3 Use of input operators for launching
function blocks in IL language
54 11 IN (Note 11)
54 12 IN (Note 11)
54 13 IN (Note 11)
___________________________________________________________________________
6/9
B
55 6 * Multiply
7 / Divide
55 9 + Add
10 - Subtract
55 11 <, >, <=, >= Comparison
55 12 = Equality
55 13 <> Inequality
55 15 Boolean AND
55 16 XOR Boolean Exclusive or
55 17 Boolean or
56 1 := Assignment
56 3 RETURN structure
56 4 IF structure "if... then... elsif... then... else...
end_if"
56 6 FOR structure "for... to... do... end_for" (Note 13)
56 7 WHILE structure "while... do... end_while"
56 8 REPEAT structure "repeat ... until... end_repeat"
56 9 EXIT structure
Note 13 : Implementation of the FOR loop with an implicit step of 1 (by 1).
___________________________________________________________________________
6/10
Conformity to the IEC 1131-1 standard 6
B
Common graphic elements
Table no. Characteristic no.Description of characteristics
57 2 Graphic horizontal lines B
57 4 Graphic vertical lines
57 6 Graphic horizontal/vertical line connection
57 8 Graphic crossing of lines without connection
57 10 Graphic connected and non-connected corners
57 12 Blocks with graphic connected lines
58 2 Unconditional jump: LD language
58 4 Conditional jump: LD language
58 5 Conditional return: LD language
58 8 Unconditional return: LD language
LD language elements
Table no. Characteristic no. Description of characteristics
59 1 Left power rail
59 2 Right power rail
60 1 Horizontal link
60 2 Vertical link
61 1 Open contact
61 3 Closed contact
61 5 Positive transition-sensing contact
61 7 Negative transition-sensing contact
62 1 Coil
62 2 Negated coil
62 3 SET (latch) coil
62 4 RESET (unlatch) coil
___________________________________________________________________________
6/11
B
Implementation-dependent parameters
Parameter PL7 limitations and behavior
___________________________________________________________________________
6/12
Conformity to the IEC 1131-1 standard 6
___________________________________________________________________________
6/13
B
Depth of divergent and convergent Limit given by the entry grid
construction
List of PLC which can be programmed by TSX 3710, 3720,
PL7 TSX 5710, 5720, 5725, 5730,
5735, 5740, 57 45
PMX 5710, 5720, 5735, 5745,
PCX 5710, 5735
Maximum number of tasks 1 periodic or cyclic task
1 periodic task
8 event-triggered tasks
for 37 10 PLCs
16 event-triggered tasks
for 37 20 PLCs
32 event-triggered tasks
for 57 10 PLCs
64 event-triggered tasks
for 57 20/30 PLCs
Task interval range from 1 ms to 255 ms
Preemptive or non-preemptive scheduling Preemptive scheduling
Maximum length of an expression Variable
Partial evaluation of Boolean No
expressions
Maximum length of control structures Variable
in ST
Value of control variable after The value of the control variable
complete execution of a FOR loop equals the value of the limit
+ 1 (since the step is 1)
Graphic/semi-graphic representation Graphic representation
Restrictions on network topology An LD network can occupy a
maximum of 16 columns and 7
lines
___________________________________________________________________________
6/14
Conformity to the IEC 1131-1 standard 6
B
Note 14 : These types of data are not yet implemented in a manner visible to
the user. This table, however, defines their ranges of values in IEC 1131-3
format.
TIME: from T#0 to T#429496729.5s
TIME_OF_DAY: from TOD#0:0:0 to TOD#23:59:59 B
DATE_AND_TIME: from DT#1990-01-01:0:0:0 to DT#2099-12-31:23:59:59
DATE: from D#1990-01-01 to D#2099-12-31
___________________________________________________________________________
6/15
B
Error conditions
Error conditions PL7 limits and behavior
___________________________________________________________________________
6/16
Section
Quick reference 7
guide 7
7 Quick reference guide B
7.1 Quick reference guide
Boolean LD IL
instructions
Accumulator or
rung initialization LD TRUE B
Test (read) LD
direct, negated, LDN
rising edge, LDR
P N
falling edge LDF
P N
AND( AND(N AND(RAND(F
Inversion N
Exclusive logic OR XOR XORN
(direct, negated, rising XORR XORF
edge, falling edge
Write ST
( ) ( / )
(direct, negated) STN
Set to 1 S
(S ) (R )
Set to 0 R
Operation block OPERATE
(for contents see action [action]
following pages)
Horizontal comparison LD [comparison]
block AND [comparison]
COMPARE
(for contents see AND( [comparison]
comparison
comparaison
following pages) OR [comparison]
OR( [comparison]
XOR [comparison]
Vertical comparison COMPARE
block EN >
=
<
<>
___________________________________________________________________________
7/1
B
b
Instructions ST
Assignment :=
Boolean OR OR
Boolean AND AND
Boolean exclusive OR XOR
Negation NOT
Rising, falling edge RE, FE
Set to 1, set to 0 SET, RESET
Function blocks LD IL
IEC timer %TMi IN
IN Q
BLK..END_BLK structure
PL7-3 timer %Ti
E D
C R
Up/down counter % Ci R
R E
S
S D CU
CU F CD
CD BLK..END_BLK structure
%MNi
Monostable S
S R
BLK..END_BLK structure
%Ri
Register R
R F
I
I E O
O BLK..END_BLK structure
Drum % D Ri R
R F U
U
BLK..END_BLK structure
Function blocks ST
IEC timer START %TMi
DOWN %TMi
PL7-3 timer PRESET %Ti
START %Ti
STOP %Ti
Up/down counter RESET %Ci
PRESET %Ci
UP %Ci, DOWN %Ci
Monostable START %MNi
register RESET %Ri
PUT %Ri
GET %Ri
Drum RESET %DRi
UP %DRi
___________________________________________________________________________
7/2
Quick reference guide 7
B
Control structure ST
Conditional action IF...THEN... ELSIF...THEN... ELSE...END_IF;
Conditional iterative action WHILE...DO...END_WHILE;
Conditional iterative action REPEAT...UNTIL...END_REPEAT;
Repetitive action FOR...DO...END_FOR; B
Loop output instruction EXIT
Arithmetic operations on integers LD/IL/ST
(single and double length)
Transfer or initialization :=
Comparisons = <> <= “ >=
Addition, subtraction, multiplication, + - * / REM
division, remainder
AND, OR, exclusive OR, complement AND OR XOR NOT
Absolute value, square root ABS, SQRT
Increment INC
Decrement DEC
Shift to the left SHL
Shift to the right SHR
Circular shift to the left ROL
Circular shift to the right ROR
Arithmetic operations on floating points LD/IL/ST
Transfer or intialization :=
Comparisons = <> <= “ >=
Addition, subtraction, multiplication, + - * / TRUNC
division, integer part
Absolute value, square root ABS, SQRT
Logarithm, exponentials LOG, LN, EXPT, EXP
Sine, cosine, tangent SIN, COS, TAN
Arc sine, arc cosine, arc tangent ASIN, ACOS, ATAN
Degree <--> radian conversion DEG_TO_RAD, RAD_TO_DEG
___________________________________________________________________________
7/4
Quick reference guide 7
B
«Orphee» instructions LD/IL/ST
Shift to the left on word with retrieval of shifted WSHL_RBIT, DSHL_RBIT
bits
Shift to the right on word with sign extension and WSHR_RBIT, DSHR_RBIT
retrieval of shifted bits B
Shift to the right on word with filling of spaces WSHRZ_C, DSHRZ_C
with 0 and retrieval of shifted bits
Up/down counting with indication of SCOUNT
overshoot
Circular shift to the left ROLW, ROLD
Circular shift to the right RORW, RORD
Explicit exchanges LD/IL/ST
Read %M parameters of a logical channel READ_PARAM
Read status %M of a logical channel READ_STS
Restore %M parameters of a logical channel RESTORE_PARAM
Save %M parameters of a logical channel SAVE_PARAM
Write control %M of a logical channel WRITE_CMD
Write %M parameters of a logical channel WRITE_PARAM
Time management instructions LD/IL/ST
Realtime clock SCHEDULE
Comparisons = <> <= “ >=
Transfer :=
Read date and code of last PLC stop PTC
Read system date RRTC
Update system date WRTC
Add a time to a full date ADD_DT
Add a time to a time of day ADD_TOD
Convert date to string DATE_TO_STRING
Day of the week DAY_OF_WEEK
Difference between two dates DELTA_D
Difference between two full dates DELTA_DT
Difference between two times of day DELTA_TOD
Convert full date to string DT_TO_STRING
Subtract a duration from a full date SUB_DT
Subtract a duration from a time of day SUB_TOD
Convert duration to string TIME_TO_STRING
Convert time of day to string TOD_TO_STRING
Change duration to hours-min-sec format TRANS_TIME
Time delay instructions LD/IL/ST
On-delay FTON
Off-delay FTOF
Pulse time delay FTP
Square wave signal generator FPULSOR
Data archiving instructions LD/IL/ST
Initialize archiving zone on PCMCIA card SET_PCMCIA
Write data to PCMCIA card WRITE_PCMCIA
Read data from PCMCIA card READ_PCMCIA
___________________________________________________________________________
7/5
B
Instructions on character strings LD/IL/ST
Comparisons = <> <= “ >=
Transfer :=
Convert double integer to string DINT_TO_STRING
Convert single integer to string INT_TO_STRING
Convert string to double integer STRING_TO_DINT
Convert string to single integer STRING_TO_INT
Convert string to floating point value STRING_TO_REAL
Convert floating point value to string REAL_TO_STRING
Concatenation of two chains CONCAT
Delete substring DELETE
Find first different character EQUAL_STR
Find substring FIND
Insert substring INSERT
Extract left part of a string LEFT
Length of a string LEN
Extract substring MID
Replace substring REPLACE
Extract right part of a string RIGHT
Communication LD/IL/ST
Request to stop a function in progress CANCEL
Send and/or receive data DATA_EXCH
Request to read character string INPUT_CHAR
Send and/or request to receive a character string OUT_IN_CHAR
Send character string PRINT_CHAR
Receive telegram RCV_TLG
Read basic language objects READ_VAR
Send/receive UNI-TE requests SEND_REQ
Send telegram SEND_TLG
Write basic language objects WRITE_VAR
Circular shift one byte to the right in a table ROR1_ARB
Swap bytes in a word table SWAP
Read common Modbus+ data READ_GDATA
Write common Modbus+ data WRITE_GDATA
Management of the modem card connection CALL_MODEM
Immediate server SERVER
Write 1 K message WRITE_ASYN
Read 1 K message READ_ASYN
___________________________________________________________________________
7/6
Section 88
Performance
8 Performance
B
8.1 General
The execution time of the program is calculated using the tables on the following pages,
by adding up the time taken for each program instruction.
Note : the time obtained is a maximum time. In fact, an operate block or a subroutine
will only be processed if the execution condition (logic equation conditioning the
execution of the block or subroutine) is true. It may be, therefore, that the actual time
is much less than the maximum time calculated.
Calculating the complete cycle time involves parameters which are specific to the PLC
(overhead time, duration of I/O exchange, etc.). Please refer to the PLC installation
manual (performance section) for the complete calculation procedure.
___________________________________________________________________________
8/1
B
In the tables on the following pages, information on sizes refers to the volume of
instruction codes. In order to find out the total size of an instruction or a program, it is
necessary to use a multiplication coefficient which takes account of information that is
typical to a language (for example : graphic information in the case of Ladder language).
• Grafcet language :
The volume associated with the chart itself is as follows :
Chart volume (in words) = 214 + 17 * no. of chart steps + 2 * total no. of configured
steps + 4 * no. of programmed actions
Comment
The figures shown in the following tables are average estimations obtained from a
typical application. It is not possible to provide exact data, since PL7 optimizes
memory use according to the contents and structure of the application.
Section 8.4.1 describes the various memory zones occupied by the application.
___________________________________________________________________________
8/2
Performance 8
B
8.2 TSX 37 performance
8.2.1 Boolean instructions
LD IL ST Objects Execution time Size
(µs) (words)
3705 3720 3720 37xx B
08/10 ram cart
0.25 0.13 0.19 1
LDN
%M1[%MW2] 13.10 12.85 12.85 7
%MW0:X0 (2) 6.06 5.75 5.75 4
%IWi.j:Xk (3) 77.04 69.25 69.25 8
%MW0[%MW10]:X0 16.29 15.55 15.55 8
%KW0[%MW10]:X0 87.27 79.05 79.05 12
LDR, %M1 0.50 0.25 0.38 2
LDF
%M1[%MW2] 13.01 12.75 12.75 7
AND, idem LD, LDN
S, R
%M1[%MW2] 13.10 12.85 12.85 7
%MW0:X0 5.88 5.60 5.60 4
%NW{i}j:Xk (3) 76.86 69.10 69.10 8
%MW0[%MW10]:X0 16.41 15.65 15.65 8
multiple coils in Ladder, «cost» of the 2nd and subsequent coils 0.25 0.13 0.19 1
operation block [ action] block executed 0.74 0.75 0.75 1
not executed 5.55 5.40 5.40 1
(1) This concerns all the bit objects which can be forced : %I, %Q, %X, %M, %S
(2) Other objects of the same type : output bits of function block %TMi.Q ..., system
word extract bits %SWi:Xj
(3) Other objects of the same type : common word extract bits %NW{i}j:Xk, I/O word
extract bits %IWi.j.Xk, %QWi.j.Xk, %KW extract bits, fault bits %Ii.j.ERR
___________________________________________________________________________
8/3
B
LD IL ST Objects Execution time Size
(µs) (words)
3705 3720 3720 37xx
08/10 ram cart
horizontal comparison LD time in addition to the 0.00 0.00 0.00 0
block [comparison] comparison
vertical comparison between 2 %MWi 12.38 11.85 11.85 4
block
convergence ) ) 0.25 0.13 0.19 1
divergence not followed ladder, 1 divergence 0.25 0.13 0.19 1
by a convergence
MPS, MPP, list MPS+MPP 0.75 0.38 0.56 3
MRD list MRD 0.25 0.13 0.19 1
IE timer
rising edge on IN IN %TM1 START %TM1 start timer 43.39 41.11 3
(rising edge)
falling edge on IN IN %TM1 DOWN %TM1 stop timer 17.47 17.01
(falling
edge)
IN =1 IN %TM1 (=1) timer on 18.74 17.99
PL7-3 timer
START %T1 enable 3
timer off
Up/down counter
reset, R=1 R %C8 (=1) RESET %C8 reset 18.69 17.92 3
___________________________________________________________________________
8/4
Performance 8
B
Function blocks (continued)
LD IL ST objects/conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx
B
Monostable
rising edge on S S %MN0, START %MN0 start 35.08 33.16 3
rising edge
S=1 S %MN0, active monostable 11.64 11.17
S=1/0
Register
edge on I I %R2 (edge) PUT %R2 store 21.90 21.27 3
Drum
edge on U U %DR0 UP %DR1 up, fixed 181.37 169.13 3
___________________________________________________________________________
8/5
B
8.2.3 Integer and floating point arithmetic
70.98 63.50 2
• Value to add for an operation with the result of an operation in parentheses or of a higher prior-
ity, example : %MW0 + %MW2 + (...)
%MW0 2.86 2.55 1
___________________________________________________________________________
8/6
Performance 8
B
ST Objects Conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx
object after the := %MW0 4.81 4.50 2
%MD0,%MF0 6.45 5.70 2
:= %MW0 4.46 4.30 2
B
%MD0 5.15 4.85 2
et %MF0
=, <>, <=, <, >, >= %MW0 8.94 8.50 4
%MD0 10.71 10.26 4
%MF0 29.06 28.39 4
AND, OR, XOR %MW0 7.29 6.90 3
%MD0 9.21 8.55 3
+, - %MW0 7.29 6.90 3
%MD0 9.21 8.55 3
%MF0 62.83 61.20 3
* %MW0 9.75 9.10 3
%MD0 39.63 36.50 3
%MF0 58.26 56.90 3
/, REM %MW0 10.69 10.08 3
%MD0 205.21 201.38 3
/ %MF0 62.47 60.25 3
ABS, -object %MW0 7.20 6.95 3
%MD0 9.97 9.53 3
%MF0 13.01 12.50 3
NOT %MW0 6.69 6.45 3
%MD0 7.80 7.40 3
SQRT %MW0 17.02 16.70 3
%MD0 85.73 85.25 3
%MF0 165.04 158.40 3
INC, DEC %MW0 4.86 4.40 2
%MD0 5.20 4.75 2
SHL, SHR, ROL, ROR %MW0 for 1 bit 17.74 17.05 5
%MD0 for 1 bit 20.58 19.15 5
per additional bit 0.063
___________________________________________________________________________
8/7
B
8.2.4 Program instructions
ST Objects Conditions Execution time Size
(µs) (words)
3705/08/10 3720 37xx
Jump %Li 41.93 38.20 3
Maskevt 12.21 10.80 1
Unmaskevt 40.27 37.10 1
SRi 48.68 42.88 3
Return 42.18 38.33 3
___________________________________________________________________________
8/8
Performance 8
B
8.2.6 Numeric conversions
ST Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
___________________________________________________________________________
8/9
B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
___________________________________________________________________________
8/10
Performance 8
B
8.2.8 Word, double word and floating point value tables
ST conditions Execution time volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
___________________________________________________________________________
8/11
B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
*
%MW0:10 :=%MW20*%MW10:10; 10 words 166.86 132.45 132.45 12
per word 7.94 5.05 5.05
%MD0:10:=%MD20*%MD10:10; 10 double words 587.01 522.95 522.95 12
per double word 49.18 43.80 43.80
/, REM
%MW0:10 :=%MW10:10 / %MW30; 10 words 196.69 155.85 155.85 12
per word 10.86 7.30 7.30
%MD0:10:=%MD10:10 / %MD30; 10 double words 2 230.17 2 173.95 2 173.95 12
per double word 213.66 208.90 208.90
AND, OR, XOR
%MW0:10 :=%MW10:10 AND %MW20; 10 words 117.20 106.45 106.45 12
per word 2.64 2.40 2.40
%MD0:10:=%MD20*%MD10:10; 10 double words 587.01 522.95 522.95 12
per double word 6.47 6.15 6.15
NOT
%MW0:10 :=NOT(%MW10:10); 10 words 110.28 100.25 100.25 9
per word 2.96 2.75 2.75
%MD0:10:=NOT(%MD10:10); 10 double words 126.39 114.00 114.00 9
per double word 4.50 4.05 4.05
___________________________________________________________________________
8/12
Performance 8
B
ST conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
Find
%MW20 := FIND_EQW(%MW0:10,%KW0) 10 words, max. 340.00 250.00 266.25 15
instance
%MD20 := FIND_EQD(%MD0:10, %KD0) 10 double words, 350.00 260.00 276.90 16
max. instance
%MF20 := FIND_EQR(%MF0:10, %KF0) 10 double words 833 648 690.12 15
%MF20 := FIND_EQRP(%MF0:10, %KF0) 10 double words 845 650 692.25 15
%MD20 := FIND_GTR(%MF0:10, %KF0) 10 double words 836 643 684.79 15
%MD20 := FIND_LTR(%MF0:10, %KF0) 10 double words 836 643 684.79 15
Number of occurrences
%MW20 := OCCUR_ARW(%MW0:10, %KW0) 10 words 350.00 250.00 266.25 15
%MD20 := OCCUR_ARD(%MD0:10, %KD0) 10 double words 370.00 270.00 287.55 16
%MF20 := OCCUR_ARR(%MF0:10, %KF0) 10 double words 1265 973 1036.24 16
Circular shift
ROL_ARW(word or value, %MWj:10) 10 words 550.00 400.00 426.00 9
ROL_ARD(%MDi,%MDj:10) 10 double words 590.00 430.00 457.95 9
ROL_ARR(%MFi,%MFj:10) 10 double words 585 450 479.25 9
Sort
SORT_ARW(%MWi,%MWj:10) 10 words, max. 970.00 700.00 745.50 9
instance
SORT_ARD(%MDi,%MDj:10) 5 double words, max. 610.00 450.00 479.25 9
instance
SORT_ARR(%MFi,%MFj:10) 10 double words 1863 1433 1526.14 9
___________________________________________________________________________
8/13
B
8.2.9 Time management
ST Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
___________________________________________________________________________
8/14
Performance 8
B
8.2.10 Character strings
ST Conditions Execution time Volume
(µs) (words)
3705/08/10 3720 ram 3720 cart 37xx
B
Character string assignment, feedback
%MB0:8:=%MB10:8 8 characters 105.16 93.80 93.80 9
per character 1.65 1.30 1.30
%MB0:8:=’abcdefg’ 8 characters 120.72 110.20 110.20 11
per character 4.15 3.85 3.85 0.5
String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) 1 170.00 770.00 820.05 15
%MB10:20 := DELETE(%MB10:22.2,3); 950.00 600.00 639.00 15
%MW0 := EQUAL_STR(%MB10:20,%MB30:20); the 5th character 860.00 520.00 553.80 13
is different
%MW0 := FIND(%MB10:20,%MB30:10); 1 610.00 1 000.00 1 065.00 13
%MB10:20 := INSERT(%MB30:10,%MB50:10.4); 1 270.00 800.00 852.00 17
%MB10:20 := LEFT(%MB30:30,20); 920.00 570.00 607.05 13
%MW0 := LEN(%MB10:20); 770.00 340.00 362.10 9
%MB10:20 := MID(%MB30:30,20,10); 1 080.00 700.00 745.50 15
%MB10:20 : 1 450.00 870.00 926.55 19
= REPLACE(%MB30:20,%MB50:10,10,10);
%MB10:20 := RIGHT(%MB30:30,20); 1 480.00 950.00 1 011.75 13
___________________________________________________________________________
8/15
B
8.2.11 Application-specific functions and Orphee function
ST Conditions Execution time Volume
(µs) (words)
3705/ 3720 3720 37xx
08/10 ram cart
Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10,%MW30:4) 2182 1818 1936 21
SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 1636 1364 1452 15
Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2208 19
SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2208 19
GET_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
GET_VALUE(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) 2 240 2 000 2 208 23
ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) 2 240 2 000 2 208 21
DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) 1 120 1 000 1 104 17
CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 000 2 208 19
Process control
PID(“PIDS1”,’Unit’,%IW3.5,%MW12,%M16,%MW284:43) deval_mmi=0 1320 1100 1172 24
deval_mmi=1 1080 900 958.5
PWM(%MW11,%Q2.1,%MW385:5) 600 500 532.5 11
SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3,%MW284:43, 960 800 852 19
%MW390:10)
PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1140 950 1012 20
___________________________________________________________________________
8/16
Performance 8
B
ST Conditions Execution time Volume
(µs) (words)
3705/ 3720 3720 37xx
08/10 ram cart
Orphee function
DSHL_RBIT(%MD102,16,%MD204,%MD206) read 10 words 440 320 341 13 B
DSHR_RBIT(%MD102,16,%MD204,%MD206) write 10 words 660 480 511 13
DSHRZ_C(%MD102,16,%MD204,%MD206) mirror req.10 words 410 310 330 13
WSHL_RBIT(%MW102,8,%MW204,%MW206) exchange 10 words 300 220 234 13
WSHR_RBIT(%MW102,8,%MW204,%MW206) 20 bytes 390 280 298 13
WSHRZ_C(%MW102,8,%MW204,%MW206) 20 bytes 300 220 234 13
SCOUNT(%M100,%MW100,%M101,%M102,%MW101, 20 bytes 510 410 437 25
%MW102,%M200,%M201,%MW200,%MW201)
___________________________________________________________________________
8/17
B
8.3 TSX 57 performance
A more convenient method of displaying the processors has been used in the rest of this
document, by grouping them into 3 families :
Reference Processors
A TSX 57 10 and PCX 57 10
B TSX 57 20, TSX 57 25, TSX 57 30, TSX 57 35
PMX 57 10, PCX 57 35
C TSX 57 40, TSX 57 45
PMX 57 20, PMX 57 35, PMX 57 45
Note : in the rest of this document, the 3 families are shown at the foot of each page as a
reminder.
___________________________________________________________________________
8/18
Performance 8
B
8.3.1 Boolean instructions
LD IL ST Objects Execution time Size
(µs) (words)
A A B/C B/C B/C B/C 57xx
> 4K ram ram cart cart
0.29 0.12
> 4K
0.21
> 4K
1
B
LDN
%M1[%MW2] 2.33 1.00 1.00 1.58 1.58 6
%MW0:X0 (2) 1.46 0.62 0.62 1.00 1.00 4
%IWi.j:Xk (3) 2.33 1.00 1.00 1.58 1.58 6
%MW0[%MW10]:X0 3.50 1.50 1.50 2.37 2.37 9
%KW0[%MW10]:X0 3.50 1.50 1.50 2.37 2.37 9
LDR, %M1 0.87 0.37 0.50 0.58 0.79 2
LDF
%M1[%MW2] 2.62 1.12 1.12 1.79 1.79 7
AND, idem LD, LDN
S, R
%M1[%MW2] 2.62 1.12 1.12 1.75 1.75 7
%MW0:X0 1.75 0.75 0.75 1.17 1.17 4
%NW{i}j:Xk (3) 2.62 1.12 1.12 1.75 1.75 8
%MW0[%MW10]:X0 3.79 1.25 1.25 2.54 2.54 8
multiple coils in Ladder, «cost» of the 2nd and subsequent coils 0.87 0.37 0.50 0.54 0.75 1
operation block [ action] block executed 0.58 0.25 0.25 0.42 0.42 1
not executed 0.71 0.37 0.37 0.54 0.54 1
(1) This refers to all bit objects which can be forced : %I, %Q, %X, %M, %S
(2) Other objects of the same type : output bits of function block %TMi.Q ..., system word extract
bits %SWi:Xj, %KW extract bits, fault bits %Ii.j.ERR
(3) Other objects of the same type : common word extract bits %NW{i}j:Xk, I/O word extract bits
%IWi.j.Xk, %QWi.j.Xk
___________________________________________________________________________
8/19
B
LD IL ST Objects Execution time Size
(µs) (words)
A A B/C B/C B/C B/C 57xx
> 4K ram ram cart cart
> 4K > 4K
horizontal LD [comparison] time in addition to 0.00 0.00 0.00 0.00 0.00 0.00 0
comparison block the comparison
vertical between 2 %MWi 2.04 2.04 0.87 0.87 1.37 1.37 5
comparison block
convergence ) ) 0.29 0.29 0.12 0.12 0.21 0.21 1
divergence not followed ladder, 1 divergence 0.29 0.29 0.12 0.12 0.21 0.21 1
by a convergence
MPS, MPP, list MPS+MPP 0.87 0.87 0.37 0.37 0.62 0.62 3
MRD list MRD 0.29 0.29 0.12 0.12 0.21 0.21 1
IE timer
rising edge on IN IN %TM1 START %TM1 start timer 67.87 46.92 13.52 3
(rising edge)
falling edge on IN IN %TM1 DOWN %TM1 stop timer 27.84 19.50 5.01
(falling edge)
IN =1 IN %TM1 (=1) timer on 32.15 22.66 5.80
IN =0 IN %TM1 (=0) timer off 28.60 20.18 5.40
PL7-3 timer
START %T1 enable 3
STOP %T1 freeze 23.08 16.16 5.13
E=0 RESET %T1 reset 23.46 16.26 5.85
timer on 30.40 21.51 5.78
timer off
Up/down counter
reset, R=1 R %C8 (=1) RESET %C8 reset 30.38 21.26 6.11 3
preset, S=1 S %C9 (=1) PRESET %C9 preset 33.99 23.55 6.25
rising edge on CU CU %C8 UP %C8 up 33.81 23.49 6.50
(rising edge)
rising edge on CD CD %C9 DOWN %C9 down 33.81 23.49 6.50
rising edge)
inactive steps R/S/CU/CD inactive bit no action 22.37 16.22 4.58
B
Function blocks (continued)
LD IL ST objects/conditions Execution time Size
(µs) (words)
A B C 57xx
B
Monostable
rising edge on S S %MN0, START %MN0 start 57.42 40.65 11.88 3
rising edge
S=1 S %MN0, active monostable 20.38 14.11 4.04
S=1/0
Register
edge on I I %R2 (front) PUT %R2 store 35.69 24.92 6.72 3
edge on O O %R2 (front) GET %R2 retrieve 35.69 24.92 6.72
R=1 R %R1 (=1) RESET %R2 reset 26.83 18.80 6.11
inactive inputs I/O/R, inactive no action 20.71 15.50 4.62
bit
Drum
edge on U U %DR0 UP %DR1 up, fixed 268.69 185.41 58.68 3
per control bit 25.00 25.00 25.00
R=1 R %DR1 RESET %DR2 reset, fixed 257.01 176.06 57.00
per control bit 25.00 25.00 25.00
inactive inputs R/U, inactive bit no action, fixed 259.07 179.06 56.82
per control bit 25.00 25.00 25.00
B
ST objects conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
object after the := %MW0 0.87 0.37 0.58 0.37 0.58 2
%MW0+(..., or before *, /, REM 1.17 0.50 0.75 0.50 0.75 2
%MD0 1.17 0.50 0.75 0.50 0.75 2 B
%MD0+(..., or before *, /, REM 1.75 0.75 1.08 0.75 1.08 2
%MF0 1.75 0.75 1.08 0.75 1.08 2
:= %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 and %MF0 1.17 0.50 0.75 0.50 0.75 2
=, <>, <=, <, >, >= %MW0 1.17 0.50 0.79 0.50 0.79 4
%MD0 1.46 0.62 1.04 0.62 1.04 4
%MF0 48.36 33.88 34.13 4.17 4.42 4
AND, OR, XOR %MW0 0.87 0.37 0.58 0.37 0.58 3
%MD0 1.17 0.50 0.75 0.50 0.75 3
+, - %MW0 0.87 0.37 0.58 0.37 0.58 3
%MD0 1.17 0.50 0.75 0.50 0.75 3
%MF0 99.42 71.51 71.76 4.42 4.67 3
* %MW0 10.83 9.14 9.35 4.65 4.86 3
%MD0 55.31 42.71 42.96 15.26 15.51 3
%MF0 87.60 63.61 63.86 4.42 4.67 3
/, REM %MW0 11.93 9.99 10.20 4.94 5.15 3
%MD0 333.15 226.54226.79 49.38 49.63 3
/ %MF0 95.83 68.51 68.76 5.72 5.97 3
ABS, -object %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 1.17 0.54 0.75 0.54 0.75 2
%MF0 18.82 13.01 13.26 3.67 3.92 2
NOT %MW0 0.87 0.37 0.58 0.37 0.58 2
%MD0 1.17 0.54 0.75 0.54 0.75 2
SQRT %MW0 22.20 16.24 16.45 5.53 5.74 3
%MD0 111.29 89.66 89.91 16.14 16.39 3
%MF0 233.62 173.01173.26 5.10 5.35 3
INC, DEC %MW0 1.17 0.50 0.75 0.50 0.75 2
%MD0 1.75 0.75 1.08 0.75 1.08 2
SHL, SHR, ROL, ROR %MW0 for 1 bit 2.92 1.25 1.96 1.25 1.96 10
%MD0 for 1 bit 3.21 1.37 2.12 1.37 2.12 10
per additional bit 0.042 0.042 0.042 0.042 0.042
B
8.3.6 Numeric conversions
ST Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
BCD_TO_INT 30.33 24.44 24.65 4.75 4.96 3
INT_TO_BCD 24.48 20.19 20.40 4.51 4.72 3 B
GRAY_TO_INT 59.73 40.79 41.00 5.82 6.02 3
INT_TO_REAL 60.35 40.64 40.85 3.25 3.46 3
DINT_TO_REAL 49.14 34.76 35.01 3.67 3.92 3
REAL_TO_INT 91.59 60.86 61.11 3.38 3.63 3
REAL_TO_DINT 68.84 48.31 48.56 3.67 3.92 3
DBCD_TO_DINT 1 625.73 1 069.50 1 192.30 378.40 378.15 5
DBCD_TO_INT 1 379.53 909.63 1 014.07 323.83 323.62 5
DINT_TO_DBCD 1 251.05 819.50 913.55 314.88 314.63 5
INT_TO_DBCD 620.01 439.50 489.85 168.73 168.48 5
B
8.3.8 Word, double word and floating point value tables
B
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
Find
%MW20 := FIND_EQW(%MW0:10,%KW0) 10 words 374.68 240.00 267.60 97.00 97.00 14
%MD20 := FIND_EQD(%MD0:10, %KD0) 10 double words 394.40 260.00 289.90 100.00 100.00 15
%MF20 := FIND_EQR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MF20 := FIND_EQRP(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MD20 := FIND_GTR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
%MD20 := FIND_LTR(%MF0:10, %KF0) 10 double words 936 624.00 645.53 135.70 135.70 15
Number of occurrences
%MW20:=OCCUR_ARW(%MW0:10,%KW0) 10 words 394.40 260.00 289.90 100.00 100.00 14
%MD20:=OCCUR_ARD(%MD0:10,%KD0) 10 double words 423.98 280.00 312.20 107.69 107.69 15
%MF20 := OCCUR_ARR(%MF0:10, %KF0) 10 double words 1435 957.00 990.02 239.25 293.25 15
Circular shift
ROL_ARW(word or value, %MWj:10) 10 words 621.18 400.00 446.00 153.85 153.85 12
ROL_ARD(%MDi,%MDj:10) 10 double words 670.48 430.00 479.45 165.38 165.38 12
ROL_ARR(%MFi,%MFj:10) 10 double words 654 436.00 451.04 109.00 109.00 12
Sort
SORT_ARW(%MWi,%MWj:10) 10 words 1 133.90 720.00 802.80 276.92 276.92 12
SORT_ARD(%MDi,%MDj:10) 10 double words 700.06 440.00 490.60 169.23 169.23 12
SORT_ARR(%MFi,%MFj:10) 10 double words 2150 1433.00 1482.44 358.25 358.25 12
Length calculation
LENGTH_ARW(tab_word) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARD(tab_dword) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARW(tab_real) 71.42 50 55.74 19.28 19.28 12
LENGTH_ARX(tab_bit) 71.42 50 55.74 19.28 19.28 12
B
8.3.11 Character strings
ST conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
B
Character string assignment, feedback
%MB0:8:=%MB10:8 8 characters 147.75 103.56 103.56 51.96 51.96 15
per character 1.64 1.25 1.25 1.21 1.21
%MB0:8:=’abcdefg’ 8 characters 193.86 136.88 136.88 56.53 56.53 14
per character 5.94 4.35 4.35 1.69 1.69 0.5
String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) 1 106.00 790.00 880.85 303.85 303.85 24
%MB10:20 := DELETE(%MB10:22,2,3); 896.00 640.00 713.60 246.15 246.15 21
%MW0 := EQUAL_STR(%MB10:20,%MB30:20); 756.00 540.00 602.10 207.69 207.69 19
%MW0 := FIND(%MB10:20,%MB30:10); 1 456.00 1 040.00 1 159.60 400.00 400.00 19
%MB10:20 := INSERT(%MB30:10,%MB50:10,4); 1 162.00 830.00 925.45 319.23 319.23 26
%MB10:20 := LEFT(%MB30:30,20); 826.00 590.00 657.85 226.92 226.92 19
%MW0 := LEN(%MB10:20); 490.00 350.00 390.25 134.62 134.62 12
%MB10:20 := MID(%MB30:30,20,10); 994.00 710.00 791.65 273.08 273.08 21
%MB10:20 :=
REPLACE(%MB30:20,%MB50:10,10,10); 1 246.00 890.00 992.35 342.31 342.31 28
%MB10:20 := RIGHT(%MB30:30,20); 1 358.00 970.00 1 081.55 373.08 373.08 19
Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10, 2 800 2 000 2 230 33
%MW30:4)
SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 2 100 1 500 1 673 24
Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
GET_MSG(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
GET_VALUE(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) 2 800 2 000 2 230 800 32
ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) 2 800 2 000 2 230 800 27
DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) 1 400 1 000 1 115 400 20
CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 000 2 230 800 25
Process control
PID(“PIDS1”,’Unit’,%IW3.5,%MW12,%M16, deval_mmi=0 1700 1100 1227 32
%MW284:43)
deval_mmi=1 1500 900 1004
PWM(%MW11,%Q2.1,%MW385:5) 700 500 557.5 17
SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3, 1000 800 892 31
%MW284:43,%MW390:10)
PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1400 1000 1115 30
Data archiving
SET_PCMCIA (for 1600 words) 6000 8000 24
WRITE_PCMCIA (for 1600 words) 6000 7000 24
READ_PCMCIA (for 1600 words) 4000 7000 24
B
ST Conditions Execution time Volume
(µs) (words)
A B ram B cart C ram C cart 57xx
Orphee function B
DSHL_RBIT(%MD102,16,%MD204,%MD206) read 10 words 493 320 357 123 17
DSHR_RBIT(%MD102,16,%MD204,%MD206) write 10 words 749 510 569 196 17
DSHRZ_C(%MD102,16,%MD204,%MD206) mirror req. 10 words 493 310 346 119 17
WSHL_RBIT(%MW102,8,%MW204,%MW206) exchange 10 words 365 220 245 85 17
WSHR_RBIT(%MW102,8,%MW204,%MW206) 20 bytes 424 290 323 112 17
WSHRZ_C(%MW102,8,%MW204,%MW206) 20 bytes 365 220 245 85 17
SCOUNT(%M100,%MW100,%M101,%M102, 20 bytes 670 420 468 162 38
%MW101,%MW102,%M200,%M201,%MW200,
%MW201)
Read_Sts %CHi.MOD
Whatever the application, except for the 997 712 748 316.4 316.4 2
processor communication channel
Read_Sts %CHi
Discrete input 462 330 347 147 147 6
Discrete output 630 450 473 201 201
Analog input 510 380 390 170 170 6
Analog output 500 370 380 165 165
CTY 518 370 389 165 165
CFY 756 540 567 241 241
CAY 532 380 399 170 170
Write_Param %CHi
Analog input 860 620 630 277 277 6
Analog output 810 580 600 259 259
CTY 1 134 810 851 362 362
CFY 1 064 760 798 339 339
CAY 784 560 588 250 250
Read_Param %CHi
Analog input 180 120 130 54 54 6
Analog output 180 120 130 54 54
CTY 532 380 399 170 170
CFY 644 460 483 205 205
CAY 630 450 473 201 201
Save_Param %CHi
Analog input 1 300 880 890 393 393 6
Analog output 1 300 890 900 397 397
CTY 1722 1230 1292 549 549
CFY 700 500 525 223 223
CAY 700 500 525 223 223
Restore_Param %CHi
Analog input 800 570 590 254 254 6
Analog output 800 570 590 254 254
CTY 1148 820 861 366 366
CFY 1092 780 819 348 348
CAY 826 590 620 263 263
Write_Cmd %CHi
Discrete output 448 320 336 143 143 6
Analog input
. input forcing 200 140 150 63 63
. input forcing 1 390 1 020 1 040 455 455
Analog output : output forcing
Discrete output 210 150 150 67 67
Smove %CHi
CFY 1176 840 882 375 375 19
CAY 1148 820 861 366 366
A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/34
Performance 8
B
8.3.15 DFB function block
Size occupied by DFB type
Size of DFB type = Size of DFB variables and parameters + size of DFB code
• Size of DFB variables and parameters =
B
110 + Sum of the variable and parameter descriptors + Sum of the sizes occupied by
each variable or parameter
Descriptor of a variable or a parameter = 5.5 + (Number of characters in the name
of the variable or parameter)/2
Size occupied by each variable or parameter :
Type IN IN/OUT OUT PUBLIC PRIVATE
EBOOL 0.5 2 0.5 0.5 0.5
BOOL 0.5 2 0.5 0.5 0.5
WORD 1 2 1 1 1
DWORD 2 2 2 2 2
REAL 2 2 2 2 2
AR_X 3 3 0.5*N 0.5*N 0.5*N
AR_W 3 3 N N N
AR_D 3 3 2*N 2*N 2*N
AR_R 3 3 2*N 2*N 2*N
STRING 3 3 0.5*N 0.5*N 0.5*N
N = number of elements in the table or length of the character string (STRING)
• Size of DFB code = 11 + Sum of the size of each of the instructions (1)
(1) Add the following volumes to the size of the instructions according to the variable
or parameter contained in the instruction :
Non-indexed object
Description Type Volume
IN EBOOL 0.5
BOOL, WORD, DWORD, REAL 0
AR_X,AR_W,AR_D,AR_R,STRING 3
IN/OUT EBOOL 3
BOOL, WORD, DWORD, REAL 3
AR_X,AR_W,AR_D,AR_R,STRING 3
OUT, PUBLIC EBOOL 0.5
PRIVATE BOOL, WORD, DWORD, REAL 0
AR_X,AR_W,AR_D,AR_R,STRING 0
___________________________________________________________________________
8/35
B
Indexed object
Description Type Volume
IN AR_X,AR_W,AR_D,AR_R, 7
IN/OUT AR_X,AR_W,AR_D,AR_R, 7
OUT, PUBLIC AR_X,AR_W,AR_D,AR_R, 6
PRIVATE
___________________________________________________________________________
8/36
Performance 8
B
Execution time
Total execution time of the DFB = DFB code threshold + Sum of access times to DFB
variables and parameters + DFB call (no parameters) + Sum of access times to each
parameter B
Execution time (µs)
A B ram B cart C ram C cart
Threshold for DFB code 16.24 7.00 8.00 7.00 8.00
• IN
- EBOOL 0.290 0.125 0.208 0.125 0.208
- BOOL,WORD,DWORD,REAL 0 0 0 0 0
- AR_X,AR_W,AR_D,AR_R,STRING 1.739 0.750 1.282 0.750 1.282
• IN/OUT (all types) 1.739 0.750 1.282 0.750 1.282
• OUT,PUBLIC,PRIVATE
- EBOOL 0.290 0.125 0.208 0.125 0.208
- BOOL,WORD,DWORD,REAL 0 0 0 0 0
- AR_X,AR_W,AR_D,AR_R,STRING 0 0 0 0 0
Non-indexed objects
• IN, IN/OUT
- AR_X,AR_W,AR_D,AR_R, 3.496 1.5 1.472 1.5 1.472
• OUT,PUBLIC,PRIVATE
- AR_X,AR_W,AR_D,AR_R, 2.616 1.125 1.931 1.125 1.931
A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/37
B
8.4 Size of the application
8.4.1 Description of the memory zones
The bit and data memory zones are always stored in the internal RAM, the application
memory zone can be stored in the internal RAM or on a memory card.
The memory structure is described in section 1.3. part A.
A TSX 57 10 and PCX 57 10 B TSX 57 20/25/30/35 C TSX 57 40/45 and PMX 57 20/35/45
___________________________________________________________________________
8/38
Performance 8
B
8.4.2 Memory size of PL7 objects
Grafcet interpreter data = 355 + 2 x No active steps configured + (No. of valid transitions
configured) / 2
For each module type, the following tables provide the size occupied in each of the zones
as well as a fixed size which should be added to the power consumption table the first time
an application-specific function is used.
___________________________________________________________________________
8/39
B
Discrete family Bit memory Data Application
(words) (words) zone
(words)
8 discrete inputs 4 12 40
16 discrete inputs 8 12 50
4 discrete outputs 2 12 40
8 discrete outputs 4 12 40
8 discrete inputs/8 discrete outputs 4 12 40
16 discrete inputs/12 discrete outputs 16 20 100
32 discrete inputs/32 discrete outputs 32 20 142
B
Module memory power consumption table, on TSX/PCX/PMX 57
Processors Bit memory Data Application
(words) (words) zone
(words)
TSX/PCX/PMX 57-10 70 4714 1720
TSX 57-20/25/30/35/40/45 70 4714 1784 B
PCX 57-10/35
PMX 57-10/20/35/45
Use of FAST task (TSX 57) 520
Add. amount of 1st module in config. 600
___________________________________________________________________________
8/42
Performance 8
B
Servo-Motor family Bit memory Data Application
(words) (words) zone
(words)
CAY•1 78 1050 280
CAY•2 78 376 232
B
CAY33 3rd channel 78 264 170
Add. amount of 1st channel 2130
configured CAY •1
Add. amount of 1st channel 3600
configured CAY •2
Add. amount of 1st channel 3 3600
configured CAY33
B
8.4.4 Memory size of advanced functions
The following tables show for each advanced function (OF), the size of the code embedded
in the application (application zone) when an advanced function is called.
The functions in the same family share the code (common code). This common code is
embedded in the PLC on the first call of a function for that family. The code specific to a
function is embedded on the first call for that function. B
Example :
• First call of a function of the Numeric conversions family, ie DBCD_TO_DINT
Code embedded in the application zone :
- Common code = 154 words
- OF code DBCD_TO_INT = 149 words
• Call of another function of the Numeric conversions family, ie DINT_TO_DBCD
Code engaged in the application zone :
- OF code DINT_TO_DBCD = 203 words
Call of a function of the Numeric conversions family which has already been called
(DBCD_TO_DINT or DINT_TO_DBCD) : no code embedded
___________________________________________________________________________
8/45
B
Bit strings OF code size
(in words)
Logic AND between two tables AND_ARX 209
Copy of a bit table to a double word table BIT_D 248
Copy of a bit table to a word table BIT_W 205
Copy of a bit table to a bit table COPY_BIT 146
Copy of a double word table to a bit table D_BIT 196
One’s complement in a table NOT_ARX 157
Logic OR between two tables OR_ARX 209
Copy a word table to a bit table W_BIT 195
Exclusive OR between two tables XOR_ARX 209
Length in number of elements LENGTH_ARX 20
common code 427
___________________________________________________________________________
8/46
Performance 8
___________________________________________________________________________
8/47
B
Date, time and time periods OF code size
(words)
Add a duration to a complete date ADD_DT 519
Add a duration to a time of day ADD_TOD 188
Convert a date to a string DATE_TO_STRING 150
Day of the week DAY_OF_WEEK 99
Difference between two dates DELTA_D 374
Difference between two complete dates DELTA_DT 547
Difference between two times of day DELTA_TOD 110
Convert a complete date to a string DT_TO_STRING 266
Remove a duration from a complete date SUB_DT 548
Remove a duration from a time of day SUB_TOD 186
Convert a duration to a string TIME_TO_STRING 413
Convert a time of day to a string TOD_TO_STRING 156
Format a duration as hours-minutes-seconds TRANS_TIME 211
Realtime clock function SCHEDULE 700
common code 1703
B
Time-delay functions OF code size
(in words)
Pulse output FPULSOR 215
Off-delay FTOF 272 B
On-delay FTON 217
Pulse time-delay FTP 245
Application-specific functions
___________________________________________________________________________
8/49
B
Man-Machine Interface functions OF code size
(in words)
Blocking entry of a variable on CCX17 ASK_MSG, 46.5
Blocking entry of a variable on message contained in ASK_VALUE, 46.5
CCX17
Dynamic assignment of keys ASSIGN_KEYS, 46.5
LED control command CONTROL_LEDS, 46.5
Display an alarm contained in CCX17 DISPLAY_ALARM, 46.5
Display a group of messages contained in CCX17 DISPLAY_GRP, 46.5
Display a message contained in CCX17 DISPLAY_MSG, 46.5
Multiple entry of a variable on CCX17 GET_MSG, 46.5
Multiple entry of a variable on message contained in GET_VALUE, 46.5
CCX17
Send a command to CCX17 PANEL_CMD, 46.5
Display an alarm message contained in the PLC SEND_ALARM, 46.5
memory
Display a message contained in the PLC memory SEND_MSG 46.5
common code 573
___________________________________________________________________________
8/50
Performance 8
B
Explicit exchange functions (1) OF code size
(in words)
Read status parameters READ_STS 0
Read adjustment parameters READ_PARAM 0
Update adjustment parameters WRITE_PARAM 0 B
Save adjustment parameters SAVE_PARAM 0
Restore adjustment parameters RESTORE_PARAM 0
Update command parameters WRITE_CMD 0
(1) Specific OF, the code is included in the volume of the I/O module.
Diagnostic DFB
The following table indicates the code size built into the application (in program zone) for
each type of diagnostic DFB and the size taken up in each case in the data zone and
the program zone.
The first time a diagnostic DFB is programmed, 200 words are reserved in the application
program zone.
___________________________________________________________________________
8/51
B
8.5 Appendix : method of calculating the number of instructions
This method is used to calculate the number of basic Boolean or numerical instructions
(assembler code).
Note : this is the method which was used to calculate the performance information given
in section 1.3 part A.
Example :
LD %M0
AND( %M1
OR %M2
)
ST %M3
= 5 Boolean instructions
Example : %MW0:=(%MW1+%MW2)*%MW3;
instructions counted :
:=
%MW1 (corresponds to the load instruction in the accumulator)
+
*
ie. 4 instructions.
___________________________________________________________________________
8/52
Performance 8
B
Example of application which is 65% Boolean and 35% numerical :
___________________________________________________________________________
8/53
B
___________________________________________________________________________
8/54
Performance 8
___________________________________________________________________________
8/55
B
(1):%MW0:=%MW1+%MW2+%MW3+%MW4+%MW5+%MW6+%MW7+%MW8+%MW9+%MW10+1
Result
Number of
instructions %
Boolean without edge 187 54.05% 64.16%
Boolean with edge 4 1.16%
Operation block 31 8.96%
Function block 3 0.87% 35.84%
Single arithmetic (+,-,:=,AND,...) 111 32.08%
Indexed arithmetic 4 1.16%
*,/ 6 1.73%
Immediate values 24
Total number 346 100.00%
___________________________________________________________________________
8/56
Section
OLE Automation Server 99
9 OLE Automation Server
B
9.1 Presentation
9.1-1 Warning
Knowledge of one of the following languages is required when creating a client
application for the OLE server for OLE Automation programming :
• Microsoft Visual Basic, version 5.0 or later
• Microsoft Visual C++, version 4.2 or later
• Microsoft VBA in Excel, version 5.0 or later
___________________________________________________________________________
9/1
B
9.1-2 Introduction
The OLE Automation Server PL7 function provides the possibility of "controlling" the
execution of a PL7 in a programmed manner, which is not interactive (without
intervention by the operator), for applications external to PL7. The client application
terminology of the PL7 OLE Automation server is used.
PLC
Client Server
Automation
Client
Automation
OLE
Applications PL7
OLE
*.STX
Completely in line with the standard defined by Microsoft, in its OLE offer designed to
meet this requirement, PL7 now has a standard interface which is public, distributed,
separate and independent of the programming language of the client application.
The main characteristics are as follows :
• automation of repetitive tasks,
• delegation to PL7 of processing which can only be executed by PL7,
• access to information about the applications contained in the *.STX files,
• more generally, the development of functions of a higher level than PL7, of the
integrator type, whilst encapsulating the implementation details which are specific
to PL7.
___________________________________________________________________________
9/2
OLE Automation Server 9
B
9.1-3 Execution context
The PL7 OLE Automation server function is integrated in PL7 Pro. It is installed and
executed under the same installation and execution conditions as PL7.
The PL7 OLE Automation server is based on Microsoft OLE Automation run-time
provided with Windows 95, 98 and NT.
The choice of operating mode depends on the PL7 start procedure. Interactive mode
is initialized when PL7 is started via Windows (Start/Programs/Modicon Telemecanique/
PL7 Pro menu).
Server mode is chosen if the PL7 OLE Automation server is called in the programming
of an OLE client application. An instance cannot change mode while it is in progress.
Each time a client application calls the PL7 OLE Automation server, a specific instance
of PL7 is started, independently of other instances which may already have been
started. Any number of PL7 instances in server or interactive mode may be executed
on the same station. The instances are completely independent of one another, and
each can be executed in its own context.
For all these instances, the same exclusion rules regarding concurrent access to an
STX application or a PLC apply, namely : an STX application or a PLC may only be
manipulated by one instance at a time.
This rule has been adapted for the PL7 OLE Automation server, which may open an
STX application which is already open but which cannot be saved. Likewise, in
response to an explicit request, it can carry out a PLC —> PC transfer from a PLC
reserved elsewhere.
A client application may instantiate several "PL7 OLE Automation servers" at the same
time.
___________________________________________________________________________
9/3
B
9.2 Implementation
9.2-1 Installation
The installation of the PL7 OLE Automation Server product is transparent for the user,
and is performed implicitly during the installation of PL7.
The installation comprises :
1. Four examples of OLE Automation client, complete with source code, and a README
file are provided in the software.
These examples correspond to :
• a "minimum" Visual C++ 4.2 client : the minimum required in order to write an OLE
client,
• a "complete" Visual C++ 4.2 client which uses all the available input points,
• a Visual Basic 5.0 client which uses all the available input points,
• an Excel client.
2. An *.h file which defines the value of the error codes returned by the server.
3. A TLB interface file for a Visual C++ client.
The server is located transparently for the client application in the Createdispatch by
interrogating the register base.
The link between the client application and the server application is created if the latter
is referenced in the register base. In order to ensure that the PL7 Pro application
operates correctly in server mode, when installing the product it is necessary to save
it as an OLE server in the register base.
The client application is now able to interrogate the server application via the interface
accessible from the “A” object.
Example :
A.OpenStx(“C:\appli.stx”)
___________________________________________________________________________
9/4
OLE Automation Server 9
B
9.2-3 Starting the server in remote mode (DCOM)
The PL7 server is executed according to the information present in the register base.
It can be located on the client machine or on a remote machine.
DCOM mode is in fact an extension of COM mode (Component Object Model). COM
mode is used for communication between a client application and a server application
on the same machine.
DCOM mode is used for communication between two remote machines. It replaces
inter-process communication protocols with network protocols.
COM COM
Client Component
run-time run-time
DCOM network
protocol
___________________________________________________________________________
9/5
B
9.2-4 Setting up the server for remote mode
Example of use :
A machine A (Windows NT 4) installed with PL7 Pro server.
The user of the machines must connect under an “administrator” account in order to
manage the access rights.
The client is machine B (Windows 95).
Procedure :
On machine B, start DCOMCNFG.EXE :
• Select the "Default Properties" tab in order to display the following information :
[X] «Enable Distributed COM on this computer
Default Authentication Level: CONNECT
Default Impersonation Level: Identify
• On the "Default Security" tab, check the option :
[X] Enable remote connection
Note :
For more information :
There is a newsgroup where it is possible to ask questions about DCOM :
“http://www.microsoft.com/support/news/win32.htm”
___________________________________________________________________________
9/6
OLE Automation Server 9
B
9.3 PL7 server execution modes
The PL7 OLE Automation Server has two execution modes, which can be selected
dynamically during execution (see SetIHMServer ) :
• Execution mode without HMI. The PL7 is started as a “background task”, with no
display or possibility of operator entry. This mode is typically used, for example,
to automate repetitive tasks or to access data about an application contained in
an stx file.
• Execution mode with HMI. PL7 is started as an "interactive" PL7 with display and the
possibility of operator entry, but it remains receptive to commands sent by its client
application. This mode has been developed in order to display program or configu-
ration elements of an application contained in an stx file, from external tools such as
DIAG Viewer.
Notes :
Services regarding the display of programs, tools or modules can only be executed in the mode
with HMI.
In its mode with HMI, the PL7 OLE Automation Server is subject to user rights checks. It is
positioned in the “Read Only” user rights profile, which corresponds to its role of displaying PL7
I/O code and modules.
In its mode without HMI, the PL7 OLE Automation Server is not subject to user rights checks,
but the services offered do not allow the application to be modified.
___________________________________________________________________________
9/7
B
9.4 Input points : OLE function
The input points are organized into four types :
• Execution context
Name Description
OpenStx Opens an application
SaveStx Saves the active application
CloseStx Closes the active application
SetDriverAndAddress Modifies the address and driver of the PLC being accessed
SetServerIHM Makes the PL7 OLE Automation Server interactive or not
GetPL7State Gives the status : application open or closed, offline/online mode,
PLC status
GetMessageError Reads the error message associated with the error code
• PLC control :
Name Description
ConnectPLC Enters online mode
DisconnectPLC Exits online mode
SendCommandToPLC Sends a command to the PLC (RUN, STOP, INIT)
DownloadToPLC Downloads the active application to a PLC
UploadFromPLC Copies a PLC application to the active application
• Data reading :
Name Description
ExportScyFile Exports symbols to the active application in the form of an scy file
ExportFefFile Exports the active application in the form of an fef type file
GetSymbol Reads the symbol and comment associated with an address
GetSTXAppIdentity Reads the general information about an application contained in
an STX file
GetPLCAppIdentity Reads the general information about an application contained in a PLC
GetServerVersion Reads the server version
___________________________________________________________________________
9/8
OLE Automation Server 9
B
• Displaying an application element
Name Description
SetPosPL7Window Modifies the PL7 display characteristics (position and form)
ShowProgram Opens an editor on a given program module
CloseProgram Closes a program editor
ShowIOModule Opens an editor on a given I/O module
CloseIOModule Closes an I/O module editor
ShowDFB Opens an editor on the code of a given DFB
CloseDFB Closes an editor on the code of a DFB
OpenTool Opens any MDI tool without context
Note:
The input points relating to the display of application elements do not function if the server is in the
mode without HMI.
___________________________________________________________________________
9/9
B
9.5 Description of OLE functions
9.5-1 OpenStx
This function is used to open an stx application file.
Syntax : integer OpenStx(String lpAppPathName).
• Input :
Enter the character string containing the name of the file the user wishes to open.
• Function called :
OpenStation : Station management function (gesta.dll).
• Nominal context
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_FILENOTFOUND : The file has not been found.
SRV_ERR_OPEN_BADZIP : File decompression problem.
SRV_ERR_OPEN_BADFILE : Problem reading the stx file
SRV_ERR_OPEN_NOK_COMPATIBLE : The processor is not compatible
with the open PL7.
SRV_ERR_OPEN_OPEN : An application is already open.
SRV_ERR_GEN_PARAM_EMPTY : The path name is empty.
SRV_ERR_GEN_ACTION : Error opening the application.
SRV_ERR_GEN_DRIVE FULL : No more free space on the disk
for opening the application.
• Output :
Short type return code. Either 0 if the application has been opened successfully, or
an error code.
9.5-2 CloseStx
This function is used to close the current application.
Syntax : integer CloseStx(integer p_bWithoutSave).
• Input :
If the application has been modified, it is possible to close it without warning the user
(p_bWithoutSave a TRUE)
• Function called :
CloseStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active, an application is open.
___________________________________________________________________________
9/10
OLE Automation Server 9
B
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_CLOSE_NOTSAVE: The application has been modified, it must be
saved in order to exit.
• Output :
Short type return code. Either 0 if the application has been closed successfully, or
an error code.
9.5-3 ExportScyFile
This function is used to export the symbols contained in the active application in the
form of an scy file.
Syntax : integer ExportScyFile(String p_psScyFile)
• Input:
Enter the character string containing the name of the scy file.
• Function called :
ExportScyFile : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the creation of the symbol
source file.
SRV_ERR_GEN_NOTOPEN: No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_ psScyFile is empty
SRV_EXPORT_ERRFILE Error writing the source file.
• Output :
Short type return code. Either 0 in the case of a successful export, or an error code.
___________________________________________________________________________
9/11
B
9.5-4 ExportFefFile
This function is used to export the active application in the form of an fef file.
Syntax : integer ExportFefFile(String p_psNamefile)
• Input :
Enter the character string containing the name of the fef file.
• Function called :
ExportFefFile : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the creation of the application
source file.
SRV_ERR_GEN_NOTOPEN: No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_psNamefile is empty.
SRV_EXPORT_ERRFILE Error writing the source file.
• Output :
Short type return code. Either 0 in the case of a successful export, or an error code.
9.5-5 DisconnectPLC
• Function called :
DisconnectStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• Output :
Short type return code. Either 0 in the case of a successful disconnection, or an error
code (SRV_ERR_GEN_ACTION).
___________________________________________________________________________
9/12
OLE Automation Server 9
B
9.5-6 ConnectPLC
This function is used for connecting to a PLC.
Syntax : integer ConnectPLC(String p_lpDriver, String p_lpAddress)
• Input :
Enter two character strings containing the driver and address of the PLC.
• Function called :
ConnectStation : Station management function (gesta.dll).
• Nominal context
The PL7 server is active.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.
• In the event of an error :
SRV_ERR_GEN_CONNECT : Connection was not possible.
SRV_ERR_GEN_COMMUNICATION : Communication problem between PL7 Pro
and the PLC.
SRV_ERR_GEN_RESERVED : The PLC is reserved; it is therefore
impossible to connect to it.
SRV_ERR_PLC_BLANK : The PLC does not contain an application;
connection is therefore impossible.
SRV_ERR_PC_BLANK : No application is open; connection
is therefore impossible.
SRV_ERR_DIFFERENCE_PLC_STX : The open application and the application
contained in the PLC are different;
connection is therefore impossible.
SRV_ERR_GEN_ADDRESS : The address parameter is incorrect.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_GEN_DRIVER: The driver parameter is incorrect.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PROTECTEDAPPLI : Protected application.
SRV_COMPATIBLE_PLC : Compatibility problem with the PLC.
• Output
Short type return code. Either 0 in the case of successful connection, or an error code.
___________________________________________________________________________
9/13
B
9.5-7 SaveStx
This function is used to save the open application.
Syntax : integer SaveStx(String p_lpStxFile)
• Input :
Enter a character string containing the path and name of the backup file.
• Function called :
SaveStx : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open, PL7 is in offline mode.
• In the event of an error :
SRV_ERR_SAVEDENIED : Access to file refused.
SRV_ERR_SAVEERRZIP : Error when compressing the application.
SRV_ERR_SAVEERRREN : Renaming refused.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_ lpStxFile is empty.
SRV_ERR_GEN_ACTION : Error saving the application.
SRV_ERR_PLC_CONNECT : Saving can only be carried out in
offline mode.
• Output :
Short type return code. Either 0 if the application has been saved successfully, or an
error code.
9.5-8 DownloadToPLC
This function is used to download an application to the PLC memory.
Syntax : integer DownloadToPLC(String p_lpDriver, String p_lpAdresse)
• Input :
Enter two character strings containing the driver and address of the PLC.
• Function called :
DownloadStation: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open, PL7 is in offline mode.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.
___________________________________________________________________________
9/14
OLE Automation Server 9
B
• In the event of an error :
SRV_ERR_DOWNLOAD_CART : Memory card compatibility problem
between the open application and the PLC.
SRV_ERR_COMPATIBLE_PLC : Compatibility problem between the open
application and the PLC.
SRV_ERR_GEN_ADDRESS : The p_lpAdresse parameter is incorrect.
SRV_ERR_GEN_DRIVER : The p_lpDriver parameter is incorrect.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_RESERVED : The PLC is reserved.
SRV_ERR_GEN_COMMUNICATION : Communication problem.
SRV_ERR_PLC_CONNECT : The PLC is already connected.
SRV_ERR_PLC_ACTION : Download error.
• Output
Short type return code. Either 0 in the case of a successful download, or an error code.
9.5-9 UploadfromPLC
This function is used to copy an application contained in a PLC to the memory.
Syntax : integer UploadFromPLC(String p_lpDriver, String p_lpAdresse, integer
p_iReservedMode)
• Input :
Enter two character strings containing the driver and address of the PLC.
An integer (p_iReservedMode) making it possible to carry out an Upload on a
reserved PLC.
• Function called :
UploadStation : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
No application is open, and PL7 is in offline mode.
If the parameters are empty strings, the server executes the function using the current
driver and/or address.
___________________________________________________________________________
9/15
B
• In the event of an error :
SRV_ERR_UPLOAD_TRANSFER : Problem transferring the application
contained in the PLC.
SRV_ERR_UPLOAD_ABORT : Suspension of the transfer.
SRV_ERR_UPLOAD_RESERVED : Application reserved.
SRV_ERR_UPLOAD_NOAPPLI : No application on PLC.
SRV_ERR_GEN_ADDRESS : Incorrect address.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_PLC_CONNECT : Connection error.
SRV_ERR_GEN_DRIVER : Incorrect driver.
SRV_ERR_GEN_COMMUNICATION : Communication error.
SRV_ERR_PLC_CONNECT : The PLC is in online mode.
SRV_OPEN_NOT_COMPATIBLE : Compatibility problem.
• Output :
Short type return code. Either 0 in the case of a successful upload, or an error code.
9.5-10 GetSymbol
This function is used to provide the symbol and comment associated with an address.
Syntax : integer GetSymbol(String p_lpRepere, String* p_bsSymbole, String*
p_bsComment)
• Input :
Enter the character string containing the address to be modified or entered.
• Function called :
GetSymbol : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open and in offline mode.
• In the event of an error :
SRV_ERR_ADDRESSSYNTAX : The character string entered as a parameter
does not correspond to an address.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : p_lpRepere is empty.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
___________________________________________________________________________
9/16
OLE Automation Server 9
B
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
- Two character strings :
The associated symbol (p_bsSymbole).
The associated comment (p_bsComment).
9.5-11 SetServerIHM
This function is used to display or hide the PL7 server. It performs the transition from
one operating mode to the other, namely from a PL7 Pro server without HMI to a PL7
Pro server with HMI and vice versa.
Syntax : integer SetServerIHM (integer p_bIHM)
• Input :
A Boolean (stating whether to display HMI or not).
• Function called :
SetIHMServer : Function of the Windows application (sawinapp.cpp).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_ACTION: Error during the execution of the function.
SRV_ERR_GEN_MODIFAPPLI : Application being modified.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
___________________________________________________________________________
9/17
B
9.5-12 GetPL7State
This function provides the state of the server.
Syntax : integer GetPL7State(String* p_lpStation, String * p_lpConnection)
• Function called :
GetPL7State : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_ACTION : Error during the execution of the function.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
Two character strings provide the user with information about :
- The station state (open or closed).
- The mode state (offline or online). In online mode, the PLC status (run or stop) is
indicated.
9.5-13 GetSTXAppIdentity
This function is used to find out the general information about an application.
Syntax : integer GetSTXAppIdentity(String p_lpNameStx, VARIANT FAR* p_pVarInfo)
• Input :
Enter the character string ( p_lpNameStx) containing the name of the application.
• Function called :
FicheIdentAppli: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : p_ lpNameStx is empty.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_APPLIINFO_NOK : Incorrect information.
___________________________________________________________________________
9/18
OLE Automation Server 9
B
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
Information displayed :
1 The station name,
2 Date and time of creation,
3 The station ID,
4 The ID for the configuration of the local I/O,
5 The ID for the configuration of the remote I/O,
6 The ID for the PL7 code,
7 The ID for Grafcet,
8 The ID for the constants,
9 The ID for the symbols,
10 The ID for the reservation,
11 The comment associated with the application.
9.5-14 GetPLCAppIdentity
This function is used to find out the general information about an application contained
in a PLC.
Syntax : integer GetPLCAppIdentity(String p_lpDriver, String p_lpAdresse, VARIANT
FAR* p_pvInfoAppli)
• Input :
Enter the two character strings containing the driver and address of the PLC.
• Function called :
FicheIdentAppliOnAutomate : Station management function (gesta.dll).
• Nominal context :
The PL7 server is active and in offline mode.
• In the event of an error :
SRV_ERR_APPLIINFO_NOK : Incorrect information.
SRV_ERR_GEN_ACTION : Error during the execution of the function.
SRV_ERR_GEN_ADDRESS : Incorrect address.
SRV_ERR_COMPATIBLE_PLC : Compatibility problem between the PLC and the
PL7 software.
SRV_ERR_PLC_BLANK : There is no application in the PLC.
SRV_ERR_GEN_ACTION : Problem saving the application data.
SRV_ERR_GEN_DRIVER : The p_lpDriver parameter is incorrect.
SRV_ERR_GEN_COMMUNICATION : Communication error.
___________________________________________________________________________
9/19
B
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.
Information displayed :
1 The station name,
2 Date and time of creation,
3 The station ID,
4 The ID for the configuration of the local I/O,
5 The ID for the configuration of the remote I/O,
6 The ID for the PL7 code,
7 The ID for Grafcet,
8 The ID for the constants,
9 The ID for the symbols,
10 The ID for the reservation,
11 The comment associated with the application.
9.5-15 SendCommandToPLC
This function is used to send a command to the PLC.
Syntax : integer SendCommandToPLC(integer p_iCommand)
• Input :
The type of command the user wishes to execute.
There are 3 possible types :
SRV_COMMAND_INIT : PLC initialization command
SRV_COMMAND_STOP : Stop command
SRV_COMMAND_RUN : Run command
• Function called :
StationCommand : Station management function (gesta.dll).
• Nominal context
The PL7 server is active. An application is open; PL7 is in online mode, in STOP.
• In the event of an error :
SRV_ERR_GEN_ACTION : Incorrect command.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_COMMAND_NOTINLOCAL : The server is in offline mode.
SRV_COMMAND_ERRINIT : The INIT function is impossible, the PLC is in RUN.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
___________________________________________________________________________
9/20
OLE Automation Server 9
B
9.5-16 SetDriverAndAdresse
This function is used to change the driver and address of the current station.
Syntax : integer SetDriverAndAdresse(String p_lpDriver, String p_lpAdresse)
• Input :
Enter the two character strings containing the driver and address of the PLC.
• Function called :
DriverAndAdresse: Station management function (gesta.dll).
• Nominal context :
The PL7 server is active.
An application is open and in offline mode.
If the parameters are not entered or are incorrect, the current values remain
unchanged.
• In the event of an error :
SRV_ERR_GEN_ADDRESS : The address entered as a parameter is incorrect.
SRV_ERR_GEN_DRIVER : The driver entered as a parameter is incorrect.
SRV_ERR_PLC_CONNECT : The server is in online mode.
SRV_ERR_PLC_ACTION : Error during the execution of the function.
SRV_ERR_PARAM_EMPTY : The parameters are empty.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
9.5-17 OpenTool
This function is used to open the tools present in the character string entered as a
parameter.
Syntax : integer OpenTool(String p_lpListTool))
• Input :
Character strings containing the list of tools which the server must open.
Format example : tools1;tools2;tools3
• Function called :
OpenTool : Station management function (gesta.dll).
___________________________________________________________________________
9/21
B
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
9.5-18 SetPosPL7Windows
This function is used to size the PL7 window.
Syntax : integer PosPL7Windows(integer CoordX, integer CoordY, integer CoordCX,
integer CoordCY)
• Input :
The x, y coordinates of the window.
• Function called :
MoveWindow : Mfc function.
• Nominal context :
The PL7 server with HMI is active.
___________________________________________________________________________
9/22
OLE Automation Server 9
B
9.5-19 ShowProgram
This function is used to open the programs present in the character string entered as
a parameter.
Syntax : integer ShowProgram(String p_lpListProgram)
• Input :
Enter the character strings containing the list of programs which the server must open.
Format example : mast\lad1;mast\lit2;evt\evt0;sr1;mast\prl
• Function called :
ShowProgram : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Command failed.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
SRV_ERR_GEN_SHOWPROGRAM : Impossible to open the module.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
• Limitations :
This function is not capable of opening an uninstantiated DFB. To display the code
of an uninstantiated DFB, use the ShowDFB function.
9.5-20 CloseProgram
This function is used to close the programs present in the character string entered as
a parameter.
Syntax : integer CloseProgram(String p_lpListProgram)
• Input :
Character strings containing the list of programs which the server must close.
Format example : mast\lad1;mast\lit2;evt\evt0;sr1;mast\prl.
___________________________________________________________________________
9/23
B
• Function called :
CloseProgram : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Close failed.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
SRV_ERR_GEN_CLOSEPROGRAMM : Impossible to close the module.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
• Limitations :
This function is not capable of closing an open DFB.
9.5-21 ShowIOModule
This function is used to open the I/O modules present in the character string entered
as a parameter.
• Input :
Character strings containing the list of modules which the server must open.
The format of the character string is rack,module;rack,module
Format example : 0,0;0,1;1,2
• Function called :
ShowIOModule : Station management function (gesta.dll).
• Nominal context :
The PL7 Pro server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ACTION_NOK : Problem with activating the user rights.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
___________________________________________________________________________
9/24
OLE Automation Server 9
B
in HMI mode.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
• Limitations :
An I/O module is opened in offline mode; the module configuration screen is open.
If the user changes from offline mode to online mode, the server does not change from
the configuration screen to the debug screen. The user can either operate directly
on the PL7 Pro, or open/close the module using the client.
9.5-22 CloseIOModule
This function is used to close the I/O modules present in the character string entered
as a parameter.
Syntax : integer CloseIOModule(String p_lpListIOModule).
• Input :
Character strings containing the list of modules which the server must open.
Format example : 0,0;0,1;1,2
• Function called :
CloseIOModule : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_ACTION : Close command failed.
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output :
Short type return code. Either 0 in the case of a successful load, or an error code.
• Limitations :
This function does not close the configuration editor opened using the function
ShowIOModule.
___________________________________________________________________________
9/25
B
9.5-23 ShowDFB
This function is used to display the code of one or more DFBs present in the character
string entered as a parameter. Opening a DFB via this function does not require
instantiation.
Syntax : integer ShowDFB(String p_lpListeDFB).
• Input :
Character strings containing the list of DFBs which the server must open.
• Function called :
ShowDFB : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Problem opening a DFB.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.
9.5-24 CloseDFB
This function is used to close one or more DFBs present in the character string entered
as a parameter.
Syntax : integer CloseDFB(String p_lpListeDFB)
• Input :
Character strings containing the list of DFBs which the server must close.
• Function called :
CloseDFB : Station management function (gesta.dll).
• Nominal context :
The PL7 server with HMI is active.
An application is open.
___________________________________________________________________________
9/26
OLE Automation Server 9
B
• In the event of an error :
SRV_ERR_GEN_PARAM_EMPTY : Parameter empty.
SRV_ERR_GEN_NOTOPEN : No application is open.
SRV_ERR_GEN_ACTION : Problem closing a DFB.
SRV_ERR_GEN_WITHIHM : Function available with the PL7 server
in HMI mode.
• Output
Short type return code. Either 0 in the case of a successful load, or an error code.
9.5-25 GetMessageError
This function is used to associate an error message depending on the error code
entered as a parameter.
Syntax : String GetMessageError(integer p_iCodeError)
• Input :
The error code of one of the services to be returned.
• Nominal context :
The PL7 server is active.
• Output :
A character string corresponding to the name of the error.
9.5-26 GetServerVersion
This function is used to find out the version number of the PL7 Pro server.
String GetServerVersion()
• Nominal context
The PL7 server is active.
• Output
A character string corresponding to the name of the version number of the PL7 Pro
server.
___________________________________________________________________________
9/27
B
9.6 Mechanism for accessing the PL7 OLE Automation Server
There are two methods of accessing the services provided by the PL7 OLE Automation
Server.
DCOM
___________________________________________________________________________
9/28
INDEX
Index 9
10 Index B
Symbols B
%Ci B 1/14 BCD <--> Binary conversion B 2/29
%DRi B 2/9 Binary --->ASCII conversion B 2/54
%Li B 1/30 Bit memory A 1/26, A 1/29
%MNi B 2/2 Bit tables A 1/21, B 2/92
%Ri B 2/5 BIT_D B 2/94
%Ti B 2/13 BIT_W B 2/94
%TMi B 1/10 Bits A 1/10
* B 1/23 BLK A 3/8
+ B 1/23 Boolean instructions B 1/2
- B 1/23 Byte A 1/16
/ B 1/23
:= B 1/20 C
< B 1/19
<= B 1/19 CALL A 2/3
<> B 1/19 Character string A 1/21, B 2/51
= B 1/19 Circular shift B 2/19
> B 1/19 Cold restart A 1/38
>= B 1/19 Comments A 2/6, A 3/4, A 4/7, A 5/14
Common words A 1/18
A Comparison B 1/19
Complement B 1/25
ABS B 1/23 CONCAT B 2/59
Absolute value B 1/23 Concatenation of two strings B 2/59
ACOS B 2/26 CONCATW B 2/34
Action zone A 2/1 Constant A 1/16
Actions A 5/17 Control structures A 4/9
ADD_DT B 2/80 Conversion B 2/28, B 2/29
ADD_TOD B 2/81 Conversions ASCII ---> Binaire B 2/112
Addition B 1/23 COPY_BIT B 2/92
Addressing A 1/11 COS B 2/26
Addressing TSX 37 objects A 1/11 Cyclic execution A 1/41
Addressing TSX 57 objects A 1/13
Alphanumeric comparisons B 2/53 D
AND B 1/6, B 1/25
AND convergences A 5/4 D_BIT B 2/96
AND divergences A 5/4 DATE_TO_STRING B 2/86
AND_ARX B 2/93 Dates B 2/72
ANDF B 1/6 DAY_OF_WEEK B 2/79
ANDN B 1/6 DEC B 1/23
ANDR B 1/6 Decrement B 1/23
Arithmetic on integers B 1/23 DEG_TO_RAD B 2/28
ASCII ---> Binary conversion B 2/56 DELETE B 2/60
ASCII --> Floating point conversion B 2/58 DELTA_D B 2/83
ASIN B 2/26 DELTA_DT B 2/84
Assignment B 1/20 DELTA_TOD B 2/85
ATAN B 2/26 Destination connector A 5/5
DFB A 1/9, A6/1
___________________________________________________________________________
10/1
B
DFB instance A6/8 FIND_LTW B 2/43
DFB objects A6/3 Floating point A 1/17, B 2/20
DFB type A6/3 Floating point ---> ASCII conversion B 2/57
DINT_TO_REAL B 2/32 Floating point instructions B 2/20
DINT_TO_STRING B 2/54 FOR ... END_FOR A 4/13
Direct coils B 1/5 Forcing A 1/30
Directed links A 5/5, A 5/13 FPULSOR B 2/109
Division B 1/23 Freezing the Grafcet chart A 5/26
Double length A 1/17 FTOF B 2/107
DOWN B 1/12, B 1/16 FTON B 2/105
Downcounter B 1/14 FTP B 2/108
Drum controller B 2/9 Function block objects A 1/20
DSHL_RBIT B 2/98 Function blocks B 1/9
DSHR_RBIT B 2/98 Functions on tables B 2/40
DSHRZ_C B 2/98
DT_TO_STRING B 2/87 G
Durations B 2/72
GET B 2/8
E Grafcet language A 5/1
Grafcet objects A 1/23, A 5/6
Edges A 1/29, B 1/2 Grafcet section A 5/23
END B 1/32 Graphic elements, Grafcet A 5/4
End of program B 1/32 Graphic elements, Ladder language A 2/2
END_BLK A 3/8 Gray --> Integer conversion B 2/33
ENDC B 1/32 GRAY_TO_INT B 2/33, B 2/34
ENDCN B 1/32
EQUAL B 2/41 H
EQUAL_ARR B 2/41
EQUAL_STR B 2/69 HALT B 1/33
Event masking/unmasking B 1/34 HW B 2/34
Event-triggered tasks A 1/50
Exclusive OR B 1/8
I
EXIT A 4/14 IF ... END_IF A 4/9
EXP B 2/25 Immediate values A 1/18
Exponential instructions B 2/25 INC B 1/23
EXPT B 2/25 Increment B 1/23
Index overrun A 1/23
F Indexation A 1/22
Falling edge contacts B 1/4 Indexed objects A 1/22
FAST A 1/48 INSERT B 2/61
Fast task A 1/48 Instruction List language A 3/1
FIFO stack B 2/5 INT_TO_REAL B 2/32
FIND B 2/70 INT_TO_STRING B 2/54
Find in tables B 2/43 Integer <--> Floating point conversion B 2/31
FIND_EQD B 2/43 Internal words A 1/16
FIND_EQW B 2/43 Inverse coils B 1/5
FIND_GTD B 2/43
FIND_GTW B 2/43
FIND_LTD B 2/43
___________________________________________________________________________
10/2
Index 9
B
J NOT_ARX B 2/93
Numerical expression B 1/27
JMP B 1/30
JMPC B 1/30 O
JMPCN B 1/30
Objects which can be symbolized A 1/24
Jump B 1/30
OCCUR_ARD B 2/46
L OCCUR_ARR B 2/46
OCCUR_ARW B 2/46
Label A 2/6, A 3/4, A 4/8 OLE B9/2
Ladder language A 2/1 OLE server B9/2
LD B 1/4 Operating modes A 5/1
LDF B 1/4 OR B 1/7, B 1/25
LDN B 1/4 OR convergences A 5/5
LDR B 1/4 OR_ARX B 2/93
LEFT B 2/67 ORF B 1/7
LEN B 2/71 ORN B 1/7
LENGTH_ARR B 2/50 ORR B 1/7
LIFO stack B 2/5 OUT_BLK A 3/8
LN B 2/25 Overflow B 1/24
LOG B 2/25
Logarithms B 2/25 P
Logic AND B 1/6
Logic OR B 1/7, B 1/25 Parentheses A 3/5
Logic shift B 2/19 PCMCIA B 2/111
Periodic execution A 1/42
LW B 2/34
Post-processing A 5/30
M Pre-processing A 5/24
PRESET B 1/16
Macro-step A 5/15 Presymbolization A 1/25
MASKEVT B 1/34 Private variables A6/4
Master task A 1/47 Program instructions B 1/28
MAX_ARD B 2/45 PTC B 2/78
MAX_ARW B 2/45 Public variables A6/4
Memory card A 1/26 PUT B 2/8
MID B 2/65
MIN_ARD B 2/45 R
MIN_ARW B 2/45
Monostable B 1/11, B 2/2 R B 1/5
RAD_TO_DEG B 2/28
MPP A 3/7
MPS A 3/7 Read day of the week B 2/79
MRD A 3/7 Read system date B 2/77
READ_PCMCIA B 2/116
Multiplication B 1/23
Multitask A 1/45 REAL_TO_DINT B 2/32
REAL_TO_INT B 2/32
N Realtime clock B 2/75
Register B 2/5
N/C contacts B 1/4 REM B 1/23
N/O contacts B 1/4 REPEAT ... END_REPEAT A 4/12
NOT B 1/25 REPLACE B 2/63
___________________________________________________________________________
10/3
B
RESET B 1/16, B 2/8, B 2/11 Subroutine return B 1/29
Reset coils B 1/5 Subtraction B 1/23
RET B 1/29 SUM B 2/40
RETCN B 1/29 SUM_ARR B 2/40
RIGHT B 2/67 Symbol A 1/6, A 1/24
Rising edge contacts B 1/4 System bits B 3/1
ROL_ARD B 2/47 System words B 3/9
ROL_ARW B 2/47
ROR_ARD B 2/47 T
ROR_ARR B 2/47 Table comparisons B 2/41
ROR_ARW B 2/47 TAN B 2/26
RRTC B 2/77 Test zone A 2/1
Rung A 2/5 Time B 2/72
Rungs, execution A 2/13 Time delay B 2/105
Time of day B 2/72
S TIME_TO_STRING B 2/88
S B 1/5 Timer B 1/10, B 2/13, B 2/105, B 2/107
SCHEDULE B 2/75 B2/108, B 2/109
SCOUNT B 2/101 TOD_TO_STRING B 2/89
Section A 1/4, A 1/39 TRANS_TIME B 2/91
Sequence A 3/4 Transition conditions A 5/20
Sequence selection A 5/10 Transitions A 5/4
Sequential processing A 5/28 Trigonometric functions B 2/26
Set coils B 1/5 TRUNC B 2/24
SET_PCMCIA B 2/112
Simultaneous step activation A 5/10 U
SIN B 2/26 UNMASKEVT B 1/34
Single task A 1/39 UP B 2/11
Sort function on tables B 2/49, B 2/50 Upcounter B 1/14
SORT_ARD B 2/49 Update system date B 2/77
SORT_ARR B 2/49 User function blocks A 1/9
SORT_ARW B 2/49 User memory A 1/26
Source connector A 5/5
SQRT B 1/23 V
Square root B 1/23
SRi A 1/39 Vertical comparison B 2/17
ST B 1/5
START B 1/12, B 2/3 W
Steps A 5/4 W_BIT B 2/96
STN B 1/5
Warm restart A 1/37
Stop code B 2/78
Watchdog A 1/44
STRING_TO_DINT B 2/56 WHILE ... END_WHILE A 4/11
STRING_TO_INT B 2/56
Word extract bits A 1/18
STRING_TO_REAL B 2/58 Word memory A 1/26, A 1/27, A 1/31
Structured data B 4/4
Word tables A 1/21, B 2/35
Structured Text language A 4/1
WRITE_PCMCIA B 2/114
SUB_DT B 2/80 WRTC B 2/78
SUB_TOD B 2/81
WSHL_RBIT B 2/98, B 2/103
Subroutine A 1/39, B 1/28
___________________________________________________________________________
10/4
Index 9
B
WSHR_RBIT B 2/98
WSHRZ_C B 2/98
X
XOR B 1/8, B 1/25
XOR_ARX B 2/93
XORF B 1/8
XORN B 1/8
XORR B 1/8
___________________________________________________________________________
10/5
B
___________________________________________________________________________
10/6