You are on page 1of 48

Chng 1: Tng quan v ngn ng SFC

1.1 Cc nh ngha v ngn ng SFC


Theo Automating With PLCs SFC c nh ngha Sequential Function
Charts (SFCs) are a graphical technique for writing concur-rent control
programs[1]. Sch Programming Manual (SFC) vit: SFC, an abbreviation for
"Sequential Function Chart", is a control specification description format in
which a sequence of control operations is split into a series of steps to enable a
clear expression of the program execution sequence and execution conditions
[2]. Tuy hai ngun c cch din t khc nhau nhng chung quy ta rt ra nh
ngha SFC vit tt ca Sequential Function Chart, l mt phng php lp trnh
c bit kiu ha trong chng trnh s c chia thnh chui cc bc
(step) v iu kin chuyn tip bc(transition condition). SFC thch hp
lp trnh cho h thng c nhiu hot ng xy ra ng thi vi nhau.

1.2 Gii thiu chung v ngn ng SFC


SFC l mt trong nm loi ngn ng lp trnh tiu chun c cp
trong phin bn IEC61131-3 c cng b nm 2003. Nm ngn ng c
chun ha l lit k lnh( IL, Instruction List), s tip im (LD, Ladder
Diagram), s khi chc nng (FBD, Function Block Diagram), vn bn c
cu trc (ST, Structured Text) v biu hot ng tun t (SFC, Sequential
Function Chart).

1.3 c im ca ngn ng SFC


SFC c bit ph hp vi cc ng dng c th c cu trc thnh cc bc
xc nh r rng. Mch logic trong mt bc c th c lp trnh trong bt k
ngn ng lp trnh khc, ngoi ra SFC cn c mt s c im c bn nh sau:

Trang 1

D lp trnh v sa li chng trnh.


Chng ta c th a cc chng trnh iu khin nguyn mt nh my, iu
khin cc thit b thuc cc trm khc v ton b my mc vo chui cc khi v
bc ca mt chng trnh SFC . Vi cch lp trnh vi ngn ng c dng biu
nh SFC ngi lp trnh c th thy r hot ng ca tng bc trong h thng nn
s d dng hn cho vic k v sa li, nht l nhng ng dng phc tp nh
Hnh 1.1

Hnh 1.1. ng dng ngn ng SFC trong iu khin phc tp


[ngun: Programing Manual]
Khng cn n mch kha cho phc tp.
Mch kha cho ch c s dng trong s iu khin ng ra cho mi bc. Bi
v khng mt cng tc kha cho no c tc ng gia cc bc vi nhau trong
Trang 2

chng trnh SFC. Khi mi bc ca chng trnh SFC c kch hot bi iu


kin chuyn tip, n s xa hot ng ca bc lin trc tr mt s trng hp ta
dng n cc khi c bit.
V d v mch kha cho c cho trong Hnh 1.2.

Hnh 1.2. Mch kha cho trong chng trnh SFC

[ngun: Programing Manual]

Trang 3

SFC c s tng ng vi dng lu gii thut trong cch chuyn


t bc ny sang bc khc, ta c th quan st qua v d trong Hnh 1.3

Hnh 1.3 S tng quan gia SFC v Flowchart


[ngun: PLC

Programmable Logic Controllers theory and implementation

Second Edition]
S thit lp cho cc khi v cc bc c th thay i rt d dng cho mt
ng dng mi.
i vi cc loi ngn ng khc nh Ladder hay Instruction List khi ta mun
thay i hay m rng thm cho ng dng th ta c th phi vit li chng trnh
iu khin, iu ny gy bt li nht l nhng dy chuyn nhp khu hon ton
nc ngoi h c th m ha chng trnh khng cho php chng ta can thip.
Tuy nhin vi SFC, ta c th m rng ng dng d dng hn. Bng cch lp
Trang 4

trnh theo khi (phn ny n khng cp) th khi thm mt ng dng ta c


th lp trnh ng dng vo mt khi ring ri a vo chng trnh chnh, thng
qua cc iu kin chuyn tip chng trnh s hot ng ng theo ca
ngi lp trnh. C th:
o Tng cng ta c th to 320 khi trong mt chng trnh SFC
o Ti a 512 bc c th to trong mt khi
o C ti 2000 bc tun t c th to cho ton b cc khi ng ra.
o Mt iu kin chuyn tip khc c th c to trong uy nht mt
khi ladder.
C th to nhiu khi m u trong mt chng trnh.
Chng ta c th to mt chng trnh vi nhiu bc m u nh v d trong
Hnh 1.3. Khi c nhiu khi m u c kch hot ( S0,S1,S2,S3) ti bt k
mt bc m c iu kin chuyn tip c tha mn (t4 n t7) th bc S8 s
c thc thi.

Hnh 1.4 Chng trnh SFC vi nhiu bc m u


[ngun: Programing Manual]

Trang 5

Chng 2: Cu trc ngn ng SFC


