Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] control servo motor

2008-11-10 by David VanHorn

On Sun, Nov 9, 2008 at 6:55 PM, wiyawan <wwn_st3@yahoo.co.id> wrote:
> hello, can you help me programing AVR to control servo motor ?, i
> using atmega8535 and compiler use code vision. thx

Assuming you mean a radio-control type servo:

You'll need to output pulses of the appropriate width, for each of the
servos that you are controlling.
You can probably find out the appropriate widths on google for the
specific models (they do vary somewhat), but a 1mS pulse is a good
starting point.

The period between the pulses can be varied, shorter means more
accurate control.

What I've done in the past, is to store an array of bytes in ram with
0-255 values in each, and in the T0 ISR, load the appropriate byte,
calculate the proper timer value for T1, and load the timer value to
T1, and bring the proper output pin high.  When the T1 ISR fires, I
bring all the servo pins low. (easier than figuring out which one)

The T0 timer can be set to 1mS ints, and used for many different
timing functions.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.