+ All Categories
Home > Documents > 31[1].Temparature Control Fan

31[1].Temparature Control Fan

Date post: 16-Jul-2015
Category:
Upload: tejaspathi-lv
View: 45 times
Download: 0 times
Share this document with a friend

of 64

Transcript

HITAM

TEMPERATURE CONTROLLED FAN

INDEX1. INTRODUCTION 1.1. OBJECTIVE OF THE PROJECT 1.2. EMBEDDED SYSTEM 1.3. BLOCK DIAGRAM 2. DESCRIPTION OF THE PROJECT 2.1. CIRCUIT DIAGRAM 2.2. WORKING DESCRIPTION 3. HARDWARE DESCRIPTION 3.1. MICROCONTROLLER 3.2. POWER SUPPLY 3.3. LM 35 3.4. ADC 0804 3.5. MAX 232 3.6.RELAY 4. SOFTWARE DESCRIPTION 4.1. FLOW CHART 4.2. ASSEMBLY/ KEILC LANGUAGE PROGRAM 5.CONCLUSION

6. BIBLIOGRAPHY

Page 1

HITAM

TEMPERATURE CONTROLLED FAN

1.INTRODUCTION:1.1. OBJECTIVE OF THE PROJECT.

Temperature controlled Fan (AT89C52)

This Project is used to control the Fan speed according to the temperature and it also indicates the temperature. The system will get the temperature from the IC (LM35) and it will control the speed according the values stored by the user. The System is fully controlled by the microcontroller AT89C52. It is a popular 8 bit microcontroller. The circuit consists of four switches, in which two buttons are used to increment and decrement the temperature value and the next button is to edit the temperature values stored it in the memory and the other button is cancel button.

Page 2

HITAM

TEMPERATURE CONTROLLED FAN

HARDWARE: 1. 2. 3. 4. 5. 6. 8052 MICROCONTROLLER. LM 35 (Temperature Sensor). ADC 0804. MAX 232. DB-9 CONNECTOR. RELAY

Page 3

HITAM

TEMPERATURE CONTROLLED FAN

1.2 BLOCK DIAGRAM:

LM35 Temp Sensor

ADC0804

89C52 MICROCONTROLLER

RELAY

PERSONAL COMPUTER PC MAX232 FAN

SIMULATION: TOOL: KEIL MICROVISION PLATFORM: WINDOWS LANGUAGE: EMBEDDED C

Page 4

HITAM

TEMPERATURE CONTROLLED FAN

1.3 EMBEDDED SYSTEMS:DEFINITIONS:Embedded system is a combination of hardware and software, it is also named as Firm ware. An embedded system is a special purpose computer system, which is completely encapsulated by the device it controls. It is a computer-controlled system

An embedded system is a specialized system that is a part of a larger system or machine. As a part of a larger system it largely determines its functionality. Embedded systems are electronic devices that incorporate microprocessors with in their implementations. The main purpose of the microprocessors are simplify the system design and improve flexibility. In the embedded systems, the software is often stored in a read only memory (RAM) chip.

Embedded systems provide several major functions including monitoring of the analog environment by reading data from sensors and controlling actuators.

Inputs (sensor)

Embedded System

Outputs(actuator)

Figure 2.1 a real time system interacts with environment

Page 5

HITAM

TEMPERATURE CONTROLLED FAN

EXAMPLES OF EMBEDDED SYSTEMS:

Embedded systems are found in wide range of application areas. Originally they were used only for expensive industrial control applications, but as technology brought down the cost of dedicated processors, they began to appear in moderately expensive applications such as automobiles, communication and office equipments and television Today's embedded systems are so inexpensive that they are used in almost every electronic product in our life. Embedded systems are often designed for mass production. Some examples of embedded systems: Automatic Teller Machines Cellular telephone and telephone switches Computer network equipment Computer printers Disk drives Engine controllers and antilock break controllers for automobiles Home automation products Handheld calculators Household appliances Medical equipment Measurement equipment Multifunction wrist watches

Page 6

HITAM Multifunction printers

TEMPERATURE CONTROLLED FAN

