You are on page 1of 9

Phép toán nhị phân

I0.0 I0.1 Q 8.0

Q 8.1 (MCRA)

I 0.0
( MCR< )

I 1.0 I 1.1 Q 8.0


( )

M0.0
I1.2 Q 9.3
SR
S Q

I1.3
R

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.1

Tiếp điểm thường mở, thường đóng, cảm biến, ký hiệu

Xử lý Xử lý kỹ thuật lập trình PLC

Cảm biến cảm biến bị ... Có điện áp Tình trạng Kiểm tra tình trạng tín Check for
là ... tại cổng vào Tín hiệu hiệu “1” signal state “0”
không cổng vào
Ký hiệu/ Kết quả Ký hiệu/ Kết quả
Câu lệnh kiểm tra Câu lệnh kiểm tra

NO Tác động
contact LAD: LAD:
Yes 1 “Yes“ “No”
1 0
“NO contact” “NC contact”

Không No
Tác động 0 “No” “Yes”
0 1
FBD: FBD:

& &
NC Tác động No
contact 0 “No” “Yes”
0 1

Không STL: STL:


Tác động Yes 1 “Yes” “No”
A I x.y 1 AN I x.y 0

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.2

Seite 1
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Địa chỉ của các module S7 300

Slot No. 1 2 4 5 6 7 8 9 10

Modules PS CPU SM SM SM SM SM SM SM

Address 0.0
Address 0.7
Address 1.0
Address 1.7

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.3

Địa chỉ DI/DO trong cấu hình đa tầng

PS IM 96.0 100.0 104.0 108.0 112.0 116.0 120.0 124.0


Rack
3 (Receive) to to to to to to to to
99.7 103.7 107.7 111.7 115.7 119.7 123.7 127.7

PS IM 64.0 68.0 72.0 76.0 80.0 84.0 88.0 92.0


Rack (Receive) to to to to to to to to
2 67.7 70.7 75.7 79.7 83.7 87.7 91.7 95.7

PS
IM 32.0 36.0 40.0 44.0 48.0 52.0 56.0 60.0
Rack to to to to to to to to
1 (Receive)
35.7 39.7 43.7 47.7 51.7 55.7 59.7 63.7

PS 0.0 4.0 8.0 12.0 16.0 20.0 24.0 28.0


CPU IM
Rack (Send) to to to to to to to to
0 3.7 7.7 11.7 15.7 19.7 23.7 27.7 31.7

Slot 1 2 3 4 5 6 7 8 9 10 11

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.4

Seite 2
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Taäp leänh : Kí hieäu: KQ laø keát quaû thu ñöôïc sau pheùp tính
KT laø keát quaû tröôùc pheùp tính
A.Thanh Ghi Traïng Thaùi:
Khi thöïc hieän leänh, CPU seõ ghi laïi traïng thaùi cuûa pheùp tính trung gian cuõng nhö cuûa keát
quaû vaøo moät thanh ghi ñaëc bieät 16 Bits, ñöôïc goïi laø thanh ghi traïng thaùi ( Status Word)

Maëc duø thanh ghi traïng thaùi naøy coù ñoä daøi 16 Bits nhöng chæ söû duïng 9 Bits vôùi caáu truùc
nhö sau:

FC ( First check) : Khi phaûi thöïc hieän moät daõy caùc leänh logic lieân tieáp nhau goàm caùc
pheùp tính and, or vaø not, bit FC coù giaù trò baèng 1, hay noùi caùch khaùc,FC=0 khi daõy leänh
Logic tieáp ñieåm vöøa ñöôïc keát thuùc.
RLO (Result of logic operation) : Keát quaû töùc thôøi cuûa pheùp tính logic vöøa ñöôïc thöïc
hieän
STA (Status bit) : Bit traïng thaùi naøy luoân coù giaù trò logic cuûa tieáp ñieåm ñöôïc chæ ñònh
trong leänh.
OR :Ghi laïi giaù trò cuûa pheùp tính logic and cuoái cuøng ñöôïc thöïc hieän ñeå phuï giuùp cho
vieäc thöïc hieän pheùp toaùn or sau ñoù. Ñieàu naøy laø caàn thieát vì trong moät bieåu thöùc haøm 2
trò, pheùp tính and bao giôø cuõng phaûi ñöôïc thöïc hieän tröôùc caùc pheùp tính or.
OS (Stored overflow bit) : Ghi laïi giaù trò Bit bò traøn ra ngoaøi maûng oâ nhôù.
OV(Overflow Bit): Bit baùo caùo keát quaû pheùp tính bò traøn ra ngoaøi maûng oâ nhôù.

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.5

