Design of high-precision intelligent AC and DC voltage data acquisition system based on single-chip microcomputer

Publisher:电子设计艺术家Latest update time:2015-03-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Voltage is one of the most basic measurement elements in electronic and power systems. Quickly and accurately obtaining voltage values ​​has always been one of the important contents of data acquisition and electronic measuring instrument research. Traditional pointer voltmeters have defects such as low precision, short visual distance, and single function, and are no longer suitable for the development needs of high-speed informatization. The digital voltmeters widely used in the market are currently low in intelligence. When measuring voltage, the range needs to be switched manually. When the range is not selected properly, the measurement accuracy will decrease or even burn out the voltmeter. High-precision full-range non-shift digital voltmeters generally use complex circuit systems such as DSP, FPGA or CPLD, and the hardware and software implementation costs are high. To this end, the author designed and developed an intelligent AC and DC voltage data acquisition system with a single-chip microcomputer as the control body. It has the advantages of small size, high precision, simple structure, convenient use and reading, high cost performance, and wide adaptability, which effectively makes up for the shortcomings and disadvantages of the above-mentioned various voltmeter systems.


1 System Overall Plan

The voltage data acquisition system mainly consists of five parts: voltage attenuator, range conversion and amplification circuit, AC/DC conversion circuit, A/D conversion circuit, main control microcontroller STC89C52 and LCD display circuit. Its principle block diagram is shown in Figure 1. The voltage attenuator and amplifier convert the voltage value of the analog signal to be measured into the input voltage range of the AC/DC converter. The DC voltage does not need to be converted to AC/DC after attenuation and amplification; the range conversion circuit controls the relay to make corresponding adjustments to the attenuation and amplification circuit according to the analog DC voltage input to the A/D converter, and the microcontroller judges and controls the relay to make corresponding adjustments to the attenuation and amplification circuit to ensure the selection of the best range; the A/D conversion is started by the microcontroller, and the collected data is processed by digital filtering, scale conversion and system error calibration in the software, and the measured value and voltage type are displayed on the LCD according to the voltage type flag.



Figure 1 Schematic diagram of voltage data acquisition system


2 System Hardware Design

2.1 Voltage attenuation, amplification and range conversion circuit

The voltage attenuation amplification and range conversion circuit is shown in Figure 2. Resistors R1~R5 form a voltage divider with attenuation coefficients of 1, 10, 100, 1 000, and 10 000, respectively, which attenuates the measured input voltage Uin to a range of 0~200 mV and sends it to the back-end circuit for amplification, AC/DC conversion (DC voltage does not need to be converted), A/D conversion, and acquisition, processing and display by the single-chip microcomputer. In order to reduce the measurement error, the voltage divider resistors R1~R5 are all precision metal film resistors with an error of ±0.5%. The range selection is achieved by the P1.0~P1.4 port line of the single-chip microcomputer being inverted by the inverter 74HC04 to control the input terminals 1 B~5 B of the high-voltage, high-current Darlington transistor integrated circuit ULN2003 of SPRAGUE, thereby driving the contact switches of the electromagnetic relays K1~K5 to close or disconnect. AC voltage and DC voltage share the same conversion range. When K1~K5 are independently energized, the corresponding ranges are 200 mV, 2V, 20 V, 200 V, and 1 000 V (AC 750 V). If the measured voltage is higher than the range set by the microcontroller, the microcontroller controls the corresponding relay coil to turn on and attenuate the signal, otherwise it will be amplified to ensure that the signal input to the AC/DC converter and A/D converter does not exceed their operating voltage range. Because the measured voltage is unknown, in order to avoid the circuit being burned out, the initial range should be set to the highest range.



Figure 2 Voltage attenuation amplification and range conversion circuit


The negative common terminal COM of the diode inside the ULN2003 chip is connected to the load power supply +5 V, which plays a reverse freewheeling role for each relay coil. The purpose of adding the inverter 74HC04 is to prevent the input high voltage from directly entering the subsequent weak current system without voltage division when the single-chip system is powered on or reset, causing the circuit to burn out. The operational amplifier U3 is connected in the form of a voltage follower, which plays the role of isolating the front and rear channels, reducing the output impedance and improving the load capacity. Among them, R6 and R7 are current limiting resistors to prevent excessive current caused by switching to various ranges; D1 and D2 are bidirectional limiting diodes, which play an overvoltage protection role. The operational amplifier A4 and resistors R8, R9, and R10 are connected to form a common-phase proportional circuit, which amplifies the signal attenuated into the range of 0 to 200mV by 10 times and sends it to the subsequent AC/DC converter AD637J (nominal full scale is 2V) for AC/DC conversion (DC does not need to be converted).