Mobile phones with additional capabilities

MICROPROCESSOR AND MICROCONTROLLERMicroprocessors and microcontrollers are used in embedded system products. An embedded product uses a microprocessor (or microcontroller) to do one task and one task only.

Microprocessor as the term come to be known is a general purpose digital computer central processing unit. Although popularly known as a "computer on chip", the microprocessor is in no sense a complete digital computer.

Microprocessor CPU contains Arithmetic Logical Unit, a program counter, a stack pointer, some working registers, a clock timing circuits and interrupt circuit.

To make complete microcomputer memory must add, usually Read Only Memory, Random Access Memory, memory decoders and an Input/Output devices. In addition special purpose devices such as interrupts, counters may be added to relieve the CPU from time consuming counting or timing chores.

The hardware design of microprocessor CPU is arranged so that a small or very large system can be configured around the CPU as the application demands. The internal

Page 7

HITAM

TEMPERATURE CONTROLLED FAN

CPU architecture as well as the resultant machine level code that operates that architecture is comprehensive but as flexible as possible.

The prime use of microprocessor is to read data perform extensive calculations on that data and store those calculations in mass storage devices or display the results for user use. The program is used by microprocessor are stored in the mass storage devices and loaded into RAM as the user directs.

A microcontrollers is a computer on a single chip .Micro suggest that the device is small and controller tells that the device is used to control objects, process or events

Microcontroller is a highly integrated chip that contains all the devices comprising a computer. Typically this includes a CPU, RAM, Input/ Output ports, timers, interrupts. So microcontroller is also called as "true computer on a chip". Unlike a general purpose computer which also includes all of these devices. A microcontroller is designed for a very specific task to control a particular system.

The advantages of microcontroller over microprocessor are cost is less speed is more power consumption is less compact device

Page 8

HITAM

TEMPERATURE CONTROLLED FAN external components are minimum

2.1 Operating ProcedureAC 230 Volts 50Hz is connected to the primary. Secondary of transformer is a 12-0-12V. A rectifier converts AC to DC, but the DC output is varying. There are several types of rectifiers; here we use a bridge rectifier. here the bridge rectifier is connected to transformer . For smoothing d.c a capacitor is connected with transformer .Regulator eliminates ripple by setting DC output to a fixed voltage .Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltage these are connected transformer. LM35 is the temperature sensor used to sense the temperature .The ADC0804 IC is used which is an analog-to-digital converter in the family of the ADC800 series from National Semiconductors. It works with 5V and as a resolution of 8 bits in addition to resolution; conversion time is another major factor in judging an ADC .these are connected to the power supply AT89C52 is used here which provides the following standard features: 8Kbytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry Serial communication between PC and microcontroller is done by using MAX232.Here the connections are given as per circuit diagram shown in 2.2 When the power supply is on at a particular temperature of 45 degrees motor increases fan speed increases. start rotating .when the temperature to the

Page 9

HITAM

TEMPERATURE CONTROLLED FAN

2.2 CIRCUIT DIAGRAM

Page 10

HITAM

TEMPERATURE CONTROLLED FAN

3. HARD WARE DESCRIPTION:3.1 MICROCONTROLLER:A BRIEF HISTORY OF 8051

In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. this microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial port, and four ports all on a single chip. At the time it was also referred as A SYSTEM ON A CHIP

The 8051 is an 8-bit processor meaning that the CPU can work only on 8 bits data at a time. Data larger than 8 bits has to be broken into 8 bits pieces to be processed by the CPU. The 8051 has a total of four I\O ports each 8 bit wide.

There are many versions of 8051 with different speeds and amount of on-chip ROM and they are all compatible with the original 8051. this means that if you write a program for one it will run on any of them.

The 8051 is an original member of the 8051 family. There are two other members in the 8051 family of microcontrollers. They are 8052 and 8031. All the three microcontrollers will have the same internal architecture, but they differ in the following aspects. 8031 has 128 bytes of RAM, two timers and 6 interrupts.

Page 11

HITAM

