Realizing High-precision Digital Watt-hour Meter Using PIC16C73

Publisher:genius6Latest update time:2017-12-07 Source: eefocusKeywords:PIC16C73 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Design concept of digital household electricity meter

In recent years, digital household electricity meters have been rapidly promoted and applied in China, and have great market prospects. From the perspective of the requirements for household electricity meters, they mainly include the following aspects: (1) The accuracy must be higher than the original analog electricity meter by 2%; (2) The cost cannot be too high. As a common civilian appliance, the cost of household electricity meters will directly affect its promotion and application; (3) The reliability must be high. Based on the author's practical experience over the past few years, this article mainly introduces the basic design ideas of using PIC16C73 series microcontrollers to realize ordinary household high-precision digital electricity meters. The main reason for selecting the PIC16C73 series microcontroller is that it contains an on-chip analog-to-digital conversion ( A/D ) channel, which can save the dedicated A/D chip, and each input and output pin can be operated by programmable bits. The output pin has strong driving capability and can directly drive the digital display. In this way, including other IC card data reading circuits, E2PROM and other peripheral circuits, the overall mass production cost (1000 yuan) of 20A (10A) digital electricity meter can be controlled at a low level; PIC16C73 single-chip microcomputer is more suitable for working in industrial environment, and its anti-interference ability is much stronger than that of 51 series single-chip microcomputers; PIC16C73 single-chip microcomputer also has a software watchdog. When the electricity meter is subject to strong interference or other influence programs "flying", the watchdog can reset the single-chip microcomputer in time and resume normal operation, thus ensuring the high reliability of the electricity meter. When implemented, the single-chip microcomputer A/D channel continuously samples the grid voltage and the user's power current , and after real-time calculation and accumulation by the single-chip microcomputer CPU, the user's power consumption is finally obtained and deducted from the power purchased by the user (recorded in the E2PROM chip). The block diagram of the digital household electricity meter composed of PIC16C73 single-chip microcomputer is shown in Figure 1.

Since the precision of the A/D channel in the PIC16C73 microcontroller is eight bits, the theoretical value of its sampling error is about 1/(28-1), that is, its full-scale precision is about 0.4%. The accuracy of the digital meter can be guaranteed when the meter is working at full scale (referring to current).

Figure 1 Block diagram of digital watt-hour meter

Under normal circumstances, the general household electricity load is unlikely to reach the maximum value allowed by the meter most of the time. If no special measures are taken, the error of the meter will increase significantly. For example, for a 20A meter, its full load value is 4.4kW. At this time, the error of the meter is about 0.4%, which can meet the 2% requirement of ordinary meters; if the user's power load is 100W (the working current is about 0.5A at this time), the error of the meter caused by the A/D sampling error alone will reach about 16%. Therefore, in order to ensure that the accuracy of the meter within the full load range can meet the index requirements, when designing the circuit, it is necessary to adopt segmented management according to the user's power current or other similar methods to reduce the A/D sampling error and achieve the purpose of improving the accuracy. At the same time, in order to ensure that the accuracy of the meter is not affected by the difference in the use environment (temperature, humidity, etc.), the meter also needs to design a self-calibration circuit to correct the error caused by the circuit parameter offset caused by environmental changes in real time. In addition, the various components used in the actual production and assembly of watt-hour meters are discrete, which will cause certain inconsistencies in the accuracy and other indicators of the finished watt-hour meters assembled according to the principle circuit. In order to simplify the debugging process in the production process, a software online debugging circuit is also specially set up in the watt-hour meter, and the software parameter adjustment replaces the previous hardware parameter adjustment (such as adjusting the amplifier amplification with a potentiometer, etc.), thereby greatly improving the debugging efficiency of the finished product and the product qualification rate. After adopting the above measures, the actual full-process accuracy of the finished watt-hour meter is better than 0.5% (that is, the error is less than 0.5%).

The main function of the overcurrent and overvoltage control protection circuit in Figure 1 is to control the relay to cut off the user's power supply circuit according to the software design requirements when the user's load is too large (i.e. overcurrent) or the grid voltage is too high (instantaneous process, such as lasting 10 seconds or half a minute, etc., which is specifically set by the program). After waiting for a certain period of time (such as 5 minutes), it will automatically supply power and then monitor. If overcurrent or overvoltage faults occur for 2 or 3 consecutive times (the specific number is determined by software programming), the watt-hour meter will no longer automatically supply power, and the overcurrent or overvoltage information will be displayed on the digital display (mainly used to display power data during normal operation).

