极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 77884|回复: 19

解决问题系列(3)——红外发射,控制美的空调开

[复制链接]
发表于 2013-6-18 14:28:04 | 显示全部楼层 |阅读模式
本帖最后由 瘦网虫 于 2013-6-26 21:49 编辑

好久没搞红外遥控了,今天拿起来。感觉还好,对照前人们的教程贴,很快就把电路搭起来。

今天准备遥控美的空调(我手边的是美的)。

用IRremote库里面的IRdump例程,先克隆出来空调的开关,再发送回去,搞了半天,控制不了。

  1. //unsigned int rawCodes_ac_open[100] = {3602,4400,4450,550,1600,550,550,550,1650,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,1650,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,550,550,1650,550,1600,550,1650,550,550,550,500,550,550,550,550,550,1600,550,550,550,550,550,1600,550,1650,550,1600,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,500,550,1650,550,1600,550,1650,550,1600,550,1650,550};
  2. unsigned int rawCodes_ac_open[200] = {4397,4368,561,1578,560,537,557,1581,584,1582,584,486,558,537,584,1554,560,538,558,510,558,1607,557,513,585,511,556,1585,581,1583,583,486,557,1609,556,513,558,538,557,512,558,1607,558,1583,557,1608,558,1608,557,1580,559,1606,559,1581,556,1609,557,512,559,537,558,512,557,539,557,512,558,1607,558,1582,558,537,584,1555,558,1607,556,514,559,537,556,513,558,537,556,514,558,1606,559,511,583,513,558,1582,557,1608,558,1580,585,5154,4419,4347,584,1555,558,539,557,1581,584,1581,571,501,577,516,571,1568,557,541,581,487,557,1608,557,513,558,538,557,1582,583,1582,584,487,557,1608,557,511,611,486,558,510,558,1607,557,1609,556,1583,583,1582,583,1555,558,1607,558,1607,559,1582,557,537,585,486,558,510,558,540,558,509,557,1608,558,1608,557,512,559,1606,559,1581,558,537,581,490,558,510,587,511,557,511,559,1606,559,510,569,527,558,1582,560,1604,561,1605,561};
  3. unsigned int rawCodes_ac_close[100] ={25524,4400,4400,550,1650,550,550,550,1600,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,1600,550,550,550,1600,550,1650,550,550,550,1600,550,1650,550,1600,550,1650,550,1600,550,1650,550,550,500,1650,550,550,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,1650,550,1650,550};
复制代码


被屏蔽的第一行代码,就是用IRdump读出来的,这个不能控制空调。
第二行可以,看出来区别了吗?1个是100,一个是200。
每个数字为单片机捕获的美的空调遥控器的高低电平时间,单位为US,一高一低一高一低......详见sendRaw函数。
可以预见的是,第三行代码也不能用。

第二行的内容我也是无意中搜出来的,见下面的链接:
http://blog.21ic.com/user1/3179/archives/2010/68502.html

找到正确的序列,才可以控制。
下面是发送代码

  1. Serial.print("SendIR: ");
  2.   irsend.sendRaw(rawCodes_ac_open,200, 38);   // 记得换成你遥控器的红外线编码
  3.   delay(3000);   
复制代码


无它,唯运气好而已,记录一下,防止遗忘。

解决问题系列(4)——红外编码分析利器使用


解决问题系列(2)——红外发射"未知类型"代码

评分

参与人数 1 +2 收起 理由
幻生幻灭 + 2 很给力!

查看全部评分

回复

使用道具 举报

发表于 2013-6-18 15:49:51 | 显示全部楼层
IRremote接收数据的rawbuf最大长度是可以改的

见IRremote.h文件中的宏定义
#define RAWBUF 100 // Length of raw duration buffer
回复 支持 反对

使用道具 举报

发表于 2013-6-18 19:22:44 | 显示全部楼层
本帖最后由 学长 于 2013-6-18 19:23 编辑

非常高级 有参考价值.. 谢谢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-18 20:38:39 | 显示全部楼层
histamine 发表于 2013-6-18 15:49
IRremote接收数据的rawbuf最大长度是可以改的

见IRremote.h文件中的宏定义

