Gathering protocol from remote control helicopter

杀马特。学长 韩版系。学妹 提交于 2019-12-25 01:55:36

问题


I have a (S107G) mini helicopter, and an Arduino. The possibilities sounded quite fun. So I set off to find the protocol for the transfer of data from controller to helicopter with IR. I used this code to try to figure out something of it.

void setup()
{
    Serial.begin(9600);
    pinMode(12, INPUT_PULLUP); // 12 is IR sensor
}

void loop()
{
    Serial.print(digitalRead(12) ? LOW : HIGH);
    delay(1);
}

Obviously there a number of flaws with this.

  1. delay(1); is arbitrarily chosen, I have no way of knowing at what speed data is transmitted.
  2. It could be an analog input. (Though I doubt it, as most IR sensors I found don't support that)
  3. I have no way of knowing when a "packet" starts or ends.

If any of you have an idea of how to do this I would much appreciate it. Thanks!

EDIT: I found this on SO and it sounds very nice, but he didn't go into depth as to how he did it, and what his findings were (speed, etc.)


回答1:


You can find the complete code library here on my GITHUB in which you will find the examples of IRsendDemoHelicopter.ino and IRrecvDump.ino. These and the IRremote.cpp should answer your questions. I have had it on my plan (for sometime) to implement the transmitter on an Esplora.

Below are the Micro Seconds, found at https://github.com/mpflaga/Arduino-IRremote/blob/master/IRremoteInt.h#L192

#define SYMA_UPDATE_PERIOD_CH_A 120 // 0
#define SYMA_UPDATE_PERIOD_CH_B 180 // 1
#define SYMA_HDR_MARK 2000
#define SYMA_HDR_SPACE 2000
#define SYMA_BIT_MARK 320
#define SYMA_ONE_SPACE 687
#define SYMA_ZERO_SPACE 300

and here is the pattern of bits for both the R3 and R5. I believe the R5 is the most common being in production.

union helicopter {
  uint32_t dword;
  struct
  {
     uint8_t Throttle  : 7;    //  0..6   0 - 127
     uint8_t Channel   : 1;    //  7      A=0, B=1
     uint8_t Pitch     : 7;    //  8..14  0(forward) - 63(center) 127(back)
     uint8_t Pspacer   : 1;    // 15      na
     uint8_t Yaw       : 7;    // 16..22  127(left) - 63(center) - 0(right)
  } symaR3;
  struct
  {
     uint8_t Trim      : 7;    //  0..6  127(left) - 63(center) - 0(right)
     uint8_t Tspacer   : 1;    //  7     na
     uint8_t Throttle  : 7;    //  8..14 0 - 127
     uint8_t Channel   : 1;    // 15     A=0, B=1
     uint8_t Pitch     : 7;    // 16..22 0(forward) - 63(center) 127(back)
     uint8_t Pspacer   : 1;    // 23     na
     uint8_t Yaw       : 7;    // 24..30 127(left) - 63(center) - 0(right)
  } symaR5;
};

but it is always possible they have come out with a new pattern.



来源:https://stackoverflow.com/questions/22593784/gathering-protocol-from-remote-control-helicopter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!