Design and development of a new-type terminal for smart electricity use in the energy USB system

With the in-depth development of energy Internet, the requirements for smart electricity use (SEU) in a comprehensive energy system is higher. Aiming at the current smart electricity controllers that can only realize the monitoring of voltage, current, power and electricity consumption, while neglecting the impact of environmental quality on electricity use behaviours, this paper designs and develops a new type of terminal for SEU in the energy universal service bus system (USB), based on the techniques of digital signal processing, wireless communication and intelligent sensing. A detailed modular hardware design is given for the terminal, as well as the software design, apart from the basic functions, the terminal can complete harmonic analysis, wireless communication, on-off controlling, data display, etc. in addition, take the user perception into account through collecting the ambient temperature and humidity, as well as detecting indoor environment comfort, so that promoting home electricity use optimization. The terminal developed can play an important role in the energy USB system under the background of energy Internet, and the paper ends by giving the testing results which verify the effectiveness, intelligence and practicability of the terminal.


Introduction
The smart grid is a fully automated power transmission network which can monitor and control each user and each grid node, so as to ensure the bidirectional flow of signal and power between all the nodes in the whole transmission and distribution process from power plants to the terminals. It is based on the physical grid, integrating the modern advanced techniques, such as the sensing measurement technology, communication technology, information technology, computer technology and controlling technology, so it is a new type of power grid in high integration with the physical grid. The construction of smart grid involves the whole process of electricity generation, transmission, transformation, distribution and utilization.
Since 1980s, with the further development of energy industries, the fossil energy resources, i.e., oil, gas and coal, have becoming exhausted, together with the deepening environmental crises, faced with a looming energy crisis, the human societies are falling into a tremendous difficulty in energy utilization. As a result, a new concept of energy Internet is proposed by Rifkin J., a famous American scholar, in his latest book "The third industrial revolution: how lateral power is transforming energy, the economy, and the world". This concept acquires wide concerns at home and abroad, and in his book he deems that a new type of energy utilization system that is characterized by in-depth integrations of new energy utilization technology and information technology, that is, the energy Internet, will be emerged soon [1]. Based  develop policy instruments, accordingly to assess the extent of variance in annual electricity consumption in single-family homes as well as to estimate the impact of household features and building properties in this respect using independent samples t-tests and one-way as well as univariate independent samples analyses of variance. S. Annala et al. [8] discuss the issue of SEU, namely how to get customers involved in active demand side response, they consider that the customers have doubts about their consumption they can shift and direct control of appliances also raises many concerns and they think the microgeneration can target many of the same problems as demand response and it may also give clearer signals to change consumption patterns. Aiming at developments of smart meters that are applied in energy system, C.A.F. Lima and J.R.P. Navas [9] develop a system of smart metering to support a conscious use of water and electricity, which adds a new component to the relationship between energy business and clients / customers, who can audit and verify their consumption as well as check the reliability of the energy / water service provided. X.J. Song et al. [10] in order to achieve the goal that the ideal multifunctional smart grid electricity use monitor must be able to receive data from substations via a communication network and then process the information, they develop a LabVIEW program to analyze the received data and present it graphically for users. They give an optimized technical design of a smart grid electricity use monitor and a more efficient algorithm for data collection, processing and presentation for professional users. K.S. Cetin and O. Zheng [11] conduct a review, in which a range of technologies are discussed, including the state of their implementation and their current and future potential influence on building electricity contributions. One of the most commonly studied uses for smart meters can be consumer-oriented, which fastens on helping end-users to reduce electricity consumption [12,13], or producer-oriented, which aims to assist utilities with consumers' daily habits for the purpose of load forecasting and clustering [14,15].
So from the above introductions we know that most studies focus on user electricity use model analysis, utilization strategy analysis, smart utilization control algorithms, etc., and most of the current smart electricity use terminals can only achieve basic electrical measurement and wireless transmission, without integration of some advanced functions, such as harmonic detection, user comfort monitoring, indoor temperature and humidity measurement, etc. In order to achieve the goal of SEU, that is, to provide users with high-quality power supply services as well as improve the efficiency of electricity use, one of key factors is to acquire the complete electricity use data of the electricity use equipment and then realize the controlling of them in the network terminal. While due to a large number of various electricity use equipment in the grid, we need to install a huge number of measurement and control devices at the same time, thus we have to take into account the costs of the installed devices as well as the current supply chains of electric energy in order to realize SEU. In addition, we consider that the sockets are the most widely used distribution network terminals in the traditional grid, so, without prejudice to the basic structure of the current distribution network, we introduce the modern advanced measurement / control / communication techniques into the traditional sockets, to develop a new-type of SEU scheme based on the DSP and WiFi communication, namely, a new-type terminal for SEU, apart from the basic electrical measurement and monitoring, which can also measure the ambient comfort, as well as achieve harmonic analysis, ambient detection, wireless communication, on-off controlling, data display, etc., so that it can realize real-time and advanced electricity use monitoring and remote electricity use controlling of each electricity use equipment in the municipal government, commercial areas and residential buildings, as well as indoor ambient quality detection in the smart grid and eventually in the energy USB system.

