解码433Mhz AC123-01信号,发射机未收到控制器信息。

问题描述 投票:0回答:1

我想用433接收器从空调控制器上拷贝一个433Mhz的波形,我用一些代码就能得到这个波形,但是这个波形对我一点帮助都没有,我有一个AC123-01控制器。我使用的是Arduino的接收器和发射器射频模块。我尝试了RC-Switch库来收集控制器的二进制代码,但没有任何成功。这是我想复制的控制器 https:/www.youtube.comwatch?v=H_PyVQf_4i8 我管理的代码得到的波形。

#define DATA 2

void setup() {
Serial.begin(9600);
pinMode(DATA, INPUT);
}

void loop() {
 Serial.println(digitalRead(DATA));
}

这是控制器和我的Arduino的发射器My Setup

用这个Rc -Switch库的代码,我无法从控制器上捕捉到任何信号。完全没有反应。

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
}

void loop() {
if (mySwitch.available()) {
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), 
mySwitch.getReceivedDelay(), 
mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
}
}

我设法用一个网站来获取波浪信号, 前两行是来自向下按钮, 另外两行是来自向上按钮.Waves从控制器得到的原始数据。

Start here first frame =>888,5208,648,556,252,152,648,548,248,156,648,
156,644,160,648,548,240,
564,248,156,648,160,644,552,244,556,248,156,656,540,268,144,648,548,256,148,
660,148,656,144,648,552,252,148,660,536,260,152,640,556,252,156,644,160,644,
552,240,172,632,564,244,548,256,548,244,168,640,160,648,156,652,152,644,160,
648,144,652,152,656,148,644,552,256,148,652,152,652,152,636,172,636,156,
648,156,644,160,628,176,632,164,640,568,240,160,632,172,628,164,644,160,648
,548,260,540,256,552,256,148,656,540,264,540,256,548,256,548,252,148,656
,152,636,556<=end frame
start next 
frame=>884,5220,640,560,252,148,656,540,260,152,660,136,664,140,664,
532,264,540,264,140,660,144,664,532,256,548,256,148,652,552,248,156,636,
560,248,156,648,160,644,160,644,548,248,156,648,556,252,152,656,536,264,
140,664,140,664,532,276,136,656,540,264,540,268,528,268,144,652,156,640,
152,652,152,648,160,636,168,632,160,644,160,644,552,244,172,632,160,644,
160,648,156,640,164,640,152,656,148,656,148,652,152,644,552,252,148,656,
152,640,164,640,152,648,548,252,552,244,564,240,164,640,552,256,548,244,
564,240,564,240,160,648,156,636,556<=end frame
start next frame=>892,5212,648,548,252,152,656,540,260,
156,636,164,640,156,648,548,256,548,248,168,636,160,648,544,260,544,252,
160,652,544,264,136,660,536,260,156,648,148,660,144,660,536,252,160,644,
548,252,156,648,544,252,164,636,160,648,560,236,164,632,564,244,560,
244,560,244,156,644,164,640,152,660,144,656,148,644,160,648,144,656,
152,648,544,264,152,644,148,648,160,644,160,640,164,632,160,640,164,
640,164,644,160,632,564,236,168,640,160,644,160,636,168,640,556,248,
544,264,544,248,164,640,552,252,544,260,544,252,552,248,156,648,156
,640,552,3300,84,484,672,160<=end frame 

在Excel中对3个帧的数据进行标准化处理。wave

arduino signals binary-data waveform
1个回答
1
投票

如何解码要获得二进制格式的代码,您可以使用 下载RC_switch 2.6.3库,并将其安装到你的库目录下。 并将其安装到你的库目录下,通过 Sketch -> Library manager -> Add zip library . 然后加载 File > Examples > RC_Switch > ReceiveDemo_Advanced 和编译器到板子上。上载草图后,将433MHz射频接收器连接至 Digital Pin 2 遥控板的电源。打开Arduino IDE串行显示器,开始按遥控器的按钮。每按一次按钮后,您可以看到每个按钮的二进制代码(它以红色高亮显示)。<code>enter image description here</code>保存每个按钮的二进制代码(你也可以使用十进制或三态代码)。

Button 3 ON = (24Bit) Binary: 000101010101000101010101
Button 3 OFF = (24Bit) Binary: 000101010101000101010100
Button 4 ON = (24Bit) Binary: 000101010101010001010101
Button 4 OFF = (24Bit) Binary: 000101010101010001010100

