Browse Source

Stop sending pulses altogether on failsafe

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
Dustin Sallings 9 years ago
parent
commit
7715d6eb60
1 changed files with 10 additions and 11 deletions
  1. 10
    11
      frsky_arduino_rx_complete.ino

+ 10
- 11
frsky_arduino_rx_complete.ino View File

38
 #define chanel_number 8  //set the number of chanels
38
 #define chanel_number 8  //set the number of chanels
39
 #define SEEK_CHANSKIP   13
39
 #define SEEK_CHANSKIP   13
40
 #define MAX_MISSING_PKT 20
40
 #define MAX_MISSING_PKT 20
41
+#define FAILSAFE_MISSING_PKT 170
41
 #define PPM_FrLen 22500
42
 #define PPM_FrLen 22500
42
 #define PPM_PulseLen 300
43
 #define PPM_PulseLen 300
43
 #define default_servo_value 1500
44
 #define default_servo_value 1500
106
 static byte jumper1 = 0;
107
 static byte jumper1 = 0;
107
 static byte jumper2 = 0;
108
 static byte jumper2 = 0;
108
 volatile int ppm[chanel_number];
109
 volatile int ppm[chanel_number];
110
+volatile bool failed = false;
109
 static uint16_t total_servo_time = 0;
111
 static uint16_t total_servo_time = 0;
110
 static byte cur_chan_numb = 0;
112
 static byte cur_chan_numb = 0;
111
 boolean debug = false;
113
 boolean debug = false;
216
     unsigned long time = micros();
218
     unsigned long time = micros();
217
 
219
 
218
     #if defined(FAILSAFE)
220
     #if defined(FAILSAFE)
219
-        if (missingPackets > 170) {
220
-            //**************************************
221
-            //noInterrupts();//
222
-            //digitalWrite(sigPin, LOW);
223
-            //Servo_Ports_LOW;
224
-            //**********************************************
221
+        if (missingPackets > FAILSAFE_MISSING_PKT) {
222
+            failed = true;
225
             missingPackets = 0;
223
             missingPackets = 0;
226
-            int i;
227
-            for (i = 0; i < 8; i++) {
228
-                Servo_data[i] = 1000;
229
-                ppm[i] = 1000;
230
-            }
231
         }
224
         }
232
     #endif
225
     #endif
233
 
226
 
263
                             cc2500_strobe(CC2500_SIDLE);
256
                             cc2500_strobe(CC2500_SIDLE);
264
                             nextChannel(1);
257
                             nextChannel(1);
265
                             LED_ON;
258
                             LED_ON;
259
+                            failed = false;
266
                             break;
260
                             break;
267
                         }
261
                         }
268
                     }
262
                     }
471
 
465
 
472
 ISR(TIMER1_COMPA_vect)
466
 ISR(TIMER1_COMPA_vect)
473
 {
467
 {
468
+    if (failed) {
469
+        digitalWrite(sigPin, HIGH);
470
+        return;
471
+    }
472
+
474
     TCNT1 = 0;
473
     TCNT1 = 0;
475
     if (jumper1 == 0) {
474
     if (jumper1 == 0) {
476
         pinMode(Servo5_OUT, OUTPUT);
475
         pinMode(Servo5_OUT, OUTPUT);

Loading…
Cancel
Save