The principle of the electronic counter
To calculate the electrical energy consumed over a period of time necessary to integrate in time the instantaneous values of active power. For a sinusoidal signal power is equal to the product of the voltage across the current in the network at any given time. On this principle works of any electricity meter. In Fig. 1 shows a block diagram of an electromechanical counter.
In Fig. A. Block diagram of the electromechanical meter electricity
The implementation of a digital power meter (Fig. 2) requires specialized IC capable of producing the multiplication of the signals and provide the value obtained in a convenient form of a microcontroller. For example, the converter active power - in the pulse repetition rate. The total number of arriving pulses, counted microcontroller is directly proportional to energy consumption.
In Fig. Two. A block diagram of a digital power meter
No less important role played by various service functions such as remote access to the meter, to information on the stored energy, and many others. The presence of a digital display, controlled by a microcontroller allows software to set different modes of output, for example, display information about the energy consumed per month, according to various rates and so on.
In order to perform some unusual features, such as matching levels using additional IP. Now started to produce specialized circuits - power converters in the frequency - and specialized microcontrollers that contain such converters on the chip. But often they are too expensive for use in municipal induction meters. Therefore, many global manufacturers of microcontrollers are developing specialized chips designed for such use.
Let us analyze the simplest version of the construction of a digital counter to the most low-cost (less than a dollar) 8-bit microcontroller Motorola. In the presented solution implemented all of the minimum necessary functions. It is based on the use of low-cost IP transmitter power in the frequency of the pulses KR1095PP1 and 8-bit microcontroller MC68HC05KJ1 (Fig. 3). With this structure, the microcontroller is required to summarize the number of pulses output to the screen and carry out its defense in a variety of emergency conditions. Considered the counter is actually a digital functional analog of the existing mechanical meters, fitted to a further improvement.
In Fig. Three. The main components of the simplest digital electricity meter
Signals proportional to the voltage and current in the network are removed from the sensors and fed to the input of the converter. IP converter multiplies the input signals to obtain the instantaneous power consumption. This signal is fed to the input of the microcontroller, which converts it into Wh, and the accumulation of signals, changing the meter. Frequent disruptions of supply voltage leads to the need to use EEPROM to store the counter. Since the failure of food is the most characteristic of an emergency situation, such protection is necessary in any digital counter.
The algorithm of the program (Figure 4) for the simplest version of the counter is pretty simple. When you power the microcontroller is configured in accordance with the program reads from the EEPROM the last stored value and displays it on screen. The controller then switches to count the pulses coming from the IP converter, and the accumulation of each Wh, increases the counter.
In Fig. 4. The algorithm of the program
When writing to the EEPROM value of the stored energy can be lost at the time of power failure. For these reasons, the value of the accumulated energy stored in the EEPROM cycle to each other through a number of changes to the counter, set the software, depending on the required accuracy. This avoids loss of data stored energy. When the voltage microcontroller analyzes all the values in the EEPROM and chooses the latter. For minimal loss of sufficient importance to record with a 100 W · h This quantity can be changed in the program.
The scheme of the digital calculator is shown in Fig. Five. X1 is connected to the terminal voltage of 220 V and the load. With the current and voltage sensor signals are fed to the converter chip KR1095PP1 with opto-coupler frequency output. The basis of the counter is a microcontroller MC68HC05KJ1 firm Motorola, produced in 16-pin package (DIP or SOIC) and has 1.2 Kbytes of ROM and 64 bytes of RAM. To store the accumulated amount of power failures on the power supply is used EEPROM 24S00 small volume (16 bytes) from Microchip. As the display uses 8-digit 7-segment LCD, controlled by any low-cost controller, exchanging with the central microcontroller via SPI or I 2 C and a plug connector X2.
The implementation of the algorithm required less than 1 KB of RAM and at least half of the input / output ports of the microcontroller MC68HC05KJ1. Its capacity is sufficient to add some service functions, such as the union of the counters in the network via RS-485. This feature will provide information on the stored energy in the service center and off the electricity in the absence of payment. A network of such counters can be equipped with a multi-storey residential house. All testimony will be received over the network to the control center.
Of certain interest is a family of 8-bit microcontrollers with on-chip located FLASH-memory. Because it can be programmed directly on the board collected, provided security code and the ability to update software without installation.
In Fig. Five. Digital computer for the digital meter
Even more interesting version of the meter without an external EEPROM and costly external non-volatile RAM. It is possible for an emergency fix the testimony and service information into the internal FLASH-memory microcontroller. This also ensures the confidentiality of information which can not be done when using an external crystal, is not protected from unauthorized access. These power meters of any complexity can be implemented using microcontrollers from Motorola HC08 family of FLASH-memory located on chip.
The transition to digital automatic control and accounting system of electricity - a matter of time. The advantages of such systems are obvious. Their price will keep falling. And even the simplest microcontroller such digital meter has obvious advantages: reliability due to complete lack of friction elements, compactness, possibility of making the case in the light of contemporary interior homes, increasing the calibration period of a few times, maintainability and ease of maintenance and espluatatsii. With little additional hardware and software costs, even a simple digital counter may have a number of service functions that are absent in all the mechanical, such as the implementation of multi-tariff payments for energy consumption, the possibility of automated accounting and control energy consumption.