Application of SEU terminals
The SEU terminals are media of realizing dual interaction of energy-flow and information-flow for the distributed electricity use devices and distribution networks. Set the home smart electricity use management system (HSEUMS) as an example, the application architecture of SEU terminals in HSEUMS is shown in Fig. 1 distribution network through the SEU terminals, realizing energy connection between the distribution network and electricity use devices. Meanwhile, based on the WiFi wireless communication network, the SEU terminals can be connected to the local user terminals and data service center, realizing information interaction. Among this architecture, the data service center may be a power grid corporation or a special information management company. Fig. 1 The application architecture of SEU terminals in HSEUMS If all the distributed electricity use devices in the regional grid are connected to the grid through the SEU terminals, then we can build a cloud platform to manage all the devices. And through this platform, we can use effective optimization algorithms and coordination control strategies to optimize the electricity use models of users, then we can make full use of the potential controllable loads in the these distributed devices at the same time the user electricity use comfort is not influenced, and participate in the operation of grid scheduling, so as to achieve peak shaving and load leveling and economic operation. In addition, the users can also detect the waste situations exist in their own electricity consumption through the relevant electricity-saving analysis software, and then use the SEU terminals to achieve automatic electrical shutoff control. The construction of a complete SEU management system should contain SEU terminals, information networks, data storage and analysis, and user-side application software, etc., the following section will focus on the design and development of SEU.

