紅外線遙控原理

转自:http://coopermaa2nd.blogspot.com/2010/01/nec-ir-protocol.html

和http://www.sbprojects.com/knowledge/ir/nec.php

紅外線遙控原理

紅外線是目前最常見的一種無線通訊,普遍使用在家電以及玩具產品,如電視、音響、錄放影機、冷氣機、DVD、MP3 Player、遙控車等。紅外線遙控之所以被大量採使用,主要是因為紅外線裝置體積小、成本低、耗電少及硬體設計容易。下圖是紅外線發射器 (Transmitter 或稱 IR LED) 和接收器 (Receiver) 常見外觀,一般來說,紅外線遙控系統由發射器和接收器這兩部份組成。

image

紅外線是不可見光,其實生活中充滿了紅外線,只是我們看不到。紅外線主要來自太陽,不過很多物體也會發射紅外線,例如燈泡、蠟燭、中央空調等,甚至人體也會散發紅外線。人體所發出的紅外線的量是可以偵測的,耳溫槍就是利用這個道理測量人的體溫。有這麼多紅外線光源,當然會對遙控造成干擾,所以得做一些預防措施確保通訊正確。

image003

避免干擾的解藥是 Modulation。我們講話速度若適當,不徐不急,聽得舒服,聽者自然不漏接。相同的道理,利用 Modulation 讓 IR LED 以特定的頻率閃爍,Receiver 端也調整到同樣的頻率,便可以忽略干擾。在上圖中,可以看到調變訊號 (Modulated signal)在驅動 IR LED 發射訊號,而偵測到的訊號則從右手邊的 receiver 跑出來。

在 Serial 通訊中常會提到 mark 和 space 狀態。space 是紅外線的預設訊號,Transmitter 處於 off 狀態,這時 IR LED 不會發射光亮;而在 mark 狀態 IR LED 會以特定的頻率送出 on/off 脈衝 (Pulse)。消費電子一般使用 30kHz 到 60kHz 的頻率。

兩點注意事項:

  1. 因為 Receiver 會把訊號反向,所以從 Receiver 這端來看,space 意味著 high level 訊號輸出,而 mark 則是 low level 訊號輸出。
  2. 要特別注意 mark 跟 space 並非我們要傳輸的 1 與 0 數位訊號。mark 跟 space 以及 1 與 0 之間的關係是由所用的 protocol 決定的。目前 IR Protocol 有相當多種,如 NEC, Phlips RC5, RC6, RC-MM, Toshiba, Sharp, JVC, Sony SIRC 等。
NEC IR Protocol
Features

NEC format 特點摘要如下,詳細後述:

  • 8-bit Custom Code 與 8-bit Data Code
  • 38kHz 的 Carrier freqeuncy
  • 使用 PPM (Pulse Position Modulation)
  • Bit time 為 1.125ms 和 2.25ms
Protocol

如下圖,NEC format 由 Leader code, 8-bit Custom Code, 8-bit Data Code 組成。Leader code 包含 9ms 載波 (carrier waveform) 和 4.5ms 的 OFF waveform。Custom Code 和 Data Code 各傳輸兩次,第二次是反向後的結果,目的是讓 Receiver 驗證資料。如果不在乎可靠性,可以不要做反相,Custom Code 和 Data Code 便可以擴展成為 16-bit。

image

Bit data format:

  • 560us 的 Pulse 加上 1690us 的 space 共計 2.25ms 的波形代表 1
  • 560us 的 Pulse 加上 560us 的 space 共計 1.12ms 的波形代表 0

image

Pulse 係由很多 on/off 交替的訊號所組成:

  • Carrier frequency = 38kHz
  • duty factor = 1/3
  • period = 26.5us

image

按著遙控器按鈕不放,會發出連發指令。連發指令有兩種形式,一種是每次都發射送同樣的 code,好處是可以避免干擾,缺點是耗電。另一種是在送出正常指令的 code 後緊接著只傳送簡短的 Repeat code:

image

Repeat code 由 9ms 載波 (carrier waveform) 和 2.25ms 的 space 以及一個 560us Pulse 組成:

image



NEC Protocol

To my knowledge the protocol I describe here was developed by NEC. I've seen very similar protocol descriptions on the internet, and there the protocol is called Japanese Format. 
I do admit that I don't know exactly who developed it. What I do know is that it is used in my late VCR produced by Sanyo and was marketed under the name of Fisher. NEC manufactured the remote control IC. 
This description was taken from the VCR's service manual. Those were the days, when service manuals were fulled with useful information!

