temperature controlled fan

65
Temperature controlled fan with display CHAPTER 1 INTRODUCTION AND LAYOUT 1.0ABOUT THE PROJECT Temperature controller can be done by using Electronic circuit, Microprocessor or microcontroller. Now microcontroller is advanced among all above circuits therefore we are using Microcontroller for temperature controlling. In this project, microcontroller 89s51 forms the processing part, which firstly receives data from ADC. ADC receives data from temperature sensor through amplifier. Then microcontroller 89s51 performs the comparison of current temperature and set temperature as per the logic of program for which microcontroller has already been programmed. The result obtained from the above operation is given through output port of 89s51 to LCD display of relevant data and generated pulses as per the logic program which is further fed to the driver circuit to obtain the desired output of ceiling fan. AIET/ECE/PR/01

Transcript of temperature controlled fan

Page 1: temperature controlled fan

Temperature controlled fan with display

CHAPTER 1

INTRODUCTION AND LAYOUT

1.0ABOUT THE PROJECTTemperature controller can be done by using Electronic circuit, Microprocessor or

microcontroller. Now microcontroller is advanced among all above circuits therefore we are

using Microcontroller for temperature controlling.

In this project, microcontroller 89s51 forms the processing part, which firstly receives data

from ADC. ADC receives data from temperature sensor through amplifier. Then

microcontroller 89s51 performs the comparison of current temperature and set temperature as

per the logic of program for which microcontroller has already been programmed. The result

obtained from the above operation is given through output port of 89s51 to LCD display of

relevant data and generated pulses as per the logic program which is further fed to the driver

circuit to obtain the desired output of ceiling fan.

AIET/ECE/PR/01

Page 2: temperature controlled fan

Temperature controlled fan with display

FIG 1.0 System block diagram

1.1 Description of components used:

-1.1.1 Temperature sensor: - it’s a transducer. It converts temperature into equivalent

electrical signal. Its output voltage increases linearly with increase in temperature. So by

measuring the output voltage we may observe increase or decrease in temperature

1.1.2 ADC: because the output of sensor is an analog form, it must be converted into

equivalent digital form before it is given to micro-controller. So, 8-bit ADC converts analog

signal from sensor into 8-bit digital signal that is given to micro-controller.

1.1.3 Micro-controller: - It performs following tasks

·  Controls ADC and reads digital value at periodic interval

·  Generates PWM and controls speed of DC fan through DC driver

·  Indicates current speed on LED bar graph display.

1.1.4 LED bar graph: - its 5-step bar graph that displays min speed as one LED ON and max

speed as all five LEDs ON.

1.1.5 DC Driver: - the direct micro-controller output is not able to drive DC motor. So the DC

driver will take input PWM signal from micro-controller and generates enough current to drive

DC motor through this PWM.

1.2 Designing the layout

DIPTRACE is EDA software for creating schematic diagrams and printed circuit boards.

The first version of DipTrace was released in August, 2004. The latest version as of March

2013 is DipTrace version 2.3.1. The interface and tutorials are multi-lingual (currently

English, Czech, Russian and Turkish).[2] In January of 2011, Parallax switched from Eagle

to DipTrace for developing its printed circuit boards.

AIET/ECE/PR/02

Page 3: temperature controlled fan

Temperature controlled fan with display

Fig 1.1 Layout on PCB Wizard

1.3Printed circuit board (PCB) 

A printed circuit board (PCB) mechanically supports and electrically connects electronic

components using conductive tracks, pads and other features etched from copper

sheets laminated onto a non-conductive substrate. PCB's can be single sided (one copper

layer), double sided (two copper layers) or multi-layer. Conductors on different layers are

connected with plated-through holes called vias. Advanced PCB's may contain components -

capacitors, resistors or active devices - embedded in the substrate.

Printed circuit boards are used in all but the simplest electronic products. Alternatives to PCBs

include wire wrap and point-to-point construction. PCBs are more costly to design but allow

automated manufacturing and assembly. Products are then faster and cheaper to manufacture,

and potentially more reliable.

AIET/ECE/PR/03

Page 4: temperature controlled fan

Temperature controlled fan with display

Much of the electronics industry's PCB design, assembly, and quality control follows standards

published by the IPC organization.

When the board has only copper connections and no embedded components it is more correctly

called a printed wiring board (PWB) or etched wiring board. Although more accurate, the term

printed wiring board has fallen into disuse. A PCB populated with electronic components is

called a printed circuit assembly (PCA), printed circuit board assembly or PCB

assembly (PCBA). The IPC preferred term for assembled boards is circuit card

assembly (CCA), [1] for assembled backplanes it is backplane assemblies. The term PCB is used

informally both for bare and assembled boards.

1.4 Steps followed during fabrication

1.4.1Patterning

In subtractive methods the unwanted copper is removed to leave only the desired copper

pattern. In additive methods the pattern is electroplated onto a bare substrate using a complex

process. The advantage of the additive method is that less material is needed and less waste is

produced. The pattern in the manufacturer's PCB CAM system is usually output on a

photomask (photo-tool, film) by a photo plotter and replicated via silk screen printing or by

exposing on a photo-sensitive photoresist coating. Direct laser imaging techniques are

sometimes used for high-resolution requirements.

1.4.2Subtractive methods

This method id used to remove copper from an entirely copper-coated board:

Silk screen printing:  Uses etch-resistant inks to protect the copper foil. Subsequent etching

removes the unwanted copper. Alternatively, the ink may be conductive, printed on a blank

(non-conductive) board. The latter technique is also used in the manufacture of hybrid circuits.

Photoengraving:  Uses a photomask and developer to selectively remove a photoresist coating.

The remaining photoresist protects the copper foil. Subsequent etching removes the unwanted

copper.

PCB milling:  Uses a two or three-axis mechanical milling system to mill away the copper foil

from the substrate. A PCB milling machine (referred to as a 'PCB Prototyper') operates in a

AIET/ECE/PR/04

Page 5: temperature controlled fan

Temperature controlled fan with display

similar way to a plotter, receiving commands from the host software that control the position of

the milling head in the x, y, and (if relevant) z axis. Data to drive the Prototyper is extracted

from files generated in PCB design software and stored in HPGL orGerber file format.

1.5Chemical etching

Chemical etching is usually done with ammonium persulfate or ferric chloride. For PTH

(plated-through holes), additional steps of electroless deposition are done after the holes are

drilled, then copper is electroplated to build up the thickness, the boards are screened, and

plated with tin/lead. The tin/lead becomes the resist leaving the bare copper to be etched away.

As more copper is consumed from the boards, the etchant becomes saturated and less effective;

different etchants have different capacities for copper, with some as high as 150 grams of

copper per litre of solution. In commercial use, etchants can be regenerated to restore their

activity, and the dissolved copper recovered and sold. Small-scale etching requires attention to