2.1. Cu trc mt chng trnh SFC c bn
Theo tiu chun IEC, mt chng trnh SFC bao gm ba thnh phn chnh l:
Cc bc (steps)
Cc s chuyn tip(transitions)
Cc tc ng( actions)

Hnh 2.1. Cu trc mt chng rnh SFC c bn


[ngun: PLC

Programmable Logic Controllers theory and implementation

Second Edition]
2.2. Cc bc
Mt step biu din mt trng thi trong hot ng ca mt khi chng
trnh vi cc tn hiu ng vo v ng ra c xc nh theo cc hot ng lin
kt ca bc. Mt bc c th c kch hot hoc khng c kch hot. Trng
thi ca cc hot ng trong chng trnh thay i ph thuc vo trng thi ca
cc bc [3]. Mi bc c th c hoc khng c tc ng lin kt vi n. Mt
tc ng lin kt vi bc bao gm dy cc lnh PLC thc hin mt chc
nng no trong khong thi gian bc tch cc. Mt Action c th c lp
Trang 6

trnh bng mt trong bn ngn ng lp trnh cn li ca IEC61131-3


languages.[4]
Trong SFC, c cc loi bc c bn s c lit k trong cc phn di
y.

2.2.1. Initial steps


Initial step l mt bc m u, c k hiu l mt hnh vung nt i. N
i din cho s bt u ca mt mt khi. Trong mt khi chng ta c th thit
k ti a 32 bc m u.
Nu c nhiu hn mt khi m u c kch hot th chng trnh s c thc
thi nu c bt c mt iu kin chuyn tip sau bc m u c tha mn.
Ta xt v d trong Hnh 2.2 sau:

Hnh 2.2. Thit k chng trnh vi nhiu khi m u


Trong hnh trn, cc bc m u S0,S1,S2,S3 cng c kch hot, nu mt
trong cc iu kin chuyn tip t0,t1,t2,t3 c tha mn th bc S4 s c
thc thi.

2.2.2. Dummy step


Dummy step l mt bc m ti khng c chng trnh xut ra ng ra
ca PLC, do Dummy step c th c s dng nh mt bc to tr.
PLC s kim tra iu kin chuyn tip pha sau bc Dummy step tng ng
trong khonng thi gian hot ng ca n v chng trnh s x l bc tip
theo khi m iu kin chuyn tip c tha mn.
Dummy step s tr thnh mt step khi m ta to cho n mt chng trnh xut
d liu.
Trang 7

2.2.3. Coil Hold Step


Mt Coil HOLD step l mt step m ti cun dy c duy tr in
khi chng trnh chuyn qua bc khc.
Trong chng trnh SFC bnh thng khng s dng Coil Hold Step, trng thi
ON ca tip im cun dy s t ng chuyn sang trng thi OFF ngay sau khi
diu kin chuyn tip ti bc khc c tha mn. Ta c th thy r hot ng
qua Hnh 2.3.

Hnh 2.3. Hot ng ca mt bc bnh thng


[ngun: Programming Manual]
Hnh 2.3. bc n khi X1c tc ng th cun dy Y10 c cp in, khi
chng trnh chuyn qua bc n+1 th cun dy Y10 mt in v tip im
cun dy Y10 ti bc n+1 khng chuyn trng thi (vn trng thi off).
Bng cch thit k mt bc ng ra theo cch s dng Coil HOLD step,
tip im thng h ca cun dy s c tc ng li khi chng trnh ang x
l bc k tip.Ta phn tch Hnh 2.4 v Hnh 2.5 sau:
Hnh 2.4. bc n khi X1c tc ng th cun dy Y10 c cp in, tip
im Y10 ca cun dy bc n+1 ang thng h.

Trang 8

Hnh2.4. Hot ng ca Coil Hold Step


[ngun: Programming Manual]
Hnh 2.5. Khi chng trnh SFC chuyn qua bc n+1 tip im Y10 chuyn
trng thi sang ON d X1 chuyn sang trng thi OFF.

Hnh 2.5. Hot ng ca Coil Hold Step


[ngun: Programming Manual]

Trang 9

Khi trng thi ON ca cun dy c duy tr trong bc k tip, cun dy s


b mt in trong cc trng hp sau:
Khi chng trnh thc hin bc End( ngoi tr trng hp SM327 ang
ON)
Khi lnh iu khin chng trnh SFC(RST BLm) thc thi mt lnh END
cng bc ti khi ang x l.
Khi m thit b to tn hiu cho khi START/END ca chng trnh SFC
b reset.
Khi m bc reset c chc nng reset bc Coil Hold Step c kch
hot.
Khi m thit b iu khin chng trnh SFC START/STOP (SM321) b
tt.
Khi cun dy trong bc Coil Hold step b reset bi cc lnh trong
chng trnh.
Khi lnh STOP c thc thi.

2.2.4. Operation Hold Step (without transition check)


