Bai 1

You might also like

Download as pdf
Download as pdf
You are on page 1of 83
TRUONG DAI HOC CONG NGHIEP TP. HO CHi MINH KHOA CONG NGHE BIEN TU BQ MON DIEN TU MAY TiNH GIAO TIEP DIEU KHIEN THIET BI NGOAI VI RS232 JAWG4 YG Simulation wh GIANG VIEN: PHAM QUANG TRi TP. HO CHi MINH Phién ban 4.0 — C4p nhat 12/2018 — Luu hanh ndi bo 1 Taro ako Enrne aka ean 1. MUC LUC Mé phéng giao tip va diéu khién thiét bi ngoai vi thong qua céng COM..... 3 1.1. Giao tigp va digu khign thiét bi ngoai vi théng qua céng COM gitta may tinh va vi diGu khién PICIBF4SSO... 3 L.L1. Phan tich vidy minh hoa. 3 1.12. So-dBmé phéng. 5 1.1.3. Gidi thudt va ma ngudn cia chuong trinh digu khign 5 1.13.1. — Giai thuat. 6 1.1.3.2, Ma ngudn.. 7 1.1.4, Cac buréc m6 phone... a 1.1.4.1, Bude 1 ~Viét va bién dich ma ngudn cho vi diéu khién PIC1BF4550 trén phn mEm “mikroC PRO for PIC” 1 1.1.4.2. Bude 2~-VE mach mé phéng cho hé thdng trén phn mém mé phng “Protues"”.. 18 1.1.43, Bude 3~Nap chuong trinh cho vi didu khién PIC18F4550 trén phn m&m “Protues” sv. 18 1.1.44, Bude 4~ Sit dung céng cy gia lap giao dién diéu khién thiét bi théng qua céng COM trén may tinh 20 1.1.45. Bude 5—Tao m6 phéng két n6i gitta giao dién diéu trén may tinh va hé théng giao tiép, iBu khién thiét bj ngoai vi théng qua céng COM ding PIC18F4550 .. 1.1.4.6. Bude 6—Tién hanh mé phéng diéu khign thiét bi, 1.2, Giao tiép va digu khién thiét bj qua COM gitta may tinh va mach Arduino Mega 2560 .. 1.2.1. Phan tich vi dy minh hoa... 26 12.2. Soddmé phing 1.2.3. Gidi thudt va mé nguén cua chuong trinh di8u Khién 123.1. — Gidithuit.. 1.2.3.2, MA ngubA..o 29 1.2.4. Cac bude mé phéng 33 1.2.4.1 Buc 1 — Viét va bién dich ma nguén cho mach Arduino Mega 2560 trén phan mém_ “Arduino” 33 1.2.4.2 Buéc 2 - Vé mach mé phéng cho hé théng trén phn mm mé phdng “Protues’..... 38 1.2.43. Bude 3—Nap chuong trinh cho mach Arduino trén phn m&m mé phéng “Protues”.......39 1.2.4.4. Bude 4 Sir dyng céng cy gia lap giao dién digu khién thiét bj théng qua céng COM trén may tinh — SerialPort Terminal 1. sen “ serene 1.2.4.5. Bude 5~Ta0 md phéng két n6i gitta giao dign digu trén may tinh va hé théng giao tiép, iu khién thiét bi ngoai vi théng qua céng COM diing mach ArdUINO..nncsnnnnesnnnnnnnssnnn AD 1.2.4.6. Bude 6—Tién hanh mé phéng digu khién thiét bi a2 13. Giao dign digu khién trén may tinh, oA Peer nen enor Caiiema ieee) 13.1, 13.2. 133, 13.4, 13.4.1, 13.4.2, 135, nr i PTR) aes me) ‘Tao Project mdi trong Visual Studio C# 2012 .. 42 AT 49 66 Phan tich vi dy minh hoa. Xay dung giao dién diéu khién thiét bj ngoai vi théng qua céng COM trén may tinh.. Giai thudt va ma ngudn cua giao dién digu khién.. Giai thuat 66 Ma ngudn.. Van hanh giao dién diéu khién 8 tao ra.. 70 81 Pen Caiiema ieee) in and Control for ISI) uc PTR) aes me) Hinh Error! No text of specified style in document..1. Minh hoa téng quan hé thong giao tigp va diéu khién thiét bj ngoai vi thong qua cng COM. 1.1.Giao tiép va diéu khién thiét bi ngoai vi thong qua cng COM giira may tinh va vi digu khién PICI8F4550 1.1.1, Phin tich vi dy minh hoa Trong vi dy tham khao nay, ching ta sé m6 phéng viée sit dung mt may tinh cé tich hyp céng COM (chuan RS232) dé diéu khién thiét bi ngoai vi (LED va nit nhan) ding b6 diéu khién 1a vi diéu khién PIC] 8F4550 théng qua truyén thong UART. Ban dau khi moi duge c4p nguén thi vi diéu khién PIC] 8F4550 sé diéu khién lam cho LED tit. Cac hoat déng tiép theo sé nhu sau: * Néu PICI8F4550 nhan duge tir may tinh chudi ky tw cé dinh dang 1a “@le_on&” thi né sé diéu khién LED sdng va déng thdi sau dé né sé truyén tré lai mdy tinh chudi ky ty e6 dinh dang li “@Lle_on&”. © Néu PICI8F4550 nhan duge tir may tinh chudi ky ty c6 dinh dang 1a “@le_of&” thi n6 sé diéu khién LED tit va déng thoi sau dé no sé truyén tré lai méy tinh chudi ky ty c6 dinh dang la “@Lle_of&”. Trong a6: Bién soan: Pham Quang Tri Taro ako o Ky tu“@” la ky ty ding dé xe nhan bit dau chudi ky ty. o Ky tu “&” la ky tu ding dé xde nhan két thie chudi ky tu. © Chudi “le_on” va “le_of” li chudi tuong img ding dé PICI8F4550 xdc nhan diéu khién LED sang va tit. Chudi nay chi cho phép dai ti da 9 ky tu va mién sao cé chia ding Gi dung duge qui dinh nhv trén thi LED sé duge diéu khién tuong img, nguge lai thi LED sé khong bj tac déng va PICISF4550 sé truyén tro lai may tinh chudi ky ty ¢6 dinh dang la “@Error&”. © Chudi “Lle_on” va “Lle_of” la chudi tuong tmg ma PICI8F4550 sé truyén tré lai may tinh sau khi da diéu khién LED sang va tat. Vige nay nhim muc dich théng bao cho may tinh biét trang thai hién tai cla LED 1a dang sdng hoac dang tit. © Khi nhan-nha nat SW thi PICI8F4550 sé truyén téi may tinh chudi ky tr cé dinh dang 14 “@S...&”. Trong dé tai vj tri du “...” s& chinh 1a sé Lin nhn-nha nit SW, gia sir nat nhdn SW duge nhdn-nha 12 Lin thi chudi ky ty truyén t6i may tinh ¢6 dinh dang 1a “@S12&”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) a Taro ako 1.1.2. So dd mé phéng v4 VI DU MINH HOA GIAO TIEP QUA COM THIET KE: PHAM QUANG TRI ° AR CIO “A RESET Hinh Error! No text of specified style in document..2. So dé m6 phong giao tiép céng COM véi PICI8F4550. Cn luu y ring Hinh Error! No text of specified style in document..2 chi la so dé ding cho viée mé phéng hay cén duge hiéu 1a so dé nguyén ly rat gon va chua day di, digu d6 cé nghia 1 v6i thiét ké rit gon nhu so dé nay thi khong thé “chay” duge ngoai thye té 1.1.3. Giai thuat va ma ngudn cia chwong trinh diéu khién tigp theo 18 chung ta thye hién chung trinh digu khién dé cho phép giao tiép gitta thiét bj ngoai vi ding vi diéu khién PIC va méy tinh. 6 bai huéng din nay ching ta sé str dung phan mém “mikroC PRO for PIC” dé viét ma nguén cia chuong trinh diéu khién 1am mét vi du don gian, bat/tit mét dén LED trén ma thiét bi tir giao dign diéu khién trén may tinh va hién thi trén giao dién nay ngudi str dung da nhan-nha mit nhan trén thiét bi. Qua vi du nay sé gidp chang ta nam jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Taro ako ving duge viée giao tip va diéu khién thiét bj ngoai vi thong qua céng COM gitra may tinh va vi diéu khién PIC. Giai thudt va ma ngudn cia chuong trinh diéu khién duge viét trong phan mém “mikroC PRO for PIC” nhu sau: 1.1.3.1. Giai thuat Main. Clear_buf_string_receive Peer nen enor Ceuteaara atic) ETI) Enrne aka ean Taro ako 1.1.3.2. Ma nguén © Céc thu vién cia phan mém “mikroC PRO for PIC” duge sir dung trong chuong trinh: UART, Button, C_String, C_Type, Sprintf. © Céc khai bdo bién, hing, ky higu: // Khai bao bien va du Liew #define led on 1 // Muc logic dieu khien trang thai LED Term nen er ok encase sures Coated cravat #define max count ReceiveData 10 // Qui dinh so luong ky tu (du Lieu) toi da trong chuoi #aefine len_code $ // Qui dinh so ky tu cua ma nhan dang xac han ("le_on", “le of": 5 ky tu) char ReceiveDatar // Chua byte du Liew nhan duoc char baffer[15]; 11 80 dem du Liew gui ai int count = 0; // Chua so lan aban sw bit oldatate: // Co bao trang thai cho SW char Led_on_code(] = “le on"; // Ma nhan dang xac nhan dieu khien LED sang (chi $ ky tu) char led_off_code[] = “lef; // Ma nhan dang xac nhan dieu khien LED tat (chi 5 ky tu) char start_sign = '@4; // Ma phan dang xac nhan ky ta bat dau chuoi du Liew char end_sign = "6"; // Ma phan dang xac nhan ky tu ket thuc chuoi du Liew char count_ReceiveData // Con tro, dem so byte du Liew nhan duoc char buf_string_receive[max_count_Receivepata]; // Chua du lieu nhan duoc o dang chuoi char start_Data, end Data; // Chua du Lieu bat dau va ket thuc chuoi du liew char receive complete = 0; // Co bao hean thanh nhan du lieu (0: Chua, 1: Xong) © Dogn chong trinh con xéa néi dung b6 dém nhan dir ligu void Clear_buf_string_receive (void) { 11 Krai bao unsigned char i; W/ Chuong trink For (1-07 i<-max_count_Recelvepata; i++) ‘ buf_string _receive(i] = '\0'; —// Koa tung byte trong chuoi © Doan chuong trinh con phuc vu ngat (ngit ngoai va ngit UART): void interrupt (void) { Sf (INTCON. INTOIF == 1) { INTCON.INTOIF = 0; // Clear interrupt bit countt+: 11 Yang bien den W sprintf (buffer, "@stda",count); // Gui du lieu co mhan dang ky tu bat dau (a) UART1_Write Text (buffer); // va ky tu ket thuc (&) cua chuoi du lieu (@.... > Af (PIRL-RCIE ‘ uD PERL.RCIE Jf Clear interrupt bit Receivebata = UARTI Read(); // Doc du liew tu UART Wo xu ly lua tre chuoi du lieu aban Af (Receivepata == start_sign) // Byte nhan duoc 1a ky hiew bat dau chuoi du Liew Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Taro ako count_Receivebata = 0; 11 Xoa bo dem start_Data = Receivebata; // waa ky hieu bet dau chuoi du liew buf_string_receive(count_ReceiveData] = ReceiveData; ' if (ReceiveData == end_sign) // Byte mhan duoc la ky hieu ket thuc chuoi du lieu ‘ end_Data = ReceiveData; —// Luu ky hieu ket thuc chuoi du lieu buf_string_receive[count_Receivebata] = ReceiveData: Af ((start_Data == start_sign) && (end_pata -~ end_sign)) // Xac nhan hoan thanh phan day du 1 chuoi du lieu receive complete = 1; // Thong bao da shan dung dinh dang chuoi du lieu count Recelvebata = 0; // Koa bo den start Data = '\0"; // Xoa bo dem ky hiea bat dau chuoi du lie fend_pata = '\0"; // Koa bo den ky hieu ket thuc chuoi du Liew , else // Xac nhan byte du lieu nhan la cac ky tu trong chuoi (chua ket thuc chuoi) ( buf_string_receive(count_ReceiveData] = ReceiveData; count_Receivepatatt; LE (count_ReceiveData > max_count_ReceiveData) ‘ count _ReceiveData = Uf Xea bo dem xu ly so sank, dieu khien va gui phan hoi if (receive_complete 1) // Xu ty Kai hoan tat doc 1 chuoi du Liew Af (stenemp (strstr (but_string receive, led_on_code), led_on_code, en_code) 47 So sanh chuoi du lieu nhan duoc de dieu khien LED ‘ LATE.LATEL = led_ot // Bat LED ub Gui du Liew phan hoi UARTI Write Text ("@Lle one"); // Gui du lieu co nhan dang ky tu bat dau (8) // va ky tu ket thuc (&) cua chuol du Liew (@.......-8) ue ’ else if (stencmp (strats (buf_string receive, led_off code) , led_o: // So sanh chuoi du Lieu nhan duoc de dieu knien LED code, Len_code) ‘ LATE.LATEL = led off; // Tat LED ue UARTI_Weite Text ("@Lle_ofe") ; 11 va ky tu ket_thuc (&) cua chuoi du liew (@ Bién soan: Pham Quang Tri ‘Commu Gui du Liew phan hoi // Gai da Liew co phan dang ky tu bat dau (2) Coated Gui du Liew phan hoi UARTI_Weite Text ("@Erreré™); // Gui du liey co nhan dang ky tu bat dau (8) J/ va ky te ket thue (&) cua chuoi du liew (@. “8 “ ) receive_complete ~ 0; // Teng bao chua nhan dang chuoi dinh dang count_ReceiveData = 0; 11 Xoa bo den Clear_buf_string_receive(); // Koa chuoi © Doan chong trinh chinh: void main() 1 U7 Khai bao W/ Chuong trink ADCONL = 0x08 // Tat ca chan Analog thanh chan Digital cHCON |= 72 // Cam modul Comparators // cau hink Port B PORTS = 0x00; LATE = 0x00; ‘RISE. TRISBO = 1) J/ Cau hink Port E PORTE = 0x00; LATE “RISE.TRISEL = 07 ox09) 11 cay hink agat INTCON.INTOIF = 0; // Clear interrupt bit INTCON.INTOIE = 1; // Enable external interrupts INTCON2.INTEDGO = 1; // External interrupt on rising edge PIRL.RCTF = 0; // Clear interrupt bit PYBL.RCIE ~ 1; // Snable the EUSART receive interrupt INPCON.GIE = 1; // Bnabie global interrupt INTCON.PEIE = 1; // Snable periphiral interrupts 17 Cau hink modal VAR? // wode: receiver enabled, transmitter enabled, “ frame size @ bits, 1 STOP bit, parity mode disabled, asynchronous operation VARTI_tnit (9600); // Baud = 9600bps delay_ms (100); 1/ doi de modul VAR? on dink white (li: ) Bién soan: Pham Quang Tri 10 Taro ako 1.1.4, Cée buée mé phéng 1.1.4.1, Buée 1 — Viét va bién dich ma ngudn cho vi diéu khién PIC18F4550 trén phan mém “mikroC PRO for PIC” Khoi d6ng phan mém “mikroC PRO for PIC” va tao mét Project méi cho chuong trinh digu khién PIC. Tir thanh menu Iénh ta thyc hign Ignh “File > New > New Project...”, khi 46 h6p thoai qui trinh tgo ra mét Project méi sé xudt hign nhu minh hoa trong Hinh Error! No text of specified style in document..3. Trong hop thoai nay, 6 Buée 1 ta thye hign chon logi “Standard Project” va nhdp chugt vio nut “Next” dé tiép tuc. 2 pages Saasten crate on at | Fi (a =a Hinh Error! No text of specified style in document..3. H6p thoai chon loai Project. Tigp theo 6 Bude 2 nhu minh hoa trong Hinh Error! No text of specified style in document..4, ta thuc hién diéu chinh cdc thong tin: * Tén Project (Project Name): ty chon © Thu muc hu trit Project (Project Folder): tiy chon Tén vi diéu khién PIC (Device Name): P18F4550 ¢ Tan sé thach anh (Device Clock): 20MHz Danh dau chon vao 6 thiét lap cdc bit cdu hinh “Open Edit Project window to set Configuration bits” dé mo cita s6 higu chinh théng s6 cai dat cho Project. jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 4 Taro ako Nea Pret Ward = see Projet Stina oaentpe Lwmctoeungs | Poi oe vio pette roa ler [ rvs CO Z| — evox mame | 5550 Cneedes Sern ae tree ame, proc le, elec duce mane andar ces dat exalt 6.0). ‘ing Ont ren oe he on tr ea as ‘Tsou os eat seu os obese BO Sas regorevead peter Wibremsenbcll Copy oma Cre Hinh Error! No text of specified style in document..4. Hép thoai cai dat cu hinh Project. Sau khi higu chinh cdc théng tin xong ta nhdp chuét vao nut “Next” dé tiép tuc. Tiép theo 6 Bude 3, hép thoai bé sung tap tin vao Project xuat hién nhu minh hoa trong Hinh Error! No text of specified style in document..5, ta bé qua hp thoai nay va nhdp chudt vao nit “Next” dé tiép tuc. Nea Pret Ward = — ‘Sede exiting es you was to od to proach gga ype le To Project: Erect Bl a rove ene Fea A sea _ or Hinh Error! No text of specified style in document..5. Hp thoai bd sung tap tin vao Project. Tiép theo & buée 4, hp thoai bé sung cac thu vién can sir dung vao trong Project sé xudt hién nhu minh hoa trong Hinh Error! No text of specified style in document..6. Trong muc “Include Libraries” ta chon “Include None (Advanced)” Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 12 Taro ako nhim mye dich sé chi chon nhing thu vién can thiét dé bd sung vao Project ma théi. Viée bé sung thu vién sé duge thyc hién trong cdc thao tac tip theo. Nea Pret Ward = — ‘Select iil state for rey manager 2 racist Sado etree Steere eve a Get) © meee sions ‘Seecrg llraver emer beer ‘crite any sng rey nage (econ eared ers ae canter (bay aan oma | Care| Hinh Error! No text of specified style in document..6. H6p thoai bé sung thr vign vio Project. Nhdp chudt vao nut “Finish” dé két thie céng doan tao méi Project va chuyén sang céng doan cai dat cdu hinh cho Project. Khi dé trén man hinh sé xudt h6p thoai “Edit Project”, trong hdp thoai nay ta chit ¥ phai chon that chinh xdc cée muc duge danh déu khoanh tron mau dé nhu minh hoa trong Hinh Error! No text of specified style i khi da hoan chinh viée cai dat cdu hinh cho Project ta nhdp chudt vao nut “OK”. document..7 va Hinh Error! No text of specified style in document..8. Sau py se) bull ie ee ackise © rcooden| | 5. jes (iostsoen | [eserais spooms =) [ siesiene | at Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) i Taro ako Hinh Error! No text of specified style in document..7. Hép thoai cai dat cdu hinh cho Project (ché d6 HS). Neu dasemganey se] ute tes Brcko © ronal | a ley [ted seme | onan Resins | seni Sere eewrreis = 200000 =) [ siesiene | (Lea Hinh Error! No text of specified style in document..8. Hép thoai cai dat céu hinh cho Project (ché d6 HS). Tiép theo ta chon cc thu vign UART, Button, C_String, C_Type, Sprintf (44 duge ligt ké trong muc 1.1.3.2) dé nhing vao trong ma nguén ctia chuong trinh diéu khién. Vi nay duge thyc higén bang cach chon tab “Library Manager”, sau dé tim va danh dau chon vao mye UART, Button, C_String, C_Type, Sprintf dé chon cdc thu vign nay. Xem minh hoa trong Hinh Error! No text of specified style in document..9. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) a LAE EG IGT e AAAS SABO) s 2 Ama aI 1 sree 7 aT ares agsoooooo808 a Hinh Error! No text of specified style in document..9. Minh ha chon cdc thu vién dé nhing vao trong ma ngudn. Dén day 1a viéc tao Project da hoan tat, tip theo ta the hién viée viét ma nguén cia chong trinh diéu khién vao trong man hinh soan tho. Tham khao phan ma nguén chuong trinh diéu khién “MyProject.c” da duge trinh bay trong muc 1.1.3.2 bén trén dé viét ma ngudén. Sau khi viét xong ma nguén ctia chuong trinh chinh vao trong man hinh soan thao thi ta tién hanh luu tap tin nay vao trong may tinh bing ech tir thanh menu Iénh chon “File > Save As...”. Trong h9p thoai “Save As” hién trén man hinh, ta chon noi uu tri tip tin, d&t tén tap tin va nhdp chuét vao mit “Save” dé uu t§p tin vao may tinh. Phin ma nguén cia chong trinh diéu khién coi nh da xong nhu duge minh hoa trong Hinh Error! No text of specified style in document..10 bén du6i. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) SOE DA IIT, A ABMS ORIOL TARA EE ue ame. ae, 30 sree BD me a i 7 F fe » p i Hinh Error! No text of specified style in document..10. Minh hoa man hinh soan thao chuong trinh diéu khién “MyProject.c”. Tiép theo ta thyc hién bién dich va kiém tra 1di cat php cita chuong trinh digu khién bing cach nhp chuét vao biéu tugng Spuita” tren thanh céng cu cla man hinh soan thao. Viéc bién dich va kiém tra 16i ct phép cif chuong trinh diéu khién duge xem la thinh céng khi trong cita s6 “Message” xudt hign ding chtt c6 ni dung “Finished successfully”. Hinh Error! No text of specified style in document..11 bén duéi minh hoa viée bién dich thanh céng chuong trinh diéu khién (firmware). Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) a ETI) Enrne aka ean Taro ako Uleteonensscinea aye - 3 x paeds. rec os reed ona Enecnwwtnemcane ee Besgw ous. se i Cunt i Hinh Error! No text of specified style in document..11. Minh hoa vigc bién dich thanh céng chuong trinh diéu khién (firmware). Lic nay phan mém “mikroC PRO for PIC” sé tao ra tap tin ma HEX (firmware) va luu trét tp tin nay trong cing thu myc vi Project dang thye hién, xem minh hoa trong Hinh Error! No text of specified style in document..12. ag a o> He cece peep Bowles Documents Pies Eh aystay My Wes ays & fohicious & GovgleDrne # EB oyPrjectasm 1 Myce impject S mypaete D mretene D nriectts Eimiecter | mee doe | meen de S> Snag Pest | projected BisyProjetinens | bhpctncpe caleba 1 tiPsetane sc HngaOTaSTCH I tensdected SKS 5 fie cence Hee Test Document CoS Fie Met ie kA or TeSocumet fa Taro ako Hinh Error! No text of specified style in document..12. Tp tin mi HEX (firmware) ciia chtrong trinh sau khi bién dich thanh cng. 1.1.4.2. Bude 2— Vé mach mé phéng cho hé théng trén phan mém mé phéng “Protues” Khoi d6ng phan mém “Protues” va ién hanh vé so dd mach m6 phong cia hé théng giao tiép va diéu khién thiét bi ngoai vi thong qua cong COM nhu Hinh Error! No text of specified style in document..2. 1.1.4.3. Bude 3— Nap chong trinh cho vi digu khién PICI8F4550 trén phan mém “Protues” Dé nap chwong trinh diéu khién cho PIC18F4550 trong mach m6 phéng ta nhdp dup chugt vao vi mach PICI8F4550 trong so dé. Trén man hinh xudt hign hp thoai “Edit Component” nhu Hinh Error! No text of specified style in document..13 bén dudi. = ae a Fone: [rows] ties | pag Feb Pear [uso eed aed USB Host Conouter Addon ooanow ae = Hinh Error! No text of specified style in document..13. Hép thoai higu chinh thong 86 lam viée cho PICI8F4550. Trong h9p thoai “Edit Component”, dé dim bao tinh chinh xc vé mat thai gian, téc 46 diéu khién trong khi chay mé phéng trén may tinh thi ta cdn chon chinh xéc tin sé xung clock c4p cho vi diéu khién trong muc “Processor Clock Frequency”, trong trang hgp vi dy nay ta nh§p vao 20MHz nhu minh hoa trong jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) cS Taro ako Hinh Error! No text of specified style in document..13 bén trén. Ngoai ra, cing trong hdp thogi “Edit Component” nay & muc “Program File” ta s& phai chi duéng din dén noi luu tri tap tin chuong trinh diéu khién duge tao ra 6 Bude 1 va chon tap tin nay, sau d6 nhap chudt vao nit “Open” trong hép thoai “Select File Name” dé chon né nhu minh hoa trong Hinh Error! No text of specified style in document..14 va két thiic viéc nap chuong trinh diéu khién cho PICI18F4550 bang cach nhap chudt vao nit “OK” trong hp thoai “Edit Component”. © Saka Fete x von (EH Joe om econe [iat Fectyoo. Feseadien y Hinh Error! No text of specified styl in document..14. Hp thoai chon tp tin cho PICI8F4550. chuong trinh digu khi Sau khi da chon tap tin chuong trinh diéu khién cho PIC18F4550 thi ta tién hanh thiét lp théng sé hoat dong cho céng COM mé phéng trén phan mém “Protues”. Tién hanh vige nay bang c4ch nhdp dip chudt vao céng COM mé phng trong so dé dé mé h6p thoai “Edit Component” nh Hinh Error! No text of specified style in document..15 bén dudi. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 419 % eaecomponert 7% Palen range ere Poesia Prac Fay ‘yl ad at ‘vst Dit te Prycal up ae One eos. Cisne tte PB Lyne Clectactonate anes (alpen anit Hinh Error! No text of specified style in document..15. Hop thoai higu chinh thong sé hoat d6ng cho cong COM mé phéng. Trong h6p thoai nay ta can higu chinh chinh xac ce thong s6 nhu sau: o Tén céng COM (Physical Port): COMI o Téc dé truyén dit ligu (Physical/Virtual Baud Rate): 9600 co 86 bit dit ligu (Physical/Virtual Data Bits): 8 Bit kiém tra (Physical/Virtual Parity): NO! © Sé bit dimg (Physical/Virtual Stop Bits): 1 Sau khi da higu chinh chinh xdc cdc théng s6 nay thi ta sé két thiic bang cach nhdp chuét vao nt “OK” trong h6p thogi “Edit Component”. 1.1.4.4. Buée 4 — Sir dung céng cy gia lap giao dign didu khién thiét bi théng qua céng COM trén may tinh Do théi diém nay ta chua hoc cdch tao giao dién diéu khién trén may tinh nén ta can phai tam thai sir dung mét giao dign cé sin dé gia lap méi trudng tic dong diéu khién ti may tinh théng qua céng COM. Dé gia lap giao dign diéu khién trén may tinh ta sir dung cdc phan mém gia lap ding cho céng COM, trong bai nay sé gidi thigu cach Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) BD ETI) Enrne aka ean Grn che laren thre sir dung phan mém “SerialPort Terminal” dé lam viée nay. Khéi dong phan mém “SerialPort Terminal” va higu chinh chinh xéc cdc théng s6 nhu sau: © Tén céng COM (COM Port): COM2 © Téc dé truyén dir ligu (Baud Rate): 9600 © Sé bit dir ligu (Data Bits): 8 o Bit kiém tra (Parity): None © Sé bit dimg (Stop Bits): One {if Seren Terina =o x Pies Rated 277A 5A (aa Abt Ore Ole tnesonae — Dore oes Descends Diomarwn ore a Hinh Error! No text of specified style in document..16. Giao dign diégu khién cia phan mém SerialPort Terminal. 1.1.4.5. Buéc 5 — Tao mé phéng két ndi gitra giao dign didu trén may tinh va hé théng giao tiép, didu khién thiét bi ngoai vi thong qua cing COM ding PIC18F4550 Khéi d6ng phan mém “Virtual Serial Port Driver” va thuc hién viée cdu hinh ché d6 hoat déng cia phan mém dé tao ra su két ndi m6 phong gitta giao dién diéu khién trén may tinh (dai dién 1a phan mém “SerialPort Terminal”) va hé théng giao tiép, digu khién thiét bi ngoai vi thong qua cing COM ding PICI8F4550 (dai dién 1a phan mém “Protues”). Nhu bude thao téc trén da trinh bay thi phia giao dién diéu khién trén may tinh sé duge dai dign 1a COM2 va phia hé théng giao tiép, didu khién thiét bi ngoai vi thong qua cong COM ding PIC18F4550 sé dugc dai dién 1a COM1. in and Control for fabri Al Bién soan: Pham Quang Tri Sey sn ea ty th ya ot ruse tiaras teenie Sb coer woe ther eee on aes oo. Be [ae PR in mets a See | ‘hem alt ed Hinh Error! No text of specified style in document..17. Giao dién phan mém “Virtual Serial Port Driver”. Trong thé “Manage Ports” trén giao dién cua phan mém ta chon COMI cho myc “First Port” va COM2 cho muc “Second Port”, sau dé nh4p chudt vao mit “Add Pair” dé thyc hién viéc két ndi céng. Khi dé tai phan ctra sé phia bén trai giao dién cia phan mém sé xuat hién biéu tugng minh hoa cho viéc cong COMI va COM2 43 duge két néi véi nhau. [Via Sta Po Dine By Ee Stare Poros Cation Hele sepia: ener Manage port | Fataceisist | utompinct | 9 eeetsersa rector SED Bn an cae ud eo a cane lhe Sepang Caran oh omer sae ‘Sith pasa ating wens pope cs at amet arn Se ann SSE, Hinh Error! No text of specified style in document..18. Minh hoa két néi gitra COMI va COM2. Tai thoi diém nay viéc truyén dit ligu chua bat du nén céng COM sé chua duge m@, cho nén tai phan cira sé phia bén trai giao dién cha phan mém “Virtual Serial Port Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 22 Taro ako Driver” sé hién thj thong tin nhu minh hoa trong Hinh Error! No text of specified style in document..19 duéi day. GH) Virtual ports © a com Tl Port closed 1 Sent: 0 Bytes a Received: 0 Bytes {fii Baudrate emulation: Disabled “5 Pinout: Standard com [7 Portclosed 1 Sent: 0 Bytec Received: 0 Bytes {hil Beudrate emulation: Disabled -E Pinout: Standard Hinh Error! No text of specified style in document..19. Cac céng COM chua duge mé. 1.1.4.6. Buée 6— Tién hanh mé phéng dicu khién thiét bi Dé bat dau qua trinh m6 phong, dau tién ta can phai kich hoat giao dién diéu khién trén may tinh. Viée nay dugc thye hign bang cdch nh4p chuét vao nit “Open Port” L92="P2t | én phan mém “SerialPort Terminal” Tigp theo ta kich hoat mé phéng hé théng giao tiép va diéu kl thiét bi ngoai vi thong qua céng COM ding PIC18F4550, vig nay duge thy hién bing céch nhap chuét vao nut “Run Simulation” > trén phan mém “Protues”. Tién hanh viéc giti dit ligu tir may tinh (giao dign diéu khién) sang thiét bj ngoai vi (PIC 8F4550) nhu sau: © Nh§p chudi ky ty “@le_on&” vao 6 “Send Data” va nhap chugt vao mit “Send” trén cita sé phan mém SerialPort Terminal. Quan sat bén cira sd phan mém Protues ta nhan thay LED sang va quan sat bén cira sO phan mém SerialPort Terminal ta nhan thay chudi ky ty phan héi tro lai 1a “@Lle_on&”, xem minh hoa trong Hinh Error! No text of specified style in document..20. © Nhap chudi ky ty “@le_of&” vao 6 “Send Data” va nhap chu: vao nut “Send” trén cita sé phan SerialPort Terminal. Quan sat bén ctra sé jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Fs Taro ako phan mém Protues ta nhan thdy LED tat va quan st bén ctra sé phan mém SerialPort Terminal ta nhan thay chudi ky ty phan hdi tré lai 1a “@Lle_of&”. DSUs arougmara @ - | Pe AMOSeMBL Se? BAA Pomercn X Hinh Error! No text of specified style in document..20. Minh hoa truyén tir may tinh chudi ky ty “@le_on&”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 24 Taro ako Tién hanh viée giri dir ligu tir thiét bi ngoai vi (PIC18F4550) sang mdy tinh (giao dién digu khién) nhu sau: ¢ Nhdn-nha nit SW lin dau tién trén cira sé phin mém Protues. Quan sat bén cira sé phan mém SerialPort Terminal ta nhan thdy nhan duge chudi ky ty “@S1&”, xem minh hoa trong Hinh Error! No text of specified style in document..21. © Nha -nha nut SW lan thir hai trén ctra sé phan mém Protues. Quan sat bén cita sé phan mém SerialPort Terminal ta nhan thay nhan duge chudi ky ty “@S2&”, tong ty nhu vay cho : nhan-nha nut SW tiép theo. aa |AGumaraudmacs aris ) 2Cl4ah=eeB Aus. abla, Hinh Error! No text of specified style in document..21. Minh hoa nha ngoai vi chudi ky ty “@S1&". Quan sat trén ciza sé phan mém “Virtual Serial Port Driver”, ta nhan thay ring ca hai cong COM (COMI va COM2) da duge mo va da cé dit ligu truyén qua cong. jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Es Taro ako (i Virtual ports 5 ¢@ COMI [9600-N-2-1) [7] CAProgram Files (@86)\Lab 15) Sent: 12 Bytes de Received: 7 Bytes {fj Baudrate emulation: Disab ~& Pinout: Standard SB COM? [9600-N-2-1] [Bl caProgram Files (85) Ser 1 Sent: 7 Bytes @ Received: 12 Bytes {jij Beudrate emulation: Disab “& Pinout: Standard Hinh Error! No text of specified style in document..22. Minh hoa céng COM da duge mé va dé ligu bat dau truyén qua COM. 1.2. Giao tiép va diéu khién thiét bi qua COM giira may tinh va mach Arduino Mega 2560 1.2.1, Phan tich vi dy minh hoa ‘Vi du minh hoa trong phan nay cing tuong ty nhu da trinh bay trong phan giao tigp va diéu khién thiét bi ngoai vi thong qua céng COM gitta may tinh va vi diéu khigén PIC18F4550, xem chi tiét trong mye “1.1.1. Phan tich vi dy minh hoa”. 1.2.2. So dd mé phong Cin luu ¥ ring Hinh Error! No text of specified style in document..23 chi 12 so dé ding cho viée mé phéng hay cdn duge hiéu li so dé nguyén ly rit gon va cha day du, dié duge ngoai thuc té. 1.2.3, Gi Céng viéc tiép theo 14 ching ta thyc hién viée viét chuong trinh diéu khién dé d6 c6 nghia 14 v6i thiét ké rat gon nhu so dé nay thi khéng thé “chay” thuat va ma ngudn cia chwong trinh diéu khién cho phép giao tiép gitra thiét bi ngoai vi ding mach Arduino va may tinh. O bai huéng din nay ching ta sé sit dung phin mém “Arduino” dé viét ma nguén cia chuong trinh didu khién lam mét vi du don gian, bav/tit mot dén LED trén thiét bi tir giao dién didu khién trén may tinh va hién thi trén giao dign nay sé lin ma ngwéi sit dung da nhan- nha nut nhan trén thiét bi. Qua vi du nay sé gidp ching ta nam ving duge viée giao jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 3 oN leer tigp va digu khign thiét bi ngoai vi théng qua céng COM gitta may tinh va mach Arduino. TERMINAL “A VIDU MINH HOA GIAO TIEP QUA COM a THIET KE: PHAM QUANG TRI os sii Pa a COMPUTER Hinh Error! No text of specified style in document..23. So dé mé phéng giao tiép cong COM véi mach Arduino. Giai thuat va ma nguén cia chuong trinh diéu khién duge viét trong phin mém “Arduino” nhu sau: 1.2.3.1. Gidi thuat Computer Peripheral Devices Ea Clear_buf_string_recei Peer nen enor Caiiema ieee) A ETI) Enrne aka ean Taro ako 1.2.3.2. Ma nguén * Cac thu vign cua phan mém “Arduino” duge st dung trong chuong trinh: Hinclude #include Hinclude Cac khai bdo bién, hing, ky hié // Khai bao ten cho cac chan Arduino #define led Pin 13 // Chan noi LED Term nen er ok encase sures 29 Coated #define sw Pin 2 11 Chan noi 38 // Bhai bao bien va du lieu fdefine led_on HIGH // Muc logic dieu khien trang thai u80 fdefine led_off LOW fdefine max_count Receivebata 10 // Qui dinh so luong ky tu (du Lieu) toi da trong chuoi #define len_code § —// Qui dinh so ky tu cua ma nhan dang xac han char Receivebata; // Choa byte du Liew nhan duoc int count = 0 // Chua so lan akan sw String buf_string_send = "7 // Chua du Liew gui dio dang chuoi char led_on_code(] = "leon"; // Ma nhan dang xac nhan dieu khien LED sang (chi $ ky tu) char led_off_code(] ~ "lef"; // Ma han dang xac nhan dieu khiea LED tat (chi 5 ky tu) char start_sign = "8"; // Ma phan dang xac nhan ky tu bat dau chuoi du liew char end_sign = "6"; 47 Ma nhan dang xac nhan ky tu ket thue chuoi du liew char count_RecsiveData = 0; // Con tro, dem so byte du liew nhan duce char buf_string receive{max_count_Recelvepata]; // Chua du lieu nhan duoc o dang chuel char start Data, end Data; // Choa du lieu bat dau va ket thuc chuoi du lieu char receive_complete = 0; // Co bao hean thanh nhan du Liew (0: Chua, 1: Xong) © Doan chong trinh cdu hinh: void setup) \ 17 Rpoi tao cau hinh chan noi voi cae 1HO pintiode (Led Pin, oOTe02) ; digitalwrite(ied Fin, ied off); // Dieu Khien Lao = OFF // Ryoi ta0 cau Rink chan not vot cac sit pinMlode (sw Pin, T9907 PULLUP); // configure as an input and enable the interna? pull-up // Cas hink Serial Pore Soriai3.begin(9600,SERza2 61); // Data 11 Cau bik ngat Parity = None, Stop = 1 attachInterrupt (0, S#_ISR, RISING); // Cau hinh Serial Port giao tiep Terminal kiem tra heat dong Serial.begin(9600); // Cong UART giao tiep Terminal (FC) Serial.printin ("setup Terminal Baudrate ~ 9600"); Serial.printin ("Connection for Arduino Mega:") Serial.printin(" Device Arduino Mega") ; Serial.printin(" 15 ~ [6ND] MAx232 exp "ys Serial.printin(" 11 ~ [RX] max232 14-3; Serial.printin(" 12 ~ [Px] MAX232 15 RKB; Serial.printin(" 1 - [ANODE] LED a3 ": Serial.printin(" 2 - [CATHODE] LED ox ": Serial.printin(" 1 - (ANODE) sw 2- "ye Serial.printin(" 2 - [CATHODE] sw np "ys Serial .printin( Serial.printin ("Active MAX232 Module " Serial.printin( Serial.printin("starting 88232 (CoM). Bién soan: Pham Quang Tri ED Coated rae * Doan chuong trinh chinh: void Leop() 0 © Doan chwong trinh con phuc vu ngit ngoai: void SW_ISR() // ISR cho nat ohan ‘ count++; // Tang so lan nhan SW us buf string send = "es" + String(count) + * // Gui du Licu co nhan dang ky tu bat dau (2) Serial3.print (buf_string_send); W/ va va ky tu ket thuc (&) cua chuoi du lieu (@ “s Serial.printin(buf_string send); // Hien thi tren Serial Moniter * Doan chwong trinh con phuc vu ngit UART: void serialsvent3() // 18R cho UBRE ( Receivedata = Serial3.read(); —// Doc du lieu tu Serial Port un if (Receivepata == start_sign) // Byte mhan duoc 1a ky hiew bat dau chuot du lieu ‘ Xu ly luu Leu chuoi du Liew ahan count_ReceiveData = 0; U1 Xoa bo dem stazt_Data = ReceiveDat. // tau ky hiew bat dau chuoi du Lice buf_string_receive[count_ReceiveData] = Receivebata: Af (Receivebata == end_sign) // Byte nhan duoc 1a ky hieu ket thuc chuoi du liew end_Data = Receivebata; —// Luu ky Rieu ket thuc chuoi du Liew buf_string_receive(count_ReceiveData] = ReceiveData; Af ((start_pata start_sign) &@ (end_Data end_sign)) // Xac nhan hoan than nhan day du 1 chuoi du Liew receive_complete = 1; // Theng bao da nhan dung dink dang chuoi du Liew count Receivebata = 0; // Xoa bo dem start_Data = NULL; // Xoa bo dem ky hieu bat dau chuoi du liew end_bata = NULL? // Xoa bo dem ky hiew ket thuc chuoi du liew ) else // Xac nhan byte du Liew nhan 1a cac ky tu trong chuoi (chua ket thuc chuol) ‘ buf_string_receive[count_ReceiveData] = Receivebata; count_ReceiveDatatts Bién sogn: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Ef Coated cravat if (count ReceiveData > max count ReceiveData) ‘ count_Receivebata = 0; // Koa bo den > uw Xu ly so anh, dieu khien va gui phan hoi Af (receive complete == 1) // Xu ly khi hoan tat doc 1 chuoi du lieu ‘ Serial.printin(buf_string receive): // Hien thi tren Serial Monitor if (strnonp (strstr (buf_string_receive, led_on_code) , led_on_cede, len_code) // So sanh chuoi da Liew nhan duoc de dieu Kaien LED digitalWrite(led_Pin,led_on); // Bat LED Wo Gui du Liew phan hoi Serial3.print ("@Lle ons"); // Gui du Lieu co phan dang ky tu bat dau (2) // va va ky tu ket thuc (4) cua chuoi du lieu (@... 4 Wo , else if (stencnp(strstr(buf_string_receive, led_off_code), led_off_code,len_code) = o // So sanh chuoi du Liew nhan duoc de dieu khien LED digitaiWrite(led_Pin,led off); // Tat LED Wo Serial3.print ("@nle_of6"); // Gui du Liew co nhan dang ky tu bat dau (2) o8) Gui du Liew phan hoi // va va ky tu ket thue (4) cua chusi du lieu (@ ui du Liew phan hoi Serial3.print("@Errors"); // Gui du lieu co nhan dang ky tu bat dau (@) Jf va va ky tu ket thue (&) cua chuoi du lieu (@......+-8) We , receive_complete = 0; // Thong bao chua nhan dung chuoi dink dang count_ReceiveData = 0; WI Xea bo den Clear_puf_string_receive(); // Koa chuol Wo © Doan chuong trinh con xéa ngi dung b6 dém nhan dit ligu: // Chuong trink een xea noi dung be den nhan du Liew void Clear_buf_string_receive (void) 1 for (char i=0;i<-max_count_ReceiveData; i++) Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 32 Career Chl buf_strin = NULL: 1.2.4. Cac burée mé phéng 1.2.4.1. Buée 1 — Viét va bién dich m4 ngudn cho mach Arduino Mega 2560 trén phan mém “Arduino” Khoi dng phan mém “Arduino” va tao mét Sketch méi cho chuong trinh diéu khién Atmega2560. Trén man hinh soan thao cia phan mém “Arduino” c6 hai phan ving dé nhap ma ngudn cia chuong trinh diéu khién, phan ving “void setup{...}” va phan ving “void loop{...}”. Trong phan ving “void setup{...}”, ta sé nhap vio dogn ma nguén thiét lap cdu hinh hoat d6ng ban dau cho mach Arduino va céc thiét bi ngoai vi, luu y ring doan ma nguén trong phan ving nay chi duge chay mét lin. Trong phan ving “void loop{...}”, ta sé nhap vao doan m& nguén cua chuong trinh diéu khién chinh, lu y rang doan ma nguén trong phan ving nay sau khi chay hét dén Iénh cudi cing sé tu d6ng quay tré vé thyc hién lai lénh dau tién trong phan ving. Hinh Error! No text of specified style in document..24. Cira sé soan thao chuong trinh diéu khién ctfa phan mém Arduino. Dén day 1a viéc tao Sketch da hoan tat, tiép theo ta thyc hién viée viét ma nguén cia chuong trinh diéu khién vao trong man hinh soan thao. Tham khao phan ma nguén jén soan: Pham Quang Tri Term nen er ok rt eerie 33 Career Chl chuong trinh diéu khién “MySample_Mega2560.ino” 43 duge trinh bay trong mye 1.2.3.2 bén trén dé viét ma ngudn. Sau khi viét xong ma nguén cia chuong trinh chinh vao trong man hinh soan thao thi ta tién hanh Iuu tp tin nay vao trong may tinh bing cach tir thanh menu Iénh chon “File — Save As...”. Trong hp thoai “Save As” hign trén man hinh, ta chon noi luu trit tap tin, dat tén tap tin va nhdp chuét vao nit “Save” dé lau tap tin vao may tinh. Phin ma nguén cia chwong trinh diéu khién coi nhw da xong nhu duge minh hoa trong Hinh Error! No text of specified style in document..25 bén duéi. (© nyse Megt560| Artin 82 =o * Ble Et Sketch Took: Help Hinh Error! No text of specified style in document..25. Minh hoa man hinh soan thao chuong trinh diéu khién “MySample_Mega2560.ino”. Tigp theo ta thye hign bién dich va ém tra 16i cu phdp cia chong trinh diéu khién bang cach nhap chudt vao biéu tugng QO “Verify” trén thanh céng cy cla man hinh soan thao. Viée bién dich va kiém tra 16i cu phdp cua chuong trinh diéu khién duge xem 1a thanh céng khi trong cita sé “Message” xuat hign dong chit c6 ni dung “Done Compiling”. Hinh Error! No text of specified style in document..26 bén du6i minh hoa viéc bién dich thanh céng chuong trinh diéu khién (firmware). jén soan: Pham Quang Tri Saree eerie 34 ETI) COGENT Ch ra ee (© nyse Megt560| Artin 82 Ble Et Sketch Took: Help twfample Meou26e0| ‘Metine Jed on Hinh Error! No text of specified style in document..26. Giao dign chuong trinh sau khi bign djch thanh céng. Lic nay phan mém “Arduino” sé tao ra tap tin ma HEX (firmware) va luu trir tip tin nay trong thy muc ma ta da chi dinh trong muc “Preferences” cia phan mém. Be lanios = 8 x] Hone Share View oe eon > a Quick access: “ > excrame rete + wnat frat arose YO casein ms ‘a mE veitee 1 eee le © iB Dstnens D oysempie Mege25eCinaesp © # Downloads 48KE Tcaconem re dD Music s ed tree Be BooreaMe c) 3 Sota 152 Pierre we Rene 35 Career Chl Hinh Error! No text of specified style in document..27. Tp tin ma HEX (firmware) cua chuong trinh sau khi bién dich thanh céng. 6*6*6* Luu y: Can luu y ring mic dinh thi sau khi da bién dich thanh céng phan mém “Arduino” sé khéng ty tao ra tap tin ma HEX. Viéc phan mém “Arduino” thu hign vic “cé tao ra tap tin i HEX hay khong?” hoc “hru trit tp tin ma HEX nay tai dau trong méy tinh?” hoan toan do ngwdi str dung phai thiét lap cdc thong sé lam vige trong phan mém Itc ban diu. Muén lam duge viée nay thi ta can phai diéu chinh va bé sung lai cdc théng sé cho tap tin “Preferences.txt”. Viéc nay cé thé duge the hién bang cach, tir thanh “Menu” ta nhap chuét vao “File” — “Preferences”. © v0.2 | sano 1512 —o x || seth Took Help ec) ‘pen ese se aes Soret. CheSites oe ako xan Hinh Error! No text of specified style in document..28, Chon tinh nang Preferences trong phan mém Arduino. Khi dé trén man hinh sé xudt hign h6p thoai “Preferences”. Trong hép thoai nay ta nhap chudt dénh dau vao tinh ning “Compilation” nim trong muc “Show verbose output during”. Sau dé nhdp chudt vao dong chit minh hoa dung dan luu tap tin ma HEX nhu duge trinh bay trong Hinh Error! No text of specified style in document..29 duéi day. jén soan: Pham Quang Tri Term nen er ok rt eerie 36 re] Enrne aka ean Pelee x sete Stott (Ctsasetoamer Were one eter rege Senate SS fesureereeot iets) none (asenase | a0 Spe faquerrenar tse) ston vere bute: Pleoetson June cooper wanes: here ee nae [lee cae réns vet ce ater seat lus eater loner usseson strip (Ppa ten eto eects ni p> 8) isomer wesery perl ends Maron Us o Tee nesta occa Sirens Hinh Error! No text of specified style document..29. Diéu chinh tinh nang Preferences trong phan mém Arduino. M6t cita sé méi xuat hién, chi ra noi lu tri cla tap tin “Preferences.txt”. Ta nhdp dip chudt vao tén tap tin nay dé mé né ra va tién hinh bé sung théng tin cdu hinh cho phan mém “Arduino”. Henan ar ¢ Bee aleaaum Pntelek COEF FRE ena RH Eaton ewe ceccinn 1D ee Gi ae ie wren = hme a Daemesiied | Type See tw eep a maa, 1B) Documents 1 saging IO/IN/201644 20 Fe Felder — yee Penman! wt 4 2 at Sates ot) Teaecimet Brow ee Caiiema ieee) 37 Taro ako Hinh Error! No text of specified style in document..30. Tap tin ding dé cdu hinh hoat déng cho phan mém “Arduino”. Trong man hinh soan thao ctia tap tin “Preferences.txt”, ta nhdp bé sung thém dong lénh “build.path = ”’ nhu minh hoa trong Hinh Error! No text of specified style in document..31 duéi day (trong dé phan “.. 2” sé duge thay thé 1a duéng din dén noi ma nguoi sir dyng muén Iu trit tap tin ma HEX). Két thic bé sung va chinh nay bang cd dau tién phai déng phin mém “Arduino” lai, sau dé méi thye hign vige Iuu Jai tap tin “Preferences.txt” va nhdp chu6t vao nt “OK” trong h6p thoai “Preferences”. Luu y 14 néu ta kh6ng thye hign viéc déng phan mém “Arduino” lai tréc khi thyc hién viée luu lai tép tin “Preferences.txt” thi moi viéc higu chinh sé khéng cé tac dung. Tién hanh khéi d9ng Jai phan mém Arduino dé cp nat sy thay ddi nay va tién hanh bin dich lai chuong trinh diéu khién dé c6 duge tap tin ma HEX tai thu mue mong muén. Dp tape a = ork \Giang day\Sai giang\é. Gise & Soitorcinentstue Hinh Error! No text of specified style in document..31. Digu chinh lai noi luu tap tin ma HEX. 1.2.4.2. Bude 2— Vé mach mé phéng cho hé théng trén phan mém mé phéng “Protues” Bién soani Pham Quang Ti er er Caiiema ieee) 38 Taro ako Khéi dong phan mém “Protues” va tién hanh vé so dé mach mé phong cia hé théng giao tiép va digu khién thiét bj ngoai vi théng qua céng COM nhu trong Hinh Error! No text of specified style in document..23. 1.2.4.3. Buée 3 — Nap chwong trinh cho mach Arduino trén phan mém mé phéng “Protues” Dé nap chuong trinh diéu khién cho Atmega2560 trong mach mé phong ta nhap dup chudt vao vi mach Atmega2560 trong so dé. Trén man hinh xuat hién hp thoai “Edit Component” nhu Hinh Error! No text of specified style in document..32 bén dudi. Peder ‘ie nae =a een | Gao sical ‘Device Netes cosh a dave Ppa ne Peo [Jeeta smn (cea Ae [1S tens Hinh Error! No text of specified style in document..32. Hp thoai higu chinh thong s6 lam viéc cho mach Arduino. Trong hép thoai “Edit Component”, dé dam bao tinh chinh xdc vé mat thoi gian, t6c d@ diéu khién trong khi chay m6 phéng trén may tinh thi ta cn chon chinh xée tin sé xung clock cdp cho vi diéu khién trong myc “Clock Frequency”, trong truéng hgp vi dy nay ta nhap vao 16MHz nhu minh hoa trong Hinh Error! No text of specified style in document..32 bén trén. Ngoai ra, cing trong hop thoai “Edit Component” nay & myc “Program File” ta sé phai chi duéng din dén noi luu trit tap tin chuong trinh diéu khién duge tao ra 6 Bude 1 va chon tap tin nay, sau dé nhap jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) ES Taro ako chu§t vao nit “Open” trong hép thoai “Select File Name” 48 chon né nhw minh hoa trong Hinh Error! No text of specified style in document..33 va két thic viée nap chuong trinh diéu khién cho Atmega2560 bang cach nhap chudt vao nut “OK” trong hép thoai “Edit Component”. vec Ba bokee snes Bc Gh tiseay Hinh Error! No text of specified style in document..33. Hp thoai chon tp tin chuong trinh diéu khién cho Atmega2560. Sau khi 4 chon tap tin chuong trinh diéu khién cho Atmega2560 thi ta tién hanh thiét lap théng s6 hoat déng cho céng COM mé phéng trén phan mém Protues. Tién hanh vigc nay bing céch nhdp dup chudt vao céng COM mé phéng trong so dé dé mé h6p thoai “Edit Component” nhu Hinh Error! No text of specified style in document..34 bén dudi. Bién soan: Pham Quang Tri Peer nen enor Caiiema ieee) 40 % eaecomponert 7% Palen range ere Poesia Prac Fay ‘yl ad at ‘vst Dit te Prycal up ae One eos. Cisne tte PB Lyne Clectactonate anes (alpen anit Hinh Error! No text of specified style in document..34. Hop thoai higu chinh thong sé hoat d6ng cho cong COM mé phéng. Trong h6p thoai nay ta can higu chinh chinh xac ce thong s6 nhu sau: o Tén céng COM (Physical Port): COMI o Téc dé truyén dit ligu (Physical/Virtual Baud Rate): 9600 co 86 bit dit ligu (Physical/Virtual Data Bits): 8 Bit kiém tra (Physical/Virtual Parity): NO! © Sé bit dimg (Physical/Virtual Stop Bits): 1 Sau khi da higu chinh chinh xdc cdc théng s6 nay thi ta sé két thiic bang cach nhdp chuét vao nt “OK” trong h6p thogi “Edit Component”. 1.2.4.4. Buwée 4 — Sir dung cong cy gia lap giao dign didu khién thiét bi théng qua cong COM trén may tinh — SerialPort Terminal Thue hién tong tu nhw da trinh bay trong phan giao tiép va diéu khién thiét bi ngoai vi théng qua céng COM gitta may tinh va vi diéu khién PICI8F4550, xem chi tidt trong muc “1.1.4.4, Bude 4 — St dung céng cu gia lap giao dién diéu khién thiét bi théng qua céng COM trén miy tinh”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) mn Taro ako 1.2.4.5. Buée 5 — Tao mé phéng két néi giita giao dién didu trén may tinh va hé thong giao tiép, diéu khién thiét bi ngoai vi thong qua céng COM dang mach Arduino Thuc hién tuong ty nhw dj trinh bay trong phan giao tiép va diéu khién thiét bi ngoai vi théng qua céng COM gitta may tinh va vi diéu khién PIC] 8F4550, xem chi tiét trong muc “1.1.4.5. Bude 5 — Tao mé phong két ndi gitta giao dién diéu trén may tinh va hé théng giao tiép, digu khién thiét bi ngoai vi thong qua cng COM ding PICI8F4550”, 1.2.4.6. Buée 6 — Tién hanh mé phéng diéu khién thiét bi iu khién thiét bi Thuc hién tuong ty nhw da trinh bay trong phan giao tiép va ngoai vi théng qua céng COM gitta may tinh va vi diéu khién PIC] 8F4550, xem chi tiét trong muc “1.1.4.6. Bude 6 — Tién hanh mé phong diéu khién thiét bi”. 1.3.Giao dign digu khién trén may tinh é cé thé nhanh chéng tiép cAn véi cdch thite x4y dung mét giao dién diéu khién thiét bj théng qua céng COM trén may tinh trong cdc bai hoc sau, thi véi mute 46 co ban sinh vién chi can tham khdo that ky va ndm that vitng céc thao tac thyc hién trong bai vi du duéi day. Tuy nhién dé cé thé thye hién x4y dung mét giao dién diéu khién trén may tinh cé mite 46 phitc tap cao hon thi can tim kiém va tham khao thém c tai ligu vé phan mém “Visual Studio C# 2012”. 1.3.1. Tgo Project méi trong Visual Studio C# 2012 Sau Khi 43 cai dt phdn mém “Visual Studio C# 2012” vao may tinh, ta tién hanh khéi déng phan mém. Tuy thude vo phién ban phan mém da cai dat ma mét ctra s6 khi déng (Start Page) sé xuat hién nhu hinh minh hga bén duéi. jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) ry Hinh Error! No text of specified style in document..35. Cita sd khoi dong cua phan mém “Visual Studio”. Dé tao mét Project méi, ta nhdp chudt vao muc “New Project” trong phan myc “Start” phia bén trai cita sé lam viée hoe tit thanh menu Iénh ta chon Iénh “File” > “New” — “Project...”, xem minh hoa trong Hinh Error! No text of specified style in document..36, 2 ra mae eo ma foro w-eud i. Hinh Error! No text of specified style in document..36. Khéi dng mét Project méi. Trong cira sé “New Project” ta chon kiéu Project muén tao la “Windows Forms Application” nhu hinh minh hoa trong hinh bén duéi. Dé cé duge kiéu Project Bién soan: Pham Quang Tri Term nen er ok rt eerie Taro ako nay ta nhé luu y ring phai chon ding thir tu cde muc trong phan phia bén trai cita sé “New Project” la “Installed > Templates > Visual C# + Windows”. pena cag gn songs — $Y ota, vase ea, BT rootecistney vase sre B v0 cme hen voutce nn |S Soren : ae BEE] Wisenrsovce Yau TEER, | or cmncmon ice = Hinh Error! No text of specified style in document..37. Chon kiéu Project cin tao. Trong cira sé “New Project” nay ta cing cin ghi nhé va diéu chinh lai tén Project (diéu chinh trong myc “Name’”), noi lu tri trong may tinh (diéu chinh trong muc “Location”) 6 phan phia duéi ca cira sé nay, xem minh hoa trong Hinh Error! No text of specified style in document..37. Sau khi da thyc hign xong cdc céng viéc trén ta nhdp chuét vao nut “OK” dé hoan tat vic tao méi mét Project. Khi dé trén man hinh sé xuat hién ctra sd lam viéc dé tao giao dién diéu khién nhv hinh minh hoa bén dudi. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) rn Giao dign Thudc tinh javesseaugraesor>agmae- Hinh Error! No text of specified style in document..38. C Studio dé tao giao dign diéu khién ¢ Phan giao dign (Form): Day chinh 1a ctra sé giao dién chinh cia chuong trinh diéu khién sé xuat hién & gia man hinh lam viée cia méy tinh. Trong cita sé giao dién nay ching ta sé dat vio dé tat ca cée Adi tugng didu khién (nhw nut nhdn, nhan, hdp thoai, mut chon chire nang,...). = ied style in document..39. Giao dién diéu khién (Form). Hinh Error! No text of spe © Phan céng cu (Toolbox): Chita toan b6 cdc déi tong diéu khién ma ra mét giao dién cho chuong trinh diéu khién Ce nrerrnenrern crc Caiiema ieee) ro ching ta sé cin dén dé ti jén soan: Pham Quang Tri Taro ako ciia ching ta, Tat ca cde phan vige chiing ta cdn phai lam chi don gin 1a nhdp va gitt chuét vao déi twong diéu khién trong hép céng cu (Toolbox), sau dé ré va tha ching vao trong phan giao dién diéu khién (Form) tai vi tri mong muén. Cac déi tugng diéu khién thuéng duge gom chung vao trong céc tinh nang diéu khién khac nhau nhu “All Windows Forms”, “Common Controls”, “Containers”,... Dé y duo Jc d6i tuong diéu khién trong mdi nhém ta can nhdp chuét vao dau “+” dé cho phép ching hién thj 1én man hinh cua h6p céng cy. Trong trang hop ching ta khdng nhin thay ctra sé cla hép céng cy tir thanh menu Iénh ta chon lénh “View” > “Toolbox” dé cho phép hdp céng cu hién thi trén ‘man hinh lam vigc. Gk MaskesTetBox Search Toolbox 2 BB Monencalendar 1 Al indons Frm - Le Nottyicon 2 a BB Numericupdown I Pictrebor ED Progeenter @ PadicButton Checked By herTotbox Comboiox Teton Dotetimeicter te Tootie ibe = Teetiew Linidaes Bl Webaromer ListBox 1 Contains eview 1 Menus & Toolbars 2 MakasToxtor 0 Daa BE MonthCsender © Components - Hinh Error! No text of specified style in document..40. H6p cong cu (Toolbox). © Thudc tinh (Properties) vA quan ly chuong trinh (Solution Explorer): Méi déi tuong diéu khién, ching han nhu mt nut nhdn, déu phai 6 nhiing thuge tinh ciia nd, Thude tinh cua déi trgng diéu khién 1a nhig théng tin nhu chidu cao, chidu rong, kich c@, tén hién thi, tén diéu khién, nhan,... Dé nhin thay dugc thuéc tinh cia mét 46i tugng diéu khién nao do ta can phai chon déi tong diéu khién nay, bing cach tir trén man hinh giao dién ta sé nhap chuét vao déi tugng (Iuu y 1a chi duge nhdp chuét 1 lan vao déi tung khi dé ta sé nhin thay cdc thude tinh ciia déi tugng diéu jén soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) cs Taro ako khién xudt hién, khong duge nh4p dup chudt vao déi tugng vi khi 46 phan mém sé tu déng chuyén dén man hinh soan thao ma nguén cho déi tugng nay), quan sat cdc thudc tinh ciia déi tugng diéu khién trong phan ndi dung (Properties) nim 6 géc duéi bén phai ca cita sé lam viéc. Viée diéu chinh cac théng sé thuéc tinh nay ddi hoi sinh vién phai ty minh nim ving va tim hiéu thém trong nhiéu tai ligu khéc nhau nhim dam bao tinh, chinh xée cia timg thudc tinh. Trong phan quan ly chong trinh (Solution Explorer) la phan néi dung nam 6 géc trén bén phai cua cita sé lam viée, sé cho ching ta biét tén ciia Project, sé Iugng cdc cita sé (Form) cé trong mét Project, ma nguén cua Project,... Proper + 9X Soiion Spore @\o-roae Bllals Seorch Solution Explorer (Ctr p- eee ~ solution eimau' (projet) Aigo ayou Fae 2S tama Showcon Tue » & Propet: SodsTekiar Te Pea References, sce 0,300 B Appcontig SireGripStyle Auto 4 (B Fortes StanPockion WindowDefautlo 2 Foon! Deignacs = 73 fom rex Tet Formt > 43 Fort Z 3 bo Programmes Right To eftLayout Insiester near the conta! avout ie right-of when the Right Tole prope Solution Epler | Team Explorer Hinh Error! No text of specified style in document..41. Thudc tinh (Properties) va quan ly chuong trinh (Solution Explorer). Sau khi d3 hoan chinh viéc tao mOt Project méi ta tiém hanh Iwu lai cde cong viée da thyc hign cia ching ta bing cach nh4p chuét vao biéu tugng “Save All” trén thanh céng cu hoe tir Menu Iénh ta chon Iénh “File” —> “Save AI”, 1.3.2, Phan tich vi dy minh hoa Trong phan nay sé trinh bay chi tiét cach thire ding phan mém “Visual Studio C#” 48 tao ra mot giao dign digu khién trén may tinh dé giao tiép véi thiét bi ngoai vi théng qua céng COM. Luu y ring giao dign nay sé duge ding dé mé phéng giao tiép va diéu khién ngoai vi théng qua céng COM cho hé théng thiét bi ngoai vi ding vi digu khién PICI8F4550 ho%e mach Arduino Mega 2560 ma ta da thy hién trong bai Bién soan: Pham Quang Tri Cerne ne ces Caiiema ieee) a Taro ako hoc trude (xem lai cde mye 1.1 va mye 1.2). Vi vay dé thye hién t6t ndi dung trong mye nay, cdc sinh vién cn phai xem lai va thye hign mét céch hoan chinh cdc n6i dung cita bai hoc truée, day 14 chinh 1A yéu cdu bat buéc can phai dap tng. Yéu cdu giao did © Phan thiét fp truyén thong: © Hop chon Iya céng COM. © Hép chon Iua téc 46. co O thong tin hién thi trang thai két néi céng COM. © N&t nhdn két néi céng COM. o Nut nhdn ngat két néi cong COM. ¢ Phan diéu khién thiét bi: o Nut nhdn diéu khién bat LED. o Nut nhan diéu khién tit LED. © Phan doc trang thai thiét bi: oO théng tin hién thi sé 1an ngwai st: dung da nhan-nha nat SW. Phan truyén/nhan dit ligu: o Othéng tin nhap dit ligu can giti di. o O théng tin hién thi dé ligu nhan duge. © Céc thanh phan khée: © Nut nhdn thoat chuong trinh. Két qua giao dign sau khi tao xong sé nhw hinh minh hoa bén dudi. 1 Semple Interface - RS232 Communication - x S232 (COM) Communication Lab Communication Setup Svitch Saius Data Serd Receive COU Port Counter(s) (EME) Send Hoa eee LED Conta Receive: Lepowor | ON | Designed by patt2002 Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) cy Coated Hinh Error! No text of specified style in document..42. Giao dign cia chuong trinh giao tigp va diéu khién. 13. 3. Xay dung giao dign diéu khién thiét bi ngoai vi thong qua cong COM trén may tinh Trong phan nay sé trinh bay chi tiét cdch thite tao ra mét giao dién diéu khién sir dung phan mém “Visual Studio C#”. Dé tao ra giao dién cia chuong trinh giao tiép va diéu khién nhu trén thi ta cn sir dung mot sé déi tugng véi tén diéu khién, tén hién thi va thudc tinh duge hiéu chinh so voi mac dinh nhu trong Bang Error! No text of specified style in document. Bang Error! No text of specified style in document..1. Ligt ké cdc déi tung trén giao dién diéu khién. STP | Daitugng | Ten bign eh Téa difu khign Cie thaje tinh duye bigu chink 7 Button Conneet Tatton_Connect z Button Send bution DataSend 3 Button Disconnect Dutton DisConneet 7 Button Tx Program bation Exit 3 Button OFF button_OFF G Button ON button ON 7 ComboBox comboBox_BaudRate DropDownStyle = DropDownList Items = Collection) 8 ComboBox comboBox_COMPort | DropDownStyle = DropDownList Items = (Collection) | CheckBox checkion_DataSend Sample ‘RutoScaleMode = Font 10 Form ee Form,SampleCOM Noe ee Communication StantPosition = CenterSereen i GroupBox Communication groupBox_COMSetup Setup 7 Daw 12 | GroupBox | ieee | SOUPBOXDataSendRecive TS] GroupHiox | Switch Status wroupfox_KIQPC To) GroupBox | LED Control ‘groupBox PORE 15 Tabal Baud Rate Tabel_ BandRate 16 Tabet COM Port Tabel_COMPort 7 Tabel Counter Tabel Counter jén soan: Pham Quang Ti re eoteaa Pies rn) Taro ako 18 Tabel Send Tabel_DataSend 19 Tabel TED OOF Tabel_LEDOnOT Designed} extAlign = MiddleCenter 20 Label seneey label_NameDesigned | Te**Align= MiddleCent patri2002 ForeColor = Blue TTextAlign = MiddleCenter S232 (COM) Font = Mirosoft Sans Serif, 10pt, 2 Labet. | Communication Iabel_Nametab ~ style=Bold Lab ForeColor = Blue B Tabet Reveive Tabel_Receive BackColor= White 23 | Ovalshape ovalShape_LED - BackStyle = Opaque | SerialPort Serial Por 35] ShapeContainer apeContainerd BackColor = White Font ~ Microsoft Sans Serif, 8.25pt, 26 | TextBox textBox_DataReceive | style-Bold ReadOnly = True TextAlign = Center BackColor= White Font = Microsoft Sans Serif, 8.25pt, 27 | TextBox textBox_DataSend | style=Bold ReadOnly = True TextAlign = Center BackGolor = Red Font = Microsoft Sans Serif, 8.25pt, 28 | TextBox textBox_Status style=Bold ReadOnly = True TextAlign = Center BackColor = DodgerBiue Font = Microsoft Sans Serif, 8.25pt, 29 | TextBox textBox_SW style=Bold ReadOnly = True TextAlign = Center va luu tri m6t Project moi, van dé nay da duge trinh bay 6 pl Dau tién ta khdi déng phan mém “Visual Studio C# 2012” dé tao méi, dat tén xem chi tiét trinh bay trong muc 1.3.1. jén soan: Pham Quang Tr Pen dau ciia mye nay, in and Control for Caiiema ieee) 50 Taro ako 0 tse oc en us DIxacinacoa PEER IE KOT YEH eROKCT NLD QUG TAM FOQUAT TOOLS TEST AADACTURE AE ROOW LP Son BD o | peo lowe rl Hinh Error! No text of specified style in document..43. Tao mét Project méi. Tiép theo ta thye hién ddi tén hién thi va tén diéu khién cia giao dién diéu khién (Form): Hinh Error! No text of specified style in document..44. Minh hoa tgo giao dign diéu khién “Sample Interface - RS232 Communication”. © Diéu chinh cdc thudc tinh déi tugng nay nhu trinh bay trong Bang Error! No text of specified style in document..1. ¢ Két qua thyc hién nhu minh hoa trong Hinh Error! No text of specified style in document..45 bén dudi. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 51 Taro ako Hinh Error! No text of specified style in document..45. Minh hoa hoan tit tao giao dign didu khién “Sample Interface - RS232 Communication”. Tiép theo ta tao nhin (Label) “RS232 (COM) Communication Lab” va “Designed by pqtri2002”: Vao “Toolbox —>» Common Controls”, chon “Label” vi dua ra giao dign. Hinh Error! No text of specified style in document..46. Minh hoa tao nhan “RS232 (COM) Communication Lab” va “Designed by pqtri2002”. © Diéu chinh cac thudc tinh cdc déi tugng nay nhuw trinh bay tai Bang Error! No text of specified style in document..1. © Két qua thyc hign nhu minh hoa trong Hinh Error! No text of specified style in document..47 bén dudi. Hinh Error! No text of specified style in document..47. Minh hoa hoan tit tao nhan “"RS232 (COM) Communication Lab” ” va “Designed by pqtri2002”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) EA Taro ako Tiép theo ta tao cdc hop nhém (GroupBox) “Communication Setup”, “Data Send/Receive”, “Switch Status” va “LED Control”: Vao “Toolbox > Containers”, chon “GroupBox” va dura ra giao dign. EE ma Hinh Error! No text of specified style in document..48. Minh hoa tgo hép nhém “Communication Setup”, “Data Send/Receive”, “Switch Status” va “LED Control”. * Diéu chinh cdc thude tinh cde déi trong nay nhu trinh bay tai Bang Error! No text of specified style in document..1. ¢ Két qua thyc hién nhu minh hoa trong Hinh Error! No text of specified style in document..49 bén dudi. S232 (COM) Communication Lab ED coat Hinh Error! No text of specified style in document..49. Minh hoa hoan tit tao hop nhém “Communication Setup”, “Data Send/Receive”, “Switch Status” va “LED Control”. Tiép theo ta tao cdc hdp tha xuéng (ComboBox) cing véi cic nhan (Label) tong img kém theo “COM Port” va “Baud Rate” trong hop nhém “Communication Setup”: Vio “Toolbox > Common Controls”, chon “ComboBox” (dé tao hép tha xudng) hodc chon “Label” (dé tao nhan) va dua ra giao dién. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) Es Taro ako S282 (COM) Communication Lab i) Hinh Error! No text of specified style in document..50. Minh hoa tao hép tha xuéng cing véi cde nhan tuong (mg kém theo “COM Port” va “Baud Rate”. ¢ Pidu chinh cdc thudc tinh cde déi tugng nay nhuw trinh bay tai Bang Error! No text of specified style in document..1. © Cée biéu tuong (Items) trong phan hép tha xuéng “Baud Rate”: Nhdp vao muc “Collection” va nhap vao ndi dung nhu hinh minh hoa bén dui, sau 46 nhap chudt vao nat “OK”. 7 x rete stings in the collection fone pert Hinh Error! No text of specified style in document..51. NI vio cde gid tri té truyén dit ligu. © Két qua thye hign nhu minh hoa trong Hinh Error! No text of specified style in document..52 bén dudi. Donat Bién sogn: Pham Quang Tri Cer Porc Caiiema ieee) ES Taro ako Hinh Error! No text of specified style in document..52. Minh hoa hoan tat tao hop tha xuéng cing véi cdc nhan tuong tmg kém theo “COM Port” va “Baud Rate”. Tiép theo ta tgo cdc mit nhin (Button) “Connect”, “Disconnect”, “ON”, “OFF”, “Send” va “Exit Program” trong céc hép nhém “Communication Setup”, “LED Control” va trén giao ‘40 “Toolbox — Common Controls”, chon “Button” va dua ra giao dién [S282 (COM) Communication Lob Cayman Sep Date Secor coMPoe taste Hinh Error! No text of specified style in document..53. Minh hoa tao ede nut nhan “Connect”, “Disconnect”, “ON”, “OFF”, “Send” va “Exit Program”. * Diéu chinh cdc thude tinh cdc déi tugng nay nhw trinh bay tai Bang Error! No text of specified style in document..1. * Két qua thye hién nhu minh hoa trong Hinh Error! No text of specified style in document..54 bén duéi. £28282 (COM) Communication Lab com ror =] Hinh Error! No text of specified style in document..54. Minh hoa hoan tat tao céc nit nhin “Connect”, “Disconnect”, “ON”, “OFF”, “Send” va “Exit Program”. Tiép theo ta tao hOp dir ligu (TextBox) “Disconnected!” trong hop nhém “Communication Setup”: Vio “Toolbox —> Common Controls”, chon “TextBox” va dua ra giao dign. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 55 15232 (COM) Communication Lab cramincmin Ses Sh Sans te Sena esaie = (Se) eg by pepn2002 Hinh Error! No text of specified style in document..55. Minh hoa tao hop dit “Disconnected!” * Bidéu chinh cdc thude tinh cée déi twong nay nhu trinh bay tai Bang Error! No text of specified style in document..1. Két qua thyc hién nhu minh hoa trong Hinh Error! No text of specified style in document..56 bén duéi. S232 (COM) Communication Lab Hinh Error! No text of specified style in document..56. Minh hoa hoan tit tao hép dit ligu “Disconnected!”. Tiép theo ta tao h6p dit ligu (TextBox) cing véi nhan (Label) kém theo “Counter (SW), “Send” va “Receive” trong hép nhém “Switch Status”, “LED Control” va “Data Send/Receive”: Vio “Toolbox —» Common Controls”, chon “TextBox” (dé tao hdp dit hodc “Label” (dé tao nhin) va dua ra giao dién. aa) i | eaPaaan_| Bosna by pt2002 Hinh Error! No text of specified style in document..57. Minh hoa tao hép dit ligu cling véi cdc nhan kém theo “Counter (SW)”, “Send” va “Receive”. Bién sogn: Pham Quang Tri Cerner Cnc Caiiema ieee) 56 rch nia een) Paar raked eas * Bidu chinh cde thuge tinh cée déi trong nay nhu trinh bay tai Bang Error! No text of specified style in document..1. ¢ Két qua thuc hién nhu minh hoa trong Hinh Error! No text of specified style in document..58 bén dudi. £88282 (COM) Communication Lab Cote) (NH) Sot ep carat Designed by etn2002 Hinh Error! No text of specified style in document..58. Minh hoa hoan tat tao hop dit ligu cing véi cae nhan kém theo “Counter (SW)”, “Send” va “Receive”. Tigp theo ta tao h6p danh dau (CheckBox) “Send” trong hép nhém “Data Send/Receive”: Vio “Toolbox —> Common Controls”, chon “CheckBox” (dé tao 6 dénh dau) va dua ra giao dign. Sitch Sa come) TL Hinh Error! No text of specified style in document..59. Minh hoa tgo hop dénh diu “Send”. * Didu chinh cdc thude tinh cdc déi tugng nay nhw trinh bay tai Bang Error! No text of specified style in document..1. * Két qua thyc hign nhu minh hoa trong Hinh Error! No text of specified style in document..60 bén dui. Bién soan: Pham Quang Tri SE fabri Ed oN leer [2 Spe etee- R22 Caremuniton| 15232 (COM) Communication Lab Conmncnen Seip ‘Symch Sans (i Se Aesase ‘com Fee | Careers) EM) sere | basins ecove [—_] or) oF | | Sed | | aoa ene iy 02 Hinh Error! No text of specified style in document..60. Minh hoa hoan tit tao hop danh du “Send”. Tiép theo ta tao giao tiép céng COM “SerialPort”: Vao “Toolbox > Components”, chon “SerialPort” va dura ra giao dién. * Didu chinh cde thudc tinh cdc déi tugng nay nhw trinh bay tai Bang Error! No text of specified style in document..1. * Két qua thyc hién nhu minh hoa trong Hinh Error! No text of specified style in document..61 bén durdi. 0 seme Micct View tuo BR cra aon conve Pla ax GE BIT OW gROECT gUED gaUG THE FORINT TOO TST ARCHTECTUNE AAMLZE YMGOW HSLP son BI Setport a Inia th neve ein cota enh bec Hinh Error! No text of specified style in document..61. Minh hoa hoan tit tao giao tiép cong COM “SerialPort”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 58 Taro ako Cuéi cing trong phan tao giao dién Ii phai tao hinh vé bau duc (OvalShape) cing véi nhan (Label) kém theo “LED On/Of”” trong hop nhém “LED Control”: Vio “Toolbox —> Visual Basic PowerPack”, chon “OvalShape” (dé tao hinh vé bau dyc) hodc “Label” (dé tao nhan) va dua ra giao dig S232 (COM) Communication Lab cour =) conte (See CI Saati a | fcore [] =a ST] Ge sot | | St Poge aged by ps2002 Hinh Error! No text of specified style in document..62. Minh hoa tgo hinh vé bau duc cing véi cae nhin kém theo “LED On/Off’. * Didu chinh cde thudc tinh cdc déi tuong nay nhw trinh bay tai Bang Error! No text of specified style in document..1. ¢ Két qua thuc hién nhu minh hoa trong Hinh Error! No text of specified style in document..63 bén dudi. 85232 (COM) Communication Lab ‘ote Ss Da Serene corti) (ES 2) LED cont Foss Sed esne by p02 Hinh Error! No text of specified style in document..63. Minh hoa hoan tat tao hinh vé bau duc cling véi cdc nhan kém theo “LED On/Off”. Mét sé phién ban phin mém “Visual Studio C#” khéng duge tich hop sin déi tugng hinh bau duc (OvalShape) nay, chinh vi thé ma chung ta can phai bé sung vao trong thu vién cia phan mém. Dé lam viéc nay cn phai bé sung thu vién lién két dong Microsoft. VisualBasic.PowerPacks.dll vio trong Project giao dign dang thyc hién bang cach nhu sau, tir ctta sé “Solution Explorer” ta nhdp phai chudt vao myc “References” va chon lénh “Add Reference...”. Bién soan: Pham Quang Tri ‘Communication and Control for Caiiema ieee) 59 oN leer @ e- Fog o +B Sesh Soliton Epo (tt 2 Slaton MySarpie PICTEFASS (pet 4° i MySample PICLFASS0 > be roperes D sopeenig b Bbtemic — AdsSensce Reece, > Pragiamcs Bf Manage Mute Pacage. BE Ne soitan ptererien ms Hinh Error! No text of specified style in document..64. B6 sung thu vign lién két dong vao trong Project. Trong hép thoai “Reference Manager” ta nhdp chudt vio nut “Browse...” dé chon tp tin thu vién DLL. eteence Manage = MySurpePCi=50 2 owe cent [Heme [0 Hinh Error! No text of specified style in document..65. Hp thoai quan ly cde Reference cla Project dang thye hién. Tiép theo ta chon dudng din dén noi Iuu tré tap tin thu vién lién két dng Microsoft.VisualBasic.PowerPacks.dll trong may tinh va chon n6. Computer Peripheral Devices co Taro ako © > + |[e Weapecatia + Co nibae near Dias? ew aes mys) Nee . MyWons * code zi 256CH TL aMysotmae [codecs nae s20cH sm Petes Mises alle PonsPece Deg, e strana 2385 F MicoickaualbmiePowePade 4 Mies View yg Flepame [tierra Visual PuerPctsll | Componenti alist i Conc Hinh Error! No text of specified style in document..66. Hp thoai chon tp tin thir vién DLL. Sau dé nhdp chuét vai mit “Add” trong hép thoai “Select the files to reference ” va nut “OK” trong hdp thoai “Reference Manager” dé két thic vige bé sung thu vién lién két dong. Két qua viée bé sung nay duge minh hoa trong Hinh Error! No text of specified style in document..67. @ o-eagas-2 F Prats a B Hinh Error! No text of specified style in document..67. Minh hoa hoan thanh viéc bé sung thu vién DLL. Tiép theo ta can bd sung déi tugng hinh bau duc (OvalShape) cia thu vién lién két dong Microsoft. VisualBasic.PowerPacks.dll vio Toolbox ciia Project dang thy Bién soan: Pham Quang Tri Peer nen enor Caiiema ieee) ol Taro ako por uaa hign bing cach ta chon tab myc “Toolbox” va chon céng cy “General” (nim phia dudi cing cia mye Toolbox). 94 rasp 16 RIE OT ve PROKCT. BULD DEBUG e-o 8-aEw >see ) EE Sarr ooeor 2 » alWindor Foome Common Conte Conte Ethers Toone Dae > Peiting » Disogs > Repoting WPF rteopeaiity a “har are no vale contin hc group, Dragan Hinh Error! No text of specified style in document..68, Minh hoa chon céng cu General trong mye Toolbox. Peer nen enor Caiiema ieee) 62 Taro ako Enrne aka ean Nhép phai chudt vao cng cu “General” va chon Iénh “Choose Item 0) dysaple RIOFSS0- Mies Vin io FE EDT EW PROUECT AULD OEBUG TEAM SOL TOOLS TEST. AF e-o any > sit = oabug = a | fs ree o fb Avandous Foes Common Contos Eb Containers Ey Mens 8 Toate ‘0 coo! boa Cr oes > Components Cuz Ouse > Perang ie is ter Raping Cue Cue WPF ntepetiy Val Bai Poweocke Hinh Error! No text of specified style in document..69. Minh hga chon Iénh “Choose Item...” trong edng cy “General”. Khi d6 trén man hinh hién thj hép thoai “Choose Toolbox Items” nhu minh hoa trong Hinh Error! No text of specified style in document..70 bén dudi. oc Toortene 7x Sapam do Pont Conpnets|_VndowsXAML Conger | WOF Corp net Famovoi commana > | COM Components Sinaia Gomera Tene = Tanase Pee ane : Gh Aemstaiiouce Seminar — sy SreenttotionCorgmentioss — Sprniiion opener 1 Aicimuconsst thera erroneivaconeniitine Wccrteenrandon Cnt 1 mecoe ene ops voc Vier Compe TE oncemy Moran Conpatlg 86 ices ua Compa mater ‘poem entcont Spicnthcbie thee Semmeivercoroce Soon fepeematiot Spentesietcoweneres Spent ‘enter yen Contig est Sn Corgan an tga tint Caiiema ieee) cs Taro ako Hinh Error! No text of specified style in document..70. Hép thoai “Choose Toolbox Items”. Trong hép thoai nay ta chon tab “.NET Framework Components” va nhdp chuét vao nat “Browse” dé chon tap tin thu vién DLL. Tiép theo ta chon duéng dan dén noi lwu trit tap tin thu vién lién két dgng Microsoft. VisualBasic.PowerPacks.dll trong méy tinh va chon né. ay [Ds Wace Dec > MMO PCED» VO) Seeh CS Miva PERS p Dime? ew aes reef wnat [| Codecs: Soviets # | ee : ae! My Wens yt Caled S Hinh Error! No text of specified style in document..71. Hp thoai chon tp tin thir vién DLL. Khi dé trong hdp thoai “Choose Toolbox Items” tai tab “.NET Framework Components” sé xudt hign thém déi tugng “OvalShape” nhu minh hoa ¢ Hinh Error! No text of specified style in document..72 Bién soan: Pham Quang Tri Peer nen enor Caiiema ieee) 64 Taro ako Ce Testes tene 7 x | Sivatight Components [Windows Phone Camponens | Sa [Whe Compeners | HET Framework Components COM Components System Acti: Components Name Namespace = Assen Name [)atstesener LinaShape fectangeSape RecaneSape ee Language nari Language hit County) (a Cae] Hinh Error! No text of specified style in document..72. Déi tugng “UsbHidPort” duge bé sung thém vao Project. Cuédi cing nh4p chuét vao nut “OK” dé két thie vi bau duc cia thu vién lién két dong Microsoft.VisualBasic.PowerPacks.dll vio bé sung déi tuong hinh Toolbox cia Project. Sec Tooicx 2 esfcon moO mage mE Hinh Error! No text of specified style in document..73. Déi tugng hinh bau duc cua thu vién Microsoft. VisualBasic.PowerPacks.dll. Sau Khi thy hign day du céc céng viée bén trén thi chung ta sé cé duge giao dign giao tiép va diéu khién thiét bi ngoai vi thong qua céng COM hoan chinh nhu minh hoa trong Hinh Error! No text of specified style in document..74. Bién soan: Pham Quang Tri Cerner ccd Caiiema ieee) cS Lyre) Enrne aka ean Ieee CR ket) 26) an td de owe saan EAE WT Yl OKT GUD NE TM FAT OLS TST MATER aE NOON on 8 Q[e-20gR/o %— sen se Ope = Hinh Error! No text of specified style in document..74. Minh hoa giao dign diéu khién hoan chinh. 1.3.4, Giai thuat va ma ngudn ciia giao dién didu khién 1.3.4.1. Gidi thuat Forn_SampleCOM_Load comboBox_COMPort_Sclected B comboBox BaudRate_Selected. jén soan: Pham Quang Tr ‘Communication and Control for Caiiema ieee) co ETI) Enrne aka ean Taro ako ‘checkBox_DataSend_CheckedChanged Send_Data. ho phép sir dung nat “Send” va nhgp dit ligu vao hép dir ligu “Send” button_DisConnect Click Hop thogi théng bao "Céng COM da déng” Term nen er ok encase sures a Coated button_Conneet_Click Hop thoai thong bao "Céng COM 43 me" ‘Mé céng COM duge chen = Hop thoai théng bio "Céng COM duge chon da m6" = Xiriy 8 hoa giao dign = Xéa b6 dom nhén va gu i tigu button_Exit_Click. ‘Déng giao dién churong trinh ———T jén soan: Pham Quang Tr Term nen er ok encase sures co ir ly 48 hoa giao dign Hép thoal théng bao. "Céng COM chua doc mo" button_OFF_Click. Xt ly dé hea giao dién 5 H6p thoai théng bao. “Céng COM chua dugc mo" Xie ly dé hga giao dign Hp thoai théng bao "Céng COM chua duoc mo” —_—d Bién soan: Pham Quang Tri Term nen er ok rt eerie CS Serial_Port_DataReceived Hidn thi chudi dr igu len hep dtr ligu “Receive” 13.4.2. Ma ngudn Sau khi hoan tat viée tao cde déi tung diéu khién trong giao dién thi ta tiép tuc chuyén sang phan tao ma ngudn cho giao dién nay nhim muc dich dat duge cdc chite nang diéu khién theo yéu cdu dat ra ban dau. Dé tao ma ngudn ta nhdp phai chudt vao giao dién vita mdi tao ra va chon “View Code”, khi dé mét cira sé duge mé ra dé cho ta nhap ma nguén ciia giao dién vao. Dau tién ta viét va bé sung (néu chua duge tao sin) khai béo cac thu vién sir dung trong phan tao code cho giao dién, dic biét chi ¥ dén dong khai bao thu vién “using System.1O.Ports” vi né cho phép ta truy xuat dén cde Iénh sir dung trong viée giao tiép cng COM. Using systen; Using Systen.Collections. Generics Using Systen.Conponenttodel using Systen.Datas Using System.Drawings Using systen.tings soar ham Quang Tr ‘Communication and Control for 70 ETI) Enrne aka ean Taro ako Using System. Texts using System.Threading. Tasks; using System.Windows.Forms; using System. TO; using Syston. aly Tiép theo ta viét phan khai béo bién toan cyc can sit dung va phan ma ngudn dé Khoi déng cdc thanh phan (Component) trong chuong trinh giao dign diéu khién. Xem minh hoa trong doan ma nguén ngay bén duéi day: [* see Weiter eKerrensesHrnersenereoiassnneieereniersuiessie 4/ // Bien chua chuoi nhan ve (Receive) // Bien chua chuoi truyen di (Transmit) Ppa erreenPeTCnTErn CU UUTTETTCnNErTUTTES Tet UtrreTiterrsvcTrerterttrrrtttrrrtttteral?] 11 Khoi_dong chuong trinh. public Form_Samplecom() { ? 7) SER OO Ee ORE OH OO SERS Ea UE Hoenn ee Tiép theo ta nhdp dip vao ctra sé giao dién diéu khién dé tao ma nguén didu khién cho déi tuong nay, phan ma nguén nay sé duge chay cho méi lan ctta sé giao dign diéu khién duge mo lén (hay néi céch khac 1a khi cita sé giao dign didu khién duge kich hoat “chay”). Trong phan ma nguén nay gdm cé 2 phan (tinh tir trén xudng duéi), xem minh hga trong doan ma nguén ngay bén dudi day: Phan 1: ding dé khai bo cdu hinh mic dinh ban dau cho céng COM. © Phan 2: ding dé ty dng kiém tra cdc cong COM dang hign dang t6n tai trong may tinh dé cp nhat vao trong hép tha xuéng “COM Port”. [OSE ERO HO eH ROO HA Eo ODER mE 17 11 Xu ly khi m0 giao dien. private void Form SampleCOM_Load(object sender, EventArgs e) £ 77 Cau hank cong COM mac dinh. 7/ COM Port: ??2, Baud: 96000 / Data: 8 / Parity: @ / Stop: 1] Serial_Port.PortName = "Select COM Port Serial Port.BaudRate = 9600; Serial Port.DataBits = 8; serial port.varity = varity.None; Serial Port.StopBits = Stoplits Ones Peer nen enor a oN leer TT Doc thong tin cac cong COM co trong PC. string[] ports = SerialPort.GetPortNames(); // Them ten cua tat ca cac cong vao muc COM Port, foreach (string port in ports) { 3 comboBox_COMPort. Items .Add(port) y Tigp theo ta viét phn ma nguén ding dé truyén chudi ky ty mong muén thong qua eéng COM va hién thi chudi ky ty nay 1én hdp dit ligu “Send”. Xem minh hoa trong doan ma nguén ngay bén duéi day: [7 HHH eee noe eniieasenieieeteeiieS 47 // Chuong trinh con gui du lieu public void Send_pata(string Send_Text) { Serial_Port.wirite(Send_Text); ‘textBox_DataSend. Text = Send Text.Tostring(); // Hien thi du lieu gui ? [a sete HUES EEE eteEE een ebbedieebenieeteeesaaenie 4/ Tigp theo ta viét phan ma nguén ding dé déng ctra sé giao dign hay néi céch khdc 1a khi giao dién diéu khién durgc déng bang nut El & géc trén bén phai ctta cita sé giao dién. Xem minh hga trong doan ma nguén ngay bén dudi day: [nes Sere rere neee tere cnet eeteeeern rere tree rerreneeetn teeny] 11 Xu ly khi dong giao dien. private void Form SamplecOM_FormClosed(object sender, FornClosedéventangs e) { if (Serial_Port.Is0pen) // Dong cong neu cong dang duoc no. Serial Port.Close(); // Dong cong COM da chon truoc do. d Tiép theo ta chon thé “Forml1.cs [Design]” dé quay tré vé ctra sé giao dién diéu khign. Sau dé nhdp ditp chudt vao nut “Connect” dé tao ma nguén diéu khién cho déi tugng nay. Trong phan ma nguén nay gém cé 4 phan (tinh tir trén xuéng dur , xem minh hoa trong doan ma nguén ngay bén duéi day: Phan 1: ding dé kiém tra va digu khién hién thi ctra sé canh bao néu céng COM va téc dé truyén dit ligu chua duge chon Iya trong hdp tha xuéng tuong tng “COM Port” va “Baud Rate”. ¢ Phan 2: ding dé kiém tra va didu khién hién thj ctra sé théng bdo néu céng COM chon lya da duge m6 truée dé. Pere ne nr, Computer Peripheral Devices in Taro ako Parana ens © Phan 3: ding dé kiém tra va digu khién hién thj cua sé théng bao néu céng COM chon Iva chua duge mé truée dé, digu khién mé céng COM chon lya, di mau va hién thi chit. © Phan 4: ding dé kiém tra va diéu khién hién thi cita sd thong bao 13i néu céng COM chon Iya khéng thé mé duge vi mét sé ly do nao dé (Idi céng, Ii cép,...). [7 HHH ee Een eneeasenieneeteeniteS 47 // Xa Ly khi phan nut Connect private void button_Connect_Click(object sender, EventArgs e) 77 Kien tra da chon cong COM. if (comboBox_CoMPort. Text MessageBox.Show("Select COM Port.", "Warning", MessageBoxButtons.OK, lessagefloxTcon.Warning); // Thang bao loi neu else if (comboBox_BaudRate.Text MessageBox.Show("COM Port is connected and ready for use.", Information", MessageBoxButtons.Ok, MessageBoxIcon. Information) ; Serial_Port.open(); 77 No cong COM. MessageBox. Show(comboBox_COMPort.Text +" is connected.", “Information”, MessageBoxButtons.OK, MessageBoxIcon. Information); textBox_Status.BackColor = Color.Line; 11 Hieu chinh mau va ‘thong tin textBox_Status.Text = "Connecting. .."5 comboBox_CoMPort .Enabled conboBox_BaudRate. Enabled ReceiveData = String.Empty; TransmitData = String. Empty; ‘catch (exception) 77 xa ly xuat hien loi Khong thay thiet bi t ‘textBox_Status.BackColor = Color.Red; textBox_Status.Text = "Disconnected!" MessageBox.Show("COM Port is not found. Please check your COM or Cable." error”, MessageBoxButtons.OK, NessageBoxIcon.Error); // Hieu chinh mau va thong tin ? reer CrrrenerscOLer Te eCTETeCeneTSCULTETSstTeTeTrTerertcecteetettetenttcaly] Peer nen enor Caiiema ieee) i Taro ako Paar raked eas Ké tiép ta lai tiép tue chon thé “Form1.cs [Design]” dé quay tré vé cita sé giao dign diéu khién. Sau d6 nhdp dip chudt vo nit “Disconnect” dé tao ma ngudn diéu khién cho déi tugng nay. Trong phan ma ngudn nay gdm cé 3 phan (tinh tir trén xuéng duéi), xem minh hga trong doan ma nguén ngay bén dudi day: © Phan 1: ding dé kiém tra va diéu khién hién thi ctta sé théng bao néu céng COM chon Iya di duge mé truéc d6, diéu khién dong cong COM chon lya, d6i mau va hién thi chit. © Phan 2: ding dé kiém tra va diéu khién hién thi cia sé théng bio néu céng COM chon lya chua duge mé trude dé. © Phan 3: ding dé kiém tra va diéu khién hién thi cita sé théng bao 15i néu céng COM chon Iya khéng thé déng duge vi mét sé ly do nio dé (16i cdng, 15i cép,...). /# HHH nen eerie area ioaadeeneniereiiete 47 // Xa Ly khi nhan Disconnect. private void button DisConnect_Click(object sender, EventArgs e) t try if (Serial_port.tsOpen) 7] Xa ly truong hop da ket noi 1s srtal_port.close()s textBox Status.BackColor = Color.Red; // Hiew chinh mau va thong ti textBox_Status.Text = "Disconnected! "s MessageBox. Show("COM Port is disconnected.", "Information", jessageBoxButtons.OK, MessageBoxIcon. Information) ; onboBox_CONPort. Enabled Thus ket-nor MessageBox. Show("COM Port have been disconnected. Please reconnect to Ise.", "Information", MessageBoxButtons .0K, MessageBoxIcon. Information) ; y Lf Xe ly khi_xuat_hien Loi, MessageBox.Show("Disconnection appears error. Unable to disconnect.", Perron”, MessageBoxButtons.OK, MessageBoxIcon. Error); ree err enerSTOTLRTSETUCETTSTUTETSSTLRTSSTTUTETSTUTESSCCTLESTSTTUTTETTCaEy] Peer nen enor Caiiema ieee) 74

You might also like