Test and Implementation of Control Algorithm in Hybrid Energy System with Phase Change Material Storage Tank in State Flow Matlab Toolbox

Control algorithm is the most important element of hybrid energy system while it is in operation. It determines energy effects of each segment of system, which has influence on efficiency of whole system and operating costs. This paper presents the results of research studies which enabled control algorithm of hybrid energy system combining heat pump, solar installation and phase change material (PCM) storage tank to be tested and optimised. Matlab Simulink software was used to perform simulations. A great advantage of this software is the possibility to compile and implement control algorithm in programmable logic controller (PLC). The algorithm that was implemented in PLC is in form of function block diagram, which makes the entire PLC programme very clear.


INTRODUCTION
Control algorithm is the most important element of hybrid energy system while it is in operation. It determines energy effects of each segment of system, which has influence on efficiency of whole system and operating costs. This paper presents the results of research studies which enabled control algorithm of hybrid energy system combining heat pump, solar installation and phase change material (PCM) storage tank to be tested and optimised. Matlab Simulink software was used to perform simulations. A great advantage of this software is the possibility to compile and implement control algorithm in programmable logic controller (PLC). The algorithm that was implemented in PLC is in form of function block diagram, which makes the entire PLC programme very clear.
Green energy sources, for example, solar radiation, wind etc. have lower density of energy compared to conventional sources. Due to this fact, renewable sources of energy are connected in hybrid energy system in order to provide continuous power supply for the system [1,2]. One of the most popular connection is solar thermal installation and heat pump. Geothermal energy is more stable than solar energy, so heat pump plays a dominant role in hybrid energy system, but it needs electric energy to power compressor. Operating costs depend on prices of electric energy. There are available special electric energy tariffs for heat pump users in many European Union countries. These tariffs regulate prices of electric energy throughout the day. Prices depend on supply and demand of electric energy in network. This means that operation of heat pump is economical in periods, when there are lower prices for electric energy. It requires heat demand of building to adapt to periods of lower prices for electric energy. This requirement is impossible to achieve in operating conditions. The solution of this problem is to use heat storage system based on the phase change materials (PCM).

HEAT PUMP, SOLAR COLLECTORS AND PCM STORAGE TANK IN HYBRID ENERGY SYSTEM
Due to the fact that phase change materials change value of specific heat as a function of temperature, it is possible to store heat or cold in a long period of time. The analysis of long-term heat storage shall be presented in this paper. The main problem with phase change materials is loss of accumulation abilities during phase changes from solid to liquid or from liquid to solid. Thus, it is required to keep temperature between solid and liquid areas as PCM storage tank is in operation. This means that temperature between solid and liquid phase should match the operating temperature of PCM storage tank. Due to this, the most important element of hybrid energy system operation is control algorithm.

ANALYSIS OF CONTROL ALGORITHM OF HYBRID ENERGY SYSTEM
Energy absorbed by solar installation was transferred to DHW tank. When temperature of water reached set point of 45°C in DHW tank, controller changed position of two-way valves and solar installation started to operate again together with PCM storage tank. After that, when PCM reached liquid phase temperature, due to high value of solar radiation of 1000 W/m 2 and possibility of charging DHW tank (water temperature of 45°C), solar installation started to operate together with DHW tank. Simultaneously, value of solar radiation decreased to 450 W/m 2 . In consequence, temperature difference between working fluid and DHW tank was lower than stop set value of solar pump. Due to lack of working fluid flow in solar system, temperature increased above control set value. This means that controller must periodically start and stop solar pump. The following simulation of control algorithm tested how the system operates when solar radiation is low and temperature in DHW tank is high. As a result of DHW consumption, temperature of water decreased to 62°C. Next, solar pump ran continuously until temperature of DHW increased to 68°C and after that solar pump was periodically in operation. After testing control algorithm, it is possible to implement it in PLC programme. At this stage control algorithm should be completed, and then it is possible to generate the structure of control algorithm using language dedicated for one of possible to select from programmable logic controllers (Fig. 3). After generating the structure of control algorithm, it should be implemented in State Flow Matlab Toolbox where programming PLC as external source file and generating code is possible. Next, compiled controller transforms into simpler block with empty places for input and output signals ready to use. It is necessary to define memory areas of PLC for input and output values in these empty places and upload whole block to PLC (Fig. 4). After these procedures controller is ready to work.

SUMMARY AND CONCLUSIONS
The solution presented in this paper is very simple and useful. It gives the possibility to design and test control algorithm of hybrid energy systems and implement it in programmable logic controller. It should be noted that design time of control algorithm is very short and there is no need to rewrite tested control algorithm in PLC software. It is very important that compiled control algorithm is implemented in PLC as homogeneous block. This solution simplifies the structure of PLC programme. Otherwise, implementation of control algorithm tested in Matlab Simulink would require many lines in LAD language in PLC programme, which could adversely affect its clarity.
The best way to design and develop control algorithm of hybrid energy system is to perform simulation tests of how selected segments of the system work together. Each model of hybrid energy system components such as: solar collectors (SC), domestic hot water tank (DHWT), heat pump (HP), hot PCM storage tank was implemented in Matlab Simulink State Flow Toolbox. These models are described in papers [3,4]. Despite the fact that the models are very simple, their implementation and connection was very difficult, and consequently the structure of the whole system is very complicated (Fig. 1).   The main role of solar installation is to transfer energy to DHW tank so it can be stored. If temperature difference between working fluid and DHW tank is higher than 10 K, controller starts solar pump and DHW tank charges within 1200 s. Set point temperature in DHW tank was 45°C. When set point in DHW tank was reached, controller changed position of twoway valves and energy absorbed by solar collectors was transferred to PCM storage tank (time 1200÷3900 s) (Fig. 2). While PCM storage tank was charging, flow rate of working fluid in solar installation was changed from 0.138 kg/s to 0.148 kg/s and after 400 s to 0.138 kg/s. As a result, difference between input and output temperature in solar installation changed. Due to DHW consumption during charging process of PCM storage tank and transition phase of PCM, temperature of water in DHW tank decreased below 40°C, and as a result controller changed position of two-way valves.