Design of An Intelligent Split-type Electricity Utilization Measurement and Control Terminal for Local Household Energy Management and Optimization

.


Introduction
In recent years, with rapid development of cyberphysical systems (CPS), the concepts of energy Internet and smart energy [1-3], and the electricity market [4], demand response (DR) technology is an effective mean to solve the issues of renewable energy accommodating and real-time balance of power system supply and demand [5][6][7].Among them, the automatic demand response (ADR) is an important embodiment of the power system and user sides to participate in the energy Internet [1,8].With the improvement of people's living standards, the proportion of household electricity loads in the total social power load will continue to increase [9,10].The importance of household users' participation in demand response based on home energy management systems (HEMS) is increasingly prominent [10][11][12][13].In addition, smart metering systems [14] and advanced metering systems [15] have been gradually applied to home users' energy management systems.The key to realizing the ADR of home-side loads is to develop smart electricity terminals that can achieve complete and accurate data collection of power consumption and flexible and effective load control functions [16,17].
Regarding the related research of smart power terminals, at present, the intelligent controller developed in [18] has the functions of electrical metering, wireless communication, and remote control, but it can only perform on-off control and does not have load adjustment capability.An intelligent device design integrating infrared transceiver module and wireless communication module is proposed in [19], with remote control, communication networking and other functions, but only supports 38kHz carrier frequency infrared signal, and does not have the function of power consumption information collection.A smart power terminal is developed in [14] based on DSP chip.Thanks to the computing advantages of DSP, this device implements powerful data analysis functions, with remote control and timing control capabilities, but still simple on/off control.In [20], a type of demand response controller is designed with functions of power data acquisition and infrared remote control.However, due to the use of a single-chip microcomputer as the core chip, the computational processing capacity is limited, and it is difficult to support high-frequency sampling and data analysis functions.Its infrared control only supports the carrier with frequency of 38kHz, no infrared encoding library is configured, the use of a slightly more complex, and does not consider the characteristics of infrared light linear propagation, did not mention the infrared transmitter head shape and layout.
From the above investigations, it obtains that most existing devices have the disadvantages of a simple control method and weak data acquisition and processing capabilities.The simple control method of non-stop and disconnection makes the adjustable electrical equipment such as air conditioners and fans lose the ability to regulate continuously.Infrared remote control is the first-choice low-cost solution for realizing the precise control of such appliances.At present, however, some devices with infrared control function still have problems such as single infrared carrier frequency and no infrared encoding library.In addition, since the device is generally installed behind the electrical appliance, the design of the device and the infrared module does not take into account the possibility that the linear propagation of the infrared light may encounter obstacles, thus limiting the flexibility and application scene of the device.
Based on this, this paper integrates digital signal processing and infrared remote control technologies, and considers the actual application requirements, thus designs a split-type smart electricity measurement and control terminal with power data acquisition and analysis, environmental state awareness, and load flexible regulation functions.This intelligent terminal is able to adapt to a complex home environment, which ultimately can lay a solid hardware foundation for realizing effective home energy management and promoting family load participation in demand response.

Basic hardware structure
Taking into account the complex changes in the home environment and the characteristics of infrared light linear propagation, the smart electricity monitoring and control terminal developed in this paper adopts a splittype design approach.Specifically, we divide the terminal into two components: the device body and the air conditioning controller.Among them, the device body is used for electrical quantity data collection and circuit on-off control of the electrical equipment, and the infrared controller can be freely placed to avoid the inadequacies of infrared wireless communication and achieve accurate control of the electrical equipment.In this paper, the ZigBee module can be used to achieve wireless communication between the developed device body and the infrared controller.

Hardware design of the device body
The hardware design scheme of the device body is demonstrated in Fig. 1.

Core processing unit design
As the smart electricity measurement and control terminal needs to achieve the following functions: including the collection of power frequency electrical quantity, AD conversion and FFT and harmonic analysis.At the same time, it needs to be compatible with both WIFI and ZigBee wireless communication methods.Therefore, the terminal needs to have complex functions, which requires its core processor to have strong computing power, faster control capability, and more communication interfaces.Therefore, in the design of this paper, we chose a DSP chip produced by the United States TI Company, namely TMS320F28335.This chip has a high-speed processing capability of 150MHz and a 32-bit floating-point processing unit that can carry SCI, SPI, I2C serial communication interfaces, and eCAN, ADC and other functional modules.Therefore, this DSP chip is very suitable as the core processor of the smart power terminal.

