Upload
sinyorakyol
View
33
Download
0
Tags:
Embed Size (px)
Citation preview
T.C.
BAHÇEŞEHİR UNIVERSITY
SMART BUILDING AUTOMATION
Capstone Project
Sezgin Bayram Kaplan
İSTANBUL, 2012
T.C.
BAHÇEŞEHİR UNIVERSITY
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
SMART BUILDING AUTOMATION
Capstone Project
Sezgin Bayram Kaplan
Advisor: Prof. Dr. Emin Tacer
Co-Advisor: Assist. Prof. Zafer Aydın
İSTANBUL, 2012
T.C.
BAHÇEŞEHİR UNIVERSITY FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING
Name of the project: Smart Building Automation
Name/Last Name of the Student: Sezgin Bayram Kaplan
Date of Thesis Defense: 06/01/2012
I hereby state that the graduation project prepared by Sezgin Bayram Kaplan has
been completed under my supervision. I accept this work as a “Graduation Project”.
06/01/2012
Prof. Dr. Emin Tacer
I hereby state that I have examined this graduation project by Sezgin Bayram
Kaplan which is accepted by his supervisor. This work is acceptable as a graduation
project and the student is eligible to take the graduation project examination.
06/01/2012
Assoc. Prof. Çiğdem Eroğlu Erdem
Head of the Department of
Electrical Electronics Engineering
We hereby state that we have held the graduation examination of Sezgin Bayram
Kaplan and agree that the student has satisfied all requirements.
THE EXAMINATION COMMITTEE
Committee Member Signature
1. Prof. Dr. Emin Tacer ………………………..
2. ………………………….. ………………………..
3. ………………………….. ………………………..
ii
ACADEMIC HONESTY PLEDGE
In keeping with Bahçeşehir University Student Code of Conduct, I pledge that this work is
my own and that I have not received inappropriate assistance in its preparation.
I further declare that all resources in print or on the web are explicitly cited.
NAME DATE SIGNATURE
Sezgin Bayram Kaplan 06.01.2012
iii
ABSTRACT
SMART BUILDING AUTOMATION
Sezgin Bayram Kaplan
Faculty of Engineering
Department of Electrical & Electronics Engineering
Advisor: Prof. Dr. Emin Tacer
JANUARY, 2012, 44 pages
Technology is developing rapidly day by day. According to these developments,
people started to want to control and access their buildings and homes from everywhere.
These requests mean, much more energy consuming. If we know, our basic energy sources
are limited, the solution of these requests must supply the energy efficiency. This energy
efficient solution named by “Smart Building Automation” which is also the topic of this
project. This project includes five parts in it. First one is about the definition of the smart
building and major systems that can control in a smart building. Second part is about an
appliance which is controlling a building with a microcontroller, in the second part, the
equipments of the system and basic information about these systems were explained. In the
third part, the hardware of the system was explained with the block diagrams and circuit
schematics. Also in the third part the software algorithms of the devices were given. The
fourth part is about an alternative solution to smart building automation. In the alternative
solution a PLC was choosen as a controller. The reasons of the preffering a microcontroller
to a PLC were explained also in the fourth part. In the fifth part, the next steps of the
project and things that are going to do were explained.
Key Words: Energy efficiency, Smart Building Automation, Microcontroller,
PLC, Algorithm
iv
ÖZET
AKILLI BİNA OTOMASYONU
Sezgin Bayram Kaplan
Mühendislik Fakültesi
Elektrik-Elektronik Mühendisliği Bölümü
Tez Danışmanı: Danışmanın Prof. Dr. Emin Tacer
OCAK, 2012, 44 sayfa
Teknolojinin hızla ilerleyişi ile birlikte insanların yaşadıkları ortamları kontrol etme
ve bu ortamlara bulundukları heryerden erişebilme istekleri de artmıştır. Ancak her yeni
istek daha fazla enerji tüketimi anlamına gelmektedir. Dünyamızın temel enerji
kaynaklarının da sınırlı olduğu düşünüldüğünde, bu ihtiyaçları karşılayan sistemlerin aynı
zamanda enerji verimliliğine de uygun sistemler olması gerekmektedir. Bütün bu
nicelikleri barındıran bina yönetim sistemlerine “Akıllı Bina Otomasyonu” denmektedir.
Akıllı Bina Otomasyonu konulu bu tezin birinci bölümünde, akıllı bina tanımı ve akıllı
binalarda kontrol edilen sistemler hakkında bilgi verilmiştir. İkinci bölümde
mikrokontrolör kullanılarak yapılacak olan akıllı bina sisteminin elemanları tanıtılmış, bu
elemanlar hakkında temel bilgiler verilmiştir. Üçüncü bölümde ise uygulaması yapılacak
olan sistemin donanımı, bu donanımların blok diyagramları ve devre şemaları figürler ile
desteklenerek açıklanmıştır. Ayrıca bu bölümde bu donanımların çalışması için gereken
yazılımların algoritmaları verilmiştir. Dördüncü bölümde, akıllı bina uygulamasına
alternatif olarak PLC ile çalışan bir sistem tanıtılmış, bu sistemin tercih edilmeme
nedenleri açıklanmıştır. Beşinci ve son bölümde ise projenin uygulama aşamasında takip
edilecek süreç açıklanmıştır.
Anahtar Kelimeler: Erişilebilirlik, Akıllı Bina Otomasyonu, Enerji Verimliliği,
Mikrokontrolör, PLC, algoritma.
v
TABLE OF CONTENTS
ABSTRACT .......................................................................................................................... iii
ÖZET .................................................................................................................................... iv
TABLE OF CONTENTS ....................................................................................................... v
LIST OF TABLES ............................................................................................................... vii
LIST OF FIGURES ............................................................................................................ viii
LIST OF ABBREVIATIONS ............................................................................................... ix
1. INTRODUCTION ............................................................................................................. 1
1.0. What is the Smart Building? .................................................................................. 1
1.1. What are the main systems of Smart Buildings? ................................................... 1
1.1.1. HVAC(Heat Ventilating Air Conditioning) Systems ................................... 1
1.1.2. Lighting ......................................................................................................... 2
1.1.3. Security ......................................................................................................... 2
1.1.4. Accessibility .................................................................................................. 2
1.1.5. Energy Management ..................................................................................... 2
1.2. Why Smart Building Automation is Necessary? ................................................... 3
1.2.1. Energy Efficiency ......................................................................................... 3
1.2.2. More Comfortable Buildings ........................................................................ 3
2. APPLIANCE OF SMART BUILDING AUTOMATION ................................................ 4
2.1. General Information About the Project ................................................................. 4
2.2. Determining and Choosing the Main Unit ............................................................. 4
2.2.1. What is a Microcontroller ............................................................................. 4
2.2.2. Characteristics of the ATmega 2560 ............................................................ 5
2.3. Devices to Control ................................................................................................. 5
2.3.1. PIR Motion Sensor ........................................................................................ 6
2.3.2. Temperature Sensor ...................................................................................... 7
2.3.3. PC Fan for Cooling ....................................................................................... 8
2.3.4. Optocoupler .................................................................................................. 8
2.3.5. Pulse Width Modulation (PWM) .................................................................. 9
2.3.5. Dimming of LEDs ...................................................................................... 11
2.4. w5100 Ethernet Chip ........................................................................................... 14
vi
3. HARDWARE AND SOFTWARE .................................................................................. 16
3.1. Basic Running Principle of the System ............................................................... 16
3.2. Microcontroller Board ......................................................................................... 16
3.2.1. Inputs and Outputs of the Board ................................................................. 18
3.2.2. Communication of the Board ...................................................................... 19
3.2.3. Programming of the Board ......................................................................... 19
3.2.4. USB Overcurrent Protection ....................................................................... 20
3.3. Ethernet Board ..................................................................................................... 20
3.3.1. Creating a Web Server ................................................................................ 21
3.4. Connection of the PIR Motion Sensor ................................................................. 23
3.5. Connection of the Temperature Controlled PC Fan ...................................... 24
3.6. LED Dimming ..................................................................................................... 26
3.7. Final Circuit Block Diagram ................................................................................ 28
4. BUILDING AUTOMATION WITH PLC ...................................................................... 29
5. FUTURE WORKS .......................................................................................................... 30
REFERENCES .................................................................................................................... 31
vii
LIST OF TABLES
Table 4-1. Classification of the PLCs .................................................................................. 29
viii
LIST OF FIGURES
Figure 2-1. Pin Configuration of ATmega 2560 ………………………………………5
Figure 2-2. Typical PIR Sensor Configuration ...............................................................6
Figure 2-3. PIR Sensor Module ......................................................................................7
Figure 2-4. Temperature Sensor ......................................................................................8
Figure 2-5. CNY75 type Optocoupler .............................................................................8
Figure 2-6. Three different PWM signals .......................................................................10
Figure 2-7. Electronical Symbol of a LED .....................................................................12
Figure 2-8. Crosssection of a Traditional LED ...............................................................12
Figure 2-9. Different Colours of LEDs ...........................................................................13
Figure2-10. Pin Configuration of the w5100 ..................................................................14
Figure 2-11. Block Diagram of the w5100 .....................................................................15
Figure 3-1. Block Diagram of the Basic System .............................................................16
Figure 3-2. The Circuit Schematic of the Development Board .......................................17
Figure 3-3. Circuit Diagram of the Ethernet Board .........................................................21
Figure 3-4. Pin Configuration of the Ethernet Board .......................................................22
Figure 3-5. Connection of the PIR sensor .........................................................................23
Figure 3-6. Connection of the Optocoupler ......................................................................25
Figure 3-7. Connection of the LED and the Potentiometer ..............................................27
Figure 3-8. Block Diagram of the Final Circuit ................................................................28
ix
LIST OF ABBREVIATIONS
HVAC Heat Ventilating Air Conditioning
GPRS General Pocket Radio Service
SMS Short Message Service
RS232 Recommended Standard 232
RF Radio Frequency
kWh Kilowatt Hour
U.S. United States
PIR Passive Infrared Sensor
PLC Programmable Logic Controller
I/O Inputs and Outputs
CPU Central Processing Unit
CU Control Unit
RISC Reduced Instruction Set Computing
CISC Complex Instruction Set Computing
CMOS Complementary Metal Oxide Semiconductor
SRAM Static Random-Access Memory
EEPROM Electronically Erasable Programmable Read-Only Memory
MHz Mega Hertz
DC Direct Current
AC Alternating Current
Kb Kilobytes
PC Personal Computer
FET Field-Effect Transistor
RPM Revolutions Per Minute
x
PWM Pulse Width Modulation
LED Light Emitting Diode
DSP Digital Signal Processing
GaP Gallium Posphide
GaAs Gallium Arsenide
TCP/IP Transmission Control Protocol / Internet Protocol
UDP User Datagram Protocol
USB Universal Serial Bus
FTDI Future Technology Devices International
UART Universal Asynchronous Receiver/Transmitter
SPI Serial Peripheral Interface Bus
HTTP Hypertext Transfer Protocol
Bps Bits Per Second
$ American Dollar
1
1. INTRODUCTION
According to the developments in the technology, people started to request more
comfortable and more functionable places to live and work. Because of that new building
management systems occured. But these requests and systems mean, much more energy
usage firstly. These systems must be energy saver and use the energy efficiently to make
these requests logical. This problem solved with the term of “Smart Building”. Nowadays,
almost every new building become a smart building.
1.0. What is the Smart Building?
Smart Building means; controlling HVAC, lighting, security, energy management
systems of a building from one station. Also smart building can determine and apply some
scenarios by itself. For example; It can keep the temperature of the building in a specified
range or adjusting the lighting of a building according to specified values and the day light
or it can call automatically the police station or the fire department if a dangerous situation
occurs.
1.1. What are the main systems of Smart Buildings?
There are many controllers in a smart building. These are HVAC controls, lighting
controls, energy management, fire controls, access controls, security and broadcast
controls. All of these controllers can be programmed as working together with other
systems.
1.1.1. HVAC(Heat Ventilating Air Conditioning) Systems
People always wanted to live in suitable places to their body temperatures. If they
could not find a place like that, they tried to heat there. Because of that reason HVAC is
one of the major subjects of the building automation. Also humidity can controlled except
of the temperature with automation. HVAC is system, that can control both humiditiy and
temperature. Controlling the humidity and temperature with an automation system supplies
lower electric consume and always being in optimized places.
2
1.1.2. Lighting
Another major subject for the building automation is lighting, because lighting is
the major electric consumer in the buildings. So the biggest electric consumer of the
buildings must controlled with an automation system. Another point is lower light
intensities can damage on eyes or it can cause performance drops in the business life. This
automation can done with sensors which meter the light intensity of the place. Also these
sensors meter the day light and dim the light according to these values and keep the light
intensity in the specialized range. Another efficiency method is switching off the lights
automatically when there is no human in the room.
1.1.3. Security
Smart buildings decrease the risk of fire, thievery and gas leakage. System does
these controls with the inputs of the sensors which putted the necessary areas in the
building.
Security systems have a control panel. All of these sensors are connected to this
panel and if the one of the sensors detects any danger it sends signal to the panel. Then
control panel notices the situation to the related departments and records these events.
1.1.4. Accessibility
Smart building automation systems have high accessibilities. People can command,
check and watch their buildings on web or on smart phones. These accessibility may
increase the discipline of the staff.
There are also some other protocol types to access the system; GPRS, SMS,
Ethernet, RF, RS232.
1.1.5. Energy Management
In the smart buildings energy management does these jobs; peak demand
monitoring, current detection, network monitoring, load shedding, metering and
visualisation. The main purpose of the energy management is decreasing the maintanence
fees and with the monitoring, overcurrent faults can detect momentarily.
3
1.2. Why Smart Building Automation is Necessary?
A smart building, not only improves security and event response time, but also
energy efficiency and saves cost. If we look at the major issues of companies; electric bills
and maintenance fees stated at the first lines. Smart building automation also helps in
saving energy and it helps to make our planet more green.
1.2.1. Energy Efficiency
We have to use our energy sources economically. Because if the world continue to
growing with these rates, our energy sources may become deficient to us.
“Energy efficiency is one of the most underrated sources of energy. Similar to the
well known phrase “a penny saved is a penny earned,” energy saved is energy created. In
1974 refrigerator/freezer efficiency was a growing concern as almost every home had one.
In 2001, it was estimated that there were about 150 million refrigerator/freezers in the
United stetes. If all of the 1974 models were replaced with 2001 models, the energy
efficiency each year would save over 200 billion kWh of energy. To put that number into
perspective, this generates more energy than double the energy produced by renewable
energies in the U.S.” [1]
1.2.2. More Comfortable Buildings
Comfort level of the smart building can design according to requests of the
consumer. The main purpose to increase the comfort level is doing some processes with
automation which are waste of time for people. Also consumers can personalize their
automation system by adding new scenarios onto the system. There are some processes
that there must be a person to do this processes, but with an automation system you can
control your processes online or with your smart phone from everywhere. For example; if
you have a smart home, when you wake up, you can have a hot coffee or if you forgot to
close any electronic device you can close them on your smart phone.
4
2. APPLIANCE OF SMART BUILDING AUTOMATION
2.1. General Information About the Project
Briefly, this project is about controlling a building on a website. This project
includes; led dimming for lighting, PIR motion sensor for security and a temperature
sensor controlled fan unit for HVAC systems and an ethernet board and a modem to
display and control these devices on a website. The main purpose of the controlling the
building on internet is; increase the accessibility of the project.
2.2. Determining and Choosing the Main Unit
Building automation can be done with various equipments and systems. There are
two mainly solutions to automation; PLCs(programmable logic circuits) and
microcontrollers. In this project; a microcontroller choosed as processor.
2.2.1. What is a Microcontroller
Microcontrollers are microcomputers that combines; a microprocessor, data and
program memory, digital inputs and outputs(I/O), analog inputs and etc.(circuit breakers,
counters, analog to digital converters...) on a single silicone chip.
The simplest microcontroller includes; a microprocessor, a memory, an input and
an output. The microprocessor unit includes CPU(Central Processing Unit) and
CU(Control Unit). CPU does the arithmetical and logical processes. CU controls the
internal processes of CPU and sends signals to the other sections to do requesting
commands.
There are two necessary things to program a microcontroller. One of them is a
circuit to structure of the microcontroller, the other one is a software to transfer the
prepared codes to microcontroller.
Microcontrollers seperated into two groups by their structures. These are;
RISC(Reduced Instruction Set Computer) and CISC(Complex Instruction Set Computer).
5
2.2.2. Characteristics of the ATmega 2560
The ATmega 2560 that produced by ATMEL choosed as a microcontroller to this
project. It is a low-power CMOS 8-bit type. It based on the AVR enhanced RISC
architecture. It has 54 digital input/output pins. 14 of these pins can be used as Pulse Width
Modulation outputs, 16 analog inputs on it. Pin configuration of the ATmega 2560 can
seen in the Figure 2-1:
Figure 2-1. Pin configuration of the ATmega 2560
The ATmega has 256 kb of flash memory to store the codes and 8 kb of it used for
bootloader. It has a 8 kb SRAM and 4 kb EEPROM. The producer recommends 7-12 DC
voltage to this microcontroller. Its clock frequency is 0-16 MHz.
One of the major causes to select this microcontroller is; its easy usage and simple
programming. [2]
2.3. Devices to Control
In this project, several devices will control and metering from one center. These
devices are; motion sensor, PC fan, led lightings and temperature sensor.
6
2.3.1. PIR Motion Sensor
In this project PIR(Passive Infra Red) motion sensor used for the security part.
PIR sensors can detect whether a human has moved in or moved out of the sensor’s
range. These sensors are not expensive, they use low-power. They are generally used in
home and business.
PIR sensors basically includes a pyroelectric sensor, which can detect the infrared
radiation level. The pyroelectric sensor is made of a crystalline material that generates a
surface electric charge when exposed to heat in front of sensor. When the amount of
radiation striking the crystal changes, the amount of charge also changes and can then be
measured with a sensitive FET device built into the sensor. The sensor elements are
sensitive to radiation over a wide range.
Typically, the FET source terminal pin 2 connects through a pulldown resistor of
about 100 K to ground and feeds into a two stage amplifier having signal conditioning
circuits. The amplifier is typically bandwidth limited to below 10Hz to reject high
frequency noise and is followed by a window comparator that responds to both the positive
and negative transitions of the sensor output signal. A well filtered power source of from 3
to 15 volts should be connected to the FET drain terminal pin 1. An example to typical
configuration of PIR sensors shown in the Figure 2-2:
Figure 2-2. Typical PIR Sensor Configuration
The PIR sensor has two sensing elements connected in a voltage jump
configuration. This arrangement cancels signals caused by vibration, temperature changes
and sunlight. A body passing in front of the sensor will activate first one and then the other
element whereas other sources will affect both elements simultaneously and be cancelled.
7
The radiation source must pass across the sensor in a horizontal direction when
sensor pins 1 and 2 are on a horizontal plane so that the elements are sequentially exposed
to the IR source.
An example figure of a PIR sensor shown in Figure 2-3:
Figure 2-3. PIR Sensor Module
2.3.2. Temperature Sensor
In this project temperature sensor used to measure the temperature of the building.
These sensors use a solid-state technique to determine the temperature. Instead,
they use the fact as temperature increases, the voltage across a diode increases at a known
rate. Technically, this is actually the voltage drop between the base and emitter - the Vbe -
of a transistor. By precisely amplifying the voltage change, it is easy to genereate an
analog signal that is directly proportional to temperature. There have been some
improvements on the technique but, essentially that is how temperature is measured.
Because, this sensor has not got moving parts, they are precise, never wear out,
don't need calibration, work under many environmental conditions, and are consistant
between sensors and readings. Also they are very inexpensive and quite easy to use.
There is an example picture to temperature sensor in the Figure 2-4 below:
8
Figure 2-4. Temperature Sensor
2.3.3. PC Fan for Cooling
This device is using almost every PC to cooling. This project used it as a cooler too.
It runs with 12 V DC. So there must be an extra circuit or optocoupler between the
microcontroller and the PC fan. In this project fan will run when the building’s temperature
passes the specified value and it stop when the building is in the optimized values.
The RPM control of the Fan is doing with the Pulse Width Modulation. We have
PWM pins on our microcontroller.
2.3.4. Optocoupler
Optocoupler includes a LED and a phototransistor inside it. The phototransistor
switches on or conducts current when the internal LED switched on. The brighter the
internal LED the more current can pass through the phototransistor. The LED and
phototransistor are physically isolated from each other. This physical isolation protects the
input side (the LED) from voltage spikes on the output side (phototransistor) and can
provide the voltage translation. An example to an optocoupler is shown in Figure 2-5:
Figure 2-5. CNY75 type Optocoupler
9
2.3.5. Pulse Width Modulation (PWM)
Pulse width modulation is one of the powerful method to control analog circuits
with a microcontroller’s digital outputs. Now, PWM is used in various aplications, ranging
from communications and measurement to power control and conversion.
A basic analog signal has a continuosly varying value, with infinite resolution in
both magnitude and time. A simple battery (1.5 V) is an example of an analog device, in
that its output voltage is not certainly 1.5 V, it changes over time and can take any real
number value. Briefly, the amount of the current drawn from a battery is not limited to a
finite set possible values. Analog signals differ from digital signals because digital signals
always take values only from a finite set of predetermined possibilities as 0 to 5 V.
Analog voltages and currents used for controlling devices directly, for example
adjusting the volume of a radio. In a simple radio increasing and decreasing the volume
done by a potentiometer. It means rotating the button means increasing or decreasing the
current.
By controlling analog circuits digitally, system costs and power consumption can
be visible reduced. Also, many microcontrollers and DSPs already include on-chip PWM
controllers, making implementation easy.
To put in a nutshell, PWM is a way of digitally encoding analog signal levels.
Through the use of high-resolution counters, the duty cycle of a square wave is modulated
to encode a specific analog signal level. The PWM signal is still digital because, at any
given certain time, the full DC supply is either fully on or fully off. The voltage or current
source is supplied to the analog load by means of a repeating series of on and off pulses.
The on time is the time during which the DC supply is applied to the load, and the off time
is the period during which that supply is switched off. Given a sufficient bandwidth, any
analog value can be encoded with PWM.
There is a graph in Figure 2-6 about three different PWM signals. First signal PWM
output is %10 duty cylce. It means; the signal works %10 of the period so if our input is
1.5 V our output is 0.15 V. Second and third one is %50 and %90 duty cycle, respectively.
These three PWM outputs encode three different analog signal values at %10, %50 and
%90 of the full power.
10
Figure 2-6. Three different PWM signals
Many microcontrollers include on-chip PWM controllers. For example, Atmel's ATmega
2560 includes 14 pins, each of which has a selectable on-time and period. The duty cycle is
the ratio of the on-time to the period; the modulating frequency is the inverse of the period.
To start PWM operation, the data sheet suggests the software should:
Set the period in the on-chip timer/counter that provides the modulating square
wave
Set the on-time in the PWM control register
Set the direction of the PWM output, which is one of the general-purpose I/O pins
Start the timer
Enable the PWM controller
One of the advantages of PWM is that the signal remains digital all the way from
the processor to the controlled system; no need to any digital-to-analog conversion. By
keeping the signal digital, noise effects are minimized. Noise can only affect a digital
signal if it is strong enough to change a logic 1 to a logic 0.
Increased noise immunity is the another benefit of choosing PWM over analog
control, and is the principal reason PWM is sometimes used for communication. Switching
from an analog signal to PWM can increase the length of a communications channel
dramatically. At the receiving end, a suitable RC (resistor-capacitor) or LC (inductor-
capacitor) network can remove the modulating high frequency square wave and return the
signal to analog form.
PWM finds application in a variety of systems. As a concrete example, consider a
PWM controlled brake. To put it simply, a brake is a device that clamps down hard on
something. In many brakes, the amount of stopping power is controlled with an analog
input signal. The more voltage or current that's applied to the brake, the more pressure the
brake will exert.
11
The output of a PWM controller could be connected to a switch between the supply
and the brake. To produce more stopping power, the software need only increase the duty
cycle of the PWM output. If a specific amount of braking pressure is desired,
measurements would need to be taken to determine the mathematical relationship between
duty cycle and pressure. [3]
Pulse-width modulation uses a rectangular pulse wave whose pulse width is
modulated resulting in the variation of the average value of the waveform. If we consider a
pulse waveform f(t) with a low value y-min, a high value y-max and a duty cycle D, the
average value of the waveform is given by:
(2.1.)
As f(t) is a pulse wave, its value is ymax for and ymin for
. The above expression then becomes:
(2.2.)
This latter expression can be fairly simplified in many cases where y-min = 0 as
(2.3.). From this, it is obvious that the average value of the signal ( ) is
directly dependent on the duty cycle D. [4]
2.3.5. Dimming of LEDs
Dimming of LEDs is doing with PWM technique too.
A Light-Emitting Diode (LED) is basicly includes P-N junction solid-state
semiconductor diode that emits light when a current is applied through the diode. Its
scientific definition is, it is a solid-state device that controls current without the deficiency
of having heated filaments. In the Figure 2-7 electronical symbol of a LED shown:
12
Figure 2-7. Electronical Symbol of a LED
There is a crosssection of a traditional LED in Figure 2-8. Traditional indicator
LEDs utilize a small LED semiconductor chip that is mounted on a reflector cup also
known as the anvil, on a lead-frame. This whole configuration is encased in epoxy which
also serves the purpose of a lens. LEDs have very high thermal resistance with upwards of
200K per Watt.
Figure 2-8. Crosssection of a Traditional LED
LEDs are highly monochromatic, only emitting a single pure color in a narrow
frequency range. The color emitted from an LED is identified by peak wavelength which is
measured in nanometers . The peak wavelength is a function of the material that is used in
the manufacturing of the semiconductor. Most LEDs are produced using gallium-based
crystals that differ in one or more additional materials such as phosphorous to produce
distinct colors. Different LED chip technologies enable manufacturers to produce LEDs
that emit light in a specific region of the visible light spectrum and replicate different
intensity levels. Thus, one would vary the material used in the production of LEDs in order
to obtain the desired results. [5]
13
Different colours of LEDs shown in the Figure 2-9:
Figure 2-9. Different Colours of LEDs
The term diode means, the twin-terminal structure of the light-emitting device. In a
flashlight, for example, a wire filament is connected to a battery through two terminals,
one (the anode) presents the negative electric charge and the other (the cathode) presents
the positive charge. In LEDs, as in other semiconductor devices such as transistors, the
“terminals” are actually two semiconductor materials of different composition and
electronic properties brought together to form a junction. In one material (the negative, or
n-type, semiconductor) the charge carriers are electrons, and in the other (the positive, or
p-type, semiconductor) the charge carriers “holes” created by the absence of electrons.
Under the influence of an electric field, current can be made to flow across the p-n
junction, providing the electronic excitation that causes the material to luminesce.
In a typical LED structure the clear epoxy dome serves as a structural element to
hold the lead frame together, as a lens to focus the light, and as a refractive index match to
permit more light to escape from the chip. The LED chip, typically 250 × 250 × 250
micrometres in dimension, is mounted in a reflecting cup formed in the lead frame. The p-
n type GaP:N layers represent nitrogen added to gallium phosphide to give green emission,
the p-n type GaAsP:N layers represent nitrogen added to gallium arsenide phosphide to
give orange and yellow emission, and the p-type GaP:Zn,O layer represents zinc and
oxygen added to gallium phosphide to give red emission.
14
Two further enhancements, developed in the 1990s, are LEDs based on aluminum
gallium indium phosphide, which emit light efficiently from green to red-orange, and also
blue-emitting LEDs based on silicon carbide or gallium nitride. Blue LEDs can be
combined on a cluster with other LEDs to give all colours, including white, for full-colour
moving displays. [6]
2.4. w5100 Ethernet Chip
The W5100 is a full-featured, single-chip Internet-enabled 10/100 Ethernet
controller designed for embedded applications where ease of integration, stability,
performance, area and system cost control are required. The W5100 has been designed to
facilitate easy implementation of Internet connectivity without OS.
There is a pinout figure of the w5100 in the Figure 2-10:
Figure 2-10. Pin Configuration of the w5100
The W5100 includes TCP/IP stack and integrated Ethernet MAC. Hardwired
TCP/IP stack supports TCP, UDP which has been proven in various applications for
several years. 16 kb internal buffer is included for data transmission. No need of
consideration for handling Ethernet Controller, but simple socket programming is
required. [7]
15
There is also a block diagram for w5100 in the Figure 2-11:
Figure 2-11. Block Diagram of the w5100
16
3. HARDWARE AND SOFTWARE
Styles define the appearance of various text elements in your document, such as
headings, captions, and body text. When you apply a style to a paragraph or word, you can
apply a whole group of character or paragraph formats or both in one simple operation.
When you want to change the formatting of all the text of a particular element at once, you
just change the style that's applied to that element. Styles make formatting your document
easier. Additionally, they serve as building blocks for outlines and tables of contents.
3.1. Basic Running Principle of the System
System basicly works as these principles; microcontroller takes inputs from
sensors, then it send its commands to output devices according to the input values.
There is a block diagram of the basic system in the Figure 3-1:
Figure 3-1. Block Diagram of the Basic System
3.2. Microcontroller Board
Every microcontroller needs auxiliary equipments to take the codes from a
computer. Also this board must include; power supply entrance, connection port to
computer, oscillator and protective equipments to overcurrent. So a development board
choosen as this project which shown in the Figure 3-2:
17
Figure 3-2. The Circuit Schematic of the Development Board
This board can be powered via the USB connection or with an external power
supply. The power source is selected automatically.
External power can come either from an AC-to-DC adapter (wall-wart) or battery.
The adapter can be connected by plugging a 2.1mm center-positive plug into the board's
power jack. Leads from a battery can be inserted in the ground and the power supply pin.
18
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage the
board. The recommended range is 7 to 12 volts.
The Mega2560 differs from all preceding boards in that it does not use the FTDI
USB-to-serial driver chip. Instead, it features the ATmega8U2 programmed as a USB-to-
serial converter.
The power pins are as follows:
VIN; The input voltage to the board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source).
5V; The regulated power supply used to power the microcontroller and other
components on the board. This can come either from VIN via an on-board
regulator, or be supplied by USB or another regulated 5V supply.
3V3; A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
GND; Ground pins. [8]
3.2.1. Inputs and Outputs of the Board
Each of the 54 digital pins on the microcontroller can be used as an input or output,
using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each
pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor
(disconnected by default) of 20-50 kOhms. In addition, some pins have specialized
functions:
“Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and
16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX)
TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the
ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4),
20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
19
PWM: 0 to 13. Provide 8-bit PWM output with the analogWrite() function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI
communication using the SPI library. The SPI pins are also broken out on the ICSP
header.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
TWI: 20 (SDA) and 21 (SCL). Support TWI communication using the Wire library.
The Mega2560 has 16 analog inputs, each of which provide 10 bits of resolution
(i.e. 1024 different values). By default they measure from ground to 5 volts, though
is it possible to change the upper end of their range using the AREF pin and
analogReference() function.
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller.” [9]
3.2.2. Communication of the Board
“The Arduino Mega2560 has a number of facilities for communicating with a
computer, or other microcontrollers. The ATmega2560 provides four hardware UARTs for
TTL (5V) serial communication. An ATmega8U2 on the board channels one of these over
USB and provides a virtual com port to software on the computer.
A SoftwareSerial library allows for serial communication on any digital pins of the
ATmega 2560.
The ATmega2560 also supports TWI and SPI communication. The development
software includes a Wire library to simplify use of the TWI bus.” [10]
3.2.3. Programming of the Board
The boad can be programmed with the Arduino software.
The board comes preburned with a bootloader that allow us to upload new code to
it without the use of an external hardware programmer. It communicates using the original
STK500 protocol. [11]
20
3.2.4. USB Overcurrent Protection
The board has a resettable polyfuse that protects our computer's USB ports from
shorts and overcurrent. Although most computers provide their own internal protection, the
fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port,
the fuse will automatically break the connection until the short or overload is removed.
[12]
3.3. Ethernet Board
Ethernet board used to transfer the datas on the web. It helps us to use our circuits
like a webserver. It uses TCP/IP stacks.
Ethernet board allows microcontroller board to connect to the internet. It is based
on the Wiznet w5100 ethernet chip. The Wiznet w5100 provides a network (IP) stack
capable of both TCP and UDP. It supports up to four simultaneous socket connections.
This chip can not use single, it needs some auxiliary equipments to run. So there is
need to an ethernet board. [13]
21
There is a circuit diagram of the ethernet board in Figure 3-3:
Figure 3-3. Circuit Diagram of the Ethernet Board
3.3.1. Creating a Web Server
This algorithm to use the microcontroller circuit as a webserver. The ethernet board
should be connected to a network with an ethernet cable. There are some changes in the
network settings in the program to correspond to the network. Before the algorithm,
connections of the ethernet board and main board explained below:
Ethernet board attached to pins 10, 11, 12, 13(SS, MOSI, MISO, SCK) and analog
inputs attached to pins A0 through A5. [14]
22
The pin configuration of the ethernet board shown in Figure 3-4.
Figure 3-4. Pin Configuration of the Ethernet Board
Algorithm of the webserver:
Enter a MAC address and IP address for the controller below.
The IP address will be dependent on the local network
Initialize the Ethernet server library with the IP address and port that want to use
(port 80 is default for HTTP)
Start the Ethernet connection and the server
Listen for incoming clients
An http request ends with a blank line
If you've gotten to the end of the line (received a newline character) and the line is
blank, the http request has ended, so you can send a reply
Send a standard http response header
23
Output the value of each analog input pin
Starting a new line
You've gotten a character on the current line
Give the web browser time to receive the data
Close the connection
3.4. Connection of the PIR Motion Sensor
In this project, the PIR sensor connected on a LED and then to the main board.
Also a buzzer can replaced with LED. This LED will switched on when sensor detects any
motion. If there is a buzzer, it will sound to warn.
Connection of the PIR sensor on the board explained below, also there is a
schematic display of the connection in the Figure 3-5.
PIR sensor has three connection wire; first one is wired to any digital input on the
board, second one is connected to 5V power supply pin, last one is wired to the ground.
Figure 3-5. Connection of the PIR sensor
24
Algorithm of the PIR sensor:
The time we give the sensor to calibrate(10-60 secs)
The time when the sensor outputs a low impulse
The amount of milliseconds the sensor has to be low before we assume all motion
has stopped
The digital pin connected to the PIR sensor's output
Give the sensor some time to calibrate
Makes sure we wait for a transition to LOW before any further output is made
The led visualizes the sensors output pin state
Save the time of the transition from high to LOW
Make sure this is only done at the start of a LOW phase
If the sensor is low for more than the given pause, (we assume that no more motion
is going to happen)
Makes sure this block of code is only executed again after a new motion sequence
has been detected
Output
3.5. Connection of the Temperature Controlled PC Fan
The goal of these devices is to keep the building in specified temperature ranges.
Temperature sensor meters the temperature, then sends it to microcontroller,
microcontroller send signal to the PC Fan to run or not according to the input values.
Controlling a PC Fan that requires 12V from the microcontroller without frying it.
The microcontroller board is a 5V device and can not directly drive a 12V device such as a
PC fan. There are many possible solutions, but in this project the CNY75 optocoupler used
to separate the two voltages. When the LED that in the optocoupler is activated from the
5V Main Board, the phototransistor will turn on and pass current for the 12VDC fan. The
isolation provided by the optocoupler keeps the Main Board is safe from destruction.
The optocoupler’s internal transistor does not have sufficient current capacities to
drive a DC motor (like our FAN) directly. To boost the current a BD137 transistor used
which can drive up to 1.5 Amperes. This power transistor is sufficient for controlling PC
Fan motors. The PC Fan running current is approximately 300 mA.
25
To control the fan speed we could reduce the drive voltage to the motor. This would
be harder to do and could reduce the motor torque. PWM (Pulse Width Modulation) is
easier with the ATmega 2560 and is basically like turning the motor on and off very
quickly. We are turning on and off the LED inside the optocoupler which is turning on and
off the transistor in the optocoupler which is in turn controlling the power transistor which
is turning on and off the Fan motor. The longer the motor is on, the fast it will spin. The
cycle time (off to on) is very short, that you will not hear it occurring. Actually it occurs
so fast that the fan averages the on and off times to run at a nearly constant speed.
The connection of the optocoupler is shown in Figure 3-6:
Figure 3-6. Connection of the Optocoupler
The Main Board has several analog inputs which are converted into a 10-bit digital
number. The function to read the analog pin is the anologRead(Y) function. The number
will be 0 if the input voltage is 0 volts and will increase with voltage to 1024 when the
input pin is at 5V. So to get the voltage at the analog input we would use the following
formula. ‘Y’ means the correct analog input for the analogRead(X) function call.
Voltage = analogRead(Y)*5.0/1024.0 This formula gives us the correct voltage
value.
26
The LM35(temperature sensor that used in this project) is a popular and
inexpensive temperature sensor. It provides an output voltage of 10.0mV for each degree C
of temperature from a reference voltage. We can read this voltage with one of the analog
inputs. So the output pin would be at 0V when the temperature is 0 degrees C and would
raise to 1000mV or 1.0V at 100 degrees C. So to get temperature we would multiply the
voltage by 100. For example if the voltage is 0.50V that would be 50 degrees C. The
voltage and temperature conversion math can be combined to give the simple formula
below.
Temperature = ( 5.0 * analogRead(X) * 100.0) / 1024.0
The board connection of the LM35 temperature sensor is explained below:
LM35 temperature sensor has three wires; first one is to the power source, second
one is to the ground and the last one is wired to the on of the analog inputs of the main
board.
Here is the algorithm of the temperature sensor:
Declare variables
Open serial port, set data rate to 9600 bps
Read the value from the sensor
Convert the analog data to temperature
Send the data to the computer
Wait one second before sending new value[eleman]
3.6. LED Dimming
Dimming of the led done with a potentiometer. Also a resistor must wired to LED
to control the current.
The connections of the led and the potentiometer explained below and illustrated in
the Figure 3-7.
Potentiometer has three wire, first one is ground, second one is wired to analog
input of microcontroller board and last one is wired to 5V power supply.
27
Figure 3-7. Connection of the LED and the Potentiometer
Algorithm of the process:
Select the input pin for the potentiometer
Select the pin for the LED
Variable to store the value coming from the sensor
Declare the ledPin as an OUTPUT
For debugging via the Serial Monitor
Read the value from the sensor
Scale it to use it with the LED
Set brightness
28
3.7. Final Circuit Block Diagram
Finally, the whole building will controlled from one station(web). The final
circuit’s block diagram is shown in the Figure 3-8:
Figure 3-8. Block Diagram of the Final Circuit
29
4. BUILDING AUTOMATION WITH PLC
There are many solutions and systems to control a building. Commonly used types
are; automation with microcontrollers and automation with PLCs. Microcontrollers used
for small and medium size solutions. PLCs are for more complicated and large sized
solutions.
PLC(Programmable Logic Cirucits) are devices which typically contain a variable
number of inputs/outputs (I/O) ports and usually employ reduced instruction set computing
(RISC). PLCs are designed for real-time use, and they can work under hard conditions
such as excessive vibration and high noise levels. The programmable logic controller
circuits monitors the status of multiple sensor inputs, which control output actuators such
as motor starters, solenoids, lights, displays and valves.
PLCs are seperated into five groups by their input/output range as shown in the
Table 4.1:
Table 4-1. Classification of the PLCs
PLC I/O Range
Micro 0-32
Small 32-128
Medium 64-1024
Large 512-4096
Very Large 2048-8192
Similar version of the project can be done with a PLC. It can control every system
in the project. But PLC using may become ineffective in some ways. First of all main PLC
controllers start from $350 so if we add the other prices the whole project may become
higher than $1k. Another reason is microcontroller’s customization is easier than a PLC..
And microcontroller that used in project is a open sourced type, so accessibility of the
sources much more than a PLC. For that reasons using a microcontroller more suitable for
this project instead of a PLC. We can list the advantages of microcontrollers to PLC as
below:
Economical reasons
Customization options
Amount of sources
30
5. FUTURE WORKS
In the next semester, the equipments will be combined and wired, software of them
will be tested individually for the devices, whole code will be tested on the hardware. If
there is a fault on a code or a device, fault will be solved. Finally, circuit will be tested on
the website. If everything goes well and project finish before the deadline, some
improvements will be done on the system. For example; if PIR sensor detects a motion it
sends e-mail to specified address. And maybe AC light dimming and control it from web
can be add to system.
31
REFERENCES
[1] Iwahashi, G. (2011, September). “What is Energy Efficiency?” . Retrieved 24 October,
2011, from http://www.greeniacs.com/GreeniacsArticles/Energy/What-is-Energy
-Efficiency.html
[2] ATMEL Corporation. (2011, May). ATmega640/V-ATmega1280/V-ATmega1281/V-
ATmega2560/V-ATmega2561/V Preliminary Datasheet - 2549N–AVR–05/11. Retrieved
25 December, 2011, from http://www.atmel.com/dyn/resources/ prod_documents/
doc2549.pdf
[3] M. Barr, "Pulse Width Modulation", Embedded Systems Programming, 2001, pp. 103-
104
[4] Goldberg, Sam. (2006, November). “Pulse Width Modulation”, Radar Spoofer, pp 50-
51
[5] Seling, Duan Kelvin, “Light Emitting Diodes”, An Analysis on construction, material,
uses and socioeconomic impact, December, 2002, pp 4-7
[6] Light-emitting diode (LED) 2012. Encyclopædia Britannica Online. Retrieved 02
January, 2012, from http://www.britannica.com/EBchecked/topic/340594/light-emitting-
diode
[7] WIZnet Corporation. (2008). WIZnet w5100 Datasheet. Retrieved 03 January, 2012,
from http://mct.de/download/wiznet/w5100.pdf
[8], [9], [10], [11], [12] Arduino Team (2011). Arduino Mega Datasheet. Retrieved 23
December, 2011, from http://arduino.cc/en/Main/ArduinoBoardMega2560
[13], [14] Arduino Team (2011). Arduino Ethernet Shield Datasheet. Retrieved 02 January,
2012, from http://arduino.cc/en/Main/ArduinoEthernetShield