Difference between revisions of "Matrix - Compact Kit"

From FriendlyELEC WiKi
Jump to: navigation, search
(特性)
(Applications)
 
(7 intermediate revisions by the same user not shown)
Line 95: Line 95:
 
|}
 
|}
  
==硬件连接==
+
==Applications==
===连接NanoPi 2===
+
===Connect to NanoPi 2===
参考下图连接模块:<br>
+
Refer to the following connection diagram to connect the module to the NanoPi 2:<br>
 
[[File:Matrix-Compact_Kit_nanopi2.jpg|frameless|600px|Matrix-Compact_Kit_nanopi2]]
 
[[File:Matrix-Compact_Kit_nanopi2.jpg|frameless|600px|Matrix-Compact_Kit_nanopi2]]
  
==编译运行测试程序==
+
==Compile & Run Test Program==
启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库:
+
Boot your ARM board with Debian and copy the matrix code:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ apt-get update && apt-get install git
 
$ apt-get update && apt-get install git
 
$ git clone https://github.com/friendlyarm/matrix.git
 
$ git clone https://github.com/friendlyarm/matrix.git
 
</syntaxhighlight>
 
</syntaxhighlight>
克隆完成后会得到一个名为matrix的目录。
+
If your cloning is done successfully a "matrix" directory will be generated.
  
编译并安装Matrix:
+
Compile and install Matrix:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cd matrix
 
$ cd matrix
Line 114: Line 114:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
运行测试程序:
+
Run test program:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ matrix-compact_kit
 
$ matrix-compact_kit
 
</syntaxhighlight>
 
</syntaxhighlight>
注意:此模块并不支持热插拔,启动系统前需要确保硬件连接正确。<br>
+
Note: this module is not plug and play therefore before running the module please make sure it is connected to an ARM board.<br>
运行效果如下:<br>
+
Here is what you should observe:<br>
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
LED blinking 1
 
LED blinking 1
Line 130: Line 130:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
运行Qt程序,测试TFT屏:
+
Run Qt program to test the TFT LCD:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd matrix/demo/nanopi-status
 
cd matrix/demo/nanopi-status
Line 136: Line 136:
 
./run.sh /dev/fb-st7735s
 
./run.sh /dev/fb-st7735s
 
</syntaxhighlight>
 
</syntaxhighlight>
程序会显示出系统的基本信息,效果如下:<br>
+
The program will present the system's basic information:<br>
 
[[File:st7735s-status.pnc|frameless|600px|st7735s-status]]
 
[[File:st7735s-status.pnc|frameless|600px|st7735s-status]]
  
==代码说明==
+
==Code Sample==
所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-compact_kit,内容如下:
+
This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-compact_kit". Here is its source code:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
int main(int argc, char ** argv)
 
int main(int argc, char ** argv)
Line 161: Line 161:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
API说明参考维基:[[Matrix API reference manual/zh|Matrix API reference manual]] <br>
+
For more details about this APIs called in this code sample refer to [[Matrix API reference manual]] <br>
  
==通过Python控制==
+
==Code Samples in Python==
使用的Python版本为2.7.9。<br>
+
The Python version is 2.7.9 in the following samples<br>
克隆Matrix配件Python相关的库之前,需要先确保你的板可正常上网,并且已经安装好git;接着执行以下步骤安装Python相关的库文件
+
Install the Python libraries and modules:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ apt-get install Python-dev libi2c-dev  
 
$ apt-get install Python-dev libi2c-dev  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
在开发板Debian系统上克隆matrix-python仓库:
+
The python code is in our github:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ git clone https://github.com/friendlyarm/matrix-python.git
 
$ git clone https://github.com/friendlyarm/matrix-python.git
 
</syntaxhighlight>
 
</syntaxhighlight>
克隆完成后会得到一个名为matrix-python的目录。
+
After it is done a matrix-python directory will be generated.
  
控制LED:
+
Access LED:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cd matrix-python/Matrix.GPIO
 
$ cd matrix-python/Matrix.GPIO
Line 182: Line 182:
 
$ python test/matrix_output.py 33
 
$ python test/matrix_output.py 33
 
</syntaxhighlight>
 
</syntaxhighlight>
可以看到红色LED闪烁了一下。
+
The red LED will be flashing.
  
读按键KEY1:
+
Read KEY1:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cd matrix-python/Matrix.GPIO
 
$ cd matrix-python/Matrix.GPIO
Line 190: Line 190:
 
$ python test/matrix_input.py 36
 
$ python test/matrix_input.py 36
 
</syntaxhighlight>
 
</syntaxhighlight>
当KEY1按下时value=0,KEY1弹起时value=1。
+
When you press KEY1 "value" will be set to 0. When you release KEY1 "value" will be set to 1.
  
