Matrix - Compact Kit

From FriendlyELEC WiKi
Revision as of 03:16, 19 June 2016 by Yftan (Talk | contribs) (编译运行测试程序)

Jump to: navigation, search

查看中文

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

Please 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

程序会显示出系统的基本信息,效果如下:
st7735s-status

5 代码说明

所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-compact_kit,内容如下:

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;
}

API说明参考维基:Matrix API reference manual

6 通过Python控制

使用的Python版本为2.7.9。
克隆Matrix配件Python相关的库之前,需要先确保你的板可正常上网,并且已经安装好git;接着执行以下步骤安装Python相关的库文件

$ apt-get install Python-dev libi2c-dev

在开发板Debian系统上克隆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
$ modprobe pcf8591
$ 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

通过改变开发板的朝向可以获得不同的方向值。


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