Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Interrupt-driven RC Servo Function Library (servo.c)
[Drivers (software-based)]

 #include "servo.h" 
Overview
This code allows you to drive up to 8 RC servos from any combination of ports and pins on the AVR processor. Using interrupts, this code continuously sends control signals to the servo to maintain position even while your code is doing other work.
The servoInit and servoOff effectively turn on and turn off servo control. When you run ServoInit, it automatically assigns each "channel" of servo control to be output on the SERVO_DEFAULT_PORT. One "channel" of servo control can control one servo and must be assigned single I/O pin for output.

If you're using all eight channels (SERVO_NUM_CHANNELS = 8), then then by default the code will use SERVO_DEFAULT_PORT pins 0-7. If you're only using four channels, then pins 0-3 will be used by default.

The command servoSetChannelIO(channel, port, pin) allows you to reassign the output of any channel to any port and I/O pin you choose. For exampe, if you have an RC servo connected to PORTC, pin 6, and you wish to use channel 2 to control it, use:

servoSerChannelIO( 2, _SFR_IO_ADDR(PORTC), 6)

(NOTE: you must include the "_SRF_IO_ADDR()" part around your port)

The servoSetPostion and servoGetPosition commands allow you to command a given servo to your desired position. The position you request must lie between the SERVO_MIN and SERVO_MAX limit you defined.

: This servo library has been tested to work without issue on several different AVR processors and with several different brands/kinds of servos. However:


Generated on Sun Oct 29 03:41:09 2006 for Procyon AVRlib by  doxygen 1.4.2