mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 19:58:13 +00:00
Failsafe modification
The following protocols are supporting failsafe: FrSkyX, Devo, WK2x01, SFHSS, HISKY/HK310 and AFHDS2A In Serial mode failsafe is configured on the radio itself. In PPM mode and only after the module is up and fully operational, press the bind button for at least 5sec to send the current stick positions as failsafe to the RX.
This commit is contained in:
parent
18af4a0724
commit
e783ce5788
@ -13,28 +13,6 @@
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef FAILSAFE_ENABLE
|
||||
//Convert from percentage to failsafe value
|
||||
#define FAILSAFE_THROTTLE_LOW_VAL (((FAILSAFE_THROTTLE_LOW+125)*1024)/125)
|
||||
#if FAILSAFE_THROTTLE_LOW_VAL <= 0
|
||||
#undef FAILSAFE_THROTTLE_LOW_VAL
|
||||
#define FAILSAFE_THROTTLE_LOW_VAL 1
|
||||
#elif (FAILSAFE_THROTTLE_LOW_VAL) >= 2046
|
||||
#undef FAILSAFE_THROTTLE_LOW_VAL
|
||||
#define FAILSAFE_THROTTLE_LOW_VAL 2046
|
||||
#endif
|
||||
void InitFailsafe()
|
||||
{
|
||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||
Failsafe_data[i]=1024;
|
||||
Failsafe_data[THROTTLE]=(uint16_t)FAILSAFE_THROTTLE_LOW_VAL; //1=-125%, 204=-100%
|
||||
FAILSAFE_VALUES_on;
|
||||
#ifdef FAILSAFE_SERIAL_ONLY
|
||||
if(mode_select == MODE_SERIAL)
|
||||
FAILSAFE_VALUES_off;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_PPM
|
||||
void InitPPM()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_REVISION 1
|
||||
#define VERSION_PATCH_LEVEL 83
|
||||
#define VERSION_PATCH_LEVEL 84
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
|
@ -653,6 +653,7 @@ uint8_t Update_All()
|
||||
Channel_data[i]=val;
|
||||
}
|
||||
PPM_FLAG_off; // wait for next frame before update
|
||||
PPM_failsafe();
|
||||
update_channels_aux();
|
||||
INPUT_SIGNAL_on; // valid signal received
|
||||
last_signal=millis();
|
||||
@ -693,6 +694,32 @@ uint8_t Update_All()
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PPM
|
||||
void PPM_failsafe()
|
||||
{
|
||||
static uint8_t counter=0;
|
||||
|
||||
if(IS_BIND_IN_PROGRESS || IS_FAILSAFE_VALUES_on) // bind is not finished yet or Failsafe already being sent
|
||||
return;
|
||||
BIND_SET_INPUT;
|
||||
BIND_SET_PULLUP;
|
||||
if(IS_BIND_BUTTON_on)
|
||||
{// bind button pressed
|
||||
counter++;
|
||||
if(counter>227)
|
||||
{ //after 5s with PPM frames @22ms
|
||||
counter=0;
|
||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||
Failsafe_data[i]=Channel_data[i];
|
||||
FAILSAFE_VALUES_on;
|
||||
}
|
||||
}
|
||||
else
|
||||
counter=0;
|
||||
BIND_SET_OUTPUT;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update channels direction and Channel_AUX flags based on servo AUX positions
|
||||
static void update_channels_aux(void)
|
||||
{
|
||||
@ -927,7 +954,7 @@ static void protocol_init()
|
||||
set_rx_tx_addr(MProtocol_id);
|
||||
|
||||
#ifdef FAILSAFE_ENABLE
|
||||
InitFailsafe();
|
||||
FAILSAFE_VALUES_off;
|
||||
#endif
|
||||
|
||||
blink=millis();
|
||||
|
@ -123,11 +123,12 @@
|
||||
/** Low Power **/
|
||||
//Low power is reducing the transmit power of the multi module. This setting is configurable per model in PPM (table below) or Serial mode (radio GUI).
|
||||
//It can be activated when flying indoor or small models since the distance is short or if a model is causing issues when flying closed to the TX.
|
||||
//By default low power is completly disabled on all rf chips to prevent mistakes, but you can enable it by uncommenting the lines below:
|
||||
//#define A7105_ENABLE_LOW_POWER
|
||||
//#define CYRF6936_ENABLE_LOW_POWER
|
||||
//#define CC2500_ENABLE_LOW_POWER
|
||||
//#define NRF24L01_ENABLE_LOW_POWER
|
||||
//By default low power selection is enabled on all rf chips, but you can disable it by commenting (add //) the lines below if you don't want to risk
|
||||
//flying a model with low power.
|
||||
#define A7105_ENABLE_LOW_POWER
|
||||
#define CYRF6936_ENABLE_LOW_POWER
|
||||
#define CC2500_ENABLE_LOW_POWER
|
||||
#define NRF24L01_ENABLE_LOW_POWER
|
||||
|
||||
|
||||
/*****************/
|
||||
@ -240,25 +241,12 @@
|
||||
/**************************/
|
||||
/*** FAILSAFE SETTINGS ***/
|
||||
/**************************/
|
||||
//The module is using the same default failsafe values for all protocols which currently supports it:
|
||||
// Devo, WK2x01, SFHSS, HISKY/HK310 and AFHDS2A
|
||||
//All channels are centered except throttle which is forced low.
|
||||
//If you want to diasble failsafe globally comment the line below using "//".
|
||||
//The following protocols are supporting failsafe: FrSkyX, Devo, WK2x01, SFHSS, HISKY/HK310 and AFHDS2A
|
||||
//In Serial mode failsafe is configured on the radio itself.
|
||||
//In PPM mode and only after the module is up and fully operational, press the bind button for at least 5sec to send the current stick positions as failsafe to the RX.
|
||||
//If you want to disable failsafe globally comment the line below using "//".
|
||||
#define FAILSAFE_ENABLE
|
||||
|
||||
//Failsafe throttle low value in percentage.
|
||||
//Value between -125% and +125%. Default -100.
|
||||
#define FAILSAFE_THROTTLE_LOW -100
|
||||
|
||||
//The radio using serial protocol can set failsafe data.
|
||||
// Two options are available:
|
||||
// a. replace the default failsafe data with serial failsafe data when they are received.
|
||||
// b. wait for the radio to provide failsafe before sending it. Enable advanced settings like "FAILSAFE NOT SET" or "FAILSAFE RX".
|
||||
// Option a. is the default since you have a protection even if no failsafe has been set on the radio.
|
||||
// You can force option b. by uncommenting the line below (remove the "//").
|
||||
//#define FAILSAFE_SERIAL_ONLY
|
||||
|
||||
|
||||
/**************************/
|
||||
/*** TELEMETRY SETTINGS ***/
|
||||
/**************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user