The meter display has 5 digital tubes , which can be set according to the program (such as -2 degrees, -10 degrees) to allow users to borrow electricity appropriately. At this time, the digital tube displays special symbols and values ​​to warn users to purchase electricity in time. The display accuracy is 0.1 degrees, and the internal cumulative calculation accuracy of the meter is selected to be 10-4 degrees, thereby reducing the impact of power outages to a completely negligible level (achieved by E2PROM).

 

2 Core Circuit Principle

2.1 PIC16C73 Microcontroller

PIC16C73 is a low-power, high-performance, CMOS , fully static, 8-bit EPROM-type microcontroller with an addressing space of 4K×14. It adopts advanced RISC instruction structure, 8-level stack, and multiple internal and external interrupt sources. It has 192 bytes of RAM and 22 I/O ports, 3 timers/counters, 2 serial ports, and 5-channel 8-bit A/D. The synchronous serial port can be set to 3-wire SPI or 2-wire I2C mode, and the serial communication port (SCI) can be set to synchronous or asynchronous mode. There are two main types of PIC16C7´ series microcontrollers. One is a low-cost one-time user programmable device (OTP), which is suitable for batch products; the other is a UV-erasable dual in-line chip, which can be used for product development or small-batch production applications. Its pin arrangement is shown in Figure 2.

Figure 2 PIC16C73 (Dual In-line) Pinout

The detailed functions of each pin can be found in reference [1].

 

2.2 Digital tube display interface circuit

The PIC16C73 microcontroller is equipped with a dedicated serial data transmission port (pin RC5/SDO) and a corresponding clock signal transmission port (pin RC3/ SCK ). In this way, the display data can be mainly completed by these two ports, and the circuit is shown in Figure 3.

Figure 3 Digital tube display interface circuit

In Figure 3, the reset pin (MR) of the 74LS164 chip is connected to the reset pin MCLR of the PIC16C73 microcontroller. The RC3/SCK pin of the microcontroller is used to generate a serial port synchronous clock signal. The RC5/SDO serial data is output to the serial input terminal of the 74LS164 chip. After serial/parallel conversion, the parallel code is output and sent to the digital tube display through the current limiting resistors R1~R8. The 5 common cathode digital tubes are connected in a scanning mode. The scanning time interval is the same as the A/D sampling period , which is 2ms. Its cathode L1~L5 is respectively connected to the RB0~RB4 pins of the microcontroller (these pins have the ability to directly drive the digital tube). The light-emitting diode D is mainly used as a decimal point (it can also be used for program debugging). The characteristic of this circuit is that it makes full use of the performance of the PIC16C73 microcontroller that each pin can be programmed individually, and the efficiency is relatively high.

 

2.3 Grid voltage sampling and processing circuit

The theoretical voltage value of the household power grid in China is 220V 50 Hz . Due to various factors, the fluctuation range of the power grid voltage is large (sometimes lower than 150V during peak hours). In this way, in order to improve the accuracy of the electric meter, it is necessary to sample the grid voltage in real time to take into account the impact of grid voltage changes on the power consumption and electricity consumption of users. The signal sampling and processing circuit is shown in Figure 4.

In Figure 4, metal film resistors RJ1 and RJ2 with an accuracy of 0.5% are selected as sampling resistors. The main starting point is to improve the stability of the voltage sampling of the watt-hour meter and the consistency of mass-produced products, and to reduce the debugging workload; resistor R1 mainly plays an isolation role, and resistor R2 plays a stabilizing role (it can also be omitted); the operational amplifier (1/2MC1458S) is used as a follower.

Figure 4 Voltage signal sampling and processing circuit

 

2.4 Current sampling and processing circuit

Residential electricity load is reflected in the magnitude of the current, so the range of user current is much larger than the grid voltage fluctuation, and its range is generally from 0 to full scale. The circuit for real-time sampling and processing of user current signals is shown in Figure 5.

Figure 5 Current signal sampling and processing circuit

 

The current sampling resistor RJ3 in Figure 5 uses a manganese-copper alloy resistance wire with an accuracy of 0.02% and a resistance of 0.01Ω. Considering that the load of the household meter is not large (usually 10A or 20A, etc.), a series sampling method is adopted, and the circuit is simple and effective. The follower and the voltage sampling circuit in Figure 4 share an MC1458S operational amplifier.

 

2.5 Current Shift and Channel Self-Calibration Circuit

The current shifting and channel self-calibration circuit is the most critical part of the designed digital watt-hour meter, and its principle circuit is shown in FIG6 .

