打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Digital Potentiometer数字电位器AD5171

这是一篇教程,原文地址https://docs.arduino.cc/learn/communication/wire。该是比较古旧的文字,但仍然能看到作者在今年刚刚修订过的痕迹。我琢磨它,是因为有几天要学习Arduino的I2C通讯原理。

我们知道,I2C是一条时钟线上约好了怎么配合传输数据,然后就开始、读写、应答、读写、停止,都有专门的条件。这和交通指导做手势是类似的,双手高举,然后依次落下,就是告诉Slave器件,我要开始了;再分帧传输数据,最后两手一上一下交叉,互换左右手再交叉,就是结束了。和常见的shut up手势很像,就是没有耸肩的动作。Arduino的wire库就是专门做这件事儿的,习惯上的Ack,在wire里面是begin和end的Transmission。

这篇教程是介绍AD5171数字电位器。关于这个器件,专门找了它的介绍,是通过I2C控制来实现电阻变化,一定程度上代替了机械式的滑片,相当于有无数个抽头,这样就能得到众多的电阻,结合分压电路,就能实现机械与电子、电压与电阻之间的互相控制。不少电器上有按压的气泡调节按钮,就是这种数字电位器。

不过我实在想不出目前能用它干什么。我后来看到有些文献说它应该被消失,因为现在太多芯片比它方便。但我觉得它还是挺新颖的。阅读了,且整理了这篇文章,所以还是留着以后万一有用呢。

一、AD5171结构框图。

W即引脚1,即为滑片。

二、电路接线:

Connect pins 3, 6, and 7 of the AD5171 to GND, and pins 2 and 8 to +5V. Connect pin 4, the digital pot's clock pin (SCL), to analog pin 5 on the Arduino, and pin 5, the data line (SDA), to analog pin 4. On both the SCL and SDA lines, add 4.7K ohm pull up resistors, connecting both lines to +5 V. Finally, wire an LED to pin 1, the AD5171's "wiper", with a 680 ohm LED in series.

When the AD5171's pin 6, ADO, is connected to ground, it's address is is 44. To add another digital pot to the same SDA bus, connect the second pot's ADO pin to +5V, changing it's address to 45.这个芯片用AD0控制地址,接GND为十进制44,即0x2C,接+5V为十进制45,即0x2D。You can only use two of these digital potentiometers simultaneously.

三、电路图

四、Arduino代码

// I2C Digital Potentiometer
// by Nicholas Zambetti <http://www.zambetti.com>
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>

// Demonstrates use of the Wire library
// Controls AD5171 digital potentiometer via I2C/TWI

// Created 31 March 2006

// This example code is in the public domain.

// This example code is in the public domain.


#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte val = 0;

void loop()
{
  Wire.beginTransmission(44); // transmit to device #44 (0x2c)
                              // device address is specified in datasheet
  Wire.write(byte(0x00));            // sends instruction byte  
  Wire.write(val);             // sends potentiometer value byte  
  Wire.endTransmission();     // stop transmitting

  val++;        // increment value
  if(val == 64) // if reached 64th position (max)
  {
    val = 0;    // start over from lowest value
  }
  delay(500);
}

到TB上看看AD5171,发现没有直插封装的,只有贴片的,贴片很不好焊,以后有机会试试。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
实验室:使用数字电位器进行SPI通信 - ITP物理计算
Arduino之简易航模遥控器
Arduino基础
Arduino one wire temperature DS18B20
Arduino教程 Lesson 12:可控舵机
arduino舵机servo库介绍和检查调整舵机的两个方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服