?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 6

Line No. Rev Author Line
1 6 kaklik /*! \file servo.h \brief Interrupt-driven RC Servo function library. */
2 //*****************************************************************************
3 //
4 // File Name : 'servo.h'
5 // Title : Interrupt-driven RC Servo function library
6 // Author : Pascal Stang - Copyright (C) 2002
7 // Created : 7/31/2002
8 // Revised : 8/02/2002
9 // Version : 1.0
10 // Target MCU : Atmel AVR Series
11 // Editor Tabs : 4
12 //
13 /// \ingroup driver_sw
14 /// \defgroup servo Interrupt-driven RC Servo Function Library (servo.c)
15 /// \code #include "servo.h" \endcode
16 /// \par Overview
17 /// This code allows you to drive up to 8 RC servos from any
18 /// combination of ports and pins on the AVR processor. Using interrupts,
19 /// this code continuously sends control signals to the servo to maintain
20 /// position even while your code is doing other work.
21 ///
22 /// The servoInit and servoOff effectively turn on and turn off servo
23 /// control. When you run ServoInit, it automatically assigns each
24 /// "channel" of servo control to be output on the SERVO_DEFAULT_PORT.
25 /// One "channel" of servo control can control one servo and must be
26 /// assigned single I/O pin for output.
27 ///
28 /// If you're using all eight channels (SERVO_NUM_CHANNELS = 8), then
29 /// then by default the code will use SERVO_DEFAULT_PORT pins 0-7.
30 /// If you're only using four channels, then pins 0-3 will be used by
31 /// default.
32 ///
33 /// The command servoSetChannelIO(channel, port, pin) allows you to
34 /// reassign the output of any channel to any port and I/O pin you
35 /// choose. For exampe, if you have an RC servo connected to PORTC, pin 6,
36 /// and you wish to use channel 2 to control it, use:
37 ///
38 /// servoSerChannelIO( 2, _SFR_IO_ADDR(PORTC), 6)
39 ///
40 /// (NOTE: you must include the "_SRF_IO_ADDR()" part around your port)
41 ///
42 /// The servoSetPostion and servoGetPosition commands allow you to command
43 /// a given servo to your desired position. The position you request must
44 /// lie between the SERVO_MIN and SERVO_MAX limit you defined.
45 ///
46 /// \WARNING: This servo library has been tested to work without issue on
47 /// several different AVR processors and with several different brands/kinds
48 /// of servos. However:
49 /// - Proper output duty cylces are dependent upon a user calibation and
50 /// configuration.
51 /// - IF YOUR SERVOS ARE EXCEPTIONALLY POWERFUL, AN ERRONEOUS OUTPUT DUTY
52 /// CYCLE GENERATED FROM THIS CODE OR ANY OTHER SOURCE CAN DAMAGE YOUR
53 /// SERVO'S INTERNAL DRIVER CHIP OR ITS GEARS!
54 /// - I have never experienced any servo damage from erroneous control signal
55 /// input, but it is possible.
56 //
57 // This code is distributed under the GNU Public License
58 // which can be found at http://www.gnu.org/licenses/gpl.txt
59 //
60 //*****************************************************************************
61  
62 #ifndef SERVO_H
63 #define SERVO_H
64  
65 #include "global.h"
66 #include "timer.h"
67  
68 // include configuration
69 #include "servoconf.h"
70  
71 typedef struct struct_ServoChannel
72 {
73 // hardware I/O port and pin for this channel
74 u08 port;
75 u08 pin;
76 // PWM duty setting which corresponds to servo position
77 u16 duty;
78 } ServoChannelType;
79  
80 // functions
81  
82 // initializes servo system
83 // You must run this to begin servo control
84 void servoInit(void);
85  
86 // turns off servo system
87 // This stops controlling the servos and
88 // returns control of the SERVOPORT to your code
89 void servoOff(void);
90  
91 // set the port and I/O pin you wish to use for a given channel
92 // If you do not assign a port and I/O pin for a channel (ie. you don't
93 // use this command) then all output will be done through the
94 // SERVO_DEFAULT_PORT. See above definition of SERVO_DEFAULT_PORT.
95 void servoSetChannelIO(u08 channel, u08 port, u08 pin);
96  
97 // set and get servo position on a given channel
98 // servoSetPosition() commands the servo on <channel> to the position you
99 // desire. The position input must lie between 0 and POSITION_MAX and
100 // will be automatically scaled to raw positions between SERVO_MIN and
101 // SERVO_MAX
102 // servoGetPosition() returns the most recently set postition of the
103 // servo on <channel>. The return value will be scaled 0->POSITION_MAX
104 void servoSetPosition(u08 channel, u08 position);
105 u08 servoGetPosition(u08 channel);
106  
107 // set and get raw servo position on a given channel
108 // Works like non-raw commands but position is not scaled. Position must
109 // be between SERVO_MIN and SERVO_MAX
110 void servoSetPositionRaw(u08 channel, u16 position);
111 u16 servoGetPositionRaw(u08 channel);
112  
113 // servo interrupt service routine
114 void servoService(void);
115  
116 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3