TEMPERATURE CONTROLLED FAN 8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts. 8052 has 8K ROM, 128 bytes of RAM, three timers and 8 interrupts.

Of the three microcontrollers, 8051 is the most preferable. Microcontroller supports both serial and parallel communication.

In the concerned project 8052 microcontroller is used. Here microcontroller used is AT89C52, which is manufactured by ATMEL laboratories.

Description of 8951 Microcontroller

The AT89C52 provides the following standard features: 8Kbytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89C52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power down Mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications.

Page 12

HITAM

TEMPERATURE CONTROLLED FAN

Features of Microcontroller (8052)

Compatible with MCS-51 Products 8 Kbytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-Level Program Memory Lock 256 x 8-Bit Internal RAM 32 Programmable I/O Lines Three 16-Bit Timer/Counters Eight vector two level Interrupt Sources Programmable Serial Channel Low Power Idle and Power Down Modes

Page 13

HITAM

TEMPERATURE CONTROLLED FAN

BLOCK DIAGRAM OF MICRO CONTROLLER

Page 14

HITAM

TEMPERATURE CONTROLLED FAN

: Figure 5.1 Block Diagram Of 8052

Pin Configurations:Page 15

HITAM

TEMPERATURE CONTROLLED FAN

Figure : Pin Diagrams of 8952

Pin Description: VCC Pin 40 provides Supply voltage to the chip. The voltage source is +5v

GND. Pin 20 is the grounded

Port 0

Page 16

HITAM

TEMPERATURE CONTROLLED FAN

Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. 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 may 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 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups from pin 1 to 8. 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.

Port 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28. 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,

Page 17

HITAM

TEMPERATURE CONTROLLED FAN

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 it 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 from pin 10 to 17. 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 AT89C51 as listed below:

Page 18

HITAM

TEMPERATURE CONTROLLED FAN

Table : Special Features of 89C5

Port 3 also receives some control signals for Flash programming and programming verification.

RST Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities. A high on this pin for two machine cycles while the oscillator is running resets the device.

ALE/PROG Address Latch is an output pin and is active high. Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In

Page 19

HITAM

TEMPERATURE CONTROLLED FAN

normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN Program Store Enable is the read strobe to external program memory. When the AT89C52 is 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.

EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.

XTAL1

Page 20

HITAM

TEMPERATURE CONTROLLED FAN

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2 Output from the inverting oscillator amplifier.

Oscillator Characteristics:

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on chip oscillator, as shown in Figure 5.3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure.

Figure : crystal connections

Page 21

HITAM

TEMPERATURE CONTROLLED FAN

Figure :External Clock Drive Configuration

There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

TIMERS: Timer 0 and 1 Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in the AT89C51.

Timer 2 Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 5.2. Timer 2

Page 22

HITAM

TEMPERATURE CONTROLLED FAN

consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

Table : Timer 2 Operating Modes

In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle. There are no restrictions on the duty cycle of external input signal, but it should for at least one full machine to ensure that a given level is sampled at least once before it changes

Page 23

HITAM

TEMPERATURE CONTROLLED FAN

Interrupts:The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all shown in Figure 5.5

Figure 5.5 Interrupts source Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once.

Note that Table 5.3 shows that bit position IE.6 is unimplemented. In the AT89C51, bit position IE.5 is also unimplemented. User software should not write 1s to these bit positions, since they may be used in future AT89 products.

Page 24

HITAM

TEMPERATURE CONTROLLED FAN

Table 5.3 Interrupts Enable Register

Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored To. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software.

The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows. Page 25

HITAM

TEMPERATURE CONTROLLED FAN

Idle Mode:In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.

Power down Mode:In the power down mode the oscillator is stopped, and the instruction that invokes power down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. The only exit from power down is a hardware reset. Reset redefines the SFRs but does not change the onchip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

Page 26

HITAM

TEMPERATURE CONTROLLED FAN

Table 5.3 Status of External Pins During Idle and Power Down Mode

Program Memory Lock BitsOn the chip are three lock bits which can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the table 5.4. When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value, and holds that value until reset is activated. It is necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.

