Printer Friendly

Development of a hardware-in-the-loop framework with modelica for energy efficient buildings.


Buildings consume more than 40% of energy in the U.S. Effectively and efficiently managing and controlling building energy and mechanical systems for a sustainable built environment remains a critical challenge. Studies shows intelligent building heating ventilation and air-conditioning (HVAC) controls enable a greater than 20% energy savings in specific buildings, accounting for 2% of national energy consumption (Brambley et al. 2005). This equals to about 509 Twh (1.737 x [10.sup.9] MMBTU) in terms of primary energy savings in 2013 (IEA 2014). Even small improvements in control system logic can lead to significant energy and cost savings over the course of a year and longer.

How to develop, test and evaluate controller performance is crucial for scalable deployment of their control logic including load, supervisory and distributed control solutions. In building industry, the standard approach to test control loops has been to test the loops on the fully assembled systems. This approach is frequently time-consuming and cost-intensive because a real test in buildings/subsystems, even in a laboratory, involves many variables in a complex multi-physics environment. An alternative emulation technique, Hardware-in-the-loop (HIL) is being widely used in automotive and power industry (Xu et al. 2014). However, the HIL technique has not been widely applied in the building energy sector (Xu et al. 2004, Michalek et al. 2005, Otten et al. 2011, NIST 2016). As applied to building systems, the HIL technique would simulate a building by connecting the controller to a virtual building system model in lieu of the actual system. Therefore, hardware controllers and control strategies (e.g., load control algorithms) could be tested and optimized in conjunction with a real-time emulator that was connected to the real controller. Models running on the real-time emulator would represent the building energy equipment and system. This approach would enable a closed control loop to be emulated in a partially virtual system with real controllers. NIST developed a virtual cybernetic building testbed (VCBT) that used HVACSIM+ models for the HIL simulation (Decious et al. 1997, NIST 2016). In this paper, equation based object-oriented modeling languages, e.g., Modelica (Modelica 2016), will be investigated for the HIL study. This modeling language is known for enabling a scalable and dynamic modeling of building HVAC and control systems consistently (Wetter et al. 2014).

This paper focuses on a development of a real- time HIL testbed for analysis of advanced and intelligent building control strategies. The primary goal of this study is to conduct a feasibility study of using a Modelica based model for a HIL real-time simulation for HVAC applications. First, the HIL simulation environment is introduced, followed by a case study for a room served by a variable air volume (VAV) terminal box. Then, real-time simulation results will be discussed. Finally, we will present conclusions and future work.


Architecture for Hardware-in-the-loop

Fig. 1 shows a schematic architecture of a typical HIL setup for building applications. There are several different open source and commercial real-time emulators available. Another set of important components for a HIL test are the building and HVAC models. A critical requirement for these models used for the HIL simulation is that they need to run on emulators through real-time interactions with real physical controllers via digital-to-analog (D/A) and analog-to-digital (A/D) boards. Unfortunately, commonly used whole building energy simulation programs cannot be directly used for the HIL purpose. These simulation programs are mainly for building energy performance estimation instead of controls design. On the other hand, control-oriented models (Wetter et al., 2014).have been widely used for the HIL simulation.

HIL Setup in This Study

The pieces of equipment chosen to complete the loop in this study include a dSPACE processor to execute models and a set of programmable HVAC controllers. Additionally, D/A and A/D boards are used to establish communications between the real-time emulator and the controllers. A block diagram of this setup is shown in middle of Fig. 2. The real setup in the laboratory is presented in the left of Fig. 2. This includes controllers for typical HVAC equipment such as an Air Handler Unit (AHU), Rooftop unit (RTU), chiller, and VAV terminal box. Only one controller for the VAV box is used for this study. A local Arcnet network is established through a router. This enables all controllers to communicate with a centralized Building Energy Management System (BEMS) through a BACnet protocol (A Data Communication Protocol for Building Automation and Control Networks). All local controllers used in this testbed are natively BACnet compatible. In addition, a web-based BEMS is established. Modern BEMS allow users to fully access their buildings' schedules, setpoints, trends, alarms, and other control functions from virtually any computer, anywhere in the world. As a native BACnet system, this BEMS interfaces with LonWorks, Modbus and many other protocols to provide an integrated solution to building control needs.

