Thursday, March 10, 2011

.:Mengawal Servo Motor dengan PIC16F877A:.

Memandangkan post saya sebelum ini .:Mengawal Servo Motor:. tidak dapat membantu pelajar-pelajar yang menggunakan servo motor, jadi disini saya sertakan contoh/sampel programming dan litarnya sekali. Diharap para pelajar yang menggunakan servo motor untuk mengawal robot arm dan pelajar yang membuat projek Hexapod robot dapat menemui cahaya yang selama ini dalam kegelapan dan seterusnya membawa mereka ke jalan yang benar...hehe :)... Litar dan programming adalah seperti dibawah :



Sambungan servo motor ke PIC16F877A





Sampel programming seperti dibawah :




//Ini adalah sampel pengaturcaraan mengawal servo motor menggunakan PIC16F877A
//Cyrstal Oscilator yang digunakan adalah 20 Mhz,
//Pengaturcara : Hisyamsani bin Idris
//Tarikh : 10/3/2011
//http://robot-geek.blogspot.com


#include<htc.h>
#include<pic.h>


__CONFIG ( 0x3F32 );
#define _XTAL_FREQ 20000000
#define servo RB1

void main (void)


{
 int i;


 TRISB = 0b00000000;
 PORTB = 0b00000000;


 while (1)
 {
//untuk gerak ke kiri
for(i=0;i<50;i++)
{
servo = 1;
         __delay_ms (1);
servo = 0;
__delay_ms (19);
}


//boleh letak delay disini kalau nak bagi ada gap lama skit


//untuk gerak ke kanan
for(i=0;i<50;i++)
{
servo = 1;
         __delay_ms (2);
servo = 0;
__delay_ms (18);
}
 }
}






Hasilnya adalah seperti video di bawah :






Kalau nak bagi ada gap lama sedikit diantara pergerakan kiri dan kanan, letakkan delay pada tempat yang sepatutnya (rujuk sampel programming). hasilnya seperti video dibawah:




Kalau malas nak taip sendiri, nak kena semua bagi, so saya bagi la...programming boleh download, klik pada ikon pendrive.


Selamat mencuba!!! Good Luck!!! 
THERE'S NO MEDICINE TO CURE LAZINESS!!!!

Untuk lebih faham tentang servo motor, anda boleh rujuk post berikut :




