Rev 50 | Rev 63 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
60 | hbuss | 1 | /*####################################################################################### |
2 | Flight Control |
||
3 | #######################################################################################*/ |
||
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
5 | // + Regler für Brushless-Motoren |
||
6 | // + ATMEGA8 mit 8MHz |
||
7 | // + Nur für den privaten Gebrauch |
||
8 | // + Copyright (c) 12.2007 Holger Buss |
||
9 | // + www.MikroKopter.com |
||
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
11 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
||
12 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
||
13 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
||
14 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
15 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
||
16 | // + Verkauf von Luftbildaufnahmen, usw. |
||
17 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
18 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
||
19 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
||
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
21 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
22 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
23 | // + eindeutig als Ursprung verlinkt werden |
||
24 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
25 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
26 | // + Benutzung auf eigene Gefahr |
||
27 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
28 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
29 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
30 | // + mit unserer Zustimmung zulässig |
||
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
32 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
33 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
34 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
||
35 | // + this list of conditions and the following disclaimer. |
||
36 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
37 | // + from this software without specific prior written permission. |
||
38 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
||
39 | // + for non-commercial use (directly or indirectly) |
||
40 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
||
41 | // + with our written permission |
||
42 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
||
43 | // + clearly linked as origin |
||
44 | // + * porting to systems other than hardware from www.mikrokopter.de is not allowed |
||
45 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
46 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
47 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
48 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
49 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
50 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
51 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
52 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
53 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
54 | // + POSSIBILITY OF SUCH DAMAGE. |
||
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1 | ingob | 56 | #include "main.h" |
57 | |||
58 | volatile unsigned char Phase = 0,ShadowTCCR1A = 0; |
||
59 | volatile unsigned char CompFreigabeTimer = 100; |
||
60 | volatile unsigned char CompInterruptFreigabe = 0; |
||
61 | |||
62 | |||
63 | //############################################################################ |
||
64 | // |
||
65 | SIGNAL(SIG_OVERFLOW2) |
||
66 | //############################################################################ |
||
67 | { |
||
68 | } |
||
69 | |||
70 | //############################################################################ |
||
71 | // + Interruptroutine |
||
72 | // + Wird durch den Analogkomperator ausgelöst |
||
73 | // + Dadurch wird das Kommutieren erzeugt |
||
74 | SIGNAL(SIG_COMPARATOR) |
||
75 | //############################################################################ |
||
76 | { |
||
77 | unsigned char sense = 0; |
||
78 | do |
||
79 | { |
||
80 | if(SENSE_H) sense = 1; else sense = 0; |
||
81 | switch(Phase) |
||
82 | { |
||
83 | case 0: |
||
84 | STEUER_A_H; |
||
85 | if(sense) |
||
86 | { |
||
87 | STEUER_C_L; |
||
50 | holgerb | 88 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 89 | TCNT2 = 1; |
90 | if(ZeitZumAdWandeln) AdConvert(); |
||
91 | SENSE_FALLING_INT; |
||
92 | SENSE_B; |
||
93 | Phase++; |
||
94 | CntKommutierungen++; |
||
95 | } |
||
96 | else |
||
97 | { |
||
98 | STEUER_B_L; |
||
99 | } |
||
100 | break; |
||
101 | case 1: |
||
102 | STEUER_C_L; |
||
103 | if(!sense) |
||
104 | { |
||
105 | STEUER_B_H; |
||
50 | holgerb | 106 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 107 | TCNT2 = 1; |
108 | if(ZeitZumAdWandeln) AdConvert(); |
||
109 | SENSE_A; |
||
110 | SENSE_RISING_INT; |
||
111 | Phase++; |
||
112 | CntKommutierungen++; |
||
113 | } |
||
114 | else |
||
115 | { |
||
116 | STEUER_A_H; |
||
117 | } |
||
118 | |||
119 | break; |
||
120 | case 2: |
||
121 | STEUER_B_H; |
||
122 | if(sense) |
||
123 | { |
||
124 | STEUER_A_L; |
||
50 | holgerb | 125 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 126 | TCNT2 = 1; |
127 | if(ZeitZumAdWandeln) AdConvert(); |
||
128 | SENSE_C; |
||
129 | SENSE_FALLING_INT; |
||
130 | Phase++; |
||
131 | CntKommutierungen++; |
||
132 | } |
||
133 | else |
||
134 | { |
||
135 | STEUER_C_L; |
||
136 | } |
||
137 | |||
138 | break; |
||
139 | case 3: |
||
140 | STEUER_A_L; |
||
141 | if(!sense) |
||
142 | { |
||
143 | STEUER_C_H; |
||
50 | holgerb | 144 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 145 | TCNT2 = 1; |
146 | if(ZeitZumAdWandeln) AdConvert(); |
||
147 | SENSE_B; |
||
148 | SENSE_RISING_INT; |
||
149 | Phase++; |
||
150 | CntKommutierungen++; |
||
151 | } |
||
152 | else |
||
153 | { |
||
154 | STEUER_B_H; |
||
155 | } |
||
156 | |||
157 | |||
158 | break; |
||
159 | case 4: |
||
160 | STEUER_C_H; |
||
161 | if(sense) |
||
162 | { |
||
163 | STEUER_B_L; |
||
50 | holgerb | 164 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 165 | TCNT2 = 1; |
166 | if(ZeitZumAdWandeln) AdConvert(); |
||
167 | SENSE_A; |
||
168 | SENSE_FALLING_INT; |
||
169 | Phase++; |
||
170 | CntKommutierungen++; |
||
171 | } |
||
172 | else |
||
173 | { |
||
174 | STEUER_A_L; |
||
175 | } |
||
176 | |||
177 | break; |
||
178 | case 5: |
||
179 | STEUER_B_L; |
||
180 | if(!sense) |
||
181 | { |
||
182 | STEUER_A_H; |
||
50 | holgerb | 183 | if(!PPM_Betrieb) TCNT1 = 1; |
1 | ingob | 184 | TCNT2 = 1; |
185 | if(ZeitZumAdWandeln) AdConvert(); |
||
186 | SENSE_C; |
||
187 | SENSE_RISING_INT; |
||
188 | Phase = 0; |
||
189 | CntKommutierungen++; |
||
190 | } |
||
191 | else |
||
192 | { |
||
193 | STEUER_C_H; |
||
194 | } |
||
195 | break; |
||
196 | } |
||
197 | } |
||
198 | while((SENSE_L && sense) || (SENSE_H && !sense)); |
||
199 | ZeitZumAdWandeln = 0; |
||
200 | } |
||
201 | |||
202 | //############################################################################ |
||
203 | // |
||
204 | void Manuell(void) |
||
205 | //############################################################################ |
||
206 | { |
||
207 | switch(Phase) |
||
208 | { |
||
209 | case 0: |
||
210 | STEUER_A_H; |
||
211 | STEUER_B_L; |
||
212 | SENSE_C; |
||
213 | SENSE_RISING_INT; |
||
214 | break; |
||
215 | case 1: |
||
216 | STEUER_A_H; |
||
217 | STEUER_C_L; |
||
218 | SENSE_B; |
||
219 | SENSE_FALLING_INT; |
||
220 | break; |
||
221 | case 2: |
||
222 | STEUER_B_H; |
||
223 | STEUER_C_L; |
||
224 | SENSE_A; |
||
225 | SENSE_RISING_INT; |
||
226 | break; |
||
227 | case 3: |
||
228 | STEUER_B_H; |
||
229 | STEUER_A_L; |
||
230 | SENSE_C; |
||
231 | SENSE_FALLING_INT; |
||
232 | break; |
||
233 | case 4: |
||
234 | STEUER_C_H; |
||
235 | STEUER_A_L; |
||
236 | SENSE_B; |
||
237 | SENSE_RISING_INT; |
||
238 | break; |
||
239 | case 5: |
||
240 | STEUER_C_H; |
||
241 | STEUER_B_L; |
||
242 | SENSE_A; |
||
243 | SENSE_FALLING_INT; |
||
244 | break; |
||
245 | } |
||
246 | } |
||
247 |