Difference between revisions of "Matrix - Compact Kit"
(→测试温度传感器) |
(→测试红外接收头) |
||
Line 259: | Line 259: | ||
[[File:matrix-temperature_sensor_result.png|frameless|600px|matrix-temperature_sensor_result]] | [[File:matrix-temperature_sensor_result.png|frameless|600px|matrix-temperature_sensor_result]] | ||
− | === | + | ===Test IR Receiver=== |
− | + | Please refer to the following connection diagram to connect the Matrix-Compact_Kit to the VS1833B IR receiver:<br> | |
[[File:Matrix-Compact_Kit_vs1833b.jpg|frameless|600px|Matrix-Compact_Kit_vs1833b]] | [[File:Matrix-Compact_Kit_vs1833b.jpg|frameless|600px|Matrix-Compact_Kit_vs1833b]] | ||
− | + | Please run the following commands: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ cd /modules | $ cd /modules | ||
$ insmod matrix_ir_recv.ko gpio=92 | $ insmod matrix_ir_recv.ko gpio=92 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | gpio= | + | gpio=92 means pin GPIOC28 is used. 92 is the index number in LINUX.<br> |
− | + | After the driver is successfully loaded a device node will be generated under /dev/input/. We assume it is event1 in our example.<br> | |
− | + | An open source utility "input-utils" can be used to read a device's data. Here is how to do it:<br> | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ apt-get install input-utils | $ apt-get install input-utils | ||
$ input-events 1 | $ input-events 1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 1 stands for device node event1。<br> | |
− | + | If you send data to the IR receiver with a remote control you will be able to see this:<br> | |
[[File:matrix-ir_receiver_result.png|frameless|600px|matrix-ir_receiver_result]] | [[File:matrix-ir_receiver_result.png|frameless|600px|matrix-ir_receiver_result]] | ||
Revision as of 11:00, 17 February 2016
Contents
1 Introduction
- The Matrix-Compact Kit is a compact board with various hardware resources, interfaces and ports including user keys, LED, buzzer, ADC, compass, temperature sensor, IR receiver, TFT port and etc. This board can be connected to the NanoPi, NanoPi 2 and Raspberry Pi via its 40 pin header. In addition you can connect other external modules to its GPIOs.
2 Features
Matrix - Compact Kit has the following onboard resources:
- 0.9 TFT LCD
- 3 x tact switch
- 4 x 5mm LED
- Buzzer
- ADC
- Sliding rheostat
- 40 pin female connector
- 4 pin header - I2C interface
- 4 pin header - UART interface
- 3 pin double row pin-header - 3.3V and GND
- 18B20 temperature sensor
- IR receiver
- 10 x 3 pin header - 3 x AIO, 7 x DIO (two of them can be configured to PWM and four of them can be configured to SPI)
- Compass
3 Dimensional Diagram and Pin Description
- PCB Dimension(mm):
- 40 pin female connector's pin description
Pin# Name Pin# Name 1 VDD_SYS_3.3V 2 VDD_5V 3 I2C0_SDA 4 VDD_5V 5 I2C0_SCL 6 DGND 7 GPIOB28 8 UART3_TXD 9 DGND 10 UART3_RXD 11 GPIOB29 12 GPIOB26 13 GPIOB30 14 DGND 15 GPIOB31 16 PWM2 17 VDD_SYS_3.3V 18 GPIOB27 19 SPI0_MOSI 20 DGND 21 SPI0_MISO 22 PWM0 23 SPI0_CLK 24 SPI0_CS 25 DGND 26 PWM1 27 I2C1_SDA 28 I2C1_SCL 29 GPIOC8 30 DGND 31 SPI2_CLK 32 GPIOC28 33 SPI2_CS 34 DGND 35 SPI2_MOSI 36 GPIOC7 37 SPI2_MISO 38 ALIVEGPIO2 39 DGND 40 ALIVEGPIO3
- 30 pin header's pin description
Ch# G Ch# V Ch# S 1 GND 2 VDD_5V 3 A1_PCF 4 GND 5 VDD_5V 6 A2_PCF 7 GND 8 VDD_5V 9 A3_PCF 10 GND 11 VDD_5V 12 D1_Pi11 13 GND 14 VDD_5V 15 D2_Pi26 16 GND 17 VDD_5V 18 D3_Pi16 19 GND 20 VDD_5V 21 D4_Pi19 22 GND 23 VDD_5V 24 D5_Pi21 25 GND 26 VDD_5V 27 D6_Pi23 28 GND 29 VDD_5V 30 D7_Pi24
- 18B20 and IR receiver's pin description
Pin# Name Pin# Name Pin# Name 1 VDD_5V 2 DATA 3 GND 1 DATA 2 GND 3 VDD_5V
4 Download Matrix Source Code
All the matrix modules' code samples are open source. They are maintained on GitHub: https://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 https://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 Connect to NanoPi 2
5.1 Hardware Connection
Please refer to the following connection diagram to connect the Matrix-Compact_Kit to the NanoPi 2:
5.2 Compile Test Program
Please login the matrix hub and enter the nanopi2 branch
$ cd matrix $ git checkout nanopi2
Compile the Matrix code
$ make CROSS_COMPILE=arm-linux- clean $ make CROSS_COMPILE=arm-linux- $ make CROSS_COMPILE=arm-linux- install
Note: please make sure to install the cross compiler "arm-linux-gcc-4.9.3" on your PC, which is used to compile files for the NanoPi 2.
Generated library files are under the "install/lib" directory. The test program is under the "install/usr/bin" directory. The modules are under the "modules" directory
5.3 Copy Test Program
Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.
We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the module, library and test program to the card
$ cp modules /media/rootfs/ -r $ cp install/lib/* /media/rootfs/lib/ -d $ cp install/usr/bin/* /media/rootfs/usr/bin/
5.4 Test LCD
Insert this TF card to your NanoPi 2, power on and run the following commands.
$ cd /modules $ insmod fbtft_device.ko name=matrix-st7735s gpios=dc:58,reset:63,cs:59 $ sudo FRAMEBUFFER=/dev/fb-st7735s startx &
"fbtft_device" is the LCD's driver.After it is loaded the LCD will be initialized.
"startx" sets the LCD to the output device. Here is what you should expect:
5.5 Access LED
LED | CPU GPIO | linux ID |
LED1 | GPIOC10 | 74 |
LED2 | GPIOC9 | 73 |
LED3 | GPIOC11 | 75 |
LED4 | GPIOC12 | 76 |
We took LED1 as an example. Please run the following commands to access LED1:
$ cd /sys/class/gpio/ $ echo 74 > export $ echo out > gpio74/direction $ echo 1 > gpio74/value
1 indicates LED on and 0 indicates LED1 off.
5.6 Test Key
Key | CPU GPIO | linux ID |
KEY1 | GPIOC7 | 71 |
KEY2 | ALIVEGPIO2 | 162 |
KEY3 | ALIVEGPIO3 | 163 |
We took KEY1 as an example. Running the following commands reads its value:
$ cd /sys/class/gpio/ $ echo 71 > export $ echo in > gpio71/direction $ cat gpio71/value
After you press KEY1 the value will be 0. After it is released the value will be 1.
5.7 Test AD
Please run the following command to get Channel 0's value:
$ matrix-adc
When you turn the resistor the AD value will be changing. Here is what you should expect:
5.8 Test Compass
Please run the following command to activate the compass:
$ matrix-compass
When you change the module's directon you will get a changing value. Here is what you should expect:
5.9 Test Temperature Sensor
Please refer to the following connection diagram to connect the Matrix-Compact_Kit to the DS18B20 temperature sensor:
Please run the following commands:
$ cd /modules $ insmod w1-gpio.ko $ insmod w1_gpio_board gpio=72 $ matrix-temp_sensor
gpio=92 means pin GPIOC8 is used. 72 is the index number in LINUX.
Here is what you should expect:
5.10 Test IR Receiver
Please refer to the following connection diagram to connect the Matrix-Compact_Kit to the VS1833B IR receiver:
Please run the following commands:
$ cd /modules $ insmod matrix_ir_recv.ko gpio=92
gpio=92 means pin GPIOC28 is used. 92 is the index number in LINUX.
After the driver is successfully loaded a device node will be generated under /dev/input/. We assume it is event1 in our example.
An open source utility "input-utils" can be used to read a device's data. Here is how to do it:
$ apt-get install input-utils $ input-events 1
1 stands for device node event1。
If you send data to the IR receiver with a remote control you will be able to see this:
5.11 通过Python控制
使用的Python版本为2.7.9。
在NanoPi2上直接克隆Matrix配件Python相关的代码仓库
$ git clone https://github.com/friendlyarm/matrix-python.git
克隆完成后会得到一个名为matrix-python的目录。
控制LED:
$ cd matrix-python/Matrix.GPIO $ python setup.py install $ python test/matrix_output.py 33
可以看到红色LED闪烁了一下。
读按键KEY1:
$ cd matrix-python/Matrix.GPIO $ python setup.py install $ python test/matrix_input.py 36
当KEY1按下时value=0,KEY1弹起时value=1。
测试AD转换:
$ cd matrix-python/modules $ insmod pcf8591.ko $ cd ../Matrix.pcf8591 $ python setup.py install $ python test/matrix_adc.py
通过旋转可调电阻可以改变AD转换值。
测试指南针:
$ cd matrix-python/Matrix.I2C $ python setup.py install $ python test/matrix_compass.py
通过改变开发板的朝向可以获得不同的方向值。
6 Connect to NanoPi
7 Connect to Tiny4412
8 Connect to RaspberryPi
9 Connect to Arduino
10 Resources
- [Schematic](Matrix - Compact Kit-Schematic.pdf)