Table 5.4 Lock Bit Protection Modes

Page 27

HITAM

TEMPERATURE CONTROLLED FAN

Programming the Flash

The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low voltage programming mode provides a convenient way to program the AT89C51 inside the users system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers.

The AT89C51 is shipped with either the high-voltage or low voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table.

Table : Top side marking and Device Signature Codes

The AT89C52 code memory array is programmed byte-by-byte in either programming mode. To program any non-blank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode.

Page 28

HITAM

TEMPERATURE CONTROLLED FAN

Programming Algorithm

Before programming the AT89C52, the address, data and control signals should be set up according to the Flash programming mode table and Figures 3 and 4. To program the AT89C52, take the following steps.

1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12 V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The bytewrite cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.

Data PollingThe AT89C52 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written datum on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

Page 29

HITAM

TEMPERATURE CONTROLLED FAN

Ready/BusyThe progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.

Program VerifyIf lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.

Chip EraseThe entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all "1"s. The chip erase operation must be executed before the code memory can be reprogrammed.

Page 30

HITAM

TEMPERATURE CONTROLLED FAN

Reading the Signature BytesThe signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a Logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 51H indicates 89C51 (032H) = FFH indicates 12 V programming (032H) = 05H indicates 5 V programming

Programming InterfaceEvery code byte in the Flash array can be written and the entire array can be erased by using the appropriate combination of control signals. The write operation cycle is self-timed and once initiated, will automatically time itself to completion.

Page 31

HITAM

TEMPERATURE CONTROLLED FAN

Page 32

HITAM

TEMPERATURE CONTROLLED FAN

3.2. POWER SUPPLY:There are many types of power supply. Most are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. For example a 5V regulated supply can be shown as below

F i : Block Diagram of a Regulated Power Supply System g

Similarly, 12v regulated supply can also be produced by suitable selection of the individual elements. Each of the blocks is described in detail below and the power supplies made from these blocks are described below with a circuit diagram and a graph of their output:

Page 33

HITAM

TEMPERATURE CONTROLLED FAN

Transformer: A transformer steps down high voltage AC mains to low voltage AC. Here we are using a center-tap transformer whose output will be sinusoidal with 36volts peak to peak value.

Fig: Output Waveform of transformer The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for electronic circuits unless they include a rectifier and a smoothing capacitor. The transformer output is given to the rectifier circuit. Rectifier: A rectifier converts AC to DC, but the DC output is varying. There are several types of rectifiers; here we use a bridge rectifier. The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite ends of the bridge. The load resistance is connected between the other two ends of the bridge. For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance RL and hence the load current flows through RL.

Page 34

HITAM

TEMPERATURE CONTROLLED FAN

For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load resistance RL and hence the current flows through RL in the same direction as in the previous half cycle. Thus a bi-directional wave is converted into unidirectional.

Fig: The output waveform of the rectifier is shown as below

The

varying

DC

output

is suitable for lamps, heaters and standard motors. It is not suitable for electronic circuits unless they include a smoothing capacitor.

Page 35

HITAM

TEMPERATURE CONTROLLED FAN

Smoothing: The smoothing block smoothes the DC from varying greatly to a small ripple. The ripple voltage is defined as the deviation of the load voltage from its DC value. Smoothing is also named as filtering. Filtering is frequently effected by shunting the load with a capacitor. The action of this system depends on the fact that the capacitor stores energy during the conduction period and delivers this energy to the loads during the no conducting period. In this way, the time during which the current passes through the load is prolongated, and the ripple is considerably decreased. The action of the capacitor is shown with the help of waveform.

Fig:

The waveform of the rectified output after smoothing is given below:

Page 36

HITAM Regulator:

TEMPERATURE CONTROLLED FAN

REGULATER: Regulator eliminates ripple by setting DC output to a fixed voltage.Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. Negative voltage regulators are also available Many of the fixed voltage regulator ICs has 3 leads (input, output and high impedance). They include a hole for attaching a heat sink if necessary. Zener diode is an example of Fixed regulator which is shown here.