Operation Hold Step l bc m ti hot ng xut tn hiu ng ra ca
bc Operation Hold step vn tip tc sau khi chng trnh chuyn qua bc
k tip. Tuy nhin, chng trnh s khng chuyn qua bc k tip nu iu kin
chuyn tip qua bc c tha mn mt ln na. Ta quan st hot ng ca
Operation Hold Step (without transition check) qua Hnh 2.6 v Hnh 2.7 di.
Khi chng trnh SFC khng s dng Operation Hold Step (without transition
check), trng thi ON ca tip im cun dy ( c kch hot bi lnh OUT ) s
t ng chuyn sang OFF trc khi chng trnh SFC chuyn qua bc k tip.
Khi s dng Operation Hold Step (without transition check) th trng thi ng ra
ca bc ny s c gi khi chng trnh x l sang bc tip theo.
V vy khi tn hiu ng vo thay i th trng thi ca tip cun dy cng thay
i theo.
Trang 10

Hnh 2.6 Hot ng ca Operation Hold Step


[ngun: Programming Manual]

Nh trong Hnh 2.6 trn ta thy khi chuyn t bc n sang n+1 th


trng thi ng ra ca bc n l tip im cun dy Y10 khng thay i, khi
trng thi ca tn hiu ng vo cp cho Y10 l X1 chuyn t ON sang OFF trong
bc n th sau khi chuyn qua bc n+1 trng thi ca Y10 cng thay i
theo.
Hnh 2.7. Sau khi chng trnh x l sang bc tip theo s khng c s kim
tra iu kin chuyn tip t bc Operation Hold Step (without transition check)
sang bc k tip na, v vy s khng c s chuyn bc xy ra khi iu kin
chuyn tip c tha mn mt ln na. Chng trnh s thc thi bc k tip
nu iu kin chuyn tip ca bc c tha mn.

Trang 11

Hnh 2.7. Qu trnh chuyn tip


[ngun: Programming Manual]

Bc Operation HOLD step (without transition check) s b mt tch cc khi


mt trong nhng trng hp sau xy ra:
Khi bc END ca khi c thc thi.
Khi lnh iu khin chng trnh SFC(RST BLm) thc thi mt lnh END
cng bc ti khi
Khi m bc Operation HOLD step b reset bi cc lnh iu
khinchng trnh SFC( RST BLm\ RST Sn). ( ngoi tr trng hp
SM327 ang trng thi ON)
Khi m thit b to tn hiu cho khi START/END ca chng trnh SFC
b reset.
Khi m bc reset bc Operation HOLD c kch hot
Khi m rle (SM321) iu khin chng trnh SFC START/STOP b a
xung mc OFF

2.2.5. Operation Hold Step (with transition check)


Operation Hold Step l bc m ti hot ng xut tn hiu ng ra ca
bc Operation Hold step vn tip tc sau khi chng trnh chuyn qua bc
k tip. Tuy nhin, chng trnh s vn chuyn qua bc k tip nu iu kin
chuyn tip qua bc c tha mn mt ln na (c kch hot li).

Trang 12

Trong chng trnh SFC bnh thng th trng thi ON ca tip im cun
dy (c kch hot bi lnh OUT) s t ng chuyn sang OFF trc khi
chng trnh SFC chuyn qua bc k tip.
Khi s dng Operation Hold Step (with transition check) th trng thi ng
ra ca bc ny s c gi khi chng trnh x l sang bc tip theo.
V vy khi tn hiu ng vo thay i th trng thi ca tip im cun dy
cng thay i theo. Ta c th quan st s thay i ca cun dy Y10 theo X1
qua Hnh 2.8 di

Hnh 2.8. Hot ng ca Operation Hold Step

[ngun: Programming Manual]


Nh trong hnh trn ta thy khi chuyn t bc n sang n+1 th trng
thi ng ra ca bc n l tip im cun dy Y10 khng thay i, khi trng
thi ca tn hiu ng vo cp cho Y10 l X1 chuyn t ON sang OFF trong bc
n th sau khi chuyn qua bc n+1 trng thi ca Y10 cng thay i theo.
Sau khi chng trnh x l sang bc tip chng trnh s kim tra li
iu kin chuyn tip t bc Operation Hold Step (with transition check) , do
khi iu kin chuyn tip ca bc c tha mn li th chng trnh s
quay li bc va x l v thc thi n. Nu iu kin khng tha mn th
chng trnh mi thc hin bc k tip.

Trang 13

Hnh 2.9. S chuyn tip ca Operation Hold Step


(with transition check)
[ngun: Programming Manual]

Bc Operation HOLD step (with transition check) s b mt kch hot khi mt


trong nhng trng hp sau xy ra:
Khi chng trnh thc hin bc End( ngoi tr trng hp SM327 ang
ON)
Khi lnh iu khin chng trnh SFC(RST BLm) thc thi mt lnh END
cng bc ti khi ang x l.
Khi m thit b to tn hiu cho khi START/END ca chng trnh SFC
b reset.
Khi m bc reset c chc nng reset bc Coil Hold Step c kch
hot.
Khi m thit b iu khin chng trnh SFC START/STOP (SM321) b
tt.

Trang 14

2.2.6. Reset Step