Design of electrical quantities measurement with power frequency
The idea of processing the electric quantity signals is to convert the electric quantity analog signals through the signal conversion of the voltage/current transformers and the amplifier chip.Thereby, the signals are made to satisfy the 5V input amplitude requirement of the ADC chip, and then through the ADC chip, the AD conversion is performed.Finally, these digital signals are transmitted to the DSP chip for digital signal processing.The wiring is illustrated in Fig.The ADC chip model chosen in this design is AD7606, this chip can realize 16 synchronous sampling, the sampling rate is as high as 200k, can guarantee the sampling speed and precision.
The voltage transformer is a 2mA/2mA current-type voltage transformer with model of DL-PT2020H.The input voltage signal is obtained from the live line and the neutral line.After the current limiting resistor Ru1, the voltage signal is converted into a 2mA current signal input to the transformer.In this case, the transformer implements a 1/1 AD conversion and outputs 2mA, and then passes through the parallel-connected resistor Ru2 at the output to reconvert the current signal into a 2V voltage signal to meet the ADC input limit.Current transformer selection is DL-CT1010A, turns ratio is 1000/1.When the input current is a rated value of 16A, the transformer outputs current of 16mA, converted into a 320mV voltage signal through the sampling resistor SR1, and then achieve 10 times the signal amplification through the op amp circuit, and finally achieve 3.2V output signal.
Compared with the traditional resistive voltagedividing acquisition method, the influence of the temperature rise of the sampling resistor on the sampling accuracy is avoided, and the accuracy of the transformer sampling is higher.In addition, the transformer realizes electrical isolation between the distribution network side and the device side, thereby protecting the device itself.

Design of wireless communication function
The intelligent power terminal supports both ZigBee and WIFI wireless communication methods.The ZigBee communication method is used to issue control commands to the infrared controller, and the data collected by the device body is uploaded to the cloud server through the WIFI communication method.
ZigBee communication power is small, selforganizing ability is strong, communication distance is far, can reach 1km as far as possible, the shortcoming is that the transmission speed is slower, it is suitable for the device body and infrared controller this kind of communication that there is less communication volume, communication distance is uncertain.ZigBee module is selected DRF1609, its powerful processing power, easy to use.The intelligent terminal uses a set of serial ports to connect with the ZigBee module, the baud rate is set to 38400, the device body is set as the master node, the infrared controller is set as the slave node, and the transparent control mode is used to issue the control command.
The WIFI communication speed is fast and the data volume is large.Since a large amount of data needs to be transmitted between the smart terminal and the cloud server, WIFI communication becomes the most suitable method.WIFI module selection for the USR-C215, the module hardware integrated MAC, baseband chip, RF transceiver unit and power amplifier, support WIFI protocol and TCP / IP protocol.The device body is set as a TCP client, and the TCP server is a cloud server for data storage.The transparent transmission mode is used to upload the electrical quantity and environmental quantity information collected in the smart terminal.

Design of other important circuits
Each module on the device body requires two different operating voltages of 5V or 3.3V.This design uses the power module HQ05P10 to realize the conversion of 220V AC to 5V DC.The efficiency of the module is as high as 78%, the output voltage is stable, the error is within ±1%, the ripple noise is low, and the overcurrent protection is provided.Then use TI's TPS73633 regulator chip to achieve 5V DC to 3.3V DC conversion.The power supply circuit is designed as shown in Fig. 3.The device has a relay for controlling the opening and closing of the electrical device.In order to prevent the interference in the circuit breaking process from affecting the normal operation of the device, the design drives the switch on and switch off of the relay through optocoupler isolation, and the circuit connection is shown in Fig. 4. The relay model is HF7520 and the optocoupler chip is PC817.DSP uses an I/O port output high and low to control the relay turn on and turn off.In order to avoid the loss of some important information in the device after power down, the device is equipped with a piece of EEPROM chip.The EEPROM is selected as AT24C64AN and I2C communication is used between DSP and EEPROM.
The device is also equipped with a temperature sensor for real-time temperature in the room.The acquisition of temperature data can provide the basis for the decision-making of the control of the airconditioning control of important objects of infrared control, and can also be used for other purposes such as user comfort.The selection of the temperature sensor is AM2302.The sensor is based on the NTC temperature measuring element.The temperature measurement resolution is 0.1°C and the measurement error is less than ±0.5°C.

