You are on page 1of 6

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).

2011

CHUYN I M HNH IU KHIN T MNG PETRI SANG GRAFCET


TRANSFORMATION OF CONTROL MODEL FROM PETRI NET TO GRAFCET Trn nh Khi Quc
i hc Nng

L Phng Quyn
Trng i hc Duy Tn

TM TT Bi bo phn tch c ch thi gian khng ng b ca mng Petri, cng c m phng v lp trnh iu khin theo thi gian thc cho cc h thng gin on theo s kin, v c ch thi gian ng b ca PLC, mt thit b iu khin ang c s dng rng ri trong cng nghip. T nhng c im trong c ch thi gian, s khc nhau trong vic lu gi s kin v tnh tng ng trong cu trc hnh hc gia mng Petri v Grafcet, tc gi xy dng phng php chuyn i mt m hnh iu khin t mng Petri sang ngn ng Grafcet. Phng php ny c kim chng trn PLC h TSX Pro ca Schneider, p dng thc nghim trn dy chuyn SAPHIR ti PFIEV Nng v mang li cc kt qu chnh xc. ABSTRACT This paper analyzes asynchronous time mechanism of Petri net, a tool for modelling and programming real time control of discrete event systems and synchronous time mechanism of PLC, a control unit widely used in industries. With the properties of time mechanism and the difference in holding events and the equivalence in geometric structure between Petri net and Garfcet, the authors design a transformation method for a control model from Petri net to Grafcet. This method is verified on the TSX Pro family of Schneider PLC and applied to the SAPHIR chain at PFIEV Danang. Thus this has brought good results.

1. S lc v mng Petri v Grafcet Mng Petri, cng c hnh hc v ton hc biu din qu trnh bin i trng thi ca cc h thng, do Carl Adam Petri xut u tin vo nm 1962. L thuyt mng Petri sau c hon thin v tr thnh cng c m hnh ha cc h thng gin on theo s kin (vit tt l DES - Discret Event System) [3]. Trong k thut iu khin, m hnh ha h thng bng mng Petri gip ngi iu khin gim st c qu trnh chia s ti nguyn, bin i trng thi, nhn bit cc xung t cu trc,... lm c s t chc qu trnh iu khin mt cch cht ch. Vi s h tr ca cc h iu hnh thi gian thc nh VxWorks, QNX, ... cng vi trnh bin dch thch hp, mng Petri khng ch dng li cng c m phng m cn tr thnh ngn ng lp trnh iu khin [4]. Trong cng nghip, PLC (Programmable Logic Controller) c s dng ngy cng ph bin trong iu khin v gim st nh hot ng n nh, d dng lp t, bo dng v thay th. Mt trong nhng u im ca PLC l ngn ng lp trnh n gin, trc quan v d s dng. Grafcet hay cn gi SFC (Sequence Flow Chart) l ngn ng
83

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).2011

lp trnh ca PLC rt ph hp khi lp trnh iu khin cc h thng tun t. u im ca Grafcet l bn thn cu trc hnh hc ca chng trnh gip ngi iu khin c th gim st s bin i trng thi ca h thng trong qu trnh iu khin. So snh v mt hnh hc, ngi lp trnh v iu khin cc h thng DES c th nhn thy mt cu trc hnh hc tng ng gia mng Petri v Grafcet. Tuy nhin, do c ch thi gian v tnh cht lu gi s kin ca mi cng c khc nhau nn nguyn tc bin i trng thi trong chng trnh iu khin vit trn mng Petri v Grafcet c nhiu im khc bit. u th ca mng Petri l c h tr bi cng c ton hc kim tra, nh gi chng trnh v cc tnh cht ca h thng. Trong khi , ngn ng Grafcet cho PLC khi kt ni n cc thit b ngoi vi c th thc hin vic iu khin v gim st mt cch rt n gin v nhanh chng. V vy, trn c s phn tch c ch lm vic v tnh c th ca mi cng c, bi bo ny xut phng php chuyn mt m hnh/chng trnh iu khin t mng Petri sang Grafcet. S kt hp ca hai cng c ny, mt mt m bo chnh xc ca chng trnh iu khin nh cu trc t mng Petri, mt khc c th kt ni v thc hin vic iu khin mt cch nhanh chng v hiu qu thng qua PLC. 2. Phn tch cc nguyn tc c bn ca mng Petri v Grafcet 2.1 Tnh tng ng gia mng Petri v Grafcet T cc nguyn tc c bn v s bin i trng thi v trao i thng tin ca mng Petri [3] v Grafcet [5], c th d dng nhn thy Grafcet l mt trng hp c bit ca mng Petri, trong mi v tr cha ti a mt token v tt c cc cung u c trng lng l 1. Mt v tr trong mng Petri ang cha mt token tng ng vi mt bc ca Grafcet ang trng thi tch cc. Cc nguyn tc AND, OR v iu kin thng chuyn tip mng Petri v Grafcet tng ng nhau. Ngoi ra, do Grafcet qui nh tc ng ch gn ti cc bc nn khi xy dng m hnh iu khin trn mng Petri, ngi lp trnh ch t tc ng ti cc bc ch khng t ti cc chuyn tip d dng cho vic chuyn i. 2.2 S khc nhau trong c ch lm vic 2.2.1 C ch khng ng b E1 E2 T1 t1 t2 T2 t3 E3 T3 Thi gian

