遥控直升机采集协议 [英] Gathering protocol from remote control helicopter

查看:28
本文介绍了遥控直升机采集协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 (S107G) 迷你直升机和一个 Arduino.这些可能性听起来很有趣.因此,我开始寻找使用 IR 将数据从控制器传输到直升机的协议.我用这段代码试图找出其中的一些东西.

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);
}

显然这有很多缺陷.

  1. delay(1); 是任意选择的,我无法知道数据传输的速度.
  2. 它可能是一个模拟输入.(虽然我对此表示怀疑,因为我发现的大多数红外传感器都不支持)
  3. 我无法知道数据包"何时开始或结束.
  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!

我在 SO 上找到了 这个听起来很不错,但他没有深入说明他是如何做到的,以及他的发现是什么(速度等)

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.)

推荐答案

您可以在这里找到完整的代码库在我的 GITHUB 上,您将找到 IRsendDemoHelicopter.ino 和 IRrecvDump.ino 的示例.这些和 IRremote.cpp 应该可以回答您的问题.我计划(一段时间)在 Esplora 上实施发射器.

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.

以下是微秒,位于 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

这里是 R3 和 R5 的位模式.我相信 R5 是生产中最常见的.

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.

这篇关于遥控直升机采集协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