Servo motor adalah alat electromechanical. Ia adalah sebuah motor yang mempunyai feedback loop. Oleh itu ia sebuah motor yang boleh dikawal posisi dan kelajuannya tanpa feedback kepada microcontroller. Servo motor hanya berputar dalam lingkungan sudutnya sahaja, contohnya hanya boleh berputar pada 1800.

Servo motor mempunyai tiga wayar. Kebiasaannya wayar merah adalah supply positif, wayar hitam adalah ground manakala wayar ketiga adalah signal daripada microcontroller. Wayar signal mempunyai beberapa standard warna iaitu warna putih, kuning atau oren.
Servo motor bergerak mengikut pulse signal. Signal ke servo adalah berbentuk PWM dengan frequency lebih kurang 50Hz iaitu masa bagi satu cycle adalah 20mS. Posisi armature servo motor bergantung pada duty cycle PWM tersebut. Dengan mengubah-ubah duty cycle, servo motor akan bergerak atau berputar. Dengan ini juga, kelajuannya boleh di kawal. Contoh signal untuk menggerakkan servo motor berputar mengikut arah jam atau mengikut arah lawan jam seperti diagram di bawah.

Walaubagaimanapun, untuk memprogram servo, tidak boleh menggunakan PWM Module dalam PIC kerana PWM yang diperlukan adalah frekuensi rendah. Oleh itu, PWM boleh dihasilkan menggunakan counter di dalam timer interrupt. Kemudian, hanya perlu menetapkan nilai posisi servo tersebut.
Berikut adalah skematik untuk menggerakkan servo mnggunakan input analog.

Berikut adalah videonya.
After I programmed the pic, just connect the pic to the sevo and variable resistor as shown in the schematic diagram? So the whole system just consists of a servo, pic, variable resistor and battery?
Thanks
I have update the schematic.
Hi, can I get the schematic diagram? How the pic is connected? Thanks in advance.
Leong, if use 6V from voltage regulator, it’s problem when the servo consumes high current that make the voltage regulator down. Further more, parallel 4 servo it’s need high current. So, must use direct 6V battery or use high current 5V/6V power supply.
I discover the problem y the servo motor is moving no according to the program. It is because of the current that i supplied from DC power supply. I have one problem now. It i use DC power supply i can control the current i wan. But when i use battery i cannot control the current i wan. Especially now i need to you 4 servo motor. So how i connect the servo motor to the battery? Any additional circuit to improve the current?
You can try,
Give 1ms ON 19ms OFF, repeat 20 cycle.
Then give 1.5ms ON 18.5ms OFF, repeat 20 cycle.
I writing my program in assembly code. I have make 1mS on and 19mS off pulse. I test is with oscilloscope and get the result. But when i connect to the servo motor, it suppose to rotate to 0 degree, but it rotated to 180 degree. So may i know what is the problem? What can i do?
apa kebaikan servo controller??
ferus, variable resistor sambung pada PORTA<0> dan servo motor sambung pada PORTC<0>.
salam bos boleh berikan saya mcm mana penyambungan antara vabriable resistor dengan servo motor tu ka