Reset Step l bc m ti mt bc c chn s b xa kch hot mt
cch cng bc. Ngoi ra bc reset cn c th dng reset cc tn hiu ng ra
nh trong cc dng ngn ng khc.

Hnh 2.10. Hot ng ca bc Reset


[ngun: Programming Manual]
Khi lp trnh mt s phn mm v d nh GX-Deverloper nu mun reset mt
bc xc nh ta s th t ca bc mun reset vo Reset, khi bc Reset
c kch hot step 3 s b reset.

2.2.7. Block START Step (with END check)


Block START Step (with END check) l bc m ti khi c xc
nh bi bc s c bt u, khi chng trnh thc thi bc END ca khi
ny th chng trnh s kim tra iu kin chuyn qua bc khc.
Khi bc Block START Step (with END check) c kch hot, chng
trnh s cho php khi m c thc thi.
Chng trnh chnh s khng thc thi bt c mt hot ng no trong khi
khi m ang c x l.
Khi chng trnh x l trong khi m gp bc END th chng trnh s
ch kim tra iu kin chuyn tip.
Khi iu kin chuyn tip c tha mn th chng trnh s x l sang
bc tip theo.

Trang 15

Hnh 2.11. Hnh dng Block START Step(with END check)


[ngun: Programming Manual]

Hinh 2.12 Hot ng x l chng trnh khi gp bc


Block START Step(with END check)
[Ngun: PLC Programmable Logic Controllers theory and implementation 2nd
ed][4]
Hnh 2.12 cho ta thy hot ng ca chng trnh khi gp Block START Step.
Ta c th thy r l chng trnh chnh s r nhnh qua thc hin chng trnh
trong Block m. Sau khi chng trnh thc thi xong cc Bc trong Blockm
mi chuyn v chng trnh chnh v kim tra iu kin tip tc.

Trang 16

2.2.8. Block START Step (without END check)


Block START Step (without END check) l bc m ti khi c xc
nh bi bc s c bt u, trong lc chng trnh ang thc thi cc bc
trong khi th iu kin chuyn tip vn c kim tra.
Khi c kch hot Block START Step (without END check) s cho php
khi m c hot ng.
Sau khi khi m hot ng, iu kin chuyn tip t bc m sang
bc k tip l xung tc ng cnh ln X0 s c kim tra.

Hnh 2.13. Hnh dng Block START Step


(without END check)
[ngun: Programming Manual]
Nu iu kin chuyn tip c tha mn th chng trnh s chuyn qua
bc k tip m khng cn ch cho ti khi khi m kt thc.

2.2.9. END Step


END Step l bc m ti tt c s hot ng ca khi b dng li.
Hot ng ca bc END nh sau:
Khi bc END c kch hot cc hot ng sau s c x l kt
thc hot ng ca khi:
o Tt c cc bc trong khi b mt kch hot
o Cun dy c cp in bi lnh OUT tt c b mt in

Trang 17

2.3. S chuyn tip


Qu trnh chuyn tip l thnh phn c bn ca mt khi, sau khi PLC
thc hin xong cc lnh trong phn tc ng gn vi bc, PLC s thc hin mt
s chuyn tip ri mi thc thi bc k tip. Mt iu kin chuyn tip l iu
kin tin hnh thc hin cc bc tip theo sau khi iu kin c tha
mn. Mt chuyn tip c th ly t cc tn hiu ng vo c s thay i, kt qu
ca tc ng bc k trc hay l kt qu mt php so snh (e.g.,
IFTemp_1100 trong Hnh 2.1).[4]
Mt s loi chuyn tip c cho trong Bng 2.1
Bng2.1. Chc nng mt s chuyn tip
Loi

Serial transition

Selection transition
(branch/coupling)

Chc nng tng loi


Khi iu kin chuyn tip tha mn, bc tip theo c
thc hin, v tng t cho cc bc sau .
- Mt nhnh ra hoc vo vi nhiu iu kin chuyn tip.
- Trong s nhiu iu kin chuyn tip, bc tip theo s
c thc hin ni iu kin chuyn tip tha mn.
- Thc hin tin hnh nhiu bc t mt bc duy nht.

Parallel transition

- Khi cc bc tc thi trc khp ni c thc thi,

(branch/coupling)

bc tip theo cng s c thc thi khi cc iu kin


chuyn tip thng thng tha mn.

Jump transition

Khi iu kin chuyn tip tha mn, s tin hnh thc thi
cc bc quy nh trong cng mt khi.

Trang 18

2.3.1. Serial transition


Serial transition l qu trnh chuyn i ni tip, trong s x l v tin
hnh cc bc ngay di bc hin ti, khi cc iu kin chuyn tip tha mn.

Hnh 2.14. V tr ca Transition


.
[ngun: Programming Manual]

Qu trnh chuyn i ni tip c ti a 512 bc

trong mi

khi. V vy cng c 512 qu trnh chuyn i ni tip c m t.


Tuy nhin , c mt s hn ch v s lng cc dng nh ch ra trong hnh 2.15
di y. ph thuc vo cc hin th ct SFC.