disposal of used etchant, which is corrosive and toxic due to its metal content.

The etchant removes copper on all surfaces exposed by the resist. "Undercut" occurs when

etchant attacks the thin edge of copper under the resist; this can reduce conductor widths and

cause open-circuits. Careful control of etch time is required to prevent undercut. Where

metallic plating is used as a resist, it can "overhang" which can cause short-circuits between

adjacent traces when closely spaced. Overhang can be removed by wire-brushing the board

after etching

1.6Drilling

Holes through a PCB are typically drilled with small-diameter drill bits made of solid

coated tungsten carbide. Coated tungsten carbide is recommended since many board materials

are very abrasive and drilling must be high RPM and high feed to be cost effective. Drill bits

must also remain sharp so as not to mar or tear the traces. Drilling with high-speed-steel is

simply not feasible since the drill bits will dull quickly and thus tear the copper and ruin the

boards. The drilling is performed by automated drilling machines with placement controlled by

a drill tape or drill file. These computer-generated files are also called numerically controlled

drill (NCD) files or "Excellon files". The drill file describes the location and size of each drilled

AIET/ECE/PR/05

Page 6: temperature controlled fan

Temperature controlled fan with display

hole. These holes are often filled with annular rings (hollow rivets) to create vias. Vias allow

the electrical and thermal connection of conductors on opposite sides of the PCB..

It is also possible with controlled-depth drilling, laser drilling, or by pre-drilling the individual

sheets of the PCB before lamination, to produce holes that connect only some of the copper

layers, rather than passing through the entire board. These holes are called blind vias when they

connect an internal copper layer to an outer layer, or buried vias when they connect two or

more internal copper layers and no outer layer.

Fig 1.2 Flow chart for pcb fabrication steps

AIET/ECE/PR/06

Page 7: temperature controlled fan

Temperature controlled fan with display

CHAPTER 2

CIRCUIT AND CONNECTIONS

2.0Complete circuit: -

Fig 2.0 Complete circuit diagram

I have divided complete circuit in three different sections1.    ADC section2.    Controller section3.    DC driver section

AIET/ECE/PR/07

Page 8: temperature controlled fan

Temperature controlled fan with display

 2.1ADC Section: -

Fig 2.1 ADC Section 2.2 About LM35It is semiconductor type temperature sensor. Here are its main features

1.  Calibrated directly in ° Celsius (Centigrade)

2.  Linear + 10.0 mV/°C scale factor

3.  0.5°C accuracy guaranteed (at +25°C)

4.  Rated for full ?55° to +150°C range

5.  Operates from 4 to 30 volts

6.   Less than 60 ?A current drain

7.   Low self-heating, 0.08°C in still air

8.   Nonlinearity only ±1?4°C typical

9.   Low impedance output, 0.1 W for 1 mA load

 So its output changes to ±10 mV with change in ± 1 oC. I have set the reference voltage (Vref)

of ADC to 2.56 V. so its full scale input voltage will be 5.12 V. and resolution will be

ADC resolution = FSV / (28 - 1)

= 5.12 / 256

= 0.02

  = 20 mV

From above calculation we can say that for every 2 oC change in temperature, the ADC output

will change. So ADC output is perfectly calibrated to oC change in temperature. Its control

signals and data bus are interfaced with micro-controller. There are four control signals CS,

RD, WR, INTR, and 8-bit data bus.

AIET/ECE/PR/08

Page 9: temperature controlled fan

Temperature controlled fan with display

·  8-bit data bus – it is connected with port P1 of 89C52. It sends 8-bit digital data equivalent to

analog output form LM35.

·  CS (chip select) – active low input signal. Connected to ground permanently to always enable

chip.

·  RD (read enable) – active low input signal. Connected with pin no 17 (P3.7) of 89C52

·  WR (write enable) – active low input also known as start of conversion (SoC). Connected

with pin no 16 (P3.6) of 89C52

·  INTR (interrupt out) – low output signal also know as end of conversion (EoC). Connected

with pin no 13 (P3.3 of 89C52) 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 ±¼°C at room temperature and ±¾°C over a full -55 to +150°C

temperature range. Low cost is assured by trimming and calibration at the wafer level. The

LM35's 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.1°C in still air. The LM35 is rated to operate over a -55° to +150°C

