57
Integration of Electrochromic Smart Windows in Building Automation Systems MARCUS HULTMARK VAREJÃO Master’s Degree Project Stockholm, Sweden 2013 MMK 2013:76 MDA 469

Integration of Electrochromic Smart Windows in Building

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Integration of Electrochromic Smart Windows in Building

Integration of Electrochromic SmartWindows in Building Automation Systems

MARCUS HULTMARK VAREJÃO

Master’s Degree ProjectStockholm, Sweden 2013

MMK 2013:76 MDA 469

Page 2: Integration of Electrochromic Smart Windows in Building

i

Page 3: Integration of Electrochromic Smart Windows in Building

Examensarbete MMK 2013:76 MDA 469

Integration av Elektrokroma Smarta Fönster iByggnadsautomationssystem

Marcus Hultmark Varejão

Godkänt Examinator Handledare

2013-09-06 Mats Hanson Lei FengUppdragsgivare Kontaktperson

ÅF AB Jacob Rydholm

Sammanfattning

Byggindustrin investerar i smarta lösningar för att sänka energiförbrukningen. Dessa lösningar brukaranvända kontroll och automatisering för att både öka energieffektiviteten och underlätta användningen,och därmed locka konsumenter. Denna uppsats ger en bättre inblick i hur ett elektrokromiskt (EC) fönster,som är en relativt ny smart produkt, bör användas för att ytterligare förbättra byggnaders intelligens.

Företaget som finansierar projektet har ännu inte integrerat EC fönster i byggnadsautomationssystem(BAS). Olika BAS tekniker studeras, varav två tekniker mer ingående; LonWorks och BACnet. De bådeteknikerna analyseras och utvärderas för att sedan utse vilken som är att föredra. Slutsatsen dras om attLonWorks är mer lämplig att implementera.

Fönster förser rummet med solenergi och belysningsstyrka. Om fönstret släpper in för mycket solljuskan personer påverkas av bländning samt att det kan bli för varmt. Komforten ökar om dessa parametrarstyrs automatiskt. Denna uppsats härleder ekvationer för att beräkna solens position som sedan användsi simuleringar. Simuleringsförfaranden används också för att beräkna belysningsstyrkan inomhus såvälsom temperaturen; den senare tillämpas sedan för att beräkna energiförbrukningen och jämföra EC medhögeffektiva vanliga fönster. Dessa simuleringar visar att energin som behövs för att reglera temperaturentill 23oC i rum innehållande EC fönster med reglering av belysningsstyrkan är ca 2,6% mindre än i ruminnehållande högeffektiva vanliga fönster.

En regleralgoritm föreslås för att justera belysningsstyrkan inomhus genom att manipulera transmittansenhos EC fönster. Denna algoritm implementeras sedan på det verkliga systemet. En webbsida konstruerassedan så att vem som helst med tillgång till en webbläsare och anslutning till intranätet (där fönstren äranslutna) kan manipulera dem.

ii

Page 4: Integration of Electrochromic Smart Windows in Building

iii

Page 5: Integration of Electrochromic Smart Windows in Building

Master of Science Thesis MMK 2013:76 MDA 469

Integration of Electrochromic Smart Windows inBuilding Automation Systems

Marcus Hultmark Varejão

Approved Examiner Supervisor

2013-09-06 Mats Hanson Lei FengCommissioner Contact person

ÅF AB Jacob Rydholm

Abstract

To lower energy consumption, the building industry invests in smart solutions. These solutions usuallyuse control and automation to both increase energy efficiency and facilitate usage, and therefore attractconsumers. This paper gives a better insight into how an electrochromic (EC) window, which is a rela-tively new smart product, should be used to further improve the intelligence of buildings.

The funding company has not yet integrated the EC windows in building automation systems (BASs). Aresearch was realized to understand the BAS technologies available so that it is possible to decide whichto use. The researched technologies were LonWorks and BACnet; both are explained and discussed inthis paper. The paper goes on to conclude that LonWorks is more convenient to implement.

Windows provide solar power and indoor illuminance. If there is too much sunlight indoors, the roommight get too warm and people may be affected by glare. Being able to automatically control these pa-rameters improves comfort. This paper provides equations to calculate the position of the sun to be usedin simulations. Simulation procedures are also provided so it is possible to calculate the indoor illumi-nance as well as the temperature; the latter is then used to estimate the energy consumption and compareEC with high efficient regular windows. These simulations show that, with illuminance controlled ECwindows, the energy used to regulate the temperature to 23oC is around 2.6% less than with high efficientregular windows.

A control algorithm is proposed to adjust indoor illuminance by manipulating the transmittance of theEC windows. This algorithm is then implemented on the real system. Then, to be able to manuallycontrol the windows, a website is designed so anyone with access to a web-browser and a connection tothe intranet (where the windows are connected) can manipulate them.

iv

Page 6: Integration of Electrochromic Smart Windows in Building

v

Page 7: Integration of Electrochromic Smart Windows in Building

Foreword

This project was realized in collaboration of the Royal Institute of Technology (KTH), ÅF AB andChromoGenics AB. Special thanks go to Lei Feng at KTH for providing good knowledge and insight intocontrol theory; Jacob Rydholm at ÅF AB for leading me into the right direction; Johnny D. Engfeldt andGreger Gregard at ChromoGenics AB for defining a good project and supplying me with test objects; andMats Hanson at KTH for assigning me a supervisor and helping with defining the scope of a mechatronicsproject. I would also like to thank the people at ÅF AB with whom I have been able to discuss aboutthings that I had little knowledge of.

Marcus Hultmark Varejão

StockholmSeptember 2013

vi

Page 8: Integration of Electrochromic Smart Windows in Building

vii

Page 9: Integration of Electrochromic Smart Windows in Building

List of Acronyms

ARCNET Attached Resource Computer NETwork

BACnet Building Automation and Control NETwork

BAS Building Automation System

BTL BACnet Testing Laboratories

CRC Cyclic Redundancy Check

CSMA Carrier Sense Multiple Access

EC Electrochromic

HMI Human Machine Interface

HVAC Heating, Ventilation, and Air-Conditioning

I2C Inter-Integrated Circuit

LAN Local Area Network

MS/TP Master-Slave/Token Passing

OS Operating System

PDLC Polymer Dispersed Liquid Crystal

PLC Power Line Communication

PTP Peer-To-Peer

RF Radio Frequency

RTOS Real Time Operating System

SCPT Standard Configuration Property Type

SHGC Solar Heat Gain Coefficient

SI International System of Units

SNVT Standard Network Variable Type

SPD Suspended Particle Device

UML Unified Modeling Language

USB Universal Serial Bus

WCU Window Control Unit

viii

Page 10: Integration of Electrochromic Smart Windows in Building

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Delimitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Literature review 52.1 LonWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 BACnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Smart Window Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 Control design 113.1 System modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4 Implementation 214.1 Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.2 Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.3 Automatic Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.4 Manual Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.5 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.6 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5 Results 295.1 Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295.2 Real Test Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

6 Discussion and Conclusions 396.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396.2 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

7 Future Work 437.1 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437.2 Communication Optimizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437.3 Software Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437.4 Energy Focused Control Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Bibliography 45

A Pseudo-code 47

ix

Page 11: Integration of Electrochromic Smart Windows in Building

CHAPTER 1. INTRODUCTION

1. Introduction

Among the benefits of using electrochromic (EC) smart windows in buildings, are the increase of indoorcomfort and energy savings; the latter leading to less building expenses and, of course, less environmentalimpact. Since there are different industry standards for building automation systems (BASs), a challengeis to be able to integrate the EC windows. Then, to get the most out of their potential benefits, it isimportant that they are able to be controlled, either autonomously or manually.

1.1 Background

1.1.1 Smart Windows

Smart windows are defined as windows with controllable optical properties (Dussault et al. 2012). Win-dows that can control light transmittance act as solar energy materials (Niklasson & Granqvist 2007),since dimming sunlight or letting it pass through, will cool or heat the room respectively.

There are different types of technologies to accomplish this chromogenic feature:

• Electrochromic: Electrochromism is the coloration of a material induced by an electron-transfer(redox) reaction; i.e. electrons are either gained (by reduction) or lost (by oxidation) (Monk et al.2008); this process is used in EC smart windows to manipulate light transmittance. The advantageof EC windows, as compared to some other technologies, is that power is only supplied whentransmittance change is demanded, otherwise it is not required (Niklasson & Granqvist 2007),which makes it likely to consume very little energy.

• Photochromic: Photochromism works much the same way as electrochromism, except that thetransmittance changes depending on the light input (Dürr & Bouas-Laurent 2003) making it veryuseful for eyeglasses.

