Line No. | Rev | Author | Line |
---|---|---|---|
1 | 6 | kaklik | /*! \file servoconf.h \brief Interrupt-driven RC Servo configuration. */ |
2 | //***************************************************************************** |
||
3 | // |
||
4 | // File Name : 'servoconf.h' |
||
5 | // Title : Interrupt-driven RC Servo function library |
||
6 | // Author : Pascal Stang - Copyright (C) 2002 |
||
7 | // Created : 07/31/2002 |
||
8 | // Revised : 09/30/2002 |
||
9 | // Version : 1.0 |
||
10 | // Target MCU : Atmel AVR Series |
||
11 | // Editor Tabs : 4 |
||
12 | // |
||
13 | // NOTE: you need the latest version (3.2+) of the AVR-GCC compiler to use this |
||
14 | // function library. Download it from http://www.avrfreaks.net/AVRGCC |
||
15 | // |
||
16 | // Description : This code allows you to drive up to 8 RC servos from any |
||
17 | // combination of ports and pins on the AVR processor. Using interrupts, |
||
18 | // this code continuously sends control signals to the servo to maintain |
||
19 | // position even while your code is doing other work. |
||
20 | // |
||
21 | // The servoInit and servoOff effectively turn on and turn off servo |
||
22 | // control. When you run ServoInit, it automatically assigns each |
||
23 | // "channel" of servo control to be output on the SERVO_DEFAULT_PORT. |
||
24 | // One "channel" of servo control can control one servo and must be |
||
25 | // assigned single I/O pin for output. |
||
26 | // |
||
27 | // If you're using all eight channels (SERVO_NUM_CHANNELS = 8), then |
||
28 | // then by default the code will use SERVO_DEFAULT_PORT pins 0-7. |
||
29 | // If you're only using four channels, then pins 0-3 will be used by |
||
30 | // default. |
||
31 | // |
||
32 | // The command servoSetChannelIO(channel, port, pin) allows you to |
||
33 | // reassign the output of any channel to any port and I/O pin you |
||
34 | // choose. For exampe, if you have an RC servo connected to PORTC, pin 6, |
||
35 | // and you wish to use channel 2 to control it, use: |
||
36 | // |
||
37 | // servoSerChannelIO( 2, _SFR_IO_ADDR(PORTC), 6) |
||
38 | // |
||
39 | // (NOTE: you must include the "_SRF_IO_ADDR()" part around your port) |
||
40 | // |
||
41 | // The servoSetPostion and servoGetPosition commands allow you to command |
||
42 | // a given servo to your desired position. The position you request must |
||
43 | // lie between the SERVO_MIN and SERVO_MAX limit you defined. |
||
44 | // |
||
45 | // This code is distributed under the GNU Public License |
||
46 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
47 | // |
||
48 | //***************************************************************************** |
||
49 | |||
50 | #ifndef SERVOCONF_H |
||
51 | #define SERVOCONF_H |
||
52 | |||
53 | // set number of servo channels (1 to 8) |
||
54 | // This is the number of servos you would like to drive |
||
55 | // Each "Channel" can control one servo and by default will |
||
56 | // map directly to the port pin of the same number on the |
||
57 | // SERVO_DEFAULT_PORT. You can change this default port/pin |
||
58 | // assignment for a given channel to any port/pin you like. |
||
59 | // See the "servoSetChannelIO" function. |
||
60 | #define SERVO_NUM_CHANNELS 4 |
||
61 | // set default SERVO output port |
||
62 | // This is the AVR port which you have connected to your servos |
||
63 | // See top of file for how servo "channels" map to port pins |
||
64 | #define SERVO_DEFAULT_PORT PORTB |
||
65 | // set servo characteristics (min and max raw position) |
||
66 | // You must find these by testing using your brand/type of servos. |
||
67 | // The min/max settings will change proportional to F_CPU, the CPU |
||
68 | // clock frequency. |
||
69 | // The numbers below good for parallax servos at an F_CPU of ~8MHz. |
||
70 | //#define SERVO_MAX 71 |
||
71 | //#define SERVO_MIN 17 |
||
72 | // The numbers below good for parallax servos at an F_CPU of ~14.745MHz. |
||
73 | #define SERVO_MAX 138 |
||
74 | #define SERVO_MIN 34 |
||
75 | |||
76 | // set servo scaled range |
||
77 | // This sets the scaled position range of the servo. Allowed scaled |
||
78 | // positions are 0 -> SERVO_POSITION_MAX, and correspond to raw |
||
79 | // positions of SERVO_MIN -> SERVO_MAX. |
||
80 | #define SERVO_POSITION_MAX 255 |
||
81 | |||
82 | #endif |
Powered by WebSVN v2.8.3