Introduction to the method flow and practical application of AD analog-to-digital conversion

Let's take a look at the experimental and product development work that we will be using with the 51 MCU integrated learning system. This system includes various modules such as water lamps, digital tube displays, liquid crystal displays, push button switches, buzzers for music, relay control, I²C bus, SPI bus, PS/2 experiments, AD analog-to-digital conversion, optocoupler experiments, serial communication, infrared remote control, wireless remote control, temperature sensing, and stepper motor control. The main system is shown in Figure 1, while the supporting book tutorial titled "MCU Quick Start" is illustrated in Figure 2.

Figure 1: Picture of the host part of the 51 MCU integrated learning system

Figure 2: Supporting book tutorial for the 51 MCU comprehensive learning system - "MCU Quick Start"

The above images show the hardware platform of the 51 MCU integrated learning system that we will use. As shown in Figure 1, this experiment utilizes the integrated system host along with the onboard ADC0832 analog-to-digital conversion chip. It also introduces the principles and usage of other functional modules within the integrated system. You can find more detailed information in previous issues of the "Electronic Production" magazine and post-production tutorials. In industrial control and intelligent instrumentation, real-time control and data processing are typically handled by microcomputers. While computers process digital information, the parameters being controlled or measured are often continuously varying analog signals, such as temperature, speed, and pressure. These signals are usually electrical in nature and are difficult to store and process directly. They are also not suitable for long-distance transmission and are prone to interference. Therefore, in most industrial systems, sensors convert non-electrical analog signals into corresponding electrical analog signals, which are then converted into digital signals by an Analog-to-Digital (ADC) conversion circuit. This complete signal chain involves the ADC circuit, which is commonly encountered in many applications. **Introduction to Analog-to-Digital Conversion (ADC)** **ADC Conversion Principle** The principle of ADC varies depending on the circuit design. Typically, an ADC consists of two main parts: a sample-and-hold circuit and a quantization and coding circuit. Among these, the quantization and coding circuit is the core component, and every ADC must include it. There are two general methods for ADC implementation: indirect and direct. Indirect method: The sampled and held analog signal is converted into a time or frequency proportional to the analog value, and then into a digital value. This is usually done with a clock counter, known as a counter. It has low working speed, high precision, and strong anti-interference capability. Direct method: The reference voltage is compared with the sample-and-hold signal to convert it into digital form. This method offers high speed and ease of achieving accuracy. The analog-to-digital conversion process involves four stages: sampling, holding, quantizing, and encoding. **Sampling** is the process of converting a continuous-time signal into a discrete-time signal. After sampling, the continuous-time, continuous-value analog signal becomes a time-discrete, numerically continuous signal called a sampled signal. The sampling circuit acts like an analog switch that operates periodically. In theory, the switch closes for a very short period during each cycle. At the moment the switch closes (sampling time), we “take” a “sample” of the analog signal. **Quantization** is the process of converting a continuous numerical signal into a discrete numerical signal. After quantization, the time-discrete, numerically continuous sampled signal becomes a time-discrete, numerically discrete digital signal. Since digital quantities are usually represented in binary code, there is an encoding circuit following the quantization stage to convert the signal value into binary code. However, quantization and encoding require some time to complete, so a **hold circuit** is placed before the quantization stage. The hold process converts a time-discrete, numerically continuous signal into a time-continuous, numerically discrete signal. During quantization and encoding, the hold circuit acts as a constant voltage source that "holds" the signal voltage at the sampling instant at the input of the quantizer. Although the logical keeper is a separate unit, in engineering, the holder is always combined with the sampler. Together, they are referred to as a **sample-and-hold** unit. **Introduction to the 8-bit Serial A/D Converter ADC0832** The ADC0832 is an 8-bit resolution, dual-channel A/D converter from National Semiconductor. Due to its compact size, strong compatibility, and cost-effectiveness, it is widely used by MCU enthusiasts and enterprises, making it a popular choice in the market. The ADC083X series includes models like ADC0831, ADC0832, ADC0834, and ADC0838, all of which are 8-bit serial I/O analog-to-digital converters with multiplexer switches. They offer high conversion speeds (32μS), single supply operation, low power consumption (15mW), and are ideal for portable smart meters. This chapter uses the ADC0832 as an example to explain its operation and application. The ADC0832 is an 8-pin DIP package that supports two analog channels and can operate in both single-ended and differential modes. It uses serial communication for channel selection, data acquisition, and data transfer via the DI pin. With 8-bit resolution (up to 256 levels), it meets general analog-to-digital conversion requirements. The internal power supply and reference voltage are shared, allowing the analog input voltage to range between 0V and 5V. It features dual data output for error checking, fast conversion speed, and good stability. Its independent chip enable input makes multi-device setups and processor control more convenient. **Key Features of ADC0832:** - 8-bit resolution - Dual-channel A/D conversion - TTL/CMOS compatible input/output levels - Input voltage range: 0–5V (with 5V power supply) - Operating frequency: 250kHz, conversion time: 32μS - Low power consumption: 15mW - Available in 8-Pin and 14-Pin DIP packages - Commercial grade: 0°C to +70°C; Industrial grade: -40°C to +85°C

