Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
964 - 1
//PPM FRAME
2
#define PPM_CHANNELS    8                       //number of channels. Depends on RC, eg. FX-30 wants 8 or 12. 
3
                                                                        //All but HDG, PIT and ROL channel will be fixed to DEFAULT_US 
4
 
5
#define PPM_FRAME               22000;          //PPM frame length in microseconds
6
#define PPM_SYNC_PW             300;            //PPM sync pulse length in microseconds. 300-400us usually
7
#define PPM_PIN                 (1<<PD4)        //OCR1B
8
#define PPM_INV                 0                       //0= normal PPM, 1= inverted PPM
9
#define DEFAULT_US              1500
10
 
11
//HEADING
12
#define HDG_MIN                 -45.0           //min. Heading angle from starting point after which hdg will be clipped
13
#define HDG_MAX                 +45.0           //max. Heading angle
14
#define HDG_US_MIN              1000            //min. Heading Servo PWM pulse width in microseconds
15
#define HDG_US_MAX              2000            //max. Heading Servo PWM pulse width in microseconds
16
#define HDG_CH                  6                       //Heading CH number
17
 
18
//PITCH
19
#define PIT_MIN                 -45.0
20
#define PIT_MAX                 +45.0
21
#define PIT_US_MIN              1000
22
#define PIT_US_MAX              2000
23
#define PIT_CH                  7
24
 
25
//ROLL
26
#define ROL_MIN                 -45.0
27
#define ROL_MAX                 +45.0
28
#define ROL_US_MIN              1000
29
#define ROL_US_MAX              2000
30
#define ROL_CH                  8
31
 
32
/*
33
 * m_max and m_min are calibration values for the maximum and minimum
34
 * measurements recorded on each magnetic axis, which can vary for each
35
 * LSM303DLH. You should replace the values below with max and min readings from
36
 * your particular device.
37
 *
38
 * To obtain the max and min values, you can use this program's
39
 * calibration mode, which is enabled by setting J1
40
*/
41
 
42
const vector p = {0, -1, 0};
43
const vector right = {1, 0, 0};
44
const vector down = {0, 0, -1};
45
vector m_max = {371, 583, 507};
46
vector m_min = {-798, -543, -471};
47
 
48
void i2c_start();  
49
 
50
void i2c_write_byte(char byte);
51
 
52
char i2c_read_byte();  
53
 
54
char i2c_read_last_byte();  
55
 
56
void i2c_stop();
57
 
58
void ppm_init(void);
59
 
60
void read_data_raw(vector *a, vector *m);
61
 
62
float IIR2(float x, float* z);
63
 
64
int thr_filter(int  x, int * x_reg, int * y_reg);
65
 
66
void read_data(vector *a, vector *m);
67
 
68
float get_heading(const vector *a, const vector *m, const vector *p);
69
 
70
float get_perpendicular(const vector *a, const vector *d, const vector *q);
71
 
72
int get_us(float angle, float deg_min, float deg_max, int pwm_min,int pwm_max);