Sunteți pe pagina 1din 2

Interface of adc0808 with microcontroller at89c51

The ADC0808 or ADC0809 are 8 bit and 8 channel analog to digital converters and have very good results in the conversion. they are easy to use and can be used in variety of projects. Their interfacing with micro controllers like at89s51 is very simple , but they can be used with any type of microcontroller or even with direct PC parallel port through some electronics circuit. I used this chip for several time for different types of conversions, forexample temperature and pressure, load cells, differential pressure transducers which can give us even current loop of 4-20 mA, but for that purpose again current to voltage conversion circuit will be need. Here is a sample program which converts 8 analog inputs of 0-5v to digital 0-255 one by one, stores in an array of 8 number. then this data is transmitted to PC by using serial port with RS 232 on 9600 baud rate. This program is written in Kiel c51 which include adc0809 and microcontroller 8051. #include unsigned char sec1,sec,adc[8],ss; void rdadc0808(void); void send(void); void pause (void); sbit eoc = P3^4; sbit ale = P3^5; sbit oe = P3^6; sbit sc = P3^7; sbit adda = P2^0; sbit addb = P2^1; sbit aadc = P2^2; void timer(void) interrupt 1 { TH0 = 0xdc; sec1++; if(sec10>=100) { rdadc(); setout(); sec1=0; } } void main() { EA = 1; ET0 = 1; SCON = 0x52; TMOD = 0x21; TH1 = 0xfd; // 9600 baud rate TR1 = 1; TR0 = 1;

ES = 1; wt = 1; rd = 1; en = 1; adc = 0; P1 = 0xff; eoc = 1; ale = 0; oe = 0; sc = 0; while(1) { ; } } void send(void) { for(ss=0;ss<8;ss++) { TI = 0; SBUF = adc[ss]; while(!TI){;} } void rdadc0808(void) { for(ss=0;ss<8;ss++) { P2 = ss; pause(); ale = 1; pause(); sc = 1; pause(); ale = 0; sc = 0; while (eoc); while (!eoc); oe = 1; pause(); adc[ss] = P1; oe = 0; } void serial(void) interrupt 4 { If (RI) RI=0; } void pause(void) { unsigned int idelay ; for(idelay=0; idelay < 2500;idelay++); }

Posted by Dr.Rana at 11:29:00 AM Email ThisBlogThis!Share to TwitterShare to Facebook

S-ar putea să vă placă și