REGULATOR Transformer + Rectifier + Smoothing + Regulator:

Page 37

HITAM

TEMPERATURE CONTROLLED FAN

3.3 TEMPERATURE SENSOR: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 +150C 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 selfheating, less than 0.1C in still air. The LM35 is rated to operate over a -55 to +150C temperature range, while the LM35C is rated for a -40 to +110C range (-10 with improved accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, 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.

Page 38

HITAM

TEMPERATURE CONTROLLED FAN

FEATURES: Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guarantee able (at +25C) Rated for full -55 to +150C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 A current drain Low self-heating, 0.08C in still air Non-linearity only C typical Low impedance output, 0.1 Ohm for 1 mA load

Why to Use L35s to Measure Temperature?

You can measure temperature more accurately than a using a thermistor. The sensor circuitry is sealed and not subject to oxidation, etc. The LM35 generates a higher output voltage than thermocouples and may not require that the output voltage be amplified.

Page 39

HITAM

TEMPERATURE CONTROLLED FAN

What Does An LM35 Look Like?

What Does an LM35 Do? How does it work? It has an output voltage that is proportional to the Celsius temperature. The scale factor is .01V/oC The LM35 does not require any external calibration or trimming and maintains an accuracy of +/-0.4 oC at room temperature and +/- 0.8 oC over a range of 0 oC to +100 oC.

Page 40

HITAM

TEMPERATURE CONTROLLED FAN Another important characteristic of the LM35DZ is that it

draws only 60

micro amps from its supply and possesses a low self-

heating capability. The sensor self-heating causes less than 0.1 oC temperature rise in still air. The LM35 comes in many different packages, including the following. TO-92 plastic transistor-like package, T0-46 metal can transistor-like package

What Can You Expect When You Use An LM35?You will need to use a voltmeter to sense Vout. The output voltage is converted to temperature by a The sensor has a sensitivity of 10mV / oC. Use a conversion factor that is the reciprocal that is

simple conversion factor. 100V / oC. The general equation used to convert output voltage to temperature is: Temperature ( oC) = Vout * (100 oC/V) So if Vout is 1V , then, Temperature = 100 oC The output voltage varies linearly with temperature.

Page 41

HITAM

TEMPERATURE CONTROLLED FAN

How Do You Use An LM35? (Electrical Connections)Here is a commonly used circuit. For connections refer to the picture above. In this circuit, parameter values commonly used are: Vc = 4 to 30v 5v or 12 v are typical values used. Ra = Vc /10-6 Actually, it can range from 80 KW to 600 KW ,

Page 42

HITAM

TEMPERATURE CONTROLLED FAN

Here is a LM 35 wired on a circuit board. The white wire in to the power supply. Both the resistor and the black wire go to ground. The output voltage is measured from the middle pin to ground 1

3.4 ADC DEVICE (0804):

Analog-to-digital converters are among the most widely used devices for data acquisition. Digital. Computers use binary (discrete) values, but in the physical world everything is analog (continuous). Temperature, pressure, humidity, and velocity are a few examples of physical quantities that we deal with every day. Physical quantity is converted to electrical (voltage, current) signals using a device called a transducer. Transducers are also referred to as sensors. Although there are sensors for temperature, velocity, pressure, light, and many other natural quantities, they produce an output that is voltage (or current). Therefore, we need an analog-to-digital converter to translate the analog signals to digital numbers so that the micro controller can read them.

FEATURES: Compatible with 8080 P derivativesno interfacing logic needed 135 ns Easy interface to all microprocessors, or operates stand alone Differential analog voltage inputs

access time

Page 43

HITAM o o o o

TEMPERATURE CONTROLLED FAN

Logic inputs and outputs meet both MOS and TTL Voltage level specifications Works with 2.5V (LM336) voltage reference On-chip clock generator 0V to 5V analog input voltage range with single 5V supply No zero adjust required 0.3 standard width 20-pin DIP package 20-pin molded chip carrier or small outline package

FUNCTIONAL DESCREPTION:The ADC0804 IC is an analog-to-digital converter in the family of the ADC800 series from National Semiconductors. It works with 5V and as a resolution of 8 bits in addition to resolution; conversion time is another major factor in judging an ADC. Conversion time is defined as the time it takes the ADC to convert the analog input to a digital (binary) number. In the ADC 0804, the conversion time varies depending on the clocking signals apply to the CLK R and CLK IN pins, but it cannot be faster than 110 micro seconds.

PIN DIAGRAM:

Page 44

HITAM

TEMPERATURE CONTROLLED FAN

PIN DESCRIPTION:

CS:Chip select is an active low input used to activate the ADC 0804 chip. To accesses the ADC 0804, this pin must be low.

RD:

Page 45

HITAM

TEMPERATURE CONTROLLED FAN This is an input signal and is active low. The ADC converts the

analog input to its binary equivalent and holds it in an internal register. RD is used to get the converted data out of the ADC 0804 chip. When CS=0, if a high to low pulse is applied to RD pin, the 8 bit digital output shows up at the D0-D7 data pins. The RD pin is also referred to as output enable.

WR:This is an active low input used to inform the ADC 0804 to start the conversion process. If CS=0 when WR makes a low to high transition, the ADC 0804 starts converting the analog input value of Van to an 8 bit digital number the amount of time it takes to convert it varies depending on the CLK IN and CLK R values. When the data conversion is complete, the ADC 0804 forces the INTR pin low.

CLK IN and CLK R:CLK IN is an input pin connected to an external clock source when an external clock is used for timing. However the 0804 have an internal clock generator. To use the internal clock generator of the ADC 0804, the CLK IN and CLK R pins are connected to a capacitor and resistor, in that case the clock frequency is determined by the equation F= 1/1.1 R

INTR:This is an output pin and is active low. It is a normally high pin and when the conversion is finished, it goes low to signal the CPU that the converted data is ready t be picked up. After INTR goes low, we make CS=0 and send a high to low pulse to the RD pin t get the data out of the ADC 0804 chip.

Page 46

HITAM

TEMPERATURE CONTROLLED FAN

Vin (+) and Vin (-):This are the differential analog inputs where Vin= Vin (+)Vin(-). Often the Vin () connected to ground and the Vin (+) pin used as the analog input to the converted to digital.

VCC:This is the +5V power supply. It is also used as a reference voltage when the Vref/2 Vcc: input is open (not connected).

D0-D7:D0-D7 (whereD7is the MSB, D0 the LSB) is the digital data output pins. These are tri state buffered and the converted data is accessed only CS=0 and RD is forced low. To calculate the output voltage, use the following formula. Dout =Vin/step size

ANALOG AND DIGITAL GROUNDThese are the input pins providing the ground for both analog signal and digital signal and the digital signal. Analog ground is connected to the ground and of the analog Vin while digital ground is connected to the ground of Vcc pin. The reason that we have two ground pins is to isolate the analog vin signal from transient voltages caused by digital switching of the

Page 47

HITAM

TEMPERATURE CONTROLLED FAN

digital data output. D0-D7. Such isolation contributes to the accuracy of digital data output 1. 2. Make CS=0 and send a low to high pulse to pin WR to start the Keep monitoring the INTR pin. If INTR is low, low, the conversion and we can go the next step. If INTR is high, keep polling

conversion. is finished until goes low. 3. After the INTR has become low, we make CS=0 and send a high to low pulse to the RD pin to get the data out of the ADC 0804 IC chip.

3.5 Serial communication between PC and microcontroller:

When a processor communicates with the outside world, it provides data in byte sized chunks. Computers transfer data in two ways: parallel and serial. In parallel data transfers, often more lines are used to transfer data to a device and 8 bit data path is expensive. The serial communication transfer uses only a single data line instead of the 8 bit data line of parallel communication which makes the data transfer not only cheaper

Page 48

HITAM

TEMPERATURE CONTROLLED FAN

but also makes it possible for two computers located in two different cities to communicate over telephone. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers data at a time while the asynchronous transfers a single byte at a time. There are some special IC chips made by many manufacturers for data communications. These chips are commonly referred to as UART (universal asynchronous receiver-transmitter) and USART (universal synchronous asynchronous receiver transmitter). The AT89C51 chip has a built in UART. In asynchronous method, each character is placed between start and stop bits. This is called framing. In data framing of asynchronous communications, the data, such as ASCII characters, are packed in between a start and stop bit. We have a total of 10 bits for a character: 8 bits for the ASCII code and 1 bit each for the start and stop bits. The rate of serial data transfer communication is stated in bps or it can be called as baud rate. To allow the compatibility among data communication equipment made by various manufacturers, and interfacing standard called RS232 was set by the Electronics industries Association in 1960. Today RS232 is the most widely used I/O interfacing standard. This standard is used in PCs and numerous types of equipment. However, since the standard was set long before the advent of the TTL logic family, its input and output voltage levels are not TTL compatible. In RS232, a 1 bit is represented by -3 to -25V, while a 0 bit is represented +3 to +25 V, making -3 to +3 undefined. For this reason, to connect any RS232 to a microcontroller system we must use voltage converters such as MAX232 to connect the TTL logic levels to RS232 voltage levels and vice versa. MAX232 ICs are commonly referred to as line drivers.

Page 49

HITAM

TEMPERATURE CONTROLLED FAN

The RS232 cables are generally referred to as DB-9 connector. In labeling, DB-9P refers to the plug connector (male) and DB-9S is for the socket connector (female). The simplest connection between a PC and microcontroller requires a minimum of three pin, TXD, RXD, and ground. Many of the pins of the RS232 connector are used for handshaking signals. They are bypassed since they are not supported by the 8051 UART chip.

IBM PC/ compatible computers based on x86(8086, 80286, 386, 486 and Pentium) microprocessors normally have two COM ports. Both COM ports have RS232 type connectors. Many PCs use one each of the DB-25 and DB-9 RS232 connectors. The COM ports are designated as COM1 and COM2. We can connect the serial port to the COM 2 port of a PC for serial communication experiments. We use a DB9 connector in our arrangement. The AT89C52 has two pins that are used specifically for transferring and receiving data serially. These two pins are called TXD and RXD and are part of the port3 (P3.0 and P3.1). These pins are TTL compatible; therefore they require a line driver to make them RS232 compatible. One such line driver is the MAX232 chip. One advantage of MAX232 chip is that it uses a +5v power source which is the same as the source voltage for the at89c51. The MAX232 has two sets of line drivers for receiving and transferring data. The line drivers for TXD are called T1 and T2 while the line drivers for RXD are

Page 50

HITAM

TEMPERATURE CONTROLLED FAN

designated as R1 and R2. T1 and R1 are used for TXD and RXD of the 89c51 and the second set is left unused. In MAX232 that the TI line driver has a designation of T1 in and T1 out on pin numbers 11 and 14, respectively. The T1 in pin is the TTL side and is connected to TXD of the microcontroller, while TI out is the RS232 side that is connected to the RXD pin of the DB9 connector. To allow data transfer between PC and the microcontroller system without any error, we must make sure that the baud rate of the 8051 system matches the baud rate of the PCs COM port.

3.6. RELAYOverviewA relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be ON or OFF so relays have two switch position and they are double throw (changeover) switches.

Page 51

HITAM

TEMPERATURE CONTROLLED FAN Relays allow one circuit to switch a second circuit which can be completely

separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits; the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) can not provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relay with 4 sets of changeover contacts are readily available. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. The supplier's catalogue should show you the relay's connection. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil.

