You are on page 1of 55

Bo co thc tp

LI NI U
Ngy nay, cc thit b t ng ha ang ng mt vai tr v cng quan trng trong cuc sng con ngi n cng gp phn ln vo s pht trin ca nn kinh t quc dn. Cc thit b ny gip con ngi rt nhiu trong lao ng sn xut, n gii phng c sc lao ng, nng cao sn lng hng ha, to ra nhiu ca ci vt cht. Nh c t ng ha m cuc sng chng ta ngy nay c ci thin r rt, tt p hn, d dng hn, no hn. Thc tp tt nghip l mt c hi v mt khong thi gian qu bu mi sinh vin t trau ri kin thc, kinh nghim bn thn v tm hiu lm quen vi cng vic ca mnh trong tng lai. t thc tp khng nhng gip sinh vin hc tp cc kin thc k thut thc t m cn gip sinh vin hnh dung cng vic ca mnh trc khi ra trng. Do tm quan trng ca vic thc tp nn theo chng trnh o to k s ti trng HBKHN trc khi ra trng t chc cho sinh vin i thc tp chuyn ngnh 5 tun. Trong qu trnh thc tp ti cng ty ng dng gii php cng ngh ASTEC, a ch: S 172/1/15 Nguyn Tun - Thanh Xun - H Ni, em rt c nhiu kin thc v cc thit b iu khin hin i nh LOGO, PLC, bin tn... iu gip em c mt li suy ngh r rng hn v ng dng ca chng trong cuc sng. c s gip v hng dn tn tnh ca thy Kit v thy Tun trong qu trnh thc tp, chng em thu c rt nhiu kin thc k thut thc t b ch hon thnh c t thc tp ny. Do thi gian v kin thc cn hn ch nn bn bo co thc tp ny khng th trnh khi nhng thiu xt, em rt mong nhn c s nhn xt v gp ca thy c bn n c hon thin hn. Em xin chn thnh cm n.

Bo co thc tp

PHN I: THIT B PLC CHNG 1: GII THIU V PLC


1. Gii thiu chung: PLC vit tt ca Programmable Logic Controller, l thit b iu khin lp trnh c (kh trnh) cho php thc hin linh hot cc thut ton iu khin logic thng qua mt ngn ng lp trnh. Ngi s dng c th lp trnh thc hin mt lot trnh t cc s kin. Cc s kin ny c kch hot bi tc nhn kch thch (ng vo) tc ng vo PLC hoc qua cc hot ng c tr nh thi gian nh th hay cc s kin c m. PLC dng thay th cc mach relay (r le) trong thc t. PLC hot ng theo phng thc qut cc trng thi trn u ra v u vo. Khi c s thay i u vo th u ra s thay i theo. Ngn ng lp trnh ca PLC c th l Ladder hay State Logic. Hin nay c nhiu hng sn xut ra PLC nh Siemens, Allen-Bradley, Mitsubishi Electric, General Electric, Omron, Honeywell... Mt khi s kin c kch hot tht s, n bt ON hay OFF thit b iu khin bn ngoi c gi l thit b vt l. Mt b iu khin lp trnh s lin tc lp trong chng trnh do ngi s dng lp ra ch tn hiu ng vo v xut tn hiu ng ra ti cc thi im lp trnh. khc phc nhng nhc im ca b iu khin dng dy ni ( b iu khin bng Relay) ngi ta ch to ra b PLC nhm tha mn cc yu cu sau : Lp trnh d dng , ngn ng lp trnh d hc.

Gn nh, d dng bo qun, sa cha. Dung lng b nh ln c th cha c nhng chng trnh phc Hon ton tin cy trong mi trng cng nghip. Giao tip c vi cc thit b thng minh khc nh: my tnh, ni mng, Gi c c th cnh tranh c. 2

tp.

cc mi Modul m rng.

Bo co thc tp Cc thit k u tin l nhm thay th cho cc phn cng Relay dy ni v cc Logic thi gian. Tuy nhin ,bn cnh vic i hi tng cng dung lng nh v tnh d dng cho PLC m vn bo m tc x l cng nh gi c Chnh iu ny gy ra s quan tm su sc n vic s dng PLC trong cng nghip. Cc tp lnh nhanh chng i t cc lnh logic n gin n cc lnh m, nh thi, thanh ghi dch sau l cc chc nng lm ton trn cc my ln S pht trin cc my tnh dn n cc b PLC c dung lng ln, s lng I/O nhiu hn. Trong PLC, phn cng CPU v chng trnh l n v c bn cho qu trnh iu khin hoc x l h thng. Chc nng m b iu khin cn thc hin s c xc nh bi mt chng trnh. Chng trnh ny c np sn vo b nh ca PLC, PLC s thc hin vic iu khin da vo chng trnh ny. Nh vy nu mun thay i hay m rng chc nng ca qui trnh cng ngh, ta ch cn thay i chng trnh bn trong b nh ca PLC. Vic thay i hay m rng chc nng s c thc hin mt cch d dng m khng cn mt s can thip vt l no so vi s dng cc b dy ni hay Relay. 2. Lch s pht trin:

1968: Richard Morley sng to tng PLC cho General Motors 1969: PLC u tin (Allen Bradley v Bedford), c GM s dng trong 1971: ng dng PLC u tin ngoi CN -t 1973: PLC thng minh vi kh nng tnh ton, iu khin my in, x l 1975: PLC vi b iu khin PID 1976: Ln u tin s dng trong h thng phn cp iu khin dy

cng nghip -t (128 DI/DO, 1kByte b nh)


d liu, giao din mn hnh


chuyn sn xut

1977: mP-based PLC 1980: Cc module vo/ra thng minh 3

Bo co thc tp

1981: PLC ni mng, 16-bit PLC, cc mn hnh CRT mu 1982: PLC vi 8192 I/O (ln nht) 1992: Chun IEC 61131 ra i 1996: Slot-PLC, 3. Vai tr v phm vi ng dng:

Lc u ch yu trong cc ngnh cng nghip ch to, iu khin cc qu trnh ri rc. Ngy nay c trong iu khin trnh t v iu khin qu trnh lin tc -> cnh tranh vi Compact Digital Controllers v cc h DCS trong cc ng dng lai. Thit b thu thp d liu trong cc h SCADA. Nh bit, nc ta hin nay ang trong qu trnh cng nghip ha, hin i ha. V th, t ng ha sn xut ng vai tr quan trng, t ng ha gip tng nng sut, tng chnh xc v do tng hiu qu qu trnh sn xut. c th thc hin t ng ha sn xut, bn cnh cc my mc c kh hay in, cc dy chuyn sn xutv.v, cng cn thit phi c cc b iu khin iu khin chng. PLC l mt trong cc b iu khin p ng c yu cu . 4. Cu trc ca PLC: Tt c cc PLC u c thnh phn chnh l: Mt b nh chng trnh RAM bn trong (c th m rng thm mt s b nh ngoi EPROM). Mt b vi x l c cng giao tip dng cho vic ghp ni vi PLC. Cc Modul vo/ra. Bn cnh , mt b PLC hon chnh cn i km thm mt n v lp trnh bng tay hay bng my tnh. Hu ht cc n v lp trnh n gin u c RAM cha ng chng trnh di dng hon thin hay b sung. Nu n v lp trnh l n v xch tay, RAM thng l loi CMOS c pin d phng, ch khi no chng trnh c kim tra v sn sng s dng th n mi truyn sang b nh PLC. i vi cc PLC ln thng lp trnh trn my tnh nhm h tr cho vic vit, c v kim tra chng trnh. Cc n v lp trnh ni vi PLC qua cng RS232, RS422, RS458, 4