Overall solution design
The overall hardware solution for the SEU terminal is shown in Fig. 2, in which the hardware system is mainly composed of DSP core processing unit, ADC chip, information storage unit, signal sampling unit, power supply unit, relay modules, ZigBee and WiFi communication unit, LCD display, ambient temperature and humidity detection unit, TVOC concentration sensor, load control unit, real-time clock, Flash storage expansion unit, etc. The overall modular design of the SEU terminal According to the design shown in Fig. 2, we give a brief introduction on the working principle of the main components: the electricity use devices are connected to the incoming line terminals of distribution network through the SEU terminal; the sampling module collect the signals of current and voltage from the fire wire and zero wire, which are then converted via the ADC module and then output to the DSP chip for a series of operations; the relay is controlled by the DSP through the optocoupler drive for load control (on-off control); the storage chip is used for saving of key variables and modified parameters; the ZigBee module is used for wireless communication between the SEU terminal and the home concentrator, realizing data uploading and data integration; the ambient temperature & humidity sensors as well as the TVOC concentration sensor are used for acquisition of the interior temperature, humidity and organic compound gases, respectively, realizing environmental quality detection; the LCD display is used to show detection data for the users, improving humancomputer interaction; the system power supply unit is used to provide power for each component of the SEU terminal after a voltage conversion of the commercial power, maintaining its stable operation. Therefore, under the coordinated control of the DSP core processing unit, the SEU terminal, as a smart terminal, first monitors and records the electricity use information of the devices access to the system through its measurement unit, and then adopts the WiFi communication unit to achieve information transmission between the user terminals and the data service center, lastly the load control unit conducts the operations, i.e., regulation and control, on the electricity use devices according to the orders issued by the grid corporations or the users themselves.
We should try to make sure that each electricity use device is allocated with such a little SEU terminal, and meanwhile the home concentrator configured with the ZigBee module is installed on the outlet of the distribution box, then we can complete wireless networking between the concentrator and multiple SEU terminals, realizing the integrations of electricity use information and ambient data and monitoring of the family appliances, so that we can finally establish a complete home energy management network system. The main functional modules of SEU terminal are designed as follows.
3.1.1. The DSP-based core processing unit. The SEU terminal not only completes the basic electric data detection, i.e., voltage and current measurement, but also conducts complex calculations, i.e., FFT-based harmonic analysis, meanwhile it is also responsible for the coordinated operation between the ambient parameter sensors and each module, to satisfy the data computation ability and program storage capacity that are needed for the terminal. Consequently, in order to alleviate pressure of data processing of the remote server, the terminal needs to share part responsibility for computational and analysis tasks of the collecting data, in addition, the terminal should be able to realize some additional functions, so aiming at the core chip selection of the terminal, we select DSP chip as the core processing unit, which is as a digital signal processor, generally adopting the Harvard pipeline architecture as well as configuration of special hardware multiplier, so it has a very high speed of computing, and is easier to complete the tasks, i.e., FFT, vector control and image signal processing. Compared with the microprocessors, i.e., MCU and PLC, the DSP has stronger control performance, as well as a more outstanding ability of digital signal processing. Specifically, we adopt TMS320F28335 produced by the TI Corporation as DSP selection in this paper, which is a 32-bit single-precision floating-point real-time processor, with a dominant frequency of 60MHz, Flash 128k, RAM 20k, and as more as 45 multiplexing ports, one SCIs, two SPIs, and one ECAN network port, and is fit for the demands of precise control and real-time computation in various industries and research domains. The TMS320F28335 as the core digital processor of the developed SEU terminal, its main responsibility is to conduct data processing and coordinate each module in a stable operation state. We can see the communication links of the DSP with each functional module in Fig. 3 Fig. 4, where we first use the resistance-based current detection method, and then conduct voltage-dividing, and lastly we amplify the sampling signals, so that we can achieve the electric signal measurement. In Fig. 4, the voltage and current signals of the electricity use devices are converted into the weak voltage signals through the voltage-dividing resistance R 1 and R 2 , and the current detection resistance R 3 , and then the voltage signals U 1 and U 2 of the operational amplifier are conducted signal conditioning and amplification. The output signals of this unit, namely U 0 and I 0 , are generally amplified to three seconds of the full scale of the ADC converter. Fig. 4 The circuit design of the electric signal measurement unit In Fig. 4, the current collecting is based on the Ohm's law, generally, the constantan resistance of 2.5mΩ is connected in series in the inlet wire, which converting the big current signals into small voltage signals and then the high-frequency components through of which are filtered by the RC lowpass filtering circuit, after that, the signals are sent to the computational amplifier INA129 for signal conditioning, so as to improve the signal to noise ratio (SNR differential instrumentation amplifier with low-power consumption and high-precision. We can adjust the resistance RG (contains RG1 and RG2) between the pin 1 and pin 8 to make sure we can select any gain from 1 to 10000, and the gain calculation formula is G=1+49.4kΩ/RG, in this paper the RG is selected 5.6kΩ and 1kΩ respectively, which corresponds to 10 times amplification of the voltage signal and 50 times amplification of the current signal, respectively, so as to meet the range of signal input of the ADC chip, namely [-5V, +5V]. We select the INA129 as the operational amplifier, because the difference amplifier can suppress the common-mode noise in the input signals effectively as well as the impacts of the ground wire level voltage floating on the circuit comparing with the base amplifier. The signals sampled by INA129 are converted into digital signals by the ADC chip and then sent to the DSP for the subsequent data processing, in which the ADC chip is selected the AD7607 chip. This chip is a 16-bit, successive approximation, analog-to-digital converter as a data acquisition system that has 16-bit no missing code performance as well as high conversion accuracy, and been widely used in electric measurement. The terminal is configured with a 16-bit parallel output in hardware design and the output pins are connected to 16 I/O ports of the DSP chip. In order to achieve the on and off of the relays in a controllable way according to the demands, the built-in relay module of the terminal is selected HF7520 005-HSTP. Its maximum on-off voltage / current are AC 250V/16A, and the actuation-time under rated voltage is lower than 15ms, so it can meet the on-off requirements immediately. The relays are connected in series to the fire wire, and when the ZigBee module of the terminal receives the records of load on / off that are issued by the concentrator, one I / O pin of the DSP immediately outputs the corresponding signals to the QCTL port, in which the high level means on and low level means off, so that we can achieve automatic onoff to the loads. We choose the ZigBee as one of the wireless communication mode because it is a short-distance and low-power consumption wireless communication technique, and is as a low-power consumption LAN protocol based on the IEEE 802.15.1, in addition, it has a strong networking ability, so it is very suitable for the case with multiple network nodes. Therefore, in this paper we choose the DRF1605H as the selection of ZigBee module, which can realize the data transmission and wireless networking between the terminal and the concentrator, and they communicate with each other in a master-slave mode. DRF1605H can be configured with multiple serial port speeds, the highest of which can reach 115200, meanwhile, in aspect of design, we give consideration to both bit error rate (BER) and realtime in data transmission, and we configure its baud rate as 38400, and it communicates with the DSP via the serial port SCIB. making the terminal can not only achieve plug-and-play in information transformation, but also reduce the cost of device promotion. In development of the terminal, we select the USR-WIFI232-T module to achieve WiFi communication. It is a WiFi converting serial port module with features of low-power consumption, low cost and small size. In addition, it is integrated with many components in hardware level, i.e., MAC, base-frequency chip, RF transceiver unit, TCP / IP protocol suite, and power amplifier, so it is very appropriate for secondary development in many domains, i.e., smart home, smart grid, and handheld device. Meanwhile, this module supports UART, PWM and GPIO data communication, so it can be embedded into the MCU system directly to realize the transparent data transmission between the SEU terminal and Internet, which is shown in Fig. 6. In the design of this unit, in order to provide power for the whole hardware system conveniently, we adopt AC-DC switching power supply model to convert the AC 220V in the transmission lines into DC 5V, comparing with the traditional approach that first conducts voltage-drop by transformer and then uses the linear regulator mode, which has some advantages, i.e., small-size, light weight, low output ripple, low-power consumption and the voltage stabilized accuracy reaching ±1％, so it is very fit for AC-DC circuits. In addition, comparing with another common AC acquisition mode, that is, the resistive-capacitive divider voltage mode, the switching power supply mode can provide higher power, meeting the high power demand from the WiFi wireless communication in the hardware system. Accordingly, the AC-DC switching power supply module is selected HB05N24-2636, converting the AC 220V into DC 5V to power the signal amplifiers, ADC chip, relays, sensors, and LCD display screen. Aiming at the voltage level demand of the signal measurement unit, we apply TPS60403 charge pump for converting +5V into -5V. In addition, in order to the power supply demand of the whole DSP system, we adopt the dual output voltage regulator chip TPS73HD301 to convert DC 5V output by the switching power supply into DC 1.9V and DC 3.3V, which are used to maintain a stable operation state for the DSP, meanwhile, we adopt the linear voltage regulator TPS73633 to convert DC 5V into DC 3.3V, powering the digital units, i.e., the storage chip and ZigBee module. The system power supply unit is designed as shown in Fig. 7.