The relays switch connections are usually contains COM, NC and NO. COM = Common, always connect to this; it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on. Connect to COM and NO if you want the switched circuit to be on when the relay coil is on.

Page 52

HITAM

TEMPERATURE CONTROLLED FAN

Connect to COM and NC if you want the switched circuit to be on when the relay coil is off. Most relays are SPDT or DPDT which are often described as "single pole changeover" (SPCO) Or "double pole changeover"(DPCO).

This is a Single Pole Double Throw relay. Current will flow between the movable contact and one fixed contact when the coil is energized and between the movable contact and the alternate fixed contact when the relay coil is energized. The most commonly used relay in car audio, the Bosch relay, is a SPDT relay..

This relay is a Double Pole Double Throw relay. It operates like the SPDT relay but has twice as many contacts. There are two completely isolated sets of contacts.

Page 53

HITAM

TEMPERATURE CONTROLLED FAN

Relay Construction:Relays are amazingly simple devices. There are four parts in every relay:

Electromagnet Armature that can be attracted by the electromagnet Spring Set of electrical contacts A relay consists of two separate and completely independent circuits. The

first is at the bottom and drives the electromagnet. In this circuit, a switch is controlling power to the electromagnet. When the switch is on, the electromagnet is on, and it attracts the armature. The armature is acting as a switch in the second circuit. When the electromagnet is energized, the armature completes the second circuit and the light is on. When the electromagnet is not energized, the spring pulls the armature away and the circuit is not complete. In that case, the light is dark. When you purchase relays, you generally have control over several variables:

