Servo Control using a Microcontroller

In this tutorial, I have used Atmega8 development board and HXT900 servo. If you do not have a development board, you can either setup the entire circuit on a breadboard, or make yourself one. Refer DIY AVR development board tutorial if you are interested in making your own development board. If you are using a breadboard, just keep voltage and power requirements in mind and generate regulated input to your setup and servos.

Also refer Software requirements tutorial if you are not sure what software to use for writing and compiling code, or for uploading code into the microcontroller.

While writing this tutorial, I have used USBasp programmer and Eclipse with AVR Eclipse Plug-in installed. You can as well use any serial programmer (or other compatible programmers), AVR Studio and/or Ponyprog for development and uploading code into microcontroller.

Simple Servo Code (Using software PWM)

There are two programs written in this tutorial for controlling a servo. First one is using software PWM for generating appropriate repetitive cycles and pulses using delays. In the second program, the logic is still the same, but uses timers to generate hardware PWM.

Psuedocode:
  1. Setup hardware
  2. Bring a port pin high for 1ms-2ms
  3. Bring pin Low
  4. Wait for 15-20ms
  5. Go to step 2 and Repeat the process

...to be continued

 

 

 

Do you have anything to say?
Visit the Forum to discuss, learn and share anything related to robotics and electronics !!

rss feeds



Featured Videos




Advertisements


Recent Articles




Atmega8 Development Board


A great step-by-step tutorial on building your own Atmel AVR based Atmega8 development board. The board is ideal for beginners with detailed explanation and pictures More...

L293D Motor Driver


For robots to do work, you need to know how to control a motor. L293D is a cleverly packed IC which can control two DC motors in both directions: forwards and reverse. Here is a detailed explanation of building a board based on L293D ICMore...

Hobby Servo Tutorial


Servo Motor is a device which uses error-sensing feedback signals to determine and control the position of a motor shaft. The term "servomechanism" closely relates to servo motors..More...

Blinking LED Tutorial


This is similar to what we achieve in any "Hello World" program. However, it is not just limited to blinking LED but scratches the surface of AVR-GCC programming... More...


Kindly Donate

If this site has helped you, then kindly consider a Donation to say "Thank You!!". Donation might help us keep all this information available for free and also pay for the resources.

If that is difficult, then a simple "Hi" in the forum would still do good :)