Introduction:

Data collection and processing are widely used in the field of automation. Due to different application occasions, the hardware required for data collection and processing is also different. In the control process, sometimes several analog signals need to be collected and processed. The collection and processing of these signals do not require high speed. Generally, A/D conversion circuits composed of chips such as AD574 or ADC0809 are used to realize signal collection and analog-to-digital conversion. However, A/D converters such as AD574 and ADC0809 are expensive and have complex circuits, which increases product prices and project costs. In this article, starting from practical applications, an A/D conversion circuit composed of V/F converter LM331 chip is given. The V/F converter LM331 chip can convert voltage signals into frequency signals with good linearity. Through computer processing, the frequency signal is converted into a digital signal to complete the A/D conversion. Compared with AD574 and other circuits, it has the characteristics of simple wiring, low price, high conversion accuracy, etc., and the LM331 chip does not require software program drive during the conversion process, which is much more convenient to use than AD574 and other A/D conversion circuits that require software program control.

1. Chip Introduction

LM331 is an integrated chip with a relatively high performance-price ratio produced by NS Company in the United States. It is currently the simplest high-precision V/F converter, A/D converter, linear frequency modulation and demodulation, long-time integrator and other related devices. LM331 is a dual in-line 8-pin chip, and its pin block diagram is shown in Figure 1.


 Figure 1 LM331 logic block diagram 

Figure 2 is a commonly used voltage-frequency conversion circuit. According to Figure 2, the circuit is designed. LM331 is powered by a single power supply, the power supply voltage is VCC, the input range of the analog signal is -VCC~0V, the frequency range is 1~500KHZ, and the nonlinearity is less than 0.01%. After the analog signal is integrated by the integrator LF356, it becomes a stable current input proportional to the input voltage at the INPUT end. After the V/F conversion is performed by the LM331 chip, it becomes a frequency signal proportional to the voltage. The frequency signal output from the FOUT end is sent to the counting/timing port of the computer, and the computer collects, processes and stores the frequency signal. Thus, the conversion of analog signals to digital signals is realized. Since the conversion linearity of LM331 directly affects the accuracy of the conversion result, and the reason for the nonlinear error in V/F conversion is usually the output impedance of pin 1, which makes the output current change with the input voltage, thus affecting the conversion accuracy. To overcome this shortcoming, the high-precision V/F converter adds an integrator between pins 1 and 7. This integrator is an anti-integrator composed of a conventional op amp LF356 and an integral capacitor C4. After adding the integral circuit, since the current source (pin 1) always maintains the ground potential, the voltage does not change with or FOUT, so it has a high linearity.

2. Frequency-to-digital signal conversion


                                                                                                 Figure 2 Voltage-frequency conversion circuit

In Figure 3, the analog signal is converted into a pulse signal through the voltage/frequency converter LM331, and the pulse signal is sent to the counting/timing port of the computer. The computer receives, processes and stores the frequency signal. Since the voltage/frequency conversion relationship of the voltage/frequency converter LM331 is linear, we can know the size of the analog signal based on the collected frequency data, thereby realizing the conversion of analog signals to digital signals. The frequency counter and timer can use the counting/timing port of the computer and be realized through software programming. The reference frequency and data processing are also realized through software programming, and the data can be stored in the internal data storage or the external data storage.

3. Computer software programming

LM331 needs to be used in conjunction with the counter to realize A/D conversion. The output terminal FOUT of LM331 is connected to the T0 port of the microcontroller counter, and the timer T1 is used for timing. According to the formula f=D/T, D is the count value; T is the count time. The count time T is determined by the timer T1, and FOUT is obtained by calculation, and then data processing and storage are performed. The brief program and description are as follows:


                                                                                            Figure 3 LM331 A/D conversion framework


The main program MAIN sets the working modes of timers T0 and T1 to 16-bit counting and timing respectively, and sets the initial value. T1 opens the interrupt. The timing time of T1 is determined according to the conversion accuracy. If the conversion accuracy is 12 bits, the highest frequency is 100KHZ, and the full-scale time is FFFH/100K=8.192ms. When the single-chip microcomputer uses a 12MHZ crystal oscillator, the machine cycle = 1µs, and the initial timing value is:


The DATA subroutine is mainly used for data processing and storage. The data obtained is 12-bit A/D conversion data. By changing the initial timing value, the A/D conversion bit can be adjusted, such as 13 bits, 14 bits, etc.

Conclusion:

Using LM331 to realize A/D conversion has the characteristics of simple circuit, low cost, high measurement accuracy and adjustable conversion bit number. Before actual work, the circuit device parameters are adjusted. After adjustment, the system stability is good. Compared with circuits such as AD574, the price is several times cheaper.