The ambient quality detection unit and other functional modules.
Given a close relationship between electricity use behaviour and indoor air quality, for example, the utilizations of the temperature and humidity-sensitive loads, i.e., the air-conditioning and humidifier, as well as other weather-sensitive loads, are mostly depending on the degree of user comfort, thus the data acquisition of the terminal should take into account the impacts of ambient comfort, as a result, we add the detections, i.e., temperature, humidity and the concentration of organic compound gases, into the terminal. We adopt the sensor AM2302 to achieve temperature & humidity detections, which has a capacitive humidity sensing element and a NTC temperature measuring element, with a temperature measurement precision 0.1℃ and humidity measurement precision 2%RH respectively, in addition, this sensor adopts single pin digital communication with the DSP system in hardware design. Meanwhile, we adopt the sensor KQM2801AU as the TVOC concentration sensor, to detect the concentration of the organic compound gases in indoor air, i.e., ammonia, formaldehyde and carbon monoxide, and the detection range is 0.1 to 30.0 ppm with the precision 0.5ppm. KQM2801AU communicates with the DSP system via the communication interface SCIA. The load control of the terminal is achieved through the high power relays, namely load switches. In order to avoid the impacts of the electromagnetic interference on the system that is generated in the on-off process of relays, we adopt the optical coupling isolation method, in which the optical coupling switches are used to drive the high power electronic devices.
The terminal during the operation needs to save the electricity consumption information of the devices, and we need to conduct parameter modification and electricity consumption reading after each restart in order to make sure the accuracy of data measurement and avoid missing the electricity consumption data due to blackout. Combined with consideration of storage capacity, we select EEPROM AT24C64 as the storage chip, which is responsible for the saving of electricity consumption information and modified parameters. The communication interference between the storage chip and the DSP system is I 2 C. In addition, we adopt AT25FS040 as the external Flash memory chip to save the important information and data due to power off, i.e., the measurement data, user local information, and the ID information of devices. Moreover, in order to mark the time information for the measurement data, to improve the effects of dada analysis, we add the function of real-time clock into the SEU terminal, and which can be realized by the real-time clock chip DS1302.
Lastly, in order to improve the function of human-computer interaction, the developed SEU terminal is equipped with a 2-inch USART serial port color LCD display screen. The screen resolution is 220176, and we can configure the font by ourselves based on needs. The communication interface between LCD and the DSP system is designed as SCIC. The LCD can display the electrical quantities and ambient data, i.e., voltage, current, power, electricity consumption, temperature, humidity and TVOC concentration, which is showed in Fig. 8.