temperature range, while the LM35C is rated for a -40° to +110°C range (-10° with improved

accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, while

the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package.

The LM35D is also available in an 8-lead surface mount small outline package and a plastic

TO-220 package. 

2.3 CONTROLLER AND DRIVER SECTION: -The details of the circuit have been mentioned in the Circuit Diagram Tab. 

Connections: -

The connections from previous sections (ADC) are shown. Five LEDs LED1 to LED5 are

connected to port2 pins P2.0 to P2.4 as shown. A 12 MHz crystal with two 33 pF capacitors is

AIET/ECE/PR/09

Page 10: temperature controlled fan

Temperature controlled fan with display

connected to 89C52 crystal pins to provide clock signal. A capacitor C4 with diode D1 and

resistor R4 forms power on reset circuit. This completes controller section.

 

In driver section, IC555 is configured in monostable mode that receives PWM from 89C52 as

trigger input and it generates exact inverted PWM. Its time constant is less than 0.1 ms that is

decided by R1C1. This PWM output is fed at the base of PNP type Darlington pair transistor

TIP127. The collector of TIP127 is connected to DC fan motor. It will provide enough current

to drive motor.

 

Operation: -·   The micro-controller initially starts rotating motor at minimum speed by applying 30% duty cycle.·   Then periodically it will read the digital value of current temperature from ADC·    If new value is higher than previous value then duty cycle is increased in 5 steps as 30%, 50%, 70%, 80% and 90%.·   Similarly if new value is lower duty cycle is decreased in same steps.·   If temperature remains constant the output duty cycle also remains constant and so does the speed.  ·  So this is continuous process. The micro-controller continuously reads new temperature value and continuously varies speed of fan.The program loaded into micro-controller is written in C language and compiled using keil

IDE. The code can be retrieved from the Code tab.

There are two functions and one main function.

Int1() is an interrupt function. It reads digital value given by ADC. Then it increases or

decreases duty cycle as per received value.

Delay() function generates variable delay in step of 1 ms. If value passed to it is 5 that means it

will generate delay of 5 ms and so on.

 

AIET/ECE/PR/010

Page 11: temperature controlled fan

Temperature controlled fan with display

Fig 2.2 Temperature based fan

AT89S8253 that is capable of taking decisions on the basis of input. Crystal oscillator is used

to generate frequency it is of 10MHz. This crystal is coupled with 22pf /33pf capacitor so that

microcontroller circuitry get complete and it can work with programming.

The complete working of this system can be divided in the following blocks for easier

understanding

2.2Temperature Sensor

It consists of the sensor which measures the temperature of its surrounding and communicates

that data to the microcontroller. The sensor used here is DS18B20.It is a highly sensitive

sensor with a resolution of less than 0.50C. It communicates with microcontroller using one

wire protocol of communication.

2.3Microcontroller Block

Microcontroller takes the temperature data from DS18B20 temperature sensor. Based on this

data it decides which device is to be operated and at what power it is to be operated. The

outputs of the microcontroller are fed into the power amplifying unit. It also controls the

display on the Display Unit. The microcontroller used in this project is AT89S8253.

AIET/ECE/PR/011

Page 12: temperature controlled fan

Temperature controlled fan with display

2.3 Display Unit

It is 16*2 LCD that shows the temperature of the room at any particular instant. It also shows

which appliance is being used and at what power it is being used.

2.4Power amplifying block

This is the block that converts the TTL outputs of microcontroller into high power signals.

These signals can then be used be used to drive appliances. This block consists of relays, relay

pre-amplifiers and transistors.

2.5Appliances Block

This block consists Fan and a DC motor whose status show the appliance used. This block is

connected to the Power Amplifying Block.

2.6Power supply Block

This consist a 12V AC to DC Adaptor and a power regulator (7805) to get 5v power supply.

This 12V supply drives power amplifiers and appliances while the 5v supply drives the sensor,

microcontroller and the LCD.

This project report contain full working, block diagram, component used in the project,

component description. Use this report only for your reference and study work. 

2.7. ADC 0804 LCN

The ADC0801, ADC0802, ADC0803, ADC0804 and ADC0805 are CMOS 8-bit successive

approximation A/D converters that use a differential potentiometric ladder-similar to the 256R

products. These converters are designed to allow operation with the NSC800 and INS8080A

derivative control bus with TRI-STATE output latches directly driving the data bus. These

A/Ds appear like memory locations or I/O ports to the microprocessor and no interfacing logic

is needed.

Differential analog voltage inputs allow increasing the common-mode rejection and offsetting

the analog zero input voltage value. In addition, the voltage reference input can be adjusted to

allow encoding any smaller analog voltage span to the full 8 bits of resolution.

AIET/ECE/PR/012

Page 13: temperature controlled fan

Temperature controlled fan with display

2.8. Opt coupler

In electronics an opto-isolator, also called an optocoupler, photocoupler, or optical isolator, is

"an electronic device designed to transfer electrical signals by utilizing light waves to provide

coupling with electrical isolation between its input and output". The main purpose of an opto-

isolator is "to prevent high voltagesor rapidly changing voltages on one side of the circuit from

damaging components or distorting transmissions on the other side."Commercially available

opto-isolators withstand input-to-output voltages up to 10 kV and voltage transients with

speeds up to 10 kV.

2.9Voltage Regulator L7805

Voltage Regulator L7805 (regulator), usually having three legs, converts varying input voltage

and produces a constant regulated output voltage. They are available in a variety of outputs.

The most common part numbers start with the numbers 78 or 79 and finish with two digits

indicating the output voltage. The number 78 represents positive voltage and 79 negative one.

The 78XX series of voltage regulators are designed for positive input. And the 79XX series is

designed for negative input.  

Fig 2.3 Voltage regulator

2.10. Crystal Oscillator 12MHz

An oscillator is something that produces an output that repeats regularly. In the electronics field

this will be an electrical waveform, often but not always a sine wave.The most important

property of an oscillator is its frequency: the rate at which the output repeats. This is measured

in Hertz (Hz for short). One Hertz is one repetition (aka cycle) per second. One Mega Hertz

AIET/ECE/PR/013

Page 14: temperature controlled fan

Temperature controlled fan with display

(MHz) is one million repetitions per second. One of the problems in designing a high quality

oscillator is maintaining the output frequency at the value required. One method is to control it

by a quartz crystal; this is cut so that it vibrates mechanically at the design frequency, and is

coupled to the electronics by the piezo-electric effect.A 12 MHz crystal oscillator is an

electronic circuit, whose output frequency is controlled by a quartz crystal to repeat 12 million

times per second.

 

Fig 2.4 Crystal oscillator

CHAPTER 3

DESCRIPTION OF COMPONENTS

3.1Resistors

Axial- lead resistors on tape. The tape is removed during assembly before the leads are formed

and the part is inserted into the board. Three carbon composition resistors in a 1960s valve

(vacuum tube) radio. A resistor is a two-terminal electronic component that produces a voltage

across its terminals that is proportional to the electric current through it in accordance with

Ohm's law:

AIET/ECE/PR/014

Page 15: temperature controlled fan

Temperature controlled fan with display

Fig 3.1 Variable resistor

Variable resistors consist of a resistance track with connections at both ends and a wiper which

moves along the track as you turn the spindle. The track may be made from carbon, cermets

(ceramic and metal mixture) or a coil of wire (for low resistances). The track is usually rotary

but straight track versions, usually called sliders, are also available.

Variable resistors may be used as a rheostat with two connections (the wiper and just one end

of the track) or as a potentiometer with all three connections in use. Miniature versions called

presets are made for setting up circuits which will not require further adjustment.

Variable resistors are often called potentiometers in books and catalogues. They are specified

by their maximum resistance, linear or logarithmic track, and their physical size

3.2 Capacitor

A capacitor or condenser is a passive electronic component consisting of a pair of conductors

separated by a dielectric. When a voltage potential difference exists between the conductors, an

electric field is present in the dielectric. This field stores energy and produces a mechanical

force between the plates. The effect is greatest between wide, flat, parallel, narrowly separated

conductors.

The conductors and leads introduce an equivalent series resistance and the dielectric has an

electric field strength limit resulting in a breakdown voltage.

Capacitors are widely used in electronic circuits to block the flow of direct current while

allowing alternating current to pass, to filter out interference, to smooth the output of power

supplies, and for many other purposes. They are used in resonant circuits in radio frequency

equipment to select particular frequencies from a signal with many frequencies.

Ceramic Capacitor:

Ceramic capacitors are constructed with materials such as titanium acid barium used as the

AIET/ECE/PR/015

Page 16: temperature controlled fan

Temperature controlled fan with display

dielectric. They can be used in high frequency applications. Typically, they are used in circuits

which bypass high frequency signals to ground.

These capacitors have the shape of a disk. Their capacitance is comparatively small.

The capacitor on the left is a 100pF capacitor with a diameter of about 3 mm.The capacitor on

the right side is printed with 103, so 10 x 103pF becomes 0.01 µF. The diameter of the disk is

about 6 mm.

Ceramic capacitors have no polarity Ceramic capacitors should not be used for analog circuits,

Because distort the signal

3.3LED

A light-emitting diode (LED) is an electronic light source. LEDs are used as indicator lamps in

many kinds of electronics and increasingly for lighting. LEDs work by the effect

of electroluminescence, discovered by accident in 1907. The LED was introduced as a practical

electronic component in 1962. All early devices emitted low-intensity red light, but modern

LEDs are available across the visible, ultraviolet and infra red wavelengths, with very high

brightness.

LEDs are based on the semiconductor diode. When the diode is forward biased.

LEDs present many advantages over traditional light sources including lower energy

consumption, longer lifetime, improved robustness, smaller size and faster switching. However,

they are relatively expensive and require more precise current and heat management than

traditional light sources.

Applications of LEDs are diverse. They are used as low-energy indicators but also for

replacements for traditional light sources in general lighting, automotive lighting and traffic

signals. The compact size of LEDs has allowed new text and video displays and sensors to be

developed, while their high switching rates are useful in communications technology

3.4 Relay

A relay is an electrical switch that opens and closes under the control of another electrical

circuit. In the original form, the switch is operated by an electromagnet to open or close one

or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to

AIET/ECE/PR/016

Page 17: temperature controlled fan

Temperature controlled fan with display

control an output circuit of higher power than the input circuit, it can be considered to be.

Fig 3.1 Sugar cube relay

3.5 LCD

A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or

monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a

column of liquid crystal molecules suspended between two transparent electrodes, and two

polarizing filters, the axes of polarity of which are perpendicular to each other. Without the

liquid crystals between them, light passing through one would be blocked by the other. The

liquid crystal twists the polarization of light entering one filter to allow it to pass through the

other.

Many microcontroller devices use 'smart LCD' displays to output visual information. LCD

displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use,

and it is even possible to produce a readout using the 8x80 pixels of the display. They

have a standard ASCII set of characters and mathematical symbols.

3.5.1Signals to LCD

1. Enable

This line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly

2.Read/write

This line allows access to the display through R/W and RS lines. When this line is low, the

LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks

the state of the two control lines and responds accordingly.

AIET/ECE/PR/017

Page 18: temperature controlled fan

Temperature controlled fan with display

3.6 Regulators

Battery balancing and battery redistribution refer to techniques that maximize a battery's

capacity to make all of its energy available for use and increase the battery's lifetime. A battery

balancer or battery regulator is a device in a battery pack that performs battery balancing.[1]

Balancers are often found in Lithium ion battery packs for cell phones and laptop computers.

They can also be found in battery electric vehicle battery packs.

Typically, the individual cells in a battery have somewhat different capacities and may be at

different levels of state of charge (SOC). Without redistribution, discharging must stop when

the cell with the lowest capacity is empty (even though other cells are still not empty); this

limits the energy that can be taken from and returned to the battery.

Without balancing, the cell of smallest capacity is a “weak point”, it can be easily overcharged

or over-discharged while cells with higher capacity undergo only partial cycle. For the higher

capacity cells to undergo full charge/discharge cycle of the largest amplitude, balancer should

“protect” the weaker cells; so that in a balanced battery, the cell with the largest capacity can be

filled without overcharging any other (i. e. weaker, smaller) cell, and it can be emptied without

over-discharging any other cell. Battery balancing is done by transferring energy from or to

individual cells, until the SOC of the cell with the lowest capacity is equal to the battery's SOC.

Battery redistribution is sometimes distinguished from battery balancing by saying the latter

stops at matching the cell's state of charge (SOC) only at one point (usually 100% SOC), so that

the battery's capacity is only limited by the capacity of its weakest cell.

A full battery management system (BMS) might include active balancing as well as

temperature monitoring, charging, and other features to maximize the life of a battery pack

AIET/ECE/PR/018

Page 19: temperature controlled fan

Temperature controlled fan with display

Fig 3.3 Battery Regulator

Voltage Regulator L7805 (regulator), usually having three legs, converts varying input voltage

and produces a constant regulated output voltage. They are available in a variety of outputs. 

 The most common part numbers start with the numbers 78 or 79 and finish with two digits

indicating the output voltage. The number 78 represents positive voltage and 79 negative one.

The 78XX series of voltage regulators are designed for positive input. And the 79XX series is

designed for negative input.  

Fig 3.4 Voltage regulator

3.7 Speed controllerTo control the speed of fan PWM TECHNIQUE is used.

3.7.1 PWM technique

AIET/ECE/PR/019

Page 20: temperature controlled fan

Temperature controlled fan with display

Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a modulation

technique that conforms the width of the pulse, formally the pulse duration, based on modulator

signal information. Although this modulation technique can be used to encode information for

transmission, its main use is to allow the control of the power supplied to electrical devices,

especially to inertial loads such as motors. In addition, PWM is one of the two principal

algorithms used in photovoltaic solar battery chargers,[1] the other being MPPT.

The average value of voltage (and current) fed to the load is controlled by turning the switch

between supply and load on and off at a fast pace. The longer the switch is on compared to the

off periods, the higher the power supplied to the load is

Normal case

Fig 3.5 For a pulse

Pulse width modulation

AIET/ECE/PR/020

Page 21: temperature controlled fan

Temperature controlled fan with display

Fig 3.6 High and low duty cycles.

3.8 L293D

The L293D is a popular motor driver IC that is usable from 6 to12V, at up to 1A total output current. By itself, the IC is somewhat difficult to wire and use, but the Compact L293D Motor Driver makes it much more convenient to use.

Board Special Features

Four motor direction indicator LEDS Schottky EMF-protection diodes Socket pin connectors for easy logic interfacing Enable pins are user accessible

Fig 3.7 L293D

3.9 ADC 0804

AIET/ECE/PR/021

Page 22: temperature controlled fan

Temperature controlled fan with display

ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single channel IC,

i.e., it can take only one analog signal as input. The digital outputs vary from 0 to a maximum

of 255. The step size can be adjusted by setting the reference voltage at pin9. When this pin is

not connected, the default reference voltage is the operating voltage, i.e., Vcc. The step size at

5V is 19.53mV (5V/255), i.e., for every 19.53mV rise in the analog input, the output varies by

1 unit. To set a particular voltage level as the reference value, this pin is connected to half the

voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2), thereby

