A Microcontroller Based Embedded System
A Microcontroller Based Embedded System
II. RELATED WORK means. The end result of all of these efforts is that
an intelligent building is not just one thing.
1. Adewale A. A., Isaac Samuel, Awelewa A. A.
and Dike U. Ike proposed the “Design and There are a multitude of definitions with different
Development of a Microcontroller Based Automatic levels of detail and varying degrees of emphasis on
Switch for Home Appliances”. In this paper, the various aspects of building intelligence. The first
design and implementation of 2 devices where definition, coined by the Intelligent Buildings
explored. One was a device which helps detect the Institute, defines an intelligent building as „one
presence or movement of persons in a room, so as which provides a productive and cost-effective
to switch ON the light (240V) if this condition is environment through optimization of four basic
true and OFF if false. The other device was used to elements: structure, systems, services and
turn ON or OFF the fan in the room based on a management, and the interrelationship between
certain preset temperature of the room and also iff a them‟. According to this initial definition, an
presence or movement is detected [1]. intelligent building is one that optimally matches
these four elements to the users‟ needs with an
2. Poonam Lakra and Dr. R. P. Gupta proposed the emphasis on the technology that makes the
design of a "Microcontroller Based Automatic interrelationship between the elements possible. [3]
Control Home Appliances". The paper presented the
Automatic control of home appliances including Other sources term building automation to be the
Room Light and Fan Controller Using automatic centralized control of a building's
Microcontroller AT89C51, a reliable circuit that heating, ventilation and air conditioning, lighting
takes over the task of controlling the room fan and and other systems through a Building Management
room lights as well as counting number of persons / System or Building Automation System (BAS). The
visitors in the room very accurately .When objectives of building automation are improved
somebody enters into the room then the counter is occupant comfort, efficient operation of building
incremented by one and the light in the room will be systems, and reduction in energy consumption and
switched ON and when any one leaves the room operating costs [4]. Although there are multiple and
then the counter is decremented by one. The speed evolving perspectives on all these subjects, it is
control of fan will depend on PWM signal. It becoming increasingly clear that an intelligent
contain temperature sensor that can sense the building is a connected and efficient building which
temperature & gives the control commands for proffers easy management to the house/building
microcontroller .Then microcontroller increases as owner
well as decreases the speed of the fan.. The total
number of persons inside the room is also displayed The origins of Intelligent Buildings and Building
on the liquid crystal display. The microcontroller Management Systems have roots in the industrial
does the above job. The main objective of control is sector in the 1970's, from the systems and controls
to get the desired output and in energy conservation used to automate production processes and to
[2]. optimize plant performances.
1. Time-based Control: This method provides 3. Motion Based Control: This method
heating, lighting, etc services, given provides services given preferences to the
preferences to the time due motion actions
2. Temperature & Humidity - based Control: 4. Optimizer Parameter based: This is more of
This method provides heating or cooling a general category representing services
services given preferences to the offered based on key parameters set. E.g
temperature or humidity level Security key codes for safe door openings or
sophisticated gadget switching ON and OFF
IV. METHODOLOGY
A major phase of interactivity in this module is interaction is the adjudging parameter used by the
between the thermometer (LM35) and the ADC MCU for the switch on/off decision.
terminal of the MCU. The data derived from this
1. Power Supply thermometer and the MCU‟s set control buttons. In the
The module requires two 12V DC Source (for the 12- case of the 12V DC supply, the 240V, 50Hz AC signal
volt relays) and a number of other 5V DC supplies to is stepped down through a transformer and rectified
power components such as the MCU, LCD, using a bridge rectifier. The 220uF electrolytic
capacitor stabilizes the output of the rectifier circuit as iv. Decide the switching on and off of the air
the7812 regulator regulates the rectified voltage to 12V cooling and conditioning systems by
DC (max). The combination of the Zener and regulator comparing the instantaneous temperature
makes sure the output does not exceed 12V. Capacitor with the switch on and off temperature
C2 helps to protect the regulator from excessive voltage parameters provided by the user
demand by the load. v. Electrically triggers the switching on and
off of the air cooling and conditioning
2. Thermometer Reading stems in the home after making the
The thermometer, an LM35 module, passes an analogue decision in „iv‟ above
signal proportional to its temperature reading into the vi. Send display data to the interfacing LCD
MCU. The MCU converts this analogue value into The MCU uses an interrupt system to ensure that the
digital values using its ADC channel, sends it to the user can at any instance of time change the switch on
LCD for display and also uses it for the switching and off temperature parameters. This is enabled by the
trigger decision making. connection of a 5V source through a press button to the
interrupt pin (INT0) of the MCU. Once the button is
pressed, the interrupt routine is triggered, thereby
calling the setup display screen.
Interrupts form the basis for separating the time-critical
events from the others and execute them in a prioritized
manner. An interrupt tells the microcontroller to drop
whatever it is doing and execute another program stored
at a predefined place in the program memory. Interrupt
requests are asynchronous, which means that an
interrupt request can occur at any time during the
execution of a program. Note that a microcontroller has
Fig 3. Image of the LM35 Module [6] several sources of interrupts which can be external or
internal.
3. MCU Control System
The Microcontroller (PIC18F4550) which is a single
chip computer, serves technically as the brain of the
system. Synonymous to its name is its function.
Microcontrollers are used to execute simple and not so
complex task within a system. A close relative of these
are the microprocessors which are far more
sophisticated and can execute numerous operations,
simultaneously (such as you have in our modern day
desktop computers). A microcontroller is also called an Fig. 4. Schematic of the PIC18F4550 MCU [7]
embedded controller because the microcontroller and its
support circuits are often built into or embedded in the The analogue temperature reading is converted and
devices they control. In this system, it is programmed interpreted by the MCU using the Analogue to Digital
to: Conversion Channels. Details of this is explained in the
section below
i. Read the instantaneous temperature value
from the thermometer
ii. Request, read and store the Fan switch on 3.1. Digital Nature of the MCU and
and switch off temperature Resolution
iii. Request, read and store the AC switch on MCUs are digital in nature. They can only differentiate
and switch off temperatures between HIGH or LOW level on input pins. For
example if input is more than 2.5V it will be read as 1
and if it is below 2.5 then it will be read as 0 (in case of The reference voltage specifies the minimum and
5v systems). So we cannot measure voltage directly maximum voltage range of analogue input. For example
from MCUs. To solve this problem most modern if the input signal Vref- is applied to an analogue input
MCUs have an Analogue to Digital Converter (ADC) channel then the result of conversion will be 0 and if
unit. This helps in converting a voltage value to a voltage equal to Vref+ is applied to the input channel
number so that it can be processed by a digital system the result will be 1023 (max value for a 10 bit ADC).
like MCU. More than one Analogue signal can be connected to the
MCU‟s ADCs are in different specifications, mostly MCU, this is because the ADC module of the MCU is
differentiated by their resolutions (8bit, 10bit, 12bit connected to several channels via a multiplexer. The
etc). Putting into considerations the fact that the MCU multiplexer can connect the input of the ADC to any of
analogue pins can only measure a range of 0 to 5V the available channels.
input voltage. The level of precision to which this
voltage can be measured is highly dependent on the 3.3. ADC Acquisition Time
resolution of the ADC. For example an 8 bit ADC will When a specific channel is selected the voltage from
successfully break the 0 to 5V range to 256 different that input channel is stored in an internal holding
levels, meaning, it can measure accurately, a 19mV capacitor. It takes some time for the capacitor to get
(5/256) change in voltage level conveniently. Likewise, fully charged and become equal to the applied voltage.
a 10 bit ADC will divide the measurement range to
1024 various levels, meaning a 5/1024 = 4.8mV change 3.4. ADC Clock
can be successfully detected. ADC requires a clock source to do its conversion, this
is called ADC Clock. The time period of the ADC
Table 1: ADC Resolution Parameters
Clock is called TAD. It is also the time required to
Resol- Bits Resol- Maximum
ution ution generate 1 bit of conversion. The ADC requires 11
ADC Voltage
TAD to do a 10 bit conversion.
Value Value
When the MCU tests the instantaneous temperature and V. DEVICE OPERTATIONS AND
decides that the Air conditioner or Fan needs to be DIAGRAMATIC VIEW
switched on, its PIN B2 or B3 connected to the Fan and
AC respectively are made high. This high is equivalent 1. How to start Up
to about a 2.5 to 5 volt output signal depending on its
design. The output signal is passed through a base i. Switch on Controller Device
resistor into the base of the NPN transistor which has ii. Set fan switch on temperature by turning the
the ability to exert control over a much larger flow of potentiometer RV2 (Maximum of 100oC)
electrons through the collector due to a relatively small iii. Press the „OK button‟
flow of electrons sent through the base of the transistor. iv. Set fan switch off temperature by turning the
To trigger this large flow, a signal of not less than 0.7 potentiometer RV2 (Minimum of 0oC)
volt has to be passed through the base of the transistor v. Press the „OK button‟
with a small resistor attached to it (the base) to make vi. Set AC switch on temperature by turning the
sure that the transistor is driven to saturation. potentiometer RV2 (Maximum of 100oC)
Considering the fact that the emitter terminal has been vii. Press the „OK button‟
grounded, as soon as the required base signal is passed, viii. Set AC switch off temperature by turning the
the collector grounds the terminal of the relay potentiometer RV2 (Minimum of 0oC)
connected to it , and then, the 12 volt relay triggers on ix. Press the „OK button‟
the Fan or AC by completing its own circuit
connection. 2. How to Change Temperature Settings