Difference between revisions of "Matrix - IR Receiver"
(Replaced content with "查看中文") |
|||
Line 1: | Line 1: | ||
[[Matrix - IR Receiver/zh|查看中文]] | [[Matrix - IR Receiver/zh|查看中文]] | ||
+ | |||
+ | ==Introduction== | ||
+ | [[File:IR Receiver01.png|thumb|IR Receiver]] | ||
+ | *Matrix-IR Receiver是38KHz红外接收模块,主要器件是一个红外接收头,可接收标准38KHz调制的遥控器信号,并放大和滤波输出,通过MCU编程,即可实现对遥控器信号的解码操作。 | ||
+ | *接收范围:12-13米 | ||
+ | |||
+ | ==Features== | ||
+ | * GPIO control, 3.3/5V | ||
+ | * Small | ||
+ | * 2.54mm spacing pin header | ||
+ | * PCB Dimension(mm): 8 x 24 | ||
+ | [[File:IR Receiver.png | frameless|400px|IR Receiver.PCB]] | ||
+ | |||
+ | * Pin Description: | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | |Pin || Description | ||
+ | |- | ||
+ | |S || GPIO | ||
+ | |- | ||
+ | |V || Supply Voltage 5V | ||
+ | |- | ||
+ | |G || Ground | ||
+ | |} | ||
+ | |||
+ | ==Basic Device Operation== | ||
+ | *红外接收头内部包括红外监测二极管、放大器、限副器、带通滤波器、积分电路、比较器等。红外监测二极管检测到红外信号,然后把信号送到放大器和限幅器,限幅器把脉冲幅度控制在一定的水平,而不论红外发射器和接收器的距离远近。交流信号进入带通滤波器(带通滤波器可以通过30khz到60khz的负载波),再通过解调电路和积分电路进入比较器,比较器输出高低电平,还原出发射端的信号波形。 | ||
+ | *注意:输出的高低电平和发射端是反相的,这样的目的是为了提高接收的灵敏度。 | ||
+ | |||
+ | ==Download Matrix Source Code== | ||
+ | |||
+ | All the matrix modules' code samples are open source. They are maintained on GitHub: git://github.com/friendlyarm/matrix.git <br> | ||
+ | Each branch in this hub contains the matrix modules' code samples for a board that the matrix modules can work with.<br> | ||
+ | * The matrix-nanopi branch contains the matrix modules' code samples for the NanoPi | ||
+ | * The matrix-nanopi2 branch contains the matrix modules' code samples for the NanoPi 2 | ||
+ | * The matrix-tiny4412 branch contains the matrix modules' code samples for the Tiny4412; | ||
+ | * The matrix-raspberrypi branch contains the matrix modules' code samples for the RaspberryPi; | ||
+ | |||
+ | Please follow the steps below to get the source code:<br> | ||
+ | Install the git utility on a PC running Ubuntu14.04 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ sudo apt-get install git | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Clone the matrix code from GitHub | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ git clone git://github.com/friendlyarm/matrix.git | ||
+ | </syntaxhighlight> | ||
+ | If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples. | ||
+ | |||
+ | ==与NanoPi 2连接使用== | ||
+ | ===硬件连接=== | ||
+ | 参考下图连接模块Matrix-IR_Receiver和NanoPi 2:<br> | ||
+ | [[File:Matrix-IR_Receiver_nanopi_2.jpg|frameless|600px|Matrix-IR_Receiver_nanopi_2]] | ||
+ | |||
+ | 连接说明: | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | |Matrix-IR_Receiver || NanoPi 2 | ||
+ | |- | ||
+ | |S || Pin7 | ||
+ | |- | ||
+ | |V || Pin4 | ||
+ | |- | ||
+ | |G || Pin6 | ||
+ | |} | ||
+ | |||
+ | ===编译测试程序=== | ||
+ | 进入Matrix代码仓库,切换到nanopi2分支 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cd matrix | ||
+ | $ git checkout nanopi2 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 编译Matrix配件代码 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ make CROSS_COMPILE=arm-linux- clean | ||
+ | $ make CROSS_COMPILE=arm-linux- | ||
+ | $ make CROSS_COMPILE=arm-linux- install | ||
+ | </syntaxhighlight> | ||
+ | 注意:请确保你的主机PC当前使用的交叉编译器为NanoPi 2配套的arm-linux-gcc-4.9.3。<br> | ||
+ | 编译成功后库文件位于install/lib目录下,而测试程序则位于install/usr/bin目录下。<br> | ||
+ | |||
+ | ===运行测试程序=== | ||
+ | 将带有Debian系统的SD卡插入一台运行Linux的电脑,可以挂载SD卡上的boot和rootfs分区。<br> | ||
+ | 假设rootfs分区的挂载路径为/media/rootfs,执行以下命令将Matrix的硬件驱动、库文件和测试程序拷贝到NanoPi 2的文件系统上。<br> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cp modules /media/rootfs/ -r | ||
+ | $ cp install/lib/* /media/rootfs/lib/ -d | ||
+ | $ cp install/usr/bin/* /media/rootfs/usr/bin/ | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 将SD卡重新插入NanoPi 2,上电启动,在Debian的shell终端中执行以下命令加载硬件驱动。<br> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cd /modules | ||
+ | $ insmod matrix_ir_recv.ko | ||
+ | </syntaxhighlight> | ||
+ | 成功加载驱动后,会在/dev/input/目录下生成一个event设备节点,这里假设生成的设备节点为event1。<br> | ||
+ | |||
+ | 开源软件input-utils可以读取event设备的数据,它的使用方法如下:<br> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ apt-get install input-utils | ||
+ | $ input-events 1 | ||
+ | </syntaxhighlight> | ||
+ | 1表示读设备节点event1。<br> | ||
+ | |||
+ | 用一个普通的遥控器往模块发送数据,可看到运行效果如下:<br> | ||
+ | [[File:matrix-ir_receiver_result.png|frameless|600px|matrix-ir_receiver_result]] | ||
+ | |||
+ | |||
+ | ==与NanoPi连接使用== | ||
+ | |||
+ | ==与Tiny4412连接使用== | ||
+ | |||
+ | ==与RaspberryPi连接使用== | ||
+ | |||
+ | ==与Arduino连接使用== | ||
+ | |||
+ | ==相关资料== |
Revision as of 10:53, 25 December 2015
Contents
1 Introduction
- Matrix-IR Receiver是38KHz红外接收模块,主要器件是一个红外接收头,可接收标准38KHz调制的遥控器信号,并放大和滤波输出,通过MCU编程,即可实现对遥控器信号的解码操作。
- 接收范围:12-13米
2 Features
- GPIO control, 3.3/5V
- Small
- 2.54mm spacing pin header
- PCB Dimension(mm): 8 x 24
- Pin Description:
Pin | Description |
S | GPIO |
V | Supply Voltage 5V |
G | Ground |
3 Basic Device Operation
- 红外接收头内部包括红外监测二极管、放大器、限副器、带通滤波器、积分电路、比较器等。红外监测二极管检测到红外信号,然后把信号送到放大器和限幅器,限幅器把脉冲幅度控制在一定的水平,而不论红外发射器和接收器的距离远近。交流信号进入带通滤波器(带通滤波器可以通过30khz到60khz的负载波),再通过解调电路和积分电路进入比较器,比较器输出高低电平,还原出发射端的信号波形。
- 注意:输出的高低电平和发射端是反相的,这样的目的是为了提高接收的灵敏度。
4 Download Matrix Source Code
All the matrix modules' code samples are open source. They are maintained on GitHub: git://github.com/friendlyarm/matrix.git
Each branch in this hub contains the matrix modules' code samples for a board that the matrix modules can work with.
- The matrix-nanopi branch contains the matrix modules' code samples for the NanoPi
- The matrix-nanopi2 branch contains the matrix modules' code samples for the NanoPi 2
- The matrix-tiny4412 branch contains the matrix modules' code samples for the Tiny4412;
- The matrix-raspberrypi branch contains the matrix modules' code samples for the RaspberryPi;
Please follow the steps below to get the source code:
Install the git utility on a PC running Ubuntu14.04
$ sudo apt-get install git
Clone the matrix code from GitHub
$ git clone git://github.com/friendlyarm/matrix.git
If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples.
5 与NanoPi 2连接使用
5.1 硬件连接
参考下图连接模块Matrix-IR_Receiver和NanoPi 2:
连接说明:
Matrix-IR_Receiver | NanoPi 2 |
S | Pin7 |
V | Pin4 |
G | Pin6 |
5.2 编译测试程序
进入Matrix代码仓库,切换到nanopi2分支
$ cd matrix $ git checkout nanopi2
编译Matrix配件代码
$ make CROSS_COMPILE=arm-linux- clean $ make CROSS_COMPILE=arm-linux- $ make CROSS_COMPILE=arm-linux- install
注意:请确保你的主机PC当前使用的交叉编译器为NanoPi 2配套的arm-linux-gcc-4.9.3。
编译成功后库文件位于install/lib目录下,而测试程序则位于install/usr/bin目录下。
5.3 运行测试程序
将带有Debian系统的SD卡插入一台运行Linux的电脑,可以挂载SD卡上的boot和rootfs分区。
假设rootfs分区的挂载路径为/media/rootfs,执行以下命令将Matrix的硬件驱动、库文件和测试程序拷贝到NanoPi 2的文件系统上。
$ cp modules /media/rootfs/ -r $ cp install/lib/* /media/rootfs/lib/ -d $ cp install/usr/bin/* /media/rootfs/usr/bin/
将SD卡重新插入NanoPi 2,上电启动,在Debian的shell终端中执行以下命令加载硬件驱动。
$ cd /modules $ insmod matrix_ir_recv.ko
成功加载驱动后,会在/dev/input/目录下生成一个event设备节点,这里假设生成的设备节点为event1。
开源软件input-utils可以读取event设备的数据,它的使用方法如下:
$ apt-get install input-utils $ input-events 1
1表示读设备节点event1。