reducing the step size to 15.62mV (4V/255).

ADC0804 needs a clock to operate. The time taken to convert the analog value to digital value

is dependent on this clock source. An external clock can be given at the Clock IN pin. ADC

0804 also has an inbuilt clock which can be used in absence of external clock. A suitable RC

circuit is connected between the Clock IN and Clock R pins to use the internal clock.

Fig 3.8 ADC0804

3.10 OptCoupler ILD 74

In electronics an opto-isolator, also called an optocoupler, photocoupler, or optical isolator, is

"an electronic device designed to transfer electrical signals by utilizing light waves to provide

AIET/ECE/PR/022

Page 23: temperature controlled fan

Temperature controlled fan with display

coupling with electrical isolation between its input and output". The main purpose of an opto-

isolator is "to prevent high voltages or rapidly changing voltages on one side of the circuit from

damaging components or distorting transmissions on the other side."Commercially available

opto-isolators withstand input-to-output voltages up to 10 kV and voltage transients with

speeds up to 10 kV.

FEATURES

• ILD74, ILQ74 TTL compatible

• Transfer ratio, 35 % typical

• Coupling capacitance, 0.5 pF

• Single, dual, and quad channel

• Industry standard DIP packages

• Compliant to RoHS Directive 2002/95/EC and

in accordance to WEEE 2002/96/EC