Bo co thc tp i vi PLC c nh cc b phn thng c kt hp thnh mt khi. Cng c mt s hng thit k PLC thnh tng m un ngi s dng c th la chn cu hnh PLC cho ph hp m t tn km nht, ng thi p ng c yu cu ng dng. Mt b PLC c th c nhiu m un nhng thnh phn c bn nht ca phn cng trong b PLC bao gi cng c cc khi sau: Khi ngun, khi vi x l b nh, khi u vo, khi u ra. Thng thng cc tn hiu xut nhp u dng s (1- 0), cn nu tn hiu l dng lin tc th ta cn gn cc khi xut nhp dng lin tc (Analog). M un ngun: (Moudule) L khi chc nng dng cung cp ngun v n nh in p cho PLC hot ng. Trong cng nghip ngi ta thng dng in p 24V mt chiu. Tuy nhin cng c b PLC s dng in p 220V xoay chiu. M un CPU (Centrol rocessor Unit module): Bao gm b vi x l v b nh M un nhp: (Input Module) Tn hiu vo: Cc tn hiu u vo nhn cc thng tin iu khin bn ngoi dng tn hiu Logic hoc tn hiu tng t. Cc tn hiu Lgic c th t cc nt n iu khin cc cng tc hnh trnh, tn hiu bo ng, cc tn hiu ca cc quy trnh cng ngh,Cc tn hiu tng t a vo ca PLC c th l tn hiu in p t cc cn nhit iu chnh nhit cho mt l no hoc tn hiu t my pht tc, cm bin. M un xut (Output Module): Trong PLC th Module xut cng ht sc quan trng khng km module nhp. N c th c 8 hoc 16 ng ra m trn mt Module xut, do vy ngi s dng c th kt ni nhiu module li vi nhau c s ng ra ph hp. i vi nhng ng dng nh th cn 16 ng ra. Nhng ng dng ln hn c th dng ti 26 hoc 256 ng ra. Cng ging nh Module nhp th cc ng ra ca Module xut l cc tip im ca rle, kh nng chu ti ln 220V/1A. Nu

Bo co thc tp mun khng ch ph ti cng sut ln th thng qua cc thit b trung gian nh: CTT. Aptomat. Triac 5. Nguyn l lm vic ca PLC: Trong qu trnh thc hin chng trnh CPU lun lm vic vi bng nh ra. Tip theo ca vic qut chng trnh l truyn thng ni b v t kim tra li. Vng qut c kt thc bng giai on chuyn d liu t b m o ra ngoi vi. Nhng trng hp cn thit phi cp nht module ra ngay trong qu trnh thc hin chng trnh. Cc PLC hin i s c sn cc lnh thc hin iu ny. Tp lnh ca PLC cha cc lnh ra trc tip c bit, lnh ny s tm thi dng hot ng bnh thng ca chng trnh cp nht module ra, sau s quay li thc hin chng trnh. Thi gian cn thit PLC thc hin c mt vng qut gi l thi gian vng qut (Scan time). Thi gian vng qut khng c nh, tc l khng phi vng qut no cng c thc hin trong mt khong thi gian nh nhau. C vng qut c thc hin lu, c vng qut c thc hin nhanh tu thuc vo s lnh trong chng trnh c thc hin, vo khi lng d liu c truyn thng trong vng qut . Mt vng qut chim thi gian qut ngn th chng trnh iu khin c thc hin cng nhanh. Nguyn l hot ng da trn cc b phn sau : n v x l trung tm CPU iu khin cc hot ng bn trong PLC. B x l s c v kim tra chng trnh c cha trong b nh, sau s thc hin th t tng lnh trong chng trnh , s ng hay ngt cc u ra. Cc trng thi ng ra y c pht ti cc thit b lin kt thc thi. V ton b cc hot ng thc thi u ph thuc vo chng trnh iu khin c gi trong b nh. H thng bus H thng Bus l tuyn dng truyn tn hiu, h thng gm nhiu ng tn hiu song song : 6

Bo co thc tp Address Bus : Bus a ch dng truyn a ch n cc Modul khc nhau. Data Bus : Bus dng truyn d liu. Control Bus : Bus iu khin dng truyn cc tn hiu nh th v iu khin ng b cc hot ng trong PLC . Trong PLC cc s liu c trao i gia b vi x l v cc modul vo ra thng qua Data Bus. Address Bus v Data Bus gm 8 ng, cng thi im cho php truyn 8 bit ca 1 byte mt cch ng thi hay song song. Nu mt modul u vo nhn c a ch ca n trn Address Bus, n s chuyn tt c trng thi u vo ca n vo Data Bus. Nu mt a ch byte ca 8 u ra xut hin trn Address Bus, modul u ra tng ng s nhn c d liu t Data bus. Control Bus s chuyn cc tn hiu iu khin vo theo di chu trnh hot ng ca PLC. Cc a ch v s liu c chuyn ln cc Bus tng ng trong mt thi gian hn ch. H thng Bus s lm nhim v trao i thng tin gia CPU, b nh v I/O . Bn cch , CPU c cung cp mt xung Clock c tn s t 118 MHZ. Xung ny quyt nh tc hot ng ca PLC v cung cp cc yu t v nh thi, ng h ca h thng. B nh PLC thng yu cu b nh trong cc trng hp : Lm b nh thi cho cc knh trng thi I/O. Lm b m trng thi cc chc nng trong PLC nh nh thi, m, ghi cc Relay. Mi lnh ca chng trnh c mt v tr ring trong b nh, tt c mi v tr trong b nh u c nh s, nhng s ny chnh l a ch trong b nh. a ch ca tng nh s c tr n bi mt b m a ch bn trong b vi x l. B vi x l s gi tr trong b m ny ln mt trc khi x l lnh tip theo. Vi mt a ch mi, ni dung ca nh tng ng s xut hin u ra, qu trnh ny c gi l qu trnh c . 7

Bo co thc tp B nh bn trong PLC c to bi cc vi mch bn dn, mi vi mch ny c kh nng cha 2000 16000 dng lnh, ty theo loi vi mch. Trong PLC cc b nh nh RAM, EPROM u c s dng. RAM (Random Access Memory) c th np chng trnh, thay i hay xa b ni dung bt k lc no. Ni dung ca RAM s b mt nu ngun in nui b mt. trnh tnh trng ny cc PLC u c trang b mt pin kh, c kh nng cung cp nng lng d tr cho RAM t vi thng n vi nm. Trong thc t RAM c dng khi to v kim tra chng trnh. Khuynh hng hin nay dng CMOSRAM nh kh nng tiu th thp v tui th ln . EPROM (Electrically Programmable Read Only Memory) l b nh m ngi s dng bnh thng ch c th c ch khng ghi ni dung vo c. Ni dung ca EPROM khng b mt khi mt ngun, n c gn sn trong my, c nh sn xut np v cha h iu hnh sn. Nu ngi s dng khng mun m rng b nh th ch dng thm EPROM gn bn trong PLC. Trn PG (Programer) c sn ch ghi v xa EPROM. Mi trng ghi d liu th ba l a cng hoc a mm, c s dng trong my lp trnh. a cng hoc a mm c dung lng ln nn thng c dng lu nhng chng trnh ln trong mt thi gian di . Kch thc b nh : Cc PLC loi nh c th cha t 300 1000 dng lnh ty vo cng ngh ch to. Cc PLC loi ln c kch thc t 1K 16K, c kh nng cha t 2000 16000 dng lnh. Ngoi ra cn cho php gn thm b nh m rng nh RAM, EPROM. Cc ng vo ra I / O Cc ng tn hiu t b cm bin c ni vo cc modul (cc u vo ca PLC), cc c cu chp hnh c ni vi cc modul ra (cc u ra ca PLC). Hu ht cc PLC c in p hot ng bn trong l 5V, tn hiu x l l 12/24VDC hoc 100/240VAC. 8

Bo co thc tp Mi n v I/O c duy nht mt a ch, cc hin th trng thi ca cc knh I/O c cung cp bi cc n LED trn PLC, iu ny lm cho vic kim tra hot ng nhp xut tr nn d dng v n gin. B x l c v xc nh cc trng thi u vo (ON,OFF) thc hin vic ng hay ngt mch u ra. 6. Cc hot ng x l bn trong PLC a. X l chng trnh Khi mt chng trnh c np vo b nh ca PLC, cc lnh s c trong mt vng a ch ring l trong b nh. PLC c b m a ch bn trong vi x l, v vy chng trnh bn trong b nh s c b vi x l thc hin mt cch tun t tng lnh mt, t u cho n cui chng trnh. Mi ln thc hin chng trnh t u n cui c gi l mt chu k thc hin. Thi gian thc hin mt chu k ty thuc vo tc x l ca PLC v ln ca chng trnh. Mt chu l thc hin bao gm ba giai on ni tip nhau : u tin, b x l c trng thi ca tt c u vo. Phn chng trnh phc v cng vic ny c sn trong PLC v c gi l h iu hnh. Tip theo, b x l s c v x l tun t lnh mt trong chng trnh. Trong ghi c v x l cc lnh, b vi x l s c tn hiu cc u vo, thc hin cc php ton logic v kt qu sau s xc nh trng thi ca cc u ra. Cui cng, b vi x l s gn cc trng thi mi cho cc u ra ti cc modul u ra. b. X l xut nhp Gm hai phng php khc nhau dng cho vic x l I / O trong PLC : Cp nht lin tc iu nay i hi CPU qut cc lnh ng vo (m chng xut hin trong chng trnh), khong thi gian Delay c xy dng bn trong chc chn rng ch c nhng tn hiu hp l mi c c vo trong b nh vi x l. Cc 9