The voltage and current that is needed to activate the armature The maximum voltage and current that can run through the armature and the The number of armatures (generally one or two) The number of contacts for the armature (generally one or two -- the relay shown Whether the contact (if only one contact is provided) is normally open (NO) or

armature contacts

here has two, one of which is unused)

normally closed (NC)

Page 54

HITAM

TEMPERATURE CONTROLLED FAN

Relay Applications:In general, the point of a relay is to use a small amount of power in the

electromagnet coming, say, from a small dashboard switch or a low-power electronic circuit-- to move an armature that is able to switch a much larger amount of power. For example, you might want the electromagnet to energize using 5 volts and 50 milliamps (250 mill watts), while the armature can support 120V AC at 2 amps (240 watts).

Relays are quite common in home appliances where there is an electronic control turning on something like a motor or a light. They are also common in cars, where the 12V supply voltage means that just about everything needs a large amount of current. In later model cars, manufacturers have started combining relay panels into the fuse box to make maintenance easier. In places where a large amount of power needs to be switched, relays are often cascaded. In this case, a small relay switches the power needed to drive a much larger relay, and that second relay switches the power to drive the load. Relays can also be used to implement Boolean logic.

Advantages of Relay: Relays can switch AC and DC, transistors can only switch DC. Relays can switch high voltages, transistors cannot. Relays are a better choice for switching large currents (> 5A). Relays can switch many contacts at once.