2.2 AC/DC conversion circuit

The AC/DC conversion circuit is shown in Figure 3. It consists of two single-channel single-pole double-throw (SPDT) analog switches MAX14763 to complete the switching function of the AC/DC voltage channel, and a high-performance true root mean square (TRMS) converter AD637K to complete the AC/DC voltage conversion function. [page]



Figure 3 AC/DC conversion circuit diagram

MAX14763 is a +3.0 V ~ +5.5 V single power supply device, allowing the passage of bipolar signals within the ±25V range beyond its power supply voltage swing. The maximum on-resistance and on-leakage current are 2Q and ±100 nA respectively. The low on-resistance and wide bandwidth (-3 dB bandwidth is 100MHz) make it very suitable for applications in digital and analog signal switching. When the toggle switch S1 is closed, the SEL terminal of MAX14763 is low level, and the C0M terminal is connected to A1, connecting the AC voltage channel to perform AC/DC conversion on the input AC voltage; otherwise, the DC voltage channel is connected to allow the DC input voltage to directly enter the subsequent circuit.


AD637K is a complete high-precision, single-chip root mean square direct current (RMS-DC) converter that can calculate the true effective value TRMS of any complex input waveform without considering the waveform parameters and the size of the distortion, and provide an equivalent DC output voltage. That is: T is the measurement time, V IN (t) is the input signal waveform. It can be seen that the true root mean square value of the waveform is directly related to the signal power, so it is more useful than the average rectified signal. The accuracy of AD637K is ± (0.25 mV + 0.05% RDG). It allows the measurement of input signals with an effective value of 200 mV and a frequency of up to 600 kHz, as well as input signals with an effective value of more than 1 V and a frequency of up to 8 MHz. The maximum full-scale range of AD637K is an effective value of 7 V. Since the effective value of 2V full-scale range can provide greater dynamic margin for peak input (high crest factor signal), the attenuation amplifier circuit output signal U1 should be controlled within this range. The average capacitor C1 in the circuit is used to set the averaging time, and at the same time determines the low-frequency accuracy, output ripple size and stabilization time. Potentiometers RW1 and RW2 are used to adjust the output to zero and amplitude respectively to make the output more accurate. 2.3 A/D conversion circuit The A/D conversion circuit is shown in Figure 4, where the op amp U8 and resistors R14~R16 form a common-phase amplifier circuit, which amplifies the DC voltage U2f≤2 v) output by the front end by 2 times, and doubles the measurement resolution of the input voltage Uin. MAX187 is a serial 12-bit successive approximation A/D conversion chip, which works with a single +5 V power supply, contains an on-chip clock and sample/hold, and has a sampling rate of 75 kHz. It is connected to the I/O port lines P2.0~P2.2 of the microcontroller through a high-speed 3-wire serial interface, and the interface is compatible with SPI, QSPI and Microwire bus protocols. SHDN is connected to a high level, and the REF terminal is connected to a 4.7 F capacitor to the ground. This is the internal 4.096 V reference voltage mode, and the voltage of the analog signal input to the AIN terminal is in the range of 0~4.096 V.







Figure 4 A/D conversion circuit diagram

 

2.4 LCD display circuit

This system uses the 5110 liquid crystal display (LCD) module produced by NOKIA as the display unit to display the current voltage value and voltage type (AC or DC). The circuit is shown in Figure 5. NOKIA 5110 is connected to the microcontroller by only 5 signal lines, and the interface circuit is simple. Its communication protocol is an SPI protocol with only MOSI but no MISO. The transmission rate is up to 4 Mb/s, and the display data can be written at full speed without waiting time. It can be simulated by the microcontroller software program. The SPI interface write data/command timing (transmit 1 B) is shown in Figure 6.



Figure 5 LCD display circuit diagram Figure 6 NOKIA5110 serial bus protocol


 

3 System software design

3.1 Overall flow of system software

