Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failsafe/Signal loss #1

Open
williamdwarke opened this issue Jul 19, 2017 · 1 comment
Open

Failsafe/Signal loss #1

williamdwarke opened this issue Jul 19, 2017 · 1 comment

Comments

@williamdwarke
Copy link

Any idea how to detect signal loss for implementing a failsafe over this protocol? It seems to spit out valid data even when my transmitter isn't turned on. Really appreciate your library BTW!

Thanks,
Willie

@pouriap
Copy link

pouriap commented Sep 29, 2017

Hi @williamdwarke

I just figured out two things:
1- The receiver keeps sending normal signal unless you have assigned a failsafe for that channel in your transmitter. So if you want failsafe for channel 4, turn it on for channel 4 on your transmitter.
Now you'll see the data received by the Arduino is changed when you turn off the controller.

2- When you turn on failsafe a 0xC is added to the received data for each channel. For example if the HEX value of the received data is 0x5DC, after the failsafe is triggered it will become 0xC5DC. So to detect the failsafe we can read the last 4bits of the received data. If it equals 0xC then we have lost signal.
This code is working for me:

//turn on failsafe on channel 4 in your transmitter

#include "FlySkyIBus.h"

void setup() 
{
  Serial.begin(115200);
  IBus.begin(Serial);
}

void loop() 
{
  IBus.loop();
  unsigned int value = IBus.readChannel(3);

  Serial.print("Read value in HEX: ");
  Serial.print(value, HEX);
  Serial.print(" - ");

  unsigned int failBits = (value >> 12) & 0xF;  // get the last 4bits of read value
  boolean signalLost = (failBits == 0xC)? true : false;
  
  if(signalLost){
    // 'value' is now is a meaningless number. We have to get the currect value by getting the first 12bits
    unsigned int failValue = (value) & 0xFFF; //the first 12 bits
    
    Serial.print("Signal lost!! - ");
    Serial.print("Failsafe value: ");
    Serial.print(failValue);
  }
  else{
    Serial.print("Normal value: ");
    Serial.print(value);
  }
  

  Serial.println("");
  
}

This is a quick and dirty fix. The more clean approach would be to learn the protocol and edit the library code to add functionality to handle failsafe. But I don't have the time/intention to do that for the time being.

Note:

  • Arduino reads 0 when you have not yet turned on your transmitter.
  • Arduino keeps reading the last value when your receiver is disconnected. I think to fix this you have to delve into the code.

Hope this will help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants