Subversion Repositories BL-Ctrl

Rev

Rev 60 | Rev 64 | 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;
88
              if(ZeitZumAdWandeln) AdConvert();
89
              SENSE_FALLING_INT;
90
              SENSE_B;
91
              Phase++;
92
              CntKommutierungen++;
93
             }
94
                         else
95
             {
96
              STEUER_B_L;
97
             }
98
          break;
99
   case 1:  
100
               STEUER_C_L;
101
           if(!sense)
102
            {
103
              STEUER_B_H;
104
              if(ZeitZumAdWandeln) AdConvert();
105
              SENSE_A;
106
              SENSE_RISING_INT;
107
              Phase++;
108
              CntKommutierungen++;
109
             }
110
             else
111
             {
112
               STEUER_A_H;
113
             }
114
 
115
          break;
116
   case 2:  
117
           STEUER_B_H;
118
           if(sense)
119
            {
120
                      STEUER_A_L;
121
              if(ZeitZumAdWandeln) AdConvert();
122
              SENSE_C;
123
              SENSE_FALLING_INT;
124
              Phase++;
125
              CntKommutierungen++;
126
             }
127
             else
128
             {
129
              STEUER_C_L;
130
             }
131
 
132
          break;
133
   case 3:  
134
           STEUER_A_L;
135
           if(!sense)
136
            {
137
                      STEUER_C_H;
138
              if(ZeitZumAdWandeln) AdConvert();
139
              SENSE_B;
140
              SENSE_RISING_INT;
141
              Phase++;
142
              CntKommutierungen++;
143
             }
144
             else
145
             {
146
              STEUER_B_H;
147
             }
148
 
149
 
150
          break;
151
   case 4:  
152
           STEUER_C_H;
153
           if(sense)
154
            {
155
                      STEUER_B_L;
156
              if(ZeitZumAdWandeln) AdConvert();
157
              SENSE_A;                     
158
              SENSE_FALLING_INT;
159
              Phase++;
160
              CntKommutierungen++;
161
             }
162
                     else
163
             {
164
              STEUER_A_L;
165
             }
166
 
167
          break;
168
   case 5:  
169
              STEUER_B_L;
170
           if(!sense)
171
            {
172
                      STEUER_A_H;
173
              if(ZeitZumAdWandeln) AdConvert();
174
              SENSE_C;
175
              SENSE_RISING_INT;
176
              Phase = 0;
177
              CntKommutierungen++;
178
             }
179
             else
180
             {
181
              STEUER_C_H;
182
             }
183
          break;
184
  }
185
}
186
 while((SENSE_L && sense) || (SENSE_H && !sense));
187
 ZeitZumAdWandeln = 0;
188
}
189
 
190
//############################################################################
191
//
192
void Manuell(void)
193
//############################################################################
194
{
195
 switch(Phase)
196
  {
197
   case 0:  
198
           STEUER_A_H;
199
                   STEUER_B_L;
200
           SENSE_C;
201
           SENSE_RISING_INT;
202
          break;
203
   case 1:  
204
           STEUER_A_H;
205
                   STEUER_C_L;
206
           SENSE_B;
207
           SENSE_FALLING_INT;
208
          break;
209
   case 2:  
210
           STEUER_B_H;
211
                   STEUER_C_L;
212
           SENSE_A;
213
           SENSE_RISING_INT;
214
          break;
215
   case 3:  
216
           STEUER_B_H;
217
                   STEUER_A_L;
218
           SENSE_C;
219
           SENSE_FALLING_INT;
220
          break;
221
   case 4:  
222
           STEUER_C_H;
223
                   STEUER_A_L;
224
           SENSE_B;
225
           SENSE_RISING_INT;
226
          break;
227
   case 5:  
228
           STEUER_C_H;
229
                   STEUER_B_L;
230
           SENSE_A;
231
           SENSE_FALLING_INT;
232
          break;
233
  }
234
}
235