Difference between revisions of "Matrix - Analog to Digital Converter"

From FriendlyELEC WiKi
Jump to: navigation, search
(介绍)
(特性)
Line 5: Line 5:
 
We utilize the PFC8591T in this module and extend necessary pins through a 2.54 mm spacing pin header. The PFC8591T is an 8-bit A/D and D/A converter. It has 4 A/D channels and 1 D/A channel. In this module we use the PFC8591T's power, ground, I2C,  A/D and D/A pins. The I2C's address is configured as 1001000x. Its power source range is 2.5V - 6.0V. By default the power pin is 5V however if you want to take a 0 - 3.3V analog signal and keep its accuracy you can connect it to a 3.3V power source.
 
We utilize the PFC8591T in this module and extend necessary pins through a 2.54 mm spacing pin header. The PFC8591T is an 8-bit A/D and D/A converter. It has 4 A/D channels and 1 D/A channel. In this module we use the PFC8591T's power, ground, I2C,  A/D and D/A pins. The I2C's address is configured as 1001000x. Its power source range is 2.5V - 6.0V. By default the power pin is 5V however if you want to take a 0 - 3.3V analog signal and keep its accuracy you can connect it to a 3.3V power source.
  
==特性==
+
==Features==
* 宽电源电压输入,2.5V-6.0V
+
* Wide power input range: 2.5V-6.0V
* I2C接口,3.3V/5V
+
* I2C, 3.3V/5V
* 8-bit A/D x4
+
* 8-bit A/D x 4
* 8-bit D/A x1
+
* 8-bit D/A x 1
* 体积小巧, 带固定孔,方便嵌入到外壳
+
* Tiny dimension, easy to use in various situations
* 2.54mm排针接口,接线方便,通用性强
+
* 2.54 mm spacing pin
  
 
==使用方法==
 
==使用方法==

Revision as of 10:03, 5 August 2015

查看中文

1 Introduction

Analog to Digital Converter

We utilize the PFC8591T in this module and extend necessary pins through a 2.54 mm spacing pin header. The PFC8591T is an 8-bit A/D and D/A converter. It has 4 A/D channels and 1 D/A channel. In this module we use the PFC8591T's power, ground, I2C, A/D and D/A pins. The I2C's address is configured as 1001000x. Its power source range is 2.5V - 6.0V. By default the power pin is 5V however if you want to take a 0 - 3.3V analog signal and keep its accuracy you can connect it to a 3.3V power source.

2 Features

  • Wide power input range: 2.5V-6.0V
  • I2C, 3.3V/5V
  • 8-bit A/D x 4
  • 8-bit D/A x 1
  • Tiny dimension, easy to use in various situations
  • 2.54 mm spacing pin

3 使用方法

3.1 连接

  • 连接到Tiny4412 SDK (1506)
VCC接5V,G接地
SDA接I2C SDA
SCL接I2C SCL

3.2 Linux下的C示例

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "libfahw.h"
 
int main(int argc, char ** argv)
{
    int devFD;
    int data, channel, mode;
 
    if ((devFD = pcf8591Init()) == -1) {
        printf("Fail to init pcf8591\n");
        return -1;
    }
 
    if (pcf8591SetCtrl(devFD, PCF8591_INIT_AD_CONTROL) == -1) {
        printf("Fail to Set pcf8591 control AD\n");
        pcf8591DeInit(devFD);
        return -1;
    }
    mode = 0;
    printf("pcf8591 working as AD in mode%d\n",mode);
    for(channel = PCF8591_AIN_CHANNEL0;channel <= PCF8591_AIN_CHANNEL3; channel++) {
        data = pcf8591Read(devFD, mode, channel);
        printf("Channel%d's value: %d\n",channel,data);
    }
    pcf8591DeInit(devFD);
    return 0;
}

3.3 编译并运行示例

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo/matrix-analog_to_digital_converter
make

将编译生成的pcf8591通过ftp上传到开发板上运行即可测试。

4 相关资料