Control System Applications 2 Programming Logic Controllers PLCs

  • Slides: 20
Download presentation
Control System Applications (2) Programming Logic Controllers PLCs Lect. 9 Dr. Tarek Ahmed Mahmoud

Control System Applications (2) Programming Logic Controllers PLCs Lect. 9 Dr. Tarek Ahmed Mahmoud Tarek_momeen@yahoo. com

Outlines ü Numerical Processing q Word Objects q Word Format q Word Types q

Outlines ü Numerical Processing q Word Objects q Word Format q Word Types q Numerical Instructions

q Word Objects § Word objects are addressed in the form of words of

q Word Objects § Word objects are addressed in the form of words of 16 bits q Word Format 8 7 6 5 4 3 2 1 0 Bit position 0 0 0 1 Bit state 1 2 4 8 16 32 64 128 Bit value 256 0 1024 1 2048 1 4096 1 8192 +/- 1 16384 0 9 512 15 14 13 12 11 10 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).

q Word Format (cont. ) § Decimal 1579 § Hexadecimal 16#A 536 (max :

q Word Format (cont. ) § Decimal 1579 § Hexadecimal 16#A 536 (max : 32767, min : -32768) (max : 16#FFFF, min : 16#0000) Alternate syntax : #A 536.

q Word Types in NANO PLC 1 - Immediate values 2 - Internal words

q 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 0 to %MW 255

Word Types in NANO PLC (cont. ) 3 - Constant words - They store

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. 4 - Function Block Words %KW 0 - They are read or modified in the program. - Such as %TMi. P and %Ci. P, %Ti. v, . . . etc. to %KW 64

q Word Types in NANO PLC (cont. ) 5 - System words Words have

q Word Types in NANO PLC (cont. ) 5 - System words Words have special functions related to the PLC operation %SW 0 to %SW 127 %SW 30 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.

q Word Types in NANO PLC (cont. ) Bit objects extracted from words %

q Word Types in NANO PLC (cont. ) Bit objects extracted from words % Word object : Xk k = 0 to 15 % MW 5: x 6 Bit position 6 of internal word %MW 5.

Word Types in NANO PLC (cont. )

Word Types in NANO PLC (cont. )

q Numerical Instructions Ø Numerical instructions generally apply to 16 -bit words Ø They

q 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

q Numerical Instructions 1 - Assignment instructions These are used to load operand Op

q Numerical Instructions 1 - Assignment instructions These are used to load operand Op 2 into operand Op 1 Syntax : [Op 1: =Op 2] Op 1 is a memory word Op 2 is a memory word or an immediate value Example %MW 10: = %MW 20 LD 1 [%MW 10: %MW 20]

LDR %I 0. 3 [%MW 10: =100]

LDR %I 0. 3 [%MW 10: =100]

q Numerical Instructions 2 - Arithmetic instructions + : Add two operands - :

q 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

- Examples

- Examples

Numerical Instructions 3 - Comparison Instructions > : test if greater than. >= :

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.

- Examples

- Examples

Numerical Instructions 4 - Logic instructions AND : AND (bit-wise) between two operands OR

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

- Examples LD %M 0 [%MW 0 : = %MW 10 AND 16#FF 00]

- Examples LD %M 0 [%MW 0 : = %MW 10 AND 16#FF 00] LD %I 0. 3 [%MW 102: = NOT (%MW 100)] LD 1 [%MW 0 : = %KW 5 OR %MW 10]

Numerical Instructions 4 - Shift instructions SHL (op 2, i) logic shift of i

Numerical Instructions 4 - Shift instructions SHL (op 2, i) logic shift of i positions to the left. SHR (op 2, i) logic shift of i positions to the right.

Application Automatic Traffic Lights steps 0 green yellow red 0 0 1 0 2

Application Automatic Traffic Lights steps 0 green yellow red 0 0 1 0 2 0 3 0 0 time 15 sec. 4 sec. 12 sec. 3 sec.