Rev 1166 | Rev 1224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1166 | Rev 1171 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | volatile unsigned int CountMilliseconds = 0; |
3 | volatile unsigned int CountMilliseconds = 0; |
4 | volatile static unsigned int tim_main; |
4 | volatile static unsigned int tim_main; |
5 | volatile unsigned char UpdateMotor = 0; |
5 | volatile unsigned char UpdateMotor = 0; |
6 | volatile unsigned int cntKompass = 0; |
6 | volatile unsigned int cntKompass = 0; |
7 | volatile unsigned int beeptime = 0; |
7 | volatile unsigned int beeptime = 0; |
8 | volatile unsigned char SendSPI = 0; |
8 | volatile unsigned char SendSPI = 0, ServoActive = 0; |
9 | volatile unsigned int ServoState = 40; |
- | |
Line 10... | Line 9... | ||
10 | 9 | ||
11 | unsigned int BeepMuster = 0xffff; |
10 | unsigned int BeepMuster = 0xffff; |
Line 12... | Line 11... | ||
12 | int ServoValue = 0; |
11 | int ServoValue = 0; |
13 | 12 | ||
Line 14... | Line -... | ||
14 | volatile int16_t ServoNickValue = 0; |
- | |
15 | volatile int16_t ServoRollValue = 0; |
- | |
16 | - | ||
Line 17... | Line 13... | ||
17 | #define HEF4017R_ON PORTC |= (1<<PORTC6) |
13 | volatile int16_t ServoNickValue = 0; |
18 | #define HEF4017R_OFF PORTC &= ~(1<<PORTC6) |
14 | volatile int16_t ServoRollValue = 0; |
19 | 15 | ||
20 | 16 | ||
Line 141... | Line 137... | ||
141 | // set PD7 as output of the PWM for nick servo |
137 | // set PD7 as output of the PWM for nick servo |
142 | DDRD |= (1<<DDD7); |
138 | DDRD |= (1<<DDD7); |
143 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
139 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
Line 144... | Line 140... | ||
144 | 140 | ||
145 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
141 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
146 | PORTC &= ~(1<<PORTC6); // set PC6 to low |
- | |
147 | 142 | HEF4017R_ON; |
|
Line 148... | Line 143... | ||
148 | // Timer/Counter 2 Control Register A |
143 | // Timer/Counter 2 Control Register A |
149 | 144 | ||
150 | // Timer Mode is FastPWM with timer reload at OCR2A (Bits: WGM22 = 1, WGM21 = 1, WGM20 = 1) |
145 | // Timer Mode is FastPWM with timer reload at OCR2A (Bits: WGM22 = 1, WGM21 = 1, WGM20 = 1) |
Line 207... | Line 202... | ||
207 | // resolution: 1500 - 375 = 1125 steps |
202 | // resolution: 1500 - 375 = 1125 steps |
Line 208... | Line 203... | ||
208 | 203 | ||
209 | #define IRS_RUNTIME 127 |
204 | #define IRS_RUNTIME 127 |
210 | #define PPM_STOPPULSE 188 |
205 | #define PPM_STOPPULSE 188 |
211 | // #define PPM_FRAMELEN (14063 |
206 | // #define PPM_FRAMELEN (14063 |
212 | #define PPM_FRAMELEN (1757 * EE_Parameter.ServoNickRefresh) |
207 | #define PPM_FRAMELEN (1757 * EE_Parameter.ServoNickRefresh) |
213 | #define MINSERVOPULSE 375 |
208 | #define MINSERVOPULSE 375 |
214 | #define MAXSERVOPULSE 1500 |
209 | #define MAXSERVOPULSE 1500 |
Line 215... | Line 210... | ||
215 | #define SERVORANGE (MAXSERVOPULSE - MINSERVOPULSE) |
210 | #define SERVORANGE (MAXSERVOPULSE - MINSERVOPULSE) |
Line 220... | Line 215... | ||
220 | static uint8_t ServoIndex = 0; |
215 | static uint8_t ServoIndex = 0; |
Line 221... | Line 216... | ||
221 | 216 | ||
222 | #define MULTIPLYER 4 |
217 | #define MULTIPLYER 4 |
Line 223... | Line -... | ||
223 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
- | |
224 | 218 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
|
225 | 219 | ||
226 | if(PlatinenVersion < 20) |
220 | if(PlatinenVersion < 20) |
227 | { |
221 | { |
228 | //--------------------------- |
222 | //--------------------------- |
Line 342... | Line 336... | ||
342 | TCCR2A |= (1<<COM2A0); // make a low pulse |
336 | TCCR2A |= (1<<COM2A0); // make a low pulse |
343 | // set pulsewidth to stop pulse width |
337 | // set pulsewidth to stop pulse width |
344 | RemainingPulse = PPM_STOPPULSE; |
338 | RemainingPulse = PPM_STOPPULSE; |
345 | // accumulate time for correct sync gap |
339 | // accumulate time for correct sync gap |
346 | ServoFrameTime += RemainingPulse; |
340 | ServoFrameTime += RemainingPulse; |
347 | HEF4017R_OFF; // disable HEF4017 reset |
341 | if(ServoActive && SenderOkay > 180) HEF4017R_OFF; // disable HEF4017 reset |
348 | ServoIndex++; // change to next servo channel |
342 | ServoIndex++; // change to next servo channel |
349 | if(ServoIndex > EE_Parameter.ServoNickRefresh) ServoIndex = 0; // reset to the sync gap |
343 | if(ServoIndex > EE_Parameter.ServoNickRefresh) ServoIndex = 0; // reset to the sync gap |
350 | } |
344 | } |
351 | // set pulse output active |
345 | // set pulse output active |
352 | PulseOutput = 1; |
346 | PulseOutput = 1; |