Professional Documents
Culture Documents
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 %M0 to %M255 are used to store intermediate states during execution of the
program.
System bits
System bits %S0 to %S127 monitor correct operation of the PLC as well as progression of the
application program.
Addressing of the main word and bit objects in I/O modules is defined by the following
characters :
Type of object
I and Q : the physical inputs and outputs of modules exchange this information implicitly
on each scan of the task to which they are attached.
Note : Other types of data (status, command words, etc) can also be exchanged if
requested by the application
Format (Size)
For objects in Boolean format, the X can be omitted. It is used in other types of format
such as byte, word and double word
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 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).
Format
Objects words can be addressed by PL7 software in 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.
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.
F floating point (1) : the floating point format used is that of the IEEE standard. Words are 32 bits
long, which corresponds to single length floating point numbers.
Example of floating point values : 1285.28
12.8528E2
Examples :
%MD0 corresponds to %MW0 and %MW1.
%MW3 corresponds to %MB7 and %MB6.
%KD543 corresponds to %KW543 and %KW544.
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 logic conditions necessary to execute the actions.
The action zone which contains the actions to be executed according to the results of the test
zone.
MAIN
A
B
Presentation of basic instructions
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.
This instruction is equivalent to a closed contact when the respective input is at state 1.
Boolean instructions
Boolean instructions act on all bit type data (I/O bits, internal bits etc).
%M0
This instruction is equivalent to a open contact when the internal bit M0 is at
state 1.
• Boolean equation :
%I1.0 %I1.0
P N
Rising edge detection contact Falling edge detection contact
This test instructions can be used to detect rising or falling edges on PLC I/O bits or on internal
bits.
Load instructions
Authorized operands
Code Operand
%I,%Q,%M,%S,%BLK,%•:Xk, (1)
%I,%Q,%M,%S,%BLK,%•:Xk, (1)
P %I,%Q,%M
N %I,%Q,%M
List of operands
Assignment instructions
These instructions correspond to :
• Direct coils : the associated bit object takes the value of the result of the equation.
• Inverse coils : the associated bit object takes the inverse value of the result of the
equation.
• Set coils : the associated bit object is set to 1 when the result of the equation is at 1.
• Reset coils : the associated bit object is set to 0 when the result of the equation is at 1.
%I1.0 %Q2.3
%Q2.2
%Q2.4
S
%I1.0 S
%Q2.4
R
Authorized operands
Code Operand
%I,%Q,%M,%S,%•:Xk
%I,%Q,%M,%S,%•:Xk
S %I,%Q,%M,%S,%•:Xk
S
R %I,%Q,%M,%S,%•:Xk
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).
There are six types of control system function block :
IN Q
MODE:TON
TB: 1mn
TM.P:9999
MODIF:Y
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 function blocks are programmed in the same way, irrespective of the mode of use
selected. TON, TOF or TP mode can be chosen in the variables editor.
Configuration
The following parameters must be entered in the variables editor :
- Mode : TON, TOF or TP.
- TB : 1min, 1s, 100ms or 10ms.
- %TMi.P : 0 to 9999.
- MODIF : Y or N.
Programming
Up/down counter function block %Ci
The up/down counter function block is used to up/down count events. These two operations can
be simultaneous.
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 simulta-neously,
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.
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
B
Numerical processing on integers
General
The numerical instructions described in this section apply to objects of the following type :
bit tables.
words.
double words.
Comparison instructions
Syntax
Operators : >,>=,<,<=,=,<>
Assignment instructions
Syntax :
Assignment of bit
These instructions are used to perform arithmetic operations between two operands or on one
operand.
Syntax
Operators
+,-,*,/ Op1:=Op2 Operator Op3
SQRT, ABS Op1:=Operator(Op2)
INC, DEC Operator Op1
Logic instructions
The associated instructions are used to perform a logic operation between two operands or on
one operand.
Subroutine call
Subroutine call instructions are used to call a subroutine module located in the same task.
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.
Program jumps
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 Micro command INIT). Any instructions following the
instruction HALT will therefore not be executed.
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.
Advanced predefined function blocks
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.
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).
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).
Configuration
The following parameters must be entered in the variables editor of the register block :
Numbers : 1 to 4.
Mode : FIFO or LIFO.
Length : 1 to 255.
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.
The state of the outputs (control bits) for each step of the drum controller.
Time base.
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.
Standard operations
The Timer function block can be pro-grammed to perform the following func-tions :
Vertical comparison blocks
Vertical comparison blocks are used to compare two operands (OP). These two operands are
either 16-bit words (possibly indexed) or immediate values.
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 >).
Shift instructions
Shift instructions consist of moving bits of a word or double word operand a certain number of
positions to the right or to the left.
Logic shift :
- SHL(op2,i) logic shift of i positions to 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.
Floating point instructions
General
PL7 Micro software is used to perform operations on floating point objects. The floating point
object format used is that of the IEEE standard. 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.
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).
Numeric conversion instructions