From d7076f5295a127654ecc4f09fa64d3d76115aa31 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Tue, 28 Feb 2017 10:36:35 +0100 Subject: [PATCH] PPM: add MIN_PPM_CHANNELS and MAX_PPM_CHANNELS --- Multiprotocol/Multiprotocol.h | 2 +- Multiprotocol/Multiprotocol.ino | 9 +++++---- Multiprotocol/TX_Def.h | 8 ++++++++ Multiprotocol/Validate.h | 13 +++++++++++++ Multiprotocol/_Config.h | 8 ++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 07150bd..b726aa3 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 1 #define VERSION_REVISION 6 -#define VERSION_PATCH_LEVEL 19 +#define VERSION_PATCH_LEVEL 20 //****************** // Protocols //****************** diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index ac0aafe..1bf00c0 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -478,6 +478,7 @@ uint8_t Update_All() if(mode_select==MODE_SERIAL && IS_RX_FLAG_on) // Serial mode and something has been received { update_serial_data(); // Update protocol and data + update_channels_aux(); INPUT_SIGNAL_on; //valid signal received last_signal=millis(); } @@ -485,7 +486,7 @@ uint8_t Update_All() #ifdef ENABLE_PPM if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received { - for(uint8_t i=0;i4840) { //start of frame - if(chan>3) + if(chan>=MIN_PPM_CHANNELS) PPM_FLAG_on; // good frame received if at least 4 channels have been seen chan=0; // reset channel counter bad_frame=0; @@ -1231,7 +1232,7 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new) if(bad_frame==0) // need to wait for start of frame { //servo values between 500us and 2420us will end up here PPM_data[chan]= Cur_TCNT1>>1;; - if(chan++>=NUM_CHN) + if(chan++>=MAX_PPM_CHANNELS) bad_frame=1; // don't accept any new channels } Prev_TCNT1+=Cur_TCNT1; diff --git a/Multiprotocol/TX_Def.h b/Multiprotocol/TX_Def.h index 9f24195..a4ada35 100644 --- a/Multiprotocol/TX_Def.h +++ b/Multiprotocol/TX_Def.h @@ -38,6 +38,14 @@ #define PPM_MIN_125 1150 // 125% #endif +// Walkera PL0811-01H +#if defined(TX_WALKERA) + #define PPM_MAX_100 1800 // 100% + #define PPM_MIN_100 1000 // 100% + #define PPM_MAX_125 1900 // 125% + #define PPM_MIN_125 900 // 125% +#endif + //Serial MIN MAX values #define SERIAL_MAX_100 2012 // 100% #define SERIAL_MIN_100 988 // 100% diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 82b553b..67c73af 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -129,3 +129,16 @@ #error BIND_CH must be below or equal to 16. #endif #endif + +#if MIN_PPM_CHANNELS>16 + #error MIN_PPM_CHANNELS must be below or equal to 16. The default for this value is 4. +#endif +#if MIN_PPM_CHANNELS<2 + #error MIN_PPM_CHANNELS must be larger than 1. The default for this value is 4. +#endif +#if MAX_PPM_CHANNELS16 + #error MAX_PPM_CHANNELS must be below or equal to 16. The default for this value is 16. +#endif diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 11ddbad..2a0598c 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -177,6 +177,7 @@ //#define TX_SPEKTRUM //Spektrum (1100<->1900µs) //#define TX_HISKY //HISKY (1120<->1920µs) //#define TX_MPX //Multiplex MC2020 (1250<->1950µs) +//#define TX_WALKERA //Walkera PL0811-01H (1000<->1800µs) //#define TX_CUSTOM //Custom // The lines below are used to set the end points in microseconds (µs) if you have selected TX_CUSTOM. @@ -192,6 +193,13 @@ #define PPM_MIN_125 1000 // 125% #endif +// The line below is used to set the minimum number of channels which the module should receive to consider a PPM frame valid. +// The default value is 4 to receive at least AETR for flying models but you could also connect the PPM from a car radio which has only 3 channels by changing this number to 3. +#define MIN_PPM_CHANNELS 4 +// The line below is used to set the maximum number of channels which the module should work with. Any channels received above this number are discarded. +// The default value is 16 to receive all possible channels but you might want to filter some "bad" channels from the PPM frame like the ones above 6 on the Walkera PL0811. +#define MAX_PPM_CHANNELS 16 + //The table below indicates which protocol to run when a specific position on the dial has been selected. //All fields and values are explained below. Everything is configurable from here like in the Serial mode. //Example: You can associate multiple times the same protocol to different dial positions to take advantage of the model match (RX_Num)