• Polymer Dispersed Liquid Crystal (PDLC): This technology uses liquid crystals confined indroplets surrounded by a polymer matrix (Woltman et al. 2007). The orientation of the symmetryaxes of the liquid crystal droplets is random in the off-state (no applied voltage), thus rendering amismatch in the index of refraction of every droplet; this mismatch scatters light which gives thematerial a milky color. In the on-state, the symmetry axes are aligned, and by using liquid crystalswith an index of refraction that matches that of the polymer, the material becomes transparent.

• Suspended Particle Device (SPD): Radiation absorbing rod- or plate-like particles suspended ina liquid are used (Bos et al. 2008). When no voltage is applied (no electric field present), theparticles orient themselves randomly, while when voltage is applied they point more or less to thesame direction as the electric field. The more parallel to the window’s normal the particles are (i.e.the higher the voltage), the less absorbing the window becomes (i.e. more transparent).

These technologies may be useful to develop mechatronic devices such as the following to improve theirproperties, e.g. by being more energy efficient or safer:

• Windows: more energy efficient temperature control in buildings; in vehicles they are usefulagainst glare.

1

Page 12: Integration of Electrochromic Smart Windows in Building

CHAPTER 1. INTRODUCTION 1.2. PURPOSE

• Rearview mirrors in cars: less glare from cars coming behind with their high beam on.

• Glasses

• Visors

• Refrigerator door: opening and closing the refrigerator door consumes unnecessary amount ofenergy when the purpose is only to check what is inside.

1.1.2 Building Automation System

A building automation system (BAS) is a system composed of interconnected sensors, actuators andcontrollers distributed throughout a building that communicate through a network (Pinto et al. 2008) tocontrol heating, ventilation, and air-conditioning (HVAC) systems as well as lighting, pumps and lifts(Marinakis et al. 2013) and therefore maximizing operation efficiency (Derek & Clements-Croome 1997)and comfort.

1.2 Purpose

The purpose of this thesis is to propose a solution for installing/replacing EC windows in buildings, andpropose an integration method that enables them to communicate with the building equipment (such assensors that broadcast useful information). The purpose is also to research, develop and implement analgorithm that controls indoor illuminance by adjusting the window’s light transmittance so that comfortis increased. And finally, a simple way to manually manipulate transmittance is to be developed such thatthe product becomes more appealing for consumers, resulting in a broader usage which in turns leads toless global energy consumption.

1.3 Delimitations

Due to time constraints, only the LonWorks and BACnet protocols were included in the research. Otherssuch as KNX, Modbus, Maxim, etc. are not studied in this paper since they are not considered to be aspopular.

The control strategy is made to only depend on the illuminance since designing an algorithm for energyoptimization would require unobtainable amount of time.

Only one test run with the real EC window could be performed in the time frame due to it requiring about24 hours and due to the controller being developed in Stockholm, Sweden, while the real windows werelocated in Uppsala, Sweden.

The inexperience in web-design is the reason why the HMI was made functional rather than well de-signed.

To simplify the implementation of the database, a text file with a predefined layout was designed insteadof using SQL or equivalent.

1.4 Method

This thesis can be divided into four parts: integration, simulations, automatic control and manual control.The methods used to tackle each of these parts are described in the following sections.

2

Page 13: Integration of Electrochromic Smart Windows in Building

CHAPTER 1. INTRODUCTION 1.4. METHOD

1.4.1 Integration

The integration research consists of evaluating the most popular BAS technologies by understanding howthey work. Then a qualified choice considering the following items can be made:

1. Availability of the technology: which technologies are installed today and which technologies areused by the biggest companies in the BAS industry.

2. Costs: how much it costs to buy the necessary equipments and licences for the technology.

3. Time to market: how long it takes from choosing the technology to selling the product. This alsoaffects the total costs.

4. Future availability: which technologies are more prone to still be in the building automation in-dustry in 10 to 20 years.

5. Ease of installation/replacement: how easy it is to configure the device in BASs and do the wiring.For the configuration, depending on the technology, it might be necessary to have technicians, thatare specialized in the device, to configure it.

6. Maintenance: how/if the technology keeps track of the device to check for errors, problems ordefects.

1.4.2 Simulations

To be able to design and test the system with ease, simulations are required. For this case, the developedtools should be capable of simulating the indoor illuminance and temperature so it is possible to drawconclusions about how to control the system, and how it affects energy consumption. A sophisticatedmodel of the environment is then built for this purpose; the model considers the position of the sun at anypoint in time, the window orientation, thickness of the clouds and other properties of a building, such asvolume of the room, area, number of people and computers, etc.

1.4.3 Automatic Control

Knowing the parameter to control (indoor illuminance), the control algorithm is derived with the help ofthe simulation tools provided by this thesis. This algorithm is then implemented on the real windows andthe system can be tested with physical input. A model-based PI controller is developed to automaticallyadjust indoor illuminance by controlling the window’s light transmittance.

1.4.4 Manual Control

A computer can’t really control human comfort, desire or need; so one would occasionally prefer havingthe possibility to manipulate the windows at will. This requires a human machine interface (HMI) withwhich multiple windows can be controlled at the same time from a device that is easily accessible, e.g.a computer or mobile phone. It is also required that the HMI is platform independent, so a website isdesigned where data is displayed and the transmittance of every window can be manipulated by turningoff the automatic control.

3

Page 14: Integration of Electrochromic Smart Windows in Building

CHAPTER 1. INTRODUCTION 1.4. METHOD

4

Page 15: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW

2. Literature review

This review consists of a research about two BAS technologies (namely LonWorks and BACnet) and astudy on smart window control strategies. LonWorks and BACnet are deemed to be the most interestingtechnologies due to their wide use and flexibility.

2.1 LonWorks

The LonWorks (local operation network) technology was developed by the Echelon R© Corporation withthe intention of eliminating a centralized controller (usually a Programmable Logic Controller) (EchelonCorporation 1994) so that each device in the network is a peer, meaning that devices communicate di-rectly by notifying and subscribing to other nodes (Hersent et al. 2012, Strata Resource Inc. 2006). Thisincreases efficiency, removes a single failure point (the controller) (Hersent et al. 2012) and enables thepossibility of integrating third party devices with each other (Echelon Corporation 1994) so the systemis not dependent on a specific manufacturer (Strata Resource Inc. 2006).

There are over 90 million LonWorks devices installed, making it one of the most widely used BAStechnologies (Hersent et al. 2012). LonWorks is an open protocol technology, i.e. the network archi-tecture is built on a particular protocol, the LonTalk R© (Strata Resource Inc. 2006) (also known as theANSI/EIA/CEA-709.1 (EN14908-1) protocol). This protocol provides a set of network rules and de-sign requirements that simplifies interoperability and enables faster time to market (Strata Resource Inc.2006). By applying these rules and requirements to every device, installation does not require man-ufacturer specific training as the software used becomes manufacturer independent (Strata ResourceInc. 2006). LonTalk supports any physical layer that transmits binary signals (usually called channels)(Hersent et al. 2012), as long as the device is connected to this channel through an appropriate transceiver(LonMark International 2005) which provides better flexibility.

To further improve interoperability of devices, an organization, called LonMark R© International, wasformed. This organization sets interoperability guidelines for data types and device profiles (Strata Re-source Inc. 2006). These guidelines include the Standard Network Variable Types (SNVTs, pronouncedsniv-its) and the Standard Configuration Property Types (SCPTs, pronounced skip-its). A network vari-able is a data item that devices expect to get or send through the network (input network variable and out-put network variable respectivelly) (LonMark International 2012). Table 2.1 shows an example of somerequirements for the HVAC temperature variables (SNVT_temp_p variables). A configuration propertyis a network variable that can be configured by network tools with the purpose of facilitating installationof new or replacement devices (Echelon Corporation 2009).

5

Page 16: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW 2.1. LONWORKS

Table 2.1: Example of requirements for the SNVT_temp_p variables.

Requirement SNVT_temp_p variables exampleWhere to use HVAC applicationsUnit oCData structure signed long (Neuron C type)Data range −27317 to 32767Equivalent temperature range −273.17oC to 327.67oCResolution 0.01oC

LonWorks devices usually integrate a microprocessor called Neuron, which has LonTalk embedded,though manufacturers may choose to port LonTalk to other processors (Strata Resource Inc. 2006). TheNeuron is able to process messages received from the network, calculate outputs, send messages and getinput or generate output signals to its I/O ports; all with built-in functions (Toshiba Corporation 2006).This processor is sufficient for most applications and external memory can be added to some versions ofthe Neuron to enable more complex operations (Toshiba Corporation 2006).

Figure 2.1 shows a block diagram of the TMPN3150, which is a Neuron chip model, and Figure 2.2shows an example of a LonWorks network.

Figure 2.1: The TMPN3150 in a Typical Node Block Diagram Configuration (Toshiba Corporation2006).

6

Page 17: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW 2.2. BACNET

Figure 2.2: Example of LonWorks System Configuration (Toshiba Corporation 2006).

2.2 BACnet