Features

  • 8 bit address and 8 bit command length
  • Address and command are transmitted twice for reliability
  • Pulse distance modulation
  • Carrier frequency of 38kHz
  • Bit time of 1.125ms or 2.25ms

Modulation

NEC ModulationThe NEC protocol uses pulse distance encoding of the bits. Each pulse is a 560µs long 38kHz carrier burst (about 21 cycles). A logical "1" takes 2.25ms to transmit, while a logical "0" is only half of that, being 1.125ms. The recommended carrier duty-cycle is 1/4 or 1/3. 

Protocol

NEC Pulse Train

The picture above shows a typical pulse train of the NEC protocol. With this protocol the LSB is transmitted first. In this case Address $59 and Command $16 is transmitted. A message is started by a 9ms AGC burst, which was used to set the gain of the earlier IR receivers. This AGC burst is then followed by a 4.5ms space, which is then followed by the Address and Command. Address and Command are transmitted twice. The second time all bits are inverted and can be used for verification of the received message. The total transmission time is constant because every bit is repeated with its inverted length. If you're not interested in this reliability you can ignore the inverted values, or you can expand the Address and Command to 16 bits each!

NEC Repeat

A command is transmitted only once, even when the key on the remote control remains pressed. Every 110ms a repeat code is transmitted for as long as the key remains down. This repeat code is simply a 9ms AGC pulse followed by a 2.25ms space and a 560µs burst.

NEC Sequence

Extended NEC protocol

The NEC protocol is so widely used that soon all possible addresses were used up. By sacrificing the address redundancy the address range was extended from 256 possible values to approximately 65000 different values. This way the address range was extended from 8 bits to 16 bits without changing any other property of the protocol. 
By extending the address range this way the total message time is no longer constant. It now depends on the total number of 1's and 0's in the message. If you want to keep the total message time constant you'll have to make sure the number 1's in the address field is 8 (it automatically means that the number of 0's is also 8). This will reduce the maximum number of different addresses to just about 13000.

The command redundancy is still preserved. Therefore each address can still handle 256 different commands.

Extended NEC protocol

Keep in mind that 256 address values of the extended protocol are invalid because they are in fact normal NEC protocol addresses. Whenever the low byte is the exact inverse of the high byte it is not a valid extended address.

External Links

NEC Electronics

Example Commands

The table below lists the messages sent by the remote control of my late Fisher 530 VCR (it served us well during its 20 years long life).

NEC Message Key Function
$68-$00 Play
$68-$01 Rec
$68-$02 Audio Dub
$68-$03 Frame Adv
$68-$04 Slow
$68-$05 Quick
$68-$06 Cue
$68-$07 Review
$68-$08 FF
$68-$09 Rew
$68-$0A Stop
$68-$0B Pause/Still
$68-$0C Up key
$68-$1E Down key

内容概要:本文介绍了基于贝叶斯优化的CNN-LSTM混合神经网络在时间序列预测中的应用,并提供了完整的Matlab代码实现。该模型结合了卷积神经网络(CNN)在特征提取方面的优势与长短期记忆网络(LSTM)在处理时序依赖问题上的强大能力,形成一种高效的混合预测架构。通过贝叶斯优化算法自动调参,提升了模型的预测精度与泛化能力,适用于风电、光伏、负荷、交通流等多种复杂非线性系统的预测任务。文中还展示了模型训练流程、参数优化机制及实际预测效果分析,突出其在科研与工程应用中的实用性。; 适合人群:具备一定机器学习基基于贝叶斯优化CNN-LSTM混合神经网络预测(Matlab代码实现)础和Matlab编程经验的高校研究生、科研人员及从事预测建模的工程技术人员,尤其适合关注深度学习与智能优化算法结合应用的研究者。; 使用场景及目标:①解决各类时间序列预测问题,如能源出力预测、电力负荷预测、环境数据预测等;②学习如何将CNN-LSTM模型与贝叶斯优化相结合,提升模型性能;③掌握Matlab环境下深度学习模型搭建与超参数自动优化的技术路线。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注贝叶斯优化模块与混合神经网络结构的设计逻辑,通过调整数据集和参数加深对模型工作机制的理解,同时可将其框架迁移至其他预测场景中验证效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值