测试AD转换:
+
Test AD:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cd matrix-python/modules
 
$ cd matrix-python/modules
Line 200: Line 200:
 
$ python test/matrix_adc.py
 
$ python test/matrix_adc.py
 
</syntaxhighlight>
 
</syntaxhighlight>
通过旋转可调电阻可以改变AD转换值。
+
When you change the resistor AD value will be changed accordingly.
  
测试指南针:
+
Test Compass:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ cd matrix-python/Matrix.I2C
 
$ cd matrix-python/Matrix.I2C
Line 208: Line 208:
 
$ python test/matrix_compass.py
 
$ python test/matrix_compass.py
 
</syntaxhighlight>
 
</syntaxhighlight>
通过改变开发板的朝向可以获得不同的方向值。
+
When you rotate the compass you will get changing direction values.
  
 
<!---
 
<!---
Line 563: Line 563:
 
===Mar-29-2016===
 
===Mar-29-2016===
 
* Corrected expression errors
 
* Corrected expression errors
 +
 +
===June-19-2016===
 +
* Re-organized and simplified wiki

Latest revision as of 10:32, 19 June 2016

查看中文

1 Introduction

Matrix-Compact Kit.png
  • The Matrix-Compact Kit is a compact board with various hardware resources, interfaces and ports. It includes 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

  • PCB Dimension(mm):

Matrix-Compact Kit PCB.png

Matrix-Compact_Kit Layout
  • 40pin female connector's GPIO Pin Spec
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
Matrix-Compact_Kit Layout
  • 30pin Pin Spec
Pin# Name Pin# Name Pin# Name
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 & IR Receiver Layout
  • 18B20 & IR Receiver Pin Spec
Module Pin# Name Pin# Name Pin# Name
18B20 1 VDD_5V 2 DATA 3 GND
IR Receiver 1 DATA 2 GND 3 VDD_5V

3 Applications

3.1 Connect to NanoPi 2

Refer to the following connection diagram to connect the module to the NanoPi 2:
Matrix-Compact_Kit_nanopi2

4 Compile & Run Test Program

Boot your ARM board with Debian and copy the matrix code:

$ apt-get update && apt-get install git
$ git clone https://github.com/friendlyarm/matrix.git

If your cloning is done successfully a "matrix" directory will be generated.

Compile and install Matrix:

$ cd matrix
$ make && make install

Run test program:

$ matrix-compact_kit

Note: this module is not plug and play therefore before running the module please make sure it is connected to an ARM board.
Here is what you should observe:

LED blinking 1
LED blinking 2
Button:  1 1 1
ADC channel0: 550
Compass angle: 328.5
Pwm start
Pwm stop

Run Qt program to test the TFT LCD:

cd matrix/demo/nanopi-status
./build.sh
./run.sh /dev/fb-st7735s

The program will present the system's basic information:
st7735s-status

5 Code Sample

This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-compact_kit". Here is its source code:

int main(int argc, char ** argv)
{
    int board;
 
    if ((board = boardInit()) < 0) {
        printf("Fail to init board\n");
        return -1;
    }
    testLED(board);
    readButton();
    readADC();
    readCompass();
    testPWM(board);
    // readTemp();
    // testIR();
 
    return 0;
}

For more details about this APIs called in this code sample refer to Matrix API reference manual

6 Code Samples in Python

The Python version is 2.7.9 in the following samples
Install the Python libraries and modules:

$ apt-get install Python-dev libi2c-dev

The python code is in our github:

$ git clone https://github.com/friendlyarm/matrix-python.git

After it is done a matrix-python directory will be generated.

Access LED:

$ cd matrix-python/Matrix.GPIO
$ python setup.py install
$ python test/matrix_output.py 33

The red LED will be flashing.

Read KEY1:

$ cd matrix-python/Matrix.GPIO
$ python setup.py install
$ python test/matrix_input.py 36

When you press KEY1 "value" will be set to 0. When you release KEY1 "value" will be set to 1.

Test AD:

$ cd matrix-python/modules
$ modprobe pcf8591
$ cd ../Matrix.pcf8591
$ python setup.py install
$ python test/matrix_adc.py

When you change the resistor AD value will be changed accordingly.

Test Compass:

$ cd matrix-python/Matrix.I2C
$ python setup.py install
$ python test/matrix_compass.py

When you rotate the compass you will get changing direction values.


7 Resources

8 Update Log

8.1 Feb-17-2016

  • Added 5.9, 5.10 and 5.11

8.2 Feb-24-2016

  • Added the driver's source code location in Section 5.2

8.3 Mar-21-2016

  • Corrected typo in Section 5.9
  • Added lib installation steps in Section 5.11

8.4 Mar-29-2016

  • Corrected expression errors

8.5 June-19-2016

  • Re-organized and simplified wiki