PL7 Reference Manual[006 200]
PL7 Reference Manual[006 200]
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