Skip to content

Commit

Permalink
Stop sending pulses altogether on failsafe
Browse files Browse the repository at this point in the history
This makes failsafe much easier to configure on the flight controller.
The previous behavior of setting all the channels to 1000 was a bit
confusing because the pulses my flight control was receiving were
already less than 1000, so going into failsafe actually raised all
channel levels until I adjusted subtrim on throttle to keep it around
1010.

With this code, it simply stops pulsing in such a way that matches what
the frsky d4r does (see below).  This is a well-known and unambiguous
path.

D4R losing radio contact:  http://i.imgur.com/8Xd27VQ.png

This code losing radio contact: http://i.imgur.com/lxGL4CT.png
  • Loading branch information
dustin committed Jun 10, 2015
1 parent ecf2e14 commit 7715d6e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions frsky_arduino_rx_complete.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const int rssi_max = -96;
#define chanel_number 8 //set the number of chanels
#define SEEK_CHANSKIP 13
#define MAX_MISSING_PKT 20
#define FAILSAFE_MISSING_PKT 170
#define PPM_FrLen 22500
#define PPM_PulseLen 300
#define default_servo_value 1500
Expand Down Expand Up @@ -106,6 +107,7 @@ volatile byte scale;
static byte jumper1 = 0;
static byte jumper2 = 0;
volatile int ppm[chanel_number];
volatile bool failed = false;
static uint16_t total_servo_time = 0;
static byte cur_chan_numb = 0;
boolean debug = false;
Expand Down Expand Up @@ -216,18 +218,9 @@ void loop()
unsigned long time = micros();

#if defined(FAILSAFE)
if (missingPackets > 170) {
//**************************************
//noInterrupts();//
//digitalWrite(sigPin, LOW);
//Servo_Ports_LOW;
//**********************************************
if (missingPackets > FAILSAFE_MISSING_PKT) {
failed = true;
missingPackets = 0;
int i;
for (i = 0; i < 8; i++) {
Servo_data[i] = 1000;
ppm[i] = 1000;
}
}
#endif

Expand Down Expand Up @@ -263,6 +256,7 @@ void loop()
cc2500_strobe(CC2500_SIDLE);
nextChannel(1);
LED_ON;
failed = false;
break;
}
}
Expand Down Expand Up @@ -471,6 +465,11 @@ void getBind(void)

ISR(TIMER1_COMPA_vect)
{
if (failed) {
digitalWrite(sigPin, HIGH);
return;
}

TCNT1 = 0;
if (jumper1 == 0) {
pinMode(Servo5_OUT, OUTPUT);
Expand Down

0 comments on commit 7715d6e

Please sign in to comment.