Table 1 lists the detailed configurations of the real-time emulator, which includes one processor, one A/D board, one D/A board, and one board for thermal resistors.


A room served by a VAV terminal unit is the focus of this case study, where the room and VAV terminal unit are modeled in the proposed modeling environment (see details in the next section) and downloaded to the HIL real-time emulator that is connected to a real VAV box controller. One of ultimate objectives of using this HIL testbed is to research different advanced control algorithms including fault tolerant controls for VAV boxes. In this paper, we will only present the HIL results related to a simple logic to control a normal VAV box for the feasibility study.

A VAV box can be used to control a zone or set of zones in a large building where there are centralized HVAC equipment providing the conditioned supply air to zones. This supply air can then only be given one temperature using the heating/cooling equipment within the AHU. The VAV boxes must adjust this supply air, both in volume and temperature, to serve the desired zones to maintain the design zone air temperature set point and meet the required ventilation rate. The VAV box studied in this study accomplishes this by using both an airflow damper and a reheat coil valve. The damper simply closes or opens the airflow pathway to modulate the volumetric flow rate of the supply air into the zone. Reheat coil is a heating coil (note: water coil in this study) inside the VAV box to give control of the supply air temperature. By opening and closing the valve on this water loop, the temperature of the supply air can be raised and lowered.


The mathematical modeling of the system is the key step to making HIL possible. Appropriate modeling software must be chosen. An equation-based and object oriented modeling language for complex multi-physics systems was used in this study. The use of such modeling language for the built environment is promising as buildings involve multiple physical phenomena (e.g., heat transfer, fluid dynamics, electricity, etc.) and are complex in terms of their dynamics (e.g., coupling of continuous time physics with discrete time and discrete event control). In addition, the problem size can be varied from equipment to buildings and communities with electrical distribution grids. An advantage of the modularity of the language is that it allows modification of the code according to the specific needs of the application. The object- oriented design enables extension and reuse of components and the use of standardized interfaces enables collaboration across physical domains and disparate developer groups. In this study, the free open source LBNL building library (Wetter et al. 2014) is utilized due to its flexibility and capability for dynamic modeling of control components.

Unfortunately, the interface used to run such models directly on the proposed real-time emulator is still under development and therefore unreliable when this study was started in 2015. Instead, such models can be first imported to a graphical block programming software, which does come with reliable code generation functionality that have been tested and demonstrated in a variety of applications in automobile and aerospace industry.

Modeling a VAV Box

The model shown in Fig. 3 mimics a VAV box with a reheat water coil valve and an air damper. In this preliminary study, we will focus only on the control of room air dry bulb temperatures. An AHU provides conditioned air at a prescribed temperature and sufficient pressure to overcome losses due to the damper and heat exchanger. The air is given a nominal flow rate, which serves as the flow rate of air with the damper fully open. From the AHU, the supply air flows through a heat exchanger block (i.e., reheat coil) with a constant effectiveness. Source reheat water is set to a hot source temperature and given a nominal flow rate, which is controlled by a linear two-way valve. Finally, the VAV damper is modeled using an exponential damper module from the LBNL buildings library. The nominal supply airflow rate is set inside this module, and varies exponentially down to zero as the damper is closed. External signals are used to control both valve position on the reheat water loop and supply air damper position, as these signals will be received from the real controllers in the HIL simulation through an A/D board. Ideal (loss less) flow and temperature sensors are placed throughout the model to monitor properties and ensure correct performance. Such sensor information will be sent to the real controller through a D/A board. Finally, parameters that are not yet defined are set as inputs to the system. These will be declared later in the emulator, allowing them to be changed during the real-time testing.

Modeling a Thermal Zone