保存你的脉冲长度: 416微秒和协议。1.如何发送 你需要用你的二进制代码,脉冲长度和协议定制下一个草图。

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
  Serial.begin(9600);
  // Transmitter is connected to Arduino Pin #10  
  mySwitch.enableTransmit(10);

  // Optional set pulse length.
  mySwitch.setPulseLength(REPLACE_WITH_YOUR_PULSE_LENGTH);
  // Optional set protocol (default is 1, will work for most appliancies)
  mySwitch.setProtocol(REPLACE_WITH_YOUR_PROTOCOL);

  // Optional set number of transmission repetitions.
  // mySwitch.setRepeatTransmit(15);
}
void loop() {
  // Binary code - button 3 ON
  mySwitch.send("000101010101000101010101");  // YOUR_CODE_HERE
  delay(1000); 
 // Binary code - button 3 OFF 
  mySwitch.send("000101010101000101010100");   // YOUR_CODE_HERE
  delay(1000);
  // Binary code - button 4 ON
  mySwitch.send("000101010101010001010101");    // YOUR_CODE_HERE
  delay(1000);  
 // Binary code - button 4 OFF
  mySwitch.send("000101010101010001010100");    // YOUR_CODE_HERE
  delay(1000);
}

所以,没有切割波信号或类似的, 只是系统地按下按钮,记录和重放。EDIT对于您的特殊需求解码AC123协议有一个解决方案。解码是通过改编下面给定的发射机程序和。RC-switch库的分叉. 由于AC123使用2个同步位和64个数据字节。协议设置(只添加到pevar库中)是。

 {15, 132, 50, {99, 13}, {5, 13}, {11, 6}, {11, 101}, false }

如何添加一个 新的远程阅读此wiki 但要使用分叉的库。作为帮助,如果你使用simple_scanner(在例子中),你会得到这样的东西:你搜索第一个844(thirvalue--在这个例子中840,你的可能是860或类似的),从下一个数字到下一个844之前的最后一个数字(你的第一个是什么),代码是一个int数组。

212,572,
from =>844,5144,596,576,212,180,612,564,212,192,600,180,608,
180,608,564,216,576,216,180,608,180,612,564,212,576,212,576,
216,564,224,180,600,188,604,180,608,576,212,564,216,576,212,
180,612,572,216,180,596,192,604,180,608,572,216,180,600,576,
212,180,612,572,216,180,608,564,216,180,612,180,608,180,608,
180,600,180,608,180,612,180,608,564,216,184,608,180,608,184,
608,180,596,192,600,180,608,180,608,180,604,188,600,576,212,
184,608,180,596,192,600,180,608,564,224,564,220,188,600,576,
212,180,608,180,600,576,216,176,612,180,608,564,212,
576<= till here
,844,5140,600,572,216,176,612,568,220,180,600,
180,612,180,608,564,224,564,220,180,608,180,608,564,228,560,
216,572,216,572   .... goes on for x lines

这个数组可以用 这个RC-switch库的分叉。 在数组的末尾加上,0

对于发送自发信号,你必须使用 这个分叉 在你根据wiki分析了数据负载之后,AC123的协议是这样建立的(你仍然必须使用RC_Scanner来获取你的硬件数据!)。

Remote ID Byte 1 (possibly Manufacturer ID)    10100011
Remote ID Byte 2                               01101110 
Remote ID Byte 3                               00010100
Remote ID Byte 4                               00110101      
Channel Byte 1                                 00000001
Channel Byte 2                                 00000000    
Control Code                                   00001011  
Checksum                                      11000011
 The command byte works as follows for my system:
 UP         STOP            DOWN
00001011    00100011    01000011    

校验和是由远程ID字节2+远程ID字节3+远程ID字节4+通道字节1+通道字节2+控制代码的加法计算出来的。在这种情况下,MSB会被忽略。 注意:这不包括远程 ID 字节 1,它可能指向制造商 ID。这里有一个快速测试草图,可以使用和实验。

// Transmitter for AC123 - Manufacturer ID 1
#include <RCSwitch.h> // Use this lib variant: https://github.com/perivar/rc-switch/

const unsigned long Remote = 0xA362281F;

const uint8_t CHANNEL_PADDING = B0000;
const uint8_t UP = B00001011;
const uint8_t STOP = B00100011;
const uint8_t DOWN = B01000011;

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  // Transmitter is connected to Pin 5 change to your setuo
  mySwitch.enableTransmit(5);
  // AC123 Protocol define as 15
  mySwitch.setProtocol(15);
  mySwitch.setPulseLength(50);
}

void loop() {
  Serial.println("Send Command");
  sendCommand(Remote, B00001111, DOWN);
  delay(2000);
  sendCommand(Remote, B00001111, STOP);
  delay(2000);
  sendCommand(Remote, B00001111, UP);
  delay(2000);
}

void comUp(unsigned long Remote, uint8_t channels) {
  sendCommand(Remote, channels, UP);
}

void comDown(unsigned long Remote, uint8_t channels) {
  sendCommand(Remote, channels, DOWN);
}

