Download presentation
Presentation is loading. Please wait.
1
Control System Applications (2)
Programming Logic Controllers PLCs Lect. 9 Dr. Tarek Ahmed Mahmoud
2
Outlines Numerical Processing Word Objects Word Format Word Types
Numerical Instructions
3
Word Objects Word Format
Word objects are addressed in the form of words of 16 bits Word Format 1 16384 +/- 8192 14 15 Bit position Bit state Bit value 13 2 3 4 5 6 7 8 9 10 11 12 4096 2048 1024 512 256 128 64 32 16 Bit 15 at 0 is a positive value. Bit 15 at 1 the word is a negative value (negative values are expressed in two's complement logic).
4
Word Format (cont.) Decimal 1579 (max : 32767, min :-32768)
Hexadecimal 16#A (max : 16#FFFF, min : 16#0000) Alternate syntax : #A536.
5
Word Types in NANO PLC 1- Immediate values 2- Internal words
- They are used to store values during the operation. - They are stored in the data memory. - They are read or written to directly by the program. - They are used as working words. %MW to %MW255
6
Word Types in NANO PLC (cont.)
3- Constant words They store constant values Their contents can only be written or modified in the CONFIGURATION editor. - They are read-only access by the program. %KW to %KW64 4- Function Block Words - They are read or modified in the program. - Such as %TMi.P and %Ci.P, %Ti.v, etc.
7
Word Types in NANO PLC (cont.)
5- System words Words have special functions related to the PLC operation %SW to %SW127 %SW30 Shows execution time of the last PLC scan cycle 6- I/O exchange words Words %IW and %QW are used to exchange data between PLCs.
8
Word Types in NANO PLC (cont.)
Bit objects extracted from words % Word object : Xk k = 0 to 15 % MW5:x6 Bit position 6 of internal word %MW5.
9
Word Types in NANO PLC (cont.)
10
Numerical Instructions
Numerical instructions generally apply to 16-bit words They are written - Between square brackets (instruction list) [ Instruction ] - In a rectangular (in ladder diagram). Instruction
11
Numerical Instructions
1- Assignment instructions These are used to load operand Op2 into operand Op1 Syntax : [Op1:=Op2] Op1 is a memory word Op2 is a memory word or an immediate value Example LD 1 [%MW10:%MW20] %MW10:= %MW20
12
LDR %I0.3 [%MW10:=100]
13
Numerical Instructions
2- Arithmetic instructions : Add two operands : Subtract two operands * : Multiply two operands / : Divide two operands SQRT : Square root of an operand INC : increment an operand
14
- Examples
15
Numerical Instructions
3- Comparison Instructions > : test if greater than. >= : test if greater than or equal. < : test if less than. <= : test if less than or equal. = : test if equal. <> : test if not equal (different from). The result is 1 when the comparison requested is true.
16
- Examples
17
Numerical Instructions
4- Logic instructions AND : AND (bit-wise) between two operands OR : Logic OR (bit-wise) between two operands XOR : Exclusive OR (bit-wise) between two operands NOT : Logic complement (bit-wise) of an operand
18
- Examples LD %M0 [%MW0 := %MW10 AND 16#FF00] LD %I0.3
[%MW102:= NOT (%MW100)] LD 1 [%MW0 := %KW5 OR %MW10]
19
Numerical Instructions
4- Shift instructions SHL (op2,i) logic shift of i positions to the left. SHR (op2,i) logic shift of i positions to the right.
20
Application Automatic Traffic Lights steps green yellow red time
15 sec. 1 4 sec. 2 12 sec. 3 3 sec.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.