Trang 19

Khi chng trnh SFC hin 1 hoc 2


ct th:
-

S bc(dng) ti a l 1536

S chuyn i ni tip ti a l 512

Hnh 2.15. S lng cc bc v iu kin chuyn tip


trong mt khi ca chng trnh SFC
[ngun: Programming Manual]

Trang 20

Hnh 2.15. cho ta thy trong mt chng trnh SFC, s c ti a 32 hot ng


song song (32 ct) v khi trrong khi s c s lng cc bc tnh theo cng
thc trn.
Bng 2.2 lit k s dng tng ng ti a vi s ct ca SFC
Bng 2.2: S lng cc dng v cc ct trong mt khi ca mt chng
trnh SFC
S ct hin th

S bc hin th ti a tng ng

1 hoc 2

1536

384

16

192

22

138

28

108

32

96

2.3.2. Selection transition


Selection transition l s la chn chuyn tip, trong x l song song
cc iu kin chuyn tip. iu kin chuyn tip nhnh no tha mn th bc
tip theo ca nhnh c thc hin.
Ta xt s la chn r nhnh v la chn ghp ni theo Bng 2.3 sau:

Trang 21

Bng 2.3: S hot ng ca cc iu kin chuyn tip


T bc n s x
l thc thi bc
n+1 hoc n+2
thng qua hai iu
kin

chuyn

tip

b hoc c tng
ng.
Nu c 2 iu kin
chuyn

tha mn ng thi,
R

th iu kin bn

nhnh

tri s c u tin.
Bc n s ngng
hot ng.
X l cc bc
cng nh cc iu
kin c tin hnh
tip tc trong tng
ct cho n khi gp
mt khp ni song
song.

Trang 22

Khi cc iu kin
chuyn i b hoc
c c tha mn
Ghp

th cc bc thc

ni

thi [A] hoc [B] s


b ngng hot ng.
Bc

n+2

c thc thi.

S c ti a 32 bc c sn la chn chuyn i.

Hnh 2.16: S lng cc bc c th chn la trong mt


khi
[ngun: Programming Manual]
Khi hai hoc nhiu iu kin la chn chuyn tip tha mn, th iu kin tn
cng bn tri c u tin.
V d: hnh 2.16 Khi iu kin chuyn tip c, d, e cng tha mn th
chng trnh SFC s u tin chn bc n+2 thc thi trc tin.

Trang 23

Hnh 2.17: La chn bc u tin


[ngun: Programming Manual]
Trong mt qu trnh la con chuyn i, s la chn ghp ni c th c b
qua bi mt chuyn i nhy, hoc chuyn i kt thc.
Khi iu kin chuyn tip b tha
mn th bc n+1 c thc thi,
sau tip tc kim tra chuyn tip
v thc thi cc bc pha di, cho
n khi iu kin chuyn tip d
tha mn th thc thi chuyn tip
nhy n bc n.

Hnh 2.18. Chuyn tip nhy bc


[ngun: Programming Manual]
Ch : Trong mt qu trnh chuyn i c chn lc, s lng chi nhnh v s
lng ca khp ni c th khc nhau.
Tuy nhin, mt chi nhnh la chn v khp ni song song hoc mt chi nhnh
song song v la chn khp ni khng th c kt hp.

Trang 24

2.3.3. Parallel transition


Parallel transition l s qu trnh chuyn tip song song. Trong cc
bc lin kt song song c thc thi ng thi khi iu kin chuyn tip tha
mn.
Bng 2.4. S hot ng ca cc iu kin chuyn tip
T bc n nu iu
kin chuyn tip b
tha mn th s thc
hin ng thi bc
R
nhnh

n+1 v bc n+3
iu

kin

chuyn

tip c tha mn th
thc

hin

bc

n+2, cn d tha
mn s thc hin
bc n+4
Khi iu kin chuyn
tip b, c tha
mn th bc n,
n+1

ngng

hot

ng v thc thi cc
Ghp
ni

bc ch i.
Bc ch i c
s dng ng b
ha song song. Khi
iu kin chuyn tip
d c tha mn
cc bc ch i,

Trang 25

chng trnh s tin


hnh thc thi bc
n+2.
Bc ch i l bc
gi

lp

(dummy

steps) vi yu cu
khn c u ra hot
ng

C ti a 32 bc x l ng thi cc chuyn i song song.

Hnh 2.19: S bc ti a c th la chn


[ngun: Programming Manual]
Nu khi khc c bt u bng cc hot ng x l song song, khi ngun bt
u khi v bt u khi im n s c thc thi cng mt lc. Trong v d
di bc n+1 s c thc hin ng thi vi khi 1.

Trang 26

Khi iu kin chuyn tip


b tha mn sau khi thc
hin bc n, th bc
n+1 v

khi 1 s c

thc thi ng thi. Sau


