Sfoglia il codice sorgente

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 anni fa
parent
commit
7715d6eb60
1 ha cambiato i file con 10 aggiunte e 11 eliminazioni
  1. 10
    11
      frsky_arduino_rx_complete.ino

+ 10
- 11
frsky_arduino_rx_complete.ino Vedi File

@@ -38,6 +38,7 @@ const int rssi_max = -96;
38 38
 #define chanel_number 8  //set the number of chanels
39 39
 #define SEEK_CHANSKIP   13
40 40
 #define MAX_MISSING_PKT 20
41
+#define FAILSAFE_MISSING_PKT 170
41 42
 #define PPM_FrLen 22500
42 43
 #define PPM_PulseLen 300
43 44
 #define default_servo_value 1500
@@ -106,6 +107,7 @@ volatile byte scale;
106 107
 static byte jumper1 = 0;
107 108
 static byte jumper2 = 0;
108 109
 volatile int ppm[chanel_number];
110
+volatile bool failed = false;
109 111
 static uint16_t total_servo_time = 0;
110 112
 static byte cur_chan_numb = 0;
111 113
 boolean debug = false;
@@ -216,18 +218,9 @@ void loop()
216 218
     unsigned long time = micros();
217 219
 
218 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 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 225
     #endif
233 226
 
@@ -263,6 +256,7 @@ void loop()
263 256
                             cc2500_strobe(CC2500_SIDLE);
264 257
                             nextChannel(1);
265 258
                             LED_ON;
259
+                            failed = false;
266 260
                             break;
267 261
                         }
268 262
                     }
@@ -471,6 +465,11 @@ void getBind(void)
471 465
 
472 466
 ISR(TIMER1_COMPA_vect)
473 467
 {
468
+    if (failed) {
469
+        digitalWrite(sigPin, HIGH);
470
+        return;
471
+    }
472
+
474 473
     TCNT1 = 0;
475 474
     if (jumper1 == 0) {
476 475
         pinMode(Servo5_OUT, OUTPUT);

Loading…
Annulla
Salva