An analog-to-digital converter is a device which converts continuous signals to discrete digital numbers. Typically, an ADC is an electronic device that converts an input analog voltage (or current) to a digital number proportional to the magnitude of the voltage or current. This circuit demonstrates the interfacing of ADC0808 with 8051 microcontroller (AT89C51). The output is taken on the LEDs. This is an intermediate circuit, which finds lot of applications. ADC0808 needs an external clock to run. The circuit describes how a D-flip flop can be used to provide the external clock.
Analog-to-digital converters are among the most widely used devices for data acquisition. Digital computers use binary values, but in physical world everything is analog. Therefore, we need an analog-to-digital converter to translate the analog signals to digital signals. An ADC has n-bit resolution where n can be 8,10,12,16 etc. The ADC chips are either parallel or serial. In parallel ADC we have 8 or more pins dedicated to bringing out the binary data. ADC0808 is a parallel ADC with 8-bit resolution.
ADC0808 has 8 input channels i.e., it can take eight analog signals. To select these input pins three select pins are available. In this circuit the controller sends the control and enabling signal to ADC.
The circuit takes only one input pin of ADC, IN1 (pin27). ALE (pin22) of ADC is connected to P1.0 of the microcontroller AT89C51. Selector pins A, B, C (pins 25, 24 & 23) of ADC are connected to P1.4, P1.5, and P1.6 pins of controller, AT89C51 respectively. SC (pin6) of controller is connected to P1.1 of microcontroller. EOC (pin7) of ADC is connected to P1.2 of controller. OE (pin 9) of ADC is connected to P1.3 of controller. Output of ADC goes to port P0 (pins 32-39) of controller. (Also see interfacing ADC0808 using clock from AT89C51).
The clock for driving the ADC0808 is taken from the crystal of the microcontroller AT89C51. The controller uses a crystal of frequency 11.0592 MHz. As this frequency is too high for the ADC, it is divided using a D flip-flop and then given to the ADC0808. The circuit uses four D-flip flops to divide the frequency by 16. For D flip-flop, IC 74LS74 is used. It is a 14 pin IC with two internal D flip flops. The circuit uses two ICs to divide the frequency by 16. The circuit diagram shows the connection of the D flip-flop ICs.
The program continuously reads the input of ADC on the port P0 and outputs the same value on the port P2. LEDs are connected on the port P2 to display the output.
Project Source Code
###
// Program to test ADC 0808. The output pins are connected to LED's. external clock is used for driving the ADC 0808. #include<reg51.h> sbit ale=P1^0; //address latch enable sbit oe=P1^3; //output enable sbit sc=P1^1; //start conversion sbit eoc=P1^2; //end of conversion sbit ADD_A=P1^4; // Address pins for selecting input channels. sbit ADD_B=P1^5; sbit ADD_C=P1^6; sfr input_port=0x80; sfr output_port=0xA0; void delay(unsigned int count) // Function to provide time delay in msec. { int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void main() { eoc=1; input_port=0xFF; ale=0; oe=0; sc=0; while(1) { ADD_C=0; // Selecting input channel 2 using address lines ADD_B=0; ADD_A=1; delay(2); ale=1; delay(2); sc=1; delay(1); ale=0; delay(1); sc=0; while(eoc==1); while(eoc==0); oe=1; output_port=input_port; delay(2); oe=0; } }###
Circuit Diagrams
Project Components
Project Video
Filed Under: 8051 Microcontroller
Filed Under: 8051 Microcontroller
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.