Program 57 :DC motor kontrol programi (DC motoru çalistirma ve durdurma)
Sekil 10.1’de PIC16F84 ile DC motor kontrolü yapilmaktadir. Devrede butonlar PIC16F84’ün A portunun 0. ve 1. bitlerine bagliyken, DC motor B portunun 0. bitine baglidir.
Program57, PIC16F84’ün A portunun 0. bitine bagli butona basildiginda motoru döndürürken, 1. bitine bagli butona basildiginda durdurur.Programin (1) numarali komut satirinda 5 bitlik TRISA içeriginin tamami “1” yapilarak buton kontrolü için PORTA’nin giris olmasi saglanmistir.
(2) numarali komut satirinda 8 bitlik TRISB’nin tüm bitleri “0” yapilarak motor kontrolü için PORTB’nin çikis olmasi saglanmistir.(3) numarali komut satirinda PORTB içerigi sifirlanarak, bu register içerisinde önceden kalabilecek datalar silinmistir.
(4) numarali komut satirina (7) numarali komut satirindan yönlendirme yapabilmek için sürekli buton kontrolü amaciyla MOTOR_KONTROL etiketi atanmistir.
(5) numarali komut satirinda PORTA’nin 0. bitine bagli butona basilip basilmadigi test edilmektedir. Bu komut satirinda Eger (IF) PORTA’nin 0.bit degeri “0” ise, o zaman (THEN) PORTB’nin 0. bitini HIGH “1” yap denmektedir.
Bu komut satirinda belirtildigi gibi RA0 butonuna basilir ise program, THEN komutundan sonra gelen HIGH PORTB.0 komutunu isleterek PORTB’nin 0. bitini “1” yapar. Bu durum B portunun 0. bit çikisinin +5V olmasi anlamina gelir ve motor çalismaya baslar.
(6) numarali komut satiri çalisan motoru durdurur. Bu komut satirinda PORTA’nin 1. bitinin “0” olup olmadigi diger bir ifadeyle butona basilip basilmadigi sorgulanmaktadir. Eger butona basilmis ise program, THEN komutundan sonra gelen LOW PORTB.0 komutunu isleterek PORTB’nin 0. bitini “0” yapar. Bu durum B portunun 0. bit çikisinin sase potansiyeli almasi anlamina gelir ve motor durur.
(7) numarali komut satiri ile buton durumlarina göre motoru çalistirmak veya durdurmak amaciyla GOTO komutu ile MOTOR_KONTROL etiketli (4) numarali komut satirina dönülür.
Program 61 : Step motoru tek fazli süren program
Program61 PIC16F84’e yüklenip, Sekil 10.12’de görülen devre ile çalistirildiginda PIC16F84’ün A portunun 0. bitine bagli butona basildiginda PORTB’nin ilk dört bitine bagli step motor bobinlerine sirayla palsler uygulanir ve step motor saat yönünde hareket eder.
Sekil 10.12’de PIC16F84’ün B portunun ilk dört bit’i step motorun bobinlerine sirasi ile A1 bobini PORTB0, B1 bobini PORTB1, A2 bobini PORTB2 ve B2 bobini PORTB3 seklinde baglanmistir. Bu baglanti türünde yer alan bobin siralamasina uyulmaz ise step motor düzgün çalismaz.Program 61’de (1) numarali komut satiri ile PORTA giris, (2) numarali komut satiri ile PORTB çikis olarak tanimlanmaktadir.
(3) ve (4) numarali komut satirlari ile PORTA ve PORTB içerikleri silinmektedir.
(5), (6) ve (7) numarali komut satirlari A portunun 0. bitine bagli butona basilip basilmadiginin sürekli test edildigi bölümdür. RA0 butonuna basildiginda PORTA’nin 0. biti sase potansiyeli alarak “0” olur ve program THEN komutundan sonra belirtilen (8) numarali MOTOR_KONTROL etiketine dallanir.
Butona basilmaz ise (7) numarali komut satiri isletilerek sürekli buton kontrolü için butona basilana kadar program (5) numarali komut satirina döner.
(9)-(16) numarali komut satirlari arasinda motorun saat yönünde dönmesi amaciyla, Tablo 10.1’de belirtilen siralamaya uygun palsler step motor bobinlerine PORTB’nin RB0, RB1, RB2 ve RB3 bitlerinden uygulanir. Her bir pals bobinlere 100msn’lik aralikla uygulanmaktadir.
Program, (9) numarali komut satirini isletip (10) numarali komut satiri ile 100msn bekledikten sonra (11) numarali komut satirini isletir. Bu durumda step motor saat yönünde 1 adim atmis olur. (15) ve(16) numarali komut satirlarinin ardindan step motor 4. adimi atarak, (17) numarali komut satiri ile MOTOR_KONTROL etiketli (8) numarali komut satirina döner. Ayni islemler devam ederek step motor 5. adimdan itibaren devam eder.
Hiç yorum yok:
Yorum Gönder