Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ABSTRACT
1. INTRODUCTION
2. LITERATURE SURVEY
3. DESIGN METHODOLOGY
10
10
13
13
14
14
18
22
22
23
24
3.4.7 Oscillator
27
28
29
30
3.5.3 SPECIFICATIONS:
32
33
33
33
34
34
35
3.7.1 Features
35
36
36
3.8 Resistors
36
3.9 Capacitors
37
38
4. HARDWARE IMPLEMENTATION
40
40
40
41
42
43
5.SOFTWARE IMPLEMENTATION
45
45
45
46
46
46
47
47
5.2 FLOWCHARTS
47
47
48
50
51
6.DEBUGGING TECHNIQUES
52
52
52
6.1.2 Features
52
53
6.2 LABTOOL-48UXP
54
6.2.1 Features
54
55
RESULTS
55
FUTURE SCOPE
56
BIBILOGRAPHY
57
APPENDIX
58
ACKNOWLEDGEMENT
Our sincere thanks to our director prof. Sri VIJAY KUMAR, who has given support to make
our project at IETE.
We thank our principal Sri BELLUBI sir for his kind support.
Our sincere thanks to our HOD, Sri GIRI RAJU sir who as guided us to the IETE (Institute of
Electronics and Telecommunication Engineering) where we successfully accomplished the
project.
Our sincere thanks to the external guide, Sri N.Abid Ali khan sir and Shankar sir, who has
guided us at IETE. He has taken all the care to complete the project in time.
ABSTRACT
This project is a standalone automatic fan controller that controls an electric fan according
to our requirement. Use of embedded technology makes this closed loop feedback control
system efficient and reliable. Micro controller allows dynamic and faster control. Liquid
crystal display (LCD) makes the system user-friendly. The sensed temperature values are
simultaneously displayed on the LCD panel. Micro controller is the heart of the circuit as it
controls all the functions.
The temperature sensor LM35 senses the temperature and converts it into an electrical
(analog) signal, which is applied to the micro controller through ADC. The analog signal is
converted into digital format by the analog-to-digital converter (ADC). The sensed and set
values of the temperature are displayed on the LCD. The micro controller drives control
relays to control the fan speed with the help of high wattage tagged wire wound resistor.
The relays are used to operate the electrical fan or for operating any other electrical device.
Normally the relay remain off. As soon as pin of the micro controller goes high, the relays
operate The system uses a compact circuitry built around 8051 microcontroller Programs are
developed in Embedded C. Flash magic is used for loading programs into Microcontroller
Keywords: Temperature sensor, ADC, LCDdisplay, relay, embedded systems
CHAPTER - I
INTRODUCTION
Now-a-days electricity has become a basic need to humans. The consumption of electricity
has increased a lot compared to the past years. In this project we present you the Automatic
temperature controlled fan which is used to cooling the electronic devices and machines in
industries .As we know every electronic device is consuming some power and dissipate some
heat.
The generated heat may increase the temperature of the surroundings of the device. Due to
increase in temperature of the device the parameters of the components are varying this will
effect the functionality of the device. If the heat dissipation is more then there may be a
chance of destroying of device. So it is necessary to cooling of device ,this can be done by
providing a coolers nearby the devices .The cooler is always running whenever the device
is ON, due to this power consumption will be more .By using electronic technology we can
reduce the power consumption by switching the motor whenever the device is hot and the
motor will switched off when the device is in normal condition .
We are explaining how to implement the above mentioned system throughout this document.
CHAPTER- II
LITERATURE SURVEY
The aim of the project is to Design and implementation of temperature controlled fan.
The microcontroller should be able to Interfacing with the temperature sensor through
2.
ADC 0804
3.
Power supply.
4.
LCD display.
5.
Temperature sensors
6.
System fan
7.
Resistors
8.
Capacitors
2.
The scope of this project is to make use of new modern technologies and implement them
into more practical fields. Our project can be implement in industries to cool the devices and
it can be implemented in house hold purpose also .It is act like a air conditioner whenever
the temperature is high the fan will be automatically ON and it will be off when the
temperature is normal .This can reduce the human involvement and the power consumption
.Our project extremely helped in computer s to work properly .
2.4 Organization of Report
Chapter1gives the introduction,. Chapter2 gives the aim and scope of the project and
selection of Hardware and software. Chapter 3 gives the brief discussion about DESIGN
METHODOLOGY .Chapter 4 gives the hardware implementation .The chapter 5 contains the
software implementation. Chapter 6 Includes the debugging techniques.
CHAPTER - III
DESIGN METHODOLOGY
In this power supply, a step down transformer is used to step down the current
from 230V to 5V AC, next step is to convert this AC to DC which is done by using a full
wave Rectifier and additional Filter Circuits are used where the ripples or noised in the DC
voltage are removed and at last a 7805 Regulatfror is used to makeup regulated a 5V DC,
from the output of the 7805 IC we connect a 2 pin connector to make a connection with the
corresponding Vcc(40) and Ground(20) pins of the AT89C51 microcontroller. Now the
microcontroller is powered up to do the specified controlling action given by the user.
Low cost
Simple design
Software Compatibility
Program Compatibility
Re-writability
The ATMEGA 16 microcontroller has an excellent software compatibility, i.e. the software
used can be applicable to any other microcontroller. The program written on this
microcontroller can be carried to any base. Program compatibility is the major advantage in
89s52. The program can be used in any other advanced microcontroller. The program can be
reloaded and changed for nearly 1000 times.
Pin Description:
Pin 18: Port 1: Each of these pins can be used as either input or output according to
your needs. Also, pins 1 and 2 (P1.0 and P1.1) have special functions associated with Timer;
these can be seen in the figure 4.3 shown above.
Pin 9: Reset Signal: High logical state on this input halts the MCU and clears all the
registers. Bringing this pin back to logical state zero starts the program a new as if the power
had just been turned on. In another words, positive voltage impulse on this pin resets the
MCU. Depending on the device's purpose and environs, this pin is usually connected to the
push-button, reset-upon-start circuit or a brown out reset circuit.The image shows one simple
circuit for safe reset upon starting the controller. It is utilized in situations when power fails to
reach its optimal voltage.
Pin 10-17: Port 3 as with Port 1, each of these pins can be used as universal input or
Pin 10: RXD - Serial input for asynchronous communication or serial output for
synchronous communication.
Pin 11: TXD - Serial output for asynchronous communication or clock output for
synchronous communication
Pin 14: T0
Pin 15: T1
Pin 16: WR
Pin 17: RD
Pin 18-19: X2 and X1; Input and output of internal oscillator. Quartz crystal
controlling the frequency commonly connects to these pins. Capacitances within the
oscillator mechanism are not critical and are normally about 30pF. Instead of a quartz crystal,
miniature ceramic resonators can be used for dictating the pace. In that case, manufacturers
recommend using somewhat higher capacitances. New Mucus works at frequencies from 0Hz
to 50MHz+.
Pin 21- 28: Port 2 if external memory is not present, pins of Port 2 act as universal
input/output. If external memory is present, this is the location of the higher address byte, i.e.
addresses A8 A15. It is important to note that in cases when not all the 8 bits are used for
addressing the memory (i.e. memory is smaller than 64kB), the rest of the unused bits are not
available as input/output.
Pin 29: PSEN: MCU activates this bit (brings to low state) upon each reading of byte
(instruction) from program memory. If external ROM is used for storing the program, PSEN
is directly connected to its control pins.
Of the external memory, MCU sends the lower byte of the address register (addresses
A0 A7) to port P0 and activates the output ALE. External register (74HCT373 or
74HCT375 circuits are common), memorizes the state of port P0 upon receiving a signal
from ALE pin, and uses it as part of the address for memory chip.
Pin 30:ALE: During the second part of the mechanical MCU cycle, signal on ALE is
off, and port P0 is used as Data Bus. In this way, by adding only one cheap integrated circuit,
data from port can be multiplexed and the port simultaneously used for transferring both
addresses and data.
Pin 31: EA: Bringing this pin to the logical state zero (mass) designates the ports P2
and P3 for transferring addresses regardless of the presence of the internal memory. This
means that even if there is a program loaded in the MCU it will not be executed, but the one
from the external ROM will be used instead. Conversely, bringing the pin to the high logical
state causes the controller to use both memories, first the internal, and then the external (if
present).
Pin 32-39: Port 0 Similar to Port 2, pins of Port 0 can be used as universal
Every MCU from 8051 families has 4 I/O ports of 8 bits each. This provides the user with 32
I/O lines for connecting MCU to the environs. Unlike the case with other controllers, there is
no specific SFR register for designating pins as input or output. Instead, the port itself is in
charge: 0=output, 1=input. If particular pin on the case is needed as output, the appropriate bit
of I/O port should be cleared. This will generate 0V on the specified controller pin. Similarly,
if particular pin on the case is needed as input, the appropriate bit of I/O port should be set.
This will designate the pin as input, generating +5V as a side effect (as with every TTL
input).
Port 0:
Port 0 has two-fold role: if external memory is used, it contains the lower address byte
(addresses A0-A7); otherwise all bits of the port are either input or output. Another feature of
this port comes to play when it has been designated as output. Unlike other ports, Port 0 lacks
the "pull up" resistor (resistor with +5V on one end). This seemingly insignificant change has
the following consequences: When designated as input, pin of Port 0 acts as high impedance
offering the infinite input resistance with no "inner" voltage.
When designated as output, pin acts as "open drain". Clearing a port bit grounds the
appropriate pin on the case (0V). Setting a port bit makes the pin act as high impedance.
Therefore, to get positive logic (5V) at output, external "pull up" resistor needs to be added
for connecting the pin to the positive pole.
Therefore, to get one (5V) on the output, external "pull up" resistor needs to be added
for connecting the pin to the positive pole.
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight
TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance
inputs.
Port 0 can also be configured to be the multiplexed low order address/data bus during
accesses to external program and data memory. In this mode, P0 has internal pull ups.
Port 0 also receives the code bytes during Flash programming and outputs the code bytes
during program verification. External pull ups are required during program verification.
Port 1:This is "true" I/O port, devoid of dual function characteristic for Port 0. Having the
"pull up" resistor, Port 1 is fully compatible with TTL circuits
Port 1 is an 8-bit bidirectional I/O port with internal pull ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the
internal pull ups and can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source current (IIL) because of the internal pull ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the
following table.
Port 1 also receives the low-order address bytes during Flash programming and verification.
Port 2:When external memory is used, this port contains the higher address byte (addresses
A8A15), similar to Port 0. Otherwise, it can be used as universal I/O port.
Port 2 is an 8-bit bidirectional I/O port with internal pull ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled
high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are
externally being pulled low will source current (IIL) because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program memory and
during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In
this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of
the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during Flash
programming and verification.
Port 3:Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pull-ups.
Port 3 also serves the functions of various special features of the ATMEGA 16, as shown in
the following table.
Port 3 also receives some control signals for Flash programming and verification.
Beside its role as universal I/O port, each pin of Port 3 has an alternate function. In
order to use one of these functions, the pin in question has to be designated as input, i.e., the
appropriate bit of register P3 needs to be set. From a hardware standpoint, Port 3 is similar to
Port 0.
As can be seen from the individual descriptions of the ports, they all share highly similar
structure. However, you need to consider which task should be assigned to which port. For
example: if utilizing port as output with high level (5V), avoid using Port 0, as its pins cannot
produce high logical level without an additional resistor connected to +5V. If using other port
to a same end, bear in mind that built-in resistors have relatively high values, producing the
currents limited to few hundreds of amperes as pin output.
3.4.3 Interrupts controls
There are 7 kinds of interrupt controllers that 8051 handles. They are as follows.
1.
2.
3.
Timer 0
4.
Timer 1
5.
Reset.
6.
7.
There are two types of external hardware interrupts. Pin 12 (P3.2) and pin 13 (P3.3) of the
8051, designated as INT0 and INT1, are used as external hardware interrupts. Upon the
activation of these pins, the 8051 gets interrupted in whatever it is doing and jumps to the
vector table to perform the interrupt service routines (ISR).
Timer 0 and timer 1 interrupts can be used in pooling method. In this method, we have to
wait until the TF is raised. The problem with this method is that the microcontroller is tied
down the controller. If the timer interrupt in the IE register is enabled, whenever the timer
rolls over, TF is raised, and the microcontroller is interrupted in whatever it is doing, and
jumps to the interrupts vector table to service the ISR.
Reset pin is an input pin and is active high (normally low). Upon applying a high pulse to this
pin, the microcontroller will reset and terminate all activities. This is often referred to as
power-on reset. In order for RESET input to be effective, it must have a minimum duration of
two machine cycles. In other words, the high pulse must be high for a minimum of two
machine cycles before it is allowed to go low. TXD and RXD are serial communication
interrupts.
RST (Reset):
A high on this pin for two machine cycles while the oscillator is running resets the device. An
internal resistor to VSS permits a power-on reset using only an external capacitor to VCC.
PSEN (Program Store Enable):
The read strobe to external program memory. When executing code from the external
program memory, PSEN is activated twice each machine cycle, except that two PSEN
activations are skipped during each access to external data memory. PSEN is not activated
during fetches from internal program memory.
The 8051 has two types of memory and these are Program Memory and Data
Memory. Program Memory (ROM) is used to permanently save the program being executed,
while Data Memory (RAM) is used for temporarily storing data and intermediate results
created and used during the operation of the microcontroller. Depending on the model in use
(we are still talking about the 8051 microcontroller family in general) at most a few Kb of
ROM and 128 or 256 bytes of RAM is used. All 8051 microcontrollers have a 16-bit
addressing bus and are capable of addressing 64 kb memory. It is neither a mistake nor a big
ambition of engineers who were working on basic core development. It is a matter of smart
memory organization which makes these microcontrollers a real programmers goody.
Program memory
The first models of the 8051 microcontroller family did not have internal program
memory. It was added as an external separate chip. These models are recognizable by their
label beginning with 803 (for example 8031 or 8032). All later models have a few Kbyte
ROM embedded. Even though such an amount of memory is sufficient for writing most of
the programs, there are situations when it is necessary to use additional memory as well. A
typical example is so called lookup tables. They are used in cases when equations describing
some processes are too complicated or when there is no time for solving them. In such cases
all necessary estimates and approximates are executed in advance and the final results are put
in the tables (similar to logarithmic tables).
Data memory
Data Memory is used for temporarily storing data and intermediate results created and
used during the operation of the microcontroller. Besides, RAM memory built in the 8051
family includes many registers such as hardware counters and timers, input/output ports,
serial data buffers etc. The previous models had 256 RAM locations, while for the later
models this number was incremented by additional 128 registers. However, the first 256
memory locations (addresses 0-FFh) are the heart of memory common to all the models
belonging to the 8051 family.
3.4.6 Registers in 8051
In the CPU, registers are used to store information temporarily. That information
could be a byte of data to be processed, or an address pointing to the data to be fetched. The
vast majority of 8051 registers are 8- bit registers. In the 8051 there is only one data type: 8
bits. With an 8-bit data type, any data larger than 8 bits must be broken into 8- bit chunks
before it is processed. The most widely used registers of the 8051 are A (Accumulator), B,
and SPF (special function registers) and PSW (Program Status Word).
A register is a general-purpose register used for storing intermediate results obtained
during operation. Prior to executing an instruction upon any number or operand it is
necessary to store it in the accumulator first. All results obtained from arithmetical operations
performed by the ALU are stored in the accumulator. Data to be moved from one register to
another must go through the accumulator. In other words, the A register is the most
commonly used register and it is impossible to imagine a microcontroller without it. More
than half instructions used by the 8051 microcontroller use somehow the accumulator
.Multiplication and division can be performed only upon numbers stored in the A and B
registers. All other instructions in the program can use this register as a spare accumulator
(A).
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even
though they are not true SFRs, they deserve to be discussed here because of their purpose.
They occupy 4 banks within RAM. Similar to the accumulator, they are used for temporary
storing variables and intermediate results during operation. Which one of these banks is to be
active depends on two bits of the PSW Register. Active bank is a bank the registers of which
are currently used.
SFR (Special Function Registers)
Special Function Registers (SFRs) are a sort of control table used for running and
monitoring the operation of the microcontroller. Each of these registers as well as each bit
they include, has its name, address in the scope of RAM and precisely defined purpose such
as timer control, interrupt control, serial communication control etc. Even though there are
128 memory locations intended to be occupied by them, the basic core, shared by all types of
8051 microcontrollers, has only 21 such registers.
PROGRAM STATUS WORD(PSW):
RS 0
BANK 0 (00H-07H)
BANK 1 (08H0FH)
BANK 2 (10H-17H)
BANK 3 (18H-1FH)
Carry flag:
CarryflagissetwheneverthereiscarryoutfromtheMSB.Thisflagisafter8bitADD/SUB
operation .It can also be set to 1or 0 directly using SETB C or CLR C
Auxiliary carry:
If there is a carry from D3 to D4 position during Add/Sub operation, this bit will set.
Otherwise, it is cleared .This flag is used for BCD operations.
Parityflagreflectsthenumberof1sinA.IfAcontainsanoddnumberof1s, then P=1. Therefore
P=0, if A has an even number of1s.
Overflow flag:
This flag is set whenever there of assigned number operation is too large to be accommodated
in7 bits, causing the higher order bit to overflow into the sign bit.
3.4.7 Oscillator
The microcontroller used in this project, ATMEGA 16 requires a baud rate of 9600.
To acquire this baud rate, an 11.0592 MHz crystal must be connected between 19th and 20th
pins of controller. The determination of machine cycle frequency and Baud rate is as follows.
MCF = (XTLfreq / 12)
= (11.0592 * 10^6) / 12
= 921.6 KHz
Baud rate = MCF/32
= (921.6 10^3) / 32
= 28800 Hz
XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:Output from the inverting oscillator amplifier.
C1, C2 = 33pF.
The LCD (Liquid Crystal Display) used to display the output to the user in the form of
GUI (Graphic User Interface) and a mono chromatic display. LCD used in this project is
JHD162A series .There are 16 pins in all. They are numbered from left to right 1 to 16 (if you
are reading from the backside). LCD shown above is marked to indicate which the 1st pin
was and which the 16th was.
In our project, we use a JHD162A LCD Display which has 2 rows and 16
characters. It contains internal 1 byte latch. It has a better contrast and a wider viewing angle.
To develop a protocol to interface this LCD with 89C51 first we have to understand how they
functions. These displays contain two internal byte-wide registers, one for command and
second for characters to be displayed. There are three control signals called R/W, RS and EN.
Select By making RS signal 0 you can send different commands to display. These commands
are used to initialize LCD, to display pattern, to shift cursor or screen etc. You can see the
markings right next to 1st and 16th pins. The 16by2 LCD with connections is as given below
LCD screen consists of two lines with 16 characters each. Each character consists of 5*7 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)
The main control pins on JHD162A are data lines, read or write and enable.
LCD is finding wide spread use replacing LEDs (seven segment LEDs or other multi segment
LEDs) because of the following reasons:
1.
The ability to display numbers, characters and graphics. This is in contrast to LEDs,
Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of
the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep
displaying the data.
3.
4.
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.
Read operation:
Enable Pin:
The enable pin has a very simple function. It is just the clock input for the LCD. The
instruction or the character data at the data pins (D0-D7) is processed by the LCD on the
falling edge of this pin. The Enable pin should be normally held at Vcc by a pull up resistor.
When a momentary button switch is pressed, the Pin goes low and back to high again when
you leave the switch. Your instruction or character will be executed on the falling edge of the
pulse. (i.e. the moment the switch closes).
3.5.3 SPECIFICATIONS:
To start with LCD the user should initialize it first which should be programmed with
its LCD commands. The LCD commands are given
LCD is used to display the current temperature which is sensed by the temperature
sensor
Analog to digital converter is a component which is used to convert the analog signal into
its equivalent digital signal .As we know microcontroller is doesnt understand the analog
signal so we have to convert it into digital signal.
In our project we are using ADC 0804 IC is used as a analog to digital converter. The
ADC0804 is a CMOS 8-bit successive-approximation analog-to-digital converter that uses a
modified potentiometric (256R) ladder. The ADC0804 is designed to operate from common
microcontroller control buses, with the 3-state output latches driving the data bus. The
ADC0804 can be made to appear to the microprocessor as a memory location or an I/O port.
3.6.1 PRINCIPLES OF OPERATION
The ADC0804 contains a circuit equivalent to a 256-resistor network. Analog switches are
sequenced by successive-approximation logic to match an analog differential input voltage
(VI+ VI) to a corresponding tap on the 256-resistor network. The most significant bit
(MSB) is tested first. After eight comparisons (64 clock periods), an 8-bit binary code (1111
1111 = full scale) is transferred to an output latch and the interrupt (INTR) output goes low.
The device can be operated in a free-running mode by connecting the INTR output to the
write (WR) input and holding the conversion start (CS) input at a low level. To ensure startup
under all conditions, a low-level WR input is required during the power-up cycle. Taking CS
low anytime after that will interrupt a conversion in process. When WR goes low, the
ADC0804 successive-approximation register (SAR) and 8-bit shift register are reset. As long
as both CS and WR remain low, the ADC0804 remains in a reset state. One to eight clock
periods after CS or WR makes a low-to-high transition, conversion starts. When CS and WR
are low, the start flip-flop is set and the interrupt flip-flop and 8-bit register are reset. The next
clock pulse transfers a logic high to the output of the start flip-flop. The logic high is AND ed
with the next clock pulse, placing a logic high on the reset input of the start flip-flop. If
either CS or WR have gone high, the set signal to the start flip-flop is removed, causing it to
be reset. A logic high is placed on the D input of the 8-bit shift register and the conversion
process is started. If CS and WR are still low, the start flip-flop, the 8-bit shift register, and
the SAR remain reset. This action allows for wide CS and WR inputs with conversion
starting from one to eight clock periods after one of the inputs goes high.
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage
is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an
advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to
subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The
LM35 does not require any external calibration or trimming to provide typical accuracies of
14C at room temperature and 34C over a full 55 to +150C temperature range. Low
cost is assured by trimming and calibration at the wafer level. The LM35s low output
impedance, linear output, and precise inherent calibration make interfacing to readout or
control circuitry especially easy. It can be used with single power supplies, or with plus and
minus supplies. As it draws only 60 A from its supply, it has very low self-heating, less than
0.1C in still air. The LM35 is rated to operate over a 55 to +150C temperature range,
while the LM35C is rated for a 40 to +110C range (10 with improved accuracy). The
LM35 series is available packaged in hermetic TO-46 transistor packages.
3.7.1 Features
within integrated circuits, particularly analog devices, and can also be integrated into hybrid
and printed circuits.
3.9 Capacitors
A capacitor (formerly known as condenser) is a device for storing electric charge. The
forms of practical capacitors vary widely, but all contain at least two conductors separated by
a non-conductor. Capacitors used as parts of electrical systems, for example, consist of metal
foils separated by a layer of insulating film.
A capacitor is a passive electronic component consisting of a pair of conductors separated by
a dielectric (insulator). When there is a potential difference (voltage) across the conductors, a
static electric field develops across the dielectric, causing positive charge to collect on one
plate and negative charge on the other plate. Energy is stored in the electrostatic field. An
ideal capacitor is characterized by a single constant value, capacitance, measured in farads.
This is the ratio of the electric charge on each conductor to the potential difference between
them.
frequencies for radio transmitters and receivers. The most common type of piezoelectric
resonator used is the quartz crystal, so oscillator circuits designed around them became
known as "crystal oscillators."
CHAPTER IV
HARDWARE IMPLEMENTATION
Pin1 to pin8 (Port 1) of controller are connected to the data lines of ADC (D0-D7).
The reset switch is connected to the 9th pin (RST) of ATMEGA 16, as it is used for
13,14,15 pins are connected to ADC as controlled pins WR, RD, INTR respectively.
The crystal oscillator which gives a frequency of 11.0592 MHz for the required Baud
rate of 9600Hz to the microcontroller. This crystal oscillator is connected in between 18th
(XALT 1) and 19th (XALT 2) pins of ATMEGA 16 micro controller.
The pins from 21st to 28th (port 2 data lines) are used for the external peripheral
connections.
The 29th pin is connected to an on-off switch so as to dump and execute the program.
Whenever the PSEN pin is connected to ground then we can execute the last dumped
program, likewise when 29th pin is connected to VCC then code can be dumped into the
controller.
Address Latch Enable pin (30th pin) of controller is connected to the ground hence no
External Access Enable or programming supply voltage should be latched when RST
is released and any subsequent changes have no effect. This pin also receives the
programming supply voltage (VPP) during Flash programming. Hence the pin 31st must be
connected to high i.e. VCC.
Port0 (pins 32 to 39) are connected to LCD in this project. But these should be
The LCD used for output display is JHD162A series. The detailed connections of LCD
is described briefly as
The 1st and 2nd pins of JHD162A LCD are connected to ground and high voltage
VCC respectively.
3rd pin of LCD is connected to the centre pin of the potentiometer or variable resistor
The 4th, 5th, 6th pins are connected to 26th (P 2.5), 27th (P 2.6), 28th (P 2.7) pins of
The 7th to 14th pins are data pins and are connected to the 39th (P 0.0) to 32nd (P 0.7)
The 15th and 16th pins are used for backlight purpose. 15th pin is connected to VCC
The 1st pin of the ADC is chip select pin it should be always low to activate the IC so
it is connected to ground.
The 2nd pin of the ADC is RD, it is connected to the 14th pin of microcontroller.
The 3rd pin of ADC is WR, it is connected to the 13th pin of microcontroller.
The 4th and 19th pin of the ADC are connected to the RC circuit to provide a clock
The 5th (interrupt) pin of the ADC is connected to the 15th pin of microcontroller.
The 6th pin is the analog input for the ADC , it is connected to the output pin of
9th pin is connected to the 10k pot to access the half of reference voltage .
The data pins of ADC (11 to 18) are connected to port 1 (1 to 8) of the controller.
LM35 temperature sensor has three pins the connections are explained below.
The 2nd pin is connected is the output pin which is connected to the 6th pin of
ADC .
CHAPTER V
SOFTWARE IMPLEMENTATION
This chapter explores some real world applications of theATMEGA 16, and also
includes how to interface the ATMEGA 16 to devices such as an LCD and its software
functionality using embedded C language. Embedded C is a set of language extensions for
the C Programming language by the C Standards committee to address commonality issues
that exist between C extensions for different embedded systems. Historically, embedded C
programming requires nonstandard extensions to the C language in order to support exotic
features such as fixed-point arithmetic, multiple distinct memory banks, and basic I/O
operations. In 2008, the C Standards Committee extended the C language to address these
issues by providing a common standard for all implementations to adhere to. It includes a
number of features not available in normal C, such as, fixed-point arithmetic, named address
spaces, and basic I/O hardware addressing.
Before you using the LCD, the program must initialize and configure it. This is
accomplished by sending a number of initialization instructions to the LCD.
The first instruction to send is the no of data for the LCD i.e., with an 8-bit or 4-bit
data bus. The other thing need to specify is display matrix; in the selected LCD it is a 5x8
dot character font. These two options are selected by sending the command 38h to the LCD
as a command. The command can give to the LCD by invoking the pre defined function call
lcdcmd with passing parameters value of 38H, the syntax for the same can be given like
lcdcmd(0x38).
rs=0;
rw=1;
while(busy==1)
{
en=0;
MSDelay(1);
en=1;
}
}
5.1.4 Writing command to the Display
{
Lcdready();
ldata=value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
{
lcdready();
ldata = value;
rs=1;
rw=0;
//read command
en=1;
en=0;
}
5.1.6 Displaying the data in to the LCD
void WriteString(unsigned char count,unsigned char *MSG)
{
unsigned char i;
for(i=0;i<count;i++)
{
lcddata(MSG[i]);
}
}
5.2 FLOWCHARTS
5.2.1 Checking the busy status of the LCD
Busy Flag (BF):
When the busy flag is high or 1 the module is performing an internal operation and
the next instruction will not be accepted. The RS=0 is used to check the Busy flag bit too see
if the LCD is ready to receive information. The Busy flag is D7 and can be read when R/W =
1 and RS = 0, as follows: if R/W = 1, RS= 0.When D7=1 (busy flag), the LCD is busy taking
care of internal operations and will not accept any new information. When D7=0, the LCD is
ready to receive new information.
Chapter VI
DEBUGGING TECHNIQUES
Keil is a compiler that has 3 windows, project window, edit window, and build or
command window Schematic. Today, Keil Software provides a broad range of development
tools for the embedded systems marketplace. Their products include ANSIC compilers,
macro assemblers, debuggers, linkers, library managers, and real-time operating systems.
It was then that Keil Software implemented the first C compiler designed from the groundup specifically for the 89C51 microcontroller.
6.1.2 Features
1.
2.
Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory types
3.
4.
5.
6.
7.
8.
Support for dual data pointers on Atmel, AMD, Cypress, Dallas semiconductor,
10.
The Keil 8051 Development Tools are designed to solve the complex problems facing
embedded software developers.
When starting a new project, simply select the microcontroller you use from the
Device Database and the vision IDE sets all compiler, assembler, linker, and memory
options for you.
Numerous example programs are included to help you get started with most popular
The Keil Vision Debugger accurately simulates on-chip peripherals (CAN, UART,
SPI, Interrupts, I/O Ports, A/D Convertor, D/A convertor, and PWM Modules) of your 8051
device. Simulation helps you understand hardware configurations and avoids time wasted on
setup problems. Additionally, with simulation, you can write and test applications before
target hardware is available.
When you are ready to begin testing your software application with target hardware,
use the MON51, MONADI, or FlashMON51 Target Monitors, the ISD51 In-system
Debugger, or the ULINK USB-JTAG Adapter to download and test program code on your
target system.
1. InstallKeilMicro Vision in your PC, Then after Click on that Keiluvision icon. After
opening the window go to toolbar and select Project Tab then close previous project.
2. Next select New Project from Project Tab.
3. Then it will open Create New Project window. Select the path where you want to save
project and edit project name.
4. Next it opens Select Device for Target window, it shows list of companies and here you
can select the device manufacturer company.
5. For an example, for your project purpose you can select the chip as 89c51rd2xx from
Philips Group. Next Click OK Button, it appears empty window here you can observe left
side a small window i.e., Project Window. Next create a new file.
6. From the Main tool bar Menu select File Tab and go to New, then it will open a window,
there you can edit the program.
7. Here you can edit the program as which language will you prefer either Assembly or C.
8. After editing the program save the file with extension as .c or .asm, if you write a
program in Assembly Language save as .asm or if you write a program in C Language save
as .c in the selected path.
9. Then after saving the file, compile the program. For compilation go to project window
select source group and right click on that and go to Add files to Group.
10. Here it will ask which file has to add. For an example here you can add test.c as you
saved before
11. After adding the file, again go to Project Window and right click on your c file then
select Build target for compilation. If there is any Errors or Warnings in your program
you can check in Output Window that is shown bottom of the Keil window.
12. Here in this step you can observe the output window for errors and warnings
13. If you make any mistake in your program you can check in this slide for which error and
where the error is by clicking on that error
14. After compilation then next go to Debug Session. In Tool Bar menu go to Debug tab
and select Start/Stop Debug Session.
15. Write a program for Leds Blinking. LEDS are connected to PORT-1. you can observe
the output in that port.
16. To see the Ports and other Peripheral Features go to main toolbar menu and select
peripherals.
17. In this slide see the selected port i.e., PORT-1.
18. Start to trace the program in sequence manner i.e., step by step execution and observe the
output in port window
19. After completion of Debug Session Create an Hex file for Burning the Processor. Here to
create a Hex file goes to project window and right click on Target next select Option for
Target.
20. It appears one window; here in target tab modify the crystal frequency as you
connected to your microcontroller.
21. Next go to Output tab. In that Output tab click on Create HEX File and then click
OK.
22. Finally Once again compile your program. The Created Hex File will appear in your path
folder
6.2 LABTOOL-48UXP
The LABTOOL-48UXP is a high performance intelligent PC-based universal programmer
that works through your PCs parallel port., , , ,.
6.2.1 Features
supports all kind of programmer chip in the market which include CPLD, EPROM,
Three simple steps to erasing and programming a device and setting key options
lower voltage chip (for example 1.8V Vcc and I/O support) also possible through
special adapter,
Device updates are disseminated through software, giving our customers quicker and
The LABTOOL-48UXP allows users to select the verification voltage after chip
programming is complete, e.g., Vcc +/-5%, Vcc+/-10%, Vcc can range from 2V to 7.5V.
Verification ensures that the chips have been properly programmed, with no data retention
problems.
1)
2)
3)
4)
Select the program which must be dumped into it and then load it.
5)
RESULTS
The system development precedes different stages and confirming that the present
stage is giving accurate results from one stage to other stage. The different stages in this
system are given like
FUTURE SCOPE
We can monitor more parameters like humidity, light and at the same time control
them.
We can send this data to a remote location using mobile or internet by connecting
GSM modem
BIBILOGRAPHY
Janci Gillespie Mazidi, Muhammad Ali Mazidi ,The 8051micro controller and
embedded systems, PHI Prentice hall India, Eastern Economy Edition, www.phindia.com.
http://en.wikipedia.org/wiki/Level_s
http://www,google.com
APPENDIX
PROJECTCODE
/* Source Code for Temp controlled Fan */
#include <at89x52.h>
#define MAX_TEMP 40
sfr ldata=0x80;
// Pre-processor Macros.
// This is Port-0 Addr. LCD
}
void lcddata (unsigned char value)
{
lcdready();
ldata=value;
rs=1;
rw=0;
en=1;
MSDelay(1);
en=0;
}
void lcdready(void)
{
busy=1;
rs=0;
rw=1;
while(busy==1)
{
en=0;
MSDelay(1);
en=1;
}
}
void MSDelay(unsigned int Iter)
{
unsigned int i, j;
for(i=0;i<Iter;i++)
{
for(j=0;j<1275;j++);
}
}
void WriteString(unsigned char *MSG)
{
unsigned char i;
for(i=0;MSG[i]!='\0';i++)
{
lcddata(MSG[i]);
}
}
void LCDClear(void)
{
lcdcmd(0x80);
WriteString("
");
lcdcmd(0xC0);
WriteString("
");
}
void Display(unsigned char value)
{
ADC_RD=1;
ADC_WR=1;
while(1)
{
ADC_WR=0;
ADC_WR=1;
while(ADC_INTR==1);
ADC_RD=0;
Buff = P1;
Display(Buff);
if(Buff=MAX_TEMP)
{
Buzzer = 0;
Motor = 1;
Led = 0;
//for(Delay=0;Delay<5000;Delay++);
}
else
{
Buzzer = 1;
Motor = 0;
Led = 1;
}
// P1 = 0x00;
ADC_INTR = 0;
ADC_RD=1;
ADC_WR=1;
}
}
void main(void)
{
ADC_INTR = 1;
ADC_RD=1;
ADC_WR=1;
Buzzer = 0;
Motor = 1;
Led = 0;
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);
WriteString("Welcome to NCET!");
lcdcmd(0xC0);
WriteString(" e-Fan Control ");
Start();
}