Escolar Documentos
Profissional Documentos
Cultura Documentos
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
5.1 JHD162A LCD INTERFACING
45
45
45
46
46
46
47
47
5.2 FLOWCHARTS
47
47
48
50
51
6.DEBUGGING TECHNIQUES
6.1 Keiluvision Debugger
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
2.1 Aim of the Project
The aim of the project is to Design and implementation of temperature controlled fan.
Customer (User) Interface to
7. Resistors
8. Capacitors
2.2.2 Software requirements
1. Lab tool universal programmer-48uxp.
2. KEIL Vision 4IDE C51 Embedded Cross Compiler.
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
3.1 Power supply
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 Regulator 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.
A variable regulated power supply, also called a variable bench power supply, is one where
you can continuously adjust the output voltage to your requirements. Varying the output of the
power supply is the recommended way to test a project after having double checked parts
placement against circuit drawings and the parts placement guide.
This type of regulation is ideal for having a simple variable bench power supply. Actually this is
quite important because one of the first projects a hobbyist should undertake is the construction
of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's
much handier to have a variable supply on hand, especially for testing.
Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need
to build a regulated 5 volt source. Usually you start with an unregulated power supply ranging
from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the
Microcontroller beginner Kit.). To make a 5 volt power supply, we use a LM7805 voltage
Fig 3.1a
The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC
power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the
Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin.
BLOCK DIAGRAM
Fig 3.1b
3.2 Block level design of temperature controlled fan
TE
MPE
RAT
URE
SEN
A
D
C
LCD
MICROCONT
ROLLER
REGUL
ATED
DRIVI
NG
FA
N
Low cost
Low power consumption, small, fast
Simple design
Easy maintainability and interoperability
Bug-free/Correctness, safety, many more
Software Compatibility
Program Compatibility
Re-writability
The 89s52 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.
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: 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 20: GND: Ground
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 input/output,
if external memory is not used. If external memory is used, P0 behaves as address output
(A0 A7) when ALE pin is at high logical level, or as data output (Data Bus) when ALE
pin is at low logical level.
Pin 40: VCC: Power +5V.
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 A8
A15), 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 AT89S52, 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.
4.
5.
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.
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.
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.
3.4.7 Oscillator
The microcontroller used in this project, AT89S52 requires a baud rate of 9600. To
acquire this baud rate, an 11.0592 MHz crystal must be connected between 19 th 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
C1, C2 = 33pF.
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
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,
which are limited to numbers and a few characters.
2.
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.
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:
Number of Characters: 16 characters x 2 Lines
To start with LCD the user should initialize it first which should be programmed with its
LCD commands. The LCD commands are given
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-tohigh 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 8bit shift register and the conversion process is started. If CS and WR are still low, the start flipflop, 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.
3.7.1 Features
3.8 Resistors
A resistor is a two-terminal passive electronic component that implements electrical
resistance as a circuit element. When a voltage V is applied across the terminals of a resistor, a
current I will flow through the resistor in direct proportion to that voltage. This constant of
proportionality is called conductance, G. The reciprocal of the conductance is known as the
resistance R, since, with a given voltage V, a larger value of R further "resists" the flow of
current I as given by Ohm's law:
Practical resistors can be made of various compounds and films, as well as resistance
wire (wire made of a high-resistivity alloy, such as nickel-chrome). Resistors are also
implemented 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.
supplies, in the resonant circuits that tune radios to particular frequencies and for many other
purposes.
The capacitor is a reasonably general model for electric fields within electric circuits. An
ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge
Q on each conductor to the voltage V between them:
CHAPTER IV
HARDWARE IMPLEMENTATION
4.1 Complete Schematic of temperature controlled fan
LCD1
D0
D1
D2
D3
D4
D5
D6
D7
7
8
9
10
11
12
13
14
RS
RW
E
4
5
6
1
2
3
VSS
VDD
VEE
LM016L
R3
R4
4k7
R5
R6
4k7
4k7
R7
4k7
R8
4k7
R9
U1
19
18
RV1
XTAL1
P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
XTAL2
RST
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
P2.7/A15
U3
29
30
31
10K
31.0
PSEN
ALE
EA
U2
VOUT
1
2
3
4
5
8
10
9
19
LM35
6
7
CS
RD
WR
CLK IN
INTR
A GND
D GND
VREF/2
CLK R
VCC
DB0(LSB)
DB1
DB2
DB3
DB4
DB5
DB6
DB7(MSB)
20
18
17
16
15
14
13
12
11
1
2
3
4
5
6
7
8
VIN+
VIN-
P1.0/T2
P1.1/T2EX
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P3.0/RXD
P3.1/TXD
P3.2/INT0
P3.3/INT1
P3.4/T0
P3.5/T1
P3.6/WR
P3.7/RD
4k7
R10
4k7
39
38
37
36
35
34
33
32
10k
21
22
23
24
25
26
27
28
D1
DIODE-LED
BUZ1
10
11
12
13
14
15
16
17
BUZZER
AT89C52
ADC0804
R1
10k
C1
R11
150p
1.2K
R2
Q1
BC547
2.2K
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 AT89S52, as it is used for set reset
the program.
13,14,15 pins are connected to ADC
respectively.
as controlled pins
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 18 th
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
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 so
as to adjust the contrast of LCD.
The 4th, 5th, 6th pins are connected to 26th (P 2.5), 27th (P 2.6), 28th (P 2.7) pins of the
microcontroller respectively.
The 7th to 14th pins are data pins and are connected to the 39 th (P 0.0) to 32nd (P 0.7) pins
of the microcontroller respectively.
The 15th and 16th pins are used for backlight purpose. 15th pin is connected to VCC and 16th
pin to ground.
.
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.
20th pin is supply for the ADC , it is connected to the 5v supply.
CHAPTER V
SOFTWARE IMPLEMENTATION
This chapter explores some real world applications of theAT89S52, and also
includes how to interface the AT89S52 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.
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).
{
Lcdready();
// wait till the LCD executes the instruction
ldata=value; // Set the value(instruction) in Data bus
rs=0;
// register select as command
rw=0;
en=1;
// set the enable command
MSDelay(1);
en=0;
// Reset the enable command
}
5.1.5 Writing Data to Display
void lcddata (unsigned char value) // LCD data placing routine
{
lcdready();
// wait till the LCD executes the instruction
ldata = value;
// Set the value(Data) in Data bus
rs=1;
//register select as data
rw=0;
//read command
en=1;
// Send Enable Signal to LCD
MSDelay(1); // This Function Gives Approximate Delay required For LCD Initialization
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]);
//Display Character on LCD at Proper Location
}
}
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.
start
Initialize lcd
Display starting
message
Read
ADC(temp)
TEMP>M
FAN IS
OFF
FAN IS
ON
DISPLA
Y
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 ground-up
specifically for the 89C51 microcontroller.
6.1.2 Features
1. Nine basic data types, including 32-bit IEEE floating-point
2. Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory
types
3. Interrupt functions may be written in C
4. Full use of the 8051 register banks
5. Complete symbol and type information for source-level debugging
6. Bit-addressable data objects
7. Built-in interface for the RTX51 real-time kernel
8. Support for dual data pointers on Atmel, AMD, Cypress, Dallas semiconductor,
Infineon, Philips, and Transcend microcontrollers
9. Support for Phillips 8xC510,8xC71,and 8xC752 limited instruction sets
10. Support for the Phillips 80C51 arithmetic unit.
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
embedded 8051 devices.
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
It features 48-pin ZIF sockets
supports all kind of programmer chip in the market which include CPLD, EPROM,
EEPOM, Serial EEPROM, Flash memory and MCU
extremely high throughput
5V and 3V chip support in both Vcc and I/O
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 insertion and continuity checks, all within a PC-based design
Device updates are disseminated through software, giving our customers quicker and
more flexible access to new chip support.
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.
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
Temperature controlled fan is designed.
The temperature sensor senses the temperature from surroundings
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 LCDClear(void);
void Start(void);
void Display(unsigned char);
void lcdcmd (unsigned char value)
{
lcdready();
ldata=value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
}
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)
{
unsigned char Buff[7];
unsigned char Loop;
LCDClear();
lcdcmd(0x80);
WriteString("Cur Temp:");
for(Loop=0;Loop<4;Loop++)
{
Buff[3-Loop]=(value%10)+0x30;
value/=10;
}
Buff[4]='\0';
WriteString(Buff);
lcdcmd(0xC0);
WriteString("Have a Good Day!");
}
void Start(void)
{
unsigned int Delay=0;
unsigned char Buff=0x00;
lcdcmd(0x80);
WriteString(" Booting Up... ");
lcdcmd(0xC0);
WriteString(" Please Wait ");
ADC_INTR = 1;
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();
}