The whole circuit design is ingenious, efficient and very economical. It only uses three chips, one LM324 and two analog switches CD4051. LM324 contains four operational amplifiers and uses ±5V power supply. The three channel control lines of U1 CD4051 are KZ1~KZ3, which are connected to the pins RB4~RB7 of the microcontroller; the three channel control lines of U2 CD4051 are KZ4~KZ6, which are connected to the pins RC0~RC2 of the microcontroller respectively.

Usually, even if the grid voltage is unstable (such as 150~240V), its relative change is still small (less than 50%) compared to the current. Therefore, there is no need to shift and amplify the voltage sampling signal in the circuit, and the total amplification factor of the circuit for the voltage sampling signal is 1.

Since the current sampling signal has a large variation range, it is necessary to perform a gear shift amplification process. Figure 6 shows three cascade amplifiers A1~A3 with a gain factor of 6. For example, taking a 10A watt-hour meter as an example, the current range corresponding to the amplified output of A1 is 2~10A, the current range corresponding to the amplified output of A2 is 0.5~2A, and the current range corresponding to the amplified output of A3 is

 

 Figure 6 Current shifting and channel self-calibration principle circuit

The current range is 0~0.5A. The sampling interval of current and voltage signals in the circuit is 2ms, that is, 10 samples are taken for each 50Hz sine cycle. When the power is just turned on, the current signal channel is selected as the maximum gear, and the effective value of the sample is calculated based on the sampled value of a sine cycle (a total of 10) , and then compared according to the gear set by the program to determine whether to shift gears (if the sampled effective value is small, the amplification amount needs to be increased and shifted to the next gear); when working normally, the up or down gear shift is determined based on the effective value obtained by sampling in the previous cycle. The microcontroller calculates the power consumption in different calculation methods according to different gears.

Considering that the chips and other components used in the circuit are relatively cheap common devices, it is inevitable that there will be a certain degree of discreteness in the work. Therefore, in order to ensure the accuracy of the electric meter, each channel needs to be calibrated in real time. First, four relatively stable reference voltage signals (i.e. Vref and Vref1~Vref3) are generated. Vref1~Vref3 are sent to two analog switch chips U1 and U2 respectively, and Vref (-2.5V) is sent to the output stage summing amplifier of analog switch U2 (amplification factor is 1). The specific implementation method is as follows:

  1. A/D linear detection. The single-chip microcomputer controls the analog switch U2 to select the 4th to 6th channels (X4 to X6) respectively. After the single-chip microcomputer A/D sampling, the linearity of the A/D channel (including the output stage amplifier, i.e. A4) can be grasped in real time (such as monitoring once a minute), thereby realizing the correction of the actual sampling value.

  2. Voltage channel self-check. The single-chip microcomputer controls KZ4~KZ6 to 111, controls the analog switch U2 to select the 7th channel (X7), and after the single-chip microcomputer A/D sampling, the drift of the voltage channel A4 can be grasped in real time (such as monitoring once a minute), thereby realizing the correction of the actual grid voltage sampling value.

  3. Current channel zero drift self-check. The single chip controls KZ1~KZ3 (001), the analog switch U1 selects the 4th channel (X4, the input is 0 signal), and the analog switch U2 selects the 1st, 2nd and 3rd channels (X1, X2 and X3) at the same time. After A/D sampling, the drift of the three current channels can be grasped in real time (such as monitoring once a minute), thereby realizing the correction of the actual current signal sampling value.

  4. Current channel linearity detection. The MCU sends the same channel selection code to KZ1~KZ3 and KZ4~KZ6, and the two analog switches U1 and U2 simultaneously select channels 1, 2 and 3 (X1, X2 and X3). After sampling by the MCU A/D, the linearity of the three current channels can be grasped in real time, thereby realizing the correction of the actual sampling value.

 

3 Conclusion

We have given the design scheme and core circuit of a high-precision digital watt-hour meter based on the PIC16C73 microcontroller, analyzed its working principle, and achieved the design requirements with the corresponding program, with good actual effect.


Keywords:PIC16C73 Reference address:Realizing High-precision Digital Watt-hour Meter Using PIC16C73

Previous article:PIC12C508/509 Light Brightness Adjuster
Next article:PIC microcontroller LCD display clock demonstration program

Recommended ReadingLatest update time:2024-11-17 03:01

Realizing High-precision Digital Watt-hour Meter Using PIC16C73
1 Design concept of digital household electricity meter In recent years, digital household electricity meters have been rapidly promoted and applied in China, and have great market prospects. From the perspective of the requirements for household electricity meters, they mainly include the following aspects: (1) The a
[Microcontroller]
Realizing High-precision Digital Watt-hour Meter Using PIC16C73
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号