我正准备找这个100在哪里定义的呢。呵呵。谢谢高人指点。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-18 20:39:45 | 显示全部楼层
学长 发表于 2013-6-18 19:22
非常高级 有参考价值.. 谢谢

按照猜想,如果改成200,应该可以继续读出该遥控器的其他按键红外值。
回复 支持 反对

使用道具 举报

发表于 2013-6-18 21:23:35 | 显示全部楼层
瘦网虫 发表于 2013-6-18 20:39
按照猜想,如果改成200,应该可以继续读出该遥控器的其他按键红外值。

期待你的测试结果哦... 加油
回复 支持 反对

使用道具 举报

发表于 2013-6-18 22:40:19 | 显示全部楼层
如果直接发十六进制数据怎么样?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-20 22:16:04 | 显示全部楼层
本帖最后由 瘦网虫 于 2013-6-21 09:56 编辑

又找来IRremote库原文
http://www.righto.com/2009/08/mu ... remote-library.html

中间提到了处理raw函数。

Handling raw codes
处理原始代码

The library provides support for sending and receiving raw durations. This is intended mainly for debugging, but can also be used for protocols the library doesn't implement, or to provide universal remote functionality.
The raw data for received IR measures the duration of successive spaces and marks in 50us ticks. The first measurement is the gap, the space before the transmission starts. The last measurement is the final mark.


The raw data for sending IR holds the duration of successive marks and spaces in microseconds. The first value is the first mark, and the last value is the last mark.



There are two differences between the raw buffers for sending and for receiving. The send buffer values are in microseconds, while the receive buffer values are in 50 microsecond ticks. The send buffer starts with the duration of the first mark, while the receive buffer starts with the duration of the gap space before the first mark. The formats are different because I considered it useful for the library to measure gaps between transmissions, but not useful for the library to provide these gaps when transmitting. For receiving, 50us granularity is sufficient for decoding and avoids overflow of the gaps, while for transmitting, 50us granularity is more than 10% error so 1us granularity seemed better.

看专家的翻译:
http://www.geek-workshop.com/thread-3574-1-1.html

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-20 23:05:19 | 显示全部楼层
学长 发表于 2013-6-18 21:23
期待你的测试结果哦... 加油

测试暂时不成功。先找来原始的网站翻翻,看看原理。
回复 支持 反对

使用道具 举报

发表于 2013-6-21 02:24:24 | 显示全部楼层
家里用的长虹空调,貌似解码不了,求楼主指导
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-21 08:47:45 | 显示全部楼层
把自己dump出来的open编码跟可以使用的正确的编码做了下对比
{4400,4450,550,1600,550,550,550,1650,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,1650,500,550,550,1650,550,550,500,
{4397,4368,561,1578,560,537,557,1581,584,1582,584,486,558,537,584,1554,560,538,558,510,558,1607,557,513,585,511,556,1585,581,1583,583,486,557,1609,556,513,558,
到37位之前都很类似(自己dump出来的第一个数字去掉后)..准备做更多研究。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-21 08:49:57 | 显示全部楼层
啷哩个铛 发表于 2013-6-21 02:24
家里用的长虹空调,貌似解码不了,求楼主指导

指导不了,自己还没有搞明白呢。
回复 支持 反对

使用道具 举报

发表于 2013-6-21 09:32:29 | 显示全部楼层
搞个35块钱的山寨分析仪测一下,分析起来会容易很多

建议RAWBUF尽量改大点,留点余量
回复 支持 反对

使用道具 举报

发表于 2013-6-21 12:07:35 | 显示全部楼层
histamine 发表于 2013-6-21 09:32
搞个35块钱的山寨分析仪测一下,分析起来会容易很多

建议RAWBUF尽量改大点,留点余量

请教下 我最近想买分析仪 配合 USBee Pro 那种的,请问你用的是哪一种的?谢谢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-6-24 14:12:04 | 显示全部楼层
学长 发表于 2013-6-21 12:07
请教下 我最近想买分析仪 配合 USBee Pro 那种的,请问你用的是哪一种的?谢谢

我用的¥168的那种,可以分析到24Mhz的。(貌似¥35的那种也一样用)

分析出红外编码后,通过sendRaw发送出去,成功控制空调了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-27 03:18 , Processed in 0.071417 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表