PL7 - Completo
PL7 - Completo
A B C D E F G H I J K L
Reserved
General
Debugging, Adjustment, Documentation and Appendices TLX DS 57 PL7 13E Applicationspecific functions Volume 1/2 Counting Common features of application-specific functions
Discrete I/O
Analog
PID control
Man-machine interface
Axis control
M N
Stepper control
A
Description of PL7 software Contents Part A
___________________________________________________________________________
Section 1 General 1.1 Presentation of PL7 software 1.1-1 Presentation 1.1-2 Single task structure 1.1-3 Multitask structure 1.1-4 Symbolic programing 1.1-5 PL7 instructions Addressable objects 1.2-1 Definition of main Boolean objects 1.2-2 Addressing TSX 37 I/O module objects 1.2-3 Addressing TSX 57 I/O module objects 1.2-4 Addressing words 1.2-5 Function block objects 1.2-6 Structured objects 1.2-7 Grafcet objects 1.2-8 Symbolization User memory 1.3-1 General 1.3-2 Saving / retrieving internal words %MWi 1.3-3 Bit memory 1.3-4 Word memory 1.3-5 TSX 37-10 PLCs 1.3-6 TSX 37-21/22 PLCs 1.3-7 TSX 57-10 PLCs 1.3-8 TSX 57-20 PLCs Operating modes 1.4-1 Processing on outage and power return 1.4-2 Warm restart processing 1.4-3 Cold restart processing Single task software structure 1.5-1 Presentation of the master task 1.5-2 Cyclic execution 1.5-3 Periodic execution
Page 1/1 1/1 1/1 1/3 1/3 1/4 1/5 1/6 1/6 1/7 1/9 1/11 1/15 1/16 1/18 1/19 1/20 1/20 1/22 1/23 1/25 1/26 1/27 1/28 1/29 1/30 1/30 1/31 1/32 1/32 1/33 1/34 1/35
1.2
1.3
1.4
1.5
___________________________________________________________________________ A / 1
A
Description of PL7 software Contents Part A
___________________________________________________________________________ Page 1.5-4 Monitoring scan time 1.6 Multitask software structure 1.6-1 Description 1.6-2 Master task 1.6-3 Fast task 1.6-4 Assigning I/O channels to the master and fast tasks 1.6-5 Event-triggered tasks 1/37 1/38 1/38 1/39 1/39 1/40 1/41 2/1 2/1 2/1 2/2 2/4 2/4 2/5 2/5 2/6 2/9 2/11 2/11 3/1 3/1 3/1 3/2 3/4 3/4 3/4 3/4 3/5 3/7 3/8 3/9
Section
2 Ladder language 2.1 Presentation of Ladder language 2.1-1 Principle 2.1-2 Graphic elements Structure of a rung 2.2-1 General 2.2-2 Labels 2.2-3 Comments 2.2-4 Rungs 2.2-5 Rungs with function and operation blocks Rules for executing rungs 2.3-1 Principle for executing a rung
2.2
2.3
3 Instruction list language 3.1 Presentation of Instruction list language 3.1-1 Principle 3.1-2 Instructions Program structure 3.2-1 General 3.2-2 Comments 3.2-3 Labels 3.2-4 Using parentheses 3.2-5 MPS, MRD and MPP instructions 3.2-6 Principles for programming predefined function blocks Rules for executing Instruction list programs
3.2
3.3
___________________________________________________________________________ A / 2
A
Description of PL7 software Contents Part A
___________________________________________________________________________ Page 4/1 4/1 4/1 4/2 4/6 4/6 4/6 4/7 4/7 4/8 4/14 5/1 5/1 5/1 5/2 5/4 5/5 5/11 5/14 5/17 5/17 5/18 5/19 5/21 5/23
Section 4 Structured Text language 4.1 Presentation of Structured Text language 4.1-1 Principle 4.1-2 Instructions Program structure 4.2-1 General 4.2-2 Comments 4.2-3 Labels 4.2-4 Instructions 4.2-5 Control structures Rules for executing a Structured Text program
4.2
4.3
5 Grafcet language 5.1 Presentation of Grafcet language 5.1-1 Reminder of principles of Grafcet 5.1-2 Graphic symbols specific to Grafcet language 5.1-3 Objects specific to Grafcet 5.1-4 Grafcet chart representation 5.1-5 Actions associated with steps 5.1-6 Conditions associated with transitions Organization of the master task 5.2-1 Description of the master task 5.2-2 Preprocessing 5.2-3 The use of system bits in preprocessing 5.2-4 Sequential processing 5.2-5 Post-processing
5.2
___________________________________________________________________________ A / 3
A
Description of PL7 software Contents Part A
___________________________________________________________________________
___________________________________________________________________________ A / 4
A
PL7 Section 1 General 1
1 General
1.1
1.1-1 Presentation PL7 Junior software is the programming software for TSX 37 and TSX 57 PLCs operating under Windows. PL7 Micro software can only be used to program TSX 37 PLCs. PL7 software offers : A graphic language, Ladder language, for transcribing relay diagrams, which is especially suitable for combinational processing and offers basic graphic elements, that is, contacts and coils. Numeric calculations can be written within operation blocks.
A Boolean language, Instruction list language, which is a "machine" language for writing logical and numerical processing operations.
___________________________________________________________________________ 1/1
A Structured text language which is a "data processing" type language enabling the structured writing of logical and numerical processing.
A Grafcet language which is used to represent the operation of a sequential control system in a graphic and structured way.
These languages include 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. 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
1
1.1-2 Single task structure This is the default structure of the software. It comprises a single task, the master task. Master task This task can either be a periodic, said to be cyclic (the default choice), or periodic. For cyclic operation, the tasks are linked one to the other, without pausing. For periodic operation, tasks are linked at a period fixed by the user. 1.1-3 Multitask structure The multitask structure of TSX 37 and TSX 57 PLCs enables better use which gives high-performance real-time applications by associating a specific program with each application. Each of these programs is controlled by a task. These tasks are independent and executed in "parallel" by the main processor which manages their priority as well as their execution. The aim of this type of structure is to : Optimize use of processing power. Simplify design and debugging. Each task is written and debugged independently of the others. Structure the application. Each task has a unique function. Optimize availability. The multitask system offers a master task, a fast task and from 8 to 64 event-triggered tasks depending on the processor.
Master task Fast task Event-triggered tasks
Priority
Fast task The fast task (optional), which is periodic, is used to perform short processing operations with a higher priority than in the master task. When it is programmed, it is automatically launched by the system during start-up. It can also be stopped and then restarted by activating a system bit. Event-triggered tasks Unlike the tasks described above, these tasks are not linked to a period. They are triggered by calls originating from certain modules. These tasks have the highest priority. The processing they perform is deliberately short so that they do not interfere with the execution of other tasks.
___________________________________________________________________________ 1/3
1.1-4 Symbolic programing Using PL7 software, the user can choose to enter or display objects : either by their address (for example : %Q2.5), or by a character string (32 characters max) known as a symbol (for example Fc_door).
Symbols used can be entered beforehand or while editing the program. This symbol database, which is managed by the software VARIABLES editor, is global to the PLC station.
___________________________________________________________________________ 1/4
A
PL7 General
1
1.1-5 PL7 instructions All PL7 languages use the same instruction set. Part B of this document describes all the instructions in detail. For simplicity's sake, these have been classified in 2 sets : basic instructions and advanced instructions. Basic instructions They include basic Boolean instructions, predefined function blocks and arithmetic and logic instructions on integers. Advanced instructions These include instructions which meet the needs of advanced programming. They are of 2 types : PL7 language : these increase language processing performance through specific functions (manipulation of character strings, time management, etc), Applications : these offer functions which are specific to the application to be processed. For example, functions for the communication application : - PRINT to send a standard character string message to a terminal or printer. - SEND to send a message to an application. - PID : PID control function.
Function entry help An entry help screen gives access to all the language functions. This screen is accessible at all times, including during programming.
___________________________________________________________________________ 1/5
1.2
Addressable objects
1.2-1 Definition of main Boolean objects Input/output bits These bits are the "logical images" of the electrical state of the I/O. They are stored in the data memory and are updated on each scan of the task in which they are configured. Internal bits Internal bits %Mi are used to store intermediate states during execution of the program.
Note : Unused I/O bits cannot be used as internal bits.
System bits System bits %S0 to %S127 monitor correct operation of the PLC as well as progression of the application program. The role and use of these bits are described in detail in section 3.1 of part B. Function block bits : Function block bits correspond to the outputs of blocks. These outputs can be either wired directly, or used as objects. Word extract bits : Using PL7 software it is possible to extract one of the 16 bits from a word object. Grafcet step status bits Grafcet step status bits %Xi are used to identify the status of Grafcet step i. List of bit operands The following table gives a list of all types of Boolean operands.
Type Immediate value Input bits Output bits Internal bits System bits Function block bits Step bits Word extract bits Address (or value) 0 or 1 (False or True) %Ix.i or %IXx.i %Qx.i or %QXx.i %Mi or %MXi %Si eg : %TMi.Q %DRi.F..... %Xi eg : %MW10:X5 Max number (2) Access in TSX 37 TSX 57 write mode (1) 328 256 128 96 1024 no yes See Sctn. 1.2-4 1.2-2 1.2-3 3.1 1.2-5 5.1-3 B A A A
Part A A
(1) Written via the program or in adjust mode via the terminal (2) Depends on the processor being used. (3) The maximum total of the bits (I/O + internal + system) is 4096.
___________________________________________________________________________ 1/6
A
PL7 General
1
1.2-2 Addressing TSX 37 I/O module objects Addressing of the main word and bit objects in I/O modules is defined by the following characters : %
Symbol
I or Q
Type of object I = input Q = output
X, W or D
Format X = Boolean W = word D = double word
i
Channel No. i= 0 to 127 or MOD
Type of object I and Q : the physical inputs and outputs of modules exchange this information implicitly on each scan of the task to which they are attached. Note : Other types of data (status, command words, etc) can also be exchanged if requested by the application (see application-specific functions : part F).
Format (Size) For objects in Boolean format, the X can be omitted. Other types of format such as byte, word and double word are defined in section 1.2-4.
Channel position and number The base modularity of the TSX 37 is 1/2 format. The positions for each type of TSX 37 PLC (base and extension) are shown in the diagrams below.
TSX 37-10
TSX 37-21/22
7 0
2
Base
2
Base
10
Extension
Extension
Standard format modules are addressed as two superposed 1/2 format modules (see table below). For example, a 64 I/O module is viewed as two 1/2 format modules : a 32 input 1/2 module located in position 5, and a 32 output 1/2 module located in slot 6. ___________________________________________________________________________ 1/7
Module
1/2 format 4Q 8Q 0 to 7
12 I 0 to 11
Channel number : i 0 to 3
x.0 to x.7
x.0 to x.11
Note : The channel number can be replaced by "MOD" to access data which is general to the module.
Suffix : an optional suffix can be added after the channel number. It is used to distinguish different objects of the same type associated with the same channel (see applications, part F). 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 remote I/O, 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 located at position no. 1. %I3.8 input channel no. 8 of the normal format module located in position no. 3 and 4. %Q4.5 output channel no. 5 of the standard format module located in position no. 3 and 4. %I5.MOD.ERR Information on module fault, of the module located in position no. 5. %IW8.0 input channel no. 0 of the 1/2 format module located in position no. 8.
%I3.8
%I5.MOD.ERR %IW8.0
2
Base
Extension %Q4.5
___________________________________________________________________________ 1/8
A
PL7 General
1
1.2-3 Addressing TSX 57 I/O module objects Addressing of the main word and bit objects in I/O modules is defined as follows :
% Symbol I or Q X, W or D x Rack address x = 0 to 7 y Module position y = 00 to 10 i Channel No. i = 0 to 127 or MOD
Type of object I and Q : the physical inputs and outputs of modules exchange this information implicitly on each scan of the task to which they are attached. Note : Other types of data (status, command words, etc) can also be exchanged if requested by the application (see application-specific functions : part F).
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
00
01
02
03
04
05
06
07
08
09
10
PS 01
00
01
02
03
04
05
06
07
08
09
10
___________________________________________________________________________ 1/9
Note : The channel number can be replaced by "MOD" to access general module information.
Suffix : an optional suffix can be added after the channel number. It is used to distinguish between different objects of the same type which are associated with a single channel (see application-specific functions, part F). ERR : indicates a module or a channel fault. Examples : - %I104.MOD.ERR : information on fault in the module in position 4 in rack at address 1. - %I104.3.ERR : information on fault in channel 3 of the module in position 4 in rack at address 1.
Note : For an addressing operation across the network or addressing remote I/O, the full access path to the station is added to the channel address.
Examples : %I102.5 : input channel 5 of the module located in position 2 in rack at address 1. %Q307.2 : output channel 2 of the module located in position 7 in rack at address 3. %I102.MOD.ERR : information on module fault, of the module located in position 2 in rack at address 1.
___________________________________________________________________________ 1/10
A
PL7 General
1
1.2-4 Addressing words Addressing I/O module words is defined in section 1.2-2 or 1.2-3. Other words used in PL7 language (except network words and function block words) are addressed in the following way : %
Symbol
M, K or S
Type of object M = internal K = constant S = system
B, W, D or F
Format B = byte W = word D = double word F = floating point
i
Number
Type of object M internal words which store values during execution of the program. They are stored in the data zone within a single memory zone. K constant words which store constant values or alphanumeric messages. Their content can only be written or modified by the terminal. They are stored in the same place as the program. They can therefore use the FLASH EPROM memory as their support. S system words. These words perform several functions : - some provide information on the status of the system by reading %SWi words (system and application operating time, etc). - others are used to perform operations on the application (operating mode, etc). System words are described in section 3, part B.
Format Word objects can be addressed by PL7 software using four different formats : B byte : this format is used exclusively for operations on character strings. W single length : these 16-bit words can contain an algebraic value between -32 768 and 32 767.
Bit position Rang du bit
15 14 13 12 11 10 9 8 0 1 1 1 7 6 5 4 0 0 1 1 3 2 1 0 0 1 0 0 Poids faible Least Significant
0 1 1 1
___________________________________________________________________________ 1/11
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 Poids faible
11 10 9 8 0 0 1 1 0 1 1 0
7 6 5 4 1 1 1 1 0 1 0 1
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
Overlay between objects : Bytes, single, double length and floating point words are stored within the data area in the same memory zone. Thus, there is overlay between : Double length word %MDi and single length words %MWi and %MWi+1 (word %MWi containing the least significant bits and word %MWi+1 containing the most significant bits of word %MDi). Single length word %MWi and bytes %MBj and %MBj +1 (where j=2.i). Between the floating point %MFk and single length words %MWk and %MWk+1. Examples : %MD0 corresponds to %MW0 and %MW1. %MW3 corresponds to %MB7 and %MB6. %KD543 corresponds to %KW543 and %KW544. %MF10 corresponds to %MW10 and %MW11.
%MW0 %MD0 %MD1 %MD2 %MD3 %MDi %MW1 %MW2 %MW3 %MWi %MWi+1 %MWk %MWk+1
%MFk
___________________________________________________________________________ 1/12
A
PL7 General
1
Immediate values These are algebraic values whose format is similar to that of single and double length words (16 or 32 bits), which allow assignment of values to these words. They are stored in the program memory and can take the following syntax :
Type Boolean Base 10 integer single length double length Base 2 integer single length (binary) double length Base 16 integer single length (hexadecimal) double length Floating point Character string Syntax 0 or 1 (FALSE or TRUE) 1506 578963 2#1000111011111011011 2#1000111011111011011 1111111011111011111 16#AB20 16#5AC10 -1.32E12 'aAbBcC' Lower limit -32768 -2 147 483 648 2#10...0 2#10...0 16#0000 16#000000000 -3.402824E+38 1.175494E-38 Upper limit +32767 2 147 483 647 2#01...1 2#01...1 16#FFFF 16#FFFFFFFF -1.175494E-38 3.402824E+38
Addressing common words on the network These are single length word objects (16 bits) common to all stations connected to the communication network. Addressing : on network n 0 : %NW{j}k where : - j = 0 to 31 station n - k= 0 to 3 word n
Word extract bits PL7 software can be used to extract one of the 16 bits from single length words. The number of the bit extracted is then added to the word address, following the syntax below :
WORD :X j Position j = 0 to 15 Bit number in the word
Examples : %MW10:X4 = bit n 4 of internal word %MW10 %QW5.1:X10 = bit n 10 of output word %QW5.1 ___________________________________________________________________________ 1/13
Summary list of main word objects and associated bits The notations used are R for read, and W for write.
Associated Type words and bits Internal words single length double length floating point byte (2) single length double length floating point byte (2) Input single length Input double length Output single length Output double length on network single length double length bit j of internal word bit j of constant word bit j of input word bit j of output word bit j of system word bit j of network 0 common word Addressing %MWi %MDi %MFi %MBi %KWi %KDi %KFi %KBi %IWxy.i %IDxy.i %QWxy.i %QDxy.i %NW{j}k %SWi %SDi %MWi:Xj %KWi:Xj %IWi:Xj %QWi:Xj %SWi:Xj %NW{j}k:Xm Limits (1) (1) (1) (1) (1) (1) (1) (1) 0i127 0i126 0i127 0i126 0j31 0k3 0i127 0i126 0j15 0j15 0j15 0j15 0j15 0m15 Possibilities R/W R/W R/W R/W R/W (3) R/W (3) R/W (3) R/W (3) R R R/W R/W R/W R/W (4) R/W (4) R/W R/W (3) R R/W R/W (4) R/W
Constant words
(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 depending on i.
___________________________________________________________________________ 1/14
A
PL7 General
1
1.2-5 Function block objects Function blocks use specific bit and word objects. Bit objects : These correspond to the outputs of blocks. These bits are accessible using Boolean test instructions. Word objects : These correspond : - to the configuration parameters of the block. The program may (eg : preset parameter) or may not (eg : time base) be used to access these parameters, - to the current values (eg : %Ci.V current counter value).
%Ci R E
sn2.2-1
sn2.2-2
Word
sn2.2-3
sn2.2-4
(1) The total number of timers %TMi and %Ti is limited to 64 for a TSX 37, 255 for a TSX 57. (2) The maximum number is given for a TSX 37, for a TSX 57 i = 0 to 254 for all function blocks.
___________________________________________________________________________ 1/15
1.2-6 Structured objects Bit tables Bit tables are sequences of adjacent bit objects of the same type and of a defined length, L.
%M10 %M11 %M12 %M13 %M14 %M15
nc by
Maximum size 1 L m (1) 1 L m (1) i+L n (2) i+L n (2) Access in write mode No Yes Yes No
(1) m = modularity of the module (eg : 8 for an 8 input or 8 output module), (2) n varies according to the size defined during configuration.
Word tables Word tables are sequences of adjacent words of the same type and of a defined length, L. Example of word tables : %KW10:5
Type Internal words Format Single length Double length Floating point Single length Double length Floating point Single length Address %MWi:L %MDi:L %MFi:L %KWi:L %KDi:L %KFi:L
%KW10
16 bits
%KW14
Maximum size
i+L Nmax (2) Yes i+L Nmax-1 (2) Yes i+L Nmax-1 (2) Yes i+L Nmax (2) No i+L Nmax-1 (2) No i+L Nmax-1 (2) No Yes
Constant words
System words
%SW50:4 (3)
Character strings Character strings are sequences of adjacent bytes of the same type and of a defined length, L. Example of character string : %MB10:5
Type Internal words Constant words Address %MBi:L (5) %KBi:L (5) Maximum size 1i+L Nmax (4) 1i+L Nmax (4)
%MB10
8 bits
%MB14
___________________________________________________________________________ 1/16
(3) Only words %SW50 to %SW53 can be addressed in table form. (4) Nmax = maximum number defined during software configuration. (5) i must be even.
A
PL7 General
1
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. 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.
Format Boolean Boolean Boolean Single length Double length Floating point Single length Double length Floating point Address %Ii[%MWj] %Qi[%MWj] %Mi[%MWj] %MWi[%MWj] %MDi[%MWj] %MFi[%MWj] %KWi[%MWj] %KDi[%MWj] %KFi[%MWj] Maximum size 0i+%MWjm (1) 0i+%MWjm (1) 0i+%MWjNmax (2) Access in write No Yes Yes
0i+%MWjNmax (2) Yes 0i+%MWjNmax-1 (2) Yes 0i+%MWjNmax-1 (2) Yes 0i+%MWjNmax (2) No 0i+%MWjNmax-1 (2) No 0i+%MWjNmax-1 (2) No 0i+%MWj+LNmax (2) Yes
Constant words
Word table
(1) m = modularity of the I/O module (eg : 8 for an 8 input or 8 output module). Indexation is only possible for discrete I/O modules. (2) Nmax = maximum number defined during software configuration. This type of addressing is used to run through a series of objects of the same type (internal words, constant words etc) in succession. The content of the index is added to the object address. Note : Indexing double words (or floating points). Example : %MD6[%MW100] direct address double word 6 + 2 times the content of word %MW100. If %MW100=10, the word addressed will be 6 + 2 x 10 -->%MD26.
___________________________________________________________________________ 1/17
Index overrun, system bit %S20 Index overrun occurs as soon as the address of an indexed object exceeds the limits of the zone including this same type of object, that is, when : object address + index content is lower than the value zero. object address + index content is higher than the maximum limit configured (see table on the previous page). In the event of index overrun, the system sets system bit %S20 to 1 and the object is assigned an index value of 0. Monitoring of overrun is the responsibility of the user : bit %S20 must be read by the user program for any processing. Resetting it is the responsibility of the user. %S20 (initial state = 0) : on index overrun : set to 1 by the system, overrun acknowledgment : set to 0 by the user after modification of the index.
1.2-7 Grafcet objects Bit objects The user has bit objects %Xi associated with the steps which enable him to identify the status of Grafcet step i. This bit is set to 1 when the step is active, and 0 when it is inactive. Word objects One word is associated with each step : %Xi.T. It indicates the activity time of Grafcet step i. It is incremented every 100ms and takes a value between 0 and 9999.
___________________________________________________________________________ 1/18
A
PL7 General
1
1.2-8 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 "DYp" or lower case alphabetical : " a to z", and accented letters : yp numerical : digits 0 to 9 (they cannot be placed at the start of the symbol). the character "_" (this cannot be placed either at the beginning or end of the symbol). A number of words are reserved by the language and cannot be used as symbols. See full list in section 5 part B. The symbols are defined and associated with language objects by the variables editor (see section 5, part D). A comment of 508 characters can be associated with each symbol. The symbols and their comments are saved to the terminal disk and not in the PLC. Objects which can be symbolized All PL7 objects can be symbolized except table type structured objects and indexed objects, but if the base object or the index is symbolized, the symbol is used in the structured object. Examples : if word %MW0 has "Temperature" as its symbol, the word table %MW0:12 is symbolized by "Temperature:12" if word %MW10 has "Oven_1" as its symbol, the indexed word %MW0[%MW10] is symbolized by "Temperature[oven_1]". Word extract bit objects and function block bits or words can be symbolized, but if they are not symbolized, they can take on the symbol of the base object. Examples : if word %MW0 has " Pump_status" as its symbol and if the word extract bit %MW0:X1 is not symbolized, it takes on the symbol of the word. %MW0:X1 has as its symbol, "Pump_status:X1". if function block %TM0 has "Oven1_timer" as its symbol and if output %TM0.D is not symbolized, it takes on a symbol of the block. %TM0.D has as its symbol, "Oven_timer.D". ___________________________________________________________________________ 1/19
1.3
User memory
1.3-1 General The memory space of TSX 37 PLCs, which is accessible to the user, is divided into two distinct units : Bit memory : RAM integrated in the processor module containing the image of 1280 bit objects. Word memory : 16-bit words (program, data and constants) supported by a RAM memory in the processor module. This memory can be extended by a 32 or 64 K word RAM or FLASH EPROM user memory card (on TSX 37-21/22). A 16 K word FLASH EPROM memory integrated in the processor module can be used to back up the application program (15 Kwords) and 1000 internal words (1 Kword) (see paragraph 1.3-2). A 32 K word FLASH EPROM backup card can also be used to update an application in the internal RAM of the processor. This card contains the program part and the constants but not the data. The word memory can be organized in 2 different ways depending on whether or not a memory card (PCMCIA) is used :
TSX 37-10 or TSX 37-21/22 (without PCMCIA card) TSX 37-21/22 (with PCMCIA card)
Internal RAM
v
Data Program
w v
Internal RAM
Data
Unusable zone
Constants Program and constants backup %MW backup RAM or external Flash EPROM memory card
w v
%MW backup
Program
Constants
: application and system dynamic data. : descriptors and executable code of tasks. : constant words, initial values and I/O configuration.
RAM memories can be protected by Cadmium-nickel batteries, supported by the processor module for the bit and internal RAM memory.
(1) The application is transferred automatically from the FLASH EPROM memory to the RAM memory if the application in the RAM is lost (backup fault or absence of battery). A manual transfer can also be requested, via a programming terminal. ___________________________________________________________________________
1/20
A
PL7 General
1
The memory space of TSX 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 or 64 K word (on TSX 57-10) and by a 32, 64 or 128 K word (on TSX 57-20) RAM or FLASH EPROM user memory card. 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 57-10 or TSX 57-20 (no memory card) TSX 57-10 or TSX 57-20 (with card)
internal RAM
internal RAM
Data
Program
Constants
: dynamic application data and system data (the system reseves a RAM zone of 5 Kwords minimum : see part B, section 8). : descriptors and executable code of tasks. : constant words, initial values and I/O configuration.
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 protected by nickel-cadmium batteries.
___________________________________________________________________________ 1/21
1.3-2 Saving / retrieving internal words %MWi Saving internal words %MWi In order to save adjustment data in the event of a power outage, when the processor battery is faulty or missing, TSX 37 PLCs can copy 1000 internal words (%MW) maximum to the internal Flash EPROM memory. This backup zone can be used at all times, even if the PLC is fitted with a PCMCIA memory card (TSX 37-21/22). To save internal words to the Flash EPROM, the application must be stopped. It is triggered according to the choice made during configuration : by setting the discrete input %I1.9 to 1, from an adjustment panel, by setting bit 0 of %SW96 to 1. The value of system word %SW97 defines the number of %MWi to be saved (1000 maximum). At the end of the backup, the display block displays OK or NOK depending on the result of the operation. The internal words %MWi are always saved when the application program is saved. If system word %SW97 is initialized to 0, only the application program contained in the internal RAM is transferred to the Flash EPROM (equivalent to a Backup program). Warning : any saved %MWi are still erased. Retrieving internal words %MWi Saved %MWi are transferred from the internal Flash EPROM memory to the RAM memory on a cold restart caused by : loss of the internal RAM contents. In this case, if the application program backup is valid, this is also transferred to the internal RAM (TSX 37-10 or TSX 37-20 without PCMCIA application cartridge), pressing the RESET button, on the front panel of the PLC, setting bit %S0 to 1, in adjust mode, clicking on the "Cold restart" button of the PL7 processor debug screen, transferring a program to the PLC (via terminal port, FIPWAY, etc), plugging in a PCMCIA application cartridge. For the saved %MW to be retrieved to the internal RAM, the "Reset %MWi on cold restart" check box must not be checked in the processor configuration screen. For further information, refer to part A of the TSX Micro installation manual.
___________________________________________________________________________ 1/22
A
PL7 General
1
1.3-3 Bit memory Composition This memory contains 1280 bit objects, for all types of TSX 37 PLC. For the TSX 57, this bit memory does not exist and its contents are found in the word memory in the application data zone.
TSX 37-10 System bits I/O bits Internal bits Step bits %SI %I/Qx %Mi %Xi 128 408 (1) 256 96 TSX 37-21/22 128 472 (1) 256 128 TSX 57-10 128 512 4096 (2) 128 TSX 57-20 128 1024 4096 (2) 128
(1) With AS-i bus (2) The number of internal bits can be set in the configuration. The default value (256 to 2048) varies depending on the processor being used and on the presence of a memory cartridge. The rest of the memory is available for application-specific functions. The total number of bits (system bits + I/O bits + internal bits) must not exceed 4096.
Structure Each bit object contained in the bit memory is stored using 3 bits assigned in the following way : F P C
Current state (only bit accessible by the application program) Previous state Forcing state
When the bit memory is updated, the system performs the following : the transfer of the image of the current state to the previous state, the updating of the current state via the program, the system or the terminal (when a bit is forced). Rising or falling edge This structure of the bit memory is used to test for a rising or falling edge on : I/O bits, internal bits. Recommendations for the use of rising or falling edges The rising or falling edge contact instructions only operate correctly in the following conditions : in all cases, for a single object : - input bit : process the edge contact in the task to which the input module has been assigned, - output or internal bit : process reading and writing of it within the same task. ___________________________________________________________________________ 1/23
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 edge is permanently on.
%M0
P
INC%MW0
In order that the edge is only detected once, an intermediate internal bit must be used. In this case the %M1 log is updated, therefore the edge only occurs once.
%M0 %M1
%M1
P
INC%MW0
Forcing states When there is a forcing request via the terminal : forcing state F is set to 1 current state C is set to : - 1 if forcing to 1 is requested - 0 if forcing to 0 is requested. These states remain unchanged until : forcing is deactivated and the bit in question updated, inverse forcing is requested, in which case only the current state is modified.
___________________________________________________________________________ 1/24
A
PL7 General
1
1.3-4 Word memory This 16-bit word memory is structured into 3 logical areas : Data Program Constants
Application constants Application data Application program
of which the size is defined by configuration. Application data memory The data memory contains the following zones : System words : fixed number Function blocks : correspond to the words and I/O of these blocks (current, adjustment values, etc). The number of each type of function block is fixed during configuration. Internal words : size defined by the number declared during configuration. I/O : correspond to the words associated with each module. Their number depends on the modules configured. Network common words : 4 common words per PLC station (only available if communication module present and configured for exchange of common words).
In the case of the TSX 57, the data memory also includes the information bits detailed in the preceding paragraph. Application program memory This zone contains the executable program code, graphic data (Ladder language rungs) and program comments. Application constant memory This zone contains the parameters of the function blocks and I/O modules defined during configuration, and constant words %KW.
Note : The symbols and comments associated with objects are not recorded in the PLC memory but stored in the local application (hard disk on the terminal).
___________________________________________________________________________ 1/25
of objects I/O bits %I/Qx.i internal bits %Mi step bits %Xi
Word memory Total size available on processor Data (%MWi) Program (3) Ladder language Instruction list language Structured text language Constants
(1) Of which 15K words are available for the program and the application constants and 1 Kword is reserved for the %MWi backup. (2) Default size can be extended. However, this will affect the size of the application program. (3) Sizes are given in Kinstructions for applications which are 100% Boolean, 90% Boolean, 65% Boolean respectively.
Note : the PLC/Memory Usage command in PL7 software provides the memory mapping of the application in the PLC memory. ___________________________________________________________________________ 1/26
A
PL7 General
1
of objects I/O bits %I/Qx.i internal bits %Mi step bits %Xi
Data
Unusable zone
w v
Program
Constants
(1) Can be used if the Program/Constants together are less than 15 K words Word memory Total size available Data (%MWi) Program (3) Ladder language List language No card 20 Kwords 0.5 Kwords 6.6/5.3/3.9 Kinst. 8.5/6.5/4.4 Kinstr. With 32 K card 52 Kwords 17.5 Kwords With 64 K card 84 Kwords 17.5 Kwords
13.5/11.6/8.8 Kinstr. 28.1/24.3/18.6 Kinstr. 17.2/14.1/10.0 Kinstr. 35.9/29.6/21.0 Kinstr. 11.5/10.9/10.0 Kinstr. 23.9/23.0/21.0 Kinstr. 256 words (2) 512 words (2)
(1) Of which 15K words are available for the program and the application constants and 1 Kword is reserved for the %MWi backup. (2) Default size can be extended. However, this will affect the size of the application program. (3) Sizes are given in Kinstructions for applications which are 100% Boolean, 90% Boolean, 65% Boolean respectively.
Note : the PLC/Memory Usage command in PL7 software provides the memory mapping of the application in the PLC memory. ___________________________________________________________________________ 1/27
1.3-7 TSX 57-10 PLCs Structure of the word memory No memory card
Internal RAM 32 Kwords Data Program Constants RAM or FLASH EPROM memory 32 Kwords card or 64 Kwords
Program
Constants
Bit memory System bits %Si I/O bits %I/Qx.i Internal bits %Mi Step bits %Xi
The number of internal bits can be set in the configuration. The values indicated are maximum values and they depend on the presence of a memory card.
Word memory Total size available Data (%MWi) Program (2) Ladder language List language No card 32 Kwords 0.5 Kwords (1) 8.5/5.0/3.4 Kinst. 10.9/5.9/3.5 Kinstr. With 32 K card 64 Kwords 26 Kwords 11.9/8.3/6.4 Kinstr. 15.1/9.9/6.5 Kinstr. 10.1/7.9/7.6 Kinstr. 256 words With 64 K card 96 Kwords 26 Kwords 26.6/21.0/16.4 Kinstr. 33.9/25.2/16.8 Kinstr. 22.6/20.1/19.4 Kinstr. 512 words
(1) Default size can be extended. However, this will affect the size of the application program. (2) Sizes are given in Kinstructions for applications which are 100% Boolean, 90% Boolean, 65% Boolean respectively.
Note : the PLC/Memory usage command in PL7 software provides the memory mapping of the application in the PLC memory. ___________________________________________________________________________ 1/28
A
PL7 General
1
1.3-8 TSX 57-20 PLCs Structure of the word memory No memory card
Internal RAM 48 Kwords Data Program Constants RAM or FLASH EPROM memory 32 Kwords card or 64 Kwords or 128 Kwords
Program
Constants
Bit memory System bits %Si I/O bits %I/Qx.i Internal bits %Mi Step bits %Xi
The number of internal bits can be set in the configuration. The values indicated are maximum values and depend on the presence of a memory card.
Word memory No card With 32 K card With 64 K card With 128 K card
Total size available Data (%MWi) Program (2) Ladder language List language Structured text language Constants (1)
14.1/10.0/7.2 K 11.0/7.6/5.8 K 18.0/11.9/7.4 K 14.0/9.0/6.0 K 12.0/9.6/8.6 K 256 words 9.3/7.2/6.9 K 256 words
25.4/20.1/15.6 K 55.2/45.8/35.8 K 32.3/24.0/16.0 K 70.3/54.7/36.6 K 21.5/19.2/18.5 K 46.9/43.9/42.4 K 1024 words 1024 words
(1) Default size can be extended. However, this will affect the size of the application program. (2) Sizes are given in Kinstructions for applications which are 100% Boolean, 90% Boolean, 65% Boolean respectively.
Note : the PLC/Memory Usage command in PL7 software provides the memory mapping of the application in the PLC memory. ___________________________________________________________________________ 1/29
1.4
Operating modes
1.4-1 Processing on outage and power return When power outage occurs, the system saves the application context and time of the outage and then sets all outputs to fallback state (state defined by configuration). On power return, the context saved is compared to the current one. This defines the type of restart to be performed : If the application context has changed (loss of the system context or new application), the PLC initializes the application, that is, performs a cold restart. If the application context is identical, the PLC performs a restart without data initialization, that is, a warm restart. If the period of the outage is shorter than the supply filter time (approximately 10 ms for an AC power supply or 1 ms for DC power supply), it is not seen by the program, which proceeds normally.
RUN Application
Outage detected No
Yes
No
No
Warm restart
Note : A cold restart can be activated : On power return 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. Then the PCMCIA memory card is inserted in its slot (or when the handle is manipulated). A warm restart can be activated : On power return without loss of context. By the program setting system bit %S1 to 1, From PL7 by the terminal.
___________________________________________________________________________ 1/30
Cold restart
A
PL7 General
1
Program execution TOP Power return If%S1 = 1, warm restart processing possible Yes Power outage > micro-break No BOT Configuration self-tests
Update outputs
Restart program execution Program execution restarts from the element at which power outage took place, without updating outputs. The system then performs a restart cycle in which it takes into account again all the input modules, relaunches the master task with bit %S1 set to 1 during one scan of the task, and updates the outputs. The system deactivates the fast and event-triggered tasks until the end of the first scan of the master task. Warm restart processing In the event of warm restarts users who require a particular processing operation in relation to the application must write the corresponding program by testing for %S1 at 1 at the beginning of the program of the master task. Change in outputs As soon as power outage is detected, the outputs are set to fallback state : either set to fallback value or retain their current value, depending on the choice made during configuration. On power return, the outputs remain at zero until they are updated by the task. ___________________________________________________________________________ 1/31
Program execution TOP Power return If %S0 = 1, process cold restart Yes Power outage > micro-break No BOT Initialization of the application Configuration self-tests
Update outputs
Initialization of the data and the system, which corresponds to : Resetting the bits, the image of the I/O and the internal words (if the option to reset internal words on a cold restart is selected in the PLC Configuration screen, see section 1.3, part D). If the Reset option for %MW is not active and the %MWi are saved in the Flash EPROM internal memory (TSX37), they are retrieved on a cold restart. Initialization of system bits and words. Initialization of function blocks based on configuration data. The tasks, other than the master task, are deactivated until the end of the first scan of the master task. Positioning of the Grafcet on the initial steps. Cold restart processing In the event of a cold restart, if the user requires a particular processing operation in relation to the application, bit %S0 can be tested (if %S0 = 1, then cold restart processing occurs). On a cold restart, the PLC either does or does not continue execution, depending on the choice of the user defined during configuration (RUN AUTO parameter). Change in outputs As soon as a power outage is detected, the outputs are set to fallback state. They are either set to fallback value, or the current value is maintained, depending on the choice made during configuration. On power return, the outputs remain at zero until they are updated by the task. ___________________________________________________________________________ 1/32
A
PL7 General
1
1.5
1.5-1 Presentation of the master task The program of a single task application is associated with a single user task : the master task, MAST. The program associated with the master task is structured into several program modules. Depending on whether or not Grafcet is used, there are two alternatives : No Grafcet: main processing (MAIN) subroutine SRi (i=0 to 253) The subroutine modules are programmed as separate entities, calls to subroutines being performed during main processing or from other subroutines (8 levels of subroutines are possible).
Main processing MAIN Subroutine SRi Subroutine SR1 Subroutine SR0
Either cyclic or periodic execution of the master task can be chosen (during configuration). With Grafcet : preprocessing (PRL). This is executed before the Grafcet chart, Grafcet (CHART) : transition conditions associated with the transitions and actions associated with the steps are programmed in the Grafcet pages, post-processing (POST). This is executed after the Grafcet chart, subroutine SRi (i = 0 to 253). The subroutine modules are programmed separately, calls to subroutines being made during preprocessing or postprocessing, in the actions associated with the steps or from other subroutines (8 levels maximum).
Preprocessing PRL
Subroutine SRi
Postprocessing POST
Subroutine SRi
Either cyclic or periodic execution of the master task can be selected (during configuration).
___________________________________________________________________________ 1/33
1.5-2 Cyclic execution This type of operation corresponds to normal execution of the PLC scan (default option). It consists of consecutively linking the cycles of the master task (MAST). After updating the outputs, the system performs its specific processing operations and then links to another task scan.
Programm processing (1) I.P. %I %Q (1) I.P. %I Program processing %Q
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 real-time clock, updating status indicator lamps, detection of RUN/STOP changes, etc) and processes requests from the terminal (modifications and animation), %I Read inputs : writes to memory the status of the information on the inputs of discrete and application-specific modules associated with the task, Program processing : execution of the application program, written by the user. %Q Update outputs : writes output bits or words associated with discrete and application-specific modules associated with the task depending on the status defined by the application program. Operating scan cycle/cycle monitoring PLC in RUN : the processor performs, in order, internal processing, reads the inputs, processes the application program and updates the outputs. PLC in STOP : the processor performs internal processing, reads the inputs, and depending on the configuration chosen : - fallback mode : the outputs are set to "fallback" position, - maintain mode : the outputs maintain their current values.
Internal processing
(1)
Update outputs
A
PL7 General
1.5-3 Periodic execution In this operating mode, reading inputs, application program processing and updating output is performed periodically according to a period of time defined during configuration (from 1 to 255 ms). At the start of the PLC scan, a timer, whose current value is initialized to the period defined during configuration, starts to count down. The PLC scan must finish before expiry of this timer, which then launches a new scan.
Program processing
(1)
Program processing %Q
(1) (1) %I
%I Period
I.P.
%Q (1) I.P.
I.P. Internal processing : the system implicitly monitors the PLC (management of system bits and words, updating current values of the real-time 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 57, internal processing is carried out in parallel with I/O processing.
___________________________________________________________________________ 1/35
Operating scan cycle/monitoring PLC in RUN : the processor performs, in order, internal processing, reads inputs, processes the application program and updates outputs. If the period is not yet over, the processor completes its operating cycle until the end of the period, via internal processing. If the operating time becomes longer than that assigned to the period, the PLC indicates a period overrun by setting system bit %S19 of the task to 1, processing continues and is fully executed (it must not, however, exceed the time limit of the watchdog). The following scan cycle is linked, after implicit writing of the outputs in the current cycle. PLC in STOP : the processor performs internal processing, reads inputs, and depending on the configuration chosen : - fallback mode : the outputs are set to "fallback" position, - maintain mode : the outputs maintain their current values. Cycle monitoring : 2 controls are performed : period overrun, via the watchdog, (see section 1.5-4).
Start of period
Internal processing
(1)
Update outputs
Internal processing
(1)
End of period
(1) In the case of the TSX 57, internal processing is carried out in parallel with I/O processing.
___________________________________________________________________________ 1/36
A
PL7 General
1
1.5-4 Monitoring scan time Software watchdog (periodic or cyclic operation) The execution time of the master task, whether in cyclic or periodic operation, is controlled by the PLC (watchdog) and should not exceed the value Tmax defined during configuration (250 ms default, 500 ms maximum). In the event of 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 57, the alarm relay on the supply is set to 0). Bit %S11 is used to monitor execution of this task. It indicates a watchdog overrun. It is set to 1 by the system when the scan time becomes longer than the watchdog. On the TSX 57, the watchdog value must be longer than the period. In periodic operation, an additional control is used to detect period overrun : %S19 : indicates a period overrun. It is set to 1 by the system when the scan time becomes longer than the task period. %SW0 : this word contains the value of the period (in ms). It is initialized at a cold restart by the value defined during configuration. It can be modified by the user.
Using the execution time of the master task The following system words provide data on the scan time : %SW30 contains the execution time of the last scan. %SW31 contains the execution time of the longest scan. %SW32 contains the execution time of the shortest scan.
Note : This data can also be accessed from the configuration editor if requested.
___________________________________________________________________________ 1/37
1.6
1.6-1 Description The structure in tasks of such an application is as follows : The master task, MAST, which is always present and can be cyclic or periodic. The fast task, FAST, which is optional and always periodic. Event-triggered processing operations EVTi, called up by the system when an event appears on an I/O module. This processing is optional and is used by applications requiring short response times to perform operations on I/O.
Master task Fast task Event-triggered tasks
Priority
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 cycle, the task stops current execution of lower priority tasks in order to execute its own processing. The interrupted task takes over when processing of the priority task is completed. The execution of fast and event-triggered tasks can be controlled by the program using system bits : %S30 is used to activate or deactivate the master task, MAST. %S31 is used to activate or deactivate the fast task, FAST. %S38 is used to activate or deactivate event-triggered tasks EVTi. Example of multitask processing cyclic master task fast task with 20 ms period event-triggered task.
Event fast I PO I PO I PO I
ET S
PO
I PO
Master System
I P
PO
I P
P O
20 ms
20 ms
20 ms
20 ms
___________________________________________________________________________ 1/38
A
PL7 General
1
1.6-2 Master task This task, which has the lowest priority, manages the majority of the application program. The MAST task is organized according to the model described in the previous section : implicit reading of inputs, execution of the application program and implicit writing of outputs. Whether the operating mode is periodic or cyclic, the task is monitored by a watchdog which is used to detect an abnormal duration of the application program. In the event of an overrun, system bit %S11 is set to 1 and the application is declared as faulty, which stops the PLC. The system bit %S30 enables or inhibits the master task. 1.6-3 Fast task This task, which is higher priority than the master task MAST, is periodic in order to leave time for execution of the lower priority task. In addition, the processing operations which are associated with it should therefore be short, to avoid adversely affecting the master task. Like the master task, the associated program consists of a main module and subroutines. The period of the fast task, FAST, is set during configuration, from 1 to 255 ms. This can be defined as longer than that of the master task, MAST, in order to adapt it to periodic processing operations which are slow but have higher priority. The program executed should however remain short to avoid overrun of lower priority tasks. The fast task is monitored by a watchdog which is used to detect an abnormal duration of the application program. In the event of an overrun, system bit %S11 is set to 1 and the application is declared as faulty, which stops the PLC. Control of the fast task System word %SW1 contains the value of the period. It is initialized at a cold restart by the value defined during configuration and can be modified by the user via the program or the terminal. System bits and words are used to monitor execution of this task : %S19 : indicates a period overrun. It is set to 1 by the system when the scan time becomes longer than the task period. %S31 : is used to enable or inhibit the fast task. It is set to 0 by the system at a cold restart of the application, at the end of the first scan of the master task. It is set to 1 or 0 to enable or inhibit the fast task. Display of the fast task execution times The following system words provide data on scan times : %SW33 contains the execution time of the last scan. %SW34 contains the execution time of the longest scan. %SW35 contains the execution time of the shortest scan. ___________________________________________________________________________ 1/39
1.6-4 Assigning I/O channels to the master and fast tasks In addition to the application program, the MAST and FAST tasks execute system functions linked to the management of implicit I/O which are associated with them. Associating a channel or a group of channels with a task is defined in the configuration screen for the corresponding module. The default associated task is the MAST task. Since the modularity of discrete modules is 8 consecutive channels (channels 0 to 7, channels 8 to 15, etc), I/O can be assigned in groups of 8 channels, either to the MAST or FAST task. For example, it is possible to assign the channels of a 28 I/O module in the following way : Inputs 0 to 7 assigned to the MAST task. Inputs 8 to 15 assigned to the FAST task. Outputs 0 to 7 assigned to the MAST task. Outputs 8 to 11 assigned to the FAST task. Each channel of a counter module can be assigned either to the MAST or FAST task. For example, for a 2 channel counter module, it is possible to assign : channel 0 to the MAST task and, channel 1 to the FAST task. The channels of TSX 37 analog input modules must be assigned to the MAST task. However, it is possible to assign analog output channels to either the MAST or FAST task, with 2 channel modularity. For example, for a module with 4 analog outputs, it is possible to assign : channels 0 and 1 to the MAST task and, channels 2 and 3 to the FAST task. The channels of TSX 57 analog I/O modules can be assigned to the MAST or FAST task. Each channel of the isolated analog I/O modules (4 isolated channels) is assigned on an individual basis. A 4-channel modularity is used for other modules.
___________________________________________________________________________ 1/40
A
PL7 General
1
1.6-5 Event-triggered tasks Event-triggered processing is used to reduce the response time of the software on command events. Command events These are external events associated with applications. The appearance of such an event diverts the application program to the processing operation associated with the I/O channel which caused the event. The inputs (%I, %IW, %ID) associated with the I/O channel which triggered the event are updated by the system before calling up event processing. It is possible to configure : 8 events in a TSX 37-10 PLC (EVT0 to EVT7). 16 events in a TSX 37-21/22 PLC (EVT0 to EVT15). 32 events in a TSX 57-10 PLC (EVT0 to EVT31). 64 events in a TSX 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 57, event processing can be triggered by : The 16 inputs of DEY 16 FK modules. The counter channels. The channels of CAY axis control modules. The channels of CFY stepper axis control modules. Communication channels "FPP20".
Management of event-triggered tasks Event-triggered processing can be globally enabled or inhibited by the application program, using system bit %S38. If one or more events occur while they are inhibited, the associated processing operations are lost. Two PL7 language instructions MASKEVT() and UNMASKEVT(), used in the application program, also allow masking or unmasking of event-triggered processing. If one or more events occur while they are masked, they are saved by the system and the associated processing will only be carried out after unmasking. The 8 possible command events with a TSX 37-10 PLC all have the same level of priority. Thus, one event processing operation cannot be interrupted by another. In a TSX 37-21/22 or a TSX 57 PLC, there are 2 levels of priority for command events : event 0 (EVT0) is higher priority than the other events. ___________________________________________________________________________ 1/41
I/O exchanges in event-triggered tasks With each event-triggered task it is possible to use I/O channels other than those relating to the event. Exchanges are then performed implicitly by the system before (%I) and after (%Q) application processing. These exchanges can relate to a single channel (example of counter module) or to a group of channels (discrete module). In the second case, if the processing modifies, for example, outputs 2 and 3 of a discrete module, it is the image of outputs 0 to 7 which will be transferred to the module.
IT
r
The appearance of such an event diverts the application program towards the processing operation which is associated with the I/O channel which caused the event :
Implicit reading of inputs associated with the channel, origin of the event Implicit reading of the inputs declared in task EVTi Event processing Implicit update of the outputs used in task EVTi
All the inputs associated with the channel which caused the event are read automatically.
All the inputs declared by the user in task EVTi are read.
Processing should be as short as possible. All the outputs used by the user in task EVTi are updated. The outputs associated with the channel which caused the event should also be declared so they can be updated.
___________________________________________________________________________ 1/42
A
PL7 General
1
Notes On the TSX 37, analog input modules, which can only be used in the MAST task, should not be exchanged in event processing. The exchange of I/O, associated with the EVTi task and used by the program, is performed channel by channel (for counter modules) or in groups of channels (for discrete modules). For this reason, if processing modifies, for example, outputs 2 and 3 of a discrete module, it is the image of outputs 0 to 7 which will be transferred to the module. On the TSX 37, for each event-triggered processing operation, it is possible to declare a maximum of exchanges for 2 input modules (before processing of the event) and 2 output modules (after processing of the event). The inputs exchanged (and the group of associated channels) during event-triggered processing are updated (loss of log values and, consequently, edges). Thus, edges should not be tested on these inputs in the master (MAST) or fast (FAST) tasks. On the TSX 57, depending on the processor used, the number of exchanges used is limited :
No. of exchanges which can be used in EVTs by processor Max. no. of discrete exchanges Max. no. of analog exchanges Max. no. of other applicationspecific exchanges P57-10 (32 EVTs) 32 exchanges 8 exchanges 4 exchanges P57-20 (64 EVTs) 128 exchanges 16 exchanges 16 exchanges
For discrete I/O, an exchange involves a group of 8 channels. It is generated when the inputs of a group of 8 channels are used (other than the group of channels which generate the event) and when writing the outputs of a group of 8 channels. For analog or other application-specific I/O, an exchange is generated when the inputs of a channel are used (other than the channel which generates the event) and when writing the outputs of a channel. Display of the number of events processed Word %SW48 shows the number of events processed. This word is initialized to 0 at a cold restart, then incremented by the system when an event is launched. This word can be modified by the user. %S39 indicates loss of event. Note : A summary of the operations to be performed to program events is given in part F, section 5.2. ___________________________________________________________________________ 1/43
A
Ladder Section 22 language
2 Ladder language
2.1
2.1-1 Principle Programs written in Ladder language consist of a series of rungs which are executed sequentially by the PLC. A rung consists of a set of graphic elements bounded on the left and right by power rails. They represent : The PLC I/O (pushbuttons, sensors, relays, indicator lamps, etc). Standard control system functions (timers, counters, etc). Arithmetic, logic and specific operations. The internal variables of the PLC. The graphic elements are interconnected by horizontal and vertical links. Each rung consists of a maximum of 7 lines and 11 columns, which are divided into 2 zones : The test zone which contains the conditions necessary to execute the actions. The action zone which contains the actions to be executed according to the results of the test zone.
Formulaire programmation schma contacts
A TT ENT E DU S ECHAG E
EVT MAIN SR
FAST PRE
MAST POST
AUX CHART
%L
%I1.0
%TM4.Q %M17
%M12 %I3.7
%Q2.5
%MW4<50 %I3.10 %Q4.3 %M27 IN %TM0 Q TYP : TP TB : 100ms TM.P : 200 MODIF : Y %I1.2 %I1.4
SR1 C
___________________________________________________________________________ 2/1
2.1-2 Graphic elements Basic elements They all occupy a single cell (1 line high, 1 column wide).
Designation Test elements Normally open contact Normally closed contact Edge detection contacts
P
Symbol
Function Contact closed when the bit object which controls it is at 1. Contact closed when the bit object which controls it is at 0. Rising edge : contact closed when the bit object which controls it changes from 0 to 1. Falling edge : contact closed when the bit object which controls it changes from 1 to 0. Used to link test and action graphic elements between the two power rails in series. Used to link test and action graphic elements in parallel. Sets the associated bit object to the value of the result of the test zone. Sets the associated bit object to the inverse value of the result of the test zone.
Link elements
Action elements
Direct coil Negated coil Latch coil Unlatch coil Conditional JUMP to another rung
S R
Sets the associated bit object to 1 when the result of the test zone is at 1. Resets the associated bit object to 0 when the result of the test zone is at 1. Allows connection to a labelled rung, either upstream or downstream. Jumps are only effective within the same programing entity (main program, subroutine, etc). If a jump is activated : Scanning of the current rung is interrupted. The requested labelled rung is executed. The part of the program between the jump action and the designated rung is not executed.
->> %Li
Offered in Grafcet language, used when programming conditions associated with transitions, to move to the next step.
___________________________________________________________________________ 2/2
A
Ladder language
2
Symbol
C
Function Allows connection at the beginning of subroutines when the result of the test zone is at 1. If a subroutine is called : Scanning of the current rung is interrupted. The subroutine is executed. Scanning of the interrupted rung is resumed.
<RETURN> Reserved for subroutines SR, allows return to the calling module when the result of the test zone is at 1. <HALT> Stops execution of the program when the result of the test zone is at 1.
Function blocks
Designation Test elements Blocks : Timer Counter Monostable Register Drum controller Symbol Function Each of the standard function blocks uses I/O which allow them to be linked to other graphic elements. The functions of each block are described in part B. Size : see section 2.2-5.
Operation blocks
Designation Test elements Vertical comparison block Horizontal comparison block Action elements Operation block Symbol Function Allows comparison of 2 operands. Depending on the result, the corresponding output changes to 1. Size : 2 columns/4 lines. Allows comparison of 2 operands. The output changes to 1 when the result is checked. (A block can contain up to 4096 characters). Size : 2 columns/1 line. Performs arithmetic, logic operations etc and uses Structured text language syntax. (A block can contain up to 4096 characters). Size : 4 columns/1 line.
___________________________________________________________________________ 2/3
2.2
Structure of a rung
2.2-1 General A rung is located between two power rails and consists of a set of graphic elements which are interconnected by horizontal or vertical links. A rung contains up to 7 lines and 11 columns divided into two zones, the test zone and the action zone.
Columns
6
EVT MAIN
7
FAST SR
9
MAST PRE
10
11
AUX
POST
CHART
Lines 1 2 3 4 5 6 7
Power rails
___________________________________________________________________________ 2/4
Action zone
Test zone
A
Ladder language
2
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 the same program entity. However, a rung must be labelled to allow connection after a program jump.
%M20
%L245
% L2 4 5
%M3
%TM4.D
%I1.6 %MW1:X2
%Q2.1
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 the reserved zone in the upper part of the rung. If a rung is deleted, the comment associated with it is also deleted.
%L
%Q2.3 %I1.4 %MW2:X9 %I1.3
%M16 %C8.E
%Q4.7 SR4 C
%M12 %TM3.Q
%I5.2
%M155 S
Comments are stored in the PLC and can be accessed at all times by the user. They therefore use program memory.
___________________________________________________________________________ 2/5
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 the left power rail and must finish on the right power rail. Tests are always located on columns 1 to 10. Actions are always located on column 11. The direction of current is the following : for horizontal links, from left to right, for vertical links, in both directions.
%L
%Q2.3 %I1.4 %MW2:X9 %I1.3
%M16 %C8.E
%Q4.7 SR4 C
%M12 %TM3.Q
%I5.2
%M155 S
%L
%M16 %T3.D %I5.4 %C13.E
Test zone This zone contains : contacts, to which all the bit objects defined above can be assigned, function blocks, comparison blocks. Rising and falling edges can only be associated with I/O bit objects and internal bits.
%L
%M9 S %MN0 R
%MW8:X4
%I6.8 %C2.D
TB : 100ms MN.P : 80
___________________________________________________________________________ 2/6
A
Ladder language
2
Action zone This zone contains : direct, negated, latch and unlatch coils, which can be assigned to any bit object which can be written by the user. operation blocks. the other "coils" : Call, Jump, Halt, Return.
%L
%M52
%MW8:X1
%MW8:X10 /
Simple rungs Control of a coil conditioned by the state of a contact. Use of up to 10 contacts in series on one line. A maximum of 7 contacts can be tested in parallel on one column, and 7 coils placed in parallel.
%I1.3
%Q4.12
%M1
%I3.2 %MW18:X4 %Q4.2 %M15 %TM2.Q %I3.4 %MW1:X5 %M5 %C0.D %Q6.3 /
%L
%M5 %I6.9
%MW15:X5
%Q6.2 %M25
%MW8:X0 / SR9 C %L20
%M12 R %Q2.6 S
___________________________________________________________________________ 2/7
Rung using several lines of contacts A rung can be divided into several independent lines of contacts controlling independent coils.
%L
%I3.2 %MW6:X10 %M88 %C2.E %S4 %L12 SR C %Q3.2 %Q3.3 / %MW3:X6 %M27 %M68 S
%I6.5
P
%M53
%MW8:X4
%M12
%L
Symbols at logic state 1 are circled. The current can pass from symbols A and C to coil F. It cannot pass from symbol C to symbols D and E. Coil G is therefore not activated.
D E G
___________________________________________________________________________ 2/8
A
Ladder language
2.2-5 Rungs with function and operation blocks Function blocks are located in the test zone and are inserted in a rung. Four sizes of graphic are used to represent all the other function blocks of the PL7 Micro language.
%C4
Up/down counter "Vertical" comparison block 2 columns 4 lines
2 columns 3 lines
%TM10
2 columns 1 line
COMPARE
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
___________________________________________________________________________ 2/9
Function blocks can be "cascaded" Like the contact type graphic elements, it is possible to combine function blocks. Connecting function blocks in series :
%L
%I3.6 S %MN1 R TB : 100ms MN.P : 80 %TM12 IN Q TYP : TP TB : 100ms TM.P : 200 MODIF : Y
%Q6.3
%TM2.P := 3450
Others possible uses of function blocks Irrespective of the type of function block used, its input must be linked to the left power rail, either directly or via other graphic elements. Outputs left open : it is not necessary to link the outputs of function blocks to other graphic elements. Testable outputs : the outputs of function blocks are accessible to the user in the form of bit objects :
%TM12.Q %C5.E
%Q4.12
Internal variables of blocks and graphic outputs can be used remotely from another part of the program.
___________________________________________________________________________ 2/10
A
Ladder language
2.3 Rules for executing rungs 2
2.3-1 Principle for executing a rung Rungs are executed rung by rung, and each rung is executed from left to right. A rung contains graphic elements which are interconnected by horizontal and vertical links (apart from the power rail), but are independent from other graphic elements in the rung (no vertical links to the top or bottom edges of the rung).
%M8
%Q2.5
Rung 1
Rung 2
%M INIT
%Q2.6 %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 labelled 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/11
Elements in this rung are executed in the following order : evaluation of the rung until the 1 st vertical convergence link is found, contacts A, B and C, evaluation of the 1 st sub-rung, contact D, continued evaluation of the rung until the 2nd vertical convergence link is found, contact E, evaluation of the 2 nd sub-rung, contacts F and G, evaluation of coil H. Example of a "Boolean" rung Order of evaluation : coil 1 : INIT, %M5, %M7, %Q2.1, coil 2 : %M4, %MW2:X1,AUTO, UP_1, coil 3 : INIT, DOWN_1.
%L
A B D F G C E
H
%L
INIT %M5
%MW2:X1
%M7 %M4
AUTO
Example of rung containing blocks Order of evaluation : coil 1 : %M0, %M8, %M2, %T1, %Q2.9, coil 2 : %T1.R, %T2, %M9, operation block.
%L
%M %M2 E C %T1 D
%M9
%M8
%Q2.9
%T1.D E C
%T2 D R
%MW10 := %MW1+50
___________________________________________________________________________ 2/12
3.1
3.1-1 Principle A program written in Instruction list language is composed of a series of instructions executed sequentially by the PLC.
Each instruction is composed of an instruction code and an operand. These instructions act on : The I/O of the PLC (pushbuttons, detectors, relays, indicator lights etc). Standard control system functions (timers, counters etc). Arithmetic and logic operations and transfer operations. The internal variables of the PLC. There are two types of instruction : Test instructions which contain the conditions necessary to execute an action, eg : LD, AND, OR etc. Action instructions which validate the result following a test sequence, eg : ST, STN, R, etc.
___________________________________________________________________________ 3/1
3.1-2 Instructions Basic instructions (For further information on each instruction, see part B).
Designation Test instructions Instructions LD, LDN, LDR, LDF Equivalent functions
P N
Negation
S R
Used to jump (unconditional, conditional on a Boolean result at 1 or conditional on a Boolean result at 0) to a labelled instruction, either upstream or downstream. Used to jump to the beginning of a subroutine. Subroutine return (unconditional, conditional on a Boolean result at 1 or conditional on a Boolean result at 0). End of program (unconditional, conditional on a Boolean result at 1 or conditional on a Boolean result at 0). Execution of the program is stopped.
HALT
___________________________________________________________________________ 3/2
A
Instruction list language
3
Result at 1 when %MW10<1000. Perform arithmetic, logic operations etc. Use Structured text language syntax (see part B). The result of the operation %MW0+100 is placed in internal word %MW10.
___________________________________________________________________________ 3/3
3.2
Program structure
3.2-1 General Like Ladder language, instructions are organized into sequences of instructions (equivalent to a rung), called a sequence. Each sequence is composed of one or more test instructions. The result of these instructions is applied to one or more action instructions. An instruction occupies up to one line. Each sequence starts with an exclamation mark (generated automatically). It can include a comment and be identified by a label. ! (*Waiting for drying*) %L2: LD %I0.1 AND %M10 ST %Q2.5
3.2-2 Comments Comments can be integrated at the beginning of a sequence and can occupy up to 3 lines (ie. 222 alphanumeric characters), framed at either end by the characters (* and *). They facilitate interpretation of the sequence to which they are assigned but are not compulsory. Comments are displayed only from the first line of the sequence. If a sequence is deleted, its associated comment is also deleted. Comments are stored in the PLC and can be accessed at all times by the user. They therefore use program memory.
3.2-3 Labels Labels are used to identify a sequence in a program entity (main program, subroutine, etc) but are not compulsory. Labels take the syntax %Li (where i is 0 to 999) and are located at the beginning of a sequence. A label can only be assigned to a single sequence within the same program entity. However, a sequence must be labelled to achieve a connection following a program jump. The system scans the sequences in the order in which they were entered, irrespective of the order of the label numbers. ___________________________________________________________________________ 3/4
A
Instruction list language
3
3.2-4 Using parentheses It is possible to use parentheses with the instructions AND and OR. These parentheses are used for simple creation of Ladder diagrams. An opening parenthesis is associated with the instruction AND or OR. A closing parenthesis represents an instruction and is compulsory for each opening parenthesis. Example : AND(
%I1.0 %I1.1 %I1.2 %Q2.0
LD AND OR ST LD AND( OR ) ST
%I1.0
%I1.1 %I1.2
%Q2.0
Example : OR(
%I1.0 %I1.1 %I1.2 %I1.3 %Q2.0
The following modifiers can be associated with parentheses : N negation, eg : AND(N or OR(N F Falling edge, eg : AND(F or OR(F R Rising edge, eg : AND (R or OR (R [ comparison
%I1.0 %I1.1 %I1.3 %MW0>100 %Q2.0
___________________________________________________________________________ 3/5
%Q2.0
Example
%I1.1 %I1.21 %I1.3 %I1.5 %I1.6 %I1.7 %I1.8 %I1.4 %Q2.0
%Q2.0
Note : Each opening parenthesis must be followed by a closing parenthesis. The labels %Li: must not be placed in expressions between parentheses. This also applies to jump instructions, JMP, and call subroutine instructions, SRi. Assignment instructions, ST, STN, S and R must not be programmed between parentheses.
___________________________________________________________________________ 3/6
A
Instruction list language
3
3.2-5 MPS, MRD and MPP instructions These three types of instruction are used to process the routing to the coils. They use a buffer known as a stack which is capable of storing up to 3 Boolean data bits. The instruction MPS (Memory PuSh) stores the result of the last test instruction at the top of the stack and shifts the other values towards the bottom of the stack. The instruction MRD (Memory ReaD) reads the top of the stack. The instruction MPP (Memory PoP) reads and retrieves the top of the stack, and shifts the other values towards the top of the stack.
Examples :
%I1.0 %M0 MPS %I1.1 %I1.2 %Q2.0 %Q2.1
MRD MPP
%I1.3 %I1.4
%Q2.2 %Q2.3
%I1.0 %M0 %I1.1 %Q2.0 %I1.2 %Q2.1 %I1.3 %Q2.2 %I1.4 %Q2.3
%I1.3 %M0
%M0
LD MPS AND MPS AND( OR ) ST MPP AND ST MRD AND ST MPP AND ST
%I1.0 %I1.1
___________________________________________________________________________ 3/7
%I1.0 %I1.1
%I1.3
%Q2.0
3.2-6 Principles for programming predefined function blocks Control system function blocks can be programmed in two different ways : with instructions specific to each function block (eg : CU %Ci). This is the simplest and most direct way. with block structure instructions BLK,OUT_BLK and END_BLK.
%CI R E
LD R LDN ANDN CU LD ST
The instructions control the inputs of the blocks (eg : CU). The outputs can be accessed in the form of bits (eg : %C8.D). Principle of structured programming This type of programming uses a sequence of instructions framed by the following instructions : BLK indicates the start of the block. OUT_BLK is used to directly wire the outputs of the block. END_BLK indicates the end of the block.
%I1.1 R %I1.2 %M0 %C8 E %Q2.0
BLK %C8 LD %I1.1 R LDN %I1.2 ANDN %M0 CU OUT_BLK LD D ST %Q2.0 END_BLK
Input processing
Output processing
Structured programming requires the additional instructions BLK, OUT_BLK and END_BLK, and therefore needs more memory compared with direct programming. It should, however, be used if similarity with reversible programs for TSX 07 nano PLCs is required. ___________________________________________________________________________ 3/8
A
Instruction list language
3
3.3
Instruction list programs are executed sequentially instruction by instruction. The first instruction in a series of instructions must always be either an LD instruction or an unconditional instruction (eg : JMP). All instructions (except LD and the unconditional instructions) use the Boolean result of the preceding instruction. Example : LD %I1.1 AND %M0 OR ST Boolean result = state of bit %I1.1. Boolean result = AND of the preceding Boolean result and the state of bit %M0. %M10 Boolean result = OR of the preceding Boolean result and the state of bit %M10. %Q2.0 %Q2.0 takes the state of the preceding Boolean result.
Parentheses can be used to modify the order in which Boolean results are taken into account : Example : LD %I1.1 AND %M0 OR( AND ) Boolean result = state of bit %I1.1. Boolean result = AND of the preceding Boolean result and the state of bit %M0. %M10 Boolean result = state of bit %M10. %I1.2 Boolean result = AND of the preceding Boolean result and the state of bit %I1.2. Boolean result = OR of the preceding Boolean result and of the Boolean result of the instruction located before the instruction with parentheses. %Q2.0 %Q2.0 takes the state of the preceding Boolean result.
ST
Sequencing of instructions can be modified by the jump (JMP) and call subroutine instructions. Example : ! LD JMPC ! LD AND ST ! %L10 : LD AND .........
___________________________________________________________________________ 3/9
___________________________________________________________________________ 3/10
4.1
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 software on TSX 57 PLCs. 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, PID control, etc).
Example :
___________________________________________________________________________ 4/1
Bit tables
Description Table := Table Table := Word Word := Table Table := Double word Double word := Table COPY_BIT AND_ARX OR_ARX XOR_ARX NOT_ARX BIT_W BIT_D W_BIT D_BIT Function Assignment between two tables Assignment of a word to a table Assignment of a table to a word Assignment of a double word to a table Assignment of a table to a double word Copy a bit table to a bit table AND between two tables OR between two tables Exclusive OR between two tables Negation on a table Copy a bit table to a word table Copy a bit table to a double word table Copy a word table to a bit table Copy a double word table to a bit table
___________________________________________________________________________ 4/2
A
Structured Text language
4
} }
Integer Floating point conversion Floating point Integer conversion Conversion of 32-bit BCD number into 32-bit integer Conversion of 32-bit integer into 32-bit BCD number Conversion of 32-bit BCD number into 16-bit integer Conversion of 16-bit integer into 32-bit BCD number
___________________________________________________________________________ 4/3
} }
ASCII Binary conversion Binary ASCII conversion ASCII Floating point conversion Floating point ASCII conversion Alphanumeric comparison Position of a substring Position of first different character Length of a character string Extract a substring Insert a substring Delete a substring Concatenate two strings Replace a string Start of string End of string
___________________________________________________________________________ 4/4
A
Structured Text language
4
"Orphee" instructions
Description WSHL_RBIT, DSHL_RBIT WSHR_RBIT, DSHR_RBIT WSHRZ_C, DSHRZ_C SCOUNT Function Shift word to left, with retrieval of shifted bits Shift word to right with sign extension and retrieval of shifted bits Shift word to right, replacing with 0, with retrieval of shifted bits Up/down counting with indication of under/overflow
Program instructions
Description HALT JUMP SRi RETURN MASKEVT UNMASKEVT Function Stop program execution Jump to a label Call subroutine Return from subroutine Mask events in the PLC Unmask events in the PLC
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/5
4.2
Program structure
4.2-1 General A Structured Text program is organized into statements. Each ST statement consists of the following elements : label, comments, instructions. Each of these elements is optional, ie. it is possible to have an empty statement, a statement consisting only of comments or consisting only of a label. Each statement begins with an exclamation mark (which is generated automatically). Example : ! %L2 : (* Here is a statement with a label, comments *) SET %M0; %MW4 := %MW2 + %MW9; (* and several instructions *) %MF12 := SQRT (%MF14);
4.2-2 Comment A comment is enclosed at either end by the characters (* and *), it can be placed at any point in a statement and there is no restriction on the number of comments per statement. Its role is to facilitate the interpretation of the statement to which it is assigned, but it is not compulsory. Any characters can be used in a comment. The number of characters is restricted to 256 per comment. Nested comments are not permitted. A comment may be several lines in length. Comments are stored in the PLC and can be accessed at any moment by the user. Because of this, they consume program memory.
___________________________________________________________________________ 4/6
A
Structured Text language
4
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/7
4.2-5 Control structures There are four control structures : the conditional action IF, the conditional iterative actions WHILE and REPEAT, the repetitive action FOR. Each control structure is enclosed between key words, and it begins and ends in the same statement. It is possible to nest control structures one inside the other, regardless of their type. Control structures can be preceded or followed by any other language instruction. The conditional action IF ... END_IF; Simple form (the instruction performs an action if a condition is true).
Syntax IF condition THEN actions ; END_IF;
CONDITION
checked not checked
Operation
start of IF
ACTIONS
end of IF
Example :
___________________________________________________________________________ 4/8
A
Structured Text language
4
General form
Syntax IF condition 1 THEN action1; ELSIF condition 2 THEN action2; ELSE action3; END_IF;
checked
Operation
start of IF
CONDITION 1
not checked
ACTION 1
checked
CONDITION 2
not checked
ACTION 2
ACTION 3
end of IF
Example :
Conditions can be multiple. Each action represents a list of instructions. Several "IF" control structures can be nested. There is no restriction on the number of ELSIF instructions. There is a maximum of one ELSE part.
___________________________________________________________________________ 4/9
The conditional iterative action WHILE ... END_WHILE; The instruction performs a repetitive action as long as a condition is checked.
Syntax WHILE condition DO
CONDITION
Mode of operation
start of WHILE not checked
action; END_WHILE;
checked
ACTION
end of WHILE
Example :
The condition can be multiple. The action represents a list of instructions. The condition is tested before executing the action. If, when the condition is first evaluated, its value is false, the action is not executed. Several WHILE control structures can be nested.
___________________________________________________________________________ 4/10
A
Structured Text language
4
The conditional iterative action REPEAT ... END_REPEAT; The instruction performs a repetitive action until a condition is checked.
Syntax REPEAT action;
not checked
Mode of operation
start of REPEAT
ACTION
CONDITION
checked end of REPEAT
Example :
The condition can be multiple. The action represents a list of instructions. The condition is tested once the action has been executed. If, when the condition is first evaluated, its value is false, the action is executed once again. Several REPEAT control structures can be nested.
___________________________________________________________________________ 4/11
The repetitive action FOR ... END_FOR; The instruction performs a processing operation a certain number of times, incrementing an index by 1 on each loop.
Syntax FOR index := initial value TO final value DO action; END_FOR;
INDEX > FINAL VALUE
false true end of FOR
Operation
start of FOR
continue
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/12
A
Structured Text language
4
Loop exit instruction EXIT The EXIT key word is used to stop execution of the loop and continue at the instruction following the key word at the end of the loop. It can be used only in the actions of one of the three WHILE, REPEAT or FOR loops. It is assigned to the closest enclosing loop, ie. it does not stop the execution of all the loops which surround it. Example :
In this example, the EXIT key word is used to stop the REPEAT loop but not the WHILE loop.
___________________________________________________________________________ 4/13
4.3
A Structured Text program is executed sequentially, instruction by instruction, while respecting the control structures. In the case of arithmetic or Boolean expressions consisting of several operators, rules of priority have been defined between the various operators. Operator priority rules The table below gives the priority for evaluating a higher or lower priority expression.
Operator Parentheses Logic complement Inversion - on an operand + on an operand Multiplication Division Modulo Addition Subtraction Comparisons Comparison of equality Comparison of inequality Logic AND Boolean AND Logic exclusive OR Boolean exclusive OR Logic OR Boolean OR
Symbol (expression) NOT NOT + * / REM + <, >, <=, >= = <> AND AND XOR XOR OR OR
Priority Highest
Lowest
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/14
A
Structured Text language
4
When there is conflict between two operators of the same priority, the first operator will take precedence (evaluation is performed from left to right). Example : %MW34 * 2 REM 6 In this example, %MW34 is first multiplied by 2, then the result is used to perform the modulo. Use of parentheses Parentheses are used to modify the order in which operators are evaluated, for example to give an addition higher priority than a multiplication. Example : (%MW10 + %MW11) * %MW12 In this example, the addition will be performed before the multiplication. Parentheses can be nested; there is no limit to the levels of nesting. Parentheses can also be used to avoid incorrect interpretation of the program. Example : NOT %MW2 <> %MW4 + %MW6 By using operator priority rules, the following interpretation is obtained : ((NOT %MW2) <> (%MW4 + %MW6)) The user might well try to perform the following operation : NOT (%MW2 <> (%MW4 + %MW6)) This example shows that parentheses can be used to clarify the program.
___________________________________________________________________________ 4/15
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 :
Left operand type Word Word Double word Double word Right operand type Word Double word Word Double word Right operand conversion No Word Double word No
Note : Any operation between two immediately adjacent values is performed in double length.
___________________________________________________________________________ 4/16
5.1
5.1-1 Reminder of principles of Grafcet Grafcet language complies with "Sequential Function Chart" (SFC) language found in IEC 1131-3 standard. Grafcet is used to represent the operation of a sequential control system in a graphic and structured way. This graphic description of the sequential operation of the control system, and the various situations which occur, is performed using simple graphic symbols :
Initial step : defines the initial situation of the PLC. Transition : the associated transition conditions indicate the logic conditions necessary for clearing this transition. Simultaneous activation of steps 3 and 7 (AND divergence). The step sequences 3, 4, 5, 6 and 7, 8, 9 constitute two sequences known as simultaneous. Sequence selection (OR divergence) from step 3 to step 4 or step 5. End of sequence selection (OR convergence) from step 4 or step 5 to step 6.
Actions
Actions
Actions
Actions
End of sequence step : enables synchronization of the simultaneous sequences. Simultaneous deactivation of steps 6 and 9 (AND convergence). Step : the associated actions are only executed while this step is active.
10
Actions
___________________________________________________________________________ 5/1
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 operative part (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-2 Graphic symbols specific to Grafcet language
Designation Initial steps Symbol or i ou i Functions Indicate the initial steps active at the start of a cycle after an initialization or a cold restart. Indicate that the control system is in a stable state. The maximum number of steps can be configured : - from 1 to 96 for a TSX 37-10, - from 1 to 128 for a TSX 37-20 or TSX 57. The maximum number of simultaneously active steps can be configured. Used to change from one step to another. A transition condition associated with this transition is used to define the logic conditions required to clear this transition. The maximum number of transitions can be configured : - from 1 to 96 for a TSX 37-10, - from 1 to 128 for a TSX 37-20 or TSX 57. The maximum number of simultaneously validated transitions can be configured. Transition from one step to several steps. Used to activate a maximum of 11 steps simultaneously. Transition from several steps to one step. Used to deactivate a maximum of 11 steps simultaneously. Transition from one step to several steps. Used to perform a sequence selection to a maximum of 11 steps. Transition from several steps to one step. Used to end a sequence selection from a maximum of 11 steps.
Single steps
or i ou i
Transitions
AND divergences
AND convergences
OR divergences
OR convergences
___________________________________________________________________________ 5/2
A
Grafcet language
5
Symbol
Functions 'n' is the number of the step from which control has come (source step). 'n' is the number of the step to which control is going (destination step).
Destination connector
n
Directed links : upwards downwards to the right or left These links are used for sequence selection, to jump over one or more steps, to repeat steps (sequence).
___________________________________________________________________________ 5/3
5.1-3 Objects specific to Grafcet The user has available to him object bits associated with steps, system bits specific to Grafcet language, word objects indicating the activity time of steps and system words specific to Grafcet language.
Designation Step bits Grafcet system bits (1) Address %Xi %S21 %S22 %S23 %S26 Description State of step i of the main Grafcet chart (i from 0 to n) (n depends on the processor) Initializes the Grafcet chart Resets all Grafcet charts to zero Freezes the Grafcet chart Set to 1 on : - table overflow (steps/transition), - execution of an incorrect chart (destination connector on a step which does not belong to the chart). Active time of step i of main Grafcet chart Word indicating, for the current cycle, the number of active steps, to be activated and deactivated. Word indicating, for the current cycle, the number of validated transitions, to be validated or devalidated.
%Xi.T %SW20
%SW21
Step bits %Xi 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 (presetting of charts). These tests and actions are programmed in Ladder language, Instruction list language, or Structured text language. These bits cannot be indexed. Step active time words %Xi.T These are incremented every 100 ms and have a value from 0 to 9999. Word incrementation : during the activity of the associated step. On deactivation of the step, the contents are frozen. On activation of the step, the contents are reset then incremented. The number of active time words cannot be configured, one word is reserved for each step. These words cannot be indexed.
___________________________________________________________________________ 5/4
A
Grafcet language
5
5.1-4 Grafcet chart representation The main chart can be programmed on 8 pages (pages 0 to 7). Each Grafcet page has 14 lines and 11 columns defining 154 cells. One graphic element can be entered in each cell.
Write rules The first line is used to enter source connectors. The last line is used to enter destination connectors. The even lines (from 2 to 12) are step lines (for steps and destination connectors). The odd lines (from 3 to 13) are transition lines (for transitions and source connectors). Each step is numbered (from 0 to 127) in any order. Several charts can be represented on a single page.
___________________________________________________________________________ 5/1
The number of transitions upstream of an end of sequence selection (OR convergence) or downstream of a sequence selection (OR divergence) must not exceed 11. A sequence selection can be directed to the left or right. A sequence selection must, in general, conclude with an end of sequence selection. To avoid clearing several transitions simultaneously, the associated transition conditions must be exclusive.
The number of steps downstream of a simultaneous activation (AND divergence) or upstream of a simultaneous deactivation (AND convergence) must not exceed 11. A simultaneous activation of steps must, in general, conclude with a simultaneous deactivation of steps. Simultaneous activation is always represented from left to right. Simultaneous deactivation is always represented from right to left.
___________________________________________________________________________ 5/2
A
Grafcet language
5
The use of connectors The purpose of connectors is to ensure the continuity of a Grafcet chart when the directed link, either on one page or between two consecutive pages, cannot be drawn. This continuity is provided by a destination connector which always has a corresponding source connector. A chart can be looped-back using connectors (for example, looping from step 18 to step 0). A sequence can be restarted using connectors (for example, step 10 to step 1 or step 8 to step 2). Connectors are used when a chart branch is longer than the page (for example, step 9 to step 10).
___________________________________________________________________________ 5/3
Connectors for sequence selection and end of sequence selection For a sequence selection, the transitions and the destination connectors must be entered in the same page. Page 1 For an end of sequence selection, the source connectors must be entered in the same page as the destination step. Page 2
For an end of sequence selection followed by a destination connector, there must be the same number of source connectors as steps before the end of sequence selection.
Page 1 Page 2
___________________________________________________________________________ 5/4
A
Grafcet language
5
Connectors for simultaneous activation and deactivation of steps For simultaneous activation of steps, the destination connectors must be on the same page as the step and the divergence transition. Page 2 Page 3
For simultaneous deactivation, the steps and convergence transition must be on the same page as the destination connector. When several steps converge on a single transition, the source connector has the number of the upstream step furthest left. Page 4 Page 5
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 , being different kinds, - meet , being the same kind. A link cannot be crossed by a simultaneous step activation or deactivation.
___________________________________________________________________________ 5/5
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/6
A
Grafcet language
5
5.1-5 Actions associated with steps Each step has associated actions which can be programmed in Ladder, Instruction list, or Structured text language. These actions are only scanned if the step with which they are associated is active. PL7 software authorizes three types of action : actions on activation : actions executed once the step with which they are associated is activated. actions on deactivation : actions executed once the step with which they are associated is deactivated. continuous actions : actions executed continuously as long as the step with which they are associated is active. These three types of action can be used for each step. A single action can contain several programming elements (sequences, statements or rungs). Referencing actions These actions are referenced as follows : MAST - CHART - PAGE n %Xi x where : x = P1 Activation = N1 Continuous = P0 Deactivation n = Page number i = Step number Example : MAST - CHART - PAGE 0 %X1 P1 Action on activation of step 1 of page 0 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 postprocessing (processing performed with each scan, see section 5.2 "Organization of the master task").
___________________________________________________________________________ 5/7
Actions on activation or deactivation These actions are pulsed and are executed on a single scan. They are used to call a subroutine, increment a counter, etc. Examples : Calling a subroutine :
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/8
A
Grafcet language
5
Timed conditional action This is a special case, in which the time is a logic condition. This link can be performed simply by testing the active time associated with the step. Example : Bit %M12 is controlled as long as the active time of step 3 is less than 10 seconds (time base : 100 ms).
These actions can also be unconditional. Order of execution of the actions In the example below, on one scan, the order of execution of the actions is as follows : When step 51 is activated, the actions are executed in the following order : 1. actions on deactivation of step 50, 2. actions on activation of step 51, 3. continuous actions of step 51.
50
Activation %X50
Continue %X50
Deactivation %X50
51
Activation %X51
Continue %X51
Deactivation %X51
When step 51 is deactivated, the associated continuous actions are no longer scanned.
___________________________________________________________________________ 5/9
5.1-6 Conditions associated with transitions Each transition has an associated condition which can be programmed in Ladder, Instruction list or Structured text language. A transition condition is only scanned when the transition with which it is associated is validated. A transition condition corresponds to a rung, a list of instructions or a Structured text statement, comprising a series of tests on bits and/or words. A transition condition which is not programmed is always a false transition condition. Referencing the transition conditions The transition conditions are referenced as follows : MAST - CHART - PAGE n %X(i) % X(j) where : n = Page number i = Upstream step number j = Downstream step number Example : MAST - CHART - PAGE 0 %X(0) %X(1) Transition condition associated with step 0 and step 1 of page 0 of the chart. During simultaneous step activation or deactivation, the address indicated is that in the column furthest to the left. Rules for programming in Ladder language The condition associated with the transition is programmed in the form of a rung comprising a test zone and an action zone. The structure of the rung is the same as that of a rung programmed in a program module. Only the following elements can be used : graphic test elements : contacts (%Mi, %I, %Q, %TMi.D, etc), comparison blocks, graphic action elements : transition condition coil only (the other coils are not significant in this case).
___________________________________________________________________________ 5/10
A
Grafcet language
5
Rules for programming in Instruction list language The transition condition is programmed in the form of a list of instructions containing only test instructions. The list of instructions for writing a transition condition differs from a standard list of instructions as follows : general structure : - no label (%L). list of instructions : - no action instructions (bit objects, words or function blocks), - no jumping, calling subroutines.
Rules for programming in Structured text language The transition condition is programmed in the form of a Boolean expression or an arithmetic expression or a combination of the two. The expression for writing a transition condition differs from a Structured text language programming line in : general structure : - no label (%L), - no action statement, conditional statement or iterative statement. list of instructions : - no action on bit object, - no jumping, calling subroutines, - no transfer, no action instruction on blocks.
___________________________________________________________________________ 5/11
Transition condition using the active time of a step In certain applications, actions are controlled with no monitoring of feedback data (end of travel, detector, etc). The duration of the step is conditioned by a time : PL7 language enables the active time associated with each step to be used. Example : If the user wishes to remain in step 3 for 15 seconds, the condition for transition between step 3 and step 4 will be (for example in structured text language) :
___________________________________________________________________________ 5/12
A
Grafcet language
5
5.2
5.2-1 Description of the master task A program written in Grafcet language has three consecutive processing sections : preprocessing, sequential processing and post-processing. They are scanned in accordance with the basic scan cycle below : Period (in periodic scanning) : Time between two tasks scans, defined by configuration.
Period Priode
In cyclical scanning, inputs are read after updating outputs. Reading inputs : Reading the physical states of the PLC input modules (values frozen during processing). Preprocessing : Used to process : initializations on power failure or return, the presetting of the Grafcet chart, the input logic. Sequential processing : Used to process the sequential structure of the application and provides access to the processing of transition conditions and actions directly associated with steps. Post-processing : Used to process : the output logic, the monitoring and safety interlocks specific to outputs. Updating of outputs : Updating the physical state of the PLC output modules (values frozen during processing). Effect of multi-task processing :
(1)
Traitement Prliminaire Langage littral Ladder, Instruction ou list or Structured text Langage contacts language
Preprocessing
Grafcet
Traitement Postrieur Langage littral Ladder, Instruction ou list or Structured text Langage contacts language
Post-processing
This structure remains the same, whether processing is multi-task or single task.
___________________________________________________________________________ 5/13
5.2-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 presetting 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 by Set and Reset instructions). Presetting the Grafcet chart It may be necessary to preset a Grafcet chart when changing from normal operation to a specific mode of operation or on the occurrence of an incident (example : fault causing degraded operation). This operation affects the normal operation of the application scan, and should therefore be used with caution. Presetting can be applied to all or part of sequential processing : by using the SET, RESET instructions, by a general reset (%S22) then, in the next scan, setting the steps to 1.
Note : When resetting a step to zero, actions on deactivation of this step are not executed.
___________________________________________________________________________ 5/14
A
Grafcet language
5
5.2-3 The use of system bits in preprocessing As the system bits associated with the Grafcet chart are numbered in order of priority (%S21 to %S23), when several of them are simultaneously set to 1 in preprocessing, they are processed one by one in ascending order (only one is effective per scan cycle). These bits are effective at the start of sequential processing. Initializing the Grafcet chart : %S21 Normally at 0, setting %S21 to 1 causes : the deactivation of the active steps, the activation of the initial steps.
Set to 1 By setting %S0 to 1 By the user program By the terminal (1) Reset to 0 By the system at the start of sequential processing By the user program By the terminal
Use When managed by the user program, %S21 must be set to 0 or 1 in preprocessing. Resetting the Grafcet chart to zero : %S22 Normally at 0, setting %S22 to 1 causes the deactivation of the active steps of all sequential processing.
Set to 1 By the user program By the terminal (1) Reset to 0 By the system at the end of 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 an initialization or Grafcet chart preset procedure. (1) In the CPU debug screen (Grafcet part) or in the animation table
___________________________________________________________________________ 5/15
Freezing the Grafcet chart : %S23 Normally at 0, setting %S23 to 1 maintains the state of the Grafcet charts. Irrespective of the value of the transition conditions downstream of the active steps, the Grafcet charts do not change. This frozen state is maintained as long as bit %S23 is at 1.
Set to 1 By the user program By the terminal (1) Set to 0 By the user program By the terminal (1)
(1) In the CPU debug screen (Grafcet part) or in the animation table. Use - managed by the user program, this bit is set to 1 or 0 in preprocessing, - bit %S23 associated with bits %S21 and %S22 is used to freeze sequential processing at initial state or state 0. Similarly, the Grafcet chart can be preset 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 set 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/16
A
Grafcet language
5
5.2-4 Sequential processing This processing section is used to program the sequential structure of the application. Sequential processing consists of : the main chart organized into 8 pages. In the main chart, several unconnected Grafcet charts can be programmed and run simultaneously. Principle of evolution The evolution of the Grafcet chart is managed as follows : Phase 1 : 1. Evaluation of the condition of validated 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. Devalidation of the cleared transitions. 4. Validation of the transitions downstream of the new activated steps. The system updates two tables dedicated respectively to step activity and transition validity : the step activity table stores, for the current scan, the active steps, the steps to be activated and the steps to be deactivated, the transition validity 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/17
Exceeding the possibilities The number of elements in the step activity table and the transition validity table can be configured. Exceeding the capacity of either table causes : the PLC to stop (execution of the application stops), system bit %S26 to change to 1 (capacity of one of the two tables exceeded), the ERR indicator lamp on the PLC to flash. The system provides the user with two system words : %SW20 : word indicating, for the current scan, the number of steps active, to be activated or deactivated. %SW21 : word indicating, for the current scan, the number of transitions validated, to be validated or devalidated. In the event of a PLC blocking fault, system words %SW125 to %SW127 are used to determine the nature of the fault. %SW125 = ERR7 (hex) %SW125 = ERRE (hex) Table overflow (steps/transitions). Execution of the incorrect Grafcet chart. (problem of transition with unresolved destination connector).
%SW126 0 =0 Step n
%SW127 =0 0 64 Step table overflow Transition table overflow Incorrect execution of Gafcet
___________________________________________________________________________ 5/18
A
Grafcet language
5
5.2-5 Post-processing Entered in Ladder language, Instruction list language or Structured text language, postprocessing is scanned from top to bottom. This processing is the last executed before activation of the outputs and is used to program the output logic. Actions associated with the Grafcet chart Post-processing is used to perform the actions generated in sequential processing by integrating the operating and stop modes as well the safety interlocks specific to the action into the equation of an output. It is also used to process an output activated several times in sequential processing. As a rule, it is advisable to program actions which directly affect the process in post-processing. Example : %I2.4 %M26 %I1.0 : safety interlock for controlling output %Q4.1. : internal bit resulting from the input logic controlling the operating and stop modes. : push-button.
___________________________________________________________________________ 5/19
Actions independent of the Grafcet chart Post-processing is also used to program the outputs which are independent of sequential processing. Monitoring the execution of the Grafcet chart In certain circumstances, it may be necessary to monitor the operation of the Grafcet chart by testing the active time of certain steps. This time is tested by comparing with either a minimum value or a maximum value defined by the user. The use made of the fault indication is at the user's discretion (indication, special operating procedure, transmission of a message). Example : ! IF (%X2.T > 100 AND %X2) THEN SET %Q4.0 ; END_IF ;
___________________________________________________________________________ 5/24
___________________________________________________________________________
Contents Part B
Section 1 Description of basic instructions 1.1 Presentation of basic instructions 1.1-1 General Boolean instructions 1.2-1 Presentation of Boolean instructions 1.2-2 Instruction format 1.2-3 Load instructions 1.2-4 Assignment instructions 1.2-5 Logic AND instructions 1.2-6 Logic OR instructions 1.2-7 Exclusive OR instructions Predefined function blocks 1.3-1 Programming principles for predefined function blocks 1.3-2 Timer function block %TMi 1.3-3 Up/down counter function block %Ci Numerical processing on integers 1.4-1 General 1.4-2 Comparison instructions 1.4-3 Assignment instructions 1.4-4 Arithmetic instructions on integers 1.4-5 Logic instructions 1.4-6 Numerical expressions Program instructions 1.5-1 Subroutine call 1.5-2 Subroutine return 1.5-3 Program jumps 1.5-4 Program end instructions 1.5-5 Stop program 1.5-6 Event masking/unmasking instructions 1.5-7 NOP Instruction
Page 1/1 1/1 1/1 1/2 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/9 1/10 1/14 1/17 1/17 1/19 1/20 1/23 1/25 1/27 1/28 1/28 1/29 1/30 1/32 1/33 1/34 1/34
1.2
1.3
1.4
1.5
___________________________________________________________________________ B / 1
___________________________________________________________________________
Contents Part B
Section 2 Description of advanced instructions 2.1 Presentation of advanced instructions 2.1-1 General Advanced predefined function blocks 2.2-1 Monostable function block %MNi 2.2-2 Register function block %Ri 2.2-3 Drum controller function block %DRi 2.2-4 Timer function block %Ti (Series 7) Vertical comparison blocks Shift instructions Floating point instructions 2.5-1 General 2.5-2 Floating point comparison instructions 2.5-3 Floating point assignment instructions 2.5-4 Floating point arithmetic instructions Numeric conversion instructions 2.6-1 BCD <--> Binary conversion instructions 2.6-2 Integer <--> Floating point conversion instructions 2.6-3 Gray --> Integer conversion instructions
Page 2/1 2/1 2/1 2/2 2/2 2/5 2/9 2/13 2/17 2/19 2/20 2/20 2/21 2/22 2/22 2/24 2/24 2/26 2/28
2.2
2.6
Word table instructions 2/29 2.7-1 General 2/29 2.7-2 Word table assignment 2/30 2.7-3 Arithmetic instructions on tables 2/32 2.7-4 Logic instructions on tables 2/33 2.7-5 Summing function on tables 2/34 2.7-6 Table comparison function 2/35 2.7-7 Find functions on tables 2/36 2.7-8 Find maximum and minimum values function on tables 2/38 2.7-9 Number of occurrences of a value in a table 2/39 2.7-10 Rotate shift function on tables 2/40 2.7-11 Sort function on tables 2/41 ___________________________________________________________________________ B / 2
2.7
___________________________________________________________________________
Contents Part B
Section 2.8 Character string instructions 2.8-1 Format of a string or table of characters 2.8-2 Character string assignment 2.8-3 Alphanumeric comparisons 2.8-4 Numeric <---> ASCII conversion functions 2.8-5 Binary --->ASCII conversion 2.8-6 ASCII ---> Binary conversion 2.8-7 Floating point ---> ASCII conversion 2.8-8 ASCII --> Floating point conversion 2.8-9 Concatenation of two strings 2.8-10 Deletion of a character substring 2.8-11 Insertion of a character substring 2.8-12 Replacement of a character substring 2.8-13 Extraction of a character substring 2.8-14 Extraction of characters 2.8-15 Comparison of two character strings 2.8-16 Search for a character substring 2.8-17 Length of a character string Time management instructions : Date, Time of day, Duration 2.9-1 Parameter format 2.9-2 Use of system bits and words - General 2.9-3 Read system date 2.9-4 Update system date 2.9-5 Read date and stop code 2.9-6 Read day of the week 2.9-7 Add / Remove a duration at a date 2.9-8 Add / Remove a duration at a time of day 2.9-9 Difference between two dates (no time) 2.9-10 Difference between two dates (with time) 2.9-11 Difference between two times 2.9-12 Convert a Date to a character string 2.9-13 Convert a complete Date to a character string 2.9-14 Convert a Duration to a character string 2.9-15 Convert a Time of day to a character string 2.9-16 Convert a Duration to HHHH:MM:SS
Page 2/42 2/42 2/43 2/44 2/45 2/45 2/47 2/48 2/49 2/50 2/51 2/52 2/54 2/56 2/58 2/60 2/61 2/62 2/63 2/63 2/65 2/66 2/66 2/67 2/68 2/69 2/70 2/72 2/73 2/74 2/75 2/76 2/77 2/78 2/80
2.9
___________________________________________________________________________ B / 3
___________________________________________________________________________
Contents Part B
Section 2.10 Bit table instructions 2.10-1 Copy one bit table to another bit table 2.10-2 Bit table logic instructions 2.10-3 Copy from a bit table to a word table 2.10-4 Copy from a word table to a bit table 2.11 "Orphee" functions : shift, counter 2.11-1 Shifts on words with retrieval of shifted bits 2.11-2 Up/down counting with indication of over/underflow 3 System bits and words 3.1 System bits 3.1-1 List of system bits 3.1-2 Detailed description of system bits System words 3.2-1 List of system words 3.2-2 Detailed description of system words
Page 2/81 2/81 2/82 2/83 2/85 2/87 2/87 2/90 3/1 3/1 3/1 3/3 3/8 3/8 3/9 4/1 4/1
3.2
4 Differences between PL7-2/3 and PL7-Micro/Junior 4.1 Differences between PL7-2/3 and PL7-Micro/Junior
5/1 5/1
___________________________________________________________________________ B / 4
___________________________________________________________________________
Contents Part B
Section 6 Conformity to the IEC standard 1131-3 6.1 Conformity to the IEC 1131-3 standard 6.1-1 Conformity tables
8/1 8/1
8.2
TSX 37 performance 8.2-1 Boolean instructions 8.2-2 Function blocks 8.2-3 Integer and floating point arithmetic 8.2-4 Program instructions 8.2-5 Command structure 8.2-6 Numeric conversions 8.2-7 Bit string 8.2-8 Word, double word and floating point tables 8.2-9 Time management 8.2-10 Character strings 8.2-11 Application-specific functions and Orphee function 8.2-12 Explicit I/O
8/3 8/3 8/4 8/6 8/8 8/8 8/9 8/9 8/11 8/14 8/15 8/16 8/17
___________________________________________________________________________ B / 5
___________________________________________________________________________
Contents Part B
Section
Page
8.3
TSX 57 performance 8.3-1 Boolean instructions 8.3-2 Function blocks 8.3-3 Integer and floating point arithmetic 8.3-4 Program instructions 8.3-5 Command structure 8.3-6 Numeric conversions 8.3-7 Bit string 8.3-8 Word, double word and floating piont tables 8.3-9 Time management 8.3-10 Character strings 8.3-11 Application-specific functions and Orphee function 8.3-12 Explicit I/O Size of the application 8.4-1 Description of the memory zones 8.4-2 Memory size of PL7 objects 8.4-3 Module memory size 8.4-4 Memory size of advanced functions
8/18 8/18 8/19 8/21 8/23 8/23 8/24 8/24 8/26 8/29 8/30 8/31 8/32 8/34 8/34 8/35 8/35 8/39
8.4
8.5 9 Index
8/44 9/1
___________________________________________________________________________ B / 6
1.1
1.1-1 General The instructions described in this section comply with the main basic instructions defined in IEC standard 1131.3. These instructions always produce the same effect, irrespective of the language used. Only their presentation in the program changes. Example of a Boolean equation : In Instruction list language : LD %I1.0 ST %Q2.0
%I1.0 %Q2.O
In Ladder language
In Structured text language :%Q2.0 := %I1.0 ; These three Boolean equations are equivalent. Bit object %Q2.0 takes the value (assignment instruction) of bit object %1.0 (load instruction). Basic instructions include : Boolean instructions (processing on bits), Predefined control system timer and counter function blocks, Numerical instructions on integers (processing on words and double words), Program instructions. The other instructions are described in section 2, "Description of advanced instructions".
___________________________________________________________________________ 1/1
B
1.2 Boolean instructions
1.2-1 Presentation of Boolean instructions Boolean instructions act on all bit type data (I/O bits, internal bits etc). Test elements, example : N/O contact. Contact closed when the bit object which controls it is at state 1.
%I1.0
LD %I1.0
%I1.0
Action elements, example : direct coil. The associated bit object takes the logic value of the logic result of the test element.
%Q2.0
ST %Q2.0
%Q2.0 :=
Boolean equation : The Boolean result of the test elements is applied to the action element. LD %I1.0 AND %I1.1 ST %Q2.0
%I1.0 %I1.1 %Q2.0
Rising and falling edges Test instructions can be used to detect rising or falling edges on PLC I/O bits or internal bits. Rising edge sensing contact : LDR %I1.0
%I1.0 P
RE %I1.0
FE %I1.0
For all inputs (discrete, counter, etc) : an edge is detected when the state of the bit has changed between scan n-1 and the current scan n. It remains detected during the current scan (see part A, section 1.3-2). Rising edge : detects a change of the controlling input from 0 to 1.
time
%I1.0
%I1.0
Boolean result
Boolean result
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
B
1.2-2 Instruction format Boolean instructions are described in the following way : The instruction described appears in bold type. Each equation is illustrated using the different languages. Load instructions These instructions correspond to : N/O contacts : contact closed when the bit object which controls it is at state 1. ... Ladder language
%I1.1 %M0 %Q2.3 %Q2.2
Authorized operands
Code LD Operand %I,%Q,%M,%S,%BLK,%:Xk, %Xi
Timing diagram
LD
LDN
%Q2.3
%Q2.2
List of operands 0/1 immediate value 0 (false) or 1 (true) %I PLC input %Ix.i %Q PLC output %Qx.i %M internal bit %Mi %S system bit %Si %BLK function block bit, eg : %TMi.Q %:Xk word extract bit, eg : %MWi:Xk %Xi step bit
Timing diagram The 4 timing diagrams have been grouped together. Timing diagram for LD the LD instruction Input state
%I1.1
Output state
%Q2.3
___________________________________________________________________________ 1/3
B
1.2-3 Load instructions These instructions correspond to : N/O contacts : contact closed when the bit object which controls it is at 1. N/C contacts : contact closed when the bit object which controls it is at 0. Rising edge contacts : detects a change of the controlling bit from 0 to 1. Falling edge contacts : detects a change of the controlling bit from 1 to 0. Ladder language
%I1.1 %M0 %Q2.3 %Q2.2
%I1.2 P %I1.3 N
%Q2.4 %Q2.5
Authorized operands
Code LD Operand %I,%Q,%M,%S,%BLK,%:Xk, %Xi (1)
Timing diagram
P N
LD
LDN
LDR
LDF
%I1.1
%M0
%I1.2
%I1.3
%Q2.3
%Q2.2
___________________________________________________________________________ 1/4
B
1.2-4 Assignment instructions These instructions correspond to : Direct coils : the associated bit object takes the value of the result of the equation. Negated coils : the associated bit object takes the inverse value of the result of the equation. Set (latch) coils : the associated bit object is set to 1 when the result of the equation is at 1. Reset (unlatch) coils : the associated bit object is set to 0 when the result of the equation is at 1. Ladder language
%I1.1 %Q2.3 %Q2.2
S LD R
%I1.2
Authorized operands
Code ST Operand %I,%Q,%M,%S,%:Xk
Timing diagram
S R
STN %I,%Q,%M,%S,%:Xk
S R
ST
STN
S R
___________________________________________________________________________ 1/5
B
1.2-5 Logic AND instructions These instructions perform : A logic AND between the operand and the Boolean result of the preceding instruction. A logic AND between the inverse of the operand and the Boolean result of the preceding instruction. A logic AND between the rising edge of the operand and the Boolean result of the preceding instruction. A logic AND between the falling edge of the operand and the Boolean result of the preceding instruction. Ladder language
%I1.1 %M1 %M2 %I1.2 %Q2.3 %Q2.2
%Q2.4 %Q2.5
Note : The parentheses are optional but make the program easier to read.
Authorized operands
Code
AND
Timing diagram
P N
Operand
%I,%Q,%M,%S,%BLK,%:Xk, %Xi (1)
___________________________________________________________________________ 1/6
B
1.2-6 Logic OR instructions These instructions perform : A logic OR between the operand and the Boolean result of the preceding instruction. A logic OR between the inverse of the operand and the Boolean result of the preceding instruction. A logic OR between the rising edge of the operand and the Boolean result of the preceding instruction. A logic OR between the falling edge of the operand and the Boolean result of the preceding instruction. Ladder language
%I1.1 %M1 %M2 %I1.2 %I1.3 %I1.4 P %M3 %I1.5 N %Q2.4 %Q2.2 %Q2.3
%Q2.5
Note : The parentheses are optional but make the program easier to read.
Authorized operands
Code OR Operand %I,%Q,%M,%S,%BLK,%:Xk, %Xi (1)
Timing diagram
P N
OR %I1.1 %M1
ORF %I,%Q,%M
N
%Q2.3 %Q2.2 %Q2.4 %Q2.5 (1) True (1)/False (0) in Instruction list or Structured text language ___________________________________________________________________________
1/7
B
1.2-7 Exclusive OR instructions These instructions perform : An exclusive OR between the operand and the Boolean result of the preceding instruction. An exclusive OR between the inverse of the operand and the Boolean result of the preceding instruction. An exclusive OR between the rising edge of the operand and the Boolean result of the preceding instruction. An exclusive OR between the falling edge of the operand and the Boolean result of the preceding instruction.
Note : There are no specific graphic elements for the exclusive OR in Ladder language. However, the exclusive OR can be programmed by using a combination of N/O and N/C contacts (see example below).
Note : The parentheses are optional but make the program easier to read.
Authorized operands
Code XOR XORN XORR XORF Operand %I,%Q,%M,%S,%BLK,%:Xk, %Xi %I,%Q,%M,%S,%BLK,%:Xk, %Xi %I,%Q,%M %I,%Q,%M
Timing diagram
XOR %I1.1 %M1 %Q2.3 XORN %M2 %I1.2 %Q2.2 XORR %I1.3 %I1.4 %Q2.4 XORF %M3 %I1.5 %Q2.5
___________________________________________________________________________ 1/8
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 pre-programmed in the PLC and therefore occupy a particular zone of the user memory. In order to optimize memory occupation, the type and number of function blocks used must be defined at the outset, within the limits imposed by the system (via the Configuration and Data editors).
%CI R E
(1) The total number of %TMi + %Ti timers must be less than or equal to 64 on the TSX 37 and less than or equal to 255 on the TSX 57.
Each block contains : Inputs (eg : IN) which are used to control it. Outputs (eg : Q) which indicate its state. Each output has an associated output bit (eg : %TM1.Q) which can be tested by the user program. In addition, each output can control one or more coils (eg : %Q2.3 and SR2). Parameters which are used to adapt it to the application (preset, time base etc).
%I1.1 IN
%TM1 Q
%Q2.3
SR2 c
The parameters of function blocks (preset, current value, etc) are displayed within the block. In Instruction list language, predefined blocks are programmed using instructions (see part A, section 3.2-6).
___________________________________________________________________________ 1/9
B
1.3-2 Timer function block %TMi Timers have three operating modes :
%TMi Q IN MODE:TON TB: 1mn TM.P:9999 MODIF:Y
Timer block
TON : this mode is used to control on-delay actions. This delay is programmable and can be modified via the terminal. TOF : this mode is used to control off-delay actions. This delay is programmable and can be modified via the terminal. TP : this mode is used to create a pulse of an exact duration. This duration is programmable and can be modified via the terminal.
Characteristics
Timer number Mode %TMi TON TOF TP TB 0 to 63 for a TSX 37, 0 to 254 for a TSX 57 on-delay (default) off-delay monostable 1min (default), 1s, 100ms, 10ms (max of 16 timers when 10ms). The smaller the time base, the greater the accuracy of the timer. Word which increments from 0 to %TMi.P when the timer is running. Can be read and tested but not written by the program (1). 0%TMi.P9999. Word which can be read, tested and written by the program. It is set to 9999 by default. The time period or delay generated is equal to %TMi.P x TB. Y : the preset value can be modified %TMi.P in adjust mode. N : no access in adjust mode. The timer starts on a rising edge (TON or TP mode) or a falling edge (TOF mode). Associated bit %TMi.Q is set to 1 depending on the function performed TON, TOF or TP.
Time base
Current value
%TMi.V
Preset value
%TMi.P
Adjust via the terminal (MODIF) Setting input (instruction) Timer output
Y/N
IN Q
___________________________________________________________________________ 1/10
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 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 long as input IN is at 1. When input IN is at 0, the timer is stopped, even if its value is still changing : %TMi.V takes the value 0.
IN
Q %TMi.P %TMi.V
Using as an off-delay timer : TOF mode The current value %TMi.V is set to 0 on a rising edge at input IN (even if the timer is still running). The timer is started on a falling edge at input IN. The current value increases to %TMi.P by one unit on each pulse of the time base TB. Output bit %TMi.Q changes to 1 when a rising edge is detected on input IN and the timer returns to 0 when the current value reaches %TMi.P.
IN
Q %TMi.P %TMi.V
Using as a monostable : TP mode The timer is started on a rising edge at input IN : (if the timer has not already started) its current value %TMi.V increases from 0 to %TMi.P by one unit on each pulse of the time base TB. Output bit %TMi.Q changes to 1 when the timer is started and returns to 0 when the current value reaches %TMi.P. When input IN and output %TMi.Q are at 0, TMi.V takes the value 0. This monostable cannot be reset.
IN
Q %TMi.P %TMi.V
___________________________________________________________________________ 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.
%I1.1 IN
%TM1 Q
%Q2.3
TON
The START %TMi instruction generates a rising edge on the timer block input IN (Mode TON and TP) or a falling edge on the timer block input IN (Mode TOF). The DOWN %TMi instruction generates a falling edge on the timer block input IN (Mode TON and TP) or a rising edge on the timer block input IN (Mode TOF).
___________________________________________________________________________ 1/12
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. These two operations can be simultaneous.
%Ci R E
Characteristics
Counter number Current value %Ci %Ci.V 0 to 31 for a TSX 37, 0 to 254 for a TSX 57 Word incremented or decremented according to inputs CU and CD. Can be read and tested but not written by the program (1). 0%Ci.P9999. Word can be read, tested and written. (default value 9999) Y : the preset value can be modified in adjust mode. N : no access in adjust mode. At state 1 : %Ci.V = 0. At state 1: %Ci.V = %Ci.P. Increments %Ci.V on a rising edge. Decrements %Ci.V on a rising edge. The associated bit %Ci.E=1 when downcounter %Ci.V changes from 0 to 9999 (set to 1 when %Ci.V reaches 9999, and reset to 0 if the counter continues to downcount).(2) The associated bit %Ci.D=1 when %Ci.V=%Ci.P. The associated bit %Ci.F =1 when %Ci.V changes from 9999 to 0 (set to 1 when %Ci.V reaches 0, and reset to 0 if the counter continues to upcount).
Preset value Adjust via terminal (MODIF) Reset input (instruction) Preset input (instruction) Upcount input (instruction) Downcount input (instruction) Underflow output
%Ci.P Y/N
R S CU CD E (Empty)
D (Done) F (Full)
(1) %Ci.V can be modified via the terminal. (2) When there is an upcount overflow or downcount underflow, bit %S18 changes to 1.
___________________________________________________________________________ 1/14
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
%I1.1 R %C8 E
%I1.2 %M0
%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
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 blocks. located in the action zone for operation blocks. These blocks can contain : a simple expression, eg : OP3:=OP1+OP2, a complex expression, eg : OP5:=(OP1+OP2)*OP3-OP4.
%I1.2
N
INC%MW100
In Instruction list language Instructions are placed between square brackets. They are executed if the Boolean result of the test instruction preceding the numerical instruction is at 1.
In Structured text language Numerical instructions are entered directly. The conditional instruction IF enables numerical instructions to be conditioned via a Boolean expression.
%Q2.2 := %MW50 > 10 ; IF %I1.0 THEN %MW10 := %KW0 + 10 ; END_IF ; IF FE %I1.2 THEN INC %MW100 ; END_IF ;
___________________________________________________________________________ 1/17
B
List of operands List of bit tables
Abbreviations Full addressing %M:L %I:L %Q:L %Xi:L %Mi:L %Ixy.i:L %Qxy.i:L %Xi:L Type of word table of internal bits table of input bits table of output bits table of step bits Access R/W R/W R/W R
(1) Write depending on i. (2) Write depending on the type of word, for example : preset values (%Ci.P can be written, whereas the current values %Ci.V can only be read).
Notes There are other types of words and double words, such as %MWxy.i %KWxy.i and %MDxy.i %KDxy.i associated with applications. These double words behave like the words and double words %MWi %KWi and %MDi %KDi respectively. Implicit conversion of words <--> double words PL7 software allows mixing of operations using words and double words. Conversion to one or other of the formats is performed implicitly. An operation involving a double word or several immediate values is automatically performed internally in double format. ___________________________________________________________________________ 1/18
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
%Q2.3 %MW10>100 %M0 %MW20<%KW35 %I1.2 %Q2.4 %Q2.2
%MW30>=%MW40
Comparison blocks are programmed in the test zone. Structured text language
%Q2.3 := %MW10 > 100 ; %Q2.2 := %M0 AND (%MW20 < %KW35) ; %Q2.4 := %I1.2 OR (%MW30 >= %MW40) ;
The comparison is executed inside square brackets following instructions LD, AND and OR.
Note : The parentheses are optional but make the program easier to read.
___________________________________________________________________________ 1/19
B
Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words Operands 1 and 2 (Op1 and Op2) %MW,%KW Immed.val.,%IW,%QW,%SW,%NW,%BLK, %Xi.T Numerical expr. %MD,%KD Immed.val.,%ID,%QD,%SD,Numerical expr.
Notes In Ladder language, comparisons can also be executed using the vertical comparison block (see part B, section 2.3). In Instruction list language, comparison instructions can be used in parentheses.
1.4-3 Assignment instructions These are used to load an Op2 operand into an Op1operand. Syntax : Op1:=Op2 <=> Op2->Op1
The following assignment operations can be performed : On bit tables On words or double words. Several assignment instructions can be linked within the same block : Op1:=Op2:=Op3:=Op4:=... Assignment of bit tables (see bit table object, section 1.2-6, part A) The following operations on bit tables can be performed : Bit table -> bit table example 1 Bit table -> word or double word (indexed) example 2 Word or double word (indexed) -> bit table example 3 Structure Ladder language
%Q2.0:8:=%M10:8 %I3.2 %MW100:=%I1.0:16 %I3.3 P %M100:16:=%KW0
example 1
example 3
___________________________________________________________________________ 1/20
B
Structured text language
%Q2.0:8 := %M10:8 ; example 1 IF %I3.2 THEN %MW100 := %I1.0:16 ; example 2 END_IF ; IF RE %I3.3 THEN %M100:16 := %KW0 ; example 3 END_IF ;
Op1:=Op2
Operand 2 (Op2) %M:L,%Q:L,%I:L, %Xi:L %MW,%KW Immed.val.,%IW,%QW,%SW %NW,%BLK, %Xi.T, Num. expr. %MD,%KD Immed.val.,%ID,%QD,%SD Num. expr.
Rules for use The source and target bit tables are not necessarily the same length. If the source table is longer than the target table, only the least significant bits will be transferred. Otherwise the target table is completed with 0s. Example of assigning a bit table -> a word (or double word) : the bits in the table are transferred into the word (the low-order word for a double word) starting from the right (first bit of the table to bit 0 of the word). The bits of the word which are not transferred (length<16 or 32) are set to 0. Example of assigning a word -> bit table : the bits of the word are transferred starting from the right (bit 0 of the word to the first bit of the table).
___________________________________________________________________________ 1/21
B
Assignment of words The following assignment operations on words can be performed : word (indexed) -> word (indexed) or double word (indexed) double word (indexed) -> double word (indexed) or word (indexed) immediate value -> word (indexed) or double word (indexed) Structure Ladder language example 1 example 2 example 3
example 3
Syntax
Operator := Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words
Op1:=Op2
Operand 2 (Op2) %MW,%KW Immed.val.,%IW,%QW,%SW %NW,%BLK,%Xi.T, Num. expr. %MD,%KD Immed.val.,%ID,%QD,%SD Numerical expr.
Note Word <--> double word conversions are performed implicitly during double word --> word assignment. If the value of the double word cannot be contained in the word, bit %S18 is set to 1. It is possible to execute multiple assignments. Example : %MW0 := %MW2 := %MW4 Note that in the example %MD14 := %MW10 := %MD12, it is not necessarily true that %MD14 := %MD12, as the higher order word of the double word will be lost when assignment to %MW10 occurs, due to the conversion from a double word to a single word.
___________________________________________________________________________ 1/22
B
1.4-4 Arithmetic instructions on integers These instructions are used to perform arithmetic operations between two operands or on one operand. + : - : * : / : REM add two operands SQRT subtract two operands INC multiply two operands DEC divide two operands ABS : remainder of division of the two operands : : : : square root of an operand increment of an operand decrement of an operand absolute value of an operand
Syntax Operators +,-,*,/,REM SQRT, ABS INC, DEC Op1:=Op2 Operator Op3 Op1:=Operator(Op2) Operator Op1
___________________________________________________________________________ 1/23
B
Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words Operand 1 (Op1) %MW %QW,%SW,%NW, %BLK %MD %QD,%SD, Operands 2 & 3 (Op2 and 3) %MW,%KW Immed.val.,%IW,%QW,%SW %NW,%BLK,%Xi.T, Num. expr. %MD,%KD Immed.val.,%ID,%QD,%SD Numerical expr.
Note : The operations INC and DEC cannot be used in numerical expressions.
Rules for use Addition : Overflow during operation If the result exceeds the limits : -32768 or +32767 for a single length operand, -2 147 483 648 or +2 147 483 647 for a double length operand, bit %S18 (overflow) is set to 1. The result is therefore not significant. The user program manages bit %S18. Example : Ladder language
%M0 %MW0:=%MW1+%MW2 %S18 %MW10:=%MW0 %S18 %MW10:=32767 %S18 R
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 ___________________________________________________________________________ 1/24
B
Multiplication : Overflow during operation. If the result exceeds the capacity of the result word, bit %S18 (overflow) is set to 1 and the result is not significant. Division/Remainder : Division by 0. If the divider is 0, division is impossible and system bit %S18 is set to 1. The result is then incorrect. Overflow during operation. Square root extraction : Square root extraction is only performed on positive values. Thus, the result is always positive. If the square root operand is negative, system bit %S18 is set to 1 and the result is incorrect.
Note : When the result of an operation is not an integer (in the case of division or square root extraction), the result is rounded down to the nearest integer. The sign of the remainder (REM) is that of the numerator. The user program is responsible for managing system bit %S18. It is set to 1 by the PLC and must be reset by the program so that it can be re-used (see previous page for example).
1.4-5 Logic instructions The associated instructions are used to perform a logic operation between two operands or on one operand. AND OR XOR NOT : : : : AND (bit-wise) between two operands Logic OR (bit-wise) between two operands Exclusive OR (bit-wise) between two operands Logic complement (bit-wise) of an operand
Instruction list language LD %M0 [%MW0 := %MW10 AND 16#FF00] LD TRUE [%MW0 := %KW5 OR %MW10]
___________________________________________________________________________ 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 ;
Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words Operand 1 (Op1) %MW %QW,%SW,%NW, %BLK %MD %QD,%SD Operands 2 & 3 (Op2 and 3) %MW,%KW Immed. val.,%IW,%QW,%SW %NW,%BLK,%Xi.T,Num. expr. %MD,%KD Immed. val.,%ID,%QD,%SD Num. expr.
___________________________________________________________________________ 1/26
B
1.4-6 Numerical expressions Numerical expressions are composed of several numerical operands and the arithmetic and logic operators described above. Example : %MW25 * 3 - SQRT(%MW10) + %KW8* (%MW15 + %MW18) AND 16#FF The number of operators and operands in an arithmetic expression is not limited. Numerical expressions on integer objects Operands in the same numerical expression can be both single or double length. Example : %MW6 * %MW15 + SQRT(%DW6) / (%MW149[%MW8]) + %KD29) AND 16#FF An operand or an operation to a single operand can be preceded by the sign + or - (by default, the sign +). Example : SQRT (%MW5) * - %MW9 All word objects can be used in arithmetic expressions. Certain words can be indexed. Execution priority of instructions In numerical expressions, priority of different instructions is observed. They are executed in the order described below : 1 -> 2 -> instruction to * an operand / REM 3 + -> 4 -> <,> <=,>= 5 = <> -> 6 -> AND 7 -> XOR 8 OR
In the example below, the instructions are executed following the order of numbering : SQRT (%MW3) + %MW5 * 7 AND %MW8 OR %MW5 XOR %MW10 1 3 4 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 5 2
___________________________________________________________________________ 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
%M8 SR10 C
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 SR 10 Call SR 10 Subroutine module SR 12
Call SR 12
Call SR 10
___________________________________________________________________________ 1/28
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
%M8 <RETURN>
LD RETC
%M8
Rule for use Subroutine return instructions are implicit at the end of each subroutine, but can be used to return to the calling module before the end of the subroutine. Example : Ladder language Instruction list language
%MW5>3 %M8
<RETURN>
%MD26:=%MW4*%KD6
Instruction list language includes the following additional instructions : RETCN : subroutine return if the Boolean result of the preceding test instruction is 0. RET : unconditional subroutine return. ___________________________________________________________________________ 1/29
B
1.5-3 Program jumps Jump instructions allow connection to a line of programming identified by a label %Li : JMP : unconditional program jump, JMPC : program jump if the Boolean result of the preceding test instruction is 1, JMPCN : program jump if the Boolean result of the preceding test instruction is 0, %Li represents the label of the line to which the connection is made (i numbered from 1 to 999 with up to 256 labels).
%L10 %M20
%M5
%I1.0
%I1.2
%Q2.1
___________________________________________________________________________ 1/30
B
Ladder language
%M2 %L20 >> %I2.0 %Q3.5
%L20 %M30
%M6
%M30 %M6
Ladder language
%L40 >> %L20 %I2.1
%Q3.5
%L40 %M20
%M20 %M5
%M5
___________________________________________________________________________ 1/31
B
Rules A program jump is performed within the same programming entity (main module of a master task (MAIN), subroutine %SRi, etc). A program jump is performed to a line of programming which is downstream or upstream. When the jump is upstream, attention must be paid to the program scan time : the program scan time is then extended and can mean the task period including the upstream jump is exceeded.
1.5-4 Program end instructions The end of the execution of a program scan is defined using the instructions END, ENDC and ENDCN : END : unconditional end of program ENDC : end of program if the Boolean result of the preceding test instruction is 1. ENDCN : end of program if the Boolean result of the preceding test instruction is 0. By default (normal mode), when the end of program is activated, the outputs are updated and the next scan is started. If scanning is periodic, the outputs are updated when the end of period is reached and the next scan is started.
Note : These instructions can only be used in Instruction list language in the master task.
If %I1.2 =1, end of program scanning. If %I1.2 =0, continues program scanning until new END instruction.
___________________________________________________________________________ 1/32
B
1.5-5 Stop program Execution of an application program can be stopped using the instruction HALT (stops all tasks). This freezes the variable objects in this program. A program stopped in this way must be initialized to restart it (using the PL7 command INIT). Any instructions following the instruction HALT will therefore not be executed. Structure Ladder language
%M10 <HALT>
___________________________________________________________________________ 1/33
B
1.5-6 Event masking/unmasking instructions Event masking/unmasking instructions are used to mask or unmask all the events which activate event-triggered tasks. MASKEVT : masks all events. The events are stored by the PLC. However, the associated event-triggered tasks remain inactive as long as the masking operation is enabled (until the next UNMASKEVT instruction). UNMASKEVT : unmasks all events. The events which were stored during the mask period are processed. The event processing mechanism is operational until the next MASKEVT instruction. Structure Ladder language
%M0 MASKEVT ( ) %M8 UNMASKEVT ( )
1.5-7 NOP Instruction The NOP instruction does not perform any operation. It is used for "reserving" lines in a program which allow the user to insert instructions later without modifying the line numbers.
___________________________________________________________________________ 1/34
2.1
2.1-1 General The instructions described in this section are suitable for advanced programming requirements. They have the same effect, irrespective of the language used. Only the syntax differs. They are : Either basic instructions of the software. Or Functions considered as extensions of the software. Extended Function type instructions are used to enhance the basic software using special programming instructions. Operations on character strings, word tables, etc. Application-specific functions : Communication, PID control, Man-Machine Interface, etc. They include the following families : Character strings. Word tables. Management of Dates, times and time periods. Conversions. Bit tables. "Orphee" functions.
==>
Notes on programming Function type instructions require additional application memory occupation (only when they are actually used in the program). This memory occupation should be taken into account by the programmer for each function, irrespective of the number used, and the maximum memory size of the PLC used must be observed.
___________________________________________________________________________ 2/1
B
2.2 Advanced predefined function blocks
2.2-1 Monostable function block %MNi The monostable function block is used to create a pulse of an exact duration. This duration is programmable and can be modified via the terminal.
%MNi S TB: 1mn MN.P:9999 MODIF:Y R
Preset value
%MNi.P
Edit via terminal MODIF Start input (or instruction) Monostable output
Y/N
S(Start) R(Running)
Operation When input S of the monostable is at 1 (rising edge), the current value %MNi.V takes the preset value %MNi.P and decreases to 0 by one unit on each pulse of the time base TB. Output bit %MNi.R (Running) assigned to output R changes to 1 when the current value %MNi.V is other than 0. When the current value %MNi.V = 0, output bit %MNi.R returns to 0. Start input S :
S %MNi.P %MNi.V R
PRESET PRESET
PRESET
B
Programming and configuration Example of use : flashing at variable cyclical periods : the preset value of each monostable defines the duration of each pulse.
%Q3.0 5s 2s 5s 2s
Configuration The following parameters must be entered in the variables editor : - TB : 1min, 1s, 100ms, 10ms or 1ms (100ms in this example). - %MNi.P : 0 to 9999 (%MN0.P=50 and %MN1.P=20 in this example). - MODIF : Y or N.
%M0:=NOT %MN1.R ; IF RE %M0 THEN START %MN0 ; END_IF ; %Q3.0 := %MN0.R ; %M1 := NOT %MN0.R ; IF RE %M1 THEN START %MN1 ; END_IF ;
In the example above, output %Q3.0 is set to 1 for 5s (%MN0.P) and reset to 0 for 2s (%MN1.P). In Structured text language, the instruction START %Mni is used to start the monostable function block. This instruction forces a rising edge on input S of the block and thus reinitializes the function block. The conditioning instruction must therefore be an edgetype. ___________________________________________________________________________ 2/3
B
Note The monostable function can also be performed by the function block %TMi in TP mode (see part B, section 1.3-2).
Special cases Effect of a cold restart : (%S0 = 1) the preset value %MNi.P is loaded into the current value %MNi.V. Since the preset value which may have been modified by the terminal is lost, output %MNi.R is reset to 0. Effect of a warm restart : (%S1) has no effect on the current value of the monostable (%MNi.V). Effect of a PLC stop, de-activation of the task and break point : a PLC stop, deactivation of the current task or execution of a break point does not freeze the current value. Effect of a program jump : the fact of not scanning the rung where the monostable block is programmed does not freeze current value %MNi.V which continues to decrease to 0. Similarly, bit %MNi.R assigned to the monostable block output continues to operate normally and can thus be tested in another rung. However, the coils directly "connected" to the block output (eg %Q3.0) will not be activated since they are not scanned by the PLC. Testing bit %MNi.R : the state of this bit can change during a scan.
___________________________________________________________________________ 2/4
B
2.2-2 Register function block %Ri A register is a memory block which is used to store up to 255 words of 16 bits in two different ways : Queue (first in, first out) known as FIFO stack (First In, First Out). Stack (last in, first out) known as LIFO stack (Last In, First Out).
%Ri R E MODE:LIFO LEN :16 F I O
Register block
Characteristics
Register number Mode Length Input word Output word Storage input (or instruction) Retrieval input (or instruction) Reset input (or instruction) Empty output Full output %Ri FIFO LIFO LEN %Ri.I %Ri.O I (In) O (Out) R (Reset) E (Empty) F (Full) 0 to 3 for a TSX 37, 0 to 254 for a TSX 57 Queue. Stack (default selection). Number of 16-bit words (1 LEN 255) in the register memory block. Register input word. Can be read, tested and written. Register output word. Can be read, tested and written. On a rising edge, stores the contents of word %Ri.I in the register. On a rising edge, loads a data word into word %Ri.O. At state 1 initializes the register. The associated bit %Ri.E indicates that the register is empty. Can be tested. The associated bit %Ri.F indicates that the register is full. Can be tested.
Note : When the two inputs I and O are activated simultaneously, storage is performed before retrieval.
___________________________________________________________________________ 2/5
B
FIFO (First In, First Out) The first data item entered is the first to be retrieved. When a storage request is received (rising edge at input I or activation of instruction I), the contents of input word %Ri.I (which have already been loaded) are stored at the top of the stack (fig a). When the stack is full (output F=1), no further storage is possible and system bit %S18 changes to 1. When a retrieval request is received (rising edge at input O or activation of instruction O) the data word lowest in the stack is loaded into output word %Ri.O and the contents of the register are moved down one place in the stack (fig.b). When the register is empty (output E=1), no further retrieval is possible. Output word %Ri.O does not change and retains its value. The stack can be reset at any time (state 1 at input R or activation of instruction R). LIFO (Last In, First Out) The last data item entered is the first to be retrieved. When a storage request is received (rising edge at the input or activation of instruction I), the contents of input word %Ri.I (which have already been loaded) are stored at the top of the stack (fig c). When the stack is full (output F=1), no further storage is possible and system bit %S18 changes to 1. When a retrieval request is received (rising edge at input O or activation of instruction O) the highest data word (last word to be entered) is loaded into output word %Ri.O (fig.d). When the register is empty (output E=1), no further retrieval is possible. Output word %Ri.O does not change and retains its last value. The stack can be reset at any time (state 1 at input R or activation of instruction R). The element indicated by the pointer is then the highest in the stack.
Example : Storage of the contents of %Ri.I at the top of the stack.
20 %Ri.I (a) 20 80 50
Retrieval of the first data item which is then loaded into %Ri.O.
20 80 50 20 80
(b) %Ri.0 50
20 %Ri.I (c) 20 80 50
%Ri.0 20 80 50 80 50 20 (b)
___________________________________________________________________________ 2/6
B
Programming and configuration Configuration The following parameters must be entered in the configuration editor : - Number : 1 to 4 for a TSX 37, 1 to 255 for a TSX 57, - Length : 1 to 255. The operating mode (FIFO or LIFO) must be entered in the variables editor. Programmation Ladder language
%R2 R %M1 I %I1.3 O %I1.3 %R2.E %MW20:=%R2.O %I1.2 %R2.F %R2.I:=%MW34 %M1 MOD : LEN : F E
The programming example shows word %MW34 being loaded into %R2.I at the storage request %I1.2, if register R2 is not full (%R2.F=0). The storage request in the register is made by %M1. The retrieval request is made by input %I1.3 and %R2.O is loaded into %MW20 if the register is not empty (%R2.E=0). ___________________________________________________________________________ 2/7
B
In Structured text language, 3 instructions are used to program the register function blocks : RESET %Ri : Initializes the register, PUT %Ri : Stores the contents of word %Ri.I in the register, GET %Ri : Loads a data word into word %Ri.O. The PUT and GET instructions create a rising edge on inputs I and O respectively of the function block. The conditioning instruction must therefore be an edge-type. Special cases Effect of a cold restart : (%S0=1) initializes the contents of the register. The Output bit %Ri.E assigned to output E is set to 1. Effect of a warm restart : (%S=1) has no effect on the contents of the register, nor on the state of its output bits. When resetting to 0 (input R or instruction R) - In Ladder language, the memorized values of inputs I and O are updated with the actual values. - In Instruction list language, the memorized values of inputs I and O are not updated. Each one retains the value it had before being called. - In Structured text language, the memorized values of inputs I and O are updated with 0.
___________________________________________________________________________ 2/8
B
2.2-3 Drum controller function block %DRi The drum controller operates on a similar principle to an electromechanical drum controller, which changes step according to external events. On each step, the high point of a cam gives an order which is executed by the control system. In the case of a drum controller, these high points are symbolized by state 1 for each step and are assigned to output bits %Qi.j or internal bits %Mi, known as control bits.
Characteristics
Number Step number Time base Time envelope or time period of current step Current step number Return to step 0 input Advanced input Output %DRi LEN TB %DRi.V 0 to 7 for a TSX 37, 0 to 254 for a TSX 57 1 to 16 (default 16). 1min, 1s, 100ms, 10ms (default 1min). 0%DRi.V9999. Word is reset on each step change. Can be read and tested but not written. The duration is equal to %DRi.V x TB. 0%DRi.S15. Word which can be read and tested. Can only be written with an immediate value. At state 1 initializes the drum controller to step 0. On a rising edge, causes the drum controller to advance by one step and updates the control bits. Indicates that the current step equals the last step defined. The associated bit %DRi.F can be tested (%DRi.F=1 if %DRi.S=configured step number - 1). 16-bit word defining the states of step j of drum controller i. Can be read and tested but not written. Outputs or internal bits associated with the step (16 control bits).
%DRi.S
R (RESET) U (UP)
F (FULL)
State of a step
%DRi.Wj
Control bits
___________________________________________________________________________ 2/9
B
Operation The drum controller comprises : A matrix of constant data (the cams) organized : - in columns : in steps from 0 to N-1 (N is the step number configured). Each column shows the states of the step in the form of 16 data bits numbered 0 to F. A list of control bits (1 per line) corresponding to either outputs %Qxy.i, or to internal bits %Mi. During the current step, the control bits take on the binary states defined for this step. The table below summarizes the main characteristics of the drum controller (controller configured with 16 steps). Step
Bit
Control bits
In the above example, for step 1, control bits %Q2.1;%Q3.5; %Q2.8;%Q3.6;%M5 and %M6 are set to state 1. The other control bits are set to 0. The current step number is incremented on each rising edge at input U (or activation of instruction U). This number can be modified by the program. Operating diagram
Input Input Step no. Output Time envelope U: R: %DRi.S %DRi.F %DRi.V 0 1 2 3 N-1 0 1 2 0 1
___________________________________________________________________________ 2/10
B
Programming and configuration In this example, the first 5 outputs %Q2.0 to %Q2.4 are activated in succession each time input %I1.1 is set to 1. Input I1.0 resets the outputs to step 0. Configuration The following information is defined in the variables editor : Step number : 5 (LEN:5). The state of the outputs (control bits) for each step of the drum controller. Step 01234 10000 01000 00100 00010 00001 Assignment of control bits %Q2.0 %Q2.1 %Q2.2 %Q2.3 %Q2.4
Bit
0: 1: 2: 3: 4:
%DR1 %TB:1 mn
U
%I1.1
LD R LD U LD ST
LEN:5
In Structured text language, 2 instructions are used to program the drum controller function blocks : RESET %DRi : Initializes the controller to step 0, UP %DRi : Advances the controller by one step and updates the control bits. This instruction creates a rising edge on input U of the function block : this conditioning instruction must therefore be an edge-type. ___________________________________________________________________________ 2/11
B
Note When resetting to 0 (input R, instruction R or RESET instruction) In Ladder language, the memorized value of input U is updated with the actual values. In Instruction list language, the memorized value of input U is not updated. It retains the value it had before being called. In Structured text language, the memorized value of input U is updated with 0.
Special cases Effect of a cold restart : (%S0=1) resets the drum controller to step 0 (with updating of the control bits). Effect of a warm restart : (%S1=1) updates the control bits, according to the current step. Effect of a program jump, de-activation of the task and break point : the fact of not scanning the drum controller means that the control bits are not reset to 0. Updating the control bits : only occurs when there is a change of step or in the case of a cold or warm restart.
___________________________________________________________________________ 2/12
B
2.2-4 Timer function block %Ti (Series 7) This timer function block, which is compatible with Series 7 PL7-2/3 blocks is used to provide control for time-delayed actions. The value of this delay is programmable and can be modified via the terminal.
%Ti E TB:1mn C T.P:9999 MODIF:Y D R
Timer block
Characteristics
Number Time base Current value %Ti TB %Ti.V 0 to 63 for a TSX 37, 0 to 254 for a TSX 57 1min, 1s, 100ms, 10ms (default 1min). Word which decreases from %Ti.P to 0 when the timer is running. Can be read and tested but not written. 0 < %Ti.P 9999. Word which can be read, tested and written. It is set to value 9999 by default. The duration is equal to %Ti.P*TB. Y : the preset value can be modified in adjust mode. N : no access in adjustmode. At state 0, resets the timer %Ti.V = %Ti.P. At state 0, freezes the current value %Ti.V. Associated bit %Ti.D = 1, if timer done %Ti.V = 0 Associated bit %Ti.R = 1 if timer %Ti.P > %Ti.V > 0 and if input C is at 1.
Preset value
%Ti.P
Adjust via terminal MODIF Setting input Control input Timer output done Timer running output
Y/N
Note : %Ti function blocks cannot be programmed in Instruction list language. The objects of %Ti blocks (%Ti.V, %Ti.P, %Ti.D and %Ti.R) can, however, be accessed. The total number of %TMi + %Ti should be less than 64 on the TSX 37 and less than 255 on the TSX 57.
___________________________________________________________________________ 2/13
B
Operation The timer changes when its two inputs (E and C) are at 1. It behaves like a downcounter. Current value %Ti.V decreases from the preset %Ti.P to 0, by one unit on each pulse of the time base TB. Output bit %Ti.R (Timer running) assigned to output R is then at state 1 and output bit %Ti.D (Timer done) assigned to output D is at state 0. When current value %Ti.V= 0, %Ti.D changes to 1 and %Ti.R returns to 0. Standard operations The Timer function block can be programmed to perform the following functions : On-time delay Ladder language
%I1.0 = E,C R PRESET D = %Q2.0 PRESET
0 0 %Ti.V = %Ti.P 0 0
0 1
1 0
1 1
%Ti.V %Ti.V %Ti.V = frozen decr. from %Ti.P %Ti.P -> 0 0 0 0 0 1 if Timer done 1 if Timer running
%I1.0
E
%T0
D
%Q2.0
TB =1mn R C %Ti.P = 3
MOD:N
___________________________________________________________________________ 2/14
B
Off-time delay Ladder language
% I1.1
%I1.1
E
%T7
D TB =1s C R %Ti.P = 120
%Q2.1
E,C R PRESET D %Q2.1
MOD:N
%I1.2
E
%T5
D
%Q2.4
%I1.3
TB =1mn C R %Ti.P = 3
%Q2.5
MOD:N
PRESET = D1 + D2 + D3
___________________________________________________________________________ 2/15
B
Cumulated off-time delay Ladder language
% I1.0
%I1.0
E
%T12
D
%Q2.4
E %I1.1
%I1.1
TB =10mn C R %Ti.P = 40
MOD:Y
R D
D1
D2
D3
IF %I1.0 THEN PRESET %T12 ; ELSE IF %I1.1 THEN STOP %T12 ; ELSE START %T12 ; END_IF ; END_IF ; %Q2.4 := NOT %T12.D ;
PRESET = D1 + D2 + D3
In Structured text language, 3 instructions are used to program the timer function blocks %Ti : PRESET %Ti : Resets the timer, START %Ti : Starts the timer running, STOP %Ti : Freezes the current value of the timer. Special cases Effect of a cold restart : (%S0 = 1) the preset value (defined by the variables editor) is loaded into the current value and output %Ti.D is set to 0, since the preset value which may have been modified by the terminal is lost. Effect of a warm restart : (%S1) has no effect on the current value of the timer. Effect of a PLC stop : a PLC stop, de-activation of the current task or execution of a break point does not freeze the current value. Effect of a program jump : the fact of not scanning the rung where the timer block is programmed does not freeze current value %Ti.V which continues to decrease to 0. Similarly, bits %Ti.D and %Ti.R assigned to timer block outputs D and R continue to operate normally and can thus be tested in another rung. However, the coils directly "connected" to the block outputs will not be activated since they are not scanned by the PLC. Testing bits %Ti.D and %Ti.R : the state of these bits can change during a scan. ___________________________________________________________________________ 2/16
B
2.3 Vertical comparison blocks
COMPARE EN > = < <>
Vertical comparison blocks are used to compare two operands (OP). These two operands are either 16-bit words (possibly indexed) or immediate values.
OP1 OP2
Characteristics
Command input Greater than output Equal to output Less than output Different from output Operand no.1 Operand no.2 EN > = < <> OP1 OP2 At state 1, compares the two operands. Is at state 1 if the contents of OP1 are greater than those of OP2. Is at state 1 if the contents of OP1 are equal to those of OP2. Is at state 1 if the contents of OP1 are less than those of OP2. Is at state 1 if the contents of OP1 are different from those of OP2. This operand is a single length word object (it can be indexed). This operand is a single length word object (it can be indexed).
___________________________________________________________________________ 2/17
B
Operation When the command input is set to 1, the two operands are compared and the four outputs are activated according to the result of the comparison. Setting the command input to 0 resets the activated outputs. Example of use The program below shows the comparison of word %MW2 indexed by word %MW40 with the immediate value 150. If the contents of %MW2[%MW40] are greater than 150 and %I1.3 = 1, coil %Q2.7 is activated. If the contents are equal to 150, coil %MW10:X4 is activated. Coil %M5 is only controlled if the contents are different from 150 (< or >). Ladder language
%I1.3
EN >
%Q2.7 %MW10:X4
%MW2 = [%MW40]
< 150 <>
This function block does not exist in Instruction list language or Structured text language. Use comparison operations >, <, =, <>
%M5
Special cases Effect of a cold restart : (%S0) operand OP1 and possibly OP2 (if OP2 is an internal word) are reset and the outputs are activated according to the result of their comparison with the new values. Effect of a warm restart : (%S1) has no effect on the comparison block.
___________________________________________________________________________ 2/18
B
Shift instructions consist of moving bits of a word or double word operand a certain number of positions to the right or to the left. Logic shift : - SHL(op2,i) logic shift of i positions to the left. - SHR(op2,i) logic shift of i positions to the right. Rotate shift : - ROL(op2,i) rotate shift of i positions to the left. - ROR(op2,i) rotate shift of i positions to the right.
0
%S17 15 (or 31) 0
%S17
If the operand to be shifted is a single length operand, the variable i will be between 1 and 16. If the operand to be shifted is a double length operand, the variable i will be between 1 and 32. The state of the last output bit is stored in bit %S17. Structure Ladder language
%I1.1 P %I1.2 P %MW10:=ROR(%KW9,8) %MW0:=SHL(%MW10,5)
%S17
Op1:=Operator(Op2,i)
B
2.5 Floating point instructions
2.5-1 General PL7 Micro software is used to perform operations on floating point objects. The floating point object format used is that of standard IEEE STD 734-1985 (equivalent to IEC 559). Words are 32 bits long, which corresponds to single length floating point numbers. Examples of floating point values : 1285.28 1.28528E3
Floating point values are between -3.402824E+38 and -1.175494E-38, and 1.175494E-38 and 3.402824E+38. Representation is accurate to 2-24. When viewing floating point numbers, no more than six digits can be displayed after the comma. Notes The value "1285" is interpreted as an integer value. To be considered as a floating point value it must be written : "1285.0", The conversion instructions Integer <--> Floating Point are used to change from one format to the other. Addressing floating point objects
Abbreviations Immed. val. %MF %KF Full addressing %MFi %KFi Type of floating point immediate values Access R Indexed form %MFi[%MWj] %KFi[%MWj]
Possibility of overlap between objects : The single and double length and floating point words are stored within the data area in a single memory zone. Thus, floating point word %MFi corresponds to single length words %MWi and %MWi+1 (word %MWi containing the least significant bits and word %MWi+1 containing the most significant bits of word %MFi). Examples : %MF0 corresponds to %MW0 and %MW1 %KF543 corresponds to %KW543 and %KW544.
___________________________________________________________________________ 2/20
B
2.5-2 Floating point comparison instructions Comparison instructions are used to compare two operands. > : test if operand 1 is greater than operand 2. >= : test if operand 1 is greater than or equal to operand 2. < : test if operand 1 is less than operand 2. <= : test if operand 1 is less than or equal to operand 2. = : test if operand 1 is equal to operand 2. <> : test if operand 1 is different from operand 2. The result is 1 when the comparison requested is true. Structure Ladder language
%Q2.3 %MF10>129.7 %M0 %MF20<%KF35 %I1.2 %Q2.4 %Q2.2
%MF30>=%MF40
The comparison is executed inside square brackets following instructions LD, AND and OR. Structured text language
%Q2.3 := %MF10 > 129.7 ; %Q2.2 := (%MF20 < %KF35) AND %M0 ; %Q2.4 := (%MF30 >= %MF40) OR %I1.2 ;
___________________________________________________________________________ 2/21
B
2.5-3 Floating point assignment instructions The following floating point assignment operations can be performed : floating point (indexed) -> floating point (indexed) floating point immediate value -> floating point (indexed) Structure Ladder language example 1 example 2
%MF10:=%KF100 %I3.2
example 1
example 1
%I3.3 P %MF100=150.25
example 2
example 2
Op1:=Op2
Operand 1 (Op1)
Operand 2 (Op2) %MF,%KF Floating point immediate value. Floating point numeric expr.
2.5-4 Floating point arithmetic instructions These instructions are used to perform arithmetic operations between two operands or on one operand. + : add two operands SQRT : square root of an operand - : subtract two operands ABS : absolute value of an operand * : multiply two operands / : divide two operands ___________________________________________________________________________ 2/22
B
Structure Ladder language
%M0 %MF0:=%MF10+129.7 %I3.2 %MF1:=SQRT(%MF10) %I3.3
P P
%MF2:=ABS(%MF20)
Rules for use Operations on floating points and on integers cannot be directly mixed. Conversion operations convert to one or other of these formats (see section 2.6, part B). System bit %S18 is controlled in the same way as for integer operations. It is set to 1 if : - Capacity is exceeded during an operation. - Division by 0 occurs. - The square root of a negative value is extracted (see section 1.4-4, part B). ___________________________________________________________________________ 2/23
B
2.6
2.6-1
There are six types of conversion instruction : BCD_TO_INT INT_TO_BCD DBCD_TO_DINT DINT_TO_DBCD DBCD_TO_INT INT_TO_DBCD
Review of the BCD code : The BCD (Binary Coded Decimal) code represents a decimal digit (0 to 9) by coding 4 bits. A 16-bit word object can thus contain a number expressed in 4 digits (0 N 9999).
Decimal BCD 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001
Example : Word %MW5 expresses the BCD value "2450" which corresponds to the binary value : 0010 0100 0101 0000, Word %MW12 expresses the decimal value "2450" which corresponds to the binary value : 0000 1001 1001 0010. Word %MW5 is converted to word %MW12 by using instruction BCD_TO_INT. Word %MW12 is converted to word %MW5 by using instruction INT_TO_BCD. Structure Conversion operations are performed as follows : Ladder language
%MW0:=BCD_TO_INT(%MW10) %I1.2 %MW10:=INT_TO_BCD(%KW9)
___________________________________________________________________________ 2/24
B
Syntax Operators (conversion of a 16-bit number) BCD_TO_INT INT_TO_BCD INT_TO_DBCD Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words Operand 1 (Op1) %MW %QW,%SW,%NW, %BLK %MD %QD, %SD Operand 2 (Op2) %MW,%KW Immed. val.,%IW,%QW,%SW %NW,%BLK,%Xi.T,Num. expr.
Op1:=Operator(Op2)
Op1:=Operator(Op2)
Application examples The BCD_TO_INT instruction is used to process a setpoint value at PLC inputs via BCD encoded thumbwheels. The INT_TO_BCD instruction is used to display numeric values (for example, the result of a calculation or the current value of a function block) on BCD coded displays.
___________________________________________________________________________ 2/25
B
Rules for use BCD-->Binary conversion The BCD-->Binary conversion instructions ensure that the conversion operator is applied to a BCD coded value. If the value is not a BCD coded value, system bit %S18 is set to 1 and the result gives the value of the first faulty 4-bit byte. Eg : BCD_TO_INT(%MW2) where %MW2=4660 gives a result of 1234. However, %MW2=242 (16#00F2) sets %S18 to 1 and the result is 15. For the DBCD_TO_INT instruction, if the BCD number is greater than 32767, system bit %S18 is set to 1 and value -1 is loaded in the result. Binary--> BCD conversion The INT_TO_BCD instruction ensures that the conversion operator is applied to a value between 0 and 9999 (or 0 and 9999 9999). If this is not the case, system bit %S18 is set to 1 and the result gives the value of the input parameter. Eg : INT_TO_BCD(%MW2) where %MW2=2478 gives a result of 9336. However, %MW2=10004 sets %S18 to 1 and the result is 10004. For the INT_TO_DBCD instruction, if the input parameter is negative, system bit %S18 is set to 1 and the result gives the value of the input parameter.
2.6-2 Integer <--> Floating point conversion instructions There are four conversion instructions : INT_TO_REAL : integer word --> floating point conversion. DINT_TO_REAL : integer double word --> floating point word conversion. REAL_TO_INT : floating point word --> integer word conversion (the result is the nearest algebraic value). REAL_TO_DINT : floating point word --> integer double word conversion (the result is the nearest algebraic value). Structure Ladder language
%MFO:=INT_TO_REAL(%MW10) %I1.8 %MD4:=REAL_TO_DIN(%MF9)
___________________________________________________________________________ 2/26
B
Syntax Operator Operands
Type Indexable words Non-indexable words Indexable floating point words Operand 1 (Op1) Operand 2 (Op2) %MW,%KW Immed. val.,%IW,%QW,%SW %NW,%BLK,%Xi.T,Num. expr.
Op1:=INT_TO_REAL(Op2)
%MF
Example :
integer word --> floating point word conversion : 147 --> 1.47e+02
Operator Operands
Type Indexable words Non-indexable words
Op1:=DINT_TO_REAL(Op2)
Operand 1 (Op1)
%MF
Example :
integer double word --> floating point word conversion : 68905 000 --> 6.8905e+07
Operator
Op1:=REAL_TO_INT(Op2) Op1:=REAL_TO_DINT(Op2)
Operands
Type Indexable words Non-indexable words Indexable double words Non-indexable double words Indexable floating point words Non-indexable floating point words Operand 1 (Op1) %MW %QW,%NW,%BLK %MD %QD Operand 2 (Op2)
Example : floating point word --> integer word conversion 5978.6 --> 5978 floating point word --> integer double word conversion -1235978.6 --> -1235979
Note : If, during conversion of a real word to an integer (or a real word to a whole double word), the floating point value exceeds the limits of the word (or double word), bit %S18 is set to 1.
___________________________________________________________________________ 2/27
B
2.6-3 Gray --> Integer conversion instructions The instruction GRAY_TO_INT converts a word in Gray code to an integer (pure binary code). Review of Gray code : Gray or "reflected binary" code is used to code a changing numeric value into a series of binary configurations which are distinguished from each other by the change of state of a single bit. This code is used, for example, to avoid the following random conditions : in pure binary code, the value 0111 changing to 1000 may generate random values between 0 and 1000 since the bits do not change value at exactly the same time.
Decimal Binary Gray 0 1 2 3 4 5 6 7 8 9
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101
%MW0:=GRAY_TO_INT(%MW10)
Op1:=GRAY_TO_INT(Op2)
___________________________________________________________________________ 2/28
B
2.7 Word table instructions
2.7-1 General PL7 software is used to perform operations on tables of : words, double words, floating point words. Word tables are sequences of adjacent words of the same type and of a defined length, L. Example of word tables : %KW10:5
Type Internal words Format Single length Double length Floating point Single length Double length Floating point Single length Maximum address %MWi:L %MDi:L %MFi:L %KWi:L %KDi:L %KFi:L %SW50:4 (2) Size i+L Nmax (1) i+L Nmax-1 (1) i+L Nmax-1 (1) i+L Nmax (1) i+L Nmax-1 (1) i+L Nmax-1 (1) Write access Yes Yes Yes No No No Yes
%KW10 16 bits
%KW14
Constant words
System words
(1) Nmax = maximum number of words defined during software configuration. (2) Only words %SW50 to %SW53 can be addressed in table form.
General rules for operations on tables Table operations are only performed on tables containing objects of the same type. Table operations can only be performed on a maximum of two tables. If the tables in an operation are of different sizes, the result table will correspond to the smaller of the two tables. The user should avoid performing operations on tables which overlap (for example : %MW100[20]:=%MW90[20]+%KW100[20]). Operations on two tables are performed on each element of the same position of the two tables and the result is transferred to the element in the same position of the result table. If during an operation between two elements, system bit %S18 is set to 1, the result for this operation is then incorrect, but operations on the following elements will be performed correctly. If one of the operands is a numeric expression it must be placed in parentheses. The position of the first word in the table corresponds to position 0.
___________________________________________________________________________ 2/29
B
2.7-2 Word table assignment The following can be assigned to word tables : immediate value -> word table (indexed) double format immediate value -> double word table (indexed) floating point immediate value -> floating point table (indexed) Example 1 : %MW0 :5:= 100
100 100 100 100 100 %MW0
example 1
100
%MW4
word (indexed) -> word table (indexed) double word (indexed) -> double word table (indexed) floating point (indexed) -> floating point table (indexed) Example 2 : %MW0 :5:= %MW11
100 100 100 100 100
example 2
%MW0
%MW11 100
%MW4
word table (indexed) -> word table (indexed) double word table (indexed) -> double word table (indexed) floating point table (indexed) -> floating point table (indexed) Example 3 : %MW0 :5:= %KW0:5
example 3
%KW0
%KW4
%MW0
%MW4
Note : Multiple assignments are authorized in examples 1 and 2 (%MW0:4 := %MW10:6 := %MW100) but not in example 3.
___________________________________________________________________________ 2/30
B
Structure Ladder language
%MW0:5:=100 %I3.2 %MW0:5:=%MW11
example 2
Op1 := Op2
___________________________________________________________________________ 2/31
B
2.7-3 Arithmetic instructions on tables These instructions are used to perform an arithmetic operation between two word table (or word and word table) type operands. + : add * : multiply : subtract / : divide REM : remainder of division Structure Ladder language
%M0 %MW0:10=%MW20:10+100 %I3.2 %MD50:5=%KD0:5+%MD0:5 %I3.3 P %MW0:10:=%KW0:10*%MW20
___________________________________________________________________________ 2/32
B
2.7-4 Logic instructions on tables The associated instructions are used to perform a logic operation between two word table (or word and word table) type operands. AND : AND (bit-wise). OR : Logic OR (bit-wise). XOR : Exclusive OR (bit-wise). NOT : Logic complement (bit-wise) of a table (only one operand). Structure Ladder language
%M0 %MW0:5:=%KW0:5AND16#FF00 %I3.2 %MD0:10:=%KD5:10OR%MD50:10 %I3.3 P %MW100:50:=NOT%MW0:50
___________________________________________________________________________ 2/33
B
2.7-5 Summing function on tables The SUM function adds together all the elements in a word table : If the table comprises single format words, the result is given in the form of a single format word. If the table comprises double words, the result is given in the form of a double word. Structure Ladder language
%I3.2 %MW5:=SUM(%MW32:12)
Res:=SUM(Tab)
Result (Res)
%MW %QW,%SW,%NW
Note : Bit %S18 is set to 1 when the result exceeds the limits of the word or double word format depending on the table operand.
B
2.7-6 Table comparison function The EQUAL function compares two tables element by element. If a difference is detected, the position of the first elements which are not the same is given in the form of a word. Otherwise, the value given is equal to -1. The third parameter provides the position from which the comparison begins (example : 0 to start at the beginning). This third parameter is optional. If it is omitted, the comparison is performed on all of the table. Structure Ladder language
%I3.2 %MW5:=EQUAL(%MW20:7,%KW0:7,3) %I1.2 %MW0:=EQUAL(%MD20:7,%KD0:7)
Res:=EQUAL(Tab1,Tab2,position)
Result (Res)
Position
Note : The tables must be the same length. If the position parameter is greater than the size of the tables, the result is then equal to this position.
Example %MW5:=EQUAL(%MW30:4,%KW0:4,1) 0 %MW30= 10 %KW0= 20 1 %MW31= 20 %KW1= 20 2 %MW32= 30 %KW2= 30 3 %MW33= 40 %KW3= 60 ==> %MW33 %KW3==> %MW5= 3 ___________________________________________________________________________ 2/35
B
2.7-7 Find functions on tables There are six find functions : FIND_EQW : find the position in a word table of the first element equal to a given value. FIND_GTW : find the position in a word table of the first element greater than a given value. FIND_LTW : find the position in a word table of the first element less than a given value. FIND_EQD : find the position in a double word table of the first element equal to a given value. FIND_GTD : find the position in a double word table of the first element greater than a given value. FIND_LTD : find the position in a double word table of the first element less than a given value. The result of these instructions is equal to the position of the first element found or to - 1 if the search is unsuccessful. Structure Ladder language
%I3.2 %MW5:=FIND_EQW(%MW20:7,%KW0) %I1.2 %MW0:=FIND_GTD(%MD20:7,%KD0)
Res:=Function(Tab,Val)
Value (Val)
Example %MW5:=FIND_EQW(%MW30:4,%KW0) Position 0 %MW30= 10 1 %MW31= 20 2 %MW32= 30 ==> %KW0= 30 ==> %MW5= 2 3 %MW33= 40 ___________________________________________________________________________ 2/36
B
Function FIND_EQD,FIND_GTD,FIND_LTD Parameters Double word tables
Type Tables of indexable words Indexable (double) words %MW Result (Res) Table (Tab) %MD:L,%KD:L %MD,%KD Immed. val.%QD, %ID,%SD Numeric expr. Value (Val)
Res:=Function(Tab,Val)
Example %MW5:=FIND_GTD(%MD30:4,%KD0) Position 0 %MD30= 100000 1 %MD32= 200000 ==> %KD0= 250000 2 %MD34= 300000 3 %MD36= 400000
==> %MW5= 2
___________________________________________________________________________ 2/37
B
2.7-8 Find maximum and minimum values function on tables There are four find functions : MAX_ARW : find the maximum value in a word table. MIN_ARW : find the minimum value in a word table. MAX_ARD : find the maximum value in a double word table. MIN_ARD : find the minimum value in a double word table.
The result of these instructions is equal to the maximum (or minimum) value found in the table. Structure Ladder language
%I3.2 %MW5:=MAX_ARW(%MW20:7) %I1.2 %MD0:=MIN_ARD(%MD20:7)
Res:=Function(Tab)
%QW,%SW,%NW
Res:=Function(Tab)
___________________________________________________________________________ 2/38
B
2.7-9 Number of occurrences of a value in a table There are two find functions : OCCUR_ARW : searches a word table for the number of elements equal to a given value. OCCUR_ARD : searches a double word table for the number of elements equal to a given value. Structure Ladder language
%I3.2 %MW5:=OCCUR_ARW%MW20:7,%KW0) %I1.2 %MW0:=OCCUR_ARD(%MD20:7,200)
Res:=OCCUR_ARW(Tab,Val)
Result (Res)
Value (Val)
Res:=OCCUR_ARD(Tab,Val)
Result (Res)
Value (Val)
%MW %QW,%SW
___________________________________________________________________________ 2/39
B
2.7-10 Rotate shift function on tables There are four shift functions : ROL_ARW : performs a rotate shift of elements in word tables by n positions from top to bottom. ROL_ARD : performs a rotate shift of elements in double word tables by n positions from top to bottom. ROR_ARW : performs a rotate shift of elements in word tables by n positions from bottom to top. ROR_ARD : performs a rotate shift of elements in double word tables by n positions from bottom to top. Structure Ladder language
%I3.2 P %I1.2 P ROR_ARD(2,%MD20:7) ROL_ARW(%KW0,%MW20:7)
0 1 2 4 5
Function(n,Tab)
Function(n,Tab)
B
2.7-11 Sort function on tables There are two sort functions : SORT_ARW : sorts the elements of the word table into ascending or descending order and stores the result in the same table. SORT_ARD : sorts the elements of the double word table into ascending or descending order and stores the result in the same table. Structure Ladder language
%I3.2 SORT_ARW(%MW20,MWO:6) %I1.2 SORT_ARD(-1,%MD20:6)
Syntax Function
SORT_ARW (dir.,Tab)
The "direction" parameter determines the order of the sort : if the direction is 0, the sort is performed in ascending order. If < 0, the sort is performed in descending order. The result (sorted table) is given in the Tab parameter (table to be sorted). Parameters Word tables
Type Tables of indexable words Indexable words Non-indexable words %MW,%KW Immed. val.%QW,%IW,%SW %NW,Numeric expr. Direction of the sort Table (Tab) %MW:L
Function
SORT_ARD(dir.,Tab)
The "direction" parameter determines the order of the sort : if the direction is 0, the sort is performed in ascending order : if < 0, the sort is performed in descending order. The result (sorted table) is given in the Tab parameter (table to be sorted). Parameters Double word tables
Type Tables of indexable words Indexable words Non-indexable words %MW,%KW Immed. val.%QW,%IW,%SW %NW,Numeric expr. Direction of the sort Table (Tab) %MD:L
___________________________________________________________________________ 2/41
B
2.8 Character string instructions
2.8-1 Format of a string or table of characters A character table is composed of a series of bytes in which a character string can be stored. The size of the table is used to specify the maximum length of the character string (up to 255 characters). Example : %MB4:6 represents a table of 6 bytes containing a string of up to 6 characters.
The first byte at the beginning of a table must be even (it is not possible to enter a byte table which starts with an odd byte, eg :%MB5:6). Byte tables use the same memory zone as words %MW and %MD. There is therefore a risk of overlap : see section1.2-4, part A. The term character string represents all the characters between the start of the table and the first string termination character encountered. The NUL character (hexa code 00) is known as the String termination character. It is symbolized by throughout this section. Examples : The following table (of 12 elements) contains the character string 'ABCDE' (5 characters long).
'A' 'B' 'C' 'D' 'E' 'J' 'K' 'L' 'M' 'N' 'O'
The following table (of 10 elements) contains the character string 'ABCDEJKLMN' (10 characters long).
'A' 'B' 'C' 'D' 'E' 'J' 'K' 'L' 'M' 'N'
The length of a character string is therefore determined either by the number of characters before the string termination character , or by the size of the table if no string termination character is detected.
Notes : System bit %S15 is set to 1 in the following cases : If, when writing a string in a table, the string is longer than the size of the table. (Impossible to write the string termination character ). If the user attempts to access a character which is not in that string. Incorrect parameters : Length to be deleted zero (DELETE function), length to be extracted zero (MID function), length to be replaced zero (REPLACE function), search for a substring which is longer than the string (FIND function).
___________________________________________________________________________ 2/42
B
2.8-2 Character string assignment This function is used to transfer a character string to a byte table of length L. Structure Ladder language Instruction list language
LD TRUE [ %MB30:10 := 'set_to_run']
OPERATE
%MB30:10:= 'set_to_run'
Example
31
'e'
32
't'
33
'_'
34
't'
35
'o'
36
'_'
37
'r'
38
'u'
39
'n'
Operands
Type Byte tables Operand 1 (Op1) %MB:L Operand 2 (Op2) %MB:L,%KB:L Immediate value
___________________________________________________________________________ 2/43
B
2.8-3 Alphanumeric comparisons These operators are used to compare two character strings contained in the byte tables provided as parameters. Comparison is performed character by character. The result is a bit which equals 1 if both strings satisfy the conditions determined by the operator, character by character. Otherwise, the bit equals 0. The order of characters is determined by the ASCII code table (ISO 646). For example, string 'Z' is larger than string 'AZ' which is larger than the string 'ABC'. Structure Ladder language
COMPARE
%MB20:12< %MB40:12
LD ST
Comparison blocks are programmed in the test zone. Structured text language
%M10 := %MB20:12 < %MB40:12 ;
The comparison is executed inside square brackets after the instructions LD, AND and OR.
==>
21
'b'
22
'c'
23
'd'
24
'e'
25
'f'
26
'g'
27
'l'
28
29
'k'
30
'w'
31
'z'
%MB
40
'a'
41
'b'
42
'c'
43
'd'
44
'e'
45
'f'
46
'h'
47
'l'
48
49
'k'
50
'w'
51
'z'
The elements after the termination character are not taken into account. Syntax Operator <, >, <=, >=, =, < > Op1 Operator Op2
Operands
Type Byte tables Operand 1 (Op1) and Operand 2 (Op2) %MB:L,%KB:L, immediate value
___________________________________________________________________________ 2/44
B
2.8-4 Numeric <---> ASCII conversion functions These functions are used to convert a numeric (or floating point) value to a character string in ASCII code or vice versa. The result of the conversion must be transferred to a PL7 object via an assignment operation : byte table, single or double length word, floating point. The conversions possible are : INT_TO_STRING DINT_TO_STRING STRING_TO_INT STRING_TO_DINT REAL_TO_STRING STRING_TO_REAL Binary -->ASCII conversion Binary -->ASCII conversion ASCII-->Binary conversion ASCII-->Binary conversion Floating point -->ASCII conversion ASCII-->Floating point conversion
Review of floating point format : ==> See section 2.5, part B Review of the ASCII code : All 256 alphanumeric and control characters can be coded on 8 bits. This code, known as ASCII (American Standard Code for Information Interchange), is compatible with the notion of bytes. Any tables of n bytes can therefore be formed by n ASCII codes defining n characters.
2.8-5 Binary --->ASCII conversion These functions are used to convert a numeric value (single or double length word) to a character string in ASCII code. Each digit, as well as the sign of the value provided as a parameter, is coded in ASCII in an element of the result byte table. INT_TO_STRING function : The contents of a single length word can be between -32768 and +32767, that is, 5 digits plus the sign. The result will therefore be a table of 6 characters plus the string termination character. The sign '+' or '-' is stored in the first character, the units in the sixth character, the tens in the fifth, and so on. DINT_TO_STRING function : The contents of a double length word can be between -2147483648 and +2147483647, that is, 10 digits plus the sign. The result will therefore be a table of 12 characters plus the string termination character. The sign '+' or '-' is stored in the first character, the unit in the twelth character, the tens in the eleventh, and so on. The second character is always '0'.
___________________________________________________________________________ 2/45
B
Structure Ladder language
OPERATE
%MB10:7:= INT_TO_STRING(%MW20)
OPERATE
%MB2:13:= DINT_TO_STRING(%MD30)
Example : Binary ---> ASCII conversion %MB10:7 := INT_TO_STRING (%MW20) where %MW20 = - 3782 in decimal ==> The result is stored in the following 7-byte table %MB10:7
%MB 10
'_'
11
'0'
12
'3'
13
'7'
14
'8'
15
'2'
16
3
'0'
4
'0'
5
'2'
6
'3'
7
'4'
8
'7'
9
'1'
10
'1'
11
'0'
12
'8'
13
'4'
14
Operator Operands
Type 12-byte tables + string termination character Indexable double words Non-indexable double words
Result %MB:13
Value
___________________________________________________________________________ 2/46
B
2.8-6 ASCII ---> Binary conversion This function is used to convert a character string representing a numeric value into binary code (result transferred to a single or double length word). Each element of the table provided as a parameter represents the ASCII code of a character. Authorized characters are digits and the characters '+' and '-'. STRING_TO_INT function : converts a string of 6 characters representing a numeric value between -32768 and +32767. The first character must represent the sign and the following characters the value. The second character represents the tens of thousands, ..., and the sixth character the units. The value must be right-justified in the string. STRING_TO_DINT function : converts a string of 12 characters representing a numeric value between -2147483648 and +2147483647. The first character must represent the sign and the following characters the value. The second is the character '0', the third the thousands of millions,..., the twelfth the units. The value must be right-justified in the string. Structure
OPERATE
%MW13:= STRING_TO_INT(%MB20:7)
21
'0'
22
'2'
23
'3'
24
'4'
25
'7'
26
Bit %S18 is set to 1 if the value described by the string is not between -32768 and +32767 or if one of the 6 characters is incorrect.
Operator Operands
Type Indexable double words Non-indexable double words 12-byte tables + string termination character
Bit %S18 is set to 1 if the value described by the string is not between -2147483648 and +2147483647 or if one of the 12 characters is incorrect. ___________________________________________________________________________ 2/47
B
2.8-7 Floating point ---> ASCII conversion This function is used to convert a real numeric value contained in a floating point type word to a character string coded in ASCII. The result is transferred to a table of 14 bytes + the string termination character. Each digit in the value and the characters '+', '-', '.', 'e' and 'E' are coded in ASCII in an element in the result table. The sign of the value is located in the first character, the decimal point (.) in the third, the exponent 'e' in the eleventh and the sign of the exponent in the twelfth. Structure Ladder language
OPERATE
%MB20:15:=REAL_TO_STRING(%MF30)
21
'3'
22
'.'
23
'2'
24
'3'
25
'4'
26
'7'
27
'1'
28
'8'
29
'0'
30
'e'
31
'+'
32
'2'
33
'6'
34
Bit %S18 is set to 1 if the floating point value provided as a parameter is not between - 3.402824e+38 and -1.175494e-38 or +1.175494e-38 and +3.402824e+38. In this case, the value of the result is incorrect.
___________________________________________________________________________ 2/48
B
2.8-8 ASCII --> Floating point conversion This function is used to convert a character string representing a real numeric value to floating point (result transferred to a floating point type word). Each element in the table provided as a parameter represents the ASCII code of one character. Authorized characters are digits and the characters '+', '-', '.', 'e' and 'E'. The string termination character is not used to determine the end of the string. This means that the 14 characters of the table must all be correct. The sign of the value must be located in the first character, the decimal point (.) in the third, the 'e' in the eleventh and the sign of the exponent in the twelfth. For example, the value 3.12 must be in the form '+3.1200000e+00'. Structure Ladder language
OPERATE
%MF18:=STRING_TO_REAL(%MB20:14)
21
'3'
22
'.'
23
'2'
24
'3'
25
'4'
26
'7'
27
'1'
28
'8'
29
'0'
30
'e'
31
'+'
32
'2'
33
'6'
34
%MF18 = - 3.234718e26
Result %MF
String
Bit %S18 is set to 1 if the value described by the string is not between -3.402824e+38 and -1.175494e-38 or +1.175494e-38 and +3.402824e+38 or if one of the 14 characters is incorrect. ___________________________________________________________________________ 2/49
B
2.8-9 Concatenation of two strings This function allows concatenation of two character strings as defined by parameters. The result is a byte table containing a character string. Structure Ladder language
OPERATE
%MB30:14:=CONCAT(%MB4:6,% MB14:9)
5
'n'
6
'c'
7
'o'
8
'n'
%MB
14
't'
15
'e'
16
's'
17
't'
18
'a'
19
'b'
20
'l'
21
'e'
22
%MB
30
'i'
31
'n'
32
'c'
33
'o'
34
'n'
35
't'
36
'e'
37
's'
38
't'
39
'a'
40
'b'
41
'l'
42
'e'
43
If the result table is too short, the result is truncated and system bit %S15 is set to 1. %MB30:10 := CONCAT (%MB4:6, %MB14:9)
%MB 30
'i'
31
'n'
32
'c'
33
'o'
34
'n'
35
't'
36
'e'
37
's'
38
't'
39
'a'
==> %S15 at 1
If the result table is too long, termination characters '' are added to the string. %MB30:15 := CONCAT (%MB4:6, %MB14:9)
%MB 30
'i'
31
'n'
32
'c'
33
'o'
34
'n'
35
't'
36
'e'
37
's'
38
't'
39
'a'
40
'b'
41
'l'
42
'e'
43
44
___________________________________________________________________________ 2/50
B
2.8-10 Deletion of a character substring This function is used to delete a number of characters (zone length L), from a given position (position of the first character to be deleted) in the string defined as a parameter. The result is a byte table containing a character string. Structure Ladder language
OPERATE
%MB14:9:=DELETE(%MB30:14,% MW2,%MW4)
Example : %MB14: 9 := DELETE (%MB30:14, %MW2, %MW4) with %MW2 = 5 (5 characters to be deleted) %MW4 = 3 (position =3)
%MB 30
'i'
31
'n'
32
'c'
33
'o'
34
'n'
35
't'
36
'e'
37
's'
38
't'
39
'a'
40
'b'
41
'l'
42
'e'
43
%MB
14
'i'
15
'n'
16
's'
17
't'
18
'a'
19
'b'
20
'l'
21
'e'
22
Notes :
Some parameters may overlap depending on the indices of PL7 objects : Table containing the source string. Table containing the result string. Word containing the length to be deleted. Word containing the position of the first character to be deleted.
A negative length or position is interpreted as being 0. The position parameter starts at the value 1 which corresponds to the first position in the character string. ___________________________________________________________________________
2/51
B
If the result table is too long, termination characters are added to the string. System bit %S15 is set to 1 in the following cases : The length to be deleted is zero, the output table is a copy of the source table. The position is greater than the length of the string, or the position of the first termination character found is less than or equal to the position of the first character to be deleted. The result is therefore an empty string. The position is equal to 0. The result table therefore contains an empty string. The result table is too short. It has therefore been truncated.
2.8-11 Insertion of a character substring Insertion of the character substring defined by the second parameter (string2) in the character string defined by the first parameter (string1). The insertion is made in the first string, after the character in the location given by the position parameter (Pos). The result of the insertion is a new character string transferred to a byte table. Structure Ladder language
OPERATE
%MB2:14:=INSERT(%MB20:9,%MB30:6,%MW40)
21
'n'
22
's'
23
't'
24
'a'
25
'b'
26
'l'
27
'e'
28
%MB
30
'c'
31
'o'
32
'n'
33
't'
34
'e'
35
%MB
2
'i'
3
'n'
4
'c'
5
'o'
6
'n'
7
't'
8
'e'
9
's'
10
't'
11
'a'
12
'b'
13
'l'
14
'e'
15
___________________________________________________________________________ 2/52
B
Syntax Operator Operands
Type Byte tables Indexable words Non-indexable words Result %MB:L Immed. value String 1 and 2 %MB:L,%KB:L %MW, %KW %IW,%QW,%SW,%NW Immediate value, %Xi.T Numeric expr. Pos (position)
Notes : The position parameter starts at the value 1 which corresponds to the first position in the character string. It is impossible to insert at the beginning of a string. In order to do this, use the CONCAT function. If the table is too long, termination type characters must be added. System bit %S15 is set to 1 in the following cases : The value of the position parameter is negative or equal to 0. In this case, it is interpreted as being 0 and the result table contains an empty string (composed of termination characters). The position provided as a parameter is greater than or equal to the length of the source string. The result table then contains an empty string (composed of termination characters). If the result table is too short, truncation occurs.
___________________________________________________________________________ 2/53
B
2.8-12 Replacement of a character substring This function is used to replace a section of a character string defined in the source table (string1) by a character substring defined in the replacement table (string2). The replacement to be made is defined by the position (pos.) and length parameters. This length corresponds to the length of the string which is removed and not to the length of the substring which replaces it. Structure Ladder language
OPERATE
%MB2:13:=REPLACE(%MB20:12,%MB30:9, %MW40,%MW41)
Example : %MB2:13 := REPLACE (%MB20:12, %MB30:9, %MW40, %MW41) where %MW40 = 3 (length=3) and %MW41 = 9 (position=9)
%MB 20
'm'
21
'i'
22
's'
23
'e'
24
'_'
25
'e'
26
'n'
27
'_'
28
'r'
29
'u'
30
'n'
31
String 1
%MB
30
's'
31
't'
32
'o'
33
'p'
34
35
'r'
36
'u'
37
'n'
38
String 2
%MB
2
'm'
3
'i'
4
's'
5
'e'
6
'_'
7
'e'
8
'n'
9
'_'
10
's'
11
't'
12
'o'
13
'p'
14
___________________________________________________________________________ 2/54
B
Notes : The position parameter starts at the value 1 which corresponds to the first position in the character string. If the output table is too long, termination type characters are added to the string. System bit %S15 is set to 1 in the following cases : If the value of the position parameter is negative or equal to 0. In this case, it is interpreted as being 0 and the result table contains an empty string (composed of termination characters). If the position provided as a parameter is greater than or equal to the length of the source string, the result table then contains an empty string (composed of termination characters). If the result table is too short, truncation occurs. If the position of the first string termination character is less than or equal to the position of the first character to be replaced, the output table is a copy of the source table up to the string termination character and completed by termination characters.
___________________________________________________________________________ 2/55
B
2.8-13 Extraction of a character substring This function is used to extract a number of characters from a source string provided as a parameter (string). The position of the first character to be extracted is determined by the position parameter (pos), and the number of characters to be extracted is given by the length parameter. The extracted string is stored in a byte table (result). Structure Ladder language
OPERATE
%MB14:7:=MID(%MB30:13,% MW2,%MW4)
Example : %MB14: 7 := MID (%MB30:13, %MW2, %MW4) where %MW2 = 4 (length), %MW4 = 9 (position)
%MB 30
'm'
31
'i'
32
's'
33
'e'
34
'_'
35
'e'
36
'n'
37
'_'
38
's'
39
't'
40
'o'
41
'p'
42
==> result
%MB 14
's'
15
't'
16
'o'
17
'p'
18
19
20
___________________________________________________________________________ 2/56
B
Notes : The position parameter starts at value 1 which corresponds to the first position in the character string. If the output table is too long, termination type characters are added to the result string. If the length provided as a parameter is greater than the size of the source string, the result table then contains the source string. If the last element of the table or the string termination character is reached before the number of characters defined by the length parameter has been extracted, extraction stops at this point. System bit %S15 is set to 1 in the following cases : If the value of the length parameter to be extracted is negative or equal to 0. In this case, it is interpreted as being 0 and the result table contains an empty string (composed of termination characters). If the value of the position parameter for the beginning of the extraction is zero or greater than or equal to the length of the table, or greater than or equal to the position of the first termination character. In this case, the result table contains an empty string (composed of termination characters). If the result table is too short, truncation occurs.
___________________________________________________________________________ 2/57
B
2.8-14 Extraction of characters Extraction of a number of characters the furthest to the left (LEFT) or furthest to the right (RIGHT) in a source string provided as a parameter (string). The number of characters to be extracted is defined by the length parameter. The extracted string is stored in a byte table (result). Structure Ladder language
OPERATE
%MB10:10:=LEFT(%MB30:13,% MW2)
31
'i'
32
's'
33
'e'
34
'_'
35
'e'
36
'n'
37
'_'
38
's'
39
't'
40
'o'
41
'p'
42
==> result
%MB 10
'm'
11
'i'
12
's'
13
'e'
14
'_'
15
'e'
16
'n'
17
'_'
18
19
___________________________________________________________________________ 2/58
B
Notes : If the output table is too long, termination type characters are added to the result string. If the length provided as a parameter is greater than the size of the source string, the result table then contains the source string. System bit %S15 is set to 1 in the following cases : If the value of the length parameter to be extracted is negative or 0. In this case, the result table contains an empty string (composed of termination characters). If the result table is too short, truncation occurs.
___________________________________________________________________________ 2/59
B
2.8-15 Comparison of two character strings This function is used to compare two character strings. The result is a word containing the position of the first different character. If the two character strings are exactly the same, the result is -1. Structure Ladder language
OPERATE
%MW2:=EQUAL_STR(%MB18:14,%MB50:14)
19
'b'
20
'c'
21
'd'
22
'e'
23
'f'
24
'g'
25
'h'
26
'i'
27
'p'
28
'w'
29
'x'
30
'y'
31
'z'
%MB
50
'a'
51
'b'
52
'c'
53
'd'
54
'?'
55
'f'
56
'g'
57
'h'
58
59
'v'
60
'w'
61
'x'
62
'y'
63
'z'
Note : A negative length or position is interpreted as being equal to 0. Upper case letters are different from lower case letters.
___________________________________________________________________________ 2/60
B
2.8-16 Search for a character substring This function is used to search for the character substring defined by the second parameter in the character string defined by the first parameter. The result is a word containing the position in the first string of the beginning of the substring searched for. If the search is not successful, the result is -1. Structure Ladder language
OPERATE
19
'b'
20
'c'
21
'd'
22
'e'
23
'f'
24
'g'
25
'h'
26
'i'
27
28
'w'
29
'x'
30
'y'
31
'z'
%MB
50
'f'
51
'g'
52
'h'
53
==> MW2 := 6 Indicates that the beginning of the string searched for is located from the sixth character onwards. Syntax Operator Operands
Type Indexable words Non-indexable words Byte tables Result %MW %QW,%SW,%NW. %MB:L,%KB:L Immediate value String 1 and 2
2/61
B
2.8-17 Length of a character string This function gives the length of the character string provided as a parameter, that is, the number of characters located before the termination character. Structure Ladder language
OPERATE
where
26
'g'
21
'b'
22
'c'
23
'd'
24
'e'
25
'f'
27
28
'n'
29
'o'
30
'p'
31
'r'
Note : If no termination character is found, the function gives the size of the table (see section 2.8-1).
___________________________________________________________________________ 2/62
B
2.9 Time management instructions : Date, Time of day, Duration
2.9-1 Parameter format The Date, Time of day and Duration parameters used by these instructions correspond to the standard formats defined by IEC standard 1131-3. Duration format (TIME type) This format is used to code durations expressed in tenths of a second and corresponds to the TIME format of the standard. These values are displayed in the following way : sssssssss.d which gives for example : 3674.3 for 1 hour, 1 minute, 14 seconds and 3 tenths of a second. The value is coded on 32 bits (a double word) of which the limits are set at [0, 4294967295] tenths of a second, which represents approximately 13 years and 7 months. Data format (DATE type) This format is used to code the year, the month and the day. It corresponds to the DATE format of the standard. The value is displayed in the following way : yyyy-mm-dd which gives for example : 1984-06-25 The value is coded in BCD on 32 bits (a double word) with 3 fields : 31 16 8 0 Year : 4 digits Year Month Day Month : 2 digits Day : 2 digits Example :
expressed in hexadecimal format
19h
84h
06h
25h
= 1984-06-25
Only values within the time period [1990-01-01, 2099-12-31] are permitted.
___________________________________________________________________________ 2/63
B
Time of day format (TOD type) This format is used to code the hour, the minutes and the seconds. It corresponds to the TIME_OF_DAY format of the standard. The value is displayed in the following way : hh:mm:ss which gives for example : 23:12:34 The value is coded in BCD on 32 bits (a double word) with 3 fields : 31 24 16 8 0 Hours : 2 digits (high-order word) Hr Min Sec Minutes : 2 digits (high-order word) Seconds : 2 digits (low-order word) Example :
expressed in hexadecimal format
23h
12h
34h
= 23:12:34
Only values within the time period [00:00:00, 23:59:59] are permitted.
Date and time format (DT type) This format is used to code the year, the month, the day, the hour, the minutes and the seconds. It corresponds to the DATE_AND_TIME format of the standard. The value is displayed in the following way : yyyy-mm-dd-hh:mm:ss which gives for example : 1984-06-25-23:12:34 The value is coded in BCD on 64 bits (a 4-word table) :
64 48 40 32 24 16 8 0
Year Example :
Month
Day
Hr
Min
Sec
1984h
06h
25h
23h
12h
34h
Only values within the time period [1990-01-01-00:00:00, 2099-12-3123:59:59] are permitted.
___________________________________________________________________________ 2/64
B
Hour, Minute, Second Format (HMS type) This format, used exclusively by the function TRANS_TIME, is used to code the hour, the minutes and the seconds. The value is displayed in the following way : which gives for example : hh:mm:ss 23:12:34
The value is coded in BCD on 32 bits (a double word) with 3 fields : 31 16 8 0 Hours : 4 digits (high-order word) Hr Min Sec Minutes : 2 digits (low-order word) Seconds : 2 digits (low0order word) Example :
expressed in hexadecimal format
23h
12h
34h
= 23:12:34
2.9-2 Use of system bits and words - General System bit %S17 is set in the following cases : Result of an operation outside the permitted time period values. An input parameter cannot be interpreted and is not consistent with the required format (DAT, DT or TOD). Operation on a Time of day (TOD) format leading to a change in the day. Access clash to the real-time clock. System bit %S15 is set to 1 if a string written in a table is longer than the size of that table. System words : %SD18 : absolute time counter is also used to perform time period calculations (incremented every 1/10 of a second by the system). %SW49 to %SW53 can also be used to display dates (see section 3.2-2, part B).
___________________________________________________________________________ 2/65
B
2.9-3 Read system date Reads the system date (Real-Time Clock) and transfers to the object given as a parameter in the Date and time (DT) format. Structure Ladder language
%M6
OPERATE
RRTC (%MW2:4)
Example : RRTC (%MW2:4) The result is transferred to the table of internal words which is 4 words long : %MW2 to %MW5. Syntax Operator Operand
Type 4-word tables in date and time format Date %MW:4
RRTC(date)
2.9-4 Update system date Updates the system date (Real-Time Clock) and transfers to the object given as a parameter in Date and time (DT) format. Structure Ladder language
%M7 P
OPERATE
Instruction list language LDR %M7 [%MW2:= 16#4300] [%MW3:= 16#1732] [%MW4:= 16#1124] [%MW5:= 16#1995] [WRTC (%MW2:4)]
%MW2:=16#4300
OPERATE
%MW3:=16#1732
OPERATE
%MW4:=16#1124
OPERATE
%MW5:=16#1995
OPERATE
WRTC (%MW2:4)
___________________________________________________________________________ 2/66
B
Structured text language
IF RE %M7 THEN %MW2 := 16#4300 ; %MW3 := 16#1732 ; %MW4 := 16#1124 ; %MW5 := 16#1995 ; WRTC (%MW2:4) ; END_IF ;
Example : The new date is loaded into an internal word table, %MW2:4, which is 4 words long and then sent to the system using the WRTC functions. Syntax Operator Operand
Type 4-word tables Date %MW:4, %KW:4 in date and time format
WRTC(date)
2.9-5 Read date and stop code Reads the date of the last PLC stop and the code specifying the cause of the stop (in the fifth word, equivalent to %SW58. See section 3.2-2, part B). Structure Ladder language
%M7
OPERATE
PTC (%MW4:5)
Example : PTC (%MW4:5) The result is transferred to the table of internal words which is 5 words long : %MW4 to %MW8. Syntax Operator Operand
Type Date 5-word tables %MW:5 in date and time format ___________________________________________________________________________
PTC (date)
2/67
B
2.9-6 Read day of the week This function gives the current day of the week in the form of a digit from 1 to 7 which is transferred to a word (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday). Structure Ladder language
%M7
OPERATE
%MW5:=DAY_OF_WEEK()
result :=DAY_OF_WEEK()
Note If the function was unable to update the result following an access error to the real-time clock, the result given is 0 and system bit %S17 is set to 1.
___________________________________________________________________________ 2/68
B
2.9-7 Add / Remove a duration at a date Adds or removes a duration (in tenths of a second) (In2) at a sorce date (In1). The result is a new date, transferred to a table of 4 words. ADD_DT () = Add a duration Structure Ladder language
%M7
OPERATE
RRTC (%MW2:4)
OPERATE
%MD8:=906
OPERATE
%MW2:4:=ADD_DT(%MW2:4,%MD8)
OPERATE
WRTC (%MW2:4)
Example : %MW2:4 := ADD_DT(%MW2:4, %MD8) %MW2:4 := Source date %MD8 := 906 (906 tenths of a second rounded to 1 min. 31 s) %MW2:4 := New date Syntax Operators result :=ADD_DT (In1, In2) result :=SUB_DT (In1, In2)
___________________________________________________________________________ 2/69
B
Operands
Type Table of four words in the date and time format Indexable double words Non-indexable double words Result %MB:4 In1(initial date) %MW4:4, %KW:4 %MD,%KD %ID,%QD Immediate value Numeric expr. In2 (time period)
Notes : The "duration" parameter (expressed in 1/10 of a second) will be rounded up or down so that the date and time can be increased or decreased (precision to within one second). - sssssssss.0 to sssssssss.4 rounded to sssssssss.0 - sssssssss.5 to sssssssss.9 rounded to sssssssss.0 + 1.0 Provision must be made in the application to handle leap years. If the result of the operation is outside the permitted time period values, system bit %S17 is set to 1 and the value of the result equals the minimum limit (for SUB_DT) or remains blocked at the maximum (for ADD_DT). If the "source date" input parameter cannot be interpreted and is not consistent with the DT (DATE_AND_TIME) format, system bit %S17 is set to 1 and the value of the result is 0001-01-01-000:00:00.
2.9-8 Add / Remove a duration at a time of day Adds or removes a time period at a time of day. The result is a new time of day which is transferred to a double word. ADD_TOD () = Add a duration Structure Ladder language
%M7
OPERATE
%MD8:= 906
OPERATE
%MD2:=ADD_TOD(%MD2,%MD8)
___________________________________________________________________________ 2/70
B
Structured text language
IF %M7 THEN %MD8 := 906 ; %MD2 := ADD_TOD (%MD2, %MD8) ; END_IF ;
Example :
%MD2 := ADD_TOD (%MD2, %MD8) %MD2 := Initial time (eg. 12:30:00) %MD8 := 906 (906 tenths of a second rounded to 1 min. 31 s) %MD2 := New time (eg. 12:31:31)
Syntax Operators result :=ADD_TOD (In1, In2) result :=SUB_TOD (In1, In2) Operands
Type Indexable double words Non-indexable double words Result %MD %QD In1(initial time) and In2 (time period) %MD,%KD %ID,%QD Immediate value, Numeric expr.
result and In1 are in the TOD format and In2 is in the time period format.
Notes : The "time period" parameter (expressed in 1/10 of a second) will be rounded up or down so that the date and time can be increased or decreased (precision to within one second).
___________________________________________________________________________ 2/71
B
2.9-9 Difference between two dates (no time) This function is used to calculate the difference in days between two dates. The result, given as an absolute value, is transferred to a double word. Structure Ladder language
%M7
OPERATE
%MD10:=DELTA_D(%MD2,%MD4)
Example :
%MD10 := DELTA_D (%MD2, %MD4) %MD2 := Date number1 (eg. 1994-05-01) %MD4 := Date number2 (eg. 1994-04-05) ==> %MD10 = 22464000 (==> difference = 26 days)
result :=DELTA_D(Date1,Date2)
result is in the TIME format and Date 1 and 2 are in the DATE format. The TIME format is defined to be accurate to within one tenth of a second. The DATE format is defined to be accurate to within one day. The time difference calculated will therefore be a multiple of 864000 (= 1day = 24 h x 60 min x 60 s x 10 tenths of a second). Warning Overflow occurs if the result exceeds the maximum value permitted for a duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1. If one of the input parameters cannot be interpreted and is not consistent with the DATE format, system bit %S17 is set to 1 and the result is 0. ___________________________________________________________________________ 2/72
B
2.9-10 Difference between two dates (with time) This function is used to calculate the time difference between two dates. The result, given as an absolute value, is transferred to a double word. Structure Ladder language
OPERATE
Example :
%MD10 := DELTA_DT (%MW2:4, %MW6:4) %MW2:4 := Date number1 (eg. 1994-05-01-12:00:00) %MW6:4 := Date number2 (eg. 1994-05-01-12:01:30) ==> %MD10 = 900 (==> difference = 1 minute and 30 seconds)
result :=DELTA_DT(Date1,Date2)
result is in the TIME format and Date 1 and 2 are in the DT format. The TIME format is defined to be accurate to within one tenth of a second. The DT format is defined to be accurate to within one second. The time difference calculated will therefore be a multiple of 10. Warning Overflow occurs if the result exceeds the maximum value permitted for a duration (TIME). In this case, the result is 0 and system bit %S18 is set to 1. If one of the input parameters cannot be interpreted and is not consistent with the DT format, system bit %S17 is set to 1 and the result is 0. ___________________________________________________________________________ 2/73
B
2.9-11 Difference between two times This function is used to calculate the time difference between two times of day. The result is transferred to a double word as an absolute value, giving a duration. Structure Ladder language
OPERATE
Example :
%MD10 := DELTA_TOD (%MD2, %MD4) %MD2 := Time1 (eg. 02:30:00) %MD4 := Time2 (eg. 02:40:00) ==> %MD10 = 6600 (==> difference = 11 minutes)
result :=DELTA_TOD(Time1,Time2)
result is in the TIME format and Time 1 and 2 are in the TOD format. The TIME format is defined to be accurate to within one tenth of a second. The TOD format is defined to be accurate to within one second. The time difference calculated will therefore be a multiple of 10. Attention If one of the input parameters cannot be interpreted and is not consistent with the TOD format, system bit %S17 is set to 1 and the result is 0.
___________________________________________________________________________ 2/74
B
2.9-12 Convert a Date to a character string This instruction converts a date to a character string (no time) in the format : YYYY-MM-DD (10 characters). This string ends with the termination character . Each character Y,M,D represents a number. Structure Ladder language
OPERATE
%MB2:11:= DATE_TO_STRING(%MD40 )
Example :
%MB
==>
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
10
'2'
11
'7'
12
result :=DATE_TO_STRING(Date)
Result %MB:11
Date
Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DATE format, system bit %S17 is set to 1 and the function returns the string : ' **** - ** - ** ' . If the output string is too short, truncation occurs and system bit %S15 is set to 1.
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
==> %S15 = 1
If the output string is too long, termination type characters are added to the string.
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
10
'2'
11
'7'
12
13
___________________________________________________________________________ 2/75
B
2.9-13 Convert a complete Date to a character string This instruction converts a complete date (with time) to a character string in the format : YYYY-MM-DD-HH:MM:SS (19 characters). This string ends with the termination character . Each character Y,M,D,H,M,S represents a number. Structure Ladder language
OPERATE
%MB2:20:= DT_TO_STRING(%MW50:4 )
Example :
%MB 2
'1'
%MB2:20 := DT_TO_STRING (%MW50:4) %MW50:4 := Date and time (type DT) (eg. 1998-12-27-23:14:37)
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
10
'2'
11
'7'
12
'-'
13
'2'
14
'3'
15
':'
16
'1'
17
'4'
18
':'
19
'3 '
20
'7'
21
result :=DT_TO_STRING(Date)
Notes : If the input parameter (date) cannot be interpreted and is not consistent with the DT format (DATE_AND_TIME), system bit %S17 is set to 1 and the function returns the string ' **** - ** -** - ** : ** : **'. If the output string is too short, truncation occurs and system bit %S15 is set to 1.
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
==> %S15 = 1
If the output string is too long, termination type characters are added to the string.
3
'9'
4
'9'
5
'8'
6
'-'
7
'1'
8
'2'
9
'-'
10
'2'
11
'7'
12
'-'
13
'2'
14
'3'
15
':'
16
'1'
17
'4'
18
':'
19
'3 '
20
'7'
21
22
___________________________________________________________________________ 2/76
B
2.9-14 Convert a Duration to a character string This instruction converts a time period (in the TIME format) to a character string. The format of the result can be broken down into hours, minutes, seconds and tenths of a second over 15 characters : HHHHHH:MM:SS.D. This string ends with the termination character . Each character H,M,S,D represents a number. The maximum time period corresponds to 119304 hours, 38 minutes, 49 seconds and 5 tenths of a second. Structure Ladder language
OPERATE
%MB2:15:=TIME_TO_STRING(%MD40)
3
'0'
4
'7'
5
'6'
6
'5'
7
'4'
8
':'
9
'3'
10
'2'
11
':'
12
'1'
13
'0'
14
'.'
15
'3'
16
result :=TIME_TO_STRING(Duration)
3
'0'
4
'7'
5
'6'
6
'5'
7
'4'
8
':'
9
'3'
==> %S15 = 1
___________________________________________________________________________ 2/77
B
If the output string is too long, termination type characters are added to the string.
3
'0'
4
'7'
5
'6'
6
'5'
7
'4'
8
':'
9
'3'
10
'2'
11
':'
12
'1'
13
'0'
14
'.'
15
'3'
16
17
2.9-15 Convert a Time of day to a character string This instruction converts a time of day (in the format TOD - TIME_OF_DAY) to a character string in the format HH:MM:SS on 8 characters plus a termination character . Each character H,M,S represents a number. Structure Ladder language
OPERATE
%MB2:9:=TOD_TO_STRING(%MD40)
Example : %MB2:9 := TOD_TO_STRING (%MD40) where %MD40 := 23:12:27 (TOD format) ==>
%MB 2
'2'
3
'3'
4
':'
5
'1'
6
'2'
7
':'
8
'2'
9
'7'
10
result :=TOD_TO_STRING(time)
B
Note : If the output string is too short, truncation occurs and system bit %S15 is set to 1.
3
'3'
4
':'
5
'1'
6
'2'
7
':'
9
'7'
==> %S15 = 1
If the output string is too long, termination type characters are added to the string.
11
___________________________________________________________________________ 2/79
B
2.9-16 Convert a Duration to HHHH:MM:SS This instruction converts a duration (in the TIME format) to a number of hours-minutesseconds, HHHH:MM:SS. The limit values are [0000:00:00, 9999:59:59]. Structure Ladder language
OPERATE
%MD100:=TRANS_TIME(%MD2)
Example :
==> MD2
result :=TRANS_TIME(Duration)
___________________________________________________________________________ 2/80
B
2.10 Bit table instructions
2.10-1 Copy one bit table to another bit table This function copies one bit table into another bit table bit-wise.
%M10:5:=COPY_BIT(%M20:5)
Notes : The tables can be of different sizes. In this case, the result table contains the result of the function executed on a length which is equivalent to the smallest table size, and the rest of the result table is not modified. Beware of overlapping between the input table and the result table.
___________________________________________________________________________ 2/81
B
2.10-2 Bit table logic instructions Associated functions are used to execute a bit-wise logic operation between two bit tables and load the result into another bit table. AND_ARX OR_ARX XOR_ARX NOT_ARX : : : : logic AND (bit-wise). logic OR (bit-wise). exclusive OR (bit-wise). logic complement (bit-wise) of a table.
%M50:10:=NOT_ARX(%M60:10)
Syntax Operator result := AND_ARX (Tab 1, Tab 2) result := OR_ARX (Tab 1, Tab 2) result := XOR_ARX (Tab 1, Tab 2) result := NOT_ARX (Tab 1)
Operands
Type Bit table Result %M:L, %Q:L, %I:L Table 1 and 2 (tab) %M:L, %Q:L, %I:L, %Xi:L
Notes : The tables can be of different sizes. In this case, the result table contains the result of the function executed on a length which is equivalent to the smallest table size, and the rest of the result table is not modified. Beware of overlapping between the input table and the result table.
___________________________________________________________________________ 2/82
B
2.10-3 Copy from a bit table to a word table This function copies bits from a bit table or part of a bit table to a word table (or double word table). Copying from the bit table is from a certain row (brow) for a number of bits (nbit). Copying to the word table (or double word table) is from the row (wrow or drow) beginning with the least significant bit of each word. BIT_W : Copies from a bit table to a word table. BIT_D : Copies from a bit table to a double word table.
%MD10:4:=BIT_D(%M20:29, 3, 22, 1)
___________________________________________________________________________ 2/83
B
Syntax Operator result := BIT_W (Tab, brow, nbit, wrow) result := BIT_D (Tab, brow, nbit, drow)
Operands
Type Word tables Double word tables Bit tables Indexable words Non-indexable words Result %MW:L %MD:L %M:L, %Q:L, %I:L, %Xi.L %MW, %KW %IW, %QW, %SW, %NW, %Xi.T Immediate value Numeric expr. Table (tab) brow - nbit wrow or drow
Notes : If the number of bits to be processed is greater than the number of bits remaining in the table from the row (brow), the function copies up to the last element in the table. If the number of bits to be copied is greater than the number of bits constituting the words remaining in the result table, the function stops copying at the last element in the word table (or double word table). A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.
___________________________________________________________________________ 2/84
B
2.10-4 Copy from a word table to a bit table This function copies bits constituting all or part of a word table (or double word table) to a bit table. Copying from the word table (or double word table) is from a certain row word (wrow or drow) for a number of words (nwd). Copying to the bit table is from the row (brow) beginning with the least significant bit of each word. W_BIT : Copies from a word table to a bit table. D_BIT : Copies from a double word table to a bit table. Structure Ladder language
OPERATE
%M20:36:=W_BIT(%MW10:7,2,2,3)
OPERATE
%M20:36:=D_BIT(%MD10:4,1,1,3)
___________________________________________________________________________ 2/85
B
Syntax Operator result := W_BIT (Tab, wrow, nwd, brow) result := D_BIT (Tab, drow, nwd, brow)
Operands
Type Bit tables Word tables Double word tables Indexable words Non-indexable words Result %M:L,%Q:L,%I:L %MW:L,%KW:L %MD:L,%KD:L %MW, %KW %IW, %QW, %SW, %NW, %Xi.T Immediate value Numeric expr. Table (tab) wrow or drow nwd - brow
Notes : If the number of bits to be processed is greater than the number of bits remaining in the table from the row (wrow), the function copies up to the last element in the table. If the number of bits to be copied is greater than the number of bits remaining in the result table, the function stops copying at the last element in the table. A negative value in the brow, nbit, wrow or drow parameters is interpreted as zero.
___________________________________________________________________________ 2/86
B
2.11 "Orphee" functions : shift, counter
2.11-1 Shifts on words with retrieval of shifted bits These functions execute arithmetical shifts to the left or right for a number of shifts (nbit) on a word or a double word (a). After a shift operation, the value is loaded into (result) and the shifted bits are loaded into (rest). WSHL_RBIT : Shift to left on a word with retrieval of shifted bits. DSHL_RBIT : Shift to left on a double word with retrieval of shifted bits. WSHRZ_C : Shift to right on a word with filling of spaces by 0 and retrieval of shifted bits. DSHRZ_C : Shift to right on a double word with filling of spaces by 0 and retrieval of shifted bits. WSHR_RBIT : Shift to right on a word with extension of sign and retrieval of shifted bits. DSHR_RBIT : Shift to right on a double word with extension of sign and retrieval of shifted bits. Structure Ladder language
OPERATE WSHL_RBIT(%MW20,%MW30,%MW21,%MW10)
[WSHL_RBIT(%MW20,%MW30,%MW21,%MW10)]
OPERATE WSHRZ_C(%MW20,%MW30,%MW21,%MW10)
LD
TRUE
[WSHRZ_C(%MW20,%MW30,%MW21,%MW10)]
OPERATE DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)
LD
TRUE
[DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)]
___________________________________________________________________________ 2/87
B
Example : WSHL_RBIT(%MW20,%MW30,%MW21,%MW10)
rest = %MW10 0000 0000 0000 Copy shifted bits result = %MW21 1111 0110 1000 Fill bits using zero 0000 0001 A = %MW20 0001 1111 0110 1000
where %MW30 = 4
WSHRZ_C(%MW20,%MW30,%MW21,%MW10)
a = %MW20 1000 0000 1111 0001 rest = %MW10 0001 0000 0000 0000
where %MW30 = 4
DSHR_RBIT(%MD30,%MW40,%MD20,%MD10)
a = %MD30 MSB 1000 0000 1111 0001 00 1111 rest = %MD10 0000 0000 0000 0000 0000 0000 00 Copy shifted bits result = %MD20 keep sign 1 111 11 10 0000 0011 1100 0100 0000 0011 propagate sign bit in bits freed by shift operation MSB LSB 00 1111
where %MW40 = 6
MSB LSB
Syntax Operator
WSHL_RBIT (a, nbit, result, rest) WSHRZ_C (a, nbit, result, rest) WSHR_RBIT (a, nbit, result, rest)
a %MW,%KW %IW, %QW, %SW, %NW Immediate value Numeric expr. nbit %MW,%KW result rest %MW
Operands
Type Indexable words Non-indexable words
___________________________________________________________________________ 2/88
%IW, %QW, %QW, %SW,%NW %SW, %NW, %Xi.T Immediate value Numeric expr.
B
Syntax Operator DSHL_RBIT (a, nbit, result, rest) DSHRZ_C (a, nbit, result, rest) DSHR_RBIT (a, nbit, result, rest)
Operands
Type Indexable double words a %MD,%KD nbit result rest %MD %QD,%SD
Non-indexable double words %ID,%QD,%SD Immediate value Numeric expr. Indexable words Non-indexable words %MW, %KW %IW, %QW, %SW, %NW, %Xi.T Immediate value Numeric expr.
Notes : If the parameter (nbit) is not between 1 and 16 for shifts on words, or between 1 and 32 for shifts on double words, the outputs (result) and (rest) are not significant and system bit %S18 is set to 1.
___________________________________________________________________________ 2/89
B
2.11-2 Up/down counting with indication of over/underflow This function executes up/down counting with an indication of an over/underflow. The function is only executed when the enable input (en) is at 1. Two independent inputs (cu and cd) are used to upcount and downcount events. Output (Qmin) is set to 1 when the minimum threshold (min) is reached and output (Qmax) is set to 1 when the maximum threshold (max) is reached. The initial counter value is fixed by parameter (pv) and the current counter value is given by parameter (cv). A 16-bit word (mwd) is used to store the state of the cu and cd inputs (bit 0 to store cu and bit 1 to store cd). Structure Ladder language
OPERATE
Example :
SCOUNT (%M9,%MW10,%M11,%M12,%MW11,%MW12,%M16,%M10,%MW15,%MW20) where %MW10 (pv) = 5, %MW11 (min) = 0, %MW12 (max) = 7
en : %M9
cd : %M12
mcd : %MW20:X1
cu : %M11
mcu : %MW20:X0
Qmax : %M10
65
___________________________________________________________________________ 2/90
B
Syntax Operator Operands
Type Bits Indexable words Non-indexable words en, cu, cd Qmin, Qmax pv, min, max cv, mwd
SCOUNT (en, pv, cu, cd, min, max, Qmin, Qmax, cv, mwd)
%I,%Q,%M,%S, %I,%Q,%M %BLK,%.:Xk %MW,%KW %IW, %QW, %SW, %NW, %Xi.T, Immed. val. Numeric expr. %MW %QW,%SW %NW
Notes : If (en) = 0 then the function is no longer enabled and on each call, there is : Qmin = Qmax = 0 mcu = mcd = 0 cv = pv If max > min then : cv max ---> Qmax = 1 and Qmin = 0 min < cv < max ---> Qmax = Qmin = 0 cv min ---> Qmax = 0 and Qmin = 1 If max < min then : max cv min ---> Qmax = 1 and Qmin = 0 cv < max ---> Qmax = 0 and Qmin = 1 cv > min ---> Qmax = 1 and Qmin = 0 If max = min then : cv < min and max ---> Qmax = 0 and Qmin = 1 cv min and max ---> Qmax = 1 and Qmin = 0 Modifiying parameter (pv) with (en) at 1 has no effect on operation. A negative value for parameters (pv) and (min) is interpreted as a zero value. A value less than 1 for parameter (max) is interpreted as 1.
___________________________________________________________________________ 2/91
___________________________________________________________________________ 2/92
33 B
1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0
S U U S S S S->U S->U S->U S->U S->U S->U S or U->S U->S U->S S U U U S->U S U U S
%S40 to %S47 1 = I/O fault of a TSX 57 rack %S49 %S50 %S51 1 = reset tripped solid state outputs 1 = set real-time clock 1 = loss of real-time clock time
B
Bit %S59 %S66 %S67 %S68 %S69 %S70 %S73 (2) %S74 (2) %S80 %S90 %S96 (2) %S97 (2) %S98 (2) %S99 (2) %S100 Function 1 = enable adjustment of current date 1 = battery indicator always off 0 = memory cartridge battery operating 0 = backup battery (processor) operating 1 = enable WORD memory display mode on displays 1 = update data on As-i bus or TSX Nano link 1 = switch to protected mode on AS-i bus 1 = save configuration on AS-i bus 1 = reset message counters 1 = update common words 0 = application program backup invalid 1 = application program backup valid 0 = %MW backup invalid 1 = %MW backup valid 1 = replace TSX SAZ 10 module pushbutton with discrete input 1 = replace centralized display block pushbutton with discrete input Terminal port protocol Init. state Control (1) 0 0 0 0 0 0 0 0 0 0 0 U U S S U S->U U->S U->S S->U S->U S->U S U U S
(1) S = controlled by the system, U = controlled by the user, U->S = set to 1 by the user, reset to 0 by the system, S->U = set to 1 by the system, reset to 0 by the user. (2) only on TSX 37.
___________________________________________________________________________ 3/2
B
3.1-2 Detailed description of system bits TSX 37 and TSX 57 PLCs have %Si system bits which indicate the status of the PLC or enable the user to intervene in its operation. These bits can be tested in the user program in order to detect any operating event which requires special processing. Some of them must be rest to their initial or normal state by the program. However, the system bits which have been reset to their initial or normal state by the system must not be reset by the program or the terminal.
System bits %S0 Function Description
Cold start
Normally at 0. It is set to 1 by : A power return with loss of data (battery fault). The user program. The terminal. Changing a cartridge. Pressing the RESET button. This bit is set to 1 during the first complete scan. It is reset to 0 before the next scan. Operation : see part A, section 1.4. Normally at 0. It is set to 1 by : A power return with saving of data. The user program. The terminal. It is reset to 0 by the system at the end of the first complete scan and before the outputs are updated. Operation : see part A, section 1.4. Changes in the state of these bits are controlled by an internal clock. They are not synchronized with the PLC scan.
%S1
Warm restart
Example : %S4
5ms 5ms
Normally at 1, this bit is used to test the wiring when the TSX 37 test PLC is in the "not configured" state. At state 1 the outputs are forced to 0. At state 0 the outputs can be modified by an adjustment terminal.
%S9
Placing outputs Normally at 0. It can be set to 1 by the program or by the terminal : in fallback At state 1 PLC outputs are forced into fallback position. position At state 0 outputs are updated normally. I/O fault Normally at 1. It is set to 0 when an I/O fault is detected on the base or extension PLC (configuration fault, exchange fault, hardware fault). Bit %S10 is reset to 1 when the fault disappears.
%S10
___________________________________________________________________________ 3/3
B
System bits %S11 Function Description
Watchdog overflow
Normally at 0. It is set to 1 by the system when the execution of a task exceeds the maximum execution time (watchdog) declared during configuration. Watchdog overflow causes the PLC to change to STOP and the application stops in error mode (ERR indicator lamp flashing). Normally at 0. It is set to 1 by the system during the first scan after the PLC has been set to RUN. Normally at 0. It is set to 1 when the destination zone of a character string transfer is not sufficiently large to receive that character string. This bit must be reset to 0 by the user. Normally at 1. It is set to 0 by the system if a fault occurs in an I/O module configured in the task. This bit must be reset to 1 by the user. This task controls its own %S16 bit. Normally at 0. It is set to 1 by the system : During a shift operation. It contains the state of the last bit. If overflow occurs in a non-signed arithmetic operation (dates). This bit must be reset to 0 by the user. Normally at 0. It is set to 1 in the case of overflow during a 16-bit operation, where : Result is greater than + 32767 or less than - 32768 for single length operations. Result is greater than + 2 147 483 647 or less than - 2 147 483 648 for double length operations. Result is greater than +3.402824E+38 or less than -3.402824E+38 for floating point operations (software version > 1.0). Capacity overflow in DCB. Division by 0. The square root of a negative number. Forcing to a non-existent step on a drum controller. Stacking a full register and unstacking an empty register. It must be tested by the user program after each operation where there is a risk of overflow, then reset to 0 by the user if an overflow occurs. Normally at 0. It is set to 1 by the system in the event of a scan period overrun (task scan time greater than the period defined by the user during configuration or programmed in word %SW associated with the task). This bit is reset to 0 by the user. Each task controls its own %S19 bit.
%S13 %S15
First scan Character string fault Task I/O fault Output bit on shift or arithmetic carry Arithmetic overflow or error
%S16
%S17
%S18
%S19
___________________________________________________________________________ 3/4
B
System bits %S20 Function Index overflow Description Normally at 0. It is set to 1 when the address of the indexed object becomes less than 0 or exceeds the number of objects declared during configuration. It must be tested by the user program after each operation where there is a risk of overflow, then reset to 0 by the user if an overflow occurs. This bit is controlled by the user to initialize the Grafcet (preferably set to 1 during preprocessing). It is reset to 0 by the system after Grafcet initialization (at the end of preprocessing, during assessment of the new Grafcet state). Grafcet initialization involves deactivating all active steps and activating initial steps. On a cold start, this bit is set to 1 by the system during preprocessing. Normally at 0, this bit can only be set to 1 by the program during preprocessing. At state 1, it causes all Grafcet steps to deactivate. It is reset to 0 by the system after acknowledgment of the end of the preprocessing. Normally at 0, setting %S23 to 1 causes the Grafcet state to be maintained. Whatever the value of the transition conditions upstream of the active steps, the Grafcet chart does not change. Freeze is maintained as long as bit %S23 is set to 1. This bit is controlled by the user program. It is set to 1 or 0 only during preprocessing. Normally at 0, it is set to 1 by the system when activation capacities (steps or transitions) are exceeded or when trying to execute an incorrectly defined chart (such as a destination connector to a step which is not part of the chart). An overflow causes the PLC to STOP. This bit is reset to 0 when the terminal is initialized. Normally at 1. If it is set to 0 by the user, the master task is deactivated. Normally at 1. If it is set to 0 by the user, the fast task is deactivated. Normally at 1. If it is set to 0 by the user, events are disabled.
%S21
Grafcet initialization
%S22
Resetting Grafcet
%S23
Grafcet freezing
%S26
%S30
Master task activation/ deactivation Fast task activation Enable/ disable events Saturation of event processing
%S31 %S38
%S39
This bit is set to 1 by the system to show that one or more events cannot be processed due to saturation of the stacks. This bit is reset to 0 by the user.
___________________________________________________________________________ 3/5
B
System bits %S40 to %S47 %S49 Function I/O fault (racks) (1) Description Bits %S40 to %S47 are assigned to racks 0 to 7 respectively. Normally at 1, each of these bits is set to 0 should an I/O fault occur on the corresponding rack. The bit is reset to 1 when the fault has cleared. Normally at state 0. This bit can be set to 1 by the user to request a reactivation every 10s from the occurrence of a solid state output fault triggered by an over-current or a short-circuit. Normally at 0. This bit can be set to 1 or to 0 by the program or by the terminal. At 0 it accesses the date and time by reading system words %SW50 to 53. At 1 it updates the date and time by writing system words %SW50 to 53. This bit, which is managed by the system, signals at 1 either that the real-time clock is missing or that the system words relating to the real-time clock are not significant. In this case, the clock should be set. Setting the time automatically changes the bit to 0. Normally at 0. This bit can be set to 1 or to 0 by the program or by the terminal. At 0 the system does not control system word %SW59. At 1 the system controls the rising and falling edges on word %SW59 to adjust the current date and time (in increments). Normally at 0. This bit can be set to 1 or to 0 by the program or by the terminal. It is used to switch the battery indicator on or off, if the backup battery is faulty or missing : At 0 the battery indicator lights up if the battery is faulty or missing At 1 the battery indicator is always off On a cold start, %S66 is reset to 0 by the system. This bit is used to check operation of the backup battery for the RAM memory cartridge. At 0 the battery is present and operating. At 1 the battery is absent or not operating. This bit is used to check operation of the backup battery for program and data in the RAM memory. At 0 the battery is present and operating. At 1 the battery is absent or not operating. Normally at 0. This bit can be set to 1 or to 0 by the program or by the terminal. At 0 the state of the I/O are displayed on the PLC indicator lamps (WRD indicator lamp off). At 1 user data is displayed (WRD indicator lamp on). (see words %SW67,68 and 69).
Reactivate outputs Updating the date and time using words %SW50 to 53 Loss of real-time clock time Updating the date and time using word %SW59 Control of battery indicator
%S50
%S51
%S59
%S66
%S67
State of cartridge battery State of processor battery Display of user data on PLC displays
%S68
%S69
___________________________________________________________________________ 3/6
B
System bits %S70 Function Update data on AS-i bus or TSX Nano link Description This bit is set to 1 by the system at the end of each TSX Nano or AS-i bus scan. On power-up, it indicates that all the data has been refreshed at least once and that it is therefore significant. This bit is reset to 0 by the user.
%S73
Switch to Normally at 0. This bit is set to 1 by the user to change to protected mode protected mode on AS-i bus. Bit %S74 must first be at 1. This on AS-i bus bit is only used in a wiring test, and has no application in the PLC. Save configuration present on AS-i bus Reset message counters Refresh common words Validity of application program backup Normally at 0. This bit is set to 1 by the user to save the configuration present on the AS-i bus. This bit is only used in a wiring test, and has no application in the PLC. Normally at 0. This bit can be set to 1 by the user in order to reset message counters %SW80 to %SW86. Normally at 0. This bit is set to 1 when common words are received from another station on the network. This bit can be set to 0 by the program or by the terminal to check the exchange cycle of common words. 0 -> application program backup invalid, 1 -> application program backup valid. This bit can be read at any time (by the program or in adjust mode) and in particular after a cold or warm restart. It is relevant to a Backup application created using PL7 in the internal Flash EPROM. 0 -> %MW backup invalid, 1 -> %MW backup valid. This bit can be read at any time (by the program or in adjust mode) and in particular after a cold start or warm restart. Normally at 0. This bit is managed by the user : 0 -> pushbutton on TSX SAZ 10 module active, 1 -> pushbutton on TSX SAZ 10 module replaced by a discrete input (see %SW98). Normally at 0. This bit is managed by the user : 0 -> pushbutton on centralized display block active, 1 -> pushbutton on centralized display block replaced by a discrete input (see %SW99). Set to 0 or 1 by the system depending on the state of the INL/DPT shunt on the terminal port. If the shunt is absent (%S100=0), UNI-TELWAY master protocol is used. If the shunt is present (%S100=1), the protocol used is that indicated by the application configuration.
%S74
%S80
%S90
%S96
%S97
%S98
Locate pushbutton on TSX SAZ 10 module remotely Locate pushbutton on display block remotely Terminal port protocol
%S99
%S100
___________________________________________________________________________ 3/7
B
3.2 System words
Control U U U U S S S S S and U S and U S S S S S S S S S and U S and U
S U S and U
S and U
S and U U
___________________________________________________________________________ 3/8
B
Word Function %SW98 (2) Module/channel geographical address of the discrete input replacing the pushbutton on the TSX SAZ 10 module %SW99 (2) Module/channel geographical address of the discrete input replacing the pushbutton on the centralized display block %SW108 No. of bits forced %SW109 Count number of analog channels forced to 0 %SW124 Type of last CPU fault found %SW125 Type of blocking fault %SW126 Address of blocking fault instruction %SW127 S = controlled by the system, (2) only on TSX 37. U = controlled by the user, Control U U S S S S S
%SW1
%SW8
%SW9
%SW10
%SW11 %SW12
___________________________________________________________________________ 3/9
B
System words %SW13 Function Main address of the station Fault status on floating point operation Description Indicates for the main network : The station number (low-order byte) from 0 to 127. The network number (high-order byte) from 0 to 63. (position of dip switch on the PCMCIA card) On detecting a fault in a floating point arithmetic operation, bit %S18 is set to 1 and the %SW17 fault status is updated in line with the following code : %SW17:X0 = Invalid operation/the result is not a number %SW17:X1 = Non-standard operand / the result is correct %SW17:X2 = Division by 0 / the result is %SW17:X3 = Overflow / the result is %SW17:X4 = Underflow / the result is 0 This word is reset to 0 by the system during a cold restart and by the program for reuse. This double word is used to calculate time periods. It is incremented every 1/10th of a second by the system (even if the PLC is in STOP). It can be read and written by the user program or by the terminal. This word contains the number of steps active, to activate and deactivate for the current scan. It is updated by the system every time the Grafcet chart changes. This word contains the number of chart transitions validated, to validate and to devalidate for the current scan. It is updated by the system every time the Grafcet chart changes. Indicates the scan time of the last master task scan (in ms). Indicates the longest scan time of the master task since the last cold restart (in ms).
%SW17
%SD18
Absolute time counter Grafcet activity level Grafcet transitions validity table Master task scan time (1) Master task maximum scan time (1) Master task minimum scan time (1) Fast task scan time (1)
%SW20
%SW21
%SW30
%SW31
%SW32
Indicates the shortest scan time of the master task since the last cold restart (in ms).
%SW33
Indicates the scan time of the last fast task scan (in ms).
(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end (update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks as well as processing of terminal requests.
___________________________________________________________________________ 3/10
B
System words %SW34 Function Fast task maximum scan time (1) Fast task minimum scan time (1) Number of events Description Indicates the longest scan time of the fast task since the last cold restart (in ms).
%SW35
Indicates the shortest scan time of the fast task since the last cold restart (in ms).
%SW48
Indicates the number of events processed since the last cold restart (in ms). This word can be written by the program or by the terminal. System words containing the current date and time in BCD : %SW49 : day of the week (1 for Monday to 7 for Sunday). %SW50 : Seconds (SS00) %SW51 : Hours and Minutes (HHMM) %SW52 : Month and Day (MMDD) %SW53 : Year (YYYY) These words are controlled by the system when bit %S50 is at 0. These words can be written by the user program or by the terminal when bit %S50 is set to 1. System words containing the date and time of the last power failure or PLC stop (in BCD) : %SW54 : Seconds (00SS), %SW55 : Hours and Minutes (HHMM), %SW56 : Month and Day (MMDD), %SW57 : Year (YYYY). %SW58 : high order byte containing the day of the week (1 for Monday to 7 for Sunday) The low order byte contains the code of the last stop. 1= Change from RUN to STOP by terminal 2= Stop on software fault (PLC scan overshoot) 4= Power outage 5= Stop on hardware fault 6= Stop on HALT instruction
%SW58
(1) This time corresponds to the time elapsed between the beginning (acquisition of inputs) and end (update of outputs) of a scan cycle. This time includes processing of event-triggered and fast tasks as well as processing of terminal requests. (2) Only on TSX 37-21/22 and TSX 57 PLCs.
___________________________________________________________________________ 3/11
B
System bits %SW59 Function Adjust current date Description Contains two sets of 8 bits to adjust the current date. The operation is always performed on a rising edge of the bit. This word is enabled by bit %S59. Increment Decrement Parameter bit 0 bit 8 Day of the week bit 1 bit 9 Seconds bit 2 bit 10 Minutes bit 3 bit 11 Hours bit 4 bit 12 Days bit 5 bit 13 Months bit 6 bit 14 Years bit 7 bit 15 Centuries Contains the Hexadecimal/BCD value that the user wishes to see displayed on the optional 7-segment display. The display appears when bit %S66 is at 1. When %S69=1, these words enable the display block (PLC front panel) to be used in WORD mode : %SW67 : control and status of WORD mode. %SW68 : maximum index and current index. %SW69 : number of the first object in the zone displayed. For more information on these system words see part F, section 1.5 (installation manual). No of messages sent by the system to the terminal port. No of messages received by the system from the terminal port. No of messages sent by the system to the PCMCIA card. No of messages received by the system from the PCMCIA card. No of telegrams sent by the system. No of telegrams received by the system. No of messages refused by the system.
___________________________________________________________________________ 3/12
B
System words %SW96 Function Description
Control and/or diagnostics of the application program and %MW save/retrieve function : bit 0 : request to transfer to the save zone. This bit is active on a rising edge. It is reset to 0 by the system once the rising edge is taken into account. bit 1 : when this bit is at 1, this signifies that the save function is complete. This bit is reset to 0 by the system once the rising edge is taken into account. bit 2 : report of the save : 0 -> save with no errors, 1 -> error during save. bits 3 to 5 : reserved. bit 6 : validity of the application program backup (identical to %S96). bit 7 : validity of the %MW backup (identical to %S97). bits 8 to 15 : this byte is only significant if the report bit is at 1 (bit 2 = 1, error during save). 1 -> number of %MW to be saved greater than the number of %MW configured, 2 -> number of %MW to be saved greater than 1000 or less than 0, 3 -> number of %MW to be retrieved greater than the number of %MW configured, 4 -> size of the application in the internal RAM greater than 15 Kwords (remember that the %MW are always saved when the application program is saved in the internal Flash EPROM), 5 -> operation prohibited in RUN, 6 -> Backup cartridge present in the PLC, 7 -> writing fault in Flash EPROM.. Is used to set the parameters for the number of %MW to be saved. When this word is between 1 and 1000, the first 1000 %MW are transferred to the internal Flash EPROM. When this word is 0, only the application program contained in the internal RAM is transferred to the internal Flash EPROM. Any saved %MW are then erased. On a cold restart, this word is initialized to -1 if the internal Flash EPROM does not contain any %MW backup. Otherwise, it is initialized to the value of the number of saved words. When bit %S98 = 1, this word indicates the geographical address (module / channel) of the discrete input which replaces the pushbutton of the TSX SAZ 10 module : High order Module number Low order Channel number
%SW97
%SW98
___________________________________________________________________________ 3/13
B
System words %SW99 Function Discrete input address Description When bit %S99 = 1, this word indicates the geographical address (module / channel) of the discrete input which replaces the pushbutton on the centralized display block : High order Module number %SW108 No. of forced bits Forced analog channel counter Type of CPU fault Low order Channel number
Indicates the number of forced bits in the application. Normally at 0, it is updated by the bit forcing and unforcing system in the application memory. Indicates the number of forced analog channels.
%SW109
%SW124
The system writes in this word the last type of CPU fault found (these codes are not changed on a cold restart) : 16#30 : system code fault 16#60 to 64 : battery overload 16#90 : system interrupt fault : IT not anticipated 16#53 : time-out fault during I/O exchanges The system writes in this word the last type of blocking fault found : 16#DB0 : watchdog overflow 16#2258 : execution of the HALT instruction 16#DEF8 : execution of a JMP instruction to an undefined label 16#2XXX : execution of a CALL instruction to an undefined subroutine 16#0XXX : execution of an unknown function 16#DEFE : Grafcet with source or destination connector undefined 16#DEFF : floating point not implemented 16#DEF0 : division by 0, (1-->%S18) 16#DEF1 : error when transferring a character string (1-->%S15) 16#DEF2 : capacity overflow, (1-->%S18) 16#DEF3 : index overflow (1-->%S20) Instruction address which generated the blocking application fault. %SW126 contains the offset of this address %SW127 contains the base of this address
%SW125
%SW126 %SW127
___________________________________________________________________________ 3/14
44 B
Immediate values
Objects Base 10 integer Base 2 integer Base 16 integer Floating point Character string PL7-2/3 1234 L'10011110' H'ABCD' -1.32e12 (PL7-3) M'aAbBcB' PL7 Micro/Junior 1234 2#10011110 16#ABCD -1.32e12 'aAbBcC'
Labels
Label Li i = 0 to 999 %Li i = 0 to 999
Bits
Objects Input bit in rack Indexed input bit in rack Remote input bit Indexed remote input bit Output bit in rack Indexed output bit in rack Remote output bit Indexed remote output bit I/O fault bit in rack module fault bit channel fault bit Remote I/O fault bit module fault bit channel fault bit output channel trip bit output channel reset bit Internal bit Indexed internal bit System bit Step bit Macro-step bit Step bit i of macro-step j Input step bit of macro-step j Output step bit of macro-step j Bit j of internal word i Bit j of indexed internal word i PL7-2/3 Ixy,i Ixy,i (Wj) (PL7-3) RIx,y,i (PL7-3) RIx,y,i (Wj) (PL7-3) Oxy,i Oxy,i (Wj) (PL7-3) ROx,y,i (PL7-3) ROx,y,i (Wj) (PL7-3) Ixy,S / Oxy,S (PL7-3) RDx,y,i / ERRORx,y,i TRIPx,y,i RSTx,y,i Bi Bi(Wj) (PL7-3) SYi Xi XMj (PL7-3) Xj,i (PL7-3) Xj,I (PL7-3) Xj,O (PL7-3) Wi,j Wi(Wk),j(PL7-3) %MWi:Xj %MWi[%MWk]:Xj %I\<path>\<mod>.MOD.ERR %I\<path>\<mod>.<channel>.ERR PL7 Micro/Junior %I<rack_mod>.<channel> %I\<path>\<mod>.<channel> %Q<rack_mod>.<channel> %Q\<path>\<mod>.<channel>
%I<rack_mod>.MOD.ERR %I<rack_mod>.<channel>.ERR
___________________________________________________________________________ 4 / 1
Bit j of constant word i Bit j of indexed constant word i Bit j of register i Bit k of common word j of station i Bit j of system word i
%KWi:Xj %KWi[%MWk]:Xj
Words
Objects Single length internal word Indexed single length internal word Double length internal word Indexed double length internal word Real internal word Indexed real internal word Single length constant word Indexed single length constant word Double length constant word Indexed double length constant word Real constant word Indexed real constant word Single length input register word Double length input register word Single length output register word Double length output register word Remote input register word Remote output register word System word Common word j of station i OWxy,i IWxy,i CWi CWi(Wj) CDWi (PL7-3) CDWi(Wj) (PL7-3) PL7-2/3 Wi Wi(Wj) (PL7-3) DWi (PL7-3) DWi(Wj) (PL7-3) PL7 Micro/Junior %MWi %MWi[%MWj] %MDi %MDi[%MWj] %MFi %MFi[%MWj] %KWi %KWi[%MWj] %KDi %KDi[%MWj] %KFi %KFi[%MWj] %IW<rack_mod>.<channel> %ID<rack_mod>.<channel> %QW<rack_mod>.<channel> %QD<rack_mod>.<channel> RIWx,y,i (PL7-3) %IW\<path>\<mod>.<channel> ROWx,y,i (PL7-3)%QW\<path>\<mod>.<channel> SWi %SWi
COMi,j %NW{i}j COMXi,j (where X = B, C, D) %NW{[r.]i}j r = network no. STATUSAx,y,i (PL7-3) STATUSBx,y,i (PL7-3)
Status word of a remote discrete module channel STSx,y,i(PL7-3) %IW\<path>\<mod>.<channel>.ERR Active time of Grafcet steps Active time of step i of macro-step j Xi,V Xj,i,V (PL7-3) %Xi.T
___________________________________________________________________________ 4 / 2
Function blocks
Objects Timer preset value (word) current value (word) timer running (bit) timer done (bit) Monostable preset value (word) current value (word) monostable running (bit) Up/down counter preset value (word) current value (word) upcounting overrun (bit) preset done (bit) downcounting overrun (bit) Register input word (word) output word (word) register full (bit) register empty (bit) Text Drum controller number of active step (word) active time of current step (word) 16 command bits (word) last step in progress (bit) Fast Counter / Timer preset value (word) current value (word) external reset (bit) preset done (bit) counting in progress (bit) Real-time clock "WEEK" or "YEAR" type day selection MTWTFSS (word) start of active time period (word) end of active time period (word) current value < setpoint (bit) current value = setpoint (bit) current value > setpoint (bit) PL7-2/3 Ti Ti,P Ti,V Ti,R Ti,D Mi Mi,P Mi,V Mi,R Ci Ci,P Ci,V Ci,E Ci,D Ci,F Ri Ri,I Ri,O Ri,F Ri,E TXTi Di (PL7-2) Di,S Di,V Di,Wj Di,F FC (PL7-2) FC,P FC,V FC,E FC,D FC,F H (PL7-2) VD BGN END < = > PL7 Micro/Junior %Ti %Ti.P %Ti.V %Ti.R %Ti.D %MNi %MNi.P %MNi.V %MNi.R %Ci %Ci.P %Ci.V %Ci.E %Ci.D %Ci.F %Ri %Ri.I %Ri.O %Ri.F %Ri.E no text block %DRi %DRi.S %DRi.V %DRi.Wj %DRi.F -
___________________________________________________________________________ 4 / 3
B
Bit and word tables
Objects Bit strings Internal bit string Input bit string Output bit string Grafcet step bit string macro-step bit string Character strings Word tables internal word table indexed internal word table internal double word table indexed internal double word table constant word table indexed constant word table constant double word table indexed constant double word table real table indexed real table constant real table indexed constant real table remote input element table remote output element table remote input indexed element table remote output indexed element table PL7-2/3 Bi[L] Ixy,i[L] (PL7-3) Oxy.i[L] (PL7-3) Xi[L] (PL7-3) XMi[L] (PL7-3) PL7 Micro/Junior %Mi:L %Ixy.i:L %Qxy.i:L %Xi:L %MBi:L (1) (where i is even) Wi[L] Wi(Wj)[L] DWi[L] (PL7-3) DWi(Wj)[L] (PL7-3) CWi[L] CWi(Wj)[L] CDWi[L] (PL7-3) CDWi(Wj)[L] (PL7-3) %MWi:L %MWi[%MWj]:L %MDi:L %MDi[%MWj]:L %KWi:L %KWi[%MWj]:L %KDi:L %KDi[%MWj]:L %MFi:L %MFi[%MWj]:L %KFi:L %KFi[%MWj]:L
___________________________________________________________________________ 4 / 4
B
Instructions
Objects Instructions on bits Reverse logic AND OR Exclusive OR Rising edge Falling edge Set to 1 Reset to 0 Instructions on words and double words Addition Subtraction Multiplication Division Comparisons Division remainder Square root Absolute value Logic AND Logic OR Exclusive logic OR Logic complement Incrementation Decrementation Logic shift to left Logic shift to right Circular shift to left Circular shift to right Floating point instructions (1) Addition Subtraction Multiplication Division Square root Absolute value Equality test Strict superiority test Strict inferiority test Other tests PL7-2 PL7-3 NOT + RE FE SET RESET + + * * / / >, >=, <, <=, =, <> MOD REM SQRT AND OR XOR CPL AND OR XOR CPL INC DEC SHL SHR SLC SRC ADDF SUBF MULF DIVF SQRTF EQUF SUPF INFF PL7 Micro/Junior NOT AND OR XOR RE FE SET RESET + * / >, >=, <, <=, =, <> REM SQRT ABS AND OR XOR NOT INC DEC SHL SHR ROL ROR + * / SQRT ABS = > < >=, <=, <>
AND OR XOR
SLC SRC
___________________________________________________________________________ 4 / 5
B
Instructions (continued)
Objects Instructions on byte strings Circular shift Conversion instructions BCD to binary conversion Binary to BCD conversion ASCII to binary conversion Binary to ASCII conversion Gray to binary conversion Floating point to integer conversion Integer to floating point conversion BCD to floating point conversion Floating point to BCD conversion ASCII to floating point conversion Floating point to ASCII conversion Instructions on tables Arithmetic operations Logic operations Addition of words in a table Search for 1st different word Search for 1st equal word Instructions on program Jump Call for sub-routine Return from sub-routine Stop application Conditional phrase Iterative phrase Instructions on interruptions Test Masking Unmasking Acknowledgment Generation of an IT to module Explicit I/O instructions Read discrete inputs Write discrete outputs Read registers Write registers Read words Write words BCD BIN ATB BTA PL7-2 PL7-3 SLCWORD DTB BTD ATB BTA GTB FTB FTF DTF FTD ATF FTA +, -, *, /, REM AND, OR, XOR + EQUAL SEARCH JUMP Li BCD_TO_INT INT_TO_BCD STRING_TO_INT or STRING_TO_DINT INT_TO_STRING or DINT_TO_STRING GRAY_TO_INT REAL_TO_INT or REAL_TO_DINT INT_TO_REAL or DINT_TO_REAL BCD_TO_REAL REAL_TO_BCD STRING_TO_REAL REAL_TO_STRING +, -, *, /, REM AND, OR, XOR, NOT SUM EQUAL FIND_EQU PL7 Micro/Junior
JUMP %Li CALL SRi SRi RET RETURN HALT HALT IF/THEN/ELSE IF/THEN/ELSE/END_IF WHILE/DO WHILE/DO/END_WHILE READINT MASKINT DMASKINT ACKINT SETIT READBIT WRITEBIT READREG WRITEREG READEXT WRITEEXT
MASKEVT UNMASKEVT
___________________________________________________________________________ 4 / 6
B
Instructions (continued)
Objects Instructions on functions blocks Preset Start Activate task Reset Deactivate task Upcounting Downcounting Store in a register Retrieve from a register Receive a message Transmit a message Transmit/Receive message Execute an OFB Read telegrams PL7-3 PRESET Ti / Ci START Ti / Mi START CTRLi RESET Ci / Ri / TXTi RESET CTRLi UP Ci DOWN Ci PUT Ri GET Ri INPUT TXTi OUTPUT TXTi EXCHG TXTi EXEC <OFBi> READTLG PL7 Micro/Junior PRESET %Ti / %Ci START %Ti / %MNi RESET %Ci / %Ri UP %Ci DOWN %Ci PUT %Ri GET %Ri
Delimiters
Objects Assignment Left parenthesis for indexing Right parenthesis for indexing Length of table PL7-2/3 -> ( ) [length] PL7 Micro/Junior := [ ] :length
___________________________________________________________________________ 4 / 7
___________________________________________________________________________ 4 / 8
5.1
Reserved words
AUX BCD_TO_INT BIT_D BIT_W BLK BLOCK BODY BOOL BOTTOM BTI BTR BY BYTE C CAL CALC CALCN CALL CALL_COIL CANCEL CASE CD CHART CH_M CLK CLOSE CLOSED_CONTACT COIL COMMAND COMMENTS COMP4 COMPCH CONCAT CONF CONFIGURATION CONSTANT CONTROL_LEDS COPY_BIT COS CTD CTU CTUD
CU D DATE DATE_AND_TIME DAT_FMT DAY_OF_WEEK DA_TYPE DEACTIVATE_PULSE DEC DELETE DELTA_D DELTA_DT DELTA_TOD DINT DINT_TO_REAL DINT_TO_STRING DISPLAY_ALRM DISPLAY_GRP DISPLAY_MSG DIV DMOVE DO DOWN DRUM DS DSHL_RBIT DSHRZ_C DSHR_RBIT DSORT_ARD DSORT_ARW DT DTS DWORD D_BIT E EBOOL ELSE ELSIF EMPTY EMPTY_LINE END ENDC
___________________________________________________________________________ 5 / 1
B
ENDCN JMPC FIND_LTD END_ACTION JMPCN FIND_LTW END_BLK JUMP FOR END_BLOCK JUMP_COIL FROM END_CASE L FUNC END_COMMENTS LAD FUNCTION END_CONFIGURATION LANGAGE FUNCTION_BLOCK END_FOR LANGUAGE F_B END_FUNCTION LD F_EDGE END_FUNCTION_BLOCK F_TRIG LDF END_IF LDN GE END_MACRO_STEP LDR GET END_PAGE LE GET_MSG END_PHRASE LEFT GET_VALUE END_PROG LEN GLOBAL_COMMENT END_PROGRAM LIFO GR7 END_REPEAT LIMIT GRAY_TO_INT END_RESOURCE LINT GT END_RUNG LIST GTI END_STEP LIT H END_STRUCT LN HALT END_TRANSITION LOCATION HALT_COIL END_TYPE LOG HASH_COIL END_VAR LREAL H_COMPARE END_WHILE LT H_LINK EQ LWORD I EQUAL M IF ERR MACRO_STEP IL EVT MAIN IN EXCHG MASKEVT INC EXCH_DATA MAST INCJUMP EXIT MAX INDEX_CH EXP MAX_ARD INFO EXPT MAX_ARW INITIAL_STEP F MAX_PAGES INIT_BUTTONS FALSE MAX_STEP INPUT FAST MCR INPUT_CHAR FBD MCR_COIL INSERT FE MCS INT FIFO MCS_COIL INTERVAL FIND MID INT_TO_BCD FIND_EQ MIN INT_TO_REAL FIND_EQD MIN_ARD INT_TO_STRING FIND_EQW MIN_ARW ITB FIND_GTD MOD ITS FIND_GTW MONO JMP ___________________________________________________________________________ 5 / 2
B
MOVE MPP MPS MRD MS MUL MUX M_CH M_MACRO_STEP N N1 NAME NB_ACTIVE_STEPS NB_ACTIVE_TIME NB_BLOCKS NB_COMMON_WORDS NB_CONSTANT_WORDS NB_CPT NB_DRUM NB_INTERNAL_BITS NB_INTERNAL_WORDS NB_MACRO_STEPS NB_MONO NB_PAGES NB_REG NB_TIMER NB_TM NB_TRANSITIONS NE NIL NO NON_STORED NOP NOT NOT_ARX NOT_COIL NOT_READABLE NO_GR7 NO_PERIOD N_CONTACT O OCCUR OCCUR_ARD OCCUR_ARW OF ON OPEN OPEN_CONTACT OPERATE OR ORF ORN ORR OR_ARX OTHERS OUT OUTIN_CHAR OUTPUT OUT_BLK P P0 P1 PAGE PAGE_COMMENT PANEL_CMD PERIOD PHRASE PHRASE_COMMENT PID PID_MMI PLC POST PRESET PRINT PRINT_CHAR PRIO0 PRIO1 PRIORITY PRL PROG PROGRAM PROG_LANGAGE PROG_LANGUAGE PT PTC PUT PV PWM P_CONTACT Q QUERY R R1 RCV_TLG RE READ READ_EVT_UTW READ_ONLY READ_PARAM READ_STS READ_VAR READ_WRITE REAL REAL_TO_DINT REAL_TO_INT REAL_TO_STRING REG REM REPEAT REPLACE RESET RESET_COIL RESOURCE RESTORE_PARAM RET RETAIN RETC RETCN RETURN RET_COIL RIGHT ROL ROL_ARD ROL_ARW ROR ROR_ARD ROR_ARW RRTC RS RTB RTC RTS RUNG R_EDGE R_TRIG
___________________________________________________________________________ 5 / 3
B
STOP UP S STR USINT S1 STRING USORT_ARD SAVE_PARAM STRING_TO_DINT USORT_ARW SCHEDULE STRING_TO_INT UTIN_CHAR SD STRING_TO_REAL VAR SEARCH STRUCT VAR_ACCESS SEL SUB VAR_EXTERNAL SEMA SUB_DT VAR_GLOBAL SEND SUB_TOD VAR_INPUT SENDER SUM VAR_IN_OUT SEND_ALARM SU_TYPE VAR_OUTPUT SEND_MBX_ALARM S_T_AND_LINK VERSION SEND_MBX_MSG S_T_OR_LINK V_COMPARE SEND_MSG T V_LINK SEND_REQ TAN W SEND_TLG TASK WHILE SERVO TASKS WITH SET THEN WORD SET_COIL TIME WRITE SFC TIMER WRITE_CMD SHIFT TIME_OF_DAY WRITE_PARAM SHL TMAX WRITE_VAR SHOW_ALARM TMOVE WRTC SHOW_MSG TO WSHL_RBIT SHOW_PAGE TOD WSHRZ_C SHR TOF WSHR_RBIT SHRZ TOFF W_BIT SIN TON XM SINGLE TOP XM_MONO SINT TP XM_MULTI SL TRANSITION XOR SLCWORD TRANS_TIME XORF SMOVE XORN SOFT_CONFIGURATION TRUE TRUNC XORR SORT TYPE XOR_ARX SORT_ARD TYPES YES SORT_ARW T_S_AND_LINK SQRT T_S_OR_LINK SR U ST UDINT STANDARD UINT START ULINT STD UNMASKEVT STEP UNTIL STI STN ___________________________________________________________________________ 5 / 4
Section 6
6 Conformity to IEC standard 1131-1
6/1
B
1 1 1 1 2 2 3 4 4 4 4 4 4 4 5 6 6 6 6 6 6 3a 4a 5a 6a 1 2 1 1 2 3 4 6 7 8 1 2 3 4 5 6 7 Number sign (#) Dollar sign ($) Vertical bar (|) Subscript delimiters: Left and right brackets "[]" Upper case and numbers Upper and lower case, numbers, embedded underlines Comments Integer literals (Note 1) Real literals (Note 1) Real literals with exponents Base 2 literals (Note 1) Base 16 literals (Note 1) Boolean Zero and One Boolean TRUE and FALSE Character string literal features $$ Dollar sign $' Single quote $L or $l Line feed $N or $n New line $P or $p Form feed (page) $R or $r Carriage return
6/2
B
6 7 10 10 10 10 10 10 10 10 10 10 15 8 1a 1 10 12 13 14 15 16 17 18 19 1 2 3 15 4 5 6 7 8 $T or $t Tab Duration literals with short prefix t# (Note 2) BOOL -1 bitREAL -32 bitsTIME -32 bits- (Note 3) DATE -32 bits- (Note 3) TIME_OF_DAY -32 bits- (Note 3) DATE_AND_TIME -64 bits- (Note 3) STRING BYTE -8 bitsWORD -16 bitsDWORD -32 bitsI prefix for Input location Q prefix for Output location M prefix for Memory location X prefix, single bit size None prefix, single bit size B prefix, byte size (8 bits) W prefix, word size (16 bits) D prefix, double word size (32 bits)
6/3
B
16 VAR_EXTERNAL VAR_GLOBAL CONSTANT AT 21 1 The PL7 overloaded functions are as follows: ABS, EQUAL, ROL, ROR, SHL, SHR, SQRT, SUM 21 2 In general, the PL7 functions belong to this category (typed functions). Type conversion functions: DINT_TO_STRING, INT_TO_STRING, STRING_TO_DINT, STRING_TO_INT, DATE_TO_STRING, DT_TO_STRING, TIME_TO_STRING, TOD_TO_STRING, REAL_TO_STRING, STRING_TO_REAL, REAL_TO_INT, REAL_TO_DINT, INT_TO_REAL, DINT_TO_REAL (Note 5) Conversion function BCD_TO_INT (Note 6) Conversion function INT_TO_BCD (Note 6) ABS function: absolute value SQRT function: square root SHL function: shift left SHR function: shift right ROR function: rotate right ROL function: rotate left LEN function: string length LEFT function: leftmost n characters Keywords (Note 4)
22
22 22 23 23 25 25 25 25 29 29
3 4 1 2 1 2 3 4 1 2
6/4
B
29 29 29 29 29 29 29 32 3 4 5 6 7 8 9 Input read Input write Output read Output write 33 1 RETAIN qualifier on internal variables of the predefined function blocks (Note 9) RETAIN qualifier on outputs of the predefined function blocks (Note 9) Pulse timer: TP (Note 10) On-delay timer: TON (Note 10) Off delay timer: TOF (Note 10) TP, TON, TOF Use of directly represented variables (address) Step, graphical form Note: A step number replaces a step identifier RIGHT function: rightmost n characters MID function: n characters from a given position CONCAT function: extensible concatenation (Note 7) INSERT function: insert one string into another DELETE function: delete characters REPLACE function: replace characters FIND function: find one string inside another (Note 8)
33
37 37 37 38 39 40
1 2a 3a timing diagrams 19 1
6/5
B
40 2 Step, textual form used in the source form of Grafcet only Declarations of actions in LD language Note: PL7 Junior does not implement action blocks 46 46 1 2c Single sequence, alternation step/transition Or divergence: user ensures that the transition conditions are mutually exclusive Or convergence And divergence And convergence 46 46 46 5c 6c 7 Sequence jump in an or divergence Sequence loop: return to a previous step Directional arrows Note: Directional arrows point up and down 48 40 42 46 57 50 5b Preemptive scheduling with the multi-tasks model Graphic representation Note: Grafcet is very similar to the 1131-3 SFC language, but cannot however claim to conform (features 41, 43, 45 are missing)
42
2l
46 46
3 4
Note 1: The underline characters (_) inserted between the digits of a numerical literal are not accepted Note 2: These literals are only visible in the application source, to show the time of configured tasks.
6/6
B
Note 3: These types of data are not yet implemented in a manner visible to the user. This table defines, however, the memory occupation of their internal representation. Note 4: These key words are only used in the sources generated by PL7 and by the PL7-2 application conversion tool. Note 5: Effects of conversions to limits: DINT_TO_STRING: If the string accepting the result is less than 13 characters, truncation occurs and %S15 is set. INT_TO_STRING: If the string accepting the result is less than 7 characters truncation occurs and %S15 is set. STRING_TO_DINT and STRING_TO_INT: If the string cannot be converted to an integer, the result is indeterminate and %S18 is set. DATE_TO_STRING If the string accepting the result is less than 11 characters truncation occurs and %S15 is set. DT_TO_STRING: If the string accepting the result is less than 20 characters truncation occurs and %S15 is set. TIME_TO_STRING: If the string accepting the result is less than 15 characters truncation occurs and %S15 is set. TOD_TO_STRING: If the string accepting the result is less than 9 characters truncation occurs and %S15 is set. REAL_TO_STRING: If the string accepting the result is less than 15 characters truncation occurs and %S15 is set. STRING_TO_REAL: If the string cannot be converted to a real value, the value of the result is "1.#NAN" (16#FFC0_0000) and %S18 is set. REAL_TO_INT: If the real cannot be converted within the limits [-32768, +32767], the value of the result is -32768 and %S18 and %SW17:X0 are set. REAL_TO_DINT: If the real cannot be converted within the limits[-2147483648, +2147483647], the value of the result is -2147483648 and %S18 and %SW17:X0 are set. INT_TO_REAL: Conversion is always possible. DINT_TO_REAL: Conversion is always possible. Note 6: As the type INT is not formally implemented, even though it is still used, these functions enable the coding format of a WORD to be changed. Note 7: Limit the CONCAT function to the concatenation of 2 strings. Note 8: This paragraph applies to the predefined PL7 function blocks. Note 9: The RETAIN qualifier is implicit. Note 10: The timers TP, TON, TOF respect the timing diagrams of table 38, but have a different I/O interface from that of 1131-3.
6/7
B
Table n 51 52 52 52 52
o
IL language elements
Feature n
o
Description of features Label, operator, operand, comment LD ST S and R AND OR XOR JMP RET ) IN (Note 11) IN (Note 11) IN (Note 11)
Instruction fields 1 2 3 4 6 7
52 52 52 54 54 54
18 20 21 11 12 13
Note 11: The operator PT is not implemented. ST language elements (Note 12)
Table no 55 55 55 Feature no 1 2 5 Description of features Place in parentheses Function evaluation NOT
6/8
B
55 6 7 55 9 10 55 55 55 55 55 55 56 56 56 56 56 56 56 11 12 13 15 16 17 1 3 4 6 7 8 9 * Multiply / Divide + Add - Subtract <, >, <=, >= Comparison = Equality <> Inequality Boolean AND XOR Boolean Exclusive or Boolean OR := Assignment RETURN structure IF structure "if... then... elsif... then... else... end_if" FOR structure "for... to... do... end_for" (Note 13) WHILE structure "while... do... end_while" REPEAT structure "repeat ... until... end_repeat" EXIT structure
Note 12: This language is used entirely in ST modules. An ST subset is also used in the OPERATE and COMPARE blocks of IL and LD languages. Note 13: Implementation of the FOR loop with an implicit step of 1 (by 1).
6/9
LD language elements
Table no 59 59 60 60 61 61 61 61 Feature no 1 2 1 2 1 3 5 7 Description of features Left power rail Right power rail Horizontal link Vertical link Open contact Closed contact Positive transition-sensing contact Negative transition-sensing contact
6/10
B
62 62 62 62 1 2 3 4 Coil Negated coil SET (latch) coil RESET (unlatch) coil
6/11
B
Implementation-dependent parameters
Parameter Procedure for processing errors PL7 limitations and behavior Numerous errors are indicated on execution with system bits and words. #, $, | Maximum length of identifiers Maximum length of comment Range of values of duration Range of values for variables of type TIME Precision of representation of seconds in types TIME_OF_DAY and DATE_AND_TIME Maximum number of array subscripts Maximum number of array 32 222 (Note 14) (Note 14) (Note 15)
1 (Note 16) Depending on the indexed area (Note 16) Not applicable 255 3 Logical mapping Depending on the indexed area (Note 16)
Default maximum length of STRING variables Maximum permitted length of STRING variables Maximum number of hierarchical levels Logical or physical mapping Maximum range of subscript values
6/12
B
Initialization of system inputs Effects of type conversions on accuracy Precision on time elapsed associated with a step Maximum number of steps per chart Initialized to zero by the system. See table 22, feature 1 100ms 96 on PLC 3710 v1.5 128 on PLCs 3720 v1.5, 5710 and 5720 Maximum number of transitions per chart and per step 1024 transitions per chart 11 transitions per step Action control mechanism Maximum number of action blocks per step P0, P1 and N1 qualifiers 3 actions are possible: on activation (P1), continuous (N1) and on deactivation (P0) Active step in reverse video Clearing time is variable and is never zero Limited by the entry grid TSX 3710, 3720, 5710, 5720 2 periodic tasks 8 event-triggered tasks Task interval resolution Preemptive or non-preemptive scheduling From 1 ms to 255 ms Preemptive scheduling
Graphic indication of step status Transition clearing time (deactivation of upstream steps and activation of downstream steps) Depth of divergent and convergent constructions List of PLCs which can be programmed by PL7 Junior Maximum number of tasks
6/13
B
Maximum length of an expression Partial evaluation of Boolean expressions Maximum length of control structures in ST Variable No Variable
Value of control variable after execution of a FOR loop The value of the control variable equals the value of the limit + 1 (since the step is 1) Graphic/semi-graphic representation Restrictions on network topology Graphic representation An LD network can occupy a maximum of 11 columns and 7 lines
Note 14: These types of data are not yet implemented in a manner visible to the user. This table, however, defines their ranges of values in IEC 1131-3 format. TIME: from T#0 to T#429496729.5s TIME_OF_DAY: from TOD#0:0:0 to TOD#23:59:59 DATE_AND_TIME: from DT#1990-01-01:0:0:0 to DT#2099-12-31:23:59:59 DATE: from D#1990-01-01 to D#2099-12-31 Note 15: Rounding is performed as follows: x.0 s to x.4 s, are rounded to x s and x.5 s to x.9 s are rounded to x+1 s. Note 16: It is possible to index all types of directly represented variables positively and negatively within the limit of their respective maximum number defined in configuration.
6/14
B
Error conditions
Error conditions Type conversion errors PL7 limitations and behavior Indicated during the with a system bit: see table Common elements: table 22, feature 1 Indicated during the execution with system bit %S18 Indicated during the execution with system bit %S18 Indicated during the execution with system bit %S15 Detected during programming Indicated on execution with system bit %S19 Detected during configuration Detected during programming if possible, otherwise indicated on execution with system bit %S18 The PLC goes to watchdog overflow fault and the CPU involved is indicated
Other task scheduling conflicts Division by zero Type of data invalid for an operation Failure of a FOR or WHILE iteration to finish
6/15
6/16
Section 7
1
7.1
Boolean instructions Accumulator or rung initialization Test (read) direct, negated, rising edge, falling edge AND logic
IL
P P P
AND
ANDN
ANDR AND(R
ANDF
OR logic direct, negated, rising edge, falling edge Inversion Exclusive OR logic (direct, negated, rising edge, falling edge) Write (direct, negated) Set to 1 Set to 0 Operation block (for contents see following pages) Horizontal comparison block (for contents see following pages) Vertical comparison block
P P
N N
ORR
ORF
OR(N
OR(R
OR(F
XORN XORF
(/)
(S)
(R)
ST STN S R [action] LD AND AND( OR OR( XOR [comparison] [comparison] [comparison] [comparison] [comparison] [comparison]
OPERATE action
C MAE O PR co pa n m riso
7/1
B
Boolean instructions Assignment Boolean OR Boolean AND Boolean Exclusive OR Negation Rising, falling edge Set to 1, set to 0 Function blocks IEC timer PL7-3 timer
E C
IL IN BLK..END_BLK structure
Up/down counter
Monostable Register
%MNi S R
%Ri
R
F E
I O
Drum
%DRi R F U
Function blocks IEC timer PL7-3 timer START %TMi DOWN %TMi PRESET %Ti START %Ti STOP %Ti RESET %Ci PRESET %Ci UP %Ci, DOWN %Ci START %MNi RESET %Ri PUT %Ri GET %Ri RESET %DRi UP %DRi
Up/down counter
Monostable Register
Drum
7/2
B
Control structures Conditional action ST IF...THEN... ELSIF...THEN... ELSE...END_IF; WHILE...DO...END_WHILE; REPEAT...UNTIL...END_REPEAT; FOR...DO...END_FOR; EXIT LD/IL/ST := = <> <= < > >= + - * / REM AND OR XOR NOT ABS SQRT INC DEC SHL SHR ROL ROR LD/IL/ST := = <> <= < > >= + - * / ABS SQRT LD/IL/ST BCD_TO_INT GRAY_TO_INT INT_TO_BCD INT_TO_REAL DINT_TO_REAL REAL_TO_INT REAL_TO_DINT DBCD_TO_DINT DINT_TO_DBCD DBCD_TO_INT INT_TO_DBCD
Conditional iterative action Conditional iterative action Repetitive action Loop output instruction Arithmetic operations on integers (single and double length) Transfer or initialization Comparisons Addition, subtraction, multiplication, division, remainder AND, OR, exclusive OR, complement Absolute value Square root Increment Decrement Shift to the left Shift to the right Rotate shift to the left Rotate shift to the right Arithmetic operations on floating points Transfer or initialization Comparisons Addition, subtraction, multiplication, division Absolute value Square root Numeric conversions
Convert BCD to single length integer Convert GRAY to single length integer Convert single length integer to BCD Convert single length integer to floating point Convert double length integer to floating point Convert floating point to single length integer Convert floating point to double length integer Convert 32-bit BCD to 32-bit integer Convert 32-bit integer to 32-bit BCD Convert 32-bit BCD to 16-bit integer Convert 16-bit integer to 32-bit BCD
7/3
B
Bit tables Transfer or initialization Copy a bit table into a bit table AND between two tables OR between two tables Exclusive OR between two tables Negation on a table Copy a bit table into a word table Copy a bit table into a double word table Copy a word table into a bit table Copy a double word table into a bit table Instructions on tables Transfer and initialization Arithmetic operations between tables Logic operations between tables Arithmetic operations between a table and an integer Logic operations between a table and an integer Complement of the elements of a table Sum of all the elements of a table Comparison of two tables Find 1st element of a table equal to a value Find 1st element of a table greater than a value Find 1st element of a table less than a value Find highest value in a table Find lowest value in a table Number of occurrences of a value in a table Rotate shift a table to the left Rotate shift a table to the right Sort a table (ascending or descending) Instructions on floating point tables Transfer and initialization := := COPY_BIT AND_ARX OR_ARX XOR_ARX NOT_ARX BIT_W BIT_D W_BIT D_BIT LD/IL/ST := + - * / REM AND OR XOR + - * / REM AND OR XOR NOT SUM EQUAL FIND_EQW, FIND_EQD FIND_GTW, FIND_GTD FIND_LTW, FIND_LTD MAX_ARW, MAX_ARD MIN_ARW, MIN_ARD OCCUR_ARW, OCCUR_ARD ROL_ARW, ROL_ARD ROR_ARW, ROL_ARW SORT_ARW, SORT_ARD LD/IL/ST LD/IL/ST
7/4
B
"Orphee" instructions Shift to the left on word with recovery of shifted bits Shift to the right on word with sign extension and recovery of shifted bits Shift to the right on word with filling with 0 and recovery of shifted bits Up/down counting with indication of overshoot LD/IL/ST WSHL_RBIT, DSHL_RBIT WSHR_RBIT, DSHR_RBIT WSHRZ_C, DSHRZ_C SCOUNT
Explicit exchanges Read %M parameters of a logic channel Read status %M of a logic channel Restore %M parameters of a logic channel Save %M parameters of a logic channel Write control %M of a logic channel Write %M parameters of a logic channel Time management instructions Comparisons Transfer Read date and code of last PLC stop Read system date Update system date Add a time to a full date Add a time to a time of day Convert date to string Day of the week Difference between two dates Difference between two full dates Difference between two times of day Convert full date to string Subtract a time from a full date Subtract a time from time of day Convert time to string Convert time of day to string Change time to hours-min-sec format
LD/IL/ST READ_PARAM READ_STS RESTORE_PARAM SAVE_PARAM WRITE_CMD WRITE_PARAM LD/IL/ST = <> <= < > >= := PTC RRTC WRTC ADD_DT ADD_TOD DATE_TO_STRING DAY_OF_WEEK DELTA_D DELTA_DT DELTA_TOD DT_TO_STRING SUB_DT SUB_TOD TIME_TO_STRING TOD_TO_STRING TRANS_TIME
7/5
B
Instructions on character strings Comparisons Transfer Convert double integer to string Convert single integer to string Convert string to double integer Convert string to single integer Convert string to floating point Convert floating point to string Concatenate two strings Delete substring Find first different character Find substring Insert substring Extract left part of a string Length of a string Extract substring Replace substring Extract right part of a string Multitasks and events Task activation / deactivation Adjust task cycle time Global masking of events Global unmasking of events Communication Request to stop a function in progress Send and/or receive data Request to read character string Send and/or request to receive a character string Send character string Receive telegram Read basic language objects Send/receive UNI-TE requests Send telegram Write basic language objects LD/IL/ST = <> <= < > >= := DINT_TO_STRING INT_TO_STRING STRING_TO_DINT STRING_TO_INT STRING_TO_REAL REAL_TO_STRING CONCAT DELETE EQUAL_STR FIND INSERT LEFT LEN MID REPLACE RIGHT LD/IL/ST %Si position %SWi position MASKEVT UNMASKEVT LD/IL/ST CANCEL DATA_EXCH INPUT_CHAR OUT_IN_CHAR PRINT_CHAR RCV_TLG READ_VAR SEND_REQ SEND_TLG WRITE_VAR
7/6
B
Integrated MMI Blocking entry of a variable on the CCX17 Dynamic assignment of keys on screen border Command to control LEDs on front panel of CCX17 Multiple entry of a variable on the CCX17 Send command to the CCX17 Display alarm message in PLC memory Display message in PLC memory Basic PID control Mixed PID controller Management of CCX17 dedicated MMI for controlling PID loops. Pulse width modulation of a numeric value PID output stage for controlling discrete valve PID PID_MMI PWM SERVO LD/IL/ST ASK_MSG ASSIGN_KEYS CONTROL_LEDS GET_MSG PANEL_CMD SEND_ALARM SEND_MSG LD/IL/ST
7/7
7/8
Section 8
1
8. Performance
8.1
General
This section calculates for TSX 37/57 PLCs : the execution time of the application program, the memory size of the application program.
Execution time of the application program The execution time of the program is calculated using the tables on the following pages, by adding up the time taken for each program instruction. Note : the time obtained is a maximum time. In fact, an operate block or a subroutine will only be processed if the execution condition (logic equation conditioning the execution of the block or subroutine) is true. It may be, therefore, that the actual time is much less than the maximum time calculated. Calculating the complete cycle time involves parameters which are specific to the PLC (overhead time, duration of I/O exchange, etc.). Please refer to the installation manual of the PLC (performance section) for the complete calculation procedure.
Application memory size The size of the application is the sum of the following elements : Element Program Calculation method Add up each of the program instructions, (see tables in sections 8.2 and 8.3). and multiply by the coefficient which corresponds to the language used (see next page) See section 8.4.4 See section 8.4.2 See section 8.4.3
8/1
B
In the tables on the following pages, information on sizes refers to the volume of instruction codes. In order to find out the total size of an instruction or a program, it is necessary to use a multiplication coefficient which takes account of information that is typical to a language (for example : graphic information in the case of Ladder language). Ladder language : Total volume = 1.7 x Code volume Structured Text language : Total volume = 1.6 x Code volume Instruction List language : - for TSX37 PLCs : Total volume = 1.4 x Code volume - for TSX57 PLCs : Total volume = 1.6 x Code volume Grafcet language : The volume associated to the chart itself is as follows : Chart volume (in words) = 214 + 17 * no. of chart steps + 2 * total no. of configured steps + 4 * no. of programmed actions
NB : program comments occupy 1 byte per character. Note The figures shown in the following tables are average estimations obtained from a typical application. It is not possible to provide exact data, since PL7 optimizes memory use according to the contents and structure of the application. Section 8.4.1 describes the various memory zones occupied by the application.
8/2
Performance 8
8.2 TSX 37 performance
LD,
%M1 (1)
LDN %M1[%MW2] %MW0:X0 (2) %IWi.j:Xk (3) %MW0[%MW10]:X0 %KW0[%MW10]:X0 %M1 13.10 6.06 77.04 16.29 87.27 0.50 12.85 5.75 69.25 15.55 79.05 0.25 12.85 5.75 69.25 15.55 79.05 0.38 7 4 8 8 12 2
LDR,
LDF %M1[%MW2] , , ... , , ... XOR, XORN %M1 %M1[%MW2] %MW0:X0 %IWi.j:Xk %MW0[%MW10]:X0 %KW0[%MW10]:X0 %M1 %M1[%MW2] %M1 1.25 26.94 12.86 83.84 33.33 104.3 1 2.25 27.28 0.50 0.63 26.08 11.88 75.38 31.48 94.98 1.13 26.13 0.25 0.94 26.26 12.06 75.56 31.66 95.16 1.69 26.44 0.38 5 13 10 14 14 18 9 19 2 AND, ANDN , AND (, AND (N , idem OR ANDR, ANDF, AND (R, AND (F, idem OR Idem LDR LDF 13.01 idem 12.75 LD, 12.75 LDN 7
%M1[%MW2] %MW0:X0 %NW{i}j:Xk (3) %MW0[%MW10]:X0 nd multiple coils in Ladder, "cost" of the 2 and subsequent coils operation block [ action] block executed not executed
7 4 8 8 1 1 1
(1) This concerns all the forceable bit objects : %I, %Q, %X, %M, %S (2) Other objects of the same type : output bits of function block %TMi.Q ..., system word extract bits %SWi:Xj (3) Other objects of the same type: common word extract bits %NW{i}j:Xk, I/O word extract bits %IWi.j.Xk, %QWi.j.Xk, extract bits of %KW, fault bits %Ii.j.ERR
8/3
B
LD IL ST Objects Execution time (s) 3710 3720 3720 ram cart 0.00 0.00 0.00 12.38 0.25 ladder, 1 divergence MPS, MPP, MRD list MPS+MPP list MRD 0.25 0.75 0.25 11.85 0.13 0.13 0.38 0.13 11.85 0.19 0.19 0.56 0.19 Size (words) 37xx 0 4 1 1 3 1
horizontal comparison block vertical comparison block convergence divergence not followed by a convergence
LD [comparison]
IE timer
rising edge on IN falling edge on IN IN =1 IN =0 IN %TM1 START %TM1 (rising edge) IN %TM1 DOWN %TM1 (falling edge) IN %TM1 (=1) IN %TM1 (=0) start timer stop timer timer on timer off 43.39 17.47 18.74 17.40 41.11 17.01 17.99 16.67 3
PL7-3 timer
START %T1 STOP %T1 E=0 RESET %T1 enable freeze reset timer on timer off 12.63 12.94 17.55 12.15 12.15 17.00 3
Up/down counter
reset, R=1 preset, S=1 rising edge on CU rising edge on CD inactive inputs R %C8 (=1) S %C9 (=1) RESET %C8 reset 18.69 20.42 19.92 19.92 13.27 17.92 19.73 19.10 19.10 12.81 3 PRESET %C9 preset up down no action
CU %C8 UP %C8 (rising edge) CD %C9 DOWN %C9 (rising edge) R/S/CU/CD inactive bit
8/4
Performance 8
Function blocks (continued)
LD IL ST objects/conditions Execution time (s) Size (words) 3710 3720 37xx
Monostable
rising edge on S S=1 S %MN0, START %MN0 start rising edge S %MN0, S=1/0 active monostable 35.08 11.64 33.16 11.17 3
Register
edge on I edge on O R=1 inactive inputs I %R2 (edge) PUT %R2 store retrieve reset no action 21.90 21.90 16.90 12.61 21.27 21.27 16.02 12.19 3 O %R2 (edge) GET %R2 R %R1 (=1) I/O/R, inactive bit RESET %R2
Drum
edge on U U %DR0 UP %DR1 up, fixed by control bit R=1 R %DR1 RESET %DR2 reset, fixed by control bit inactive inputs R/U, bit inactive no action, fixed by control bit 181.37 19.30 174.15 19.30 175.92 19.30 169.13 19.30 162.03 19.30 164.00 19.30 3
8/5
11.20
10.60
13.37
12.60
Value to add for objects of the following type : %KWi, %KWi[%MW0], %KDi, %KFi, common words, I/O words
70.98 63.50 2
Correction according to the context of the operation Value to add if the operation is in at least the 2nd position in the phrase, example *%MW2 in := %MW0 * %MW1 * %MW2, concerns the following operations
%MW0 %MD0 and %MF0 0.69 0.99 0.55 0.75 0 0
Value to add for an operation with the result of an operation in parentheses or of a higher priority, example : %MW0 + %MW2 + (...)
%MW0 %MD0 and %MF0 2.86 3.60 2.55 3.15 1 1
8/6
Performance 8
B
ST Objects Conditions 3710 object after the := %MW0 %MD0,%MF0 := %MW0 %MD0 %MF0 %MW0 %MD0 %MF0 AND, OR, XOR %MW0 %MD0 +, %MW0 %MD0 %MF0 * %MW0 %MD0 %MF0 /, REM %MW0 %MD0 / ABS, -object %MF0 %MW0 %MD0 %MF0 NOT %MW0 %MD0 SQRT %MW0 %MD0 %MF0 INC, DEC %MW0 %MD0 SHL, SHR, ROL, %MW0 ROR %MD0 for 1 bit for 1 bit per additional bit and 4.81 6.45 4.46 5.15 8.94 10.71 29.06 7.29 9.21 7.29 9.21 62.83 9.75 39.63 58.26 10.69 205.21 62.47 7.20 9.97 13.01 6.69 7.80 17.02 85.73 165.04 4.86 5.20 17.74 20.58 Execution time (s) 3720 4.50 5.70 4.30 4.85 8.50 10.26 28.39 6.90 8.55 6.90 8.55 61.20 9.10 36.50 56.90 10.08 201.38 60.25 6.95 9.53 12.50 6.45 7.40 16.70 85.25 158.40 4.40 4.75 17.05 19.15 0.063 Size (words) 37xx 2 2 2 2 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 5 5
8/7
if <cond > then <action> the times and volumes indicated below end_if; should be added to those of the action contained in the structure true condition false condition (jump) If <cond> then <action1> else <action2> end_if; true condition false condition while <cond> do.<action> end_while go to loop with loop-back exit loop repeat <action> until <cond> end_repeat go to loop with loop-back last pass for <word1:=word2> to <word3> do <action> end_for entry to the for command, executed once only go to loop with loop-back exit loop
3.60 5.55
3.30 5.40
9.15 5.55
8.70 5.40
9.15 5.55
8.70 5.40
5.55 3.60
5.40 3.30
15
8/8
Performance 8
B
8.2.6 Numeric conversions
ST Execution time Volume (s) (words) 3710 3720 ram 3720 cart 37xx 25.03 21.66 36.98 40.90 33.32 58.75 44.59 1 324.85 1 265.54 1 124.85 564.85 24.55 21.15 36.55 40.75 32.55 58.55 44.05 1 065.15 925.70 825.15 445.15 24.55 21.15 36.55 40.75 32.55 58.55 44.05 1 134.70 986.15 879.10 474.40 3 3 3 3 3 3 3 5 5 5 5
BCD_TO_INT INT_TO_BCD GRAY_TO_INT INT_TO_REAL DINT_TO_REAL REAL_TO_INT REAL_TO_DINT DBCD_TO_DINT DBCD_TO_INT DINT_TO_DBCD INT_TO_DBCD
8/9
B
ST conditions 3710 Execution time Volume (s) (words) 3720 ram 3720 cart 37xx
8/10
Performance 8
B
8.2.8 Word, double word and floating point tables
ST conditions Execution time (s) 3710 3720 ram volume (words) 3720 cart 37xx
8/11
B
ST conditions Execution time (s) 3710 3720 ram 3720 cart Volume (words) 37xx
* %MW0:10 :=%MW20*%MW10:10; 10 words per word %MD0:10:=%MD20*%MD10:10; 10 double words per double word /, REM %MW0:10 :=%MW10:10 / %MW30; 10 words per word %MD0:10:=%MD10:10 / %MD30; 10 double words per double word AND, OR, XOR %MW0:10 :=%MW10:10 AND %MW20; 10 words per word %MD0:10:=%MD20*%MD10:10; 10 double words per double word NOT %MW0:10 :=NOT(%MW10:10); 10 words per word %MD0:10:=NOT(%MD10:10); 10 double words per double word 110.28 2.96 126.39 4.50 100.25 2.75 114.00 4.05 100.25 2.75 114.00 4.05 9 9 117.20 2.64 587.01 6.47 106.45 2.40 522.95 6.15 106.45 2.40 522.95 6.15 12 12 196.69 10.86 155.85 7.30 155.85 7.30 12 12 166.86 7.94 587.01 49.18 132.45 5.05 522.95 43.80 132.45 5.05 522.95 43.80 12 12
8/12
Performance 8
B
ST conditions Execution time (s) 3710 3720 ram 3720 cart Volume (words) 37xx
Search
%MW20 := FIND_EQW(%MW0:10,%KW0) %MD20 := FIND_EQD(%MD0:10, %KD0) 10 words, max. instance 10 double words, max. instance 340.00 350.00 250.00 260.00 266.25 276.90 15 16
Number of occurrences
%MW20 := OCCUR_ARW(%MW0:10, %KW0) %MD20 := OCCUR_ARD(%MD0:10, %KD0) 10 words 10 double words 350.00 370.00 250.00 270.00 266.25 287.55 15 16
Rotate shift
ROL_ARW(word or value,%MWj:10) ROL_ARD(%MDi,%MDj:10) 10 words 10 double words 550.00 590.00 400.00 430.00 426.00 457.95 9 9
Sort
SORT_ARW(%MWi,%MWj:10) SORT_ARD(%MDi,%MDj:10) 10 words, max. instance 5 double words, max. instance 970.00 610.00 700.00 450.00 745.50 479.25 9 9
8/13
B
8.2.9 Time management
ST Execution time Volume (s) (words) 3710 3720 ram 3720 cart 37xx
8/14
Performance 8
B
8.2.10 Character strings
ST Conditions Execution time Volume (s) (words) 3710 3720 ram 3720 cart 37xx
String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) %MB10:20 := DELETE(%MB10:22,2,3); %MW0 := EQUAL_STR(%MB10:20,%MB30:20); %MW0 := FIND(%MB10:20,%MB30:10); %MB10:20 := INSERT(%MB30:10,%MB50:10,4); %MB10:20 := LEFT(%MB30:30,20); %MW0 := LEN(%MB10:20); %MB10:20 := MID(%MB30:30,20,10); %MB10:20 REPLACE(%MB30:20,%MB50:10,10,10); %MB10:20 := RIGHT(%MB30:30,20); := the 5th character is different 1 170.00 950.00 860.00 1 610.00 1 270.00 920.00 770.00 1 080.00 1 450.00 1 480.00 770.00 600.00 520.00 1 000.00 800.00 570.00 340.00 700.00 870.00 950.00 820.05 639.00 553.80 1 065.00 852.00 607.05 362.10 745.50 926.55 1 011.75 15 15 13 13 17 13 9 15 19 13
8/15
Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10,%MW30:4) SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 2182 1636 1818 1364 1936 1452 21 15
Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) GET_MSG(ADR#1.0,%MW0:2,%MW10:2) GET_VALUE(ADR#1.0,%MW0,%MW10:2) ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 240 2 240 2 240 1 120 2 240 2 240 1 120 1 120 1 120 2 240 2 240 2 240 2 000 2 000 2 000 1 000 2 000 2 000 1 000 1 000 1 000 2 000 2 000 2 000 2208 2208 2 208 1 104 2 208 2 208 1 104 1 104 1 104 2 208 2 208 2 208 19 19 19 17 23 21 17 17 17 19 19 19
Process control
PID('PIDS1','Unit',%IW3.5,%MW12,%M16,%MW284:43) deval_mmi=0 deval_mmi=1 PWM(%MW11,%Q2.1,%MW385:5) SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3,%MW284:43,%MW3 90:10) PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1320 1080 600 960 1140 1100 900 500 800 950 1172 958,5 532,5 852 1012 11 19 20 24
8/16
Performance 8
B
ST Conditions Execution time (s) 3710 3720 3720 ram cart Volume (words) 37xx
Orphee function
DSHL_RBIT(%MD102,16,%MD204,%MD206) DSHR_RBIT(%MD102,16,%MD204,%MD206) DSHRZ_C(%MD102,16,%MD204,%MD206) WSHL_RBIT(%MW102,8,%MW204,%MW206) WSHR_RBIT(%MW102,8,%MW204,%MW206) WSHRZ_C(%MW102,8,%MW204,%MW206) SCOUNT(%M100,%MW100,%M101,%M102,%MW101,%MW 102,%M200,%M201,%MW200,%MW201) read 10 words write 10 words mirror req. 10 words exchange 10 words 20 bytes 20 bytes 20 bytes 440 660 410 300 390 300 510 320 480 310 220 280 220 410 341 511 330 234 298 234 437 13 13 13 13 13 13 25
180 90 110
180 70 95
216 74 104
8/17
LD,
%M1 (1)
LDN %M1[%MW2] %MW0:X0 (2) %IWi.j:Xk (3) %MW0[%MW10]:X0 %KW0[%MW10]:X0 %M1 2.33 1.46 2.33 3.50 3.50 0.87 1.00 0.62 1.00 1.50 1.50 0.37 1.58 1.00 1.58 2.37 2.37 0.58 6 4 6 9 9 2
LDR,
LDF %M1[%MW2] , , ... , , ... XOR, XORN %M1 %M1[%MW2] %MW0:X0 %IWi.j:Xk %MW0[%MW10]:X0 %KW0[%MW10]:X0 %M1 %M1[%MW2] %M1 2.04 5.54 4.08 4.96 7.87 7.87 2.25 27.28 1.17 0.87 2.37 1.75 2.12 3.37 3.37 1.13 26.13 0.50 1.37 3.79 2.83 3.42 5.37 5.37 1.69 26.44 0.75 5 13 10 14 14 18 9 19 2 AND, ANDN , AND (, AND (N , idem OR ANDR, ANDF, AND (R, AND (F, idem OR idem LDR, LDF 2.62 idem 1.12 LD, 1.79 LDN 7
%M1[%MW2] %MW0:X0 %NW{i}j:Xk (3) %MW0[%MW10]:X0 multiple coils in Ladder, "cost" of 2nd and subsequent coils operation block [ action] block executed not executed
7 4 8 8 1 1 1
(1) This refers to all forceable bit objects : %I, %Q, %X, %M, %S (2) Other objects of the same type : output bits of function block %TMi.Q ..., system word extract bits %SWi:Xj, extract bits of %KW, fault bits %Ii.j.ERR (3) Other objects of the same type: common word extract bits %NW{i}j:Xk, I/O word extract bits %IWi.j.Xk, %QWi.j.Xk
8/18
Performance 8
B
LD IL ST Objects 5710 horizontal comparison block vertical comparison block convergence divergence not followed by a convergence MPS, MPP, MRD LD [comparison] time in addition to the comparison between 2 %MWi ) ladder, 1 divergence list MPS+MPP list MRD Execution time (s) 5720 5720 ram cart 0.00 0.00 0.00 0.87 0.12 0.12 0.37 0.12 1.37 0.21 0.21 0.62 0.21 Size (words) 57xx 0 5 1 1 3 1
IE timer
rising edge on IN falling edge on IN IN =1 IN =0 IN %TM1 START %TM1 (rising edge) IN %TM1 DOWN %TM1 (falling edge) IN %TM1 (=1) IN %TM1 (=0) start timer stop timer timer on timer off 67.87 27.84 32.15 28.60 46.92 19.50 22.66 20.18 3
PL7-3 timer
START %T1 STOP %T1 E=0 RESET %T1 enable freeze reset timer on timer off 23.08 23.46 30.40 16.16 16.26 21.51 3
Up/down counter
reset, R=1 preset, S=1 rising edge on CU rising edge on CD inactive steps R %C8 (=1) S %C9 (=1) RESET %C8 reset 30.38 33.99 33.81 33.81 22.37 21.26 23.55 23.49 23.49 16.22 3 PRESET %C9 preset up down no action
CU %C8 UP %C8 (rising edge) CD %C9 DOWN %C9 (rising edge) R/S/CU/CD inactive bit
8/19
B
Function blocks (continued)
LD IL ST objects/conditions Execution time (s) Size (words) 5710 5720 57xx
Monostable
rising edge on S S=1 S %MN0, START %MN0 start rising edge S %MN0, S=1/0 active monostable 57.42 20.38 40.65 14.11 3
Register
edge on I edge on O R=1 inactive inputs I %R2 (edge) PUT %R2 store retrieve reset no action 35.69 35.69 26.83 20.71 24.92 24.92 18.80 15.50 3 O %R2 (edge) GET %R2 R %R1 (=1) I/O/R, inactive bit RESET %R2
Drum
edge on U U %DR0 UP %DR1 up, fixed per control bit R=1 R %DR1 RESET %DR2 reset, fixed per control bit inactive inputs R/U, bit inactive no action, fixed per control bit 268.69 25.00 257.01 25.00 259.07 25.00 185.41 25.00 176.06 25.00 179.06 25.00 3
8/20
Performance 8
8.3.3 Integer and floating point arithmetic
Corrections according to object type The times and volumes on the following pages are given for %MW0, %MD0 or %MF0
Execution time Volume (s) (words) 5710 5720 ram 5720 cart 57xx
2.04 2.04
0.87 0.87
1.37 1.37
5 5
Value to add for objects of the following type : Common words, I/O words
0.87
0.37
0.58
Correction according to the context of the operation Value to add if the operation is in at least the 2nd position in the phrase, example *%MW2 in := %MW0 * %MW1 * %MW2, concerns the following operations: *,/,REM on words and double words, or all operations on floating points
%MW0 %MD0 and %MF0 0.58 0.87 0.25 0.37 0.37 0.54 1 1
Value to add for an operation with the result of an operation in parentheses, or of a higher priority, example : %MW0 + %MW2 + (...)
%MW0 %MD0 and %MF0 0.29 0.58 0.12 0.25 0.17 0.33 1 1
8/21
B
ST objects conditions Execution time (s) 5710 object after the := %MW0 %MW0+(..., or before *, /, REM %MD0 %MD0(..., or before *, /, REM %MF0 := %MW0 %MD0 et %MF0 =, <>, <=, <, >, >= %MW0 %MD0 %MF0 AND, OR, XOR %MW0 %MD0 +, %MW0 %MD0 %MF0 * %MW0 %MD0 %MF0 /, REM %MW0 %MD0 / ABS, -object %MF0 %MW0 %MD0 %MF0 NOT %MW0 %MD0 SQRT %MW0 %MD0 %MF0 INC, DEC %MW0 %MD0 SHL, SHR, ROR ROL, %MW0 %MD0 for 1 bit for 1 bit per additional bit 0.87 1.17 1.17 1.75 1.75 0.87 1.17 1.17 1.46 48.36 0.87 1.17 0.87 1.17 99.42 10.83 55.31 87.60 11.93 333.15 95.83 0.87 1.17 18.82 0.87 1.17 22.20 111.29 233.62 1.17 1.75 2.92 3.21 5720 ram 0.37 0.50 0.50 0.75 0.75 0.37 0.50 0.50 0.62 33.88 0.37 0.50 0.37 0.50 71.51 9.14 42.71 63.61 9.99 226.54 68.51 0.37 0.54 13.01 0.37 0.54 16.24 89.66 173.01 0.50 0.75 1.25 1.37 0.042 5720 cart 0.58 0.75 0.75 1.08 1.08 0.58 0.75 0.79 1.04 34.13 0.58 0.75 0.58 0.75 71.76 9.35 42.96 63.86 10.20 226.79 68.76 0.58 0.75 13.26 0.58 0.75 16.45 89.91 173.26 0.75 1.08 1.96 2.12 Volume (words) 57xx 2 2 2 2 2 2 2 4 4 4 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 3 3 3 2 2 10 10
8/22
Performance 8
8.3.4 Program instructions
ST Objects Conditions Execution time (s) 5710 5720 5720 ram cart 2.58 1.25 1.71 33.98 34.54 3.92 1.00 23.96 24.41 1.75 0.50 23.96 24.41 2.42 0.71 Volume (words) 57xx 3 1 1 2 2
if <cond > then <action> the times and volumes indicated end_if; below should be added to those of the action contained in the structure true condition false condition (jump) If <cond> then <action1> else <action2> end_if; true condition false condition while <cond> do.<action> end_while go to loop with loop-back exit loop repeat <action> until <cond> end_repeat go to loop with loop-back last pass for <word1:=word2> to <word3> do <action> end_for entry to the for command, execute once only go to loop with loop-back exit loop
0.58 0.71
0.25 0.37
0.42 0.54
1.29 0.71
0.62 0.37
0.96 0.54
1.29 0.71
0.62 0.37
0.96 0.54
0.71 0.58
0.37 0.25
0.54 0.42
15
8/23
BCD_TO_INT INT_TO_BCD GRAY_TO_INT INT_TO_REAL DINT_TO_REAL REAL_TO_INT REAL_TO_DINT DBCD_TO_DINT DBCD_TO_INT DINT_TO_DBCD INT_TO_DBCD
8/24
Performance 8
B
ST conditions 5710 Execution time (s) 5720 ram 5720 cart Volume (words) 57xx
16 bits 32 128
17 17 17
8/25
8/26
Performance 8
B
ST conditions 5710 Execution time (s) 5720 ram 5720 cart Volume (words) 57xx
8/27
B
ST conditions 5710 Execution time (s) 5720 ram 5720 cart Volume (words) 57xx
Search
%MW20 := FIND_EQW(%MW0:10,%KW0) %MD20 := FIND_EQD(%MD0:10, %KD0) 10 words 10 double words 374.68 394.40 240.00 260.00 267.60 289.90 14 15
Number of occurences
%MW20 := OCCUR_ARW(%MW0:10, %KW0) 10 words %MD20 := OCCUR_ARD(%MD0:10, %KD0) 10 double words 394.40 423.98 260.00 280.00 289.90 312.20 14 15
Rotate shift
ROL_ARW(word or value,%MWj:10) ROL_ARD(%MDi,%MDj:10) 10 words 10 double words 621.18 670.48 400.00 430.00 446.00 479.45 12 12
Sort
SORT_ARW(%MWi,%MWj:10) SORT_ARD(%MDi,%MDj:10) 10 words 10 double words 1 133.90 700.06 720.00 440.00 802.80 490.60 12 12
8/28
Performance 8
8.3.9 Time management
ST 5710 Execution time (s) 5720 ram 5720 cart Volume (words) 57xx
8/29
String manipulation OF
%MB10:20 := CONCAT(%MB30:10,%MB50:10) %MB10:20 := DELETE(%MB10:22,2,3); %MW0 := EQUAL_STR(%MB10:20,%MB30:20); %MW0 := FIND(%MB10:20,%MB30:10); %MB10:20 := INSERT(%MB30:10,%MB50:10,4); %MB10:20 := LEFT(%MB30:30,20); %MW0 := LEN(%MB10:20); %MB10:20 := MID(%MB30:30,20,10); %MB10:20 := REPLACE(%MB30:20,%MB50:10,10,10); %MB10:20 := RIGHT(%MB30:30,20); 1 106.00 896.00 756.00 1 456.00 1 162.00 826.00 490.00 994.00 1 246.00 1 358.00 790.00 640.00 540.00 1 040.00 830.00 590.00 350.00 710.00 890.00 970.00 880.85 713.60 602.10 1 159.60 925.45 657.85 390.25 791.65 992.35 1 081.55 24 21 19 19 26 19 12 21 28 19
8/30
Performance 8
8.3.11 Application-specific functions and Orphee function
ST Conditions Execution time (s) 5710 5720 5720 ram cart Volume (words) 57xx
Communication
SEND_REQ(%KW0:6,15,%MW0:1,%MW10:10,%MW30:4) SEND_TLG(%KW0:6,1,%MW0:5,%MW30:2) 2 800 2 100 2 000 1 500 2 230 1 673 33 24
Man-machine interface
SEND_MSG(ADR#1.0,%MW0:2,%MW10:2) SEND_ALARM(ADR#1.0,%MW0:2,%MW10:2) GET_MSG(ADR#1.0,%MW0:2,%MW10:2) GET_VALUE(ADR#1.0,%MW0,%MW10:2) ASK_MSG(ADR#1.0,%MW0:2,%MW10:2,%MW20:2) ASK_VALUE(ADR#1.0,%MW0,%MW10:2,%MW20:2) DISPLAY_ALRM(ADR#1.0,%MW0,%MW10:2) DISPLAY_GRP(ADR#1.0,%MW0,%MW10:2) DISPLAY_MSG(ADR#1.0,%MW0,%MW10:2) CONTROL_LEDS(ADR#1.0,%MW0:2,%MW10:2) ASSIGN_KEYS(ADR#1.0,%MW0:2,%MW10:2) PANEL_CMD(ADR#1.0,%MW0:2,%MW10:2) 2 800 2 800 2 800 1 400 2 800 2 800 1 400 1 400 1 400 2 800 2 800 2 800 2 000 2 000 2 000 1 000 2 000 2 000 1 000 1 000 1 000 2 000 2 000 2 000 2 230 2 230 2 230 1 115 2 230 2 230 1 115 1 115 1 115 2 230 2 230 2 230 25 25 25 20 32 27 20 20 20 25 25 25
Process control
PID('PIDS1','Unit',%IW3.5,%MW12,%M16,%MW284:43) deval_mmi=0 deval_mmi=1 PWM(%MW11,%Q2.1,%MW385:5) SERVO(%MW12,%IW3.6,%Q2.2,%Q2.3,%MW284:43,%MW3 90:10) PID_MMI(ADR#0.0.4,%M1,%M2:5,%MW410:62) EN=1 1700 1500 700 1000 1400 1100 900 500 800 1000 1227 1004 557,5 892 1115 17 31 30 32
8/31
B
ST Conditions Execution time (s) 5710 5720 5720 ram cart Volume (words) 57xx
Orphee function
DSHL_RBIT(%MD102,16,%MD204,%MD206) DSHR_RBIT(%MD102,16,%MD204,%MD206) DSHRZ_C(%MD102,16,%MD204,%MD206) WSHL_RBIT(%MW102,8,%MW204,%MW206) WSHR_RBIT(%MW102,8,%MW204,%MW206) WSHRZ_C(%MW102,8,%MW204,%MW206) SCOUNT(%M100,%MW100,%M101,%M102,%MW101,%MW 102,%M200,%M201,%MW200,%MW201) read 10 words write 10 words mirror req. 10 words exchange 10 words 20 bytes 20 bytes 20 bytes 493 749 493 365 424 365 670 320 510 310 220 290 220 420 357 569 346 245 323 245 468 17 17 17 17 17 17 38
Read_Sts %CHi.MOD Whatever the application, communication channel Read_Sts %CHi Discrete input Discrete output Analog input Analog output CTY CFY CAY Write_Param %CHi Analog input Analog output CTY CFY CAY 860 810 532 0 860 620 580 380 0 620 630 600 399 0 630 6 except for the processor 997 712 748 2
8/32
Performance 8
B
ST Conditions 5710 Execution time (s) 5720 5720 ram cart Volume (words) 57xx
Read_Param %CHi Analog input Analog output CTY CFY CAY Save_Param %CHi Analog input Analog output CTY CFY CAY Restore_Param %CHi Analog input Analog output CTY CFY CAY Write_Cmd %CHi Discrete output Analog input . input forcing . input forcing Analog output : output forcing Discrete output Smove %CHi CFY CAY 700 820 500 580 525 610 19 210 150 150 200 1 390 140 1 020 150 1 040 1 722 1 230 1 292 6 800 800 630 0 1 300 570 570 450 0 880 590 590 473 0 890 6 1 300 1 300 180 180 532 880 890 120 120 380 890 900 130 130 399 6 180 180 1 134 1 064 784 120 120 810 760 560 130 130 851 798 588 6
8/33
8.4
8.4.1 Description of the memory zones The application is divided into several memory zones : bit memory zone : - this zone is specific to TSX 37 PLCs and is limited to 1280 bits, - this zone is part of the data memory zone for TSX 57 PLCs, data memory zone (words) application memory zone, comprising : - configuration - program, - constants The bit and data memory zones are always stored in the internal RAM, the application memory zone can be stored in the internal RAM or on a memory card. The memory structure is described in section 1.3. part A.
8/34
Performance 8
8.4.2 Memory size of PL7 objects
Bit memory (in words) 0.5 0.5 Data (in words) 1 1 1.25 1 4 5 4 3 6+lg 6 2 2 2 1 2 49 Application (in words)
Grafcet steps (%Xi, %Xi.T) %Mi Numerics (%MWi) Constants (%KWi) %NWi %Ti %TMi %MNi %Ci %Ri (length lg) %DRi
Grafcet interpreter data = 355 + 2 x No active steps configured + (No. of valid transitions configured) / 2
8.4.3 Module memory size Note This information is given for a particular processor version. It may be subject to slight variations as the product develops. For each module type, the following tables provide the size occupied in each of the zones as well as a fixed size which should be added to the power consumption table the first time an application-specific function is used. Module memory power consumption table, on TSX 37
Processors TSX 37-10 TSX 37-21 TSX 37-22 Use of FAST task (TSX 37) First use of event (TSX 37) Bit memory (words) 70 70 70 Data (words) 1560 1570 2110 260 520 Application Zone (words) 920 930 1280
8/35
B
Discrete family 8 discrete inputs 16 discrete inputs 4 discrete outputs 8 discrete outputs 16 discrete inputs / 12 discrete outputs 32 discrete inputs / 32 discrete outputs 4 ANA input family AEZ414 Add. amount 1st module in 4 ANA input family 8 ANA input family AEZ801/AEZ802 Add. amount 1st module in 8 ANA input family ANA output family ASZ200 ASZ401 Add. amount 1st module in ANA output family Counter family CTY1A CTY2A Add. amount 1st Upcounter channel Add. amount 1st Downcounter channel Add. amount 1st Up/Down counter channel Communication family STZ010 SCP111/ SCP112/ SCP114 on UC UTW) FPP 20 on UC (Channel 0 UTW) Bit memory (words) 0 0 0 Data (words) 36 40 40 Bit memory (words) 16 32 Data (words) 108 212 Bit memory (words) 0 0 Data (words) 52 100 Bit memory (words) 0 Data (words) 212 Bit memory (words) 4 8 2 4 16 32 Bit memory (words) 0 Data (words) 12 12 12 12 20 20 Data (words) 156 Application Zone (words) 40 50 40 40 100 142 Application Zone (words) 56 120 Application Zone (words) 72 120 Application Zone (words) 40 59 120 Application Zone (words) 64 106 144 144 144 Application Zone (words) 168 763 755
8/36
Performance 8
Module memory power consumption table, on TSX 57
Processors TSX 57-10 TSX 57-20 Use of FAST task (TSX 57) Add. amount 1st module Bit memory (words) 70 70 Data (words) 3852 4125 520 600 Application Zone (words) 1164 1227
Single discrete input family 8 discrete inputs 16 discrete inputs 32 discrete inputs 64 discrete inputs Add. amount 1st single discrete input family module Single discrete output family 8 discrete outputs 16 discrete outputs 32 discrete outputs 64 discrete outputs Add. amount 1st single discrete output family module Event-triggered discrete input family 16 discrete inputs (DEY 16FK) Add. amount 1st EVT discrete input family module Analog input family AEY414 AEY800 AEY1600 Add. amount 1st analog input family module
8/37
B
Analog output family ASY410 Add. amount 1st analog output family module Counter family CTY2A module CTY4A module Add. amount 1st configured counter channel Servo-Motor family CAY21 CAY41 Add. amount 1st configured servo-motor channel Communication module family SCY21600 (Channel 0 UTW) SCP111/ SCP112 / SCP114 (UTW) on SCY21600 (Channel 1 UTW) Add. amount 1st configure channel UTW UC communication sub-module family SCP111/ SCP112/ SCP114 (UTW) on UC (Channel 0 UTW) FPP 20 on UC (Channel 0 UTW) FPP 10 on UC (Channel 0 UTW) Weighing family AWY001 Add. cost 1st configured weighing channel Bit memory (words) 1 1 Data (words) 230 450 Bit memory (words) 78 156 Data (words) 1050 2090 Bit memory (words) 32 64 Data (words) 410 800 Bit memory (words) 4 Data (words) 430 Application Zone (words) 160 1700 Application Zone (words) 170 250 1740 Application Zone (words) 280 480 2150
Application Zone (words) 580 580 870 Application Zone (words) 120 3920
8/38
Performance 8
8.4.4 Memory size of advanced functions The following tables show for each advanced function (OF), the size of the code embedded in the application (application zone) when an advanced function is called. The functions in the same family share the code (common code). This common code is embedded in the PLC on the first call of a function for that family. The code specific to a function is embedded on the first call for that function. Example : First call of a function of the Numeric conversions family, ie DBCD_TO_DINT Code embedded in the application zone : - Common code = 154 words - OF code DBCD_TO_INT = 149 words Call of another function of the Numeric conversions family, ie DINT_TO_DBCD Code engaged in the application zone : - OF code DINT_TO_DBCD = 203 words Call of a function of the Numeric conversions family which has already been called (DBCD_TO_DINT or DINT_TO_DBCD) : no code embedded
Numeric conversions Conversion of a 32-bit BCD number to 32-bit integer Conversion of a 32-bit BCD number to 16-bit integer Conversion of a 32-bit integer to a 32-bit BCD number Conversion of a 16-bit integer to a 32-bit BCD number OF DBCD_TO_DINT DBCD_TO_INT DINT_TO_DBCD INT_TO_DBCD common code code size (in words) 145 149 203 75 154
8/39
B
Bit strings Logic AND between two tables Copy of a bit table to a double word table Copy of a bit table to a word table Copy of a bit table to a bit table Copy of a double word table to a bit table Ones complement in a table Logic OR between two tables Copy a word table to a bit table Exclusive OR between two tables OF AND_ARX BIT_D BIT_W COPY_BIT D_BIT NOT_ARX OR_ARX W_BIT XOR_ARX common code OF FIND_EQW FIND_GTW FIND_LTW MAX_ARW MIN_ARW OCCUR_ARW ROL_ARW ROR_ARW SORT_ARW common code OF FIND_EQD FIND_GTD FIND_LTD MAX_ARD MIN_ARD OCCUR_ARD ROL_ARD ROL_ARW SORT_ARD common code code size (in words) 209 248 205 146 196 157 209 195 209 427 code size (in words) 75 75 75 78 78 74 145 150 144 162 code size (in words) 79 80 80 95 95 78 163 170 178 162
Word table instructions Search in a table for 1st element equal to a value Search in a table for 1st element greater than a value Search in a table for 1st element less than a value Search for the greatest value in a table Search for the smallest value in a table Number of occurrences of a value in a table Left rotate a table Right rotate a table Sort a table (ascending or descending)
Double word table instructions Search in a table for 1st element equal to a value Search in a table for 1st element greater than a value Search in a table for 1st element less than a value Search for the greatest value in a table Search for the smallest value in a table Number of occurrences of a value in a table Left rotate a table Right rotate a table Sort a table (ascending or descending)
8/40
Performance 8
B
Date, time and time periods Add a duration to a complete date Add a duration to a time of day Convert a date to a string Day of the week Difference between two dates Difference between two complete dates Difference between two times of day Convert a complete date to a string Remove a time period from a complete date Remove a time period from a time of day Convert a time period to a string Convert a time of day to a string Format a time period as hours-minutes-seconds OF ADD_DT ADD_TOD
DATE_TO_STRING
code size (words) 519 188 150 99 374 547 110 266 548 186 413 156 211 1703 code size (words) 224 279 212 225 287 38 70 44 365 55 418 code size (words) 152 152 133 91 103 90 173 617
DAY_OF_WEEK DELTA_D DELTA_DT DELTA_TOD DT_TO_STRING SUB_DT SUB_TOD TIME_TO_STRING TOD_TO_STRING TRANS_TIME common code OF CONCAT DELETE EQUAL_STR FIND INSERT LEFT LEN MID REPLACE RIGHT common code OF
Character string instructions Concatenation of two strings Delete a substring Search for first different character Search for a substring Insert a substring Extract from the left part of the string Length of a string Extract a substring Replace a substring Extract from the right part of the string
Orphee functions
Shift to left on 32 with retrieval of shifted bits Shift to right on 32 with sign extension, retrieval of shifted bits Shift to right on 32 with filling of spaces by 0, retr. of shifted bits Shift to left on 16 with retrieval of shifted bits Shift to right on 16 with sign extension, retrieval of shifted bits Shift to right on 16 with filling of spaces by 0, retr. of shifted bits Up/down counting with indication of an under/overflow
8/41
Application-specific functions
Process control functions Mixed PID controller Pulse width modulation of a numeric value PID output stage for control of discrete valve Management of CCX17 dedicated MMI for controlling PID loops OF PID PWM SERVO PID_MMI common code Man-Machine Interface Functions Blocking entry of a variable on CCX17 Blocking entry of a variable on message contained in CCX17 Dynamic assignment of keys LED control command Display an alarm contained in CCX17 Display a group of messages contained in CCX17 Display a message contained in CCX17 Multiple entry of a variable on CCX17 Multiple entry of a variable on message contained in CCX17 Send a command to CCX17 Display an alarm message contained in the PLC memory Display a message contained in the PLC memory OF ASK_MSG, ASK_VALUE, ASSIGN_KEYS, CONTROL_LEDS, DISPLAY_ALARM, DISPLAY_GRP, DISPLAY_MSG, GET_MSG, GET_VALUE, PANEL_CMD, SEND_ALARM, SEND_MSG common code code size (in words) 1800 600 1200 4400 400 code size (in words) 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 46.5 573
Communication Functions Read base language objects Write base language objects Send/receive UNI-TE requests Send and/or receive data Send a character string Request read of a character string Send and/or receive a character string Send a telegram Receive a telegram Request to stop a communication function in progress Shift 1 byte to the right of a byte table
OF READ_VAR WRITE_VAR SEND_REQ DATA_EXCH PRINT_CHAR INPUT_CHAR OUT_IN_CHAR SEND_TLG RCV_TLG CANCEL common code ROR1_ARB
code size (in words) 617 500 438 375 476 625 531 219 172 133 506 235
8/42
Performance 8
B
Axis Control Functions (1) Automatic motion command SMOVE OF code size (in words) 0
Explicit Exchange Functions (1) Read status parameters Read adjust parameters Update adjust parameters Save adjust parameters Restore adjust parameters Update command parameters
(1) Specific OF, the code is included in the volume of the I/O module.
8/43
Calculating the number of numerical instructions The number of each of the following elements is taken into account : assignments (:=) loading of first value after := arithmetic instructions (+, -, *, /, <, =, etc), operations on words or word tables, double words, floating point values logic instructions on words (OF, EQUAL, etc) functions regardless of the number of parameters function blocks (or function block instruction) Example : %MW0:=(%MW1+%MW2)*%MW3; instructions counted : := %MW1 (corresponds to the load instruction in the accumulator) + * ie. 4 instructions.
8/44
Performance 8
Example of application which is 65% de boolean and 35% numerical :
8/45
8/46
Performance 8
8/47
(1)
(1) : %MW0:=%MW1+%MW2+%MW3+%MW4+%MW5+%MW6+%MW7+%MW8+%MW9+%MW10+1
Result Number of instructions 187 4 31 3 111 4 6 24 346 % 54,05% 1,16% 8,96% 0,87% 32,08% 1,16% 1,73% 64,16%
Boolean without edge Boolean with edge Operation Block Function Block Single arithmetic (+,-,:=,AND,...) Indexed arithmetic *,/ Immediates values Total number
35,84%
100,00%
8/48
Index 9 Section 9
9 Index
9.1
Index
Symbols
%Ci %DRi %Li %MNi %Ri %Ti %TMi * + / := < <= <> = > >= B 1/14 B 2/9 B 1/30 B 2/2 B 2/5 B 2/13 B 1/10 B 1/23 B 1/23 A 1/10, B 1/23 B 1/23 B 1/20 B 1/19 B 1/19 B 1/19 B 1/19 B 1/19 B 1/19
B
BCD <--> Binary conversion Binary --->ASCII conversion Bit memory A 1/20, Bit table Bit tables BIT_D BIT_W Bits BLK Boolean instructions Byte B 2/24 B 2/45 A 1/22 B 2/81 A 1/16 B 2/83 B 2/83 A 1/6 A 3/8 B 1/2 A 1/11
C
CALL Character string A 1/16, Cold restart Comments A 2/5, A 3/4, A 4/6, Common words Comparison Complement CONCAT Concatenation of two strings Conditions Constant Control structures Conversion COPY_BIT Cyclic execution A 2/3 B 2/42 A 1/31 A 5/10 A 1/13 B 1/19 B 1/25 B 2/50 B 2/50 A 5/14 A 1/11 A 4/8 B 2/24 B 2/81 A 1/33
A
ABS Absolute value Action zone Actions Add ADD_DT ADD_TOD Addressing Addressing TSX 37 objects Addressing TSX 57 objects Alphanumeric comparisons AND B 1/6, AND convergences AND divergences AND_ARX ANDF ANDN ANDR Arithmetic on integers ASCII ---> Binary conversion ASCII --> Floating point conversion Assignment B 1/23 B 1/23 A 2/1 A 5/11 B 1/23 B 2/69 B 2/70 A 1/7 A 1/7 A 1/9 B 2/44 B 1/25 A 5/2 A 5/2 B 2/82 B 1/6 B 1/6 B 1/6 B 1/23 B 2/47 B 2/49 B 1/20
___________________________________________________________________________ 9 / 1
B
D
D_BIT Date DATE_TO_STRING DAY_OF_WEEK DEC Decrement DELETE DELTA_D DELTA_DT DELTA_TOD Destination connector DINT_TO_REAL DINT_TO_STRING Direct coils Directed links Divide Double length DOWN Downcounter Drum controller DSHL_RBIT DSHR_RBIT DSHRZ_C DT_TO_STRING B 2/85 B 2/63 B 2/75 B 2/68 B 1/23 B 1/23 B 2/51 B 2/72 B 2/73 B 2/74 A 5/3 B 2/27 B 2/45 B 1/5 A 5/3, A 5/9 B 1/23 A 1/12 B 1/12 B 1/14 B 2/9 B 2/87 B 2/87 B 2/87 B 2/76 FIND_EQD FIND_EQW FIND_GTD FIND_GTW FIND_LTD FIND_LTW Floating point A 1/12, Floating point ---> ASCII conversion FOR ... END_FOR Forcing Freezing the Grafcet chart Function block objects Function blocks B 2/36 B 2/36 B 2/36 B 2/36 B 2/36 B 2/36 B 2/20 B 2/48 A 4/12 A 1/23 A 5/20 A 1/15 B 1/9
G
GET B 2/8 Grafcet language A 5/1 Grafcet objects A 1/18, A 5/4 Graphic elements, Grafcet A 5/2 Graphic elements, Ladder language A 2/2 Gray --> Integer conversion B 2/28 GRAY_TO_INT B 2/28
H
HALT B 1/33
E
Edges END END_BLK ENDC ENDCN EQUAL EQUAL_STR Event masking/unmasking Event-triggered tasks Exclusive OR EXIT A 1/22, B 1/2 B 1/32 A 3/8 B 1/32 B 1/32 B 2/35 B 2/60 B 1/34 A 1/40 B 1/8 A 4/13
I
IF ... END_IF A 4/8 Immediate values A 1/13 INC B 1/23 Increment B 1/23 Index overrun A 1/18 Indexation A 1/17 Indexed objects A 1/17 INSERT B 2/52 Instruction list language A 3/1 INT_TO_REAL B 2/27 INT_TO_STRING B 2/45 Integer <--> Floating point conversion B 2/26 Internal words A 1/11 Inverse coils B 1/5
F
Falling edge contacts FAST Fast task FIFO stack FIND Find functions on tables B 1/4 A 1/38 A 1/38 B 2/5 B 2/61 B 2/36
___________________________________________________________________________ 9 / 2
Index
B
J
JMP JMPC JMPCN Jump B 1/30 B 1/30 B 1/30 B 1/30
O
Objects which can be symbolized A 1/19 OCCUR_ARD B 2/39 OCCUR_ARW B 2/39 Operating modes A 1/29, A 5/1 OR B 1/7, B 1/25 OR convergences A 5/2 OR divergences A 5/2 OR_ARX B 2/82 ORF B 1/7 ORN B 1/7 ORR B 1/7 OUT_BLK A 3/8 Overflow B 1/24
L
Label Ladder language LD LDF LDN LDR LEFT LEN LIFO stack Logic AND Logic OR Logic shift A 2/5, A 3/4, A 4/7 A 2/1 B 1/4 B 1/4 B 1/4 B 1/4 B 2/58 B 2/62 B 2/5 B 1/6 B 1/7, B 1/25 B 2/19
P
Parentheses Periodic execution Post-processing Power outage Pre-processing Program instructions PTC PUT A 3/5 A 1/34 A 5/23 A 1/29 A 5/18 B 1/28 B 2/67 B 2/8
M
MASKEVT Master task MAX_ARD MAX_ARW Memory card MID MIN_ARD MIN_ARW Monostable MPP MPS MRD Multiply Multitask B 1/34 A 1/38 B 2/38 B 2/38 A 1/20 B 2/56 B 2/38 B 2/38 B 1/11, B 2/2 A 3/7 A 3/7 A 3/7 B 1/23 A 1/37
R
R Read day of the week Read system date REAL_TO_DINT REAL_TO_INT Register REM REPEAT ... END_REPEAT REPLACE RESET Reset coils RET RETCN RIGHT Rising edge contacts ROL_ARD ROL_ARW ROR_ARD B 1/5 B 2/68 B 2/66 B 2/27 B 2/27 B 2/5 B 1/23 A 4/11 B 2/54 B 2/8, B 2/11 B 1/5 B 1/29 B 1/29 B 2/58 B 1/4 B 2/40 B 2/40 B 2/40
N
N/C contacts N/O contacts NOT NOT_ARX Numerical expression B 1/4 B 1/4 B 1/25 B 2/82 B 1/27
___________________________________________________________________________ 9 / 3
B
ROR_ARW Rotate shift RRTC Rung Rungs, execution B 2/40 B 2/19 B 2/66 A 2/4 A 2/11 Time of day Time period TIME_TO_STRING Timer TOD_TO_STRING TRANS_TIME Transitions TSX 37-10 memory TSX 37-21/22 memory TSX 57-10 memory TSX 57-20 memory B 2/63 B 2/63 B 2/77 B 1/10, B 2/13 B 2/78 B 2/80 A 5/2 A 1/25 A 1/26 A 1/27 A 1/28
S
S B 1/5 SCOUNT B 2/90 Sequence A 3/4 Sequence selection A 5/6 Sequential processing A 5/21 Set coils B 1/5 Simultaneous step activation A 5/6 Single task A 1/32 Sort function on tables B 2/41 SORT_ARD B 2/41 SORT_ARW B 2/41 Source connector A 5/3 SQRT B 1/23 Square root B 1/23 SRi A 1/32 ST B 1/5 START B 1/12, B 2/3 Steps A 5/2 STN B 1/5 Stop code B 2/67 STRING_TO_DINT B 2/47 STRING_TO_INT B 2/47 STRING_TO_REAL B 2/49 Structured data B 4/4 Structured Text language A 4/1 SUB_DT B 2/69 SUB_TOD B 2/70 Subroutine A 1/32, B 1/28 Subroutine return B 1/29 Subtract B 1/23 SUM B 2/34 Symbol A 1/4, A 1/19 System bits B 3/1 System words B 3/7
U
UNMASKEVT UP Upcounter Update system date User memory B 1/34 B 2/11 B 1/14 B 2/66 A 1/20
V
Vertical comparison B 2/17
W
W_BIT Warm restart Watchdog WHILE ... END_WHILE Word extract bits Word memory Word tables WRTC WSHL_RBIT WSHR_RBIT WSHRZ_C B 2/85 A 1/30 A 1/36 A 4/10 A 1/13 A 1/20, A 1/24 A 1/16, B 2/29 B 2/67 B 2/87 B 2/87 B 2/87
X
XOR XOR_ARX XORF XORN XORR B 1/8, B 1/25 B 2/82 B 1/8 B 1/8 B 1/8
T
Table comparison Test zone Time B 2/35 A 2/1 B 2/63
___________________________________________________________________________ 9 / 4