Program design
The program design of the terminal includes the main program and the interrupt subprogram, the running process of which is shown in Fig. 9. The program can be designed as five main procedures: 1) 3) activation. if the terminal is using first, then it needs activation, including the device ID, associated user account information, which can be conducted via the personal computer or the APP on phones; 4) signal measurement and calculation; 5) information interaction. The DSP system uses the UART interrupt to receive the data transmitted by the WiFi module, and then conduct the relevant tasks according to the effective instructions after data analysis, including the data uploading, equipment control, spectrum analysis and electricity-saving control, etc. Fig. 9 Program design of the SEU terminal

Main program design
The flow of main program can be designed as follows.
Step 1: when the terminal is powered on, we first initialize the DSP system, including GPIO ports setting, configuration of the serial ports, such as SCI and I 2 C, and the initialization of the timer.
Step 2: the DSP system reads the parameters and electricity consumption information, after that, the data of voltage and current are collected via the electric measurement unit and conducted A / D conversions.
Step 3: conduct calculations aiming at the sampled electric data, including the RMS of voltage and current, power and electricity consumption, as well as the FFT-based harmonic analysis, in which 0 to 31 orders of harmonic contents will be computed, and after the calculations, the results of electricity consumption will be stored in the EEPROM.
Step 4: control the temperature & humidity sensor and the TVOC concentration sensor to collect the ambient temperature, humidity and organic compound concentration, and save the data after detections.
Step 5: judge the storage data whether be effective, if so, then the LCD will display them and the program will conduct the information interactions and enter the next round circulation, otherwise we judge the data for wrong readings, and the terminal will collect the data again.