BACnet stands for Building Automation and Control NETwork and is a royalty-free and independentopen standard for BAS (Hersent et al. 2012). Due to constant development in the building automation in-dustry, the BACnet protocol was developed with consideration to unknown future applications (Newman1997). This means that BACnet is independent from processor and programming language, and supportsmultiple industry standard protocols such as BACnet/IP, Ethernet, ARCNET, PTP and LonTalk, and alsothe non-industry standard protocol MS/TP (Strata Resource Inc. 2006). The latter was developed by theBACnet committee (SSPC-135) to answer to the absence of non-proprietary low cost LAN technologiesduring BACnet’s initial development, and is now often used as the field level protocol (Strata ResourceInc. 2006). Even though BACnet supports LonTalk, LonWorks’ data structure is not compatible withBACnet’s, meaning they can’t intercommunicate (Strata Resource Inc. 2006).

Like LonWorks, BACnet is one of the mos widely used BAS technologies (Hersent et al. 2012), and wasalso developed to enable the possibility of interconnecting devices from multiple manufacturers (Hans-son 2008). This is possible due to BACnet’s way of abstracting the common functions of a device asobjects (e.g., analog input, analog output) represented by properties (e.g., name, type, configuration pa-rameters) (Hersent et al. 2012). All objects provide services in the network (Hersent et al. 2012). As anexample, a temperature sensor needs an analog input (the temperature); this means that the sensor deviceis defined with, among others, an analog input object that implements standard properties such as presentvalue, description, device type and units (Swan 1996). Figure 2.3 shows an example of a BACnet device.

7

Page 18: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW 2.3. SMART WINDOW CONTROL

Figure 2.3: Example of a temperature sensor BACnet device (Swan 1996).

BACnet works in a client-server model, meaning that messages are service requests that are sent fromthe client and processed by the server which in turns reports back to the client with the results (Newman1997). In cases where non-BACnet devices need to be integrated, a gateway, if available, can be used sothe messages are translated (Newman 1997). Apart from gateways, there are also routers (that BACnetspecifies how to build) that connect networks together even if they are of different types (Newman 1997).Figure 2.4 shows an example of a BACnet network.

Figure 2.4: Example of a BACnet network (Newman 1997).

The BACnet Testing Laboratories (BTL) verifies that BACnet has been implemented correctly by testingagainst the BACnet Device Profiles requirements. If the device passes the test, the BTL lists the devicefor the BACnet community (Strata Resource Inc. 2006).

2.3 Smart Window Control

There are many different control strategies for smart windows. The ones proposed by Jonsson & Roos(2010) are temperature control, illuminance control and switching between them depending on eitherhour of day or presence of people. According to their findings, the strategy with most benefit is switch-ing to temperature control (high transmittance when in need of heating otherwise low) as often as possibleby detecting the presence of people; this way the system is energy efficient and people are not affectedby glare, otherwise controlling only temperature would provide the highest energy efficiency.

Another strategy could be to design a predictive controller, as presented by Kolokotsa et al. (2009), in a

8

Page 19: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW 2.3. SMART WINDOW CONTROL

building energy management system. No smart windows are presented in that paper, instead they controlshading, which could be replaced by smart windows after adjustments to the equations.

The proposed control strategy presented in this paper is illuminance control; no regard is taken to pres-ence of people and energy consumption (due to time constraints). A PI controller is designed to controlthis parameter. The methods provided by Wittenmark et al. (2002) are used for the development of thecontroller describe in Section 3.2.

9

Page 20: Integration of Electrochromic Smart Windows in Building

CHAPTER 2. LITERATURE REVIEW 2.3. SMART WINDOW CONTROL

10

Page 21: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN

3. Control design

The purpose of the controller is to control the indoor illuminance that is induced by the sunlight passingthrough the windows, so as to reduce glare and provide a comfortable light intensity in the workplace.

3.1 System modeling

To be able to design a good control and simulation, a physical model of the system is required. Thissection describes how this model is built.

Illuminance is defined as luminous flux per unit area (SI unit [lux]) (Wikipedia 2013a). Luminous flux(SI unit lumen [lm]) is a measure of light intensity perceived by the human eye; it is equivalent to radiantflux (SI unit [W ]) but differs in that the luminous flux is weighted according to the sensitivity of thehuman eye to different wavelengths (Wikipedia 2013b).

Equation 3.1 describes the illuminance inside a room containing a window,

I = E · r ·Tvis ·Aw

Ar(3.1)

where

I - indoor illuminance [lux]E - incident solar heat [W/m2]r - sunlight luminous efficacy [lm/W ]Tvis - visible light transmittance [1]Aw - area of the window [m2]Ar - area of the room that is affected by the light passing through the window [m2]

The area of the window and room can be set for different buildings, but could also be neglected, so thecontroller controls glare rather than indoor illuminance. The visible light transmittance, Tvis, depends onthe state of the window; regular windows have a constant value, while the windows used for this thesiscan be controlled.

An EC window can be represented as a circuit composed of a capacitor in series with a resistance, seeFigure 3.1.

+R i

Cuc

u

Figure 3.1: EC window representation

11

Page 22: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.1. SYSTEM MODELING

The voltage over the capacitor, uc, indicates the state of the window, thus it relates to Tvis in a linearmanner, shown in Equation 3.2.

Tvis(t) = k ·uc(t)+m (3.2)

Since Tvismax⇔Umin and Tvismin⇔Umax, where Umin and Umax represent the minimum and maximum inputvoltage on the system, then

m = Tvismax− k ·Umin

andk =

Tvismax−Tvismin

Umin−Umax

By applying Kirchhoff’s voltage law on the circuit from Figure 3.1, we get

u(t)−R · i(t)−uc(t) = 0 (3.3)

where the current i is given by,

i(t) =Cduc(t)

dt(3.4)

thus, Equation 3.3 becomes

u(t)−RCduc(t)

dt−uc(t) = 0 (3.5)

The Laplace transformation of Equation 3.5 yields

U(s)−RC ·Uc(s)s−Uc(s) = 0

⇒Uc(s) =U(s)

RCs+1(3.6)

then, by Laplace transforming Equation 3.2 and replacing Uc(s) with Equation 3.6, we get

TV IS(s) = kUc(s)+m

⇒ TV IS(s) =kU(s)

RCs+1+m (3.7)

The constant m is a static gain which does not affect the controller; it can then be neglected for the cal-culation of the complete transfer function (it is however used on the Simulink simulations), so Equation3.7 becomes

TV IS(s) =kU(s)

RCs+1(3.8)

The Laplace transformation of Equation 3.1 together with Equation 3.8 yields

I(s) = E · r · k ·TV IS(s) ·Aw

Ar

⇒ I(s) =E · r · k ·U(s)

RCs+1· Aw

Ar(3.9)

And finally, given that the transfer function of a system is defined as

G(s) =Output(s)Input(s)

then

G(s) =I(s)U(s)

=E · r · k

RCs+1· Aw

Ar(3.10)

12

Page 23: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.2. CONTROLLER

3.2 Controller

A PI-controller with both feedback and feedforward was chosen because it eliminates static state error.With this kind of controller, it is possible to take advantage of pole-placement, which improves controlcapabilities by making it possible to render faster dynamics. To be able to implement the controller in thereal system, the design was made in discrete time. By designing this way from the beginning, as opposedto converting it from continuous time later on, the system becomes more exact thus not requiring fastsampling rates, rendering it more power efficient.

By defining

G(s) =B(s)A(s)

(3.11)

we get from Equation 3.10 that

B(s) =E · r · k

RC· Aw

Ar(3.12)

andA(s) = s+

1RC

(3.13)

Matlab’s built-in function c2d() converts the continuous time transfer function into discrete by usingthe zero-order hold method (which is not an approximation, rather the exact definition of discretization).Using this function we get

G(z) =B(z)A(z)

(3.14)

B(z) = b (3.15)

A(z) = z−a (3.16)

where a and b are fetched from the output of the function.

Now, to design the PI feedback transfer function in discrete time we say

Gc(z) =S(z)R(z)

(3.17)

S(z) = s0 · z+ s1 (3.18)

R(z) = z−1 (3.19)

where s0 and s1 are parameters that can be chosen by the designer; they are equivalent to the P and Iparameters in the continuous time design.

G(z)

Gc(z)

r u y−

uc

Figure 3.2: Block diagram of an output feedback control

We know that the closed-loop transfer function of an output feedback control is expressed as follows

Gcl(z) =G(z)

1+G(z)Gc(z)=

B(z)R(z)A(z)R(z)+B(z)S(z)

(3.20)

13

Page 24: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.2. CONTROLLER

then, one can observe that the s0 and s1 parameters will effectively affect the poles of the system. Itis now possible to define s0 and s1 so that the polynomial A(z)R(z)+B(z)S(z) becomes whatever thedesigner wants (as long as it is of the same order). The following equations demonstrate a way to do this.