Framework design of the infrared controller
The overall structure of the infrared controller is shown in Fig. 5.The controller takes the SCM as the core, communicates with the device main body through ZigBee, and controls the infrared control chip according to the command sent by the device main body.The infrared control chip takes the infrared waveform from the code library and sends it to the infrared driving chip to make the infrared transmitting head send out control signals.

Design of the MCU
In order to realize the interaction logic with the device body and complete the receiving, buffering, parsing, and execution of instructions sent to the device, and controlling the infrared signal of the infrared control chip to send and receive infrared signals and its power-saving state of hibernation, the infrared controller needs a central control unit.Considering the cost and function requirements comprehensively, this device selects the STC15L2K60S2 microcontroller.The STC15L2K60S2 is a single-clock/machine-cycle next-generation 8051 microcontroller produced by STC, which is 8-12 times faster and has 2 sets of ultra-fast asynchronous serial communication ports (UARTs).
A group of UART port of the one-chip computer is connected with ZigBee module, in order to realize and communicate with the apparatus body via the wireless ZigBee communication technology [21][22][23]; another set of UART port is connected with infrared control chip, used for controlling its movement and working state.Due to the slow sending speed of the infrared instruction, if the device body continuously transmits multiple instructions, the direct transmission to the infrared control chip will cause a conflict.In order to solve this problem, the device implements a circular queue for the instruction cache in the single-chip microcomputer and solves the problem of cooperation between the two high and low speed transmission modes.

Selection of the infrared control chip
There are many kinds of electrical products that use the infrared control mode in the electronic market.The difference in manufacturers and models has led to complex and diverse infrared signal coding schemes.In order to enhance the ease of use of the product and avoid the use of infrared coding for lengthy learning configurations before use, the device uses an infrared control chip XK2233 with a rich encoding library to solve this problem.Infrared control chip XK2233 is a high-performance solution for infrared control of household appliances, built-in infrared coded information of nearly a thousand types of air conditioner remote control, using carrier learning extension method, can learn infrared signals with different carrier frequencies and arbitrary encoding formats , support for TVs, set-top boxes, DVDs, fans and other home appliances.The chip uses an UART interface to communicate with the outside world.It supports a sleep power-saving mode with a static hold current of less than 6μA.

Design of the infrared receiving circuit
In order to enhance the expansion capability of the infrared controller, the device realizes the function of receiving and learning the infrared remote control signal.The infrared remote control signal itself is an optical signal and cannot be processed directly by the chip.It is necessary to convert the optical signal into a high-level signal through an infrared reception circuit.The infrared learning circuit is shown as graphically in Fig. 6, which consists of an infrared photodiode and a triode amplifier circuit.This structure is simple and the effect is good.

Design of the infrared transmitting circuit
Different from the manual alignment of the target device when used with a hand-held remote controller, the main objective of this device is to realize automatic control of unattended electrical appliances.In order to avoid the adjustment of the direction when installing, this device adopts a scheme of radiation distribution of 7 infrared emitters, and increases the pulse intensity to ensure reliable delivery of signals.
The infrared emission circuit consists of a driver chip and seven infrared light emitting diodes.The driver chip is ULN2003A, which is a series of Darlington transistor arrays with high voltage and high current.It features high current gain, high operating voltage, wide temperature range, and strong load capacity.The infrared light emitting diode is a 5mm light emitting diode with a light emitting wavelength of 940nm.Six of the six diodes are distributed on the six vertices of a regular hexagon and emit at an angle of 30° to the bottom.The other diode is emitted vertically upward at the centre of the hexagon.The principle of the infrared transmitting circuit is shown in Fig. 7.

Design of power supply circuit
High requirements are put on the flexibility of the installation location of the device, due to the characteristics of the linear propagation of infrared signals, and fundamentally speaking, it imposes requirements on the flexibility of the power supply of the device.In order to solve this problem, the device uses external adapter power supply and built-in rechargeable lithium battery power supply, which greatly reduces the installation cost due to power supply wiring.
The infrared controller power circuit is shown in Fig. 8.The positive electrode of the two lithium batteries and the positive electrode of the external 5V input are each connected to the regulator chip through a Schottky diode with a very low turn-on voltage drop.It can prevent the formation of circulation between the two lithium batteries or lithium battery to external power supply.The external DC power interface is a Micro-USB interface, which has the characteristics of strong versatility and ease of use.The TP4056 chip used in the charge control chip is easy to use, safe and reliable, and supports a programmable charge current of up to 1000mA.The lithium battery is a 2600mAh 18650 battery with built-in overcharge and over discharge protection, which greatly improves safety.The XC6206P332MR chip used in the regulator chip is a high precision, low power positive voltage regulator with an output voltage rating of 3.3V, which can be an ideal operating voltage for other devices.
3 Software programming design