Bo co thc tp lnh ng ra c ly trc tip ti cc thit b. Theo hot ng logic ca chng trnh, khi lnh OUT c thc hin th cc ng ra ci li vo n v I/O, v th nn chng vn gi c trng thi cho ti khi ln cp nht k tip. Chp nh qu trnh xut nhp Hu ht cc PLC loi ln c th c vi trm I / O, v th CPU ch c th x l mt lnh mt thi im. Trong sut qu trnh thc thi, trng thi mi ng nhp phi c xt n ring l nhm d tm cc tc ng ca n trong chng trnh. Do chng ta yu cu relay 3ms cho mi ng vo, nn tng thi gian cho h thng ly mu lin tc tr nn rt di v tng theo s ng vo. lm tng tc thc thi chng trnh, cc ng I / O c cp nht ti mt vng c bit trong chng trnh. y, vng RAM c bit ny c dng nh mt b m lu trng thi cc logic iu khin v cc n v I / O. Mi ng vo ra u c mt a ch I / O RAM ny. Sut qu trnh copy tt c cc trng thi vo trong I / O RAM. Qu trnh ny xy ra mt chu k chng trnh (t Start n End). Thi gian cp nht tt c cc ng vo ra ph thuc vo tng s I/O c copy tiu biu l vi ms. Thi gian thc thi chng trnh ph thuc vo chiu di chng trnh iu khin tng ng mi lnh mt khong t 110 s. 7. nh gi u nhc im ca PLC Trc y, b PLC thng rt t, kh nng hot ng b hn ch v quy trnh lp trnh phc tp. V nhng l do m PLC ch c dng trong nhng nh my v cc thit b c bit. Ngy nay do gim gi lin tc, km theo tng kh nng ca PLC dn n kt qu l ngy cng c p dng rng ri cho cc thit b my mc. Cc b PLC n khi vi 24 knh u vo v 16 knh u ra thch hp vi cc my tiu chun n, cc trang thit b lin hp. Cn cc b PLC vi nhiu kh nng ng dng v la chn c dng cho nhng nhim v phc tp hn. C th k ra cc u nhc im ca PLC nh sau:

10

Bo co thc tp + Chun b vo hot ng nhanh: Thit k kiu module cho php thch nghi nhanh vi mi chc nng iu khin. Khi c lp ghp th PLC sn sng lm vic ngay, ngoi ra n cn c s dng li cho cc ng dng khc d dng. + tin cy cao: Cc linh kin in t c tui th di hn cc thit b c in. tin cy ca PLC ngy cng tng, bo dng nh k thng khng cn thit cn vi mch r le cng tc t th vic bo dng nh k l cn thit. + D dng thay i chng trnh: Nhng thay i chng trnh c tin hnh n gin. sa i h thng iu khin v cc quy tc iu khin ang c s dng, ngi vn hnh ch cn nhp tp lnh khc, gn nh khng cn mc ni li dy(tuy nhin, c th vn phi ni li nu cn thit). Nh h thng rt linh hot v hiu qu. + nh gi nhu cu n gin: Khi bit cc u vo v cc u ra th c th nh gi c kch c yu cu ca b nh hay di chng trnh. Do , c th d dng v nhanh chng la chn PLC ph hp vi cc yu cu cng ngh t ra. + Kh nng ti to: Nu dng nhiu PLC vi quy cch k thut ging nhau th chi ph lao ng s gim thp hn nhiu so vi b iu khin rle, l do gim phn ln lao ng lp rp. + Tit kim khng gian: PLC i hi t khng gian hn so vi b iu khin rle tng ng. + C tnh cht nhiu chc nng: PLC c u im chnh l c th s dng cng mt thit b iu khin c bn cho nhiu h thng iu khin. Ngi ta thng dung PLC cho cc qu trnh t ng linh hot v d dng thun tin trong tnh ton, so snh cc gi tr tng quan, thay i chng trnh v thay i cc thng s. Khi tnh n gi c ca PLC th khng th khng k n gi ca cc b phn ph khng th thiu nh thit b lp trnh, my in, bng ghi... c vic o to nhn vin k thut. Ni chung nhng phn mm thit k lp trnh cho cc mc ch c bit l kh t. Ngy nay nhiu hng ch to PLC cung cp trn 11

Bo co thc tp b ng gi phn mm c th nghim, nhng vic thay th, sa i cc phn mm l nhu cu khng th trnh khi, do , vn cn thit phi c k nng phn mm. Phn b gi c cho vic lp t mt PLC thng nh sau: - 50% cho phn cng ca PLC. - 10% cho thit k khun kh chng trnh. - 20% cho son tho v lp trnh. - 15% cho chy th nghim. - 5% cho ti liu. Vic lp t mt PLC tip theo ch bng khong 1/2 gi thnh ca b u tin, ngha l hu nh ch cn chi ph phn cng. C th so snh h iu khin rle v h iu khin PLC nh sau: H rle: + Nhiu b phn c chun ho. + t nhy cm vi nhiu. +Kinh t vi cc h thng nh. - Thi gian lp t lu. - Thayi kh khn - Kh theo di v kim tra cc h thng ln, phc tp. - Cn bo qun thng xuyn. - Kch thc ln. H PLC + Thay i d dng qua cng ngh phch cm. + Lp t n gin. + Thay i nhanh quy trnh iu khin. + Kch thc nh. + C th ni vi mng my tnh. - Gi thnh cao B thit b lp trnh thng t, s dng t. 12

Bo co thc tp

CHNG 2: TP LCH PLC S7200


1. Cc lnh c bn. a. Lnh vo / ra. Lnh Load (LD):

Lnh LD np gi tr logic ca mt tip im vo trong bit u tin ca ngn xp, cc gi tr cn li trong ngn xp b y li xung mt bit. Ton hng gm: I, O, M, SM, V, C, T. Tip im thng m s ng khi ng vo PLC c a ch l 1. Dng LAD
I0.0 Q 0.0

Dng STL LD I0.0 = Q0.0

Lnh Load Not (LDN):

Lnh LDN np gi tr logic ca mt tip im vo trong bit u tin ca ngn xp, cc gi tr cn li trong ngn xp b y li xung mt bit. Tip im thng ng s m khi ng vo PLC c a ch l 1 Dng LAD
I0.0 Q0.0

Dng STL LDN I0.0 = Q0.0

13

Bo co thc tp

Cc dng khc nhau ca lnh LD,LDN: STL LD n LD Nn LDI n LD NI n LAD n n / n I n /I M t Tip im thng m s ng khi n = 1 Tip im thng ng s m khi n = 1 Tip im thng m s ng tc thi khi n = 1 Tip im thng ng s m tc thi khi n = 1 n:1 M, Ton hng n: I, Q, SM,

(bit) T, C

OUTPUT (=):

Lnh sao chp ni dung ca bit u tin trong ngn xp vo bit c ch nh trong lnh. Ni dung ngn xp khng b thay i.

14

Bo co thc tp LAD n ( ) M t Cun dy u ra trng thi kch thch khi c dng iu khin i qua Cun dy u ra c kch thch tc thi khi c dng iu khin i qua Ton hng n: I, Q, M, SM, T, C (bit) n ( I ) n: Q (bit)

b.

Cc lnh ghi/xa gi tr cho tip im:

Lnh SET ( S ) v RESET ( R ) Hai lnh ny dng ng v ngt cc im gin on c thit k. Trong LAD, logic iu khin dng in ng hay ngt cc cun dy u ra. Khi dng iu khin n cc cun dy th cc cun dy ng hoc m cc tip im. Trong STL, lnh truyn trng thi bit u tin ca ngn xp n cc im thit k. Nu bit ny c gi tr bng 1, cc lnh S hoc R s ng ngt tip im hoc mt dy cc tip im (gii hn t 1 n 255). Ni dung ca ngn xp khng b thay i bi cc lnh ny. VD: Khi tip im I0.0 ng lnh Set hoc Reset s ng (ngt) mt mng gm n (5) tip im k t Q0.0.