Hnh 1. C ch lm vic khng ng b

Mng Petri lm vic theo c ch khng ng b, hay cn gi l c ch thi gian thc [1]. Nguyn tc c bn ca mng Petri l ti mi thi im ch c mt chuyn tip c thng cho d c nhiu hn mt chuyn tip iu kin thng [4]. Hnh 1 minh ha c ch x l cng vic ca mng Petri. Khi c yu cu, nu h thng rnh th cng
84

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).2011

vic s c x l ngay nh i vi trng hp T1 hoc T3. Ngc li, yu cu E2 xut hin khi h thng khng rnh nn cng vic T2 ch c th bt u c thc hin ti thi im t2 khi T1 kt thc (gi s cc cng vic c cng mc u tin). Trng hp nhiu cng vic cn c thc hin song song, h iu hnh thi gian thc phn chia lt thi gian [1] cc cng vic c thc hin lun phin. 2.2.2 C ch ng b h thng hot ng theo c ch ng b, cc cng vic ch bt u thc hin cng vic ti nhng thi im ng b. Trong Hnh 2, do cc yu cu E1 v E2 xy ra T2 T1 tk+1 tk+2 E3 T3 Thi gian

E1 tk

E2

Hnh 2. C ch lm vic ng b

gia hai thi im ng b nn cc cng vic tng ng ch c bt u thc hin ti thi im ng b tk+1. ng thi, m bo kh nng phn ng kp vi tc ng bn ngoi, c ch lm vic ng b cho php hai cng vic c bt u thc hin ng thi nh trong trng hp ca T1 v T2. PLC l mt b iu khin in hnh lm vic theo c ch ng b trong Hnh 3. Chu k ng b tng ng vi mt chu k qut ca PLC [2]. Ti cui mi chu k qut, Truyn d liu Truyn d liu sau khi ghi nhn cc s kin v x t b m ra t ngoi vi vo l chng trnh, cc tc ng mi ngoi vi b m c PLC a n bn ngoi. Do Grafcet l ngn ng lp trnh ca PLC nn n phi tun theo c ch ng b. V vy, trong nguyn tc hot ng ca Grafcet, khi c Truyn thng Thc hin nhiu chuyn tip iu kin v kim tra ni chng trnh thng th Grafcet cho thng tt c b cc chuyn tip ng thi Hnh 3. C ch lm vic ca PLC m bo s ng b ca cc cng vic. y chnh l im khc nhau c bn ca Grafcet v mng Petri. 2.2.3 Tnh cht lu gi s kin mng Petri, mt chuyn tip khi thng s ly i s token bng trng lng cung v chuyn vo v tr k tip. S token ti mt v tr th hin s ln v tr c tch cc hay mt tch cc. Trong lc , mt bc ca Grafcet ang trng thi tch cc, nu tip tc c tch cc do s kch hot ca chuyn tip trc th bc vn gi nguyn trng thi v khng c c ch ghi nhn s ln tch cc.
85

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).2011

3. Xy dng phng php chuyn i t mng Petri sang Grafcet 3.1 Mng Petri thng, bao n v Mt mng Petri thng [3], c s token ti cc v tr gii hn n v, c th chuyn i sang Grafcet bng cch s dng cc qui nh hnh hc tng ng gia mng Petri v Grafcet (Hnh 4.a). i vi hnh thc phn k kiu OR, khi chuyn sang Grafcet, m bo chng trnh cho PLC hot ng ng theo mng Petri thit k, cn phi s dng cc iu kin ph ghi trn chuyn tip (Hnh 4b). Vic s dng cc iu kin kha ln nhau s khng cho php 2 r nhnh ca php OR c tch cc ng thi trong Grafcet.

P1 a P2 b P3 c P5 3 P4 2 b

1 a 4 c a P2

P1 b P3 d P4 2

1 ab 3 c 4 d ab

c 5 =1

b)
Hnh 4. Cu trc hnh hc tng ng gia mng Petri v Grafcet

a) 3.2 Mng Petri c yu t loi tr

P10 a
A

P20 P30 b
B

tB

tA

10 P25

tA:=1 tA

30
tB

20 32 b 25 d

tB:=1

P15

31 a 15
A; tA:=0

c P19

d P29

B; tB:=0

c 19 29

a)

b)
Hnh 5. C ch loi tr trong mng Petri v Grafcet

i vi vic iu khin hai tc ng theo nguyn tc loi tr nh s dng c semaphore [6] trong mng Petri, khi chuyn sang Grafcet bng bin i hnh hc n
86

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).2011

