Browse Source

Merge pull request #3 from dustin/master

New failsafe code to stop sending pulses on failure.
readerror67 9 years ago
parent
commit
b73b8cd8c8
1 changed files with 10 additions and 15 deletions
  1. 10
    15
      frsky_arduino_rx_complete.ino

+ 10
- 15
frsky_arduino_rx_complete.ino View 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,22 +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
-                if (i == 2) {
231
-                    Servo_data[2] = 1000; //THROTLE ON CHN3 here it can be changed Throttle on other channel
232
-                    ppm[2] = 1000;
233
-                }
234
-            }
235 224
         }
236 225
     #endif
237 226
 
@@ -267,6 +256,7 @@ void loop()
267 256
                             cc2500_strobe(CC2500_SIDLE);
268 257
                             nextChannel(1);
269 258
                             LED_ON;
259
+                            failed = false;
270 260
                             break;
271 261
                         }
272 262
                     }
@@ -475,6 +465,11 @@ void getBind(void)
475 465
 
476 466
 ISR(TIMER1_COMPA_vect)
477 467
 {
468
+    if (failed) {
469
+        digitalWrite(sigPin, HIGH);
470
+        return;
471
+    }
472
+
478 473
     TCNT1 = 0;
479 474
     if (jumper1 == 0) {
480 475
         pinMode(Servo5_OUT, OUTPUT);

Loading…
Cancel
Save