Beruflich Dokumente
Kultur Dokumente
OVERVIEW
1.1 INTORDUCTION
Temperature is a physical quantity expressing hot and cold. Something that is cold has
less temperature and hot has high temperature. Temperature is measured using
thermometers that may be calibrated in variety of temperature scales.
The main aim of this project is to continuously monitor the temperature and control the
temperature automatically according to the temperature detected by using 8051
microcontroller. It also detects fire and it spills water in order to decrease the damage
caused and also can save life of people.
1.3 OBJECTIVES
To Monitor the temperature by and controlling it with the given cooling system
present In the given Environment.
To Detect Fire ,Smoke and Spill water if it is Detected.
To develop the hardware system to monitor the temperature of the environment.
1
1.4 WORKING PRINCIPLE:
The Temperature Monitor and Control system works continuously until it gets power
from the power source. It monitors the surrounding temperature using LM35
temperature Sensor and it sends data to the LCD module. According to the temperature
detected the motor rotates the fan at different speeds automatically by using PWM
technique.
1.5 METHODOLOGY:
2
CHAPTER 2
INTRODUCTION TO EMBEDDED SYSTEM
2.1 Introduction:
Physically, embedded systems ranges from portable devices such as digital watches and MP3
players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants. In terms of complexity embedded systems can range from
very simple with a single microcontroller chip, to very complex with multiple units,peripherals
and networks mounted inside a large chassis or enclosure.
2.2 MICROCONTROLLER
Microcontroller, as the name suggests, are small controllers. They are like single chip
computers that are often embedded into other systems to function as processing/controlling
unit. For example, the remote control you are using probably has microcontrollers inside that
do decoding and other controlling functions. They are also used in automobiles, washing
machines, microwave ovens, toys ... etc, where automation is needed.
4
A Timer module to allow the microcontroller to perform tasks for certain time periods.
A serial I/O port to allow data to flow between the microcontroller and other devices
such as a PC or another microcontroller.
An ADC to allow the microcontroller to accept analogue input data for processing.
Figure 2.1: Showing a typical microcontroller device and its different subunits
The heart of the microcontroller is the CPU core. In the past this has traditionally been based
on an 8-bit microprocessor unit.
Microcontroller differs from a microprocessor in many ways. First and the most important is
its functionality. In order for a microprocessor to be used, other components such as memory,
or components for receiving and sending data must be added to it. In short that means that
microprocessor is the very heart of the computer. On the other hand, microcontroller is
designed to be all of that in one. No other external components are needed for its application
5
because all necessary peripherals are already built into it. Thus, we save the time and space
needed to construct devices
6
Memory components are exactly like that. For a certain input we get the contents of a certain
addressed memory location and that's all. Two new concepts are brought to us: addressing and
memory location. Memory consists of all memory locations, and addressing is nothing but
selecting one of them. This means that we need to select the desired memory location on one
hand, and on the other hand we need to wait for the contents of that location. Besides reading
from a memory location, memory must also provide for writing onto it. This is done by
supplying an additional line called control line. We will designate this line as R/W (read/write).
Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then
writing is done on the memory location. Memory is the first element, and we need a
few operation of our microcontroller.
Typically, the amount of ROM type memory will vary between around 512 bytes and 4096
bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as
128 Kbytes of ROM type memory.
ROM type memory, as has already been mentioned, is used to store the program code. ROM
memory can be ROM (as in One Time Programmable memory), EPROM, or EEPROM.
The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes
to 4 Kbytes.
RAM is used for data storage and stack management tasks. It is also used for register stacks
(as in the microchip PIC range of microcontrollers).
Let add 3 more memory locations to a specific block that will have a built in capability to
multiply, divide, subtract, and move its contents from one memory location onto another. The
7
part we just added in is called "central processing unit" (CPU). Its memory locations are called
registers.
Registers are therefore memory locations whose role is to help with performing various
mathematical operations or any other operations with data wherever data can be found. Look
at the current situation. We have two independent entities (memory and CPU) which are
interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for
example, we wish to add the contents of two memory locations and return the result again back
to memory, we would need a connection between memory and CPU. Simply stated, we must
have some "way" through data goes from one block to another.
2.3.3 Bus
That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires.
There are two types of buses: address and data bus. The first one consists of as many lines as
the amount of memory we wish to address and the other one is as wide as data, in our case 8
bits or the connection line. First one serves to transmit address from CPU memory, and the
second to connect all blocks inside the microcontroller.
8
Figure2.4: Showing connection between memory and central unit using buses
As far as functionality, the situation has improved, but a new problem has also appeared: we
have a unit that's capable of working by itself, but which does not have any contact with the
outside world, or with us! In order to remove this deficiency, let's add a block which contains
several memory locations whose one end is connected to the data bus, and the other has
connection with the output lines on the microcontroller which can be seen as pins on the
electronic component.
Those locations we've just added are called "ports". There are several types of ports: input,
output or bidirectional ports. When working with ports, first of all it is necessary to choose
which port we need to work with, and then to send data to, or take it from the port.
9
Figure2.5: Simplified input-output unit communicating with external world
When working with it the port acts like a memory location. Something is simply being written
into or read from it, and it could be noticed on the pins of the microcontroller.
Beside stated above we've added to the already existing unit the possibility of communication
with an outside world. However, this way of communicating has its drawbacks. One of the
basic drawbacks is the number of lines which need to be used in order to transfer data. What if
it is being transferred to a distance of several kilometers? The number of lines times’ number
of kilometers doesn't promise the economy of the project. It leaves us having to reduce the
number of lines in such a way that we don't lessen its functionality. Suppose we are working
with three lines only, and that one line is used for sending data, other for receiving, and the
third one is used as a reference line for both the input and the output side. In order for this to
work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is
therefore defined in advance so there wouldn't be any misunderstanding between the sides that
are communicating with each other. For example, if one man is speaking in French, and the
other in English, it is highly unlikely that they will quickly and effectively understand each
other. Let's suppose we have the following protocol. The logical unit "1" is set up on the
transmitting line until transfer begins. Once the transfer starts, we lower the transmission line
to logical "0" for a period of time (which we will designate as T), so the receiving side will
10
know that it is receiving data, and so it will activate its mechanism for reception. Let's go back
now to the transmission side and start putting logic zeros and ones onto the transmitter line in
the order from a bit of the lowest value to a bit of the highest value. Let each bit stay on line
for a time period which is equal to T, and in the end, or after the 8th bit, let us bring the logical
unit "1" back on the line which will mark the end of the transmission of one data. The protocol
we've just described is called in professional literature NRZ (Non-Return to Zero).
As we have separate lines for receiving and sending, it is possible to receive and send data
(info.) at the same time. So called full-duplex mode block which enables this way of
communication is called a serial communication block. Unlike the parallel transmission, data
moves here bit by bit, or in a series of bits what defines the term serial communication comes
from. After the reception of data we need to read it from the receiving location and store it in
memory as opposed to sending where the process is reversed. Data goes from memory through
the bus to the sending location, and then to the receiving unit according to the protocol.
11
2.3.6 Timer unit
Since we have the serial communication explained, we can receive, send and process data.
However, in order to utilize it in industry we need a few additionally blocks. One of those is
the timer block which is significant to us because it can give us information about time,
duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register
whose numeric value increments by one in even intervals, so that by taking its value during
periods T1 and T2 and on the basis of their difference we can determine how much time has
elapsed. This is a very important part of the microcontroller whose understanding requires most
of our time.
2.3.7 Watchdog
One more thing is requiring our attention is a flawless functioning of the microcontroller
during its run-time. Suppose that as a result of some interference (which often does occur in
industry) our microcontroller stops executing the program, or worse, it starts working
incorrectly.
Figure2.8: Watchdog
12
Of course, when this happens with a computer, we simply reset it and it will keep working.
However, there is no reset button we can push on the microcontroller and thus solve our
problem. To overcome this obstacle, we need to introduce one more block called watchdog.
This block is in fact another free-run counter where our program needs to write a zero in every
time it executes correctly. In case that program gets "stuck", zero will not be written in, and
counter alone will reset the microcontroller upon achieving its maximum value. This will result
in executing the program again, and correctly this time around. That is an important element
of every program to be reliable without man's supervision.
As the peripheral signals usually are substantially different from the ones that microcontroller
can understand (zero and one), they have to be converted into a pattern which can be
comprehended by a microcontroller. This task is performed by a block for analog to digital
conversion or by an ADC. This block is responsible for converting an information about some
analog value to a binary number and for follow it through to a CPU block so that CPU block
can further process it.
Finally, the microcontroller is now completed, and all we need to do now is to assemble it into
an electronic component where it will access inner blocks through the outside pins. The picture
below shows what a microcontroller looks like inside.
13
Figure2.10: Microcontroller outline with basic elements and internal connections
14
2.4 8051 MICROCONTROLLER
The AT89C51 provides the following standard features: 4 Kbytes of Flash, 128 bytes of RAM,
32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt architecture, a full
duplex serial port, and on-chip oscillator and clock circuitry. In addition, the AT89C51 is
designed with static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port and interrupt system to continue functioning. The Power down Mode
saves the RAM contents but freezes the oscillator.
15
2.5 PIN DIAGRAM OF 8051:
ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator
frequency, for external timing or clocking purposes, even when there are no accesses to
external memory. (However, one ALE pulse is skipped during each access to external Data
Memory.) This pin is also the program pulse input (PROG) during EPROM programming.
PSEN: Program Store Enable is the read strobe to external Program Memory. When the device
is executing out of external Program Memory, PSEN is activated twice each machine cycle
(except that two PSEN activations are skipped during accesses to external Data Memory).
PSEN is not activated when the device is executing out of internal Program Memory.
16
EA/VPP: When EA is held high the CPU executes out of internal Program Memory (unless
the Program Counter exceeds 0FFFH in the 80C51). Holding EA low forces the CPU to execute
out of external memory regardless of the Program Counter value. In the 80C31, EA must be
externally wired low. In the EPROM devices, this pin also receives the programming supply
voltage (VPP) during EPROM programming.
Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open drain output port, it can sink
eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that state will function
as high impedance inputs. Port 0 is also the multiplexed low-order address and data bus during
accesses to external memory. In this application it uses strong internal pull-ups when emitting
1s. Port 0 emits code bytes during program verification. In this application, external pull-ups
are required.
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port 1 pins that have 1s
written to them are pulled high by the internal pull-ups, and in that state can be used as inputs.
As inputs, port 1 pins that are externally being pulled low will source current because of the
internal pull-ups.
Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port 2 emits the high-
order address byte during accesses to external memory that use 16-bit addresses. In this
application, it uses the strong internal pull-ups when emitting 1s.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. It also serves the functions
of various special features of the 80C51 Family as follows:
Port Pin Alternate Function
P3.0 RxD (serial input port)
P3.1 TxD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
17
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)
The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on
the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of
reading, writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is
reset this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the
memory map. The first 8 bytes (00h - 07h) are "register bank 0". These alternative register
banks are located in internal RAM in addresses 08h through 1Fh.Bit memory actually resides
in internal RAM, from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM,
from addresses 30h through 7Fh, may be used by user variables that need to be accessed
18
frequently or at high-speed. This area is also utilized by the microcontroller as a storage area
for the operating stack.
Register Banks
The 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers
are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7).These registersare
generally used to assist in manipulating values and moving data from one memory location to
another. The concept of register banks adds a great level of flexibility to the 8051.
Bit Memory
The 8051, being a communication oriented microcontroller, gives the user the ability to access
a number of bit variables. These variables may be either 1 or 0. There are 128 bit variables
available to the user, numbered 00h through 7Fh. The user may make use of these variables
with commands such as SETB and CLR. It is important to note that Bit Memory is really a part
of Internal RAM. In fact, the 128 bit variables occupy the 16 bytes of Internal RAM from 20h
through 2Fh.
Special Function Registers (SFRs) are areas of memory that control specific functionality of
the 8051 processor. For example, four SFRs permit access to the 8051’s 32 input/output lines.
Another SFR allows a program to read or write to the 8051’s serial port .SFR is a part of
Internal Memory. This is not the case. When using this method of memory access (it’s called
direct address), any instruction that has an address of 00h through 7Fh refers to an Internal
RAM memory address; any instruction with an address of 80h through FFh refers to an SFR
control register.
19
Registers
The Accumulator
The Accumulator, as its name suggests, is used as a general register to accumulate the results
of a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile
register
The B Register:
The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-
byte) value. The "B" register is only used implicitly by two 8052 instructions: MUL AB and
DIV AB. Thus, if you want to quickly and easily multiply or divide A by another number, you
may store the other number in "B" and make use of these two instructions.
Aside from the MUL and DIV instructions, the "B" register are often used as yet another
temporary storage register much like a ninth "R" register.
The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including
R7. These registers are used as auxiliary registers in many operations.
The Program Counter (PC) is a 2-byte address that tells the 8052 where the next instruction to
execute is found in memory. When the 8052 is initialized PC always starts at 0000h and is
incremented each time an instruction is executed. It is important to note that PC isn't always
incremented by one. Since some instructions are 2 or 3 bytes in length the PC will be
incremented by 2 or 3 in these cases.
The Program Counter is special in that there is no way to directly modify its value. That is to
say, you can't do something like PC=2430h. On the other hand, if you execute LJMP 2430h
you've effectively accomplished the same thing.
20
It is also interesting to note that while you may change the value of PC (by executing a jump
instruction, etc.) there is no way to read the value of PC. That is to say, there is no way to ask
the 8052 "What address are you about to execute?" As it turns out, this is not completely true:
There is one trick that may be used to determine the current value of PC. This trick will be
covered in a later chapter.
The Data Pointer (DPTR) is the 8052ís only user-accessible 16-bit (2-byte) register. The
Accumulator, "R" registers, and "B" register are all 1-byte values. The PC just described is a
16-bit value but isn't directly user-accessible as a working register.
DPTR, as the name suggests, is used to point to data. It is used by a number of commands that
allow the 8052 to access external memory. When the 8052 accesses external memory it
accesses the memory at the address indicated by DPTR.
While DPTR is most often used to point to data in external memory or code memory, many
developers take advantage of the fact that it's the only true 16-bit register available. It is often
used to store 2-byte values that have nothing to do with memory locations.
The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value.
The Stack Pointer is used to indicate where the next value to be removed from the stack should
be taken from.
When you push a value onto the stack, the 8052 first increments the value of SP and then stores
the value at the resulting memory location. When you pop a value off the stack, the 8052 returns
the value from the memory location indicated by SP, and then decrements the value of SP.This
order of operation is important. When the 8052 is initialized SP will be initialized to 07h. If
you immediately push a value onto the stack, the value will be stored in Internal RAM address
08h. This makes sense taking into account what was mentioned two paragraphs above: First
the 8051 will increment the value of SP (from 07h to 08h) and then will store the pushed value
at that memory address (08h).
21
2.7 Addressing Modes:
Direct Addressing:
In direct addressing the operand is specified by an 8-bit address field in the instruction. Only
internal Data RAM and SFRs can be directly addressed.
Indirect Addressing:
In indirect addressing the instruction specifies a register which contains the address of the
operand. Both internal and external RAM can be indirectly addressed. The address register for
8-bit addresses can be R0 or R1 of the selected bank, or the Stack Pointer. The address register
for 16-bit addresses can only be the 16-bit “data pointer” register, DPTR.
Register Instructions
The register banks, containing registers R0 through R7, can be accessed by certain instructions
which carry a 3-bit register specification within the opcode of the instruction. Instructions that
access the registers this way are code efficient, since this mode eliminates an address byte.
When the instruction is executed, one of the eight registers in the selected bank is accessed.
One of four banks is selected at execution time by the two bank select bits in the PSW.
Register-Specific Instructions:
Some instructions are specific to a certain register. For example, some instructions always
operate on the Accumulator, or Data Pointer, etc., so no address byte is needed to point to it.
The opcode itself does that. Instructions that refer to the Accumulator as A assemble as
accumulator specific opcodes.
22
Immediate Constants:
Indexed Addressing:
Only program Memory can be accessed with indexed addressing, and it can only be read. This
addressing mode is intended for reading look-up tables in Program Memory A 16-bit base
register (either DPTR or the Program Counter) points to the base of the table, and the
Accumulator is set up with the table entry number. The address of the table entry in Program
Memory is formed by adding the Accumulator data to the base pointer. Another type of indexed
addressing is used in the “case jump” instruction. In this case the destination address of a jump
instruction is computed as the sum of the base pointer and the Accumulator data.
Interrupts
An interrupt is a special feature which allows the 8051 to provide the illusion of "multitasking,"
although in reality the 8051 is only doing one thing at a time.
Timers
Timers are one of the categories of hardware time delays. Time delays are used to keep a system
into halting System or sleepy mode. We have two timers-timer0, timer1.Hardware time delays
are used to generate exact time delays.
23
CHAPTER 3
HARDWARE DESCRIPTION
RELAY 1
8
0
5
1
RELAY 1 MOTOR
POWER SUPPLY
RELAY 1
24
3.2 LIQUID CRYSTAL DISPLAY:
LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs (seven
segment LEDs or other multi segment LEDs) because of the following reasons:
These components are “specialized” for being used with the microcontrollers, which
means that they cannot be activated by standard IC circuits. They are used for writing
different messages on a miniature LCD.
25
3.2.1 PINS FUNCTIONS:
There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background
light is built in). Their function is described in the table below:
Pin Logic
Function Name Description
Number State
Ground 1 Vss - 0V
Power supply 2 Vdd - +5V
Contrast 3 Vee - 0 – Vdd
D0 – D7 are interpreted as
0
4 RS commands
1
D0 – D7 are interpreted as data
Write data (from controller to
0 LCD)
Control of 5 R/W
1 Read data (from LCD to
operating
controller)
0 Access to LCD disabled
1 Normal operating
6 E
From 1 to Data/commands are transferred
0 to LCD
7 D0 0/1 Bit 0 LSB
8 D1 0/1 Bit 1
9 D2 0/1 Bit 2
10 D3 0/1 Bit 3
Data / commands
11 D4 0/1 Bit 4
12 D5 0/1 Bit 5
13 D6 0/1 Bit 6
14 D7 0/1 Bit 7 MSB
26
LCD
SCREEN:
LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot
matrix. Contrast on display depends on the power supply voltage and whether messages are
displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked
as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays
have built in backlight (blue or green diodes). When used during operating, a resistor for current
limitation should be used (like with any LE diode).
All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as data,
which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in processor
addresses built in “map of characters” and displays corresponding symbols. Displaying
27
position is determined by DDRAM address. This address is either previously defined or the
address of previously transferred character is automatically incremented.RS = 0 - Bits D0 - D7
are commands which determine display mode. List of commands which LCD recognizes are
given in the table below:
Execution
Command RS RW D7 D6 D5 D4 D3 D2 D1 D0
Time
Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS
Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS
Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS
Display on/off control 0 0 0 0 0 0 1 D U B 40uS
Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS
Function set 0 0 0 0 1 DL N F x x 40uS
Set CGRAM address 0 0 0 1 CGRAM address 40uS
Set DDRAM address 0 0 1 DDRAM address 40uS
Read “BUSY” flag (BF) 0 1 BF DDRAM address -
Write to CGRAM or
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
Read from CGRAM or
1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
I/D 1 = Increment (by 1) R/L 1 = Shift right
28
3.2.3 LCD INITIALIZATION:
Once the power supply is turned on, LCD is automatically cleared. The lcd commands are as
below
Automatic reset is mainly performed without any problems. Mainly but not always! If for any
reason power supply voltage does not reach full value in the course of 10mS, display will start
perform completely unpredictably? If voltage supply unit can not meet this condition or if it is
needed to provide completely safe operating, the process of initialization by which a new reset
enabling display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on whether connection to
the microcontroller is through 4- or 8-bit interface. All left over to be done after that is to give
basic commands and of course- to display messages.
29
Figure 3.4: Procedure on 8-bit initialization.
30
3.3 LCD INTERFACING WITH THE MICROCONTROLLER:
Vcc
P2.0 4 (RS) 1
P2.1 5 (R/W) 2
6(EN) 3 Gnd
P2.2
LCD
PRESET
(CONTRA
ST
D0 CONTROL
89S52 P1.0 )
P1.1 D1
P1.2 D2
P1.3 D3
P1.4 D4
P1.5 D5 15 Vcc FOR
P1.6 D6 16 BACKLIGH
Gnd
P1.7 D7 T PURPOSE
To send commands we simply need to select the command register. Everything is same as we
have done in the initialization routine. But we will summarize the common steps and put them
in a single subroutine. Following are the steps:
31
CODE:
LCD_en = 0;
To send data we simply need to select the data register. Everything is same as the command
routine. Following are the steps:
32
CODE:
Temperature is one of the most commonly measured parameter in the world. They are used in
your daily household devices from Microwave,fridges, AC to all fields of engineering.
Temperature sensor basically measures the heat/cold generated by an object to which it is
connected. It then provides a proportional resistance, current or voltage output which is then
measured or processed as per our application.
A thermistor is a thermally sensitive resistor that exhibits a large, predictable, and precise
change in resistance correlated to variations in temperature. An NTC thermistor provides a
very high resistance at low temperatures. As temperature increases, the resistance drops
quickly. Because an NTC thermistor experiences such a large change in resistance per °C,
small changes in temperature are reflected very fast and with high accuracy (0.05 to 1.5 °C).
Because of its exponential nature, the output of an NTC thermistor requires linearization. The
effective operating range is -50 to 250 °C for glass encapsulated thermistors or 150°C for
standard.
33
2. Resistance Temperature Detector (RTD):
3. Thermocouple:
This temperature sensor type consists of two wires of different metals connected at two points.
The varying voltage between these two points reflects proportional changes in
temperature. Thermocouples are nonlinear, requiring conversion when used for temperature
control and compensation, typically accomplished using a lookup table. Accuracy is low, from
0.5 °C to 5 °C. However, they operate across the widest temperature range, from -200 °C to
1750 °C.
5.Semiconductor-based sensors:
34
LM35:
LM35 is a precision IC temperature sensor with its output proportional to the temperature (in
°C).With LM35,the temperature can be measured more accurately than with a thermistor. It
also possess low self heating and does not cause more than 0.1 °C temperature rise in still air.
The operating temperature range is from -55°C to 150°C.The LM35’s low output
impedance,linear output, and precise inherent calibration make interfacing to readout or control
circuitry especially easy.It has find its applications on power supplies,battery
management,appliances,etc.
The sensor circuitry is sealed and not subject to oxidation.The LM35 generates a higher output
voltage than thermocouples and may not require that the output voltage be amplified.The LM35
has an output voltage that is proportional to the Celsius temperature.The scale factor is .01V/°C.
The LM35 does not require any external calibration or trimming and maintains an accuracy of
+/-0.4°C at room temperature and +/-0.8°C over a range of 0°C to +100°C.Another important
characteristic of the LM35 is that it draws only 60 micro amps from its supply and possesses a
low self-heating capability.The LM35 comes in many different packages such as TO-92 plastic
transistor-like package,T0-46 metal can transistor-like package,8-lead surface mount SO-8
small outline package.
35
Lower cost is assured by trimming and calibration at the wafer level. The low-output
impedance, linear output, and precise inherent calibration of the LM35 device makes
interfacing to readout or control circuitry especially easy. The device is used with single power
supplies, or with plus and minus supplies. As the LM35 device draws only 60 µA from the
supply, it has very low self-heating of less than 0.1°C in still air. The LM35 device is rated to
operate over a −55°C to 150°C temperature range, while the LM35C device is rated for a −40°C
to 110°C range (−10° with improved accuracy). The LM35-series devices are available
packaged in hermetic TO transistor packages, while the LM35C, LM35CA, and LM35D
devices are available in the plastic TO-92 transistor package. The LM35D device is available
in an 8-lead surface-mount small-outline package and a plastic TO-220 package. Main
advantage of LM35 is that it is linear i.e. 10mv/°C which means for every degree rise in
temperature the output of LM35 will rise by 10mv. So if the output of LM35 is 220mv/0.22V
the temperature will be 22°C. So if room temperature is 32°C then the output of LM35 will be
320mv i.e. 0.32V
Pin
Function Name
No
1 Supply voltage; 5V (+35V to -2V) Vcc
2 Output voltage (+6V to -1V) Output
3 Ground (0V) Ground
36
3.5 WORKING PRINCIPLE OF LM35:
There are two transistors in the center of the drawing. One has ten times the emitter area of the
other. This means it has one tenth of the current density, since the same current is going through
both transistors. This causes a voltage across the resistor R1 that is proportional to the absolute
temperature, and is almost linear across the range.The "almost" part is taken care of by a special
circuit that straightens out the slightly curved graph of voltage versus temperature.
The amplifier at the top ensures that the voltage at the base of the left transistor (Q1) is
proportional to absolute temperature (PTAT) by comparing the output of the two transistors.
The amplifier at the right converts absolute temperature (measured in Kelvin) into either
Fahrenheit or Celsius, depending on the part (LM34 or LM35).The little circle with the "i" in
it is a constant current source circuit.
The two resistors are calibrated in the factory to produce a highly accurate temperature
sensor.The integrated circuit has many transistors in it -- two in the middle, some in each
amplifier, some in the constant current source, and some in the curvature compensation circuit.
All of that is fit into the tiny package with three leads.
37
CAPACITIVE LOADS:
Like most micropower circuits, the LM35 has a limited ability to drive heavy capacitive loads.
The LM35 by itself is able to drive 50 pf without special precautions. If heavier loads are
anticipated, it is easy to isolate or decouple the load with a resistor Or you can improve the
tolerance of capacitance with a series R-C damper from output to ground;
When the LM35 is applied with a 200Ω load resistor it is relatively immune to wiring
capacitance because the capacitance forms a by- pass from ground to input, not on the output.
However, as with any linear circuit connected to wires in a hostile envi- ronment, its
performance can be affected adversely by in- tense electromagnetic sources such as relays,
radio trans- mitters, motors with arcing brushes, SCR transients, etc, as its wiring can act as a
receiving antenna and its internal junctions can act as rectifiers. For best results in such cases,
a bypass capacitor from VIN to ground and a series R-C damper such as 75Ω in series with 0.2
or 1 μF from output to ground are often useful.
38
APPLICATIONS :
The TO-46 metal package can also be soldered to a metal surface or pipe without damage. Of
course, in that case the V− terminal of the circuit will be grounded to that metal. Alternatively,
the LM35 can be mounted inside a sealed-end metal tube, and can then be dipped into a bath
or screwed into a threaded hole in a tank. As with any IC, the LM35 and accompanying wiring
and circuits must be kept insulated and dry, to avoid leakage and corrosion. This is especially
true if the circuit may operate at cold temperatures where condensation can occur. Printed-
circuit coatings and varnishes such as Humiseal and epoxy paints or dips are often used to
insure that moisture cannot corrode the LM35 or its connections.
These devices are sometimes soldered to a small light-weight heat fin, to decrease the thermal
time constant and speed up the response in slowly-moving air. On the other hand, a small
thermal mass may be added to the sensor, to give the steadiest reading despite small deviations
in the air temperature.
The LM35 can be applied easily in the same way as other integrated-circuit temperature
sensors. It can be glued or cemented to a surface and its temperature will be within about 0.01 ̊C
of the surface temperature.
This presumes that the ambient air temperature is almost the same as the surface temperature;
if the air temperature were much higher or lower than the surface temperature, the actual
temperature of the LM35 die would be at an intermediate temperature between the surface
temperature and the air temperature. This is especially true for the TO-92 plastic package,
where the copper leads are the principal thermal path to carry heat into the device, so its
temperature might be closer to the air temperature than to the surface temperature.
To minimize this problem, be sure that the wiring to the LM35, as it leaves the device, is held
at the same tempera- ture as the surface of interest. The easiest way to do this is to cover up
these wires with a bead of epoxy which will insure that the leads and wires are all at the same
temperature as the surface, and that the LM35 die’s temperature will not be affected by the air
temperature.
39
3.7 INTERFACING RELAYS WITH DC MOTOR:
3.7.1 DC MOTOR:
A DC motor is any of a class of rotary electrical machines that converts direct current electrical
energy into mechanical energy. The most common types rely on the forces produced by
magnetic fields. Nearly all types of DC motors have some internal mechanism, either
electromechanical or electronic, to periodically change the direction of current flow in part of
the motor.
DC motors were the first form of motor widely used, as they could be powered from existing
direct-current lighting power distribution systems. A DC motor's speed can be controlled over
a wide range, using either a variable supply voltage or by changing the strength of current in
its field windings. Small DC motors are used in tools, toys, and appliances. The universal motor
can operate on direct current but is a lightweight brushed motor used for portable power tools
and appliances. Larger DC motors are currently used in propulsion of electric vehicles, elevator
and hoists, and in drives for steel rolling mills.
3.7.2 Relay
40
Types of Relays
Latching relay:
A latching relay (also called "impulse", "keep", or "stay" relays) maintains either contact
position indefinitely without power applied to the coil. The advantage is that one coil
consumes power only for an instant while the relay is being switched, and the relay contacts
retain this setting across a power outage. A latching relay allows remote control of building
lighting without the hum that may be produced from a continuously (AC) energized coil.
In one mechanism, two opposing coils with an over-center spring or permanent magnet
hold the contacts in position after the coil is de-energized. A pulse to one coil turns the relay
on and a pulse to the opposite coil turns the relay off. This type is widely used where control
is from simple switches or single-ended outputs of a control system, and such relays are
found inavionics and numerous industrial applications.
Mercury relay
A mercury relay is a relay that uses mercury as the switching element. They are used where
contact erosion would be a problem for conventional relay contacts. Owing to
environmental considerations about significant amount of mercury used and modern
alternatives, they are now comparatively uncommon.
Polarized relay
A polarized relay places the armature between the poles of a permanent magnet to increase
sensitivity. Polarized relays were used in middle 20th Centurytelephone exchanges to
detect faint pulses and correct telegraphic distortion. The poles were on screws, so a
technician could first adjust them for maximum sensitivity and then apply a bias spring to
set the critical current that would operate the relay.
41
Coaxial relay
Where radio transmitters and receivers share one antenna, often a coaxial relay is used as
a TR (transmit-receive) relay, which switches the antenna from the receiver to the
transmitter. This protects the receiver from the high power of the transmitter. Such
relays are often used in transceivers which combine transmitter and receiver in one unit.
The relay contacts are designed not to reflect any radio frequency power back toward the
source, and to provide very high isolation between receiver and transmitter terminals. The
characteristic impedance of the relay is matched to the transmission line impedance of the
system, for example, 50 ohms.[4]
Time Relay
Timing relays are arranged for an intentional delay in operating their contacts. A very
short (a fraction of a second) delay would use a copper disk between the armature and
moving blade assembly. Current flowing in the disk maintains magnetic field for a short
time, lengthening release time. For a slightly longer (up to a minute) delay, a dashpot is
used. A dashpot is a piston filled with fluid that is allowed to escape slowly; both air-filled
and oil-filled dashpots are used. The time period can be varied by increasing or decreasing
the flow rate. For longer time periods, a mechanical clockwork timer is installed. Relays
may be arranged for a fixed timing period, or may be field adjustable, or remotely set from
a control panel. Modern microprocessor-based timing relays provide precision timing over
a great range.
Contactor
A contactor is a heavy-duty relay used for switching electric motors and lighting loads,
but contactors are not generally called relays. Continuous current ratings for common
contactors range from 10 amps to several hundred amps. High-current contacts are made
with alloys containing silver. The unavoidable arcing causes the contacts to oxidize;
however, silver oxide is still a good conductor. Contactors with overload protection
devices are often used to start motors. Contactors can make loud sounds when they
operate, so they may be unfit for use where noise is a chief concern.
42
A contactor is an electrically controlled switch used for switching a power circuit, similar
to a relay except with higher current ratings. A contactor is controlled by a circuit which
has a much lower power level than the switched circuit.
Contactors come in many forms with varying capacities and features. Unlike a circuit breaker,
a contractor is not intended to interrupt a short circuit current. Contactors range from those
having a breaking current of several amperes to thousands of amperes and 24 V DC to many
kilovolts. The physical size of contactors ranges from a device small enough to pick up with
one hand, to large devices approximately a meter (yard) on a side
A solid state contactor is a heavy-duty solid state relay, including the necessary heat sink,
used where frequent on/off cycles are required, such as with electric heaters, small electric
motors, and lighting loads. There are no moving parts to wear out and there is no contact
bounce due to vibration. They are activated by AC control signals or DC control signals
from Programmable logic controller (PLCs), PCs, Transistor-transistor logic (TTL)
sources, or other microprocessor and microcontroller controls.
Buchholz relay
43
CHAPTER 4
SOFTWARE DESCRIPTION
ABOUT KEIL:
44
5. Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
45
9. Select AT89S52 as shown below
46
12. Then Click either YES or NO………mostly “NO”
13. Now your project is ready to USE
14. Now double click on the Target1, you would get another option “Source group
1” as shown in next page.
15. Click on the file option from menu bar and select “new”
47
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
48
19. Now right click on Source group 1 and click on “Add files to Group Source”
20. Now you will get another window, on which by default “C” files will appear.
49
20. Now select as per your file extension given while saving the file
21. Click only one time on option “ADD”
22. Now Press function key F7 to compile. Any error will appear if so happen.
50
24. The new window is as follows
27. Drag the port a side and click in the program file.
51
28. Now keep Pressing function key “F11” slowly and observe.
29. You are running your program successfully.
52
4.2 PROLOAD:
Proload is a software which accepts only hex files. Once the machine code is converted
into hex code, that hex code has to be dumped into the microcontroller placed in the
programmer kit and this is done by the Proload. Programmer kit contains a microcontroller on
it other than the one which is to be programmed. This microcontroller has a program in it
written in such a way that it accepts the hex file from the keil compiler and dumps this hex file
into the microcontroller which is to be programmed. As this programmer kit requires power
supply to be operated, this power supply is given from the power supply circuit designed above.
It should be noted that this programmer kit contains a power supply section in the board itself
but in order to switch on that power supply, a source is required. Thus this is accomplished
from the power supply board with an output of 12volts or from an adapter connected to 230 V
AC.
53
CHAPTER
RESULTS AND CONCLUSION
54
55
56
CONCLUSION AND FUTURE SCOPE
The temperature is measured and it is controlled by using a dc motor of 5v. It can be directly
connected to the motor of a ceiling fan or an air conditioner fan such that they works
automatically .This project solves day to day usage of fans and A/c as it can control them and
also this project can be used in many places where certain amount of temperature should be
maintained for research purposes and many more. This can be implemented in many areas such
as it can be used in Apartments, Seminar Halls ,Libraries and many other places .In future this
project can be implemented as home automation. A GPS module can be interfaced to this and
the person can control it even by sending an message which helps to save power.
57
APPENDIX
#include<reg51.h>
#define lcd_data P2
sbit lcd_rs = P2^0;
sbit lcd_en = P2^1;
sbit cs=P1^0; //ADC temp
sbit din=P1^1;
sbit dout=P1^2;
sbit clk=P1^3;
sbit relay1 = P1^4;
sbit relay2 = P1^5;
sbit relay3 = P1^6;
58
lcd_data=value&(0xf0); //send msb 4 bits
lcd_rs=0; //select command register
lcd_en=1; //enable the lcd to execute command
delay(3);
lcd_en=0;
lcd_data=((value<<4)&(0xf0)); //send lsb 4 bits
lcd_rs=0; //select command register
lcd_en=1; //enable the lcd to execute command
delay(3);
lcd_en=0;
}
void lcd_init(void)
{
lcdcmd(0x02);
lcdcmd(0x02);
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/
lcdcmd(0x28); //intialise the lcd in 4 bit mode*/
delay(3);
}
SBUF=tx;
while(TI == 0);
TI=0;
void serinit()
{
TMOD=0x20;
TH1=0xFD; //9600
SCON=0x50;
TR1=1;
}
void main()
{
unsigned char rtr=0;
P2=0xff;
clk=0;
din=0;
dout=0;
cs=0;
relay1=relay2=relay3=0;
serinit();
lcd_init();
61
msgdisplay(" Welcome ");
delay(100);
lcdcmd(1);
msgdisplay("Temp:"); //0x86
while(1)
{
cs=1;
delay(10);
cs=0;
delay(10);
powerup(0);
relay1=1;
relay2=0;
relay3=0;
}
relay1=1;
relay2=0;
62
relay3=0;
}
relay1=0;
relay2=1;
relay3=0;
}
lcdcmd(0xc0);msgdisplay("Level-3");
relay1=0;
relay2=0;
relay3=1;
}
}
}
j=value%100;
k=j/10;
x=k|0x30;
sertx(x);
l=j%10;
x=l|0x30;
sertx(x);
return 1;
}
j=value%100;
k=j/10;
x=k|0x30;
lcddata(x);
l=j%10;
x=l|0x30;
lcddata(x);
return 1;
}
64
REFERNCES
1) https://ieeexplore.ieee.org/document/7975074
2) The 8051 Microcontroller and Embedded Systems: Using Assembly and C by
Mohammed Ali Mazdi
3) https://www.engineersgarage.com/electronic-components/16x2-lcd-module-datasheet
4) R. Van Nieuwenhove and L. Vermeeren, “Irradiation effects on temperature sensors for
ITER application,” Rev. Sci. Instrum.,
5) Tools for Physiology Labs: An Inexpensive Means of Temperature Control, Jacob
L.Krans and Ronald R.Hoy, the Journal of Undergraduate Neuroscience Education,
fall 2005, 4(1) A22-A26Datasheet:
6) Rose G (1983) A temperature controller for in vitro recording chambers. Brain Res
Bull10:713-714
7) Muhammad Imran and A. Bhattacharyya, “Thermal response of an on-chip assembly
of RTD heaters, sputtered sample and microthermocouples,” Sensors and Actuators
65