Difference between revisions of "Matrix - Thermistor/zh"
(→与NanoPi M2连接使用) |
(→连接NanoPC-T2) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 28: | Line 28: | ||
*模块主要器件是一个热电阻温度传感器,热电阻的测温原理是基于导体或半导体的电阻值随着温度的变化而变化的特性,在电源激励下,输出端的分压也随之变化。 | *模块主要器件是一个热电阻温度传感器,热电阻的测温原理是基于导体或半导体的电阻值随着温度的变化而变化的特性,在电源激励下,输出端的分压也随之变化。 | ||
− | == | + | ==硬件连接== |
− | + | 模块Matrix-Thermistor输出的是模拟信号,需要使用ADC转换模块Matrix-Analog_to_Digital_Converter将模拟信号转换为数字信号。<br> | |
− | + | 关于模块Matrix-Analog_to_Digital_Converter的使用方法可参考wiki:[[Matrix_-_Analog_to_Digital_Converter/zh|Matrix-Analog_to_Digital_Converter]]。<br> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ===连接NanoPi NEO/NanoPi NEO Air=== | |
− | + | NanoPi M1和NanoPi NEO以及NanoPi NEO Air的前24Pin引脚定义是一模一样的,所以它们操作Matrix配件的步骤是一样的,并且使用同一份代码。<br> | |
− | + | ||
− | < | + | |
− | + | 参考下图连接模块:<br> | |
− | + | [[File:Matrix-Thermistor_nanopi_NEO.jpg|frameless|600px|Matrix-Thermistor_nanopi_NEO]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [[File:Matrix- | + | |
连接说明: | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | |Matrix- | + | |Matrix-Thermistor || |
|- | |- | ||
− | | | + | |GND || NanoPi NEO Pin9 |
|- | |- | ||
− | + | |5V || NanoPi NEO Pin2 | |
− | + | ||
− | |5V || | + | |
|- | |- | ||
− | | | + | |S || Matrix-Analog_to_Digital_Converter A0 |
|} | |} | ||
+ | ===连接NanoPi M1=== | ||
+ | 参考下图连接模块:<br> | ||
+ | [[File:Matrix-Thermistor_nanopi_m1.jpg|frameless|600px|Matrix-Thermistor_nanopi_m1]] | ||
+ | |||
+ | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
|Matrix-Thermistor || | |Matrix-Thermistor || | ||
|- | |- | ||
− | |GND || NanoPi | + | |GND || NanoPi M1 Pin9 |
|- | |- | ||
− | |5V || NanoPi | + | |5V || NanoPi M1 Pin2 |
|- | |- | ||
|S || Matrix-Analog_to_Digital_Converter A0 | |S || Matrix-Analog_to_Digital_Converter A0 | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | ===连接NanoPi 2=== |
− | + | 参考下图连接模块:<br> | |
− | + | [[File:Matrix-Thermistor_nanopi_2.jpg|frameless|600px|Matrix-Thermistor_nanopi_2]] | |
− | [[File:Matrix- | + | |
连接说明: | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | |Matrix- | + | |Matrix-Thermistor || |
|- | |- | ||
− | | | + | |GND || NanoPi 2 Pin9 |
|- | |- | ||
− | + | |5V || NanoPi 2 Pin2 | |
− | + | ||
− | |5V || | + | |
|- | |- | ||
− | | | + | |S || Matrix-Analog_to_Digital_Converter A0 |
|} | |} | ||
+ | ===连接NanoPi M2 / NanoPi 2 Fire=== | ||
+ | NanoPi M2和NanoPi 2 Fire的40 Pin引脚定义是一模一样的,所以它们操作Matrix配件的步骤是一样的,这里仅以NanoPi M2为例。<br> | ||
+ | 参考下图连接模块:<br> | ||
+ | [[File:Matrix-Thermistor_nanopi_m2.jpg|frameless|600px|Matrix-Thermistor_nanopi_m2]] | ||
+ | |||
+ | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 172: | Line 98: | ||
|S || Matrix-Analog_to_Digital_Converter A0 | |S || Matrix-Analog_to_Digital_Converter A0 | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | === | + | ===连接NanoPi M3=== |
− | + | 参考下图连接模块:<br> | |
− | + | [[File:Matrix-Thermistor_nanopi_m3.jpg|frameless|600px|Matrix-Thermistor_nanopi_m3]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [[File:Matrix- | + | |
连接说明: | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | |Matrix- | + | |Matrix-Thermistor || |
|- | |- | ||
− | | | + | |GND || NanoPi M3 Pin9 |
|- | |- | ||
− | + | |5V || NanoPi M3 Pin2 | |
− | + | ||
− | |5V || | + | |
|- | |- | ||
− | | | + | |S || Matrix-Analog_to_Digital_Converter A0 |
|} | |} | ||
+ | ===连接NanoPC-T2/NanoPC-T3=== | ||
+ | 由于NanoPC-T2跟NanoPC-T3的引脚是一样的,所以连接方式是一样的,这里仅以T2为例,参考下图连接模块:<br> | ||
+ | [[File:Matrix-Thermistor_NanoPC-T2.jpg|frameless|600px|Matrix-Thermistor_NanoPC-T2]] | ||
+ | |||
+ | 连接说明: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | |Matrix- | + | |Matrix-Potentiometer || |
|- | |- | ||
− | |GND || NanoPC-T2 | + | |GND || NanoPC-T2 USB Host GND |
|- | |- | ||
− | |5V || | + | |5V || NanoPC-T2 USB Host 5V |
|- | |- | ||
|S || Matrix-Analog_to_Digital_Converter A0 | |S || Matrix-Analog_to_Digital_Converter A0 | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | == | + | ==编译运行测试程序== |
− | + | 启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ apt-get update && apt-get install git |
− | $ git | + | $ git clone https://github.com/friendlyarm/matrix.git |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | 克隆完成后会得到一个名为matrix的目录。 | ||
− | + | 编译并安装Matrix: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ cd matrix |
− | $ make | + | $ make && make install |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | 运行测试程序: | |
− | + | ||
− | + | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ matrix-adc |
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 注意:此模块并不支持热插拔,启动系统前需要确保硬件连接正确。<br> | |
− | + | 运行效果如下:<br> | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | + | The channel0 value is 2460 | |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ==代码说明== | |
− | + | 所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-analog_to_digital_converter,内容如下: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
int main(int argc, char ** argv) | int main(int argc, char ** argv) | ||
Line 319: | Line 164: | ||
int channel = 0; | int channel = 0; | ||
− | if ( | + | if (boardInit() < 0) { |
− | + | printf("Fail to init board\n"); | |
+ | return -1; | ||
} | } | ||
+ | if (argc == 2) | ||
+ | channel = atoi(argv[1]); | ||
+ | system("modprobe "DRIVER_MODULE); | ||
+ | signal(SIGINT, intHandler); | ||
for (i=0; i<ADC_READ_TIMES; i++) { | for (i=0; i<ADC_READ_TIMES; i++) { | ||
if (pcf8591Read(channel, &value) != -1) { | if (pcf8591Read(channel, &value) != -1) { | ||
− | printf("channel%d value | + | printf("The channel%d value is %d\n", channel, value); |
} else { | } else { | ||
− | printf("Fail to get channel%d value\n", channel); | + | printf("Fail to get channel%d value\n", channel); |
} | } | ||
− | |||
} | } | ||
+ | system("rmmod "DRIVER_MODULE); | ||
+ | |||
return 0; | return 0; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | API说明参考维基:[[Matrix API reference manual/zh|Matrix API reference manual]] <br> | ||
+ | |||
+ | ==相关资料== |
Latest revision as of 09:00, 10 November 2016
Contents
1 介绍
- Matrix-Thermistor是一个模拟热敏电阻模块。3-Pin 2.54mm排针,V接电源,G接地,S信号输出模拟电压信号。您可以把S输出的电压信号通过ADC转换成数字信号,得到与北侧物体温度对应的电压值。
- 为提高测试的准确度,请把传感器与被测物体直接紧密接触。
2 特性
- GPIO,3.3/5V电平
- 体积小巧
- 2.54mm排针接口
- PCB尺寸(mm):8x24
- 引脚说明:
名称 | 描述 |
S | 模拟GPIO |
V | 电源5V |
G | 地 |
3 工作原理
- 模块主要器件是一个热电阻温度传感器,热电阻的测温原理是基于导体或半导体的电阻值随着温度的变化而变化的特性,在电源激励下,输出端的分压也随之变化。
4 硬件连接
模块Matrix-Thermistor输出的是模拟信号,需要使用ADC转换模块Matrix-Analog_to_Digital_Converter将模拟信号转换为数字信号。
关于模块Matrix-Analog_to_Digital_Converter的使用方法可参考wiki:Matrix-Analog_to_Digital_Converter。
4.1 连接NanoPi NEO/NanoPi NEO Air
NanoPi M1和NanoPi NEO以及NanoPi NEO Air的前24Pin引脚定义是一模一样的,所以它们操作Matrix配件的步骤是一样的,并且使用同一份代码。
参考下图连接模块:
Matrix-Thermistor_nanopi_NEO
连接说明:
Matrix-Thermistor | |
GND | NanoPi NEO Pin9 |
5V | NanoPi NEO Pin2 |
S | Matrix-Analog_to_Digital_Converter A0 |
4.2 连接NanoPi M1
连接说明:
Matrix-Thermistor | |
GND | NanoPi M1 Pin9 |
5V | NanoPi M1 Pin2 |
S | Matrix-Analog_to_Digital_Converter A0 |
4.3 连接NanoPi 2
参考下图连接模块:
Matrix-Thermistor_nanopi_2
连接说明:
Matrix-Thermistor | |
GND | NanoPi 2 Pin9 |
5V | NanoPi 2 Pin2 |
S | Matrix-Analog_to_Digital_Converter A0 |
4.4 连接NanoPi M2 / NanoPi 2 Fire
NanoPi M2和NanoPi 2 Fire的40 Pin引脚定义是一模一样的,所以它们操作Matrix配件的步骤是一样的,这里仅以NanoPi M2为例。
参考下图连接模块:
连接说明:
Matrix-Thermistor | |
GND | NanoPi M2 Pin9 |
5V | NanoPi M2 Pin2 |
S | Matrix-Analog_to_Digital_Converter A0 |
4.5 连接NanoPi M3
参考下图连接模块:
Matrix-Thermistor_nanopi_m3
连接说明:
Matrix-Thermistor | |
GND | NanoPi M3 Pin9 |
5V | NanoPi M3 Pin2 |
S | Matrix-Analog_to_Digital_Converter A0 |
4.6 连接NanoPC-T2/NanoPC-T3
由于NanoPC-T2跟NanoPC-T3的引脚是一样的,所以连接方式是一样的,这里仅以T2为例,参考下图连接模块:
Matrix-Thermistor_NanoPC-T2
连接说明:
Matrix-Potentiometer | |
GND | NanoPC-T2 USB Host GND |
5V | NanoPC-T2 USB Host 5V |
S | Matrix-Analog_to_Digital_Converter A0 |
5 编译运行测试程序
启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库:
$ apt-get update && apt-get install git $ git clone https://github.com/friendlyarm/matrix.git
克隆完成后会得到一个名为matrix的目录。
编译并安装Matrix:
$ cd matrix $ make && make install
运行测试程序:
$ matrix-adc
注意:此模块并不支持热插拔,启动系统前需要确保硬件连接正确。
运行效果如下:
The channel0 value is 2460
6 代码说明
所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-analog_to_digital_converter,内容如下:
int main(int argc, char ** argv) { int i = 0; int value = 0; int channel = 0; if (boardInit() < 0) { printf("Fail to init board\n"); return -1; } if (argc == 2) channel = atoi(argv[1]); system("modprobe "DRIVER_MODULE); signal(SIGINT, intHandler); for (i=0; i<ADC_READ_TIMES; i++) { if (pcf8591Read(channel, &value) != -1) { printf("The channel%d value is %d\n", channel, value); } else { printf("Fail to get channel%d value\n", channel); } } system("rmmod "DRIVER_MODULE); return 0; }
API说明参考维基:Matrix API reference manual