I0.0

Q0.0

I0.0

Q0.0 R 5

s
5

15

Bo co thc tp

M t lnh S (Set) v R (Reset) : STL S S-bit n n ( S) R S-bit n n ( R) S bit Ngt mt mng gm n cc tip im k t S-bit. hoc Counter th lnh s xo bit u ra ca Timer/Counter . SI S-bit n SI ) RI Sbit n n ( RI ) c. Cc lnh logic i s Boolean: Cc lnh tip im i s Boolean cho php to lp cc mch logic (khng c nh). Trong LAD cc lnh ny c biu din thng qua cu trc mch, mc ni tip hay song song cc tip im thng ng hay cc tip im thng m. Trong STL c th s dng lnh A (And) v O (Or) cho cc hm h hoc cc lnh AN (And Not), ON (Or Not) cho cc hm kn. Gi tr ca ngn xp thay i ph thuc vo tng lnh. S bit S bit n ( ng tc thi mt mng gm n cc tip im k t a ch S-bit gm n cc tip im k t a ch S-bit S-bit: Q (bit) n(byte): IB, n (byte): Nu S-bit li ch vo Timer IB, QB, MB, SMB, VB, AC LAD S bit M t ng mt mng gm n cc tip im k t a ch S-bit Ton hng S-bit: I, Q, M, SM, T, C,V(bit)

Ngt tc thi mt mng QB, MB, SMB, VB, AC

16

Bo co thc tp AND (A) Dng LAD


I0.0 I0.1 Q0.0

Dng STL

LD A =

I0.0 I0.1 Q0.0

AND NOT (AN) Tn hiu ra s l nghch o ca tn hiu vo. Dng LAD


I0.0 I0.1 Q0.0

Dng STL

LD AN =

I0.0 I0.1 Q0.0

OR (O). Tn hiu ra s bng 1 khi t nht c mt tn hiu vo bng 1. Dng LAD


I0.0 Q0.0

Dng STL

LD
I0.1

I0.0 I0.1 Q0.0

O =

17

Bo co thc tp OR NOT (ON) Dng LAD


I0.0 Q0.0

Dng STL

LD
I0.1

I0.0 I0.1 Q0.0

O =

d.

Cc lnh v tip im c bit:

Tip im no tc ng cnh xung, tc ng cnh ln:

NOT

C th dng cc lnh tip im c bit pht hin s chuyn tip trng thi ca xung (sn xung) v o li trng thi ca dng cung cp (gi tr nh ca ngn xp). LAD s dng cc tip im c bit ny tc ng vo dng cung cp. Cc tip im c bit ny khng c ton hng ring ca chng v th phi t chng pha trc cun dy hoc hp u ra. Tip im chuyn tip dng/m (cc lnh trc v sn sau) c nhu cu v b nh, bi vy i vi CPU 224 c th s dng nhiu nht l 256 lnh.

18

Bo co thc tp Dng LAD Dng STL

I0.0 P

Q0.0

LD EU = Q0.0

I0.0

I0.0 N

Q0.1

LD ED = Q0.1

I0.0

I0.0 NOT

Q0.2

LD NOT = Q0.2

I0.0

Biu thi gian


I0.0

Q0.0

Q0.2

Q0.1

Hnh 7 - Gin thi gian cc tip im c bit

19

Bo co thc tp Tip im trong vng nh c bit: - SM0.0: Vng qut u tin th m nhng t vng qut th 2 tr i th ng. - SM0.1: Ngc li vi SM0.0, vng qut u tin tip im ny ng, k t vng qut th 2 th m ra v gi nguyn trong sut qu trnh hot ng. - SM0.4: Tip im to xung vi nhp xung vi chu k l 1 pht. - SM0.5: Tip im to xung vi nhp xung vi chu k l 1 giy. e. Cc lnh thi gian (Timer) Cc lnh iu khin thi gian Timer :

Timer l b to thi gian tr gia tn hiu vo v tn hiu ra nn trong iu khin vn thng gi l khu tr. Nu k hiu tn hiu (logic) vo l x(t) v thi gian tr to ra bng Timer l th tn hiu u ra ca Timer s l x (t ) S7200 c 64 b Timer (vi CPU 212) hoc 128 Timer (vi CPU 214) c chia lm 2 loi khc nhau: - Timer to thi gian tr khng c nh (On-Delay Timer), k hiu l TON. - Timer to thi gian tr c nh (Retentive On-Delay Timer), k hiu TONR. - Hai kiu Timer ca S7-200 (TON v TONR) phn bit vi nhau phn ng ca n i vi trng thi ng vo. C hai Timer kiu TON v TONR cng bt u to thi gian tr tn hiu k t thi im c sn ln tn hiu u vo, tc l khi tn hiu u vo chuyn trng thi logic t 0 ln 1, c gi l thi im Timer c kch, v khng tnh khong thi gian khi u vo c gi tr logic 0 vo thi gian tr tn hiu t trc. Khi u vo c gi tr logic bng 0, TON t ng Reset cn TONR th khng. Timer TON c dng to thi gian tr trong mt khong thi gian (min lin thng), cn vi TONR thi gian tr s c to ra trong nhiu khong thi gian khc nhau. Timer TON v TONR bao gm 3 loi vi 3 phn gii khc nhau, phn gii 1ms, 10ms v 100ms. Thi gian tr c to ra chnh l tch ca phn gii ca b Timer c chn v gi tr t trc cho Timer. V d c phn 20

Bo co thc tp gii 10ms v gi tr t trc 50 th thi gian tr l 500ms. C php khai bo s dng Timer nh sau: M t Khai bo Timer s hiu xx kiu TON to thi gian tr tnh t khi u vo IN c kch. Nu nh gi tr m tc thi ln hn hoc bng gi tr t trc PT th T-bit c gi tr logic bng1. C th Reset Timer tr logic 0 ti u vo IN. Khai bo Timer s hiu xx kiu 63, 96-127 PT: VW, T, (Word) C, IW, C, hng s. Ton hng Txx (Word) CPU 214: 32-

LAD

TON-Txx IN PT

kiu TON bng lnh R hoc bng gi QW, MW, SMW,

Txx (Word) CPU 214: 0-31, 64-95 PT: VW, TR, (Word) C, IW, QW, MW, SMW, AC, AIW, hng s.

TONR-Txx TONR to thi gian tr tnh t khi u vo IN c kch. Nu nh gi IN


tr m tc thi ln hn hoc bng

PT

gi tr t trc PT th T-bit c gi tr logic bng1. Ch c th Reset Timer kiu TONR bng lnh R cho T-bit.

Khi s dng Timer TONR, gi tr m tc thi c lu li v khng b thay i trong khong thi gian khi tn hiu u vo c logic 0. Gi tr ca T-bit khng c nh m hon ton ph thuc vo s kt qu so snh gia gi tr m tc thi v gi tr t trc.

21

Bo co thc tp Khi Reset mt Timer, T-word v T-bit ca n ng thi c xa v c gi tr bng 0, nh vy gi tr m tc thi c t v 0 v tn hiu u ra cng c trng thi logic 0. - Timer kiu TON(hnh 4.3) LAD
T33 I0.0 IN TON

STL LD I0.0 TON T33, 50

FBD
T33 I0.0 50 IN PT TON 10ms

50

PT

10ms

- Timer kiu TONR(hnh 4.4) LAD


I0.0
IN T33 TONR

STL

FBD
I0.0 IN PT T33 TONR 10ms

LD I0.0 TONR T33, 10

10

10

PT

10ms

I0.0 MAX =32767

T33 (Current)

PT =50

PT =50

T33 ( Bit)

Hnh 8. Gin thi gian Timer ca TON

22

Bo co thc tp

I0.0 MAX =32767 PT =10 T33 (Current)

T33 ( Bit)

Hnh 9. Gin thi gian Timer ca TONR Cc lnh m Counter:

f.

Counter l b m thc chc nng m sn xung, trong S7-200 cc b m c chia lm 2 loi: b m tin (CTU) v b m tin/li (CTUD). B m tin CTU m s sn ln ca tn hiu logic u vo, tc l m s ln thay i trng thi logic t 0 ln 1 ca tn hiu. S xung m c ghi vo thanh ghi 2 byte ca b m, gi l thanh ghi C- word. Ni dung ca thanh ghi C- word, gi l gi tr m tc thi ca b m, lun c so snh vi gi tr t trc ca b m, c k hiu PV. Khi gi tr m tc thi bng hoc ln hn gi tr t trc ny th b m bo ra ngoi bng cch t gi tr logic 1 vo 1 bit c bit ca n gi l C-bit. Trng hp gi tr m tc thi nh hn gi tr t trc th C-bit c gi tr logic l 0. Khc vi cc b Timer, cc b m CTU v CTUD u c chn ni vi tn hiu iu khin xa thc hin vic t li ch khi pht ban u (Reset) cho b m, c k hiu bng ch ci R trong LAD, hay c qui nh l trng thi logic ca bit u tin ca ngn xp trong STL. B m c Reset khi tn hiu xa ny c mc logic l 1 hoc khi lnh R (Reset) c thc hin vi C-bit. B m c Reset c C-word, C-bit u nhn gi tr 0. Bng lnh m ln, m xung : 23

Bo co thc tp

LAD

M t Khai bo b m tin theo sn ln ca CU. Khi gi tr m tc thi C-word, Cxx ln hn hoc bng gi tr t trc PV, C-bit (Cxx) c gi tr logic bng 1. B m ngng m khi C-word Cxx t c gi tr cc i. Khai bo b m tin/li,

Ton hng Cxx: (Word) CPU 214 : 047, 80-127 Pv(Word): VW, T, C, IW, QW, MW, SMW, AC, AIW, hng s, *VD, *AC Cxx: (Word) CPU 214 : 48-79 PV (Word) : VW, T, C, IW, QW, MW, SMW, hng s, *VD, *AC

CTU - Cxx CU R PV

CTD - Cxx CU CD
R

m tin theo sn ln ca CU, m li theo sn ln ca CD. Khi gi tr m tc thi ca C-word Cxx ln hn hoc bng gi tr t trc PV, C-bit (Cxx) c gi tr logic bng 1. B m ngng m tin khi C-word Cxx t c gi tr cc i 32.767 v ngng m li khi C-word Cxx t c gi tr cc i 32.768. CTUD Reset khi u vo R c gi tr logic bng 1.

PV

24

Bo co thc tp S dng b m CTU:

LAD
I0.0 C40 CU CTU I0.1 R +5 PV

STL

LD I0.0 LD I0.1 CTU C40, +5

Gin thi gian:


I0.0 I0.1 6 5 4 3 2 C40 cunrrent C40 (bit) 1 0 0

Hnh 10. Gin thi gian b m CTU.

25

Bo co thc tp S dng b m CTUD: LAD


I0.0 C48 CU CTUD I0.1 CD I0.2 R +5 PV

STL

LD I0.0 LD I0.1 LD I0.2 CTUD C48, +5

Gin thi gian:

I0.0 (CU) I0.1 (CD) I0.2


6 5 4 3 2 1 0 5

C48 (word) current 0 C48 (bit)

Hnh 11. Gin thi gian lnh CTUD 2. Cc lnh nng cao a. Cc lnh so snh. Khi lp trnh, nu cc quyt nh v iu khin c thc hin da trn kt qu ca vic so snh th c th s dng lnh so snh theo byte, Word hay Dword ca S7-200. 26

Bo co thc tp Nhng lnh so snh thng l: so snh nh hn hoc bng (<=); so snh bng (= =) v so snh ln hn hoc bng (>=). Khi so snh gi tr ca byte th khng cn thit phi n du ca ton hng, ngc li khi so snh cc t hay t kp vi nhau th phi n du ca ton hng l bit cao nht trong t hoc t kp. Trong STL nhng lnh so snh thc hin php so snh byte, Word hay Dword. Cn c vo kiu so snh (<=, = =, >=), kt qu ca php so snh c gi tr bng 0 (nu ng) hoc bng 1 (nu sai) nn n c th c kt hp cng cc lnh LD, A, O. to ra c cc php so snh m S7-200 khng c lnh so snh tng ng (nh so snh khng bng nhau <>, so snh nh hn <, hoc so snh ln hn >) ta c th kt hp lnh NOT vi cc lnh c (= =, >=, <=). Nhm lnh so snh : M t Ton hng n1, n2 (byte): VB, IB, QB, MB, SMB,AC, Const, *VD, *AC
n2

LAD
n1

= =B
= =I

n2

Tip im ng khi n1= n2

n1
n1

n2

B = byte

I = Integer = Word

= =D
n1 n2
D = Double Integer

= =R

R = Real

27

Bo co thc tp

n1

n2

> =B
n1 n2

Tip im ng khi n1>= n2 B = byte n1, n2 (Word): VW, T, C, QW, MW, SMW, AC, AIW, hng s, *VD, *AC

> =I
n1 n2

I = Integer = Word

> =D
n1 n2

> =R

D = Double Integer

R = Real

n1

n2

<= B
n1 n2

Tip im ng khi n1<= n2 B = byte n1, n2 (Dword): VD, ID, QD, MD, SMD, AC, HC, hng s, *VD, *AC

<= I
n1 n2

I = Integer = Word

<= D
n1 n2

<= R

D = Double Integer

R = Real Lnh v cng logic.

b.

Ngoi nhng lnh ghp ni tip, song song v tng hp cc tip im th tp lnh ca S7-200 cn cung cp cc cng logic AND, OR, EXOR thc hin i vi byte (8 bit hay 8 tip im), Word (16 bit hay 16 tip im) v Double Word (32 bit hay 32 tip im). Sau y l chi tit ca tng cng: Lnh AND byte : 28

Bo co thc tp Dng LAD


WAND_B EN VB0 IN1 OUT VB1

Dng STL

ANDB VB0, VB1

VB1 IN2

Lnh thc hin php AND tng bit ca hai byte ng vo IN1 v IN2, kt qu c ghi vo mt byte ng ra OUT, a ng ra c th ging ng vo. Ton hng trong cu lnh thuc mt trong cc vng a ch sau: IN1: VB, T, C, IB, QB, SMB, AC, Const IN2: VB, T, C, IB, QB, SMB, AC V d: VB10 1 0 0 0 1 1 1 0 AND VB20 Kt qu VB20 Lnh AND 0 0 0 0 0 1 1 0 word 0 0 1 1 0 1 1 1

Lnh thc hin php AND thng bit ca hai Word ng vo IN1 v IN2, kt qu c ghi vo 1 Word ng ra OUT, a ch ng ra c th khc ng vo. Ton hng trong cu lnh thuc mt trong cc vng a ch sau: IN1: VW, T, C, IW, SMW, AC, Const IN2: VW, T, C, IW, QW, SMW, AC Dng LAD
WAND_W EN VW0 IN1 VW2 IN2 OUT VW2

Dng STL

ANDW VW0, VW1

V d: 29

Bo co thc tp

VW10

1 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1

AND VW12 Kt qu VW12 Lnh dword : Dng LAD


WAND_DW EN VD0 VD4 IN1 IN2 OUT

1 0 0 0 1 0 1 0 1 1 0 1 1 1 0 1

1 0 0 0 1 0 1 0 0 1 0 1 1 1 0 1 AND Dng STL

ORB VB0, VB1

Lnh OR byte. Dng LAD


WOR_B EN VB0 VB1 IN1 IN2 OUT

Dng STL

ORB VB0, VB1

Lnh thc hin php OR tng bit ca hai byte ng vo IN1, IN2, kt qu thu c ghi vo 1 byte ng ra OUT, a ch ng ra c th khc ng vo. Ton hng trong cu lnh thuc mt trong cc vng a ch sau: IN1: VB, T, C, IB, QB, SMB, AC, Const IN2: VB, T, C, IB, QB, SMB, AC V d: VD10 OR 30 1 0 0 0 1 1 1 0

Bo co thc tp VD20 Kt qu VD20 Lnh OR word: Dng LAD


WOR_W EN VW0 VW2 IN1 IN2 OUT VW2

0 1

0 0

1 1

1 1

0 1

1 1

1 1

1 1

Dng STL

ORW VW0, VW2

Lnh OR Double word: Dng LAD


WOR_DW EN VD0 VD4 IN1 IN2 OUT VD4

Dng STL

ORDW VD0, VD4

c.

Cc lnh di chuyn ni dung nh:

Cc lnh di chuyn thc hin vic di chuyn hoc sao chp s liu t vng ny sang vng khc trong b nh. Trong LAD v STL lnh dch chuyn thc hin vic di chuyn hay sao chp ni dung 1 byte, 1 t n, hoc 1 t kp t vng ny sang vng khc trong b nh. Lnh trao i ni dung ca 2 byte trong mt t n thc hin vic chuyn ni dung ca byte thp sang byte cao v ngc li chuyn ni dung ca byte cao sang byte thp ca t . MOV_B. Dng LAD
MOV_B EN

Dng STL

MOVB VB0, VB0


VB0 IN OUT VB0

31

Bo co thc tp Lnh sao chp ni dung ca byte a ch ng vo IN sang byte c a ch ng ra OUT. a ch ca byte ng vo IN v a ch byte ng ra OUT c th ging nhau, thuc cc vng sau: IN: VB, IB, QB, MB, SMB, AC, Const OUT: VB, IB, QB, MB, SMB, AC, Const V d: LAD
IO.0 MOV_B EN

STL LD I0.0 MOVB 0,VB0 LD I0.1


0 IN OUT VB0

MOVB 12,VB0
IO.1 MOV_B EN

12

IN OUT VB0

Gii thch: Nu tip im I0.0 ng th ly gi tr 0 ghi vo byte VB0 (xa VB0) Tip theo ng tip im I0.1 th ly s 12 ghi vo VB0. Kt qu a ch byte VB0 c gi tr bng 12 (nh phn). MOV_W. Dng LAD
MOV_W EN

Dng STL

MOVW VW0, VW0


VW0 IN OUT VW0

Lnh sao chp ni dung ca Word a ch ng vo IN sang Word c a ch ng ra OUT, a ch ng ra c th ging ng vo, nm trong cc vng sau: IN: VW, IW, QW, MW, SMW, AC, Const OUT: VW, IW, QW, MW, SMW, AC 32

Bo co thc tp

MOV_DW. Dng LAD


MOV_DW EN

Dng STL

MOVDW VD0, VD0


VD0 IN OUT VD0

Lnh sao chp ni dung ca Dword a ch ng vo IN sang Dword c a ch ng ra OUT, a ch ng ra c th ging ng vo, nm trong cc vng sau: IN: VDW, IDW, QDW, MDWW, SMD, AC, Const OUT: VDW, IDW, QDW, MDW, SMDW, AC. MOV_R: (dch chuyn s thc). Dng LAD
MOV_R EN

Dng STL

MOVR VD0, VD0


VD0 IN OUT VD0

Lnh sao chp ni dung ca s thc cha trong Double Word c a ch ng vo IN sang Double Word c a ch ng ra OUT, a ch ng ra c th khc ng vo, thng nm trong cc vng sau: IN: VR, IR, QR, MR, SMR, AC, Const OUT: VR, IR, QR, MR, SMR, AC Khi d liu ghi vo trong cc a ch ny theo nguyn tc sau: Phn nguyn ghi vo Word thp Phn thp phn ghi vo Word cao V d:

33

Bo co thc tp LAD
IO.0 MOV_R EN

STL LD I0.0 MOVR 0.0,VD0 LD I0.1 MOVR 30.2,VD0


IO.1 MOV_R EN

0.0000000

IN OUT VD0

30.20000 IN OUT VD0

Tip im I0.0 ng th xa Double Word 0 (VD0), tip im I0.1 ng th ghi s thc 30.2 vo Double Word (VD0), kt qu nh sau:
VD0

VW2 (word cao) 20 (nh phn)

VW0 (word thp) 30 (nh phn)

d.

Lnh chuyn i d liu Dng LAD


IN SEG

Lnh chuyn i s nguyn h thp lc phn sang Led 7 on. Dng STL

SEG VB0, VB0


VB0 PT OUT VB0

Lnh ny c tc dng chuyn i cc s trong h thp lc phn t 0 n F ( dng nh phn) cha trong 4 bit thp ca byte c a ch ng vo IN thnh gi tr bit cha trong 8 bit ca byte c a ch ng ra OUT tng ng vi thanh led 7 on CK, a ch ng ra c th ging ng vo, nm trong nhng vng sau: IN: VB,IB, QB, MB, SMB, SC, Const OUT: VB, IB, AB, MB, SMB, AC 34

Bo co thc tp V d: Dng LAD


I0.0
MOV _W EN

Dng STL

LD I0.0
3 IN OUT VW0

MOVW +3, VW0

I0.1
IN SEG

LD I0.1
VB0 PT OUT AC0

SEG VB0, AC0

Khi tip im I0.0 ng th s 3 c ghi vo VW0, tip im I0.1 ng th gi tr cha trong 4 bit thp ca byte VB0 chuyn thnh 8 bit cha trong thanh ghi AC0. Lnh chuyn i s m BCD sang s nguyn. Dng LAD
BCD_I EN

Dng STL

BCDI VW0
IN OUT VW0

Lnh ny thc hin php bin i mt s dng m BCD 16 bit cha trong Word c a ch ng vo IN sang s nguyn nh phn 16 bit cha trong Word c a ch ng ra OUT, a ch ng ra c th ging ng vo, thng nm trong trong cc vng sau: IN : VW, T, C, IW, QW, MW, SMW, AC, AIW, Const OUT : VW, T, C, IW, QW, MW, SMW, AC. Lnh chuyn i s nguyn sang m BCD.

35

Bo co thc tp Dng LAD


I_BCD EN

Dng STL

IBCD VW0
IN OUT VW0

Lnh ny thc hin php bin i mt s s nguyn dng nh phn 16 bit cha trong Word c a ch ng vo IN sang m BCD 16 bit cha trong Word c a ch ng ra OUT, a ch ng ra c th ging ng vo, thng nm trong trong cc vng sau: IN : VW, T, C, IW, QW, MW, SMW, AC, AIW, Const OUT : VW, T, C, IW, QW, MW, SMW, AC. Lnh ly gi tr nghch o. Dng LAD Gi tr byte
INV_B EN

Dng STL

INVB VB0
VB0 IN OUT VB0

Gi tr Word
INV_W EN

VD0

IN

OUT

VD0

Gi tr Double Word
INV_DW EN

INVW VW0

VD0

IN

OUT

VD0

INVD VD0

36

Bo co thc tp Lnh c tc dng o gi tr tng bit ca ton hng DW c a ch ng vo IN ri ghi kt qu vo Dword c a ch ng ra OUT. Lnh ny cn c gi l lnh ly gi tr b ca mt s. V d: VB10 INVB VB10 1 1 e. 1 1 1 0 0 0 0 0 0 0 0 1 1 1

Lnh tng gim mt n v. Dng LAD


INC_B EN

Lnh cng s nguyn 1 vo ni dung byte, Word, Double Word. Dng STL

INCB VB0
VB0 IN OUT VB0

INC_W EN

INCW VW0
VW0 IN OUT VW0

INC_DW EN

INCD VD0
VD0 IN OUT VD0

Nhng lnh ny c tc dng cng s nguyn 1 vi ni dng byte, Word, Double Word c a ch ng vo IN, kt qu c ghi vo byte, Word, Double Word c a ch ng ra OUT. Ng vo IN v ng ra OUT c th cng a ch. Lnh ny c s dng cc bit nh c bit SM1.0, SM1.1, SM1.2 bo trng thi kt qu php tnh theo nguyn tc sau:

37

Bo co thc tp Kt qu tnh =0 S m > byte 1 SM 1.0 1 1 SM 1.1 SM 1.2

Lnh tr s nguyn 1 vo ni dung byte, Word, Double Word. Dng LAD


DEC_B EN

Dng STL

DECB VB0
VB0 IN OUT VB0

DEC_W EN

DECW VW0
VW0 IN OUT VW0

DEC_DW EN

DECD VD0
VD0 IN OUT VD0

Nhng lnh ny c tc dng ly ni dng byte, Word, Double Word c a ch ng vo IN tr i 1n v, kt qu c ghi vo byte, Word, Double Word c a ch ng ra OUT. Ng vo IN v ng ra OUT c th cng a ch. Lnh ny c s dng cc bit nh c bit SM1.0, SM1.1, SM1.2 bo trng thi kt qu php tnh theo nguyn tc sau: Kt qu tnh =0 S m > byte 1 1 1 SM 1.0 SM 1.1 SM 1.2

38

Bo co thc tp f. Cc lnh s hc Dng LAD


ADD_I EN

Lnh cng s nguyn 16 bit. Dng STL

VW0 VW2

IN1 IN2 OUT VW2

+I VW0, VW2

Lnh thc hin cng cc s nguyn 16 bit IN1 v IN2, kt qu l s nguyn 16 bit c ghi vo OUT, IN1 + IN2 =OUT, ng vo IN1, IN2 v ng ra VW2 c th cng a ch, thuc cc vng nh sau: IN1,IN2: VW, T, C, IW, QW, MW, SMW, AC, AIW, Const OUT: VW, T, C, IW, QW, MW, SMW, AC, AIW Lnh tr s nguyn 16 bit. Dng LAD
SUB_I EN

Dng STL

-I VW0, VW2
VW0 VW2 IN1 IN2 OUT VW2

Lnh thc hin php tr cc s nguyn 16 bit IN1 v IN2, kt qu l s nguyn 16 bit c ghi vo OUT, IN1 - IN2 =OUT, ng vo IN1, IN2 v ng ra VW2 c th cng a ch, thuc cc vng nh sau: IN1, IN2: VW, T, C, IW, QW, MW, SMW, AC, AIW, Const OUT: VW, T, C, IW, QW, MW, SMW, AC, AIW Lnh nhn s nguyn 16 bit.

39

Bo co thc tp Dng LAD


MUL EN

Dng STL

MUL VW0, VW2


VW0 VW2 IN1 IN2 OUT VW2

Lnh ny thc hin php nhn 2 s nguyn 16 bit IN1, IN2. Kt qu 32 bit cha trong t kp OUT (4 byte). Lnh chia s nguyn 16 bit. Dng LAD
DIV EN

Dng STL

DIV VW0, VW2


VW0 VW2 IN1 IN2 OUT VW2

Lnh ny thc hin php chia s nguyn 16 bit IN1 cho s nguyn 16 bit IN2. Kt qu 32 bit cha trong t kp OUT (4 byte) gm thng s ghi trong mng 16 bit t bit 0 n bit 15 v phn d cng 16 bit ghi trong mng t bit 16 n bit 32. Trong lnh ny c s dng cc bt nh c bit bo trng thi: Kt qu tnh =0 Bo trn S m Mu = 0 1 1 1 1

SM1.0

SM1.1

SM1.2

SM1.3

40

Bo co thc tp g. Lnh truy cp ng h thi gian thc.

Trong thit b lp trnh S7-200 t CPU 214 tr i th trong CPU c mt ng h ghi gi tr thi gian thc gm cc thng s v nm, thng, gi, pht, giy v ngy trong tun. ng h c cp in lin tc bi ngun Pin 3V. Khi thc hin lp trnh cho cc h thng t ng iu khin cn cp nht gi tr ng h thi gian ny ta phi thng qua 2 lnh sau: Lnh c: Dng LAD
READ_RTC EN

Dng STL

TODR VB0

VB0

Lnh ny c ni dung ca ng h thi gian thc ri chuyn sang m BCD v lu vo b m 8 byte lin tip nhau theo th t nh sau: Byte 0 Byte 1 Byte 2 Byte 3 Nm ( 0 99) Thng ( 1 12) Ngy ( 1 31) Gi ( 0 23) Byte 4 Byte 5 Byte 6 Byte 7 7) Trong byte u tin c ch nh bi ton hng T trong cu lnh, byte 7 ch s dng 4 bit thp lu gi tr cc ngy trong tun. Lnh ghi: Dng LAD
SET_RTC EN