void comStop(unsigned long Remote, uint8_t channels) {
  sendCommand(Remote, channels, STOP);
}
// This is the part you'll have to adept to your hardware
void sendCommand(unsigned long Remote, uint8_t channels, uint8_t commandR) {
  uint8_t RemoteByte1 __attribute__((unused)) = Remote >> 24; // possibly Manufacturer ID not used at the moment
  uint8_t RemoteByte2 = Remote >> 16;
  uint8_t RemoteByte3 = Remote >> 8;
  uint8_t RemoteByte4 = Remote;
  uint8_t Checksum = RemoteByte2 + RemoteByte3 + RemoteByte4 + channels + CHANNEL_PADDING + commandR;
  char SendCodeChar[64];
  uint8_t bitPos = 31;
  for (uint8_t i = 0; i <= 31; i++) {
    if bitRead(Remote, bitPos) SendCodeChar[i] = '1';
    else SendCodeChar[i] = '0';
    bitPos--;
  }
  bitPos = 7;
  for (uint8_t i = 32; i <= 39 ; i++) {
    if bitRead(channels, bitPos) SendCodeChar[i] = '1';
    else SendCodeChar[i] = '0';
    bitPos--;
  }
  bitPos = 7;
  for (uint8_t i = 40; i <= 47 ; i++) {
    if bitRead(CHANNEL_PADDING, bitPos) SendCodeChar[i] = '1';
    else SendCodeChar[i] = '0';
    bitPos--;
  }
  bitPos = 7;
  for (uint8_t i = 48; i <= 55 ; i++) {
    if bitRead(commandR, bitPos) SendCodeChar[i] = '1';
    else SendCodeChar[i] = '0';
    bitPos--;
  }
  bitPos = 7;
  for (uint8_t i = 56; i <= 63 ; i++) {
    if bitRead(Checksum, bitPos) SendCodeChar[i] = '1';
    else SendCodeChar[i] = '0';
    bitPos--;
  }
  mySwitch.send(SendCodeChar);
}

编辑2 由于上级改变了他的问题,并增加了捕获的数据(其工作OMG),这里的答案,我给了一个讨论,为他人如何解码的帮助。我分析了一个电子表格,你应该搜索8xx(脉冲)和5XXX(编码AC123-0x)的组合,在你的情况下,一帧包括逗号总是1750字符长

Start here first frame =>888,5208,648,556,252,152,648,548,248,156,648,
156,644,160,648,548,240,
564,248,156,648,160,644,552,244,556,248,156,656,540,268,144,648,548,256,148,
660,148,656,144,648,552,252,148,660,536,260,152,640,556,252,156,644,160,644,
552,240,172,632,564,244,548,256,548,244,168,640,160,648,156,652,152,644,160,
648,144,652,152,656,148,644,552,256,148,652,152,652,152,636,172,636,156,
648,156,644,160,628,176,632,164,640,568,240,160,632,172,628,164,644,160,648
,548,260,540,256,552,256,148,656,540,264,540,256,548,256,548,252,148,656
,152,636,556<=end frame
start next frame=>884,5220,640,560,252,148,656,540,260,152,660,136,664,140,664,
532,264,540,264,140,660,144,664,532,256,548,256,148,652,552,248,156,636,
560,248,156,648,160,644,160,644,548,248,156,648,556,252,152,656,536,264,
140,664,140,664,532,276,136,656,540,264,540,268,528,268,144,652,156,640,
152,652,152,648,160,636,168,632,160,644,160,644,552,244,172,632,160,644,
160,648,156,640,164,640,152,656,148,656,148,652,152,644,552,252,148,656,
152,640,164,640,152,648,548,252,552,244,564,240,164,640,552,256,548,244,
564,240,564,240,160,648,156,636,556<=end frame
start next frame=>892,5212,648,548,252,152,656,540,260,
156,636,164,640,156,648,548,256,548,248,168,636,160,648,544,260,544,252,
160,652,544,264,136,660,536,260,156,648,148,660,144,660,536,252,160,644,
548,252,156,648,544,252,164,636,160,648,560,236,164,632,564,244,560,
244,560,244,156,644,164,640,152,660,144,656,148,644,160,648,144,656,
152,648,544,264,152,644,148,648,160,644,160,640,164,632,160,640,164,
640,164,644,160,632,564,236,168,640,160,644,160,636,168,640,556,248,
544,264,544,248,164,640,552,252,544,260,544,252,552,248,156,648,156
,640,552,3300,84,484,672,160<=end frame 

所以实际上你在你发布的代码中有三个命令。不要忘了在传输之前,在最后加上0,作为一个数组。

© www.soinside.com 2019 - 2024. All rights reserved.