As the demand for electricity increases, the phenomenon of uneven electricity consumption in different time periods is becoming more and more serious. In order to reasonably regulate the power load and save energy, power companies have begun to encourage the use of multi-rate electricity meters. Traditional multi-rate electricity meters generally use mechanical rotary metering, the metering accuracy decreases with mechanical wear, the time period setting is single, the manual meter reading is labor-intensive, and there are occasional electricity thefts and many other disadvantages. This paper gives a new multi-rate single-phase electricity meter design based on AT89S52 single-chip microcomputer, using AD7755 electricity metering chip, accurate electricity metering. The electricity meter has the characteristics of time-division metering, LCD display, automatic back copying, flexible time period setting, timely time correction, novel anti-electricity theft, and low power consumption. The error analysis of the experimental test data of the electricity meter is carried out, and the methods of reducing and eliminating errors in electricity metering are pointed out.
1 Hardware Circuit Design
1.1 Overall structure
The design of multi-rate single-phase energy meter is completed based on AT89S52 single-chip microcomputer. AT89S52 has the following functions: 8k bytes of Flash memory, three-level encrypted program memory, 256 bytes of internal RAM, 32 programmable I/O lines, 3 16-bit timers/counters, a 6-vector two-level interrupt structure, a full-duplex serial communication port, on-chip oscillator and clock circuit, and two low-power working modes. It is a cost-effective 8-bit single-chip microcomputer that is more suitable for input detection of switch signals. The hardware design of the energy meter mainly includes six modules: voltage and current detection energy metering circuit AD7755 module, serial storage and watchdog X25045 circuit module, HT1621 liquid crystal display circuit module, serial clock S3530A circuit module,
The overall structure of the RS485 bus communication circuit module and the anti-electricity theft detection circuit module is shown in Figure 1.
Figure 1: System overall structure diagram
1.2 Electricity Metering
Single-phase electric energy metering is implemented using the low-power AD7755 chip from ADI of the United States. In addition to the ADC, filtering and multiplication circuits, the AD7755 uses digital circuits to effectively eliminate interference signals such as sharp pulses, allowing it to maintain extremely high accuracy and stability under harsh environmental conditions. The voltage and current signals in the single-phase circuit are sampled, the power is calculated and integrated to convert it into electric energy pulse output. The CPU measures the pulses from the output terminal CF of the AD7755 and calculates the cumulative power consumption of the electric energy meter. The relationship between electric energy and pulses is: W=M/C, where W is electric energy in kilowatt-hours, M is the cumulative number of pulses, and C is the pulse constant of the meter. Select C=1600, and there are 1600 pulses per kilowatt-hour.
1.3 RS485 communication MAX487 chip realizes RS485 communication control of multi-rate energy meter
The MAX487 chip has RS485 communication protocol, can carry 128 lower computers, the transmission distance is greater than 1km, and the transmission rate is up to 250kb/s. The electric energy meter is connected to the power management computer through the RS485 bus. Each electric energy meter has a unique eight-digit hexadecimal meter number. For the first installation, the electrician needs to record the user information and meter number and enter it into the power management computer to complete the connection between the user and the management computer. The management computer uses broadcast communication to transmit the time period setting and time calibration information. At this time, there is no address information, and the electric energy meter interrupts reception; the upper computer uses the calling address method to upload information, that is, calling someone's address, and the electric energy meter will package the information and its check code and send it to the power management computer to realize the power back copy. MAX487's DE is the transmitter enable terminal. When DE is 1, the transmitter can work. DI is the input terminal, and A and B are the output terminals. When DE is 0, the transmission stops and the output terminal is high impedance. RE is the input enable terminal. When RE is 0, the receiver is allowed to work. A and B are input terminals, and RO is the output terminal. When RE is 1, the receiver is disabled and RO is in high impedance state. Therefore, half-duplex communication is adopted, DE and RE are connected and then connected to P1.4 of AT89S52, and the P1.4 pin of AT89S52 is used to control the sending and receiving working state.
1.4 Serial Memory
The serial memory uses the X25045 low-power chip from XICOR, USA. It has three functions: watchdog timer WTD, power supply voltage monitoring, and serial E2PROM memory with 512 bytes. WTD can be set to 200ms, 600ms, and 1400ms dog feeding time intervals, and the software programming is written into X25045. During the normal operation of the program, WTD receives a trigger signal within the time interval to ensure the normal operation of the program. If one end of WTD does not receive a trigger signal within the time interval, X25045 outputs a high-level signal through the RESET pin to trigger the reset of the energy meter to prevent the program from running away. As a serial memory chip, X25045 uses 512 bytes to store energy meter coding, multi-rate time period settings, peak, flat, valley electricity and total accumulated electricity in the previous month and the current month. The storage can be rewritten 100,000 times, and the data can be saved for 100 years. It can be connected to AT89S52 using the SPI protocol bus interface.
1.5 Clock Circuit
The clock circuit is completed with the S3530A chip, which is a low-power clock chip that supports the I2C bus. It sets the clock and calendar according to the time calibration data received by the CPU via RS485 communication, and continues to run by its own oscillation. A 32.768kHz crystal oscillator is connected across the Xin and Xout pins of the S3530A. It is connected to the CPU via a two-wire method, with the SDA pin and the SCL pin connected to P2.0 and P2.1 of the AT89S52 respectively. There are two interrupt alarm pins that can be set to output second or minute synchronization pulses, providing an interrupt signal with a period of 1 second to the AT89S52. The single-chip system will read the current time through the I2C communication interface based on the signal, calculate the time period to which the moment belongs, and realize the time-division metering of electric energy for multi-rate electric energy meters. The clock circuit has a backup lithium battery. When working normally, it is powered by the power supply Vcc and charges the 3.6V lithium battery at the same time; when there is a power outage, the lithium battery is automatically switched to power the clock circuit, and the clock runs correctly even if there is a power outage.
1.6 LCD display
The HT1621 LCD display driver chip of HOLTEK is used to realize the 16-bit LCD digital display. HT1621 is an LCD driver with 128 segments (32×4) built-in memory. It includes control and timing circuits, display RAM, LCD driver and bias, monitoring timer, etc. It uses a 48-pin SSOP package, which has the advantages of small size and low power consumption. It is very suitable for application in electric energy meters. Its interface circuit and peripheral circuit are simple. It uses a serial interface with AT89S52, which only requires three wires. P2.4, P2.5, and P2.6 of AT89S52 are respectively connected to its CS chip select, WR write permission, and DATA serial data pins to control the refresh display RAM buffer. In addition, a 20kΩ adjustable resistor is connected between VDD and VLCD to adjust the LCD display contrast. Adjust the resistor so that VDD=5V and VLCD=4V have a better contrast.
1.7 Anti-electricity theft detection, etc.
Record the number of times the terminal cover of the energy meter is opened manually to analyze whether electricity is stolen. After the energy meter is installed, the case is sealed with a lead seal. Users cannot open the cover of the energy meter connection without permission to destroy the seal, otherwise it will be considered as electricity theft. Therefore, we use a Hall sensor to detect whether the terminal cover is opened. If the terminal cover is opened, the level of the P1.6 pin of the AT89S52 changes, and the cover is opened once. Record the number of times the terminal cover of the meter is opened and damaged manually to determine whether electricity theft occurs. When electricity theft is found, an alarm is given, the power is cut off, and it is uploaded to the upper management computer in time. Practice has proved that this novel anti-electricity theft technology effectively prevents electricity theft and has a good effect. The block diagram of the detection circuit is shown in Figure 2.
Figure 2: Anti-electricity theft detection block diagram
The power-off protection circuit uses the P1.7 input pin of AT89S52 to detect the power-off signal. When the system is working normally, P1.7 is at a high level. When a power failure occurs suddenly, P1.7 becomes a low level. After the query method detects that P1.7 becomes a low level, the power-off protection program will be entered. There is a large filter capacitor 1000uf/25v in the power supply circuit, which can maintain the system working time for more than ten seconds after power failure, ensuring that the electric energy meter stores important data. The photoelectric isolation circuit uses 4N35 photoelectric isolators at the pulse output end, relay control end, and RS485 communication end of the system. The electrical signal is transmitted through the coupling effect of light, and the interference source and the part susceptible to interference are isolated, thereby improving the system's anti-interference ability.
[page]
2 Software Programming
2.1 Software Program Resource Allocation
The software program of multi-rate single-phase energy meter includes eight program modules: initialization and main program, X25045 reading and writing program, RS485 serial communication processing program, interrupt processing program, timer processing program, HT1621 display control program, energy time-segment measurement and power-off processing program, system self-check and software anti-interference processing. The interrupt resource allocation of the system is INT0 interrupt for AD7755 pulse detection, INT1 for second synchronization detection, timer T0 for timing 100ms, T1 is not used, T2 is used for serial communication program baud rate generator, and serial port interrupt is set as RS485 asynchronous communication receiving interrupt.
2.2 Design of program modules
The main program module of the working process of the energy meter is shown in Figure 3. Initialization is required every time the power is turned on. The initialization includes the setting of the working mode of the AT89S52 single-chip microcomputer timer, serial port, interrupt, etc., and the control word of the serial storage chip X25045, the control word of the serial clock chip S3530A, and the control word of the serial LCD driver chip HT1621. The initial operation of the new energy meter requires the initial value of X25045 to be set, including the setting of the energy meter number, the setting of the time period, the setting of the clock, the allocation of the storage address, etc. This system sets three time periods. The single-chip microcomputer reads the clock value from the clock chip S3530A every second, and then analyzes which time period the moment belongs to according to the pre-set time period in the serial storage chip X25045. According to the corresponding time period, the electric energy is stored in the RAM memory of AT89S52, and then the electric energy is written into the corresponding address of X25045 every time it accumulates 1 degree. The 16-bit LCD display displays the time period and electric energy information in turn. If there is a communication request, the interrupt mode will be used to communicate data with the host computer. If there is a power outage, the power-off protection program will be executed. The flow charts of other program modules are omitted.
Figure 3: Main program flow chart
Test Results
The electric energy meter was tested for error and operation at Zibo Beilin Electronics Co., Ltd. The upper computer completed the power management period setting and set three rate periods. The first period was from 00:00 to 06:30, which was the valley period. The second period was from 06:30 to 22:30, which was the peak period. The third period was from 22:30 to 24:00, which was the flat period. The rate period setting was set by the power supply company in the computer management system according to national policy regulations, transmitted to the electric energy meter through RS485 serial communication, and stored in X25045. The peak, flat, valley, and cumulative electricity of each month were stored in the electric energy meter and packaged and transmitted to the upper computer management system. The communication baud rate was set to 9600 bit/s. The 0.1-level standard electronic electric energy meter calibration station was used as the standard meter, and the multi-rate electric energy meter was the meter under test. Beilin Electronics Co., Ltd. conducted tests under different load conditions. Due to space limitations, only the measured data when the load was 5KW were listed as shown in Table 1. The test results show that the error of the multi-rate electric energy meter is less than 1%, which belongs to the 1.0 level standard. The experiment shows that the method to reduce the error of electric energy measurement is: first, adjust the matching resistor of AD7755 to an accurate value; second, the resistance value of the matching resistor is required to change less with temperature; third, in the process of electric energy measurement, when switching time periods, the electric energy with a tail part of less than 0.01 degrees is counted into the next time period, avoiding the loss of less than 0.01 degrees of electric energy and causing errors in the accumulated electricity.
Table 1: The measurement values of the standard meter and the meter under test meet 5KW
Conclusion
The multi-rate energy meter can realize time-sharing measurement of energy according to different time periods, and adopts RS485 serial communication to realize automatic reading of electricity and real-time time calibration. The energy meter produced by Zibo Beilin Electronics Co., Ltd. has novel design technology, accurate measurement, precise timekeeping, flexible time period setting, novel anti-electricity theft design, and all technical indicators meet the national technical standards for multi-rate energy meters, and has broad application prospects.
The innovation of this article is that the AD7755 energy metering chip is used for accurate measurement; the serial X25045 storage is flexible and reliable, the serial clock S3530A is accurate, the RS485 bus transmission is highly reliable, and the anti-theft power design is novel. The I2C bus structure multi-rate single-phase energy meter design is more reasonable and has the characteristics of high cost performance.
Previous article:Hardware design of greenhouse intelligent controller based on single chip microcomputer
Next article:Applying MCU-based decoders to security systems
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- 【TI recommended course】#Lecture on basic knowledge of electronic circuits#
- Low-pass filter waveform distortion problem
- Questions about PCB antenna
- [RVB2601 Creative Application Development] RVB2601 Hardware Part--1
- #Servo What is a servo?
- Questions about rotary transformers
- Help, the turn-off speed problem related to the MOS tube drive resistor
- SIwave Chinese Training Manual
- Job hunting after the epidemic
- What are the advantages of machine vision defect detection systems?