The overall flow chart of system software is shown in Figure 7. In order to facilitate the transplantation, calling and debugging of the program, the modular programming concept is adopted to program the modules with different specific functions separately. When the single-chip microcomputer is powered on, the program is initialized first, and the hardware settings of K1~K5 relays, MAX187 and NOKIA5110, as well as the initialization of the system interrupt and system variables inside the single-chip microcomputer are completed. Then the highest range is selected (the state of PI.4~P1.0 port lines is set to 011l1), and the A/D conversion is started to sample the measured signal and perform data processing calculations, and determine whether the range is appropriate. The over-range threshold and under-range threshold are taken as 4000 and 400 respectively, and the corresponding ADC input voltages are 4V and 0.4V respectively. If the current range is appropriate, the measured voltage value is obtained after the processed digital quantity is scaled and calibrated, and the voltage type, effective value and unit information are displayed on the LCD. Otherwise, the range is switched to find a new optimal range, and the next measurement is performed under the newly selected range. When judging, if the range is still under-range when it is at the lowest level, the original range will be maintained unchanged; if the range is still over-range when it is at the highest level, corresponding overload disposal measures must be taken. [page]



Figure 7 Overall flow chart of the software

 

3.2 Digital filtering of sampled data

When processing the A/D sampled data, the program judgment filtering method and the sliding average filtering method are used successively. The former is used to eliminate the sharp pulse interference signal caused by random interference, false detection or system instability, and the latter is used to suppress the periodic interference components that may appear in the data, such as high-frequency interference caused by radio waves. The program judgment filtering algorithm is based on practical experience to determine the maximum deviation value DT (here the value is 8) allowed for adjacent samples. When a new value is detected each time, it is judged: if the absolute value of the difference between the current value and the previous value is less than or equal to DT, then the current sampled value is valid; otherwise, the current value is abandoned and the previous value is used to replace the current value. As shown in the following formula: After eliminating pulse interference, the sliding average filtering algorithm is used to further process the data. It regards N consecutive sampled values ​​(here, N=10) as a queue of length N. Each time a new value is sampled, it is put at the end of the queue and a data at the head of the original queue is discarded. Then, the N data in the queue are arithmetic averaged to obtain a new filtering result. This data is used for threshold identification and scale transformation. 3.3 Calibration algorithm of system error Since the non-ideal characteristics of the system circuit, zero drift and offset of the amplifier, gain error and nonlinearity will cause system error, in order to improve the measurement accuracy, the following algorithm is adopted for error calibration and compensation. Assume that the voltage sample data (Xi, Yi) is obtained by equal precision measurement, where: i = l, ..., M, Xi and Yi are the voltage value (measured value) after scale transformation and the actual value (generated by a high-precision voltage reference source) respectively. The least squares method is used to linearly fit the measured data Y=aX+b. According to the principle of minimum weighted square sum of sample data deviation, the mathematical expressions of coefficients a and b are as follows: Substitute the data of each correction point (Xi, Yi) (here M is 6) into the above two equations to obtain the values ​​of coefficients a and b, and store them in the memory unit of the microcontroller. In the formal measurement, the correction value Y is calculated according to the measured value and the error correction equation Y=aX+b to eliminate the system error. Since the system error is different when the range is different, it is necessary to perform the above processing separately in each range to obtain the best calibration effect of different ranges.







 

4 Main technical indicators

The main technical indicators of the system are as follows: (1) Range: 200 mV, 2 V, 20 V, 200 V, 1 000 V (AC750V); (2) Resolution: 50 txV, 0.5 mV, 5 mV, 50mV, 0.5V (corresponding to each range); (3) Accuracy: 200 mV range: 0.005% × reading + 0.0025% × full scale (DC), 0.05% × reading + 0.05% × full scale (AC); other ranges: 0.005% × reading + 0.001% × full scale (DC), 0.05% × reading + 0.025% × full scale (AC); (4) Working power supply: DC ± 5V.

This paper designs and implements an AC/DC voltage data acquisition system with automatic range conversion function based on a single-chip microcomputer. The system has a wide dynamic range of voltage measurement and provides a cost-effective solution for the research of high-precision voltage data acquisition and intelligent voltmeters. The actual operation results show that the system has high precision, small error, high sensitivity, stable operation and reliable performance, and can be widely used in various fields that require voltage measurement and acquisition, such as power systems, measurement and detection, national defense industry, household appliances, science and technology and industrial production, and railway equipment. In addition, some hardware and software design methods and ideas used in the design also provide a reference for the design and development of similar data acquisition systems and intelligent instruments.

Reference address:Design of high-precision intelligent AC and DC voltage data acquisition system based on single-chip microcomputer

Previous article:51 Keyboard Display Program
Next article:Multifunctional intelligent car robot based on single chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号