ADC to 8051

21,530

Circuit Image

The ADC (Analog to Digital Converter) is a crucial component in numerous embedded projects. This article focuses on interfacing an ADC with the 8051 embedded controller. The ADC0804 model is utilized, and before detailing the interfacing procedure, it is essential to understand the operational principles of the ADC0804. The ADC0804 is an 8-bit successive approximation analog-to-digital converter produced by National Semiconductor. Key features of the ADC0804 include differential analog voltage inputs, a 0-5V input voltage range, no zero adjustment, an integrated clock generator, and externally adjustable reference voltage to convert smaller analog voltage spans to 8-bit resolution. The pinout diagram of the ADC0804 is provided. The voltage at Vref/2 (pin 9) can be adjusted externally to convert smaller input voltage spans to full 8-bit resolution. Leaving Vref/2 (pin 9) open results in an input voltage span of 0-5V with a step size of 5/255 = 19.6 mV. The accompanying table illustrates various Vref/2 voltages and their corresponding analog input voltage spans. The schematic for interfacing the ADC0804 with the 8051 microcontroller is also depicted. The circuit initializes the ADC to convert a given analog input and subsequently accepts the corresponding digital data, displaying it on an LED array connected to port P0. For instance, if the analog input voltage Vin is 5V, all LEDs will illuminate, indicating a binary output of 11111111, equivalent to 255 in decimal. The AT89S51 microcontroller is employed in this setup. The data output pins (D0 to D7) of the ADC0804 are connected to the port pins P1.0 to P1.7, respectively, while LEDs D1 to D8 are linked to port pins P0.0 to P0.7. Current limiting resistors R1 to R8 are incorporated. In this configuration, P1 of the microcontroller serves as the input port and P0 as the output port. Control signals for the ADC (INTR, WR, RD, and CS) are routed through port pins P3.4 to P3.7. Resistor R9 and capacitor C1 are associated with the internal clock circuitry of the ADC, while a preset resistor R10 forms a voltage divider for applying a specific input analog voltage to the ADC. The push button S1, resistor R11, and capacitor C4 create a debouncing reset mechanism. The crystal X1 and capacitors C2 and C3 are part of the clock circuitry for the microcontroller. The assembly language code initializes port P1 as the input port and controls the ADC operations and data output.

The ADC0804, designed for 8-bit resolution, functions through a successive approximation method, allowing it to convert analog signals into digital data effectively. The device's differential analog voltage inputs enhance its versatility in various applications. The integrated clock generator simplifies the setup by eliminating the need for external clock sources, while the adjustable reference voltage enables fine-tuning of the input range, accommodating different sensor outputs.

In the interfacing schematic, the microcontroller AT89S51 communicates with the ADC0804 through specific pins designated for data input and control signals. The LEDs connected to port P0 provide a visual representation of the digital output, where each LED corresponds to a bit in the 8-bit output. The use of current-limiting resistors ensures that the LEDs operate within safe current levels, preventing damage.

The control signals are vital for managing the ADC's operation. The INTR signal indicates when the conversion is complete, while the WR and RD signals control the writing and reading of data, respectively. The implementation of a reset mechanism using a push button and a debouncing circuit ensures reliable operation by preventing false triggering.

The assembly code snippet provided illustrates the initialization and operation sequence for the ADC0804. It configures the microcontroller's ports, initiates the ADC conversion, and reads the resulting digital data to display it on the LED array. The use of the CPL instruction complements the data to provide a straightforward display output, enhancing user readability.

Overall, the ADC0804's integration with the 8051 microcontroller exemplifies a typical embedded system application, demonstrating the conversion of analog signals to digital data and the subsequent display of this data in a user-friendly format.ADC (Analogto digital converter) forms a very essential part in many embedded projects and this article is about interfacing an ADC to 8051 embedded controller. ADC 0804 is the ADC used here and before going through the interfacing procedure, we must neatly understand how the ADC 0804 works.

ADC0804 is an 8 bit successive approximation analogue to digital converter from National semiconductors. The features of ADC0804 are differential analogue voltage inputs, 0-5V input voltage range, no zero adjustment, built in clock generator, reference voltage can be externally adjusted to convert smaller analogue voltage span to 8 bit resolution etc. The pin out diagram of ADC0804 is shown in the figure below. The voltage at Vref/2 (pin9) of ADC0804 can be externally adjusted to convert smaller input voltage spans to full 8 bit resolution.

Vref/2 (pin9) left open means input voltage span is 0-5V and step size is 5/255=19. 6V. Have a look at the table below for different Vref/2 voltages and corresponding analogue input voltage spans. The figure above shows the schematic for interfacing ADC0804 to 8051. The circuit initiates the ADC to convert a given analogue input, then accepts the corresponding digital data and displays it on the LED array connected at P0.

For example, if the analogue input voltage Vin is 5V then all LEDs will glow indicating 11111111 in binary which is the equivalent of 255 in decimal. AT89s51 is the microcontroller used here. Data out pins (D0 to D7) of the ADC0804 are connected to the port pins P1. 0 to P1. 7 respectively. LEDs D1 to D8 are connected to the port pins P0. 0 to P0. 7 respectively. Resistors R1 to R8 are current limiting resistors. In simple words P1 of the microcontroller is the input port and P0 is the output port. Control signals for the ADC (INTR, WR, RD and CS) are available at port pins P3. 4 to P3. 7 respectively. Resistor R9 and capacitor C1 are associated with the internal clock circuitry of the ADC. Preset resistor R10 forms a voltage divider which can be used to apply a particular input analogue voltage to the ADC.

Push button S1, resistor R11 and capacitor C4 forms a debouncing reset mechanism. Crystal X1 and capacitors C2, C3 are associated with the clock circuitry of the microcontroller. ORG 00H MOV P1, #11111111B // initiates P1 as the input port MAIN: CLR P3. 7 // makes CS=0 SETB P3. 6 // makes RD high CLR P3. 5 // makes WR low SETB P3. 5 // low to high pulse to WR for starting conversion WAIT: JB P3. 4, WAIT // polls until INTR=0 CLR P3. 7 // ensures CS=0 CLR P3. 6 // high to low pulse to RD for reading the data from ADC MOV A, P1 // moves the digital data to accumulator CPL A // complements the digital data (*see the notes) MOV P0, A // outputs the data to P0 for the LEDs SJMP MAIN // jumps back to the MAIN program END ADC 0804 has active low outputs and the instruction CPL A complements it t0 have a straight forward display. For example, if input is 5V then the output will be 11111111 and if CPL A was not used it would have been 00000000 which is rather awkward to see.

🔗 External reference