khi 0 v khi 1 s c x
l ng thi.
Hnh 2.20. Thc thi khi v bc
[ngun: Programming Manual]
Khp ni phi c s dng khi cn ti cc cc bc thc thi v iu kin
chuyn tip song song. Chng trnh c to ra khng th khng c khp ni.

Hnh 2.21: Chuyn tip song song


Theo quy nh, mt bc ch i phi c to ra trc khi thc hin
khp ni. Tuy nhin, trong trng hp nh v d di y ca cc ct qu trnh
chuyn i song song bao gm ch c 1 bc (chng trnh m khng cn mt
iu kin chuyn tip gia cc qu trnh chuyn tip song song chi nhnh v
khp ni), mt bc ch i khng cn thit.
Trang 27

Hnh 2.22: Khp ni song song


[ngun: Programming Manual]

2.3.4. Jump transition


Jump transition l mt chuyn tip nhy, mt chuyn tip c quy nh
trong cng mt khi, bc ny c thc thi khi iu iu kin chuyn tip tha
mn.

Hnh 2.23: Chuyn tip ca bc nhy


[ngun: Programming Manual]
hnh 2.23. khi iu kin chuyn tip b tha mn th bc n s ngng hot
ng, chng trnh chuyn qua thc hin bc m.
Khng c hn ch v s lng ca qu trnh chuyn i nhy trong mt khi duy
nht.
Trong cc nh dng chuyn tip song song, ch c th nhy theo hng thng
ng tng chi nhnh.

Trang 28

Chng 3: Lp trnh bng ngn ng SFC vi PLC


ca Mitsubish
Mt s dng PLC ca hng Mitsubishi cho php lp trnh vi ngn ng
SFC, tuy nhin cng c mt s dng khng h tr. Khi lp trnh ta c th chuyn
i sang ngn ng khc m PLC h tr. Cc dng PLC Mitsubishi cho php lp
trnh vi ngn ng SFC [xem ph lc 1]

3.1. Ngn ng SFC vi PLC ca Mitsubishi


Ngn ng SFC l ngn ng quc t c chun ha, do cc nh sn
xut PLC khi s dng SFC lp trnh cho PLC ca h u phi theo chun ca
ngn ng v i vi hng Mitsubishi cng khng ngai l. Tuy nhin khi ng
dng mt ngn ng chun vo th nh sn xut vn c mt s t thay i.
i vi PLC Mitsubishi ngn ng SFC c mt s ty chnh cc bc
thc thi. Mt v d c th l khi lp trnh bng phn mm GX Developer, phn
ng ra v iu kin chuyn tip c lp trnh ring trong 1 ca s khc. Cn i
vi mt s phn mm khc nh: phn mm CoDeSys, phn mm RSLogix 5000
th phn xut d liu ng ra, iu kin chuyn tip c lp trnh lin k vi
khi chc nng tun th theo ng ngn ng SFC. [ph lc 2]

3.2. Trnh t lp trnh bng ngn ng SFC


Trnh t lp trnh bng ngn ng SFC c th chia thnh cc bc cc bc
c bn sau
Bc 1: T yu cu ca h thng cn lp trnh, ta tin hnh xc nh s u vo
v u ra. Mi lin h gia cc u vo v u ra ny.
Bc 2: Xc nh s bc, s iu kin chuyn tip, cc hot ng cng lc,
hot ng theo trnh t, lin tc hoc gin on
Bc 3: Tin hnh lp lu gii thut, t lu gii thut ta tin hnh lp
trnh chi tit trn phn mm.

Trang 29

3.3. Trnh t PLC thc hin cc bc trong chng trnh SFC


Ta xt v d Hnh 3.1

Hnh 3.1. Cu trc mt chng rnh SFC c bn


[ngun: Programming Manual]
Chng trnh SFC s thc hin mt chui cc cng on, bt u t bc u
tin, sau thc hin bc tip theo khi iu kin chuyn tip c tha mn,
v kt thc vi bc END.
C th:
Khi chng trnh SFC c bt u, chng trnh s chy bc trn cng
u tin( bc kim tra iu kin khi ng)
Chng trnh c thc hin bc u cho ti khi iu kin 1 c tha
mn. Khi iu kin 1 tha mn, hot ng ca bc u s b dng li, v
chng trnh s thc hin bc tip theo.
Hot ng ca chng trnh SFC tip tc t bc ny qua bc khc theo
cch nh trn cho ti khi bc kt thc END c thc hin.

Trang 30

3.4. Chuyn i ngn ng SFC sang dng ngn ng khc


Ngn ng SFC c th chuyn i sang cc dng ngn ng khc, tuy nhin
s chuyn i khng phi chuyn i hon ton. Trong v d Hnh 3.2 ta s xt
cc bc chuyn i mt chng trnh vit bng ngn ng SFC sang ngn ng
Ladder.
V d 3.1: Chng trnh SFC iu khin cho mt my dp
Nguyn l hot ng ca my:
Nhn nt Start, nu nt nhn automatic c nhn tip th chng trnh s
bt ngun cho my dp v n bo sng. Khi cm bin xc nh vt phm, ba
dp s c y xung v chm cng tc hnh trnh hn di. Khi gp cng tc
hnh trnh hn di, ba dp c nng ln li cho ti khi gp cng tc hnh
trnh hn trn, v ba dp s dng hot ng.
Mt nt nhn dng khn cp c thit k c th dng chng trnh khi
ba dp ang hot ng. Khi chng trnh hoat ng xong mt chu trnh, mt
nt reset c tc ng trc nt automatic. Sau bc th 6 chng trnh s ch
cho vt phm c ly ra ri mi chuyn qua bc khc.

