這是一篇教程,原文地址https://docs./learn/communication/wire。該是比較古舊的文字,但仍然能看到作者在今年剛剛修訂過的痕跡。我琢磨它,是因?yàn)橛袔滋煲獙W(xué)習(xí)Arduino的I2C通訊原理。 我們知道,I2C是一條時(shí)鐘線上約好了怎么配合傳輸數(shù)據(jù),然后就開始、讀寫、應(yīng)答、讀寫、停止,都有專門的條件。這和交通指導(dǎo)做手勢(shì)是類似的,雙手高舉,然后依次落下,就是告訴Slave器件,我要開始了;再分幀傳輸數(shù)據(jù),最后兩手一上一下交叉,互換左右手再交叉,就是結(jié)束了。和常見的shut up手勢(shì)很像,就是沒有聳肩的動(dòng)作。Arduino的wire庫就是專門做這件事兒的,習(xí)慣上的Ack,在wire里面是begin和end的Transmission。 這篇教程是介紹AD5171數(shù)字電位器。關(guān)于這個(gè)器件,專門找了它的介紹,是通過I2C控制來實(shí)現(xiàn)電阻變化,一定程度上代替了機(jī)械式的滑片,相當(dāng)于有無數(shù)個(gè)抽頭,這樣就能得到眾多的電阻,結(jié)合分壓電路,就能實(shí)現(xiàn)機(jī)械與電子、電壓與電阻之間的互相控制。不少電器上有按壓的氣泡調(diào)節(jié)按鈕,就是這種數(shù)字電位器。 不過我實(shí)在想不出目前能用它干什么。我后來看到有些文獻(xiàn)說它應(yīng)該被消失,因?yàn)楝F(xiàn)在太多芯片比它方便。但我覺得它還是挺新穎的。閱讀了,且整理了這篇文章,所以還是留著以后萬一有用呢。 一、AD5171結(jié)構(gòu)框圖。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.這個(gè)芯片用AD0控制地址,接GND為十進(jìn)制44,即0x2C,接+5V為十進(jìn)制45,即0x2D。You can only use two of these digital potentiometers simultaneously. 三、電路圖四、Arduino代碼
到TB上看看AD5171,發(fā)現(xiàn)沒有直插封裝的,只有貼片的,貼片很不好焊,以后有機(jī)會(huì)試試。 |
|