Acl(z) = A(z)R(z)+B(z)S(z) = z2 +(b · s0−a−1)z+a+b · s1 (3.21)

Ad(z) = Am ·Ao (3.22)

where Am is a polynomial of the same order as A(z) that provides the poles of the final system and Ao isa polynomial of the complementary order, such that Ad is of the same order as Acl .

Am(z) = z+ p0 (3.23)

Ao(z) = z+ p1 (3.24)

wherep0 =−e−ω0·Ts

p1 =−e−ω1·Ts

Ts is the sampling time of the controller. The parameters ω0 and ω1 define the pole of the closed-loopsystem and the zero of the feedforward transfer function (shown in Equation 3.29) respectively; bothaffect the controller’s speed and stability.

Pole-placement is now possible by solving the Diophantine equation, shown in Equation 3.25,

Acl(z) = Ad(z) (3.25)

which yields

s0 =a+1+ p0 + p1

b(3.26)

s1 =p0 · p1−a

b(3.27)

G f (z) G(z)

Gc(z)

r u f u y−

uc

Figure 3.3: Block diagram of an output feedback control with feedforward

When adding feedforward to the system, the complete transfer function is given by

Gs(z) =G(z)G f (z)

1+G(z)Gc(z)(3.28)

where

G f (z) =T (z)R(z)

(3.29)

so Equation 3.28 becomes

Gs(z) =B(z)T (z)

A(z)R(z)+B(z)S(z)=

B(z)T (z)Am(z)Ao(z)

(3.30)

14

Page 25: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.2. CONTROLLER

T (z) is chosen by the designer such that the dc-gain of the complete system becomes 1, and one pole isremoved (namely Ao) rendering Gs more stable.

T (z) = t0Ao(z) (3.31)

where t0 fixes the dc-gain. By inserting Equation 3.31 into 3.30 we get

Gs(z) =B(z)t0Ao(z)Am(z)Ao(z)

=B(z)t0Am(z)

(3.32)

The dc-gain is defined as the value of the function when time goes to infinity, which is equivalent to

dc-gain = lims→0

Gs(s)

The exact definition of z isz = esTs

solims→0

z = 1

thendc-gain = lim

z→1Gs(z) (3.33)

Since we want the dc-gain to be 1, then

t0 = limz→1

Am(z)B(z)

and from Equation 3.23 and 3.15 we get

t0 =1+ p0

b(3.34)

so the complete transfer function becomes

Gs(z) =1+ p0

z+ p0(3.35)

And finally all the required transfer functions are derived

Gc(z) =(a+1+ p0 + p1)z+ p0 · p1−a

b(z−1)(3.36)

G f (z) =(1+ p0)(z+ p1)

b(z−1)(3.37)

There is a restriction to how much supply voltage the windows can take, so as not to damage them. Thislimit affects the output of the PI controller such that the I (integrator) part winds up (grows too largewhich results in an overshoot); this happens when the controller outputs a signal but, due to the limit,no change is achieved so the input to the controller becomes constant even though the controller strivesagainst that. Since the controller integrates the input signal (in the I part), the constant input becomes alinear equation (if it differs from zero) and increases until a change happens and it starts to decrease. Ifthe I part reaches too large values, it will take some time to decrease, and the system then overshoots. Tocounteract this effect, an anti-windup system needs to be designed. The following block diagrams depicta system with anti-windup.

G f (z) Saturate G(z)

Feedback

r u f ube f ore u

∆u

y−

uc

Figure 3.4: Block diagram of the system with anti-windup

15

Page 26: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.3. SIMULATIONS

s0·zz−1

1z−1s1

f · s1

y uc

∆u

+

Figure 3.5: Block diagram of the feedback block, where f is a parameter whose value shall be tuned

∆u = u−ube f ore (3.38)

The next step is to design a good simulation of the environment and tune the controller by selectingvalues for ω0, ω1 and f and deciding what sampling time, Ts, should be used. As a rule of thumb,

Ts =

[2π

10ω0,

30ω0

]

The output of the controller, i.e. the desired input to the windows, is u. Using the block diagrams fromFigure 3.4 and 3.5, u can be calculated,

u = r ·G f (z)−(

y ·Gc(z)−∆u · f · s1

z−1

)where Gc(z), G f (z) and ∆u are fetched from Equations 3.36, 3.37 and 3.38 respectively. To simplify theequations, the constants s0, s1 and t0 are used instead of their real definitions found in Equations 3.26,3.27 and 3.34,

u = r · t0(z+ p1)

z−1− y · s0 · z+ s1

z−1+(u−ube f ore

)· f · s1

z−1(3.39)

By following the rule that,x · zk = xk (3.40)

where k =−m, 1−m, . . . , n−1, n indicating the value of x in the past (negative k) and future (positivek) iterations, one can observe that Equation 3.39 should be simplified as follows

u · z = u+ r · t0(z+ p1)− y · s0 · z+ s1 +(u−ube f ore

)· f · s1 (3.41)

Since it’s impossible to know the value of u in the future, we divide both sides with z

u = u · z−1 + r · t0(1+ p1 · z−1)− y · s0 + s1 · z−1 +(u−ube f ore

)· f · s1 · z−1 (3.42)

Using the rule from Equation 3.40 in Equation 3.42 we get

u0 = u−1 + t0(r0 + p1 · r−1)− s0 · y0 + s1 · y−1 +(u−1−ube f ore−1

)f · s1 (3.43)

At last the pseudo-code can be derived, see Appendix A.

3.3 Simulations

This section provides information about the simulation environment to test the controller. Section 3.3.1shows the equations used to achieve a truthful simulation of the controller, while Section 3.3.2 shows theequations used to observe the impact of the controller on the indoor temperature so an estimation of theenergy needed to regulate the temperature can be calculated.

16

Page 27: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.3. SIMULATIONS

3.3.1 Controller

One important thing to note about this system is that the incident solar heat intensity, E, depends ondate, time of day, latitude, angle of the window and thickness of the clouds. It is what affects the indoorilluminance if the indoor lights are off. The incident solar heat intensity is seen as a disturbance on thesystem and is what the controller will try to fix.

The best way to tune the controller is to have a simulation of the environment. Since this system is slow(step response of about 20 minutes for window sizes of about 2m2), tuning it by using the real equipmentwould take too much time. Hence good simulation tools and physical models are required.

The simulation is done by first building the real physical model of the system into Simulink (rather thanusing the transfer function from equation 3.10) and then calculating the incident solar heat intensityduring a specified period of time (from a specific date).

The following block diagrams illustrate the model of the real system with the controller.

G f (z) Saturate Real system

Feedback

r u f ube f ore u

∆u

I−

uc

Figure 3.6: Block diagram of the complete system

EC window × AxAr· r

E

u Tvis I

Figure 3.7: Block diagram of the real system from input voltage to indoor illuminance

1RCs+1 k

m

u uc Tvis

+

Figure 3.8: Block diagram of the EC window from input voltage to transmittance

17

Page 28: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.3. SIMULATIONS

To calculate the solar heat intensity, the position of the sun needs to be known for every point in time.For future reference, the following variables are used (they are all expressed in degrees)

φ - latitude angleα - angle of the window from due South (clockwise)β - solar incidence angleω - solar hour angleδ - solar declination angleγs - solar altitude angleαs - solar azimuth angleαF - wall solar azimuth angleωsr - solar sunrise hour angleωss - solar sunset hour angle

where φ and α are arbitrarily selected.

The incident solar heat intensity is defined as

E = Emax cosβ · e−C·m ·

1 if cosβ > 00 otherwise

(3.44)

where

Emax - the solar heat intensity just outside the Earth’s atmosphere, about 1361W/m2

C - the extinction coefficient of the Earth’s atmosphere; it depends on the thickness of the clouds

C =

0.21 clear sky0.80 partly cloudy

higher thicker clouds

m - the optical air mass through which the solar beams travel to reach the surface of the Earth

m =1

sinγs

To calculate the incidence angle we have

cosβ = cosγs · cosαF ·

1 if ωsr < ω < ωss

0 otherwise(3.45)

The solar hour, sunrise/sunset hour, altitude and wall azimuth angles are given by

ω = 15(t−12) (3.46)

ωsr =−cos−1(− tanφ · tanδ) (3.47)

ωss =−ωsr (3.48)

sinγs = sinδ · sinφ+ cosδ · cosφ · cosω (3.49)

αF = ∆α+

360 if ∆α < 180−360 if ∆α > 180

(3.50)

where t is the time of day in hours and ∆α = αs−α.

The following equations define the solar azimuth angle

sinαs =cosδ · sinω

cosγs

18

Page 29: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.3. SIMULATIONS

cosαs =sinφ · sinγs− sinδ

cosφ · cosγs

αs = cos−1(cosαs) ·

1 if sinαs > 0−1 if sinαs < 0