Pht ( 0 59) Giy (0 59) Khng s dng Ngy trong tun (1 -

Dng STL

TODW VB0

VB0

41

Bo co thc tp Lnh ny c tc dng ghi ni dung ca b m 8 byte vi byte u tin c ch nh trong ton hng T vo ng h thi gian thc. Trong T thuc mt trong nhng vng nh sau: VB, IB, QB, MB, SMB.

42

Bo co thc tp

PHN 2: BIN TN CHNG I: GII THIU CHUNG 1. Khi nim:


Bin tn l thit b bin i ngun in c tn s cho trc thnh mt ngun in c tn s m ta mong mun phc v yu cu t ra. 2. Nguyn l hot ng Bin tn l thit b bin i tn s dng in xoay chiu vi nguync l lm vic kh n gin. u tin, ngun in xoay chiu 1 pha hay 3 pha c chnh lu v lc thnh ngun 1 chiu bng phng. Cng on ny c thc hin bi b chnh lu cu diode v t in. Nh vy, h s cng sut cos ca h bin tn u c gi tr khng ph thuc vo ti v c gi tr t nht 0.96. in p mt chiu ny c bin i (nghch lu) thnh in p xoay chiu 3 pha i xng. Cng on ny c thc hin thng qua h IGBT (transistor lng cc c cng cch ly) bng phng php iu ch rng xung (PWM). Nh tin b ca cng ngh vi x l v cng ngh bn dn lc hin nay, tn s chuyn mch xung c th ln ti di tn s siu m nhm gim ting n cho ng c v gim tn tht trn li st ng c.

S nguyn l hot ng H thng in p xoay chiu 3 pha u ra c th thay i gi tr bin v tn s tu theo b iu khin. Hiu sut chuyn i ngun ca cc b bin tn rt cao v s dng cc b linh kin bn dn cng sut c ch to theo cng ngh hin i. Nh vy, nng lng tiu th xp x bng nng lng yu cu bi h thng. 43

Bo co thc tp 3. ng dng ca bin tn: Gim bt cc chi ph sn xut, gi thnh bo dng v ng thi nng cao tui th cho cc thit b l i hi tt yu ca hu ht cc dy truyn sn xut. Bin tn l mt gii php hng u cho vic ti u ho iu khin ng c. Bin tn rt a dng v chng loi, tu theo tng nhu cu c th m ngi s dng c th chn loi thch hp nht cho dy chuyn v ng c ca mn. Bin tn vi chc nng iu khin v cp tc ng c cho php ngi s dng iu chnh tc ng c theo nhu cu v mc ch s dng. Chc nng iu khin tc ng c ln ti 16 cp vi kh nng kim sot thi gian gia tc/gim tc, nhiu mc cng sut ph hp vi nhiu loi ng c. C chc nng bo v: Qu ti, qu p, thp p, qu dng, thp dng, qu nhit ng c, ni t... n gip ngi vn hnh yn tm khng phi lo lng v vn mt kim sot trong qu trnh vn hnh Bin tn gip cc dy chuyn hot ng ti u: Tit kim in nng, ng b cc thit b (ng c), hot ng trn tru, thn thin vi ngi s dng v gim thiu chi phi bo tr - bo dng. Sau y l mt s ng dng trong thc t:

ng tc 2 ng c cun - nh, n nh sc cng gia 2 u

44

Bo co thc tp

H tr iu khin vector dng in vng h / vng kn (dng Encoder), iu khin V/f vng h / vng kn (dng Encoder) gip nng cao chnh xc cho cc dy chuyn cn s phi hp ng b

iu khin ng c n nha v ng c cun, n nh sc cng...

45

Bo co thc tp

Bin tn J7 ca Yaskawa vi chc nng b trt tc , pht hin qu mmen, d tm tc cng vi chc nng tng mmen ng c khi mmen ti tng gip tc bng ti lun lun n nh (bn cnh bin tn c kh nng iu khin ng c chy a cp tc - 9 cp)

ng tc 2 ng c xe ln. iu khin vector dng in (dng Encoder) t c cc c tnh truyn ng mnh cho c cu nng h cn mmen quay tc thp...

46

Bo co thc tp

Bin tn L7 ca Yaskawa s dng Encoder loi incremental hoc Encoder chun Hiperface/Endat, dng ra nh mc cao, trnh t nng h xc nh gip iu khin ng c thang my ln xung, dng tng chnh xc. iu khin ng c ng m ca mm mi hn vi Encoder chnh nh rng ca. 4. Cu trc ca mt b bin tn . Gm cc phn chnh sau: B chnh lu. Mch mt chiu trung gian(b lc). B nghch lu. Khi iu khin .

4.1 B chnh lu. A. Khi nim: l thit b dng bin i ngun in xoay chiu thnh ngun in mt chiu cung cp cho ph ti mt chiu (b m in , mch kch t my in ). 47

Bo co thc tp B.Phn loicc s chnh lu . S Chnh Lu 1pha 3 pha n pha Hnh Cu Hnh tia iu khin hon ton Bn iu khin Khung iu khin

C. Cc dng s chnh lu.

48

Bo co thc tp

Hnh 20. (1) s chnh lu 1pha na chu k ; (2) s chnh lu mt pha hnh tia ; (3) s chnh lu cu mt pha ; (4) s chnh lu ba pha hnh tia ; (5) s chnh lu cu 3 pha ; (6) s chnh lu su pha c cun khng cn bng. 4.2. Khu trung gian mt chiu (b lc). Dng san phng dng in p sau khi chnh lu. ng vai tr mt kho tch tr nng lng di dng ngun p (dng t in), hoc ngun dng (dng cun cm), to ra mt khu cch ly nht nh gia ph ti v ngun in p li .Nhng cng gy ra tn hao trn cc phn t . 4.3. B nghch lu. A. Khi nim . Nghch lu l nhng b bin i dng bin i ngun in mt chiu thnh ngun in xoay chiu ,cung cp cho ph ti xoay chiu . B. Cc dng nghch lu . Nghch lu ngun p . Nghch lu ngun dng . C. Khi nim ngun dng, ngun p: Mt ngun in c th l ngun p hay ngun dng. Ch lm vic ca b nghch lu ph thuc rt nhiu vo ch lm vic ca ngun mt chiu cung cp, v vy ta cn phn bit hai loi ngun ny. Ngun p l tng l mt ngun in vi ni tr bng khng.V nh vy in p ra l khng i, khng ph thuc vo gi tr cng nh tnh cht ca ph ti. Ngun p s lm vic ch khng ti, nhng khng lm vic c ch ngn mch. V khi , v nguyn tc, dng in c th ln n v cng. Trong thc t ngun p c to ra bng cch mc u ra mt ngun mt chiu mt t in c gi tr ln. 49

Bo co thc tp Ngun dng l tng l mt ngun in vi ni tr v cng ln Nh vy dng in ra l khng i, khng ph thuc vo gi tr, cng nh tnh cht ca ph ti. in p ra s ph thuc ti. Ngun dng lm vic c ch ngn mch, v khi dng in vn khng i nhng khng th lm vic ch khng ti. Ni chung ch gn khng ti tng ng vi tr khng rt ln, khng chp nhn c. Trong thc t ngun dng c to ra bng cch mc u ra mt ngun in mt chiu mt in cm c gi tr ln. 4.4. Khi iu khin. Nhn tn hiu iu khin, thc hin cc lut iu khin, to tnh hiu iu khin cc IGBT.

50

Bo co thc tp

CHNG 2: CI T BIN TN ALTIVAR 31


1.S u ni

2.Cch ci t: 2.1. Danh sch menu SET : setting (ci t ). Drc : motor control ( tham s ng c ). I-O : input-output (ng vo ra ). CtL : command (iu khin ). Fun : function (chc nng ). FTL : faults (qun l gim st li ). Com : communication (truyn thng ). Sup :monitoring (hin th ). 2.2. Th t menu Lp trnh d dng : 51

Bo co thc tp Phm ENT v ESC chn hay thot ra kh menu thng s. Phm ENT xc nhn mt la chn hay mt iu chnh (cn phi nhn 2s trong mt vi trng hp ). Phm v di chuyn ln xung , chn cc ci t v iu chnh cc thng s . Mn hnh hin th s nhp nhy xc nhn la chn . 2.3. Menu SET v drc. Ci t thng s bin tn v thng s ng c, th d : menu SET: ACC,drc :hm dc ( thi gian tng gim tc ). HSP : tc cao nht . LTH : dng danh nh ng c , lin quan n bo v nhit ng c . Menu DRC: UNS : in p danh nh ng c . NSP : tc danh nh ng c. TUN : t ng d tham s . OFT :La chn ch iu khin . 2.4. Menu I/O Cho php ci t chc nng cho cc ng vo ra .Th d : Tcc :chn la gia kiu iu khin 2 hay 3 dy hay iu khin ti bin tn . Tct : chn la iu khin hai dy gia mc logic. CRL3 v CRH3: Ci t t l ca tn hiu AI3 v LSP v HSP. V d: 7 17mA tng ng vi LSP v HSP. AOV hay AOC: ci t cho tn hiu AO, OA: 0- 20mA; 4A: 4- 20mA; 10V: 0- 10V. AOC: c th t l ng ra loogic dO. R1 hoc R2 : C th gn relay R1, R2. 2.5. Menu iu khin CTL 52

Bo co thc tp La chn mc truy cp theo s: Level 1(LAC= L1)(mc nh). Bin tn vi cc tnh nng ph hp vi a s cc ng dng thng gp. Truy cp cc chc nng chun, ng vi cc chc nng ALTVAR28. Level 2( LAC = L2). Truy cp cc chc nng nng cao: Speed, hm trnh t, hai mc gii hn dng, chuyn i ng c. Level 3( LAC= X3). Chuyn i gia cc knh tham s tc nh AL1, AL2, AL3, AIP( bin tr ti bin tn ), Modbus, CAN open hoc bn phm t xa. Chuyn i gia cc knh iu khin nh: Local( ti bin tn); LCC (bn phm t xa); Modbus, CAN open hay cc ng vo logic LI. 2.6. Menu Fun Chn chc nng ng dng ca ALTIVAR 31. Chn chc nng: Chn ng vo logic thc hin chc nng: Menu Fun. Cc cp tc t trc: PSS PS2: Hai tc c trng. LI3: Gn LI3 cho chc nng c chn. Gn nhiu chc nng trn cc ng vo logic. Vi chc nng c th c kch hot ng thi bi mt ng vo logic. V d: LI4 c gn chuyn i hm dc( RPS, Menu Fun) v o chiu ( RRS, Menu I/O). 2.7. Menu bo li FLT Cc ci t v iu chnh chnh trong Menu FLT. ATR = YES: T ng khi ng li i vi mt s li. T ng sau 1; 5, 10 giy hay mi pht. TAN: Chn la khong thi gian ti a ca qu trnh t khi ng li( iu chnh t 5 pht n 3 gi hay khng gii hn). 53

Bo co thc tp RSF: Reset li bng ng vo logic. FLR: Khi ng li vi tc hin c( Flying starts). OHLT: Ch dng khi qu ti bin tn. OHF OLL: Ch dng khi qu ti ng c OLF. SLL: Ch dng khi li Mod bus SLF. . Ch dng khi li: YS: Dng t do, LFF: n tc fold back( thng s LFF). RLS: Gi tc trc khi xy ra li cho n khi ht li. RMP: Dng theo hm dc. FST: Dng nhanh.. 2.8. Menu hin th SUP C th hin th cc chc nng c gn cho cc ng vo logic v Analog truy cp bng Menu ph LIA v AIA. ca Menu SUP. C th hin th ng vo logic trn mn hnh bin tn, vi thng s LIS ca Menu ph LIA. 3.Mt s chc nng c bn. Chuyn i ng c( t thng s cho hai ng c khc nhau). Speed. 16 cp tc t trc. iu khin hm trnh t. B iu chnh PI. UP load/down/load 4 b thng s ci t bng bn phm t xa. Kho tham s bng Password. Hai gi tr gii hn dng.

54

Bo co thc tp

MC LC
Li ni u Phn I: Thit b PLC Chng 1: Gii thiu v PLC 1. Gii thiu chung 2. Lch s pht trin 3. Vai tr v phm vi ng dng 4. Cu trc 5. Nguyn l lm vic 6. Cc hot ng x l bn trong 7. nh gi u nhc im Chng 2: Tp lnh PLC S7200 1. Cc lnh c bn 2. Cc lnh nng cao Phn 2: Bin tn Chng 1. Gii thiu chung 1. Khi nim 2. Nguyn l hot ng 3. ng dng bin tn 4. Cu trc Chng 2: Ci t bin tn ALTIVAL 31 1.S u ni 2. Cch ci t 3.Mt s chc nng c bn 1 2 2 2 3 4 4 6 9 10 13 13 26 43 43 43 43 44 47 51 51 51 54

55