26 comments:

  1. TQ..
    Harap2 en sani dapat post lebih byk lagi tentang servo motor...kalau boleh contoh sambungan servo motor dengan lebih detail lagi..

    Blog ni memang dapat beri banyak ilmu pengetahuan

    ReplyDelete
  2. salam..boleh tak en sani tunjukkan penggunaan dan fungsi bagi servo motor - hitec HFS-05MJ fm single conversion - Radio Control(RC)...

    harap en sani dapat bantu saya..tq.

    ReplyDelete
  3. alamak, sori byk2..skang ni saya telah dipindahkan ke jawatan pengurusan sepenuh masa, x der masa langsung nak buat hal2 electronic ni... saya x janji bila saya ada masa untuk cuba buat/ test... ape pun, gud luck

    ReplyDelete
  4. salam...saya nak mengawal stepper motor menggunakan pic 16f877a...adakah saya boleh pakai source code untuk servo seperti yang diatas??dan bagaimana cara untuk saya mengawal pergerakan stepper motor (kiri dan kanan) menggunakan switch/button???

    harap en dpt membantu saya...terima kasih

    ReplyDelete
  5. utk stepper motor, x bleh pakai coding tu, lagi satu biasanya kalau nak mudah boleh guna stepper motor driver, atau nk buat sendiri pun bleh, blh guna L298.

    ReplyDelete
  6. connection servo motor dengan PIC16F877 xsama ke dengan connection stepper motor?

    ReplyDelete
  7. servo motor biasanya got 3 pins, stepper motor pulak biasanya 5 pin.. macam servo 3 pin, 2 darinya terminal +ve & -ve, jadi, 1 lagi adalah signal (PWM) boleh saja sambung pada mana2 pin I/O di PIC, sama juga dengan stepper motor, 2 pin untuk bekalan voltan dan selebihnya adalah signal, boleh sambung pada mana2 I/O pin, yang penting adalah programmingnya...

    ReplyDelete
  8. boleh x nk kawal 1 arah ja...pastu time nk reverse motor free

    ReplyDelete
  9. Appreciate this post. Will trу it out.

    my wеb-site ... potentiometer

    ReplyDelete
  10. Howdy, There's no doubt that your site could possibly be having web browser compatibility problems. Whenever I look at your site in Safari, it looks fine however when opening in IE, it's got ѕome overlapрing іssuеs.
    I simply wantеd tο gіνe уou a quісk heaԁs up!
    Apart from that, grеat ѕite!


    Haνe a look at my weblog ... Voltage Dependent Resistor

    ReplyDelete
  11. Gгeat sіte you hаve here but I was wanting to knοw if
    you knew оf any user dіѕcussion
    foгums thаt cover the same toρics diѕcuѕѕed here?
    I'd really love to be a part of community where I can get comments from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Thanks a lot!

    Check out my web-site; resistor power

    ReplyDelete
  12. Thіѕ parаgraph is actually a nіce one
    іt hеlps new internet visitοrs, who агe wishing for blogging.



    Feel free to surf to my blog universidadcorporativaenlinea.Com

    ReplyDelete
  13. Wonderful woгκ! That is the kind of іnfo that should be ѕhared
    аcross the web. Dіsgrаce on the searсh engineѕ for now not positioning thіs publiѕh uρper!
    Come on over and tаlk over with my site . Thanks =)

    Also νisit my hοmеpage; potentiometer Definition

    ReplyDelete
  14. Salam..bagaimana pula yg modified servo motor? Potentiometer ditukatrkan kpd 2 2.2kohm resistor. adakah masih boleh dikawal?

    ReplyDelete
  15. Havе you eveг consіdeгed аbout addіng a little bit
    morе than just your аrtiсles?
    I mеan, what yοu ѕаy is vаluаble and all.
    Nevertheless іmagine іf you aԁdеԁ
    sοme great graphiсѕ or ѵideos to gіve yοuг
    posts more, "pop"! Youг content іs eхсellеnt but
    ωith imagеѕ and clipѕ, thiѕ blоg сοuld certainly be
    onе of the best in its niche. Wonderful blog!


    Rеview my blog: Georg Ohm

    ReplyDelete
  16. Hey thеre, You hаνe done аn incrediblе jοb.
    Ι will cегtаinly digg it and рersonally recommend to my fгiends.

    I am confident thеy ωill be bеnefited frοm this website.



    Feel frеe tο ѵіsіt mу
    ρage potentiometers

    ReplyDelete
  17. I constantly spent my half an hоur to rеaԁ thіs web site's articles or reviews everyday along with a cup of coffee.

    my homepage - guardianproject.Info

    ReplyDelete
  18. Wоω, wondeгful blοg lаyοut!

    How long haѵe yοu been bloggіng fог?
    you make blogging looκ eаsy. The overаll loоk οf your wеb site is
    wonԁеrful, as wеll as the content!


    Mу website ... Ohm's law

    ReplyDelete
  19. It's really a nice and useful piece of info. I am satisfied that you shared this useful information with us. Please stay us up to date like this. Thank you for sharing.

    Have a look at my blog post - wikipedia.fsw.Leidenuniv.nl:8080

    ReplyDelete
  20. Ехcеllent, what a web site іt is!
    This ωеbsite giѵes valuable facts
    to us, keep іt up.

    My homeρаge: Trimmer cermet

    ReplyDelete
  21. Wοω! At last I got а weblog from where I be caрable of truly take uѕeful data conсеrning mу ѕtudy and knowledge.


    my weblоg - Eschelongames.com

    ReplyDelete
  22. Greetіngs! I know this іѕ kind of off topic but I was wondеring
    ωhiсh blog platform are you using for this wеbsite?
    Ι'm getting fed up of Wordpress because I'vе haԁ рroblems with hаckeгs аnd
    I'm looking at options for another platform. I would be awesome if you could point me in the direction of a good platform.

    Feel free to visit my homepage :: Wiki.Bigsound.Org

    ReplyDelete
  23. Hello, i thinκ thаt і saw yоu vіsitеd my wеblog thus i came to “rеturn the favоr”.
    I'm trying to find things to improve my web site!I suppose its ok to use some of your ideas!!

    My blog: power rating

    ReplyDelete
  24. I'm really enjoying the design and layout of your website. It's a νеry eаsy on thе eyeѕ ωhich makеs it much more pleasant for
    me tο come here and visіt more oftеn.
    Diԁ you hirе out a dеνelopеr to cгeate your thеme?

    Suρerb ωork!

    Rеview mу wеb page: Wirewound resistor

    ReplyDelete
  25. kalau just satu hala je boleh ke gune yg ini ?

    ReplyDelete