Software programming design of the device body
The device body program consists of a main program and an interrupt service program, as shown in Fig. 9.
After the power is switched on, the program enters the initialization, configuration communication, timing and interrupt parameters.Then, the program enters a sampling cycle of 1s per cycle, and the sampling frequency is 128 sample points per week.After collecting four frequency cycles, data processing is performed to calculate the voltage and current RMS values, power, power factor, harmonic content, and other electrical parameters through discrete sample points.Then store these data in EEPROM to avoid data loss after power-down.Finally wait for the end of the 1s timer to restart sampling and repeat the above process.The interrupt service routine triggers activation after the device body receives the cloud command, first determining whether it is the local address, and if so, determining the command: if the command is data upload, the electrical quantity information stored in the device is uploaded via WIFI.If it is an IR-controlled command, the ZigBee forwarding command allows the IR controller to respond and execute.

programming design of the infrared controller
The infrared controller program is mainly composed of a main program and an interrupt service program, as shown in Fig. 10.The main program completes the hardware and software initialization of the device, and then enters the main loop to process the received instructions.When there are no pending instructions, the entire device enters a low-power state and waits for an interrupt to wake up to achieve power saving.The interrupt service routine is used to respond to the UART receive interrupt, cache the received byte to form a complete instruction, determine whether the target of the instruction is native, and store the instruction in the instruction queue, otherwise the instruction is discarded.
Based on the previous hardware design scheme, the split-type smart power measurement and control terminal based on DSP and infrared remote control developed in this paper is shown in Fig. 11 and Fig. 12

Testing of the infrared controller
For the infrared controller, we describe the position of the controlled target electrical appliance relative to the controller by establishing a spherical coordinate system on the device.The origin of the coordinate system is the centre of the centre of the infrared diode.The z-axis is perpendicular to the horizontal.The x-axis points to the centre of the infrared diode closest to the ZigBee module.The y-axis points 90 degrees to the left of the axis.In this coordinate system, the emission directions of the six infrared LEDs on the circumference can be expressed as θ=60°and φ=k×60°(k=0, 1, ... , 5), and the centre infrared LED is represented as θ= 0°.
In order to test the coverage ability of the infrared controller's transmitted signal, the transmission angle and transmission distance were tested.The experimental results are shown in the

Conclusion
This paper has developed a novel split-type intelligent electricity consumption monitoring and control terminal with digital signal processing and infrared precision control capabilities, which is able to effectively overcome the lack of flexibility in intelligent power terminal control methods and weak data acquisition and processing capabilities.This developed terminal can realize accurate collection and processing of power consumption information, as well as accurate infrared control functions, such that we can solve the issue of traditional non-stop-on-off control mode to make the adjustable power equipment lose the ability of continuous regulation.Therefore, this smart terminal is capable of changing the situations where previous infrared controllers possess single carrier frequency and have no infrared encoding library.Thanks to the split-type and rechargeable design, the terminal developed in this paper is easy to install and adapt to a complex home environment.The split-type intelligent measurement and control terminal designed in this paper will have the following use in the future.One is to lay a solid foundation of hardware for the theoretical application of the upper layer system; second is to enable many more comprehensive and diverse control strategies to be put into practice; and the last one is to provide favorable conditions for the next step of investigation, including the research on effective household energy management in the context of energy Internet, and promoting household loads participating in demand response.

Fig. 1 .
Fig. 1.Hardware framework design of the device body.

Fig. 3 .
Fig. 3. Design of the power supply circuit.

Fig. 6 .
Fig. 6.The principle of the infrared signal learning circuit.

Fig. 7 .
Fig. 7.The principle of the infrared transmitting circuit.

Fig. 8 .
Fig. 8.The principle design of the infrared controller power supply circuit.

Fig. 9 .
Fig. 9. Design of the main program and the interrupt service routine in the device body.

Fig. 10 .
Fig. 10.Design of the main program and the interrupt service routine in the infrared controller.

Fig. 11 .
Fig. 11.Prototype of the device body developed in this paper.

Table 1 ,
where the distance r is taken 2m.The testing results of the infrared emitting distance are shown in

Table 1 .
The testing results of the infrared emitting angle.

Table 2 .
The testing results of the infrared emitting distance.