Trang 31

Hnh 3.2: Chng trnh SFC iu khin my dp


[ngun: Automating With PLCs]

Trang 32

Chng trnh SFC c th chuyn i trc tip qua dng Ladder logic theo cch
sau:
Phn u chng trnh Ladder s bt u vi mt bc khi ng cc trng
thi v cc iu kin. Mt iu kin bt u s qut ton b cc bc v iu
kin trong chng trnh SFC.

Trang 33

Phn tip chng trnh ladder l kim tra iu kin chuyn tip c tha
mn hay khng. Nu iu kin chuyn tip c tha mn th bc hoc iu
kin chuyn tip k tip c kch hot v iu kin chuyn tip ban u b xa.

Trang 34

Sau khi mi bc c xt v chng trnh logic chuyn qua bc khc,


Vic quan trng tip theo ca vic lp trnh l kim tra v thc hin cc thao tc
xut tn hiu ra ng ra thc hin cc thao tc.

Trang 35

Trang 36

Chng 4: Nhng ng dng ngn ng lp trnh SFC


y ta s dng phn mm GX-Developer lp trnh [ph lc 3 ]

4.1. Chng trnh SFC iu khin hai n sng theo gin


thi gian Hnh 4.1

Hnh 4.1 Gin thi gian hot ng ca hai bng n


Yu cu: S dng SFC lp trnh cho hai n sng theo gin thi gian Hnh
4.1. Trong gin thi gian, Plight_1 sng trong 1s trong khi Plight_2 ang tt,
sau Plight_1 trong 1s ng thi lc ny th Plight_2 sng . mt nt Start v
mt nt Reset c thit k nh trong Hnh 4.1. Khi nhn nt Reeset th c hai
n u tt. Mch cn bao gm mt n bo ngun (Light_EN) s sng sau khi
nhn

Start

ch

tt

khi

nhn

nt

Reset.

Hnh 4.2 Gin thi gian hot ng ca cc nt nhn v n

Trang 37

Bng 4.1 cc thit b ng vo ng ra trong ng dng 4.1


a ch thit

Tn thit b

Hot ng

X0

ST: Start

Nt khi ng

X1

Reset

Nt Reset

T0

T1

timer

T1

T2

Timer

Y0

Plight_1

iu khin n 1

OUTPUT Y1

Plight_2

iu khin n 2

Plight_EN

iu khin n bo ngun

Loi

INPUT

Y2

Trang 38

Plight_1=False
0

Plight_2 = False
START

Reset

NOT Reset

Plight_1 = ON

Reset
2

Light_EN(R)

Plight_2 = OFF
Light_EN(S)

TRUE

T1 = 1s

Plight_1 = OFF
4
Plight_1 = ON
T2 = 1s

Hnh 4.3 Chng trnh SFC iu khin hai bng n


Chng trnh lp trnh bng phn mm GX-Deverloper(xem ph lc 4)

4.2 iu khin bng ti


Cho mt h thng gm c 2 thng hng, 1 cnh tay robot gp sn phm, 3
bng truyn di chuyn sn phm. Thit k h thng theo yu cu sau:
Thng hng 1 c sn phm, cm bin X5 nhn bit c sn phm th cnh
tay robot gp hng a ln bng truyn 1.
Cm bin X0 xc nh c sn phm, bng truyn 1 hot ng, sn phm di
chuyn v chuyn tip qua bng truyn 2.

Trang 39

Cm bin X1 xc nh sn phm, bng truyn 1 ngng hat ng, bng


truyn 2 hot ng, sn phm di chuyn xung bng truyn 3.
Cm bin X2 xc nh sn phm, bng truyn 2 ngng hot ng, bng
truyn 3 hot ng a sn phm vo thng hng th 2.
Kt thc 1 chu trnh lm vic, v bt u 1 chu trnh mi, h thng s
ngng hot ng khi thng hng 1 ht sn phm.
Vi cnh tay robot c a ch Y7, cm bin xc nh cnh tay robot khi
v tr thng hng 1 l X5, bng truyn 1 trn cao l Y0, cm bin u bng
truyn trn cao l X0, bng truyn 2 l Y2, cm bin u bng truyn 2 l X1,
bng truyn 3 l Y4, cm bin u bng truyn 3 l X2, cm bin vt th vo
thng hng 2 l X3.

Hnh 4.4. H thng bng ti


[ngun:phn mm FXTRN-BEG-E]

Trang 40

Bng 4.2. Chi tit ng vo v ra


Loi

