Rev 1378 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1378 | Rev 1550 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | // + see the File "License.txt" for further Informations |
9 | // + see the File "License.txt" for further Informations |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | #include "rc.h" |
12 | #include "rc.h" |
13 | #include "main.h" |
- | |
Line -... | Line 13... | ||
- | 13 | #include "main.h" |
|
14 | //#define ACT_S3D_SUMMENSIGNAL |
14 | |
15 | 15 | ||
16 | volatile int PPM_in[11]; |
16 | volatile int PPM_in[26]; |
17 | volatile int PPM_diff[11]; // das diffenzierte Stick-Signal |
17 | volatile int PPM_diff[26]; // das diffenzierte Stick-Signal |
Line 18... | Line 18... | ||
18 | volatile char Channels,tmpChannels = 0; |
18 | volatile char Channels,tmpChannels = 0; |
19 | volatile unsigned char NewPpmData = 1; |
19 | volatile unsigned char NewPpmData = 1; |
20 | 20 | ||
21 | //############################################################################ |
21 | //############################################################################ |
22 | //zum decodieren des PPM-Signals wird Timer1 mit seiner Input |
22 | //zum decodieren des PPM-Signals wird Timer1 mit seiner Input |
23 | //Capture Funktion benutzt: |
23 | //Capture Funktion benutzt: |
24 | void rc_sum_init (void) |
24 | void rc_sum_init (void) |
25 | //############################################################################ |
25 | //############################################################################ |
26 | { |
26 | { |
27 | #ifndef ACT_S3D_SUMMENSIGNAL |
- | |
28 | TCCR1B=(1<<CS11)|(1<<CS10)|(1<<ICES1)|(1<<ICNC1);//|(1 << WGM12); //timer1 prescale 64 |
27 | unsigned char i; |
29 | #else |
28 | for(i=0;i<26;i++) |
- | 29 | { |
|
- | 30 | PPM_in[i] = 0; |
|
30 | TCCR1B=(1<<CS11)|(0<<CS10)|(1<<ICES1)|(1<<ICNC1); //timer1 prescale 64 |
31 | PPM_diff[i] = 0; |
31 | #endif |
32 | } |
32 | TIMSK1 |= _BV(ICIE1); |
33 | |
33 | AdNeutralGier = 0; |
34 | AdNeutralGier = 0; |
34 | AdNeutralRoll = 0; |
35 | AdNeutralRoll = 0; |
Line 57... | Line 58... | ||
57 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
58 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
58 | index = 1; |
59 | index = 1; |
59 | } |
60 | } |
60 | else |
61 | else |
61 | { |
62 | { |
62 | if(index < 10) |
63 | if(index < 13) |
63 | { |
64 | { |
64 | if((signal > 250) && (signal < 687)) |
65 | if((signal > 250) && (signal < 687)) |
65 | { |
66 | { |
66 | signal -= 466; |
67 | signal -= 466; |
67 | // Stabiles Signal |
68 | // Stabiles Signal |
Line 81... | Line 82... | ||
81 | } |
82 | } |
82 | } |
83 | } |
83 | else |
84 | else |
84 | { |
85 | { |
85 | static unsigned int AltICR=0; |
86 | static unsigned int AltICR=0; |
86 | static int ppm_in[11]; |
87 | static int ppm_in[13]; |
87 | static int ppm_diff[11]; |
88 | static int ppm_diff[13]; |
88 | static int old_ppm_in[11]; |
89 | static int old_ppm_in[13]; |
89 | static int old_ppm_diff[11]; |
90 | static int old_ppm_diff[13]; |
90 | signed int signal = 0,tmp; |
91 | signed int signal = 0,tmp; |
91 | static unsigned char index, okay_cnt = 0; |
92 | static unsigned char index, okay_cnt = 0; |
92 | signal = (unsigned int) ICR1 - AltICR; |
93 | signal = (unsigned int) ICR1 - AltICR; |
93 | AltICR = ICR1; |
94 | AltICR = ICR1; |
94 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
95 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
Line 98... | Line 99... | ||
98 | if(tmpChannels >= 4 && Channels == tmpChannels) |
99 | if(tmpChannels >= 4 && Channels == tmpChannels) |
99 | { |
100 | { |
100 | if(okay_cnt > 10) |
101 | if(okay_cnt > 10) |
101 | { |
102 | { |
102 | NewPpmData = 0; // Null bedeutet: Neue Daten |
103 | NewPpmData = 0; // Null bedeutet: Neue Daten |
103 | for(index = 0; index < 11; index++) |
104 | for(index = 0; index < 13; index++) |
104 | { |
105 | { |
105 | if(okay_cnt > 30) |
106 | if(okay_cnt > 30) |
106 | { |
107 | { |
107 | old_ppm_in[index] = PPM_in[index]; |
108 | old_ppm_in[index] = PPM_in[index]; |
108 | old_ppm_diff[index] = PPM_diff[index]; |
109 | old_ppm_diff[index] = PPM_diff[index]; |
Line 121... | Line 122... | ||
121 | index = 1; |
122 | index = 1; |
122 | if(!MotorenEin) Channels = tmpChannels; |
123 | if(!MotorenEin) Channels = tmpChannels; |
123 | } |
124 | } |
124 | else |
125 | else |
125 | { |
126 | { |
126 | if(index < 10) |
127 | if(index < 13) |
127 | { |
128 | { |
128 | if((signal > 250) && (signal < 687)) |
129 | if((signal > 250) && (signal < 687)) |
129 | { |
130 | { |
130 | signal -= 466; |
131 | signal -= 466; |
131 | // Stabiles Signal |
132 | // Stabiles Signal |
Line 153... | Line 154... | ||
153 | if(index == 20) |
154 | if(index == 20) |
154 | { |
155 | { |
155 | unsigned char i; |
156 | unsigned char i; |
156 | ROT_ON; |
157 | ROT_ON; |
157 | index = 30; |
158 | index = 30; |
158 | for(i=0;i<11;i++) // restore from older data |
159 | for(i=0;i<13;i++) // restore from older data |
159 | { |
160 | { |
160 | PPM_in[i] = old_ppm_in[i]; |
161 | PPM_in[i] = old_ppm_in[i]; |
161 | PPM_diff[i] = 0; |
162 | PPM_diff[i] = 0; |
162 | // okay_cnt /= 2; |
163 | // okay_cnt /= 2; |
163 | } |
164 | } |
Line 177... | Line 178... | ||
177 | static unsigned int AltICR=0; |
178 | static unsigned int AltICR=0; |
178 | signed int signal = 0,tmp; |
179 | signed int signal = 0,tmp; |
179 | static int index; |
180 | static int index; |
Line 180... | Line 181... | ||
180 | 181 | ||
181 | signal = (unsigned int) ICR1 - AltICR; |
182 | signal = (unsigned int) ICR1 - AltICR; |
182 | DebugOut.Analog[16] = signal; |
183 | //DebugOut.Analog[16] = signal; |
183 | signal /= 2; |
184 | signal /= 2; |
184 | AltICR = ICR1; |
185 | AltICR = ICR1; |
185 | //Syncronisationspause? |
186 | //Syncronisationspause? |
186 | if((signal > 1100*2) && (signal < 8000*2)) |
187 | if((signal > 1100*2) && (signal < 8000*2)) |
187 | { |
188 | { |
188 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
189 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
189 | index = 1; |
190 | index = 1; |
190 | } |
191 | } |
191 | else |
192 | else |
192 | { |
193 | { |
193 | if(index < 10) |
194 | if(index < 13) |
194 | { |
195 | { |
195 | if((signal > 250) && (signal < 687*2)) |
196 | if((signal > 250) && (signal < 687*2)) |
196 | { |
197 | { |
197 | signal -= 962; |
198 | signal -= 962; |