Fig 3.9 Opto-coupler ILD 74

Product information

OPTOCOUPLER, DUAL, TRANSISTOR O/P No. of Channels: 2 Isolation Voltage: 5.3kV Optocoupler Output Type: Phototransistor Input Current: 20mA Output Voltage: 20V Opto Case Style: DIP

AIET/ECE/PR/023

Page 24: temperature controlled fan

Temperature controlled fan with display

No. of Pins: 8 Current Transfer Ratio Min: 12.5% Current Transfer Ratio Typ: 12.5% Forward Current If(AV): 16mA Operating Temperature Max: 100°C Operating Temperature Min: -55°C Operating Temperature Range: -55°C to +100°C

The is an optically coupled pair with a Gallium Arsenide infrared LED and a silicon NPN

phototransistor. Signal information, including a DC level, can be transmitted by the device

while maintaining a high degree of electrical isolation between input and output. The IL74

is especially designed for driving medium-speed logic, where it may be used to eliminate

troublesome ground loop and noise problems. Also it can be used to replace relays and

transformers in many digital interface applications, as well as analog applications such as

CRT modulation. The ILD74 has two isolated channels in a single DIP package; the ILQ74

has four isolated channels per package

AIET/ECE/PR/024

Page 25: temperature controlled fan

Temperature controlled fan with display

CHAPTER 4

P89V51RD2 MICROCONTROLLER

4.1 Introduction

The P89V51RD21 is an 8051/8052-pin-compatible microcontroller by NXP (ex-Philips), with

64+8kB FLASH code memory, 768B internal RAM (ERAM/XRAM), 6-clock (x2) mode, and

a couple of extended peripherals, such as the PCA unit, SPI interface and watchdog counter.

The most remarkable feature is, however, that it's FLASH can be in-situ programmed (ISP)

through UART; and also its selfprogrammability (in-application programmability, IAP). The

P89V51RD2 is a successor to the successful P89C51RD+2/P89C51RD23 line, which

introduced the ISP/IAP paradigm to the higher-end FLASH-based 8-bit microcontrollers.

Microcontrollers with very features - 8051-pin-compatible, with up to 64kB of FLASH,

supporting IAP and ISP – are manufactured by multiple manufacturers, including NXP's own

P89C66x/P89V66x4, Atmel AT89C51RD2/AT89C51ED25 (successor to the Temic

T89C51RD2), Nuvoton (ex-Winbond) W78ERD2A6 and SST

SST89E564RD/SST89E516RD7. Some of them offer also a mix of models with less FLASH

(and Atmel also a model with 128kB FLASH, the AT89C51RE2) and 3V supply voltage.

However, although they are remarkably similar, they usually significantly differ in the IAP/ISP

method. Some even don't have factory-installed bootloader, even if they usually offer free

bootloader firmware and associated PC software. As Philips/NXP phased out the P89C51RD2

in favour of P89V51RD2, users started to complain about the rather different nature of the IAP

procedure in the latter. This made NXP to introduce the P89CV51RD28 and family, which,

although physically closer to the newer P89V51RD2, mimics closer the original IAP behaviour

of the older P89C51RD2.

AIET/ECE/PR/025

Page 26: temperature controlled fan

Temperature controlled fan with display

4.2 Family members

There are also modifications to P89V51RD2 offered by NXP, besides the three packaging

options (traditional DIP40 and PLCC44, and the miniscule TQFP44 with 0.8mm pin pitch).

Devices with less FLASH are marked as P89V51RB2 for 16kB FLASH and P89V51RC2 for

32kB FLASH. Low supply voltage (3V) devices are marked as "LV", such as in

P89LV51RD29. Unfortunately, NXP currently does not offer wide supply voltage devices in

this family. As most of the characteristics are the same across the whole family, often,

"cumulative" marking such as "P89V51Rx2" is used to denote any member of the family.

However, throughout this document,

"P89V51RD2" will be used consistently, marking also other members of the family as

appropriate. There were several versions of the P89V51RD2 datasheet issued by Philips/NXP.

To avoid confusion, it is always a good idea to download the latest one. At the time of writing

of this document, the latest datasheet is marked as "Rev.4 - 1. May 2007"10.

4.3 P89V51RD2 and ISP

One of the key moments of success of the P89V51RD2's predecessors was the ability to

program them in-situ through UART. This alleviated the need for a costly parallel device

programmer, or even a specialised programming "cable"; which made these microcontrollers

attractive for small enterprises and hobbyists, despite their higher price. It also allows easy

field-update of firmware from any PC or other device equipped with standard serial port.

The P89V51RD2 continued in this trend, although with a slightly different communication

protocol, and, more importantly, a different bootloader entry method. On the older models,

bootloader was entered when a particular set of voltage levels was applied to various pins

(including the PSEN/ pin). On P89V51RD2, after reset, the bootloader waits for a

predetermined time, until a "U" character (55h) arrives to the UART receiver. The datasheet

states this time as "approximately 400ms", however, as it is in fact derived from the watchdog,

this time is dependent on the system clock frequency, being around 400ms when fCLK is

approx. 3.5MHz; for other clock frequencies this time is proportionately shorter or longer. This

autobaud method has both its advantages and drawbacks. On one hand, it does not tie down any

pin and does not require any extra hardware nor manipulation with shorting jumpers or

AIET/ECE/PR/026

Page 27: temperature controlled fan

Temperature controlled fan with display

switches, as the old entry method did. On the other hand, in applications where an external

device sends continuous stream of data to the P89V51RD2's UART, upon reset, the bootlader

may be entered inadvertently. The extra delay before the application itself starts, may be a

hindrance in certain applications, too.

The autobauding process itself is not quite perfect either. It derives the UART's baudrate

coefficient by measuring the time between a trailing and a leading edge on the RxD pin (i.e.

duration of a "0" bit). It then starts the UART and waits for the "U" character. As the

"measurement" involves a certain granularity (uncertainty in the edges detection by bootloader

firmware), moreover on RS232/UARTs usually some small asymmetry between duration of 0s

and 1s exists, there is a chance of errorneous detection of baudrate, even if a crystal normally

allowing precise setting of a given baudrate is used11. The probability of correct baudrate

