In the intelligent instrument, a / D converter directly affects the performance of the instrument. The performance of a / D converter is mainly in two aspects: conversion accuracy and conversion time. At present, there are successive approximation converter, parallel converter, double integral converter and so on. Among them, the dual integral A / D converter is widely used in digital temperature measurement instruments and industrial field data acquisition for its high conversion accuracy, strong anti-interference performance and relatively low price. However, the dual integral A / D converter still has some shortcomings in practical application. Because of the zero drift error and the nonlinearity caused by capacitor charging and discharging in its working process, if it wants to obtain higher accuracy, it has very high requirements for the accuracy of op amp, resistor, voltage reference and temperature drift coefficient, especially for the data acquisition of fast changing signal. The price of high-precision parallel converter suitable for fast changing signal is too high, such as AD7874 with 12 bit precision. Therefore, it is of practical value to find a high-precision, high-speed and low-cost A / D conversion method. In this paper, we use the 10 bit a / D converter and PWM output of Intel 80C196, plus amplifier, filter and other simple circuits to achieve high-precision (up to 18 bit precision), high-speed A / D conversion, to meet the requirements of fast changing signal a / D conversion. The application shows that the A / D conversion method has high cost performance and good effect.
Introduction of 180c196
80C196KB is a kind of quasi 16 bit microcontroller series produced by Intel company. The common models are 80C196KB, 80C196KC, 80c196kt, etc. This paper selects 80cl96kb. Compared with other general microcontrollers, 80C196KB has the following characteristics: (1) the 232 byte register on chip has the functions of ram and accumulator, which overcomes the bottleneck problem caused by accumulator and improves the execution efficiency; (2) With 8-channel 10 bit a / D converter (successive approximation type), it is especially suitable for intelligent instruments, control systems and other applications; (3) pulse width modulation output PWM, PWM signal after integration can obtain DC output, can be used as D / a converter, the resolution of D / a converter is 8 bits; (4) high speed input / output (HSI / HSC)), HSI / HSO is particularly suitable It can measure and generate pulses with resolution as high as 2us; (5) 16 is the watchdog, which will reset the system in case of hardware and software failure; (6) the bus can be dynamically configured. In the process of operation, the 80C196KB bus can be dynamically configured into 8-bit or 16 bit, so as to adapt to byte exchange with external memory Different requirements for operations or word operations.
The characteristic of 80C196 determines that it is very suitable for automatic instrument and control. Its a / D can collect data conveniently, PWM can output D / a signal, WDT ensures the reliability of operation, his / HSO facilitates the measurement and generation of pulse signal. 80C196KB has 68 pins in total, which are packaged with PLCC. The pin diagram is shown in Figure 1.
Hardware implementation of 2 A / D conversion
Using the 10 bit a / D converter and PWM output of 80C196KB, the principle of realizing high-precision A / D conversion is as follows: assuming that the signal provided by the sensor is vs, the signal supplied to the A / D converter after amplification is as, the result of a / D conversion is Rd, the rounding error of a / D conversion is ed, and the rounding error of successive approximation A / D conversion is 0 ≤ ed
In the figure, the operational amplifiers H1 and H2 constitute the differential amplifier, H1 and H2 should choose the operational amplifier with better performance, the circuit has a very high common mode rejection ratio, the sensor signal vs is amplified by the differential amplifier to get as, as is connected to 80C196KB A / D channel input port ach0, a / D conversion to get high 8-bit digital quantity; 80C196KB PWM output signal is composed of U2 and E2 After filtering, the DC signal RD is obtained, which is the typical circuit of 80C196KB for D / a conversion by PWM; the circuit composed of operational amplifier H3 realizes es × 28, and the signal is connected to the input port ach1 of No.1 A / D channel of 80C196KB to complete the A / D conversion of ES and get the low bit digital quantity. High precision A / D conversion can be realized by combining high bit digital quantity and low bit digital quantity with software.
Software implementation of 3 A / D conversion
In order to ensure the real-time performance, the software of a / D conversion is realized by interrupt mode. Firstly, the main program sets timer and a / D interrupt mode in initialization, and starts 0 channel A / D conversion when timer interrupt arrives. When a / D is interrupted, judge the channel number of a / d. when ach0 of channel 0 is interrupted, read and save the high 8 bits of a / D result, output the result through PWM, and then start the next a / D conversion of ACHL of channel L. when ACHL is interrupted, read the A / D conversion result and combine it with the high 8 bits to get the final result.
When 12Mhz crystal oscillator is used, the A / D conversion time of 80C196KB is 22us, and the PWM output cycle is 64us. After PWM signal is output, in order to stabilize the D / a result and start ACHL again, three times of PWM cycle is delayed. The whole a / D conversion time (including a / D conversion time and software running time) can be completed in 1ms. The flow chart of a / D interrupt service program is shown in Figure 3. The initialization program and timer interrupt service program are simple, and the flow chart is sketchy.
Using the built-in 10 bit a / D converter and PWM signal of 80C196KB single chip microcomputer, the simple amplifying circuit and filtering circuit are used to realize the analog-to-digital conversion. This method has the advantages of low cost, high precision, high speed, easy implementation and high practical value. The A / D conversion method has been successfully applied in the automatic NC tool setting instrument developed by our company.
Editor in charge: GT