Subversion Repositories Projects

Rev

Rev 964 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 964 Rev 967
Line -... Line 1...
-
 
1
//////////////////////////////////////
-
 
2
// LocoHead - Mathias Kreider, 2011 //
-
 
3
//                                                                      //
-
 
4
// main.c                                                       //
-
 
5
// Main, PPM and Debug functions    //          
-
 
6
//////////////////////////////////////
-
 
7
 
1
#include <avr/io.h>   
8
#include <avr/io.h>   
2
#include <math.h>
9
#include <math.h>
3
#include <stdlib.h>
10
#include <stdlib.h>
4
#include "vector.h"
11
#include "vector.h"
5
#include <util/delay.h>
12
#include <util/delay.h>
Line 67... Line 74...
67
 
74
 
68
 
75
 
69
 
76
 
Line 70... Line 77...
70
int main()
77
int main()
Line 71... Line 78...
71
{
78
{
72
        _delay_ms(500);  //delay for VCC stabilization
79
        _delay_ms(500);  //delay for VCC stabilisation
Line 127... Line 134...
127
                       
134
                       
Line 128... Line 135...
128
                        int thr_in, thr_out;           
135
                        int thr_in, thr_out;           
Line 129... Line 136...
129
               
136
               
130
                        read_data(&a_avg, &m_avg);
137
                        read_data(&a_avg, &m_avg);
131
 
138
 
132
                        //get angle - startoffset
139
                        //calculate servo pulselength from sensor data
Line 133... Line 140...
133
                        int heading_us  = thr_filter(get_us(get_heading(&a_avg, &m_avg, &p) - heading_start, HDG_MIN, HDG_MAX, HDG_US_MIN, HDG_US_MAX),&thr_in, &thr_out);
140
                        int heading_us  = thr_filter(get_us(get_heading(&a_avg, &m_avg, &p) - heading_start, HDG_MIN, HDG_MAX, HDG_US_MIN, HDG_US_MAX),&thr_in, &thr_out);