gin, hai tc ng ny c th hot ng ng thi trn Grafcet khi iu kin thng chuyn tip n hai tc ng cng tha mn. m bo c ch loi tr trong PLC, chng ta t cc bin ph tA v tB, ng thi thit lp quyn chim gi CPU thc hin cng vic bng dng lnh c kha ln nhau ch khng phi bng cu trc. Trn Hnh 5b, khi X10 v X20 cng tch cc, do khng th thc hin ng thi cc dng lnh trn CPU nn ch tA = 1, hoc tB =1 lm X15 v X25 khng th tch cc ng thi. Gi s tA=1, khi X15 s tch cc v cng vic A ti X15 c thc hin, ng thi gii phng c tA. Ch n khi cng vic A hon thnh, X30 tch cc mi to c hi cho cng vic B gn trn X25 c thc hin. Do vy, cng vic A v B m bo hot ng theo c ch loi tr trn PLC, thc hin khi c yu cu v khi h thng rnh. 3.3 Mt v tr ca mng Petri c vai tr nh mt b m
10
P10

a 11
=1 P1 Stock+1

a
Stock

12 b 20

P0 Stock-1

b
P20

Trng hp mt v tr ca mng Petri c vai tr nh mt b m tng hoc gim ghi nh s kin trong Hnh 6, khi chuyn sang Grafcet, chng ti s dng bin m ph Stock v t thm mch phn hi mt bc ca Grafcet ch thot khi trng thi tch cc khi s Stock bng 0.

Nh vy, trc khi p dng phng php chuyn mt m hnh iu a) b) khin t mng Petri sang Grafcet, chng Hnh 6. V tr l b m ta cn xy dng v bin i mng Petri v mng Petri thng. Bng cch kt hp cc phng php trn, ngi lp trnh s nhanh chng c c chng trnh iu khin cho PLC vit trn ngn ng Grafcet m bo tnh cht ch trong cu trc.
Stock>0

13

4. nh gi qua thc nghim nh gi phng php chuyn i xy dng trn, chng ti xy dng chng trnh iu khin thanh chn s 1 v 2 bng mng Petri trn m hnh SAPHIR ti phng th nghim CRePA thuc PFIEV Nng. Yu cu iu khin khng cho hai thanh chn m ng thi v khng c qu ba chi tit gia P7 2 c2 c1 R1 1 c1 P8

t2, S2
R2

t1, S1

P9

c2

Hnh 7. S thc nghim v mng Petri

87

TP CH KHOA HC V CNG NGH, I HC NNG - S 1(42).2011

hai thanh chn. Hnh 7 l s mng Petri thc hin yu cu iu khin, trong R, S l cc tc ng m, ng thanh chn. V tr P7 cha s token bng kh nng cho php s chi tit tn ti gia hai bng chuyn. S dng cc php bin i trn chuyn sang chng trnh iu khin bng Grafcet trn PLC Schneider h TSX Pro, chng ti thu c kt qu thc nghim nh sau: - Cc cu trc Grafcet trn c PLC chp nhn; - Cc thanh chn s 1 v s 2 ch hot ng khi c sn phm n ch khng hot ng lun phin, m bo c c ch loi tr nh semaphore nh m hnh ha trn mng Petri; - Vic s dng bin ph v ng hi tip cho php Grafcet c kh nng m c s ln tch cc hay mt tch cc ca mt bc vn khng c h tr Grafcet. Kt qu thc nghim khng nh cc s chuyn i trn l chnh xc. Tuy nhin, chng trnh iu khin khi c chuyn i t mng Petri kh di dng so vi chng trnh c xy dng trc tip t PLC. Do vy, mt trong cc hng cn pht trin ca phng php ny l xy dng mt mng Petri thch hp cho Grafcet trc khi p dng cc phng php chuyn i chng trnh iu khin va m bo tnh cht ch trong cu trc mng Petri, va ngn gn v m bo s hot ng chnh xc trn PLC. 5. Kt lun Qua phn tch c ch thi gian, c ch lu gi v tnh tng ng trong biu din hnh hc gia mng Petri v Grafcet, bi bo gii thiu phng php chuyn i t mt m hnh iu khin t mng Petri sang Grafcet. Cc trng hp c bit do c ch hot ng ca PLC c gii quyt khi chuyn i v c kim chng trn thc nghim ti m hnh SAPHIR. Phng php chuyn i to ra mt lin kt cht ch gia vic thit k, m phng vi chng trnh iu khin cho cc h thng gin on theo s kin. TI LIU THAM KHO [1] Trn nh Khi Quc, Dng Quc Bo (2007), iu khin cc h thng cng nghip theo thi gian thc trn h iu hnh VxWorks, Tp ch Khoa hc v Cng ngh, i hc Nng, s 3/2007. [2] L Hoi Quc, Chung Tn Lm (1999), B iu khin lp trnh. Vn hnh v ng dng, NXB Khoa hc v K thut. [3] Robert Valette (2002), Les rseaux de Petri. LAAS-CNRS, Toulouse. [4] Jean Dominique Decotignie (2007), Grafcet and Petri nets, Neuchtel. [5] Nol Bouteille et al., (1992), Le Grafcet, Cpadus Editions. [6] Eric ZAMAI (2005), TORNATO II/VxWorks vres une programmation multi-tche et temps rel. INPG.
88