CC0 vaø CC1 ( Condition code) : Hai bit baùo traïng thaùi cuûa keát quaû pheùp tính vôùi soá
nguyeân, soá thöïc pheùp dòch chuyeån hoaëc pheùp tính logic trong ACCU

BR ( Binary result bit) : Bit traïng thaùi cho pheùp lieân keát hai loaïi ngoân ngöõ laäp trình
STL vaø LAD . Chaúng haïn cho pheùp ngöôøi söû duïng coù theå vieát moät khoái chöông trình
FB hoaëc FC treân ngoân ngöõ STL nhöng goïi vaø söû duïng chuùng trong moät chöông trình
khaùc vieát treân LAD. Ñeå tao ra ñöôïc moái lieân keát ñoù, ta caàn phaûi keát thuùc chöông trình
trong FB, FC baèng leänh ghi:

BR = 1 : neáu chöông trình chaïy khoâng coù loãi


BR = 0 : neáu chöông trình chaïy coù loãi
Khi söû duïng caùc khoái haøm ñaëc bieät cuûa heä thoáng (SFC hoaëc SFB) , traïng thaùi laøm
vieäc cuûa chöông trình cuõng ñöôïc thoâng baùo ra ngoaøi qua bit traïng thaùi BR nhö sau:
BR=1 neáu SFC hay SFB thöïc hieän khoâng coù loãi
BR=0 neáu coù loãi khi thöïc hieän SFC hay SFB

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.6

Seite 3
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Các liên kết nhị phân: AND, OR

Circuit Diag. LAD FBD STL

S1 (I 0.0)
I0.0 I0.1 Q 8.0 I 0.0 & Q 8.0 A I0.0
= A I0.1
AND S2 (I 0.1) I 0.1
= Q 8.0
Q 8.1 Q 8.1 = Q 8.1
=

L1 L2
(Q 8.0) (Q 8.1)

S3
(I 0.2) I0.2 Q 8.2
Q 8.2 O I0.2
S4 I 0.2 >=1
OR = O I0.3
(I 0.3) I 0.3 = Q 8.2
I0.3

L3 (Q 8.2)

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.7

Liên kết nhị phân: Exclusive OR (XOR)

LAD FBD STL

I 0.4 & A I0.4


I0.4 I0.5 Q 8.0 Q 8.0 AN I0.5
I 0.5 >=1 O
=
AN I0.4
I 0.4 & A I0.5
I0.4 I0.5 I 0.5 = Q8.0

Q 8.0 X I0.4
I 0.4 XOR X I0.5
=
I 0.5 = Q8.0

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.8

Seite 4
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Kết quả, Setting, Resetting

LAD FBD STL

I 1.0 I 1.1 Q 8.0 A I 1.0


I 1.0 A I 1.1
& Q 8.0
Kết quả ( ) = Q 8.0
I 1.1 =

I 1.2 I 1.3
Q 8.1 I 1.2 A I 1.2
& Q 8.1
Set (S ) A I 1.3
I 1.3 S S Q 8.1

I 1.4 Q 8.1
(R ) I 1.4 O I 1.4
>=1 Q 8.1 O I 1.5
Reset I 1.5 R R Q 8.1
I 1.5

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.9

Setting / Resetting một Flip Flop


LAD FBD STL

M0.0 M0.0
I0.0 Q 0.0 A I 0.0
SR SR S M 0.0
Ưu tiên S Q I0.0 S
Reset A I 0.1
Q0.0 R M 0.0
I0.1
R Q = A M 0.0
R I0.1 = Q 0.0

M0.0 M0.0
I1.3 Q 0.0 A I 1.3
Ưu tiên RS RS R M 0.0
R Q I1.3 R
Set A I 1.2
Q0.0 S M 0.0
I1.2
Q = A M 0.0
S I1.2 S = Q 0.0

Leänh SR:
Neáu I0.0=1 , I0.1=0 thì M0.0=1, Q0.0=1 Leänh RS:
Neáu I0.0=0 , I0.1=1 thì M0.0=0 , Q0.0=0 Neáu I1.3 =1 , I1.2 =0 thì M0.0=1, Q0.0=0
Neáu I0.0=I0.1=0 Thì khoâng coù gì thay ñoåi. Neáu I1.3 =0 , I1.2=1 thì M0.0=0 , Q0.0=1
Neáu I0.0=I0.1=1 thì M0.0=Q0.0=0 Neáu I1.3 =I1.2=0 Thì khoâng coù gì thay ñoåi.
Neáu I1.3 =I1.2=1 thì M0.0 = Q0.0=1

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.10

