Rev 2183 | Rev 2334 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2183 | Rev 2320 | ||
---|---|---|---|
1 | /*####################################################################################### |
1 | /*####################################################################################### |
2 | Decodieren eines RC Summen Signals |
2 | Decodieren eines RC Summen Signals |
3 | #######################################################################################*/ |
3 | #######################################################################################*/ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 | // + www.MikroKopter.com |
5 | // + www.MikroKopter.com |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | // + Software Nutzungsbedingungen (english version: see below) |
7 | // + Software Nutzungsbedingungen (english version: see below) |
8 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
8 | // + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
9 | // + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
9 | // + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
10 | // + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
10 | // + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
11 | // + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
11 | // + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
12 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
12 | // + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
14 | // + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
15 | // + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
15 | // + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
16 | // + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
16 | // + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
17 | // + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
17 | // + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
18 | // + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
18 | // + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
19 | // + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
19 | // + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
20 | // + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
20 | // + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
21 | // + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
21 | // + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
22 | // + des Mitverschuldens offen. |
22 | // + des Mitverschuldens offen. |
23 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
23 | // + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
24 | // + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
24 | // + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
25 | // + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
25 | // + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
26 | // + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
26 | // + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
27 | // + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
27 | // + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
28 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
28 | // + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
29 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
29 | // + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
30 | // + Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar. |
30 | // + Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar. |
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
32 | // + Software LICENSING TERMS |
32 | // + Software LICENSING TERMS |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
34 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
34 | // + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
35 | // + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware |
35 | // + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware |
36 | // + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
36 | // + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
37 | // + The Software may only be used with the Licensor's products. |
37 | // + The Software may only be used with the Licensor's products. |
38 | // + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
38 | // + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
39 | // + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
39 | // + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
40 | // + agreement shall be the property of the Licensor. |
40 | // + agreement shall be the property of the Licensor. |
41 | // + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
41 | // + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
42 | // + features that can be used to identify the program may not be altered or defaced by the customer. |
42 | // + features that can be used to identify the program may not be altered or defaced by the customer. |
43 | // + The customer shall be responsible for taking reasonable precautions |
43 | // + The customer shall be responsible for taking reasonable precautions |
44 | // + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
44 | // + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
45 | // + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
45 | // + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
46 | // + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
46 | // + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
47 | // + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
47 | // + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
48 | // + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
48 | // + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
49 | // + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
49 | // + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
50 | // + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
50 | // + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
51 | // + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
51 | // + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
52 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
52 | // + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
53 | // + #### END OF LICENSING TERMS #### |
53 | // + #### END OF LICENSING TERMS #### |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
54 | // + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | 56 | ||
57 | #include "rc.h" |
57 | #include "rc.h" |
58 | #include "main.h" |
58 | #include "main.h" |
59 | // Achtung: ACT_S3D_SUMMENSIGNAL wird in der Main.h gesetzt |
59 | // Achtung: ACT_S3D_SUMMENSIGNAL wird in der Main.h gesetzt |
60 | 60 | ||
61 | volatile int PPM_in[26]; |
61 | volatile int PPM_in[26]; |
62 | volatile int PPM_diff[26]; // das diffenzierte Stick-Signal |
62 | volatile int PPM_diff[26]; // das diffenzierte Stick-Signal |
63 | volatile char Channels,tmpChannels = 0; |
63 | volatile char Channels,tmpChannels = 0; |
64 | volatile unsigned char NewPpmData = 1; |
64 | volatile unsigned char NewPpmData = 1; |
65 | unsigned int PPM_Neutral = 466; |
65 | unsigned int PPM_Neutral = 466; |
66 | 66 | ||
67 | //############################################################################ |
67 | //############################################################################ |
68 | // Clear the values |
68 | // Clear the values |
69 | void rc_sum_init (void) |
69 | void rc_sum_init (void) |
70 | //############################################################################ |
70 | //############################################################################ |
71 | { |
71 | { |
72 | unsigned char i; |
72 | unsigned char i; |
73 | for(i=0;i<26;i++) |
73 | for(i=0;i<26;i++) |
74 | { |
74 | { |
75 | if(i < 5) PPM_in[i] = 0; else PPM_in[i] = -127; |
75 | if(i < 5) PPM_in[i] = 0; else PPM_in[i] = -127; |
76 | PPM_diff[i] = 0; |
76 | PPM_diff[i] = 0; |
77 | } |
77 | } |
78 | AdNeutralGier = 0; |
78 | AdNeutralGier = 0; |
79 | AdNeutralRoll = 0; |
79 | AdNeutralRoll = 0; |
80 | AdNeutralNick = 0; |
80 | AdNeutralNick = 0; |
81 | return; |
81 | return; |
82 | } |
82 | } |
83 | 83 | ||
84 | #ifndef ACT_S3D_SUMMENSIGNAL |
84 | #ifndef ACT_S3D_SUMMENSIGNAL |
85 | //############################################################################ |
85 | //############################################################################ |
86 | // Interrupt function for the PPM-Input |
86 | // Interrupt function for the PPM-Input |
87 | ISR(TIMER1_CAPT_vect) |
87 | ISR(TIMER1_CAPT_vect) |
88 | //############################################################################ |
88 | //############################################################################ |
89 | { |
89 | { |
- | 90 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
|
90 | if(!(EE_Parameter.ExtraConfig & CFG_SENSITIVE_RC)) |
91 | if(!(EE_Parameter.ExtraConfig & CFG_SENSITIVE_RC)) |
- | 92 | #endif |
|
91 | { |
93 | { |
92 | static unsigned int AltICR=0; |
94 | static unsigned int AltICR=0; |
93 | signed int signal = 0,tmp; |
95 | signed int signal = 0,tmp; |
94 | static int index; |
96 | static int index; |
95 | 97 | ||
96 | signal = (unsigned int) ICR1 - AltICR; |
98 | signal = (unsigned int) ICR1 - AltICR; |
97 | AltICR = ICR1; |
99 | AltICR = ICR1; |
98 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
100 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
99 | if((signal > 1100) && (signal < 8000)) |
101 | if((signal > 1100) && (signal < 8000)) |
100 | { |
102 | { |
101 | Channels = index; |
103 | Channels = index; |
102 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
104 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
103 | index = 1; |
105 | index = 1; |
104 | } |
106 | } |
105 | else |
107 | else |
106 | { |
108 | { |
107 | if(index < 13) |
109 | if(index < 13) |
108 | { |
110 | { |
109 | if((signal > 250) && (signal < 687)) |
111 | if((signal > 250) && (signal < 687)) |
110 | { |
112 | { |
111 | signal -= PPM_Neutral; |
113 | signal -= PPM_Neutral; |
112 | // Stabiles Signal |
114 | // Stabiles Signal |
113 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
115 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
114 | { |
116 | { |
115 | if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;} |
117 | if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;} |
116 | } |
118 | } |
117 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
119 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
118 | if(tmp > signal+1) tmp--; else |
120 | if(tmp > signal+1) tmp--; else |
119 | if(tmp < signal-1) tmp++; |
121 | if(tmp < signal-1) tmp++; |
120 | if(SenderOkay >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
122 | if(SenderOkay >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
121 | else PPM_diff[index] = 0; |
123 | else PPM_diff[index] = 0; |
122 | PPM_in[index] = tmp; |
124 | PPM_in[index] = tmp; |
123 | } |
125 | } |
124 | index++; |
126 | index++; |
125 | if(PlatinenVersion < 20) |
127 | if(PlatinenVersion < 20) |
126 | { |
128 | { |
127 | if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen |
129 | if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen |
128 | if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen |
130 | if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen |
129 | if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen |
131 | if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen |
130 | } |
132 | } |
131 | } |
133 | } |
132 | } |
134 | } |
133 | } |
135 | } |
- | 136 | #if (defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)) |
|
134 | else |
137 | else |
135 | { |
138 | { |
136 | static unsigned int AltICR=0; |
139 | static unsigned int AltICR=0; |
137 | static int ppm_in[13]; |
140 | static int ppm_in[13]; |
138 | static int ppm_diff[13]; |
141 | static int ppm_diff[13]; |
139 | static int old_ppm_in[13]; |
142 | static int old_ppm_in[13]; |
140 | static int old_ppm_diff[13]; |
143 | static int old_ppm_diff[13]; |
141 | signed int signal = 0,tmp; |
144 | signed int signal = 0,tmp; |
142 | static unsigned char index, okay_cnt = 0; |
145 | static unsigned char index, okay_cnt = 0; |
143 | signal = (unsigned int) ICR1 - AltICR; |
146 | signal = (unsigned int) ICR1 - AltICR; |
144 | AltICR = ICR1; |
147 | AltICR = ICR1; |
145 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
148 | //Syncronisationspause? (3.52 ms < signal < 25.6 ms) |
146 | if((signal > 1100) && (signal < 8000)) |
149 | if((signal > 1100) && (signal < 8000)) |
147 | { |
150 | { |
148 | tmpChannels = index; |
151 | tmpChannels = index; |
149 | if(tmpChannels >= 4 && Channels == tmpChannels) |
152 | if(tmpChannels >= 4 && Channels == tmpChannels) |
150 | { |
153 | { |
151 | if(okay_cnt > 10) |
154 | if(okay_cnt > 10) |
152 | { |
155 | { |
153 | NewPpmData = 0; // Null bedeutet: Neue Daten |
156 | NewPpmData = 0; // Null bedeutet: Neue Daten |
154 | for(index = 0; index < 13; index++) |
157 | for(index = 0; index < 13; index++) |
155 | { |
158 | { |
156 | if(okay_cnt > 30) |
159 | if(okay_cnt > 30) |
157 | { |
160 | { |
158 | old_ppm_in[index] = PPM_in[index]; |
161 | old_ppm_in[index] = PPM_in[index]; |
159 | old_ppm_diff[index] = PPM_diff[index]; |
162 | old_ppm_diff[index] = PPM_diff[index]; |
160 | } |
163 | } |
161 | PPM_in[index] = ppm_in[index]; |
164 | PPM_in[index] = ppm_in[index]; |
162 | PPM_diff[index] = ppm_diff[index]; |
165 | PPM_diff[index] = ppm_diff[index]; |
163 | } |
166 | } |
164 | } |
167 | } |
165 | if(okay_cnt < 255) okay_cnt++; |
168 | if(okay_cnt < 255) okay_cnt++; |
166 | } |
169 | } |
167 | else |
170 | else |
168 | { |
171 | { |
169 | if(okay_cnt > 100) okay_cnt = 10; else okay_cnt = 0; |
172 | if(okay_cnt > 100) okay_cnt = 10; else okay_cnt = 0; |
170 | ROT_ON; |
173 | ROT_ON; |
171 | } |
174 | } |
172 | index = 1; |
175 | index = 1; |
173 | if(!MotorenEin) Channels = tmpChannels; |
176 | if(!MotorenEin) Channels = tmpChannels; |
174 | } |
177 | } |
175 | else |
178 | else |
176 | { |
179 | { |
177 | if(index < 13) |
180 | if(index < 13) |
178 | { |
181 | { |
179 | if((signal > 250) && (signal < 687)) |
182 | if((signal > 250) && (signal < 687)) |
180 | { |
183 | { |
181 | signal -= PPM_Neutral; |
184 | signal -= PPM_Neutral; |
182 | // Stabiles Signal |
185 | // Stabiles Signal |
183 | if((abs(signal - ppm_in[index]) < 6)) |
186 | if((abs(signal - ppm_in[index]) < 6)) |
184 | { |
187 | { |
185 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
188 | if(EE_Parameter.FailsafeChannel == 0 || PPM_in[EE_Parameter.FailsafeChannel] < 100) // forces Failsafe if the receiver doesn't have 'signal loss' on Failsafe |
186 | { |
189 | { |
187 | if(okay_cnt > 25) SenderOkay += 10; |
190 | if(okay_cnt > 25) SenderOkay += 10; |
188 | else |
191 | else |
189 | if(okay_cnt > 10) SenderOkay += 2; |
192 | if(okay_cnt > 10) SenderOkay += 2; |
190 | if(SenderOkay > 200) SenderOkay = 200; |
193 | if(SenderOkay > 200) SenderOkay = 200; |
191 | } |
194 | } |
192 | } |
195 | } |
193 | tmp = (3 * (ppm_in[index]) + signal) / 4; |
196 | tmp = (3 * (ppm_in[index]) + signal) / 4; |
194 | if(tmp > signal+1) tmp--; else |
197 | if(tmp > signal+1) tmp--; else |
195 | if(tmp < signal-1) tmp++; |
198 | if(tmp < signal-1) tmp++; |
196 | if(SenderOkay >= 190) ppm_diff[index] = ((tmp - ppm_in[index]) / 3) * 3; |
199 | if(SenderOkay >= 190) ppm_diff[index] = ((tmp - ppm_in[index]) / 3) * 3; |
197 | else ppm_diff[index] = 0; |
200 | else ppm_diff[index] = 0; |
198 | ppm_in[index] = tmp; |
201 | ppm_in[index] = tmp; |
199 | } |
202 | } |
200 | else ROT_ON; |
203 | else ROT_ON; |
201 | if(PlatinenVersion < 20) |
204 | if(PlatinenVersion < 20) |
202 | { |
205 | { |
203 | if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen |
206 | if(index == 5) J3High; else J3Low; // Servosignal an J3 anlegen |
204 | if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen |
207 | if(index == 6) J4High; else J4Low; // Servosignal an J4 anlegen |
205 | if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen |
208 | if(index == 7) J5High; else J5Low; // Servosignal an J5 anlegen |
206 | } |
209 | } |
207 | } |
210 | } |
208 | if(index < 20) index++; |
211 | if(index < 20) index++; |
209 | else |
212 | else |
210 | if(index == 20) |
213 | if(index == 20) |
211 | { |
214 | { |
212 | unsigned char i; |
215 | unsigned char i; |
213 | ROT_ON; |
216 | ROT_ON; |
214 | index = 30; |
217 | index = 30; |
215 | for(i=0;i<13;i++) // restore from older data |
218 | for(i=0;i<13;i++) // restore from older data |
216 | { |
219 | { |
217 | PPM_in[i] = old_ppm_in[i]; |
220 | PPM_in[i] = old_ppm_in[i]; |
218 | PPM_diff[i] = 0; |
221 | PPM_diff[i] = 0; |
219 | // okay_cnt /= 2; |
222 | // okay_cnt /= 2; |
220 | } |
223 | } |
221 | } |
224 | } |
222 | } |
225 | } |
223 | } |
226 | } |
- | 227 | #endif |
|
- | 228 | ||
224 | } |
229 | } |
225 | 230 | ||
226 | #else |
231 | #else |
227 | //############################################################################ |
232 | //############################################################################ |
228 | // Interrupt function for the PPM-Input |
233 | // Interrupt function for the PPM-Input |
229 | ISR(TIMER1_CAPT_vect) |
234 | ISR(TIMER1_CAPT_vect) |
230 | //############################################################################ |
235 | //############################################################################ |
231 | 236 | ||
232 | { |
237 | { |
233 | static unsigned int AltICR=0; |
238 | static unsigned int AltICR=0; |
234 | signed int signal = 0,tmp; |
239 | signed int signal = 0,tmp; |
235 | static int index; |
240 | static int index; |
236 | 241 | ||
237 | signal = (unsigned int) ICR1 - AltICR; |
242 | signal = (unsigned int) ICR1 - AltICR; |
238 | signal /= 2; |
243 | signal /= 2; |
239 | AltICR = ICR1; |
244 | AltICR = ICR1; |
240 | //Syncronisationspause? |
245 | //Syncronisationspause? |
241 | if((signal > 1100*2) && (signal < 8000*2)) |
246 | if((signal > 1100*2) && (signal < 8000*2)) |
242 | { |
247 | { |
243 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
248 | if(index >= 4) NewPpmData = 0; // Null bedeutet: Neue Daten |
244 | index = 1; |
249 | index = 1; |
245 | } |
250 | } |
246 | else |
251 | else |
247 | { |
252 | { |
248 | if(index < 13) |
253 | if(index < 13) |
249 | { |
254 | { |
250 | if((signal > 250) && (signal < 687*2)) |
255 | if((signal > 250) && (signal < 687*2)) |
251 | { |
256 | { |
252 | signal -= 962; |
257 | signal -= 962; |
253 | // Stabiles Signal |
258 | // Stabiles Signal |
254 | if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10;} |
259 | if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10;} |
255 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
260 | tmp = (3 * (PPM_in[index]) + signal) / 4; |
256 | if(tmp > signal+1) tmp--; else |
261 | if(tmp > signal+1) tmp--; else |
257 | if(tmp < signal-1) tmp++; |
262 | if(tmp < signal-1) tmp++; |
258 | if(SenderOkay >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
263 | if(SenderOkay >= 195) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; |
259 | else PPM_diff[index] = 0; |
264 | else PPM_diff[index] = 0; |
260 | PPM_in[index] = tmp; |
265 | PPM_in[index] = tmp; |
261 | } |
266 | } |
262 | index++; |
267 | index++; |
263 | } |
268 | } |
264 | } |
269 | } |
265 | } |
270 | } |
266 | #endif |
271 | #endif |
267 | 272 | ||
268 | 273 | ||
269 | 274 | ||
270 | 275 |