Rev 2146 | Rev 2167 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2146 | Rev 2166 | ||
---|---|---|---|
Line 364... | Line 364... | ||
364 | if(!PulseOutput) // pulse output complete |
364 | if(!PulseOutput) // pulse output complete |
365 | { |
365 | { |
366 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
366 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
367 | { |
367 | { |
368 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
368 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
369 | - | ||
370 | if(ServoIndex == 0) // if we are at the sync gap |
369 | if(ServoIndex == 0) // if we are at the sync gap |
371 | { |
370 | { |
372 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; // generate sync gap by filling time to full frame time |
371 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; // generate sync gap by filling time to full frame time |
373 | ServoFrameTime = 0; // reset servo frame time |
372 | ServoFrameTime = 0; // reset servo frame time |
374 | HEF4017Reset_ON; // enable HEF4017 reset |
373 | HEF4017Reset_ON; // enable HEF4017 reset |
375 | } |
374 | } |
376 | else // servo channels |
375 | else // servo channels |
- | 376 | if(ServoIndex > EE_Parameter.ServoNickRefresh) |
|
- | 377 | { |
|
- | 378 | RemainingPulse = 10; // end it here |
|
- | 379 | } |
|
- | 380 | else |
|
377 | { |
381 | { |
378 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
382 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
379 | switch(ServoIndex) // map servo channels |
383 | switch(ServoIndex) // map servo channels |
380 | { |
384 | { |
381 | case 1: // Nick Compensation Servo |
385 | case 1: // Nick Compensation Servo |
382 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
386 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
383 | break; |
387 | break; |
384 | case 2: // Roll Compensation Servo |
388 | case 2: // Roll Compensation Servo |
385 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
389 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
386 | break; |
390 | break; |
Line 396... | Line 400... | ||
396 | default: // other servo channels |
400 | default: // other servo channels |
397 | RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
401 | RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
398 | break; |
402 | break; |
399 | } |
403 | } |
400 | // range servo pulse width |
404 | // range servo pulse width |
401 | if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
405 | if(RemainingPulse > MAXSERVOPULSE) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
402 | else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
406 | else if(RemainingPulse < MINSERVOPULSE) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
403 | // substract stop pulse width |
407 | // substract stop pulse width |
404 | RemainingPulse -= PPM_STOPPULSE; |
408 | RemainingPulse -= PPM_STOPPULSE; |
405 | // accumulate time for correct sync gap |
409 | // accumulate time for correct sync gap |
406 | ServoFrameTime += RemainingPulse; |
410 | ServoFrameTime += RemainingPulse; |
407 | } |
411 | } |
Line 413... | Line 417... | ||
413 | RemainingPulse = PPM_STOPPULSE; |
417 | RemainingPulse = PPM_STOPPULSE; |
414 | // accumulate time for correct sync gap |
418 | // accumulate time for correct sync gap |
415 | ServoFrameTime += RemainingPulse; |
419 | ServoFrameTime += RemainingPulse; |
416 | if((ServoActive && SenderOkay) || ServoActive == 2) HEF4017Reset_OFF; // disable HEF4017 reset |
420 | if((ServoActive && SenderOkay) || ServoActive == 2) HEF4017Reset_OFF; // disable HEF4017 reset |
417 | else HEF4017Reset_ON; |
421 | else HEF4017Reset_ON; |
418 | ServoIndex++; // change to next servo channel |
422 | ServoIndex++; |
419 | if(ServoIndex > EE_Parameter.ServoNickRefresh) |
423 | if(ServoIndex > EE_Parameter.ServoNickRefresh+1) |
420 | { |
424 | { |
421 | CalculateServoSignals = 1; |
425 | CalculateServoSignals = 1; |
422 | ServoIndex = 0; // reset to the sync gap |
426 | ServoIndex = 0; // reset to the sync gap |
423 | } |
427 | } |
424 | } |
428 | } |