Seite 5
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Connector

LAD STL

I 1.0 I 1.1 M0.0 I 2.0 I 2.1 M 1.1 Q 4.0


( ) NOT ( ) ( ) A I 1.0
A I 1.1
= M 0.0
A M 0.0
FBD A I 2.0
A I 2.1
NOT
I 1.0 & = M 1.1
M0.0
A M 1.1
I 1.1 &
= Q 4.0
I 2.0 M1.1 Q 4.0

I 2.1 =

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.11

Những lệnh ảnh hưởng đến RLO


LAD FBD STL

A I0.0
I0.0 I0.1
Q8.0 I0.0 & A I0.1
NOT Q8.0
NOT ( ) I0.1 = NOT
= Q8.0

CLR not available not available CLR

SET not available not available SET

I1.6 A I1.6
SAVE ( SAVE ) I1.6 & SAVE SAVE

BR Q8.1 Q8.1 A BR
BR ( ) BR = = Q 8.1

15 8 1
Status word
BR RLO

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.12

Seite 6
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Lệnh nhảy Jump (không phụ thuộc vào RLO)

LAD FBD STL

Network 1 Network 1 Network 1


NEW1 NEW1
( JMP ) .... JMP JU NEW1

Network 2 Network 2 Network 2


: : :
: : :
: : :
: : :
Network x Network x Network x

NEW1 NEW1

M5.5 I4.7 M69.0 NEW1: AN M5.5


M5.5 & M69.0
( ) AN I4.7
I 4.7 = = M69.0

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.13

Nhảy có điều kiện (phụ thuộc vào RLO)

LAD FBD STL

I 0.0 I 0.1 NEW1 I0.0 & A I0.0


Jump if NEW1 A I0.1
RLO=1 (JMP) I0.1 JMP JC NEW1

Jump if I 0.2 I 0.3 I0.2 & A I0.2


NEW2 NEW2
RLO=0 A I0.3
(JMPN) I0.3 JMPN JCN NEW2

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.14

Seite 7
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Nhận biết RLO
LAD FBD STL

A I1.0
I1.0 I1.1 M1.0 M8.0 I1.0 &
M1.0 M8.0 A I1.1
P FP M1.0
I1.1 P = = M8.0

I1.0 I1.1 M1.1 M8.1 I1.0 A I 1.0


& M8.1 A I 1.1
M1.1
N FN M1.1
I1.1 N = = M8.1

OB1-Cycle
I1.0

I1.1

RLO
Example
M1.0

M1.1

M8.0
M8.1

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.15

Nhận biết sườn tín hiệu Signal


LAD FBD STL

I1.1 I1.0 & A I1.0


I1.0 M8.0 I1.1 A (
POS POS M8.0 A I1.1
Q
M1.0 M_BIT = FP
M1.0 M_BIT M1.0
)
I1.1 I1.0 =
I1.0 M8.1 &
I1.1 M8.0
NEG A I1.0
Q NEG M8.1
A (
M1.1 M_BIT M1.1 M_BIT = A I1.1
FN
M1.1
I1.0 )
=
I1.1 M8.1

Example M1.0

M1.1
OB1-Cycle
M8.0

M8.1

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.16

Seite 8
CuuDuongThanCong.com https://fb.com/tailieudientucntt
Continuous filling operation PLC program

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.17

Bài tập: Lập trình cho hệ thống làm đầy chai (chọn chế độ)
Hệ thống ON/OFF: Chế độ tay/tự động:
I 0.0 = Start (Tiếp điêm NO) I 0.4 = Tay/tự động (công tắc)
I 0.1 = Stop (Tiếp điểm NC) I 0.5 = Thay đổi chế độ (tiêp điểm NO)

I 0.2 = Chạy thuận (M-C sw., NO funct.)


I 0.3 = Chạy ngược (M-C sw., NO func.)

Cảm biến
I 16.6 (I 8.6)

M
Q 20.5 (Q 8.5) Băng tải chạy thuận
Q 20.6 (Q 8.6) Băng tải chạy ngược

SIMATIC S7 Date: 28.08.2014 Information and Training Center


Knowledge for Automation
Siemens AG 1999. All rights reserved. File: PRO1_06E.18

Seite 9
CuuDuongThanCong.com https://fb.com/tailieudientucntt

You might also like