a ch thit b

Tn thit b

Hot ng

Cm bin

Nhn bit sn phm

X0
X1
Input

X2
X3
X4
Y0

Bng truyn 1

Y2

Bng truyn 2

Y4

Bng truyn 3

Y7

Cnh tay robot

Di chuyn sn phm

Output
Gp sn phm

Trang 41

START
X5 = 1
Tay Robot

Y7

Y0

Y2

Y4

X0 =1

Bng 1

X1 = 1

Bng 2
X2 = 1

Bng 3
X3 = 1

Hnh 4.5. Biu hot ng ca chng trnh


Chng trnh lp trnh bng phn mm GX-Deverloper [ ph lc 5]

4.3 ng dng SFC lp trnh cho h thng trn nguyn liu


Qu trnh hot ng:
H thng trn nguyn liu c nhim v trn hai khi A v B cha cc
nguyn liu rn vi mt khi lng cht lng tng ng bao gm cht lng A
v B . Mt nt khi ng(ST) c th la chn ch hot ng iu khin bng
tay hoc t ng iu khin qu trnh o lng v trn nguyn liu bt u
Trang 42

vi s hot ng cng lc ca hai nhm thit b l bng ti vn chuyn v hot


ng cn khi lng.
Qu trnh nh sau:
Loi cht lng A s c cho chy vo mng C vi khi lng l a, sau
cht lng B cng c cho vo mt lng c khi lng l b, qu
trnh ny c kim sot bi cn WC.
Hai khi cha nguyn liu rn c bng ti a vo bung trn.
Sau khi kt thc hai qu trnh a nguyn liu rn v van VC m cho
cht lng vo bung trn th motor my trn s lm vic, sau mt thi gian trn
c t l t1, qu trnh trn kt thc, motor MP c nhim v nghing bung
trn sn phm i ra. Khi bung trn ht sn phm, motor MP s a
bung trn v v tr xc nh bi S0, v motor MR hot ng li.

Trang 43

Hnh 4.1. S h thng trn nguyn liu

Trang 44

Chng trnh SFC iu khin hot ng ca h thng trn nguyn liu

START

DONE

ST & S0 & WC <= Z

Weigh A

VA

BRICK 1

WC >= WA+Z
Weigh B

MT

d right
N

DROP 1

VB

WC >= WA+WB+ Z
FILL

d wrong
VC

BRICK 2
d right
DROP 2

MT

WC <= Z & d wrong


MIX

MR

T_MIX >= t1
TIP

N MP1 S1
S1

RAISE

S0

MR

N MP0 S0

Hnh 4.1. Chng trnh SFC iu khin qu trnh trn nguyn liu

Trang 45

Ti liu tham kho


[1] Automating With PLCs,
[2] Programming Manual (SFC),
[3] IEC 61131-3 Programmable controllers - Programming languages,
[4] Luis Bryan & Eric Bryan. PLC Programmable Logic Controllers theory and
implementation Second Edition.

Trang 46

MC LC
Chng 1: Tng quan v ngn ng SFC......................................................................................1
1.1 Cc nh ngha v ngn ng SFC .................................................................................. 1
1.2 Gii thiu chung v ngn ng SFC ............................................................................... 1
1.3 c im ca ngn ng SFC ........................................................................................ 1
Chng 2: Cu trc ngn ng SFC..............................................................................................6
2.1. Cu trc mt chng trnh SFC c bn ........................................................................ 6
2.2. Cc bc ..................................................................................................................... 6
2.2.1. Initial steps ................................................................................................................7
2.2.2. Dummy step ..............................................................................................................7
2.2.4. Operation Hold Step (without transition check)
2.2.5. Operation Hold Step (with transition check)
2.2.7. Block START Step (with END check)
2.2.8. Block START Step (without END check)

..............................................10
....................................................12

...............................................................15
..........................................................17

2.2.9. END Step ................................................................................................................17


2.3. S chuyn tip ........................................................................................................... 18
2.3.1. Serial transition ........................................................................................................19
2.3.2. Selection transition ..................................................................................................21
2.3.3. Parallel transition .....................................................................................................25
2.3.4. Jump transition ........................................................................................................28
Chng 3: Lp trnh bng ngn ng SFC vi PLC ca Mitsubish .............................................29
3.1. Ngn ng SFC vi PLC ca Mitsubishi ..................................................................... 29
3.2. Trnh t lp trnh bng ngn ng SFC........................................................................ 29
3.3. Trnh t PLC thc hin cc bc trong chng trnh SFC ......................................... 30
3.4. Chuyn i ngn ng SFC sang dng ngn ng khc ................................................ 31
Chng 4: Nhng ng dng ngn ng lp trnh SFC .................................................................37
4.1. Chng trnh SFC iu khin hai n sng theo gin thi gian Hnh 4.1 ............... 37
4.2 iu khin bng ti .................................................................................................... 39
4.3 ng dng SFC lp trnh cho h thng trn nguyn liu ............................................... 42

Ti liu tham kho.....................................................................................................................46