The model in Fig. 4 describes a room using a thermal resistance/capacitance (RC) model and is modified from a RC model in the Annex 60 library (Annex 60 2016). A capacitor for each surface represents thermal energy storage, followed by conduction and internal convection resistors. The ambient temperature is an input to the system, while the ground temperature is prescribed as a fixed value. Outside surface convection and radiation are handled with constant heat flows according to the ASHRAE standard 140 BESTEST (ASHRAE 2007). Fluid ports allow the air from the VAV box to enter the room and return the air to an exit, maintaining the mass balance. Therefore, a fixed volume of air is maintained in the room at all times. There are a variety of assumptions made in this model, including the neglecting of infiltration and handling of outdoor convection, ground temperature and radiation as constants. For a longer simulation period of several weeks, months and year, it needs to use a ground temperature model (e.g. Kusuda and Achenbach 1965).

During this preliminary feasibility study of using equation-based modeling language for the real-time HIL simulation, sometimes compatibility issues are encountered between the building code for the emulator and the simulation interface. This only occurs with certain models, such as MixedAir from the LBNL building library, and we are still in the process to find the root cause of such issues. These models work fine in the block programming software but return an error during code generation. Therefore, models cannot be successfully downloaded to the emulator. The RC model from Annex 60 library (Annex 60 2016) used in this case study works well.

Downloading to The Real-time Emulator

The combined thermal zone and VAV box model must be downloaded to the emulator for the real-time HIL execution. As previously mentioned, the model will first be exported for the code generation. This is possible using a customizable block interface. This feature allows the model to be inserted as essentially a "black box" in which outputs are calculated from defined inputs. In order to complete the loop, some parameters must be associated with D/A and A/D boards, and therefore either read from or sent to the real controllers. In this study, room temperature is sent to the controller and reheat valve position is returned for the heating mode simulation of a VAV box operation. A real-time emulator blockset allows these communications to be defined. Before building the model to code, a fixed step integrating method must be selected. Variable step integrators cannot be chosen for the real-time testing. The fixed time step used in this case study is 0.001 second with an Euler solver. The model is then built into C code using a real-time simulation toolbox, and the variable description files are downloaded onto the emulator for the real-time HIL simulation. We didn't observe any issues for this short time step in this case study.


As previously discussed, a VAV box with reheat coil has capabilities to control supply air flow rate and supply air temperature through modulations of the on-board damper and reheat coil valve to maintain the room air temperature setpoint. A conventional manner for a VAV box control in HVAC practice, called single maximum logic, is shown below in Fig. 5 (Taylor et al. 2012). The term maximum refers to the flow rate of supply air. As can be seen from this figure, cooling is accomplished simply by opening and closing of the damper. The reheat functionality would only serve to heat the supply air and is therefore not used in the cooling loop.

In this case study of the VAV box in the heating mode, the damper position is set to a minimum position based on either minimum ventilation requirements or the minimum airflow needed to control the room temperature in the space, whichever is larger. Only the reheat coil valve is controlled, and the zone setpoint is maintained simply by varying the supply air temperature into the room. Fundamentally, this type of control relies upon cooling air to be heated using the reheat coil in the heating mode. Therefore for zones requiring a lot of heating, such as exterior zones in cold climates with large windows, this type of control would result in energy waste due to simultaneous heating (at the terminal zone level) and cooling (at the AHU level). The amount of energy used to reheat is large in this control strategy, and is highlighted in purple in Fig. 5. This is a common known issue for this single maximum control logic.

Programming the Controllers

It should be noted that HVAC controllers used in the building automation industry typically don't use PLCs (programmable logic controller) and have a limited on-board memory. Although some intelligent controllers (e.g., a fuzzy logic controller, a pattern recognition adaptive controller, etc.) have been developed over the past two decades, the most commonly used controller in HVAC applications remains the Proportional-Integral (PI) type (Seem 1998, Zhao et al. 2013). Indeed, 95% of industrial controllers are of the Proportional-Integral-Derivative (PID) type even though most of loops are actually PI control (Astrom and Haggland 1995).

