root/RF_BT_Tail/Servos.h

Revision 244, 1.8 kB (checked in by phil, 4 years ago)

added initial Tail Source Package

Line 
1 // File: Servos.h
2 //------------------------------------------------------------------------------
3 // Author: Giovanni de Sanctis
4 // Email: info@lateral-technologies.com
5 //------------------------------------------------------------------------------
6 // Date: Dec 2018
7 // Controls the 2 servos
8 //------------------------------------------------------------------------------
9
10 #ifndef SERVOS_H
11 #define SERVOS_H
12
13 #include <stdint.h>
14
15 #define K                       2
16 //#define P0                    (K*500)
17 //#define P1                    (K*850)
18 //#define P2                    (K*1050)
19 //#define P3                    (K*1350)
20 //#define P4                    (K*1500)
21 //#define P5                    (K*1750)
22 //#define P6                    (K*2050)
23 //#define P7                    (K*2200)
24 //#define P9                    (K*2500)
25
26 #define PL              0x0F                //Last position, don't update
27 #define P0              0 //(K*500)         //    0 degrees
28 #define P1              1 //(K*750)         // 22.5 degrees
29 #define P2              2 //(K*1000)        // 45.0 degrees
30 #define P3              3 //(K*1250)        // 67.5 degrees
31 #define P4              4 //(K*1500)        // 90.0 degrees
32 #define P5              5 //(K*1750)        //112.5 degrees
33 #define P6              6 //(K*2000)        //135 0 degrees
34 #define P7              7 //(K*2250)        //157.5 degrees
35 #define P8              8 //(K*2500)        //180.0 degrees
36
37 #define SERVO1_HOME     P8
38 #define SERVO2_HOME     P0
39 #define POS2SERVO(x) (int16_t)(((int16_t)K*550)+(int16_t)x*K*240)
40
41 #define T_PWM_SERVO 20
42 #define F_SERVO     50u                     //1/T_PwM_SERVO = 1/20ms = 50 Hz
43
44 //Initialise servos
45 void initServos();
46 //Powers the servos
47 void startServos();
48 //Turns off power to the servos
49 void stopServos();
50 //Return >0 if servo power is on
51 uint8_t isServoOn();
52
53 //Set servo to position pos (K*500 to K*2500)
54 void setServo1(int16_t pos);
55 void setServo2(int16_t pos);
56
57 #endif  /* SERVOS_H */
58
Note: See TracBrowser for help on using the browser.