DAC0832是采樣頻率為八位的D/A轉(zhuǎn)換器件,下面介紹一下該器件的中文資料以及電路原理方面的知識。 DAC0832內(nèi)部結(jié)構(gòu)資料:芯片內(nèi)有兩級輸入寄存器,使DAC0832具備雙緩沖、單緩沖和直通三種輸入方式,以便適于各種電路的需要(如要求多路D/A異步輸入、同步轉(zhuǎn)換等)。D/A轉(zhuǎn)換結(jié)果采用電流形式輸出。要是需要相應(yīng)的模擬信號,可通過一個高輸入阻抗的線性運算放大器實現(xiàn)這個供功能。運放的反饋電阻可通過RFB端引用片內(nèi)固有電阻,海可以外接。 該片邏輯輸入滿足TTL電壓電平范圍,可直接與TTL電路或微機電路相接,下面是芯片電路原理圖 DAC0832引腳圖和內(nèi)部結(jié)構(gòu)電路圖


電路圖如上圖所示,此接法是用DAC0832的直通方式,只要二進(jìn)制數(shù)據(jù)送到DAC0832的數(shù)據(jù)口,則會自動把數(shù)據(jù)轉(zhuǎn)為相應(yīng)的電壓.但運放是如圖的電壓則輸出一般不可能達(dá)到基準(zhǔn)電壓.要想達(dá)到基準(zhǔn)電壓則要提高運放的電壓.當(dāng)基準(zhǔn)為負(fù)是,只要提高運放的正電壓就可以使輸出達(dá)到基準(zhǔn)電壓了,當(dāng)基準(zhǔn)為正是,則為提高運放的負(fù)電壓,一般的運放提高兩伏就可以了,但不同的運放會有些區(qū)別.
程序如下:
1.輸出固定電壓的程序
#include "reg51.h" void DAC0832(unsigned char x) { P2=x; } void main() { DAC0832(255); while(1){ ;} }
2.輸出三角波與正弦波程序.
#include<AT89X52.H> unsigned char flag; //波型輸出標(biāo)置變量 bit time; unsigned char sin(unsigned char x) { unsigned char code sin_tab[]={125,128,131,134,138,141,144,147,150,153,156,159, 162,165,168,171,174,177,180,182,185,188,191,193,196,198,201,203, 206,208,211,213,215,217,219,221,223,225,227,229,231,232,234,235, 237,238,239,241,242,243,244,245,246,246,247,248,248,249,249,250, 250,250,250,250,250,250,250,249,249,248,248,247,246,246,245,244, 243,242,241,239,238,237,235,234,232,231,229,227,225,223,221,219, 217,215,213,211,208,206,203,201,198,196,193,191,188,185,182,180, 177,174,171,168,165,162,159,156,153,150,147,144,141,138,134,131, 128,125,122,119,116,112,109,106,103,100,97,94,91,88,85,82,79,76,73, 70,68,65,62,59,57,54,52,49,47,44,42,39,37,35,33,31,29,27,25,27,29,27,25,23,21, 19,18,16,15,13,12,11,9,8,7,6,5,4,4,3,2,2,1,1,0,0,0,0,0,0,0,0,1,1,2, 2,3,4,4,5,6,7,8,9,11,12,13,15,16,18,19,21,23,25,27,29,31,33,35,37, 39,42,44,47,49,52,54,57,59,62,65,68,70,73,76,79,82,85,88,97,94,97, 100,103,106,109,112,116,119,122}; return sin_tab[x]; } void DAC0832(unsigned char x) { P2=x; } void main() { unsigned char i; TMOD=0X02; //定時器0用于控制輸出波的頻率 TH0=256-40; ET0=1; //按鍵接于外部中斷0,與中斷1 IT0=1; IT1=1; EX0=1; EX1=1; EA=1; TR0=1; flag=0; //開始時無輸出 i=0; while(1) { if(time==1) { time="0"; if(i>249) i="0"; else i++; switch(flag) //當(dāng)按鍵1的為輸出三角波,按鍵2時輸出正弦波 { case 0:DAC0832(0);break; case 1: if(i>125) DAC0832(250-i); else DAC0832(i); break; case 2: DAC0832(sin(i)); break; default: break; } } } } void time0() interrupt 1 { time="1"; } void int0() interrupt 0 { //按鍵1接于外部中斷0 flag="1"; } void int1() interrupt 2 //按鍵2接于外部中斷1 { flag="2"; } |