秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  278 随笔 :: 0 文章 :: 308 评论 :: 20万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

利用Arduino Nano的wire库可以很方便对ADS1100进行设置和读取转换后的数据。

复制代码
/*
*  Arduino reads ADS1100  I2C 16bit diff ADC
*/  

/* 
    SDA  ==>  analog 4  PC4
    SCL  ==>  analog 5  PC5

    set register:  STBY   0  0    SC    DR1  DR0 PGA1  PGA0
          default   1     0  0    0      1    1    0     0      0x8C
          i want    1     0  0    0      1    1    0     0
                    ign   0  0   con      8SPS      GAIN 1
    STBY, only for single mode to start conversion
    SC    1= single , 0=continuous 
    DR1:0    datarate 00 = 128sps, 12 bit      -2048 to  2047
                      01 =  32sps, 14          -8192 to  9191
                      10 =  16sps, 15         -16384 to 16383
                      11 =   8sps, 16         -32768 to 32767  
    PGA1:0  Gain      00 = *1, 01 = *2, 10 = *4, 11 = *8  
*/

#include <Wire.h>

//  AD0 1001 000 r/w      AD1 1001 001 r/w ; r=1. w=0     
#define AD0 B1001000         // ADS1100 地址0x48
#define options B10001100 // 0x8C-- 8SPS,16位精度,1倍放大 uint8_t reg = 0; int16_t result = 0; void setup() { Serial.begin(9600); Wire.begin(); Wire.beginTransmission(AD0); Wire.write(options); Wire.endTransmission(); } void loop() { Wire.beginTransmission(AD0); Wire.requestFrom(AD0, 3); // 返回 3个 bytes
      while(Wire.available()) {      
        result = Wire.read();     
        result = result << 8;
        result +=  Wire.read();
        reg = Wire.read();
        Serial.print(result, DEC); 
        Serial.println("\t");
        Serial.print((3300.00 * result)/ 0x7FFF, 2);//ADS1100接3.3V电源,如果接5V要将3300.00改为5000.00
        Serial.println(" mV");     
  }
  Wire.endTransmission();
  delay(100);
}
复制代码

 

posted on   秋·风  阅读(1477)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示