detection generally increases with lower baudrates, so the conservative recommendation is to

use 9600 Bauds or below, even if this may lead to increased programming times. To start the

autobauding, usually the P89V51RD2-containing device is simply powered up; however, in

some cases a simple circuit triggering reset from some of the handshake lines (RTS, DTR) is

built to the device, for added comfort. This then has to be handled by the PC-side software

accordingly. (Note, that FlashMagic by default assumes such hardware to be present, which

may cause unexpected behaviour of FM if this hardware is absent).

The ISP protocol is entirely ASCII based, and uses intelhex-like "records" to perform various

FM (except for the response during FLASH readout, which can perhaps be described as "raw

ascii hexadecimal with spaces"). This allows to use as a PC-side programming utility any

general-purpose terminal emulator, such as the ubiquitous Hyperterminal, or Tera Term12 on

Windows, or minicom13 on Linux/Unix-like OS. Autobauding can be performed "by hand",

pressing and holding down the "U" key and relying on the keyboards autorepeat, while

resetting the target device. Commands for device identification (which serves as the successful

autobauding verification) and erasing can be either "typed in", or "uploaded" from a previously

prepared file, if needed. The FLASH content itself, as it is programmed using the "normal" type

00 intelhex fields, found in the .hex files output from compilers and assemblers, can be simply

"uploaded" from these files; to allow time for programming, an inter-line delay of some 100ms

has to be set. Even if possible, the above described "manual" method is rather tedious and may

serve only as a backup emergency method of programming. The standard PC-side application

AIET/ECE/PR/027

Page 28: temperature controlled fan

Temperature controlled fan with display

for programming is FlashMagic (by ESAcademy)14. There is also a FlashMagic forum15, with

an extensive bootloading troubleshooting list16.

4.4 Characteristics of FLASH in P89C51RD2

The code FLASH in P89C51RD2 consists of two big blocks:

- Block0, 64kB, mapped at 0000h-0FFFFh, intended to run the "normal" user application.

- Block1, 8kB, mapped at 0000h-1FFFh, containing the bootloader.

As the two blocks overlap in the 0000h-1FFFh area, which of them is "visible" is determined

by two bits in the FCF special function register. The FLASH can be written byte-by-byte. As is

usual with FLASH, bytes have to be erased prior to be written. An erased byte contains 0FFh.

FLASH can be erased by 128-byte sectors (pages), or by a whole block (using an external

parallel device programmer, a third method, full chip erase, is also possible - this erases both

blocks, the x2 flag and the security flag in one operation). During writing/erasing, execution is

not possible, so the code writing to Block0 must reside in Block1 (i.e. the bootloader code has

to be called to perform the write/erase in Block0).

The datasheet states endurance as 10.000 cycles and retention to 100 years, which together with

the relatively small sector size makes the FLASH suitable for ocassionally rewritten data

storage (EEPROM replacement e.g. for device setup parameters). The datasheet completely

fails to specify erase and write times... Note, that the datasheet specifies a minimum clock

frequency, 0.25MHz, for in-application programming. The datasheet does not specify supply

current during programming, but a safety margin of a few tens of mA over the specified

"normal" supply current, and decent supply decoupling, could never hurt.

According to the datasheet, there is a single (non-volatile) security bit, preventing reading of

the FLASH using parallel programmer. This bit can be set both by parallel programmer and

during ISP or IAP. This bit does not influence device readout through ISP (which has an

independent security mechanism, basedon a "serial number", see below), nor IAP.

4.5 IAP

In-application programming (IAP) of Block0 FLASH in P89V51RD2 is performed through

setting up a couple of registers, and making a call to a predetermined address - 1FF0h - in

Block1. This, and a list of possible operations together with the related registers (Table 13,

AIET/ECE/PR/028

Page 29: temperature controlled fan

Temperature controlled fan with display

which we are not going to reproduce here, and the reader is requested to study it thoroughly), is

roughly all the datasheet says about IAP. The reality is somewhat more complex. As said

above, the code performing programming of FLASH Block0 has to run from Block1. This is

why the IAP routines are part of the default bootloader in Block1. So, to be able to run these

routines, Block1 must be mapped as active at the lower part of code address space, 0000h-

1FFFh. This is accomplished through clearing both SWR and BSEL bits in FCF special

function register. Note, that this step has two consequences:- the code "switching" the blocks

(i.e. clearing both mentioned SFR bits) must lie above the "shared" area, i.e. within 2000h-

FFFFh. It is handy therefore to create a short routine, which handles the FLASH block

switching and the IAP entry point (1FF0h) call - see CallIAP routine in the example below –

and locate it at some suitable high address. As it is with absolutely located routines, it must be

made sure, that it is not overlapped with some other routine. In most applications, a location

near the top of the available FLASH might be a suitable place. - before the blocks switching,

interrupts must be disabled. After blocks switching, the interrupt vector area at the beginning of

code address space is occupied by Block1, with the default bootloader. As the default

bootloader has no provisions for interrupt handling, any interrupt which would occur while

Block1 is "visible", would execute some random code, leading to crash. After return from the

IAP routines, Block0 can be restored by setting BSEL bit (SWR bit is supposed to be set only

by hardware), after which interrupts may be reenabled. Using IAP, any byte in Block0 can be

programmed, including the 0000h-1FFFh area. Care has to be practiced, of course, if areas with

"living" code are programmed or erased, including the interrupt vector area. However, only

bytes which contain 0xFF (i.e. which are erased) may be programmed. This means, that if a

non-0xFF byte has to be reprogrammed, the 128-byte sector where this byte is located has to be

erased. If other bytes in this sector have to be preserved, they must be stored into RAM

(ERAM) before erasing and then reprogrammed back to that sector. The IAP "protocol"

contains confusing commands, too. There is a command for block 0 erase, which is a complete

nonsense, as the routine calling IAP would be erased, too, and there would be no code to return

to (an effective "suicide" of the application"). There is also a command for byte read, which is

much easier to perform using some of the MOVC instructions. Note also, that the datasheet

does not specify resources used by the IAP routines. Even if these can be determined by

disassembling the bootloader, there is no guarantee these will not change in some future

AIET/ECE/PR/029

Page 30: temperature controlled fan

Temperature controlled fan with display

versions. Some of the potentially problematic issues include:- stack usage - the IAP routines

perform at least two nested calls, so a conservative approach would be to reserve around 10

bytes of stack for the IAP- register usage - a conservative approach would assume that all

registers R0-R7 of the current bank, B and DPTR are changed bye IAP routines - memory and

SFR usage - it is unlikely that the IAP calls would use any memory and/or SFR (except the

FLASH interface SFRs, which are undocumented anyway) - sensitivity to register bank setting,

and possible change to it - if the bootloader code would use absolute addressed registers, it

would be sensitive to the particular register bank at the moment of IAP call. A conservative

approach would be to stick to register bank 0 when calling IAP routines.

However, it is unlikely that the IAP routines would actively change the bank. - sensitivity to

DPTR selection, and possible change to it - it is unlikely that the IAP routines would be

sensitive to which DPTR is currently selected. It is also unlikely they would change the DPTR

selection or modify the other than currently selected DPTR. Timing of the IAP routines is also

not specified. Read commands are certainly served within several tens of instruction cycles, but

programming commands take certainly more time. A conservative estimate would be, that

programming a single byte takes a couple of milliseconds, whereas a sector erase might take

tens of milliseconds, and a block erase up to several seconds. Timing of IAP routines, i.e. the

time while the mcu is essentially out of the user's control, has to be taken into account not only

for timer-based operations (including the PCA), but also for UART operation and SPI slave

operations. Handshaking with the other-side device has to be employed wherever applicable.

Another timing-sensitive issue is the watchdog, which has to be served just before and after the

IAP call, or, if this is insufficient, disabled during IAP (although disabling watchdog is

generally a bad idea).

4.6 Pin description

Port 0: Port 0 is an 8-bit open drain bi-directional I/O port. Port 0 pins that have ‘1’s written to

them float, and in this state can be used as high-impedance inputs. Port 0 is also the

multiplexed low-order address and data bus during accesses to external code and data memory.

In this application, it uses strong internal pull-ups when transitioning to ‘1’s. Port 0 also

receives the code bytes during the external host mode programming, and outputs the code bytes

AIET/ECE/PR/030

Page 31: temperature controlled fan

Temperature controlled fan with display

during the external host mode verification. External pull-ups are required during program

verification or as a general purpose I/O port.

Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 pins are

pulled high by the internal pull-ups when ‘1’s are written to them and can be used as inputs in

this state. As inputs, Port 1 pins that are externally pulled LOW will source current (IIL)

because of the internal pull-ups. P1.5, P1.6, P1.7 have high current drive of 16 mA. Port 1

also receives the low order address bytes during the external host mode programming and

verification.

AIET/ECE/PR/031

Page 32: temperature controlled fan

Temperature controlled fan with display

Fig.4.1: Pin diagram of microcontroller P89V51RD2

T2: External count input to Timer/Counter 2 or Clock-out from Timer/Counter 2.

T2EX: Timer/Counter 2 capture/reload trigger and direction control.

AIET/ECE/PR/032

Page 33: temperature controlled fan

Temperature controlled fan with display

ECI: External clock input. This signal is the external clock input for the PCA.

CEX0: Capture/compare external I/O for PCA Module 0. Each capture/compare module

connects to a Port 1 pin for external I/O. When not used by the PCA, this pin can

handle standard I/O.

SS: Slave port select input for SPI.

CEX1: Capture/compare external I/O for PCA Module 1.

MOSI: Master Output Slave Input for SPI.

CEX2: Capture/compare external I/O for PCA Module 2.

MISO: Master Input Slave Output for SPI.

CEX3: Capture/compare external I/O for PCA Module 3.

SCK: Master Output Slave Input for SPI.

CEX4: Capture/compare external I/O for PCA Module 4.

Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 pins are pulled

HIGH by the internal pull-ups when ‘1’s are written to them and can be used as inputs in this

state. As inputs, Port 2 pins that are externally pulled LOW will source current (IIL) because of

the internal pull-ups. Port 2 sends the high-order address byte during fetches from external

program memory and during accesses to external Data Memory that use 16-bit address. In this

application, it uses strong internal pull-ups when transitioning to ‘1’s. Port 2 also receives some

control signals and a partial of high-order address bits during the external host mode

programming and verification.

Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. Port 3 pins are pulled

HIGH by the internal pull-ups when ‘1’s are written to them and can be used as inputs in this

state. As inputs, Port 3 pins that are externally pulled LOW will source current (IIL) because of

the internal pull-ups. Port 3 also receives some control signals and a partial of high-order

address bits during the external host mode programming and verification.

RXD: serial input port

TXD: serial output port

INT0: external interrupt 0 input

INT1: external interrupt 1 input

T0: external count input to Timer/Counter 0

T1: external count input to Timer/Counter 1

AIET/ECE/PR/033

Page 34: temperature controlled fan

Temperature controlled fan with display

WR: external data memory write strobe

RD: external data memory read strobe

Program Store Enable: PSEN is the read strobe for external program memory. When the

device is executing from internal program memory, PSEN is inactive (HIGH). When the device

executing code from external program memory, PSEN is activated twice each machine cycle,

except that two PSEN activations are skipped during each access to external data memory. A

forced HIGH-to-LOW input transition on the PSEN pin while the RST input is continually held

HIGH for more than 10 machine cycles will cause the device to enter external host mode

programming. RST 9 4 10 I Reset: While the oscillator is running, a HIGH logic state on this

pin for two machine cycles will reset the device. If the PSEN pin is driven by a HIGH-to-LOW

input transition while the RST input pin is held HIGH, the device will enter the external host

mode, otherwise the the device will enter the normal operation mode.

External Access Enable: EA must be connected to VSS in order to enable the device to fetch

code from the external program memory. EA must be strapped to VDD for internal program

execution. However, Security lock level 4 will disable EA, and program execution is only

possible from internal program memory. The EA pin can tolerate a high voltage of 12 V. ALE/

PROG 30 27 33 I/O Address Latch Enable: ALE is the output signal for latching the low byte

of the address during an access to external memory. This pin is also the programming pulse

input (PROG) for flash programming. Normally the ALE is emitted at a constant rate of 1¤6

the crystal frequency and can be used for external timing and clocking. One ALE pulse is

skipped during each access to external data memory. However, if AO is set to ‘1’, ALE is

disabled.

Crystal 1: Input to the inverting oscillator amplifier and

input to the internal clock generator circuits.

Crystal 2: Output from the inverting oscillator amplifier.

AIET/ECE/PR/034

Page 35: temperature controlled fan

Temperature controlled fan with display

CHAPTER 5

CODING

4.0 Coding

sfr P0=0x80;

sfr P1=0x80;

sfr P1=0x90;

sfr P2=0xA0;

sfr P3=0xB0;

sbit relay = P1^0;

Sbit inc = P1^1;

sbit dec = P1^2;

#define adcdata P3

sbit intr = P2^2; //5

sbit rd =P2^0; //2

sbit wr =P2^1; //3

sbit rs = P2^5;

sbit rw = P2^6;

sbit en = P2^7;

unsigned char line[4] = {0x80,0xC0,0x90,0xD0};

#define DBUS P0

#define BLINKLCD 0x09

#define ONCURSOR 0x0A

#define ONLCD 0x0C

#define CLEARLCD 0x01

#define HOMELCD 0x02

AIET/ECE/PR/035

Page 36: temperature controlled fan

Temperature controlled fan with display

#define ENTRYMODE 0x06

#define FUNCSET 0x38

void wrlcd_cmd(unsigned char cmd );

void wrlcd_data(unsigned char Data );

void delay(unsigned int count);

void wrmsg(char LineNo,char endloc, unsigned char msg[]);

void getdata();

static unsigned char sp=0;

code unsigned char scr5[2] [16] = {" Temp: ", " SP: "};

code unsigned char scr1[2] [16] = {" JAY Patel " " BSPP 2nd SHIFT "};

void main( )

{

unsigned char i;

unsigned char x,d1,d2,d3,val,a=0;;

P3=0xff;

P0=0x00;

P2=0x0f;

relay=0;

wrlcd_cmd(FUNCSET); //set data length,no of disp,2-line display

wrlcd_cmd(ONLCD); //display and cursor on

wrlcd_cmd(ENTRYMODE); //inc. DDram address,

wrlcd_cmd(CLEARLCD); //Clear display

for(i=0;i<2;i++)

{

delay(100);

wrmsg(line[i],16,scr1[i]);

}

for(i=0;i<15;i++)

AIET/ECE/PR/036

Page 37: temperature controlled fan

Temperature controlled fan with display

delay(50000);

for(i=0;i<2;i++)

{

delay(100);

wrmsg(line[i],16,scr5[i]);

}

while(1)

{

wr=0;

delay(100);

wr=1;

while(intr != 1);

while(intr != 0);

rd=0;

delay(10);

val=adcdata;

rd=1;

wrlcd_cmd(line[0]+9);

x=val/10;

d1=val%10;

d2=x%10;

AIET/ECE/PR/037

Page 38: temperature controlled fan

Temperature controlled fan with display

d3=x/10;

wrlcd_data(d3+0x30);

delay(10);

wrlcd_data(d2+0x30);

wrlcd_data(d1+0x30);

delay(10);

a=(d3*100)+(d2*10)+d1;

wrlcd_data('C');

wrlcd_cmd(line[1]+9);

wrlcd_data((sp/10)+0x30);

wrlcd_data((sp%10)+0x30);

if(inc==0)

{

while(inc==0);

sp++;

}

if( (dec==0) && sp>0 )

while(dec==0);

sp--;

}

if(a>sp)

relay=1;

AIET/ECE/PR/038

Page 39: temperature controlled fan

Temperature controlled fan with display

else

relay=0;

delay(25000);

}

}

void wrlcd_cmd(unsigned char cmd)

{

DBUS = cmd;

delay(10);

rs = 0; //select cmd reg

delay(10);

rw = 0; //write mode

delay(10);

en = 1;

delay(300);

en = 0;

delay(20);

}

void wrlcd_data(unsigned char Data )

{

DBUS = Data;

delay(10);

rs = 1; //select data reg

delay(10);

AIET/ECE/PR/039

Page 40: temperature controlled fan

Temperature controlled fan with display

rw = 0;

delay(10);

en = 1;

delay(300);

en = 0;

delay(10);

rs = 0;

delay(20);

}

void wrmsg(char LineNo,char endloc, unsigned char msg[])

{

unsigned char i;

wrlcd_cmd(LineNo);

for(i =0;i<=endloc;i++)

{

wrlcd_data(msg[i]);

delay(50);

}

}

void delay(unsigned int dly)

{

while(dly>0)

dly--;

}

AIET/ECE/PR/040

Page 41: temperature controlled fan

Temperature controlled fan with display

RESULT

We have successfully completed the project. It is now in full working position. On connecting it to a 12 v battery and providing the required temperature specifications as given, the fan can automatically turn on and off, varying from the range of -450 C to 1200 C. The temperature sensing is being done by the LM35 and the fan is being driven by the stepper motor attached to it which drived the speed of the fan as per the requirement and the temperature changes.

Through this project we got to learn many more in the depth starting from the designing of the PCB to the final running of the project, and working as a team was extremely fabulous experience, sharing thoughts and knowledge at the same time and assisting each other in the best possible way we could. Also implementing our engineering learning’s ws a good experience.

AIET/ECE/PR/041

Page 42: temperature controlled fan

Temperature controlled fan with display

APPLICATION

1. For cooling fans of laptop and personal computers more efficiently and don’t taking any

risk as soon as the temperature rises. Generally fan in pc and laptops comes with two or

three possible speeds that results in more power consumptions. So temperature

controlled fan can accomplish that job efficiently.

2. In trains where power is wasted due to ignorant passengers

3. In public halls like community halls.

4. Useful for physically challenged people.

5. Useful for automatic control in places where temperature varies frequently with day and

night means those close to shore and sandy areas.

AIET/ECE/PR/042

Page 43: temperature controlled fan

Temperature controlled fan with display

FUTURE DEVELOPMENT

1. It can lead to the saving of enormous power and thus reduce the extra expenditure done of the power in our country thereby raising the economy of our country.

2. It can also be charged with solar cells when used in open areas and thus prove to be very efficient.

3. It can be used for several automation purposes.4. It can lead to automation in trains and metros.

AIET/ECE/PR/043

Page 44: temperature controlled fan

Temperature controlled fan with display

CONCLUSION

We did the project with a fan with fixed speed and fixed PWM duty cycle for 10 degree

centigrade interval from 25 to 65 degree Celsius. Care should be taken that such delays should

not affect the open loop control system performance. Temperature should not vary abruptly

otherwise it would degrade the performance of the system and the fan as a whole.

In conclusion, the objective to build an the temperature controlled fan was successfully

achieved. In terms of performance and efficiency, this project has provided a convenient

method. This system is also a user friendly system However, some further improvements can

be made on this in order to increase its reliability and effectiveness.

AIET/ECE/PR/044

Page 45: temperature controlled fan

Temperature controlled fan with display

REFERENCES

1. http://researchgate.net/publication/235598499_automation - /file/d91.pdf

2. http://seminarprojects.com/s/TCF

3. http://psocrfid.blogspot.in/2011/4/TCF

4. http://dnatechindia.com/projects

5. http://wikipedia/components_tempcontrolled fan

6. http://wikipedia/microcontroller

AIET/ECE/PR/045

Page 46: temperature controlled fan

Temperature controlled fan with display

COST

S. No. Name of Components Cost (Rs.)

1 P89V51RD2 Microcontroller 2502 LCD Display 1503 ADC 1104 Potentiometer 55 Fan with DC motor 206 L293D 407 5V Adapter 1508 12 V Adapter 2009 Resistors 1010 Capacitors 2011 Copper plate 2012 Connecting wires 1013 Soldering wire 1014 Glossy papers 1015 Total cost 925

AIET/ECE/PR/046

Page 47: temperature controlled fan

Temperature controlled fan with display

AIET/ECE/PR/047