Figure 3: ADC0832 pin diagram

**Chip Interface Description:** - **CS**: Chip Select Enable, active low. - **CH0**: Analog input channel 0, or IN+/-. - **CH1**: Analog input channel 1, or IN+/-. - **GND**: Ground (reference zero potential). - **DI**: Data input, used for channel selection. - **DO**: Data output, used for reading conversion results. - **CLK**: Clock input. - **Vcc/REF**: Power and reference voltage input (multiplexed). **How the ADC0832 Works:** Under normal conditions, the interface between the ADC0832 and the microcontroller requires four data lines: CS, CLK, DO, and DI. However, when I/O resources are limited, DO and DI can be used on the same line since they are not used simultaneously. When the ADC0832 is not operating, the CS pin should be set high to disable the chip, and the CLK and DO/DI pins can be in any state. To perform an A/D conversion, the CS pin must be pulled low and held until the conversion is complete. At this point, the chip begins the conversion process, and the microcontroller sends clock pulses to the CLK pin. The DI pin is used to select the channel function. Before the first clock pulse, the DI pin must be high to indicate the start of the conversion. The next two pulses are used to send channel selection bits. After the third pulse, the DI pin no longer affects the input, and the DO/DI pin starts outputting the conversion result. From the fourth pulse onward, the higher bit (Bit7) of the conversion data is output, followed by each subsequent bit. The lowest bit (Bit0) is output after the 11th pulse, completing one byte of data. The next byte follows, and the conversion ends after the 19th pulse. Finally, the CS pin is set high to disable the chip, and the converted data can be processed. **Channel Address Settings Table (Table 1):** | Channel Address | SGL/DIF | ODD/SIGN | Working Mode Description | |------------------|---------|----------|--------------------------| | 0 | 0 | 0 | Differential mode (CH0=IN+, CH1=IN-) | | 0 | 0 | 1 | Differential mode (CH0=IN-, CH1=IN+) | | 0 | 1 | 0 | Single-ended input mode (CH0 only) | | 0 | 1 | 1 | Single-ended input mode (CH1 only) | When used in single-ended mode, the ADC0832 accepts an input voltage range of 0–5V, with an 8-bit resolution resulting in a voltage accuracy of 19.53mV (5/256 V). If used in differential mode, the input range can be expanded, increasing the conversion range. However, it is important to note that if the voltage at IN- is greater than the voltage at IN+, the conversion result will always be 00H. **ADC0832 Operating Timing**

Figure 4: ADC0832 working sequence

**ADC0832 Software and Hardware Design Example** After studying the theoretical background, you should have a clear understanding of analog-to-digital conversion. Now, let’s apply this knowledge practically by implementing an example that displays the voltage sampled on channel 1 on an LED digital tube. By adjusting the input voltage on channel 1, you can observe how the output changes. Before debugging this example, make sure to set the function selection switch to the position labeled "ADC0832," as shown in Figures 5 and 6.

Figure 5: ADC0832 experimental demonstration

Figure 6: ADC0832 experimental demonstration

**Hardware Schematic**

Figure 7: Hardware schematic

**Program Flow Chart**

Figure 8: Software flow chart

Fiber Optic Tool Kit

Fiber Optical Tools,Fiber Optic Termination Tool Kit,fiber Visual Fault Locator,Optical Fiber Length Fixer,gpon sfp module

Shenzhen Runtop Technology Co.LTD , https://www.runtoptech.com