The HVAC controllers used in this study come fully programmable. The software is a drag-and-drop format using microblocks, which carry out mathematical operations. Custom microblocks can also be used to realize complicated calculations. A set of more complicated microblocks is also available, including a PID control block. A sample control program for single maximum control logic is shown in Fig. 6.

This PID block compares two quantities, in our case the zone air temperature with the setpoint, and tries to maintain the setpoint using PID controls. The proportional portion is simply the difference between the two values. The integral portion is the time-weighted error. The derivative portion is the rate of change in the difference. Due to limitations of controllers, most HVAC control is currently done without the derivative component, making the control simply PI. The implementation of this block is fairly straightforward, but the tuning of the loop determines the effectiveness of the logic. Each of the proportional and integral values is given a weight by which they are multiplied to determine the significance of each in determining control output. Additionally, a bias can be set in the block to set the default output of the block. This is collectively referred to as tuning the loop.


For the purposes of the HIL simulation in this case study, the outdoor air temperature is set to be cold (i.e., 32[degrees]F (0[degrees]C)) and the VAV box always stays in the heating mode. Therefore only the reheat valve needs be controlled following single maximum control logic. The control is accomplished by using a PID block, with the derivative component set to zero. Therefore, the logic is effectively just a PI control. Zone temperature and setpoint are compared to determine an appropriate reheat valve position, which is then sent back to the model through the emulator using the A/D board. The model is accordingly updated and continues to solve for zone temperature at each time step, writing this value (sensor information) to the controllers to complete the HIL loop via the D/A board. Both zone air temperature and reheat coil valve position are trended and recorded in the BEMS..

As we can be seen in Fig. 7, the desired setpoint of the room was 72[degrees]F (22.2[degrees]C). The simulation was stopped around 1 pm and later resumed, with different PI loop tuning to illustrate the difference the tuning can make. Before the re-tuning, wild fluctuations in the reheat valve were experienced. If this control were implemented in a real system, the constant opening and closing of the valve would lead to noise, wasted energy, mechanical wear and eventually failure. In addition, the controlling of room temperature was clearly worse as well. After a more optimal tuning was applied to the PI block, a classic underdamped oscillator curve can be seen. The reheat valve position ceases to undergo vast changes, and finds a steady value to maintain room temperature at the setpoint. Reversals in signal can still be seen, but they are minimal compared to the prior tuning and are practically unavoidable when using a PI loop.


This preliminary study has proved using a dynamic equation based object-oriented model for a real-time HIL simulation is feasible. The ongoing and future work includes:

* Use the proposed HIL simulation framework for hierarchal controls in buildings where model-based optimal controls will be deployed for supervisory control (e.g., setpoints) while the local controls will be handled by typical HVAC PI controllers.

* Use the proposed HIL simulation framework for energy flexible buildings with a smart grid through the use of ground source heat pumps. Dynamic models for vapor compression cycle with two-phase flow may raise the challenges for the real-time HIL simulation.

* Investigate the fault tolerant control for HVAC applications.


This work emerged from the Annex 60 project, an international project conducted under the umbrella of the International Energy Agency (IEA) within the Energy in Buildings and Communities (EBC) Programme. Annex 60 will develop and demonstrate new generation computational tools for building and community energy systems based on Modelica, Functional Mock-up Interface and BIM standards.


Annex 60. 2016. IEA EBC Annex 60. http:/ /

ASHRAE. 2007. ANSI/ASHRAE 2007 Standard 140-2007- Standard Method of Test for the Evaluation of Building Energy Analysis Computer Programs. maa. Atlanta, GA

Astrom, K. J. and T. Haggland. 1995. PID Controllers: Theory, Design, and Tuning. Research Triangle Park, N. C.: Instrument Society of America.

Brambley, M. R., D. Hansen, P. Haves, D. R. Holmberg, S. C. McDonald, K. W. Roth and P. Torcellini. 2005. Advanced Sensors and Controls for Building Applications: Market Assessment and Potential R&D Pathways. PNNL Report. 2005.

Decious, G. M., C. Park and G. E. Kelly. 1997. Low-Cost Building/HVAC Emulator. Heating/Piping/Air-Conditioning. January 1997: 188-193.