Subprogram design
After the ZigBee module receiving the records issued by the concentrator, the interrupt is triggered, entering the operation of subprogram, in which the instruction format will be judged according to the agreed communication protocol between the terminal and the concentrator, including step 1: if it is onoff control, and then connect / disconnect the electrical equipment according to the requirements of specific instruction, realizing remote on-off control of the loads; step 2: if it is data transmission order, and then the ZigBee module will upload the electrical quantities and ambient detection data to the concentrator; step 3: if the instruction format does not meet the agreed communication protocol, and then the program will judge the order of data transmission is wrong, and the terminal does not give response; step 4: after the corresponding actions are executed, end the subprogram and return to the main program for continuous operation.

Prototype testing
Based on the previous hardware design and program design, the prototype of the SEU terminal is developed as shown in Fig. 10(a), where each main functional component has been marked. We use the prototype to conduct experiments to test the functions of the terminal. The experimental scene is shown in Fig. 10 We can see from the Tab. 1 that the measuring relative errors of these electric quantities by the terminal are very small, among them, the voltage error is smaller than 0.5%, the current and power error are basically kept within 1%, and for the indoor ambient temperature, humidity and TVOC concentration, the relative errors are both very small. Consequently, the measuring precision of the developed SEU terminal generally meet the requirements.

Wireless communication and on-off control testing
In order to the test the functions of wireless communication and on-off control of the SEU terminal, we take two prototypes for testing. First, we configure the ZigBee module in one of them as mastertransmitting mode, and the ZigBee module in other one as slave-receiving mode. The program internal communication protocol is defined by ourselves, that is, the master prototype transmits instructions to the slave prototype, and which returns the corresponding data to the master prototype after receiving the instructions. We change the transmitting instructions of the master prototype successively, and then through connecting the JTAG interface of the testing bottom board with a simulator, we can observe the transmitting and receiving situations of memory in the two prototypes on our personal computer client. Aiming at the verification whether the on-off control instructions are executed successfully in the prototype, we can use the digital multimeter Fluke 17B+ to measure the relay at both ends, to judge whether the relay has been closed or opened normally. The experimental results are shown in Tab. 2, from which we can conclude the functions of the prototype, i.e., wireless communication and on-off control, are achieved successfully.
Tab. 2 Testing results of the wireless communication and on-off control Data transmitted by master prototype Data received by slave prototype Returned data **DP=Y (require a sign for positive in return) **DP=Y ##P=OK (an answer-back sign for positive) **DP=N (require a sign for negative in return) **DP=N ##P=NO (an answer-back sign for negative) **DP=1(require a sign for switching on the loads) **DP=1 ##P=ON (an answer-back sign: the relay has been turn-on) **DP=0(require a sign for sure in return) **DP=0 ##P=OF (an answer-back sign: the relay has been turn-off) *#DP=Y(require a sign for sure in return) *#DP=Y Not an agreed instruction, no response

Conclusion
This paper develops a new-type SEU terminal applied in the energy USB system, which can measure the basic electric quantities, and meanwhile the indoor air quality is added into its detection, that is, the ambient comfort is taken into account in design of the terminal. The terminal is a SEU terminal with the DSP as its core processor, which can be applied for electricity use information collecting and coordinated control of the distributed electricity use devices within wide area of smart grid. The testing results of the experimental prototype show that this SEU terminal not only has a higher measurement precision, but also can achieve stable controlling and monitoring for the electricity use devices. The terminal can be applied in the energy USB system, in which each family appliance access to the distribution network via the terminal, and it is able to work combining with the corresponding home concentrator, realizing the wireless networking of the family appliances, and integrated analysis on the electricity use information and ambient data as well as monitoring of family appliances, finally building a home energy management network system with taking into account the ambient comfort.
In order to promote the application of the SEU terminal in smart grid, the following research will focus on development of application software based on the terminal, as well as the development of the smart home concentrator, together with study on the theory of electricity use optimization considering ambient comfort.