Page 55

HITAM

TEMPERATURE CONTROLLED FAN

4.SOFTWARE DESCRIPTION 4.1 FLOW CHART SOURCE CODE: #include //port 0 for reading data from ADC // sbit READ=P2^0; sbit WRITE=P2^1; sbit INTI=P2^2; ///////////////////////////////////LCD PINS//////////////////////////////////////// sfr LCDDATA=0X90;//PORT 1 sbit RS=P2^5; sbit RW=P2^6; sbit EN=P2^7; sbit fan=P3^7; delay(unsigned int); fan_delay(unsigned char ); lcdcmd(unsigned char); lcddata1(unsigned char); lcddata(); unsigned char DATA,c,d,flag=0;Page 56

HITAM

TEMPERATURE CONTROLLED FAN

void main(void) { float r1; int r2,r3,a,d,d3,d2,b,p; fan=0; INTI=1; READ=1; WRITE=1; IE=0X82; lcdcmd(0x38); lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x82); lcddata();

while(1) { lcdcmd(0xc6); WRITE=0; WRITE=1; if(INTI==1) {Page 57

HITAM

TEMPERATURE CONTROLLED FAN

READ=0; r1=P0; READ=1; }

r1=r1*(0.01953); r2=r1*1000; r3=r2; d3=r2/100; a=d3%10; lcddata1(a); d=r2%10; lcddata1(d); ////// . to send////////////// lcddata1('.'); d2=p%100; b=d2%10; b=b+48; //third digit lcddata1(b); lcddata1('C');Page 58

HITAM

TEMPERATURE CONTROLLED FAN

lcdcmd(0x0C);

/************** 40-55 speed1 56


Recommended