IEA. 2014.

Kusuda, T. and P.R. Achenbach. 1965. Earth Temperatures and Thermal Diffusivity at Selected Stations in the United States. ASHRAE Transactions. 71(1): 61-74.

Michalek, D., C. Gehsat, R. Trapp, and T. Bertram. 2005. Hardware-in-the-Loop-Simulation of a Vehicle Climate Controller with a Combined HVAC and Passenger Compartment Model. Proceedings of the 2005 IEEE/ASME International Conference on Advanced Intelligent Mechatronics, Monterey, California, 24-28 July, 2005

Modelica. 2016. https:/ /

NIST. 2016. instruments/vcbt.cfim

Otten, R., B. Li and A. Alleyne. 2010. Hardware-in-the-Loop Load Emulation for Air-Conditioning and Refrigeration Systems. 2010 International Refrigeration and Air Conditioning Conference. Paper 1101.

Seem, J.E. 1998. A New Pattern Recognition Adaptive Controller with Application to HVAC Systems. Automatica. l34 (8):969- 982.

Taylor, T., J. Stein, G. Paliaga and H. Cheng. 2012. Dual Maximum VAV Box Control Logic. ASHRAE Journal. Dec 2012. Wetter, M., W. Zuo, T. S. Nouidui and X. Pang. 2014. Modelica Buildings Library. Journal of Building Performance Simulation, 7(4):253-270.

Xu, P., P. Haves, and J. Deringer. A Simulation-Based Testing and Training Environment for Building Controls. In Proceedings of SimBuild 2004, Boulder, USA, 2004.

Xu, Y., J. Yan, H. Qian and T. L. Lam. 2014. Hybrid Electric Vehicle Design and Control: Intelligent Omni-directional Hybrids. Engineering Database, McGraw-Hill Education, 2014.

Zhao, F., J. Fan and S. Mijanovic. 2013. PI Auto-tuning and Performance Assessment in HVAC Systems. 2013 American Control Conference (ACC). Washington, DC. USA. June 17-19, 2013.

Zheng O'Neill, PhD, PE


Aaron Henry

Student Member ASHRAE

Charles O'Neill, PhD

Zheng O'Neill is an assistant professor and Aaron Henry is a graduate research in the Department of Mechanical Engineering, The University of Alabama, Tuscaloosa, AL. Charles O'Neill is an assistant professor in the Department of Aerospace Engineering and Mechanics.

Caption: Figure 1: A schematic architecture of a typical HIL setup

Caption: Figure 2: The HIL system used in the study

Caption: Figure 3. Model of a VAV box with reheat

Caption: Figure 4. Model of a thermal zone

Caption: Figure 5. Single Maximum Reheat Logic (Taylor et al. 2012)

Caption: Figure 6. Single maximum control program

Caption: Figure 7. Single Maximum logic real-time simulation results trended in BEMS
Table 1. Configurations of the real-time emulator

Items                                   Configuration

Processor                    Advanced Control Education Kit 1006
                          consisting of a 2.8 GHz processor board,
                            a CDP-MP Control Development Software
                                 Package and a GNU Compiler
Multi Channel A/D Board               32-channel 16-Bit
Multi Channel D/A Board               32-Channel 14-Bit
Resistive Sensor                 4 resistor output channels
Simulation Board
COPYRIGHT 2017 American Society of Heating, Refrigerating, and Air-Conditioning Engineers, Inc.
No portion of this article can be reproduced without the express written permission from the copyright holder.
Copyright 2017 Gale, Cengage Learning. All rights reserved.

Article Details
Printer friendly Cite/link Email Feedback
Author:O'Neill, Zheng; Henry, Aaron; ONeill, Charles
Publication:ASHRAE Transactions
Date:Jan 1, 2017
Previous Article:Experimental investigation of potential energy savings and payback periods in renewing old split-type air conditioners.
Next Article:Comfort guaranteed energy saving algorithm in hospitality buildings.

Terms of use | Privacy policy | Copyright © 2021 Farlex, Inc. | Feedback | For webmasters |