(3.51)

And finally the solar declination angle, which is expressed as follows

sinδ = sin(−23.44) · cos

360

N +9365.24

+0.0167sin

(360(N−3)

365.24

(3.52)

where N is the day of the year, i.e. N = 32 yields February 1st.

3.3.2 Temperature

One of the reasons smart windows are attractive for the consumer is that they have good potential forenergy savings; this because regulating the sunlight level has a major impact on the indoor temperature.This impact is estimated in simulations and compared to regular windows. The following equation isused to calculate the indoor temperature,

dTin(t)dt

=Tout(t)−Tin(t)

V

(1cv

(Awin

(Uwin +

E(t) ·g(t)Tout(t)−Tin(t)

)+Awall ·Uwall

)+Q

)+

dTcp(t)dt

(3.53)

where

Tin(t) - indoor temperature at a certain time [oC]Tout(t) - outdoor temperature at a certain time [oC]V - volume of the room

[m3]

cv - volumetric heat capacity of air[ J

m3·K]

Awin - area of the window[m2]

Uwin - U-factor of the window[ W

m2·K]

E(t) - incident solar heat intensity at a certain time (see Equation 3.44)[W/m2

]g(t) - g-value of the window [−]Awall - area of the walls, roof and floor

[m2]

Uwall - U-factor of the walls, roof and floor[ W

m2·K]

Q - inwards volume flow of air[m3/s

]Tcp(t) - temperature originated from other factors, such as computers and people [oC]

The g-value, also known as solar factor or solar heat gain coefficient (SHGC), is a coefficient for mea-suring the solar energy transmittance of a window. In regular windows, this value is a constant whereasin smart windows it is linearly related to the light transmittance.

In Equation 3.53 it is assumed that Tout , Tin, Tcp, E and g depend on time, the rest are constants. Theconstants are defined as

V = Room area×Room heightAwall = [Area of](Facade−Windows+Floor+Side walls+Back wall)Q = [Window](Air flow×perimeter×Gap×Number)+ [Duct](Air flow×Area)

Since the temperature outside varies during a day, a very rough estimation is presented in the followingequations, where values for average maximum and minimum temperatures during every month in a yearin Stockholm, Sweden, are approximated with a sine wave function and each day is approximated with asine wave stretching from the higher wave to the lower. The average values for every month are presentedhere,

Tmax = −0.7, −0.6, 3.0, 8.6, 15.7, 20.7, 22.2, 20.4, 15.1, 9.9, 4.5, 1.1

19

Page 30: Integration of Electrochromic Smart Windows in Building

CHAPTER 3. CONTROL DESIGN 3.3. SIMULATIONS

Tmin = −5.0, −5.3, −2.7, 1.1, 6.3, 11.3, 13.4, 12.7, 9.0, 5.3, 0.7, −3.2Tmean =

Tmax+Tmin2

∆T = Tmax−Tmin

To approximate the temperature during a day, we need an approximation of the mean temperature forevery day and an approximation of the temperature oscillation during that day. The mean temperatureapproximation is shown in Equation 3.54. The reader should note that these equations were derived fromseveral trial and error attempts.

Tmeanapprox(t) = (max(Tmean)−min(Tmean))cos( t

52 −0.4)+2.5

2.1(3.54)

Equation 3.55 approximates the oscillations. Here we approximate the difference in maximum andminimum temperature during each day and then make it oscillate. The oscillation divided by two addedwith the mean temperature gives us the approximation of the temperature for every point in time.

∆Tapprox(t) =max(∆T )−min(∆T )

cos( 12t

365·1.9 −0.7)+ 1

1.52

(3.55)

And then Tout is given by,Tout(t) = Tmeanapprox(t)+∆Tapprox(t) (3.56)

Since this is supposed to simulate an office space, it is also relevant to take into consideration the numberof people present and running computers, since these parameters produce a non-negligible amount ofheat. Because employees are usually present from 8 to 17 o’clock, their produced heat is considered todepend on time. The following heat equation shows the temperature change generated from this heat.

dTcp(t)dt

=Qcp(t)V · cv

; (3.57)

where, assuming every person has one computer,

Qcp(t) = (Person heat+Computer heat)×Number of people(t)

and

Number of people(t) =

x if 8 h < t < 17 h0 otherwise

And finally, to calculate the power required to control the temperature to a desired level, such that it ispossible to compare power efficiency between windows, a simple continuous PI controller is developed.Since this is merely for a discussion, not much effort has been put into the design of this controller, insteadthe controller parameters are generated by Simulink’s PI tuner. Assuming the device that regulates thetemperature is a heat pump which can output negative and positive heat, where negative values representthe air-conditioning power, an extra parameter is added to Equation 3.53; namely,

Qpump(t)V · cv

(3.58)

where Qpump is the heat generated by the pump, and its Laplace transform is,

QPUMP(s) = (Tdesired−TIN(s)) ·(

kP +kI

s

)(3.59)

where kP and kI are the parameters that Simulink tunes.

20

Page 31: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION

4. Implementation

An EC window is usually equipped with a window control unit (WCU) which handles, among others,network communication and voltage input to the window.

Figure 4.1: Window control unit closed (left) and open (right)

The studied WCUs are composed of a 32-bit microcontroller running at 12 MHz. The embedded softwarefills the entire flash memory, so adding extra functionality implies that another has to be removed. Dueto the high rise-time in the window step response as compared to the microcontroller’s frequency, therequirement is not considered time critical, meaning that the software scheduling is an infinite loop withinterrupt handlers rather than a full featured RTOS. With a feedback control algorithm, the WCU can setthe transmittance level of a window.

The following sections describe the implementation of the computer master on this system. The computermaster was first implemented on a laptop running the Ubuntu OS and then ported to a Raspberry Pi modelB computer running the Raspbian OS due to its small physical size and low power consumption.

4.1 Communication

The WCUs are capable of communicating with a master unit. The communication is accomplished usingthe RS-485 bus network standard with a baud rate of 115200 Bd, whereas the protocol was developedby the designers of the WCUs. As the task is to implement master functionality on a computer, the

21

Page 32: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.1. COMMUNICATION

protocol has to be understood, so reading through the embedded software is required. Tables 4.1 and 4.2demonstrate how message frames are built using the protocol.

Table 4.1: Message frame

Start of frame Destination address Source address Command Data length Data CRC

The following table describes every section of Table 4.1 in more detail.

Table 4.2: Message frame protocol

Field name Length (bytes) DescriptionStart of frame 2 The same bytes in every message

Destination address 2The address of the node to which the message is des-tined

Source address 2The address of the node from which the messagewas sent

Command 1 Tells the node what kind of message it is

Data length 1Tells the node how many bytes the data has, so itknows how many bytes to read

Data 0-255 The data that is transmitted

CRC 2The checksum number to verify that data has beencorrectly received

Every node is assigned an address so it can filter the messages and only read the ones that were sent toit, since, in bus communication, all the nodes receive every message.

Node 1

Node 2

Node 3

Node 4

Figure 4.2: Bus network

The protocol uses the CSMA method to provide better reliability on the communication, i.e., with thehelp of a receiver, each node waits until no message is being sent by another node, and then sends itsown. Since the purpose of the WCUs are merely for demonstrating what the windows are capable of, thecommunication was not made 100% reliable.

When data is transmitted through the network by another node, an interrupt handler is triggered in theWCU where it saves the data into a buffer; this buffer is processed on every cycle of the infinite loopin the main function. After processing, the WCU does the requested action and replies with a message,either with just an acknowledgement or containing the requested parameter value.

After understanding how the communication works, it is possible to start implementing the computermaster. To connect the computer to the network, an USB to RS-485 converter, shown in Figure 4.3, isused. Then, to send the right messages, a software is required.

22

Page 33: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.2. DATABASE

Figure 4.3: USB to RS-485 interface module (module name USB-RS485)

4.2 Database

The layout of the designed database’s text file is described by Tables 4.3 and 4.4

Table 4.3: Database layout

Address Space Control Space Illuminance Space Transmittance level Line feed

The following table describes every section of Table 4.3 in more detail.

Table 4.4: Database description

Field name Length(characters) Description

Address 4 The address of the slave in hexadecimal (without the 0x part)Control 1 Whether in automatic or manual control mode (1/0)

Illuminance 4The current illuminance value read from the sensor in the win-dow

Transmittancelevel

5 The output of the controller

Space 1 A space character to separate the different fieldsLine feed 1 A line feed character to separate the different slaves

4.3 Automatic Control

Once the controller is defined and the communication working, the code (from Appendix A) is imple-mented. Though for it to work, a simple I2C illuminance sensor needs to be connected to the WCUs andto acquire its data, an extra function is included in the WCU’s embedded software where upon receivinga request, it replies with the value of the sensor.

4.4 Manual Control

A website is developed to make it possible for anyone to control the windows manually; this way one cancontrol a window using any device with a web-browser and a connection to the intranet of the windows(computer, smart phone, etc.). The website reads the database and displays the data to the user. The usercan then set the transmittance level of a window and start or stop automatic control at will.

Since the ability to manipulate the windows from anywhere in the world is not necessary, due to that theuser is only affected by the windows locally, the website is not made public, so the server is only seen bydevices connected to the same network (intranet).

23

Page 34: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.5. SOFTWARE

To get the server running, the Apache HTTP Server version 2.4.4 is used.

As can be seen in Figure 4.4 and 4.5, the design is very simplistic due to both the scarce knowledge onweb-design and that the reason is to have a proof of concept rather than a full feature website.

Figure 4.4: The website accessed from the Safari 6.0.5 web-browser on a computer running OS X 10.8.4

Figure 4.5: The website accessed from the Safari web-browser on an iPhone 4 running iOS 6.3.1

4.5 Software

The software for the communication and controller was written in C++ due to both the fact that it is anobject oriented programming language, which makes it easier to design software with different levels

24

Page 35: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.5. SOFTWARE

of abstraction layers, and due to it’s compatibility with the C programming language that is used in theWCUs, so e.g., the code for calculating the checksum can be reused.

The software is composed of several classes with different functionalities and levels of abstraction. Toget a better understanding of the software, a description of every class is shown in the following list.

• SerialCom - where the low level serial communication (RS-485) is handled. A helper file is usedwhere all the lowest level functions are found, e.g., open port, close port, read serial buffer andsend byte.

• Checksum - where the checksum is calculated. It uses the same functions as the WCU so as not todiffer.

• Frame - where the message frame is built with the right protocol.

• Message - used as an abstraction layer from the frame, such that if the protocol is changed, thisclass can stay the same.

• Database - handles the database actions.

• Controller - where the controller calculations take place.

• Slave - where the address and the controller are stored for each slave.

• Master - Inherits from Slave (i.e. everything Slave has, it has) and adds extra functionality so itcan manipulate the slaves.

Figures 4.6 and 4.7 provide an overview of the software following the UML standard.

Frame

Master

Checksum

1 1

Controller

1 p

1

SlaveDatabase

1 p

1

1..* p

1

1..* p

1 p

Message

SerialCom

Figure 4.6: UML class diagram of the software

25

Page 36: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.6. TESTING

Set new level

Construct a master

Get Illuminance

Controller step

Slave 1 p Slave i p i=2,3...n

Equal activity for every slave

Sample timetimer

Figure 4.7: UML activity diagram of the software

4.6 Testing

The following sections describe how tests are performed to ensure the system works properly.

4.6.1 Software

The software has two running modes: simulation and normal. In simulation mode, the software can betested against runtime errors, memory leaks and of course to assure that functions are working properly.This makes the process of spotting errors a lot faster, as the hardware (the windows) is not required. Toaccomplish this, the SerialCom class needs change so it doesn’t open the serial port for sending andreading data, but instead uses a sleep function to simulate a byte being sent.

In normal mode, the software is tested against sending and receiving messages correctly. The WCUshave to be connected to the computer for the test to be effective.

4.6.2 Complete system

To test the complete system with the controller, a model house (around 0.3 m3) was used, see Figure 4.8.This model house contains several small windows (around 0.08 m2) with their respective WCUs. Themodel WCUs differ from the real ones in that they use a counter to set the level rather than controllingthe transmittance in a closed loop manner, i.e. the WCU outputs maximum/minimum voltage until thecounter counts up/down to the specified number.

Being that the windows are smaller, the step response is faster, which means that the capacitance valueof the window is lower. By measuring the time it takes for the transmittance to change from highest tolowest, the capacitance value of these windows is estimated to be around 20 times less than for the real

26

Page 37: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.6. TESTING

windows. This means that the control parameters are different.

By logging the data, graphs (shown in Section 5.2) are used to prove that the system works properly.The source of illuminance in the tests with the model house is a lamp, while in the real system it is thedaylight.

Figure 4.8: Model house with windows’ transmittance level alternating (highest and lowest levels)

27

Page 38: Integration of Electrochromic Smart Windows in Building

CHAPTER 4. IMPLEMENTATION 4.6. TESTING

28

Page 39: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS

5. Results

5.1 Simulations

In this section, the chosen parameters and the rendered graphs from the simulations and test runs arepresented. The parameters for the simulations were estimated with regard to an office space.

5.1.1 Controller

By being able to calculate the position of the sun for any point in time, it is possible to tune the controllerparameters. This should be done with a good simulation of the environment. To accomplish this, theparameters in Table 5.1 are selected.

Table 5.1: Parameters selected for the simulation of the real environment

Parameter Dimension

Window capacitance 10 F

Window resistance 24 Ω

Direct sunlight luminous efficacy 93 lm/W

Number of windows 10

Window area 1 m×2 m×Number of windows = 20 m2

Width of the wall holding the windows 10 m

Room depth 20 m

Area of the room Wall width × Room depth = 200 m2

Maximum input voltage 2V

Minimum input voltage −2V

Maximum window transmittance 0.5

Minimum window transmittance 0.15

Controller set point 500 lux

Window angle due South 0o

Latitude 59.3o

Dates tested June 23rd and January 19th

Sky Clear

29

Page 40: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.1. SIMULATIONS

Using these parameters we get the solar heat intensity shown in the following figures

Jan Apr Jul Oct0

100

200

300

400

500

600

700

800

900

1000

Month of the year

Sola

rhea

tint

ensi

ty[W

/m2 ]

Figure 5.1: Peak incident solar heat intensity for every day in a year

00 03 06 09 12 15 18 21 000

100

200

300

400

500

600

700

800

900

1000

Hour of day

Sola

rhea

tint

ensi

ty[W

/m2 ]

Jun 23Jan 19

Figure 5.2: Incident solar heat intensity during one day in the summer and another in the winter

After many attempts with different values for the controller parameters (ω0, ω1 and f ), the followingwere considered optimal for windows with a step response of 20 minutes:

ω0 = 0.05ω1 = 0.3ω0f = 100Ts = 6 seconds ( 2π

20ω0rounded to the closest integer)

The following figures are rendered from the simulation where the tuned parameters and the parametersfrom Table 5.1 are used.

30

Page 41: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.1. SIMULATIONS

00 03 06 09 12 15 18 21 000

100

200

300

400

500

600

700

800

900

Hour of day

Indo

orill

umin

ance

[lux

]Jun 23Jan 19

Figure 5.3: Controlled indoor illuminance during one day

00 03 06 09 12 15 18 21 00−2.5

−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

2.5

Hour of day

Sign

alvo

ltage

[V]

Jun 23Jan 19

Figure 5.4: Signal voltage from the controller during one day

31

Page 42: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.1. SIMULATIONS

00 03 06 09 12 15 18 21 000

10

20

30

40

50

60

70

80

90

100

Hour of day

Tvi

s[%

]Jun 23Jan 19

Figure 5.5: Window transmittance resulted by the controller signal during one day

5.1.2 Temperature

Using the same parameter values as in Table 5.1 and complementing with Table 5.2, the indoor temper-ature simulations are performed.

Table 5.2: Parameters selected for the simulation of indoor temperature

Parameter Dimension

Room height 3 m

cv 1211 Jm3·K

Uwin 1.5 Wm2·K

Uwall 0.15 Wm2·K

Gap around the window frame that allows inflow ofair

0.001 m

Inwards air flow speed through window 1 m/s

Area of air duct 0.1 m2

Inwards air flow speed through air duct 1 m/s

Number of people and computers 30

Heat per person 100W

Heat per computer 300W

Maximum g-value 0.44

Minimum g-value 0.17

Using the equations defined in Section 3.3.2 and implementing them into the Simulink model of thesystem with the controller, the indoor temperature is simulated and a comparison can be made between

32

Page 43: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.1. SIMULATIONS

EC and regular windows. The parameters chosen for the regular window are considered to render highenergy efficiency in the northern countries; these are:

g = 0.35Uwin = 0.32 W

m2·K

00 03 06 09 12 15 18 21 00−10

0

10

20

30

40

50

60

70

80

Hour of day

Tem

pera

ture

[o C]

ToutTin EC windowTin regular window

Figure 5.6: Temperatures in June 23rd

00 03 06 09 12 15 18 21 00−10

0

10

20

30

40

50

60

70

80

Hour of day

Tem

pera

ture

[o C]

ToutTin EC windowTin regular window

Figure 5.7: Temperatures in January 19th

To compare the energy efficiency of the two windows, the simple temperature controller, described inEquations 3.58 and 3.59, is used. The following controller parameters are acquired from Simulink’s PItuner:

kP = 2675kI = 8.42

The absolute value of the controller output is integrated during a year so an estimate of the amount ofenergy required to regulate the indoor temperature is calculated. In this case, instead of simulating with

33

Page 44: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.2. REAL TEST RUN

windows only facing South, the simulation is run with windows facing all four directions (North, East,South and West) so a more accurate conclusion can be drawn. It is also relevant to consider the energyconsumed by the computer master as well as the WCUs. Both are considered to have constant valuessince, according to the simulations, the amount of extra energy required to run the windows is around10 Wh/year which can be neglected. Making the assumptions that the computer and one WCU draw 5Wand 1W respectively, which are considered rather high values, the following table shows the results,

Table 5.3: Energy required to regulate the temperature to 23oC during one year

Window type Energy in each direction [MWh] TotalNorth East South WestEC 52.56 53.99 57.63 54.80 218.99Regular 52.49 55.08 61.10 56.16 224.84

1.001 0.980 0.943 0.976 0.974 Quote

5.2 Real Test Run

Data is logged while the system runs such that it is possible to verify that the system works as it issupposed.

Running with the model house, the following graphs were generated. In this case, a lamp was placedbefore a window containing a sensor behind the EC film.

0 50 100 150 200 250 300 350 400 450 500 550 6000

100

200

300

400

500

600

700

800

900

1000

Seconds

Illu

min

ance

[lux

]

Figure 5.8: Test run with model house: sensor data

34

Page 45: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.2. REAL TEST RUN

0 50 100 150 200 250 300 350 400 450 500 550 6000

1

2

3

4

5

6·104

Seconds

Cou

nter

sign

al[-

]

Figure 5.9: Test run with model house: signal input

The test was then run with a real window facing South on a real house during one day, see Figure 5.10.

Figure 5.10: View from the real EC window

35

Page 46: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.2. REAL TEST RUN

The following graphs show the raw logged data.

18 21 00 03 06 09 12 150

1000

2000

3000

4000

5000

6000

7000

Hour of day

Illu

min

ance

[lux

]

Figure 5.11: Test run with real window: raw sensor data

18 21 00 03 06 09 12 155

10

15

20

25

30

35

40

45

Hour of day

Tran

smitt

ance

sign

al[%

]

Figure 5.12: Test run with real window: raw signal input

To get a better understanding of the previous graphs, as the sensor sometimes outputs strange data, thedata was filtered with a digital low pass filter (forward and backwards filtering to eliminate phase shift).Data is also swapped such that the graphs range from 0 to 24 o’clock to be more comparable with thesimulations.

36

Page 47: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.2. REAL TEST RUN

00 03 06 09 12 15 18 21 000

1000

2000

3000

4000

5000

6000

Hour of day

Illu

min

ance

[lux

]

Figure 5.13: Test run with real window: filtered sensor data

00 03 06 09 12 15 18 21 005

10

15

20

25

30

35

40

45

Hour of day

Tran

smitt

ance

sign

al[%

]

Figure 5.14: Test run with real window: filtered signal input

For an explanation of the strange signal input for the model house and an explanation of the real windowgraphs, the reader is redirected to Section 6.1.4.

37

Page 48: Integration of Electrochromic Smart Windows in Building

CHAPTER 5. RESULTS 5.2. REAL TEST RUN

38

Page 49: Integration of Electrochromic Smart Windows in Building

CHAPTER 6. DISCUSSION AND CONCLUSIONS

6. Discussion and Conclusions

6.1 Discussion

6.1.1 LonWorks vs BACnet

To develop a LonWorks device with the LonMark logo and get all the documentations needed or for aBACnet device to be tested in the BTL, fees are required, though the BACnet’s total fees are deemedto be less expensive. Both LonWorks and BACnet are open systems, meaning any manufacturer canget access to documents and develop devices. The Echelon Corporation provides developers with kitswith all the necessary software and hardware to get started with development of LonWorks devices. Thisdecreases time to market of a product effectively reducing development costs. The BACnet communityalso provides such development kits, though with less support.

Both technologies tackle item 4 from the list in Section 1.4.1 by being able to work with any physicallayer and be ported to any processor. Since LonWorks devices almost always use the Neuron processor,BACnet has a better support for porting which makes it a more future focused technology.

One of the challenges when installing or extending a network in a building, is wiring. All devices needpower, meaning that most of them need wires regardless of technology. Visible wires are usually dis-liked, i.e. some sort of renovation might be needed to hide them (by installing them inside the walls orceiling). By using power line communication (PLC), the amount of wires a device requires is reduced totwo, since both communication and power are distributed through the same wires. Radio frequency (RF)also accomplishes this feature, however RF signals might not reach everywhere in the building. Reduc-ing the amount of wires, facilitates installation since less wires need to be hidden. LonTalk supports bothPLC and RF, and Echelon provides Neuron processors capable of communicating through both. SinceBACnet also supports LonTalk, it also supports these media, however there is more documentation forLonWorks.

To answer to items 5 and 6 from the list in Section 1.4.1, Echelon has developed the LonMaker R© Inte-gration Tool that simplifies design, installation and maintenance of LonWorks’ networks. The BACnetcommunity also provides these kinds of tools, however each is usually built for an unique task (eitherdesign, installation or maintenance).

6.1.2 EC Smart Windows

The controlled parameter (indoor illuminance) was chosen to provide better comfort, rather than to re-duce energy consumption. This because temperature is already well regulated by other means, while theexisting indoor illuminance control (by means of curtains or automatic shading systems) is not consid-ered as pleasant, since they block the outside view, which people usually appreciate having. Increasingcomfort, increases productivity, and decreasing energy consumption, decreases not only costs but alsoenvironmental impact.

Simulating with optimal windows, i.e. maximum and minimum transmittance of 100 and 0%, the min-imum required transmittance value, to be able to control the illuminance at 500 lux in the office space

39

Page 50: Integration of Electrochromic Smart Windows in Building

CHAPTER 6. DISCUSSION AND CONCLUSIONS 6.2. CONCLUSIONS

from Table 5.1, is around 6%. This is a quite small number if compared to the 17% that is the actualvalue. With more development, lower values might be achieved with the EC technology, though reach-ing 6% on a single EC film layer could take several years. Multiple EC film layers can accomplish this,however the high end of transmittance also decreases.

6.1.3 Communication

Robust bus communication protocols are quite complex, due to the sharing of the same physical layer. Asmentioned in Section 4.1, the protocol used in this system is not 100% reliable. If this protocol is used onthe end product, improving the reliability is recommended by including collision detection (CSMA/CD)or collision avoidance (CSMA/CA). The latter method is simpler to implement while collision detectionis more reliable.

6.1.4 Test runs

As can be seen from the test runs from Section 5.2, the input signal from the model house differs some-what from the real window test. This because in the model house, the signal is actually a timer, meaningthe WCUs input a constant voltage for a period of time, whereas the signal on the real system is thetransmittance set point of the window. The timer makes it more difficult for the controller to set thetransmittance level as open loop systems are not as exact as closed loop ones.

The sensors, used in the real window test, sometimes outputs strange data, and sometimes the WCUis reset due probably to some problem with the implemented communication. This results in the rawdata being unsteady. This unsteady behavior also depends on the fact that the sky was randomly cloudyduring the test (see Figure 5.10). Another relevant fact to consider is that the windows on the outsidereflect sunlight to the EC window rendering the data to differ even more form the simulations. It is alsoimportant to note that the controller on this test run did not consider the window and room area, meaningit was actually controlling glare.

6.2 Conclusions

6.2.1 LonWorks vs BACnet

As mentioned before in Section 2.1 and 2.2, LonWorks and BACnet are the most widely used BAS tech-nologies. Two of the largest companies in this area are the TAC AB from Sweden (owned by SchneiderElectric from France) and Siemens AG from Germany. Both companies develop devices for these tech-nologies and also solutions for interoperability between them. Since LonWorks and BACnet are able tointercommunicate through gateways, and both tackle all the items in Section 1.4.1 in some way, decidingwhich technology to use is as simple as deciding which one has the fastest time to market, which relatesto its ease of implementation and leads to a cheaper solution. Since Echelon provides good support forLonWorks, and developers can follow the LonMark guidelines to design interoperable devices, a con-clusion can be drawn that LonWorks provides a faster time to market solution as compared to BACnet,making it the preferred technology.

6.2.2 Advantages of EC Windows

As mentioned before, windows affect indoor light comfort and temperature thus setting a requirementfor architects and building engineers when considering what kind of windows to use depending on whichdirection it is facing (North, South, etc.) and at what latitude it is located. Simulation tools, like the onesprovided by this thesis, can help in the decision.

The energy consumption simulation results, presented in Section 5.1.2, indicate that, in Stockholm, Swe-den, EC windows reduce on average 2.6% of the energy consumption for temperature control in a build-

40

Page 51: Integration of Electrochromic Smart Windows in Building

CHAPTER 6. DISCUSSION AND CONCLUSIONS 6.2. CONCLUSIONS

ing as compared to a high energy efficient regular window. To tackle both energy consumption andindoor comfort, a control algorithm that e.g. weighs the importance of each parameter depending on thesituation, could be added to this system. Then the energy consumption could be even less.

This thesis is a first attempt into automating the windows such as to provide benefit. The purpose is toprovide simulation tools where tests can be made and demonstrate a real implementation; the latter isfar more appealing for consumers. However, more research is required to develop algorithms with morepower efficiency focus, and with the help of the provided simulation tools, this process becomes faster.

6.2.3 Contributions

The model-based PI controller provided by this thesis is superior to a simpler rule-based one as it resultsin a better control performance as well as lower energy consumption. With the help of the developedMatlab and Simulink tools, quantitative evaluations with different parameters can be made and the win-dows can be tuned with relative ease. With a working real implementation of the control in a distributedreal time embedded system, the reader can be sure that the methods provided are true.

41

Page 52: Integration of Electrochromic Smart Windows in Building

CHAPTER 6. DISCUSSION AND CONCLUSIONS 6.2. CONCLUSIONS

42

Page 53: Integration of Electrochromic Smart Windows in Building

CHAPTER 7. FUTURE WORK

7. Future Work

7.1 Integration

In this report, a research is presented on the integration of the windows on building systems. The nextstep would be to implement the ideas.

7.2 Communication Optimizations

As mentioned in Section 6.1.3, there should be a more reliable communication system. Collision avoid-ance (CSMA/CA) would be a good extra reliability fix, due to its simplicity.

The WCU resets itself from time to time when running with the controller, probably due to a commu-nication bug on the master device. The reason to this problem should be found and a fix should bedeveloped.

7.3 Software Optimization

There are probably many possible optimizations to be done to the software. Examples are faster algo-rithms, power management and code size.

7.4 Energy Focused Control Algorithms

A more thorough research on the energy consumption impact of the windows could be realized, andalgorithms developed to this ambition, e.g. temperature control, switching control mode depending onthe time of day and presence of people, connection to weather forecast, artificial intelligence, etc.

43

Page 54: Integration of Electrochromic Smart Windows in Building

CHAPTER 7. FUTURE WORK 7.4. ENERGY FOCUSED CONTROL ALGORITHMS

44

Page 55: Integration of Electrochromic Smart Windows in Building

BIBLIOGRAPHY BIBLIOGRAPHY

Bibliography

Bos, F., Louter, C. & Veer, F. (2008), Challenging Glass: Conference on Architectural and StructuralApplications of Glass, Faculty of Architecture, Delft University of Technology, May 2008, IOS Press.URL: http://books.google.se/books?id=Um1Hj90OQL8C

Derek, T. & Clements-Croome, J. (1997), ‘What do we mean by intelligent buildings?’, Automation inConstruction 6(5 - 6), 395 – 400.

Dürr, H. & Bouas-Laurent, H. (2003), Photochromism: Molecules and Systems: Molecules and Systems,Elsevier Science.URL: http://books.google.se/books?id=i-m3tFfXAngC

Dussault, J.-M., Gosselin, L. & Galstian, T. (2012), ‘Integration of smart windows into building designfor reduction of yearly overall energy consumption and peak loads’, Solar Energy 86(11), 3405 –3416.

Echelon Corporation (1994), ‘Building a LonTalk-to-PLC Gateway - LonWorks Engineering Bulletin’,http://www.echelon.com/support/documentation/bulletin/005-0044-01A.pdf - visited on09/2013.

Echelon Corporation (2009), ‘Neuron C Programmer’s Guide’, http://www.echelon.com/support/documentation/manuals/devtools/078-0002-02H_Neuron_C_Programmers_Guide.pdf - vis-ited on 09/2013.

Hansson, L. (2008), Distributed Building Automation Systems - Implementing the BACnet communica-tion protocol, Master’s thesis, KTH, Machine Design (Dept.).

Hersent, O., Boswarthick, D. & Elloumi, O. (2012), The Internet of Things - Key Applications andProtocols, John Wiley & Sons Ltd.URL: http://www.google.se/books?id=C12WuQAACAAJ

Jonsson, A. & Roos, A. (2010), ‘Evaluation of control strategies for different smart window combinationsusing computer simulations’, Solar Energy 84(1), 1 – 9.URL: http://www.sciencedirect.com/science/article/pii/S0038092X0900262X

Kolokotsa, D., Pouliezos, A., Stavrakakis, G. & Lazos, C. (2009), ‘Predictive control techniquesfor energy and indoor environmental quality management in buildings’, Building and Environment44(9), 1850 – 1863.URL: http://www.sciencedirect.com/science/article/pii/S0360132308002990

LonMark International (2005), ‘LonMark Layer 1-6 Interoperability Guidelines’, https://www.lonmark.org/technical_resources/guidelines/docs/LmPhy34.pdf - visited on 09/2013.

LonMark International (2012), ‘LonMark SNVT and SCPT Master List’, http://www.lonmark.org/technical_resources/resource_files/snvtscpt.pdf - visited on 09/2013.

45

Page 56: Integration of Electrochromic Smart Windows in Building

BIBLIOGRAPHY BIBLIOGRAPHY

Marinakis, V., Doukas, H., Karakosta, C. & Psarras, J. (2013), ‘An integrated system for buildings’energy-efficient automation: Application in the tertiary sector’, Applied Energy 101(0), 6 – 14. Sus-tainable Development of Energy, Water and Environment System.

Monk, P., Mortimer, R. & Rosseinsky, D. (2008), Electrochromism - Fundamentals and Applications,John Wiley & Sons Ltd.

Newman, H. M. (1997), ‘BACnet: Answers to frequently asked questions’, http://www.bacnet.org/Bibliography/HPAC-3-97.pdf - visited on 09/2013.

Niklasson, G. A. & Granqvist, C. G. (2007), ‘Electrochromics for smart windows: thin films of tungstenoxide and nickel oxide, and devices based on these’, J. Mater. Chem. 17, 127 – 156.URL: http://dx.doi.org/10.1039/B612174H

Pinto, A., D’Angelo, M., Fischione, C., Scholte, E. & Sangiovanni-Vincentelli, A. (2008), Synthesis ofembedded networks for building automation and control, in ‘American Control Conference, 2008’,pp. 920 –925.

Strata Resource Inc. (2006), ‘Investigating Open Systems - Comparing LonWorks and BACnet’, http://www.stitcs.com/en/LonWorks/InvestigatingOpenSystems-2006.pdf - visited on 09/2013.Market Report.

Swan, B. (1996), ‘The Language of BACnet-Objects, Properties and Services’, http://www.bacnet.org/Bibliography/ES-7-96/ES-7-96.htm - visited on 09/2013.

Toshiba Corporation (2006), ‘Neuron Chip - TMPN3150/3120’, http://www.semicon.toshiba.co.jp/download/docs_pdf/BDE0156_catalog.pdf - visited on 09/2013.

Wikipedia (2013a), ‘Illuminance — Wikipedia, the free encyclopedia’, http://en.wikipedia.org/wiki/Illuminance - visited on 09/2013.

Wikipedia (2013b), ‘Luminous flux — Wikipedia, the free encyclopedia’, http://en.wikipedia.org/wiki/Luminous_flux - visited on 09/2013.

Wittenmark, B., Åström, K. J. & Årzén, K.-E. (2002), ‘Computer control: An overview’, IFAC Profes-sional Brief .

Woltman, S., Crawford, G. & Jay, G. (2007), Liquid Crystals: Frontiers in Biomedical Applications,World Scientific.URL: http://books.google.se/books?id=-GDbsX4MXbkC

46

Page 57: Integration of Electrochromic Smart Windows in Building

APPENDIX A. PSEUDO-CODE

A. Pseudo-code

Note that since programming languages usually only use positive indexing, the k-values are inverted sothe greater they are, the farther they are in past iterations.

input = desiredLuxSetPoint();a, b = fromMatlabs_c2d();w0, w1, f = tunedParameters();Ts = 2*pi/(20*w0);p0 = -exp(-w0*Ts);p1 = -exp(-w1*Ts);s0 = (a+1+p0+p1)/b;s1 = (p0*p1-a)/b;t0 = (1+p0)/b;Vmax, Vmin = saturationValues();y = 0, 0;u = 0, 0;u_before = 0, 0;r = 0, 0;while (true)

y[1] = y[0];y[0] = measureLux();r[1] = r[0];r[0] = input;u_before[1] = u_before[0];u[1] = u[0];u[0] = u[1]+t0*(r[0]+p1*r[1])-s0*y[0]-s1*y[1]+s1*f*(u[1]-u_before[1]);u_before[0] = u[0];if (u[0] > Vmax)

u[0] = Vmax;else if (u[0] < Vmin)

u[0] = Vmin;setVoltage(u[0]);sleep(Ts);

47