Sie sind auf Seite 1von 66

CHAPTER-1 INTRODUCTION

Every system is automated in order to face new challenges in the present day situation. Automated systems have less manual operations, so that the flexibility, reliabilities are high and accurate. Automation is intended to reduce manpower with the help of intelligent system. Hence every field prefers automated control systems. Especially in the field of electronics automated systems are doing better performance. Now a days in many homes there is a unnecessary usage of power with fans whether there be a normal temperature we use fan speed high because of manual operations i.e., why to overcome those problems we are doing automated system temperature dependent dc fan speed control. Base on the temperature dc fan speed can be controlled. Hence here we should use automatic control system which saves our manpower and money & also highest accuracy.

1.1 OBJECTIVES:
It measures the room temperature and the temperature is displayed in the LCD and then it vary the speed accordingly

1.2 EXISTING MODEL:


At present we use voltage regulators which are used manually to alter the speed of fan

1.3 EMBEDDED SYSTEM:


An embedded system is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few predefined tasks, usually with very specific requirements. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost

of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Personal digital assistants (PDAs) or handheld computers are generally considered embedded devices because of the nature of their hardware design, even though they are more expandable in software terms. This line of definition continues to blur as devices expand. With the introduction of the OQO Model 2 with the Windows XP operating system and ports such as a USB port both features usually belong to "general purpose computers", the line of nomenclature blurs even more. Physically, embedded systems ranges from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. In terms of complexity embedded systems can range from very simple with a single microcontroller chip, to very complex with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

1.4 Examples of Embedded Systems:


Avionics, such as inertial guidance systems, flight control hardware/software and other integrated systems in aircraft and missiles Cellular telephones and telephone switches Home automation products, such as thermostats, air conditioners, sprinklers, and security monitoring systems Medical equipment Personal digital assistant Videogame consoles Computer peripherals such as routers and printers. Industrial controllers for remote machine operation

CHAPTER-2 BLOCK DIAGRAM


2.1BLOCK DIAGRAM

POWER SUPPLY A D C 0 8 0 8

MICRO CONTROLLER

LCD DISPLAY (16 X 2 LINES)

TEMP SENSOR

A T 8 9 S 5 2
DRIVER DC FAN

Fig 2.1 Block diagram

2.2 FUNCION OF THE BLOCK DIAGRAM:


Power Supply:
This section is meant for supplying Power to all the sections mentioned above. It basically consists of a Transformer to step down the 230V ac to 9V ac followed by diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to regulate the obtained dc voltage.

Microcontroller:
This section forms the control unit of the whole project. This section basically consists of a Microcontroller with its associated circuitry like Crystal with capacitors, Reset circuitry, Pull up resistors (if needed) and so on. The Microcontroller forms the heart of the project because it controls the devices being interfaced and communicates with the devices according to the program being written.

LCD Display:
This section is basically meant to show up the status of the project. This project makes use of Liquid Crystal Display to display / prompt for necessary information.

ADC (0808):
ADC is a device converting signals from analog to digital format. This is used to convert the sensor values which are in analog format to digital form and provide it to microcontroller.

LM35:
LM35 are a temperature sensing devise. It is used to sense the temperature. In this project by depends on the value of temperature the exhaust fan will run.

H-Bridge (Motor Driver):


Each H-Bridge has two inputs. Micro controller gives input to H-Bridge to control the direction of the motor. Based on the given inputs to the H-Bridge, the motor will be rotates either in clock-wise or in anti-clock wise direction. So that the movement of the motor will be control

2.3 SCHEMATIC:

Fig 2.3(a) schematic diagram

SCHEMATIC DESCRIPTION:
Firstly, the required operating voltage for Microcontroller 89S52 is 5V. Hence the 5V D.C. power supply is needed by the same. This regulated 5V is generated by first stepping down the 230V to 18V by the step down transformer. In the both the Power supplies the step downed a.c. voltage is being rectified by the Bridge Rectifier. The diodes used are 1N4007. The rectified a.c voltage is now filtered using a C filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator. This voltage regulator allows us to have a Regulated Voltage. In Power supply given to Microcontroller 5V is generated using 7805 and in other two power supply 12V is generated using 7812. The rectified; filtered and regulated voltage is again filtered for

ripples using an electrolytic capacitor 100F. Now the output from the first section is fed to 40th pin of 89S52 microcontroller to supply operating voltage and from other power supply to circuitry. The microcontroller 89S52 with Pull up resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with couple of capacitors of is placed at 18 th & 19th pins of 89S52 to make it work (execute) properly. Port 0: P0 is connected to the input pins of the L293D (Motor Driver) Port 1: P1 is connected to address lines ,EOC,SC and OE of ADC Port 2: P2 is connected to ADC data output lines D0-D7 Port 3: P3 is connected to LCD

2.4 ADVANTAGES:
Since it is automated system it is programmed effectively so that no interruption would stop its functionality. To monitor the environments that is not comfortable or possible for humans. Prevents waste of energy when its not hot enough for a fan to be needed. To assist people who are disabled to adjust the fan speed automatically.

2.5 APPLICATIONS:
Personal computers Exhaust fans in large hotels Washing machines CD and DVD players

CHAPTER-3 HARDWARE DESCRIPTION


3.1 AT89S52 (MICROCONTROLLER):
The Atmel AT89S52 provides the following standard features: 8K bytes of downloadable Flash, 2K bytes of EEPROM, 256 bytes of RAM, 32 I/O lines, programmable watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 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 external interrupt or hardware reset.

3.1.1 Features of Atmel AT89s52 are as follows: Compatible with MCS-51 Products 8K Bytes of In-System Reprogrammable Downloadable Flash Memory 2K Bytes EEPROM 4V to 6V Operating Range 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 Interrupt Sources Programmable UART Serial Channel SPI Serial Interface Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Programmable Watchdog Timer Dual Data Pointer Power-off Flag

3.1.2 PIN CONFIGURATION:

Fig 3.1.1Pin Configuration

Fig 3.1.2 IC AT89S8252

Pin Number 1 2 3

Description Port 1.0 - T2 Port 1.1 T2 EX Port 1.2 Port1

Pin Number 21 22 23

Description Port 2.0 A8 Port 2.1 A9 Port 2.2 A10

4 5

Port 1.3 Port1 Port 1.4 Port1

24 25

Port 2.3 A11 Port 2.4 A12

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Port 1.5 MOSI Port 1.6 MISO Port 1.7 SCK RST Port 3.0 RXD Port 3.1 TXD Port 3.2 INT0 Port 3.3 INT1 Port 3.4 T0 Port 3.5 T1 Port 3.6 WR Port 3.7 RD XTAL2 Crystal XTAL1 - Crystal GND

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

Port 2.5 A13 Port 2.6 A14 Port 2.7 A 15 PSEN ALE/PROG EA/VPP Port 0.7 AD7 Port 0.6 AD6 Port 0.5 AD5 Port 0.4 - AD4 Port 0.3 AD3 Port 0.2 AD2 Port 0.1 AD1 Port0.0 AD0 VCC

Table 3.1.a AT89S52 pin description

3.1.3 Pin Description:

VCC - Supply voltage. GND - Ground. Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order address bytes during Flash programming and verification.

Table 3.1.b Alignment of port1 Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being

10

pulled low will source current (IIL) because of the internal pull-ups. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.

Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table.

Table 3.1.c Alignment of port3

RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG:

11

Address Latch Enable (ALE) is an 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 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 (PSEN) is the read strobe to external program memory. When the AT89S51 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. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2: Output from the inverting oscillator amplifier. Oscillator Characteristics:

12

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 Figs 6.2.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 6.2.4.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 flipflop, but minimum and maximum voltage high and low time specifications must be observed.

Fig 3.1.3 Oscillator Connections Configuration

Fig 3.1.4 External Clock Drive

3.2 Power supply:

13

Fig 3.2(a) components of LPS The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronic circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D.C Power Supply

3.2.1 Step down Transformer:


A transformer is an electrical device which is used to convert electrical power from one electrical circuit to another without change in frequency. Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down transformers decrease in output voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the

14

turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.

Fig 3.2(b) Step-Down Transformer

Fig 3.2(c) Step-Up Transformer Transformers are classified as: (a) Based on position of the windings with respect to core i.e. 1) Core type transformer 2) Shell type transformer (b) Transformation ratio: 1) Step up transformer 2) Step down transformer 15

a)Core & shell types:


Transformer is simplest electrical machine, which consists of windings on the laminated magnetic core. There are two possibilities of putting up the windings on the core. 1) Winding encircle the core in the case of core type transformer 2) Cores encircle the windings on shell type transformer.

b) Step up and Step down:


In these voltage transformation takes place according to whether the primary is high voltage coil or a low voltage coil. 1) Lower to higher-> Step up 2) Higher to lower-> Step down

3.2.2 BRIDGE RECTIFIER:


A circuit which is used to convert ac to dc is known as RECTIFIER. The process of conversion ac to dc is called rectification

TYPES OF RECTIFIERS:
Half wave Rectifier Full wave rectifier 1. Centre tap full wave rectifier. 2. Bridge type full wave rectifier. Comparison of rectifier circuits: Parameter Half wave Type of Rectifier Full wave Bridge

16

Number of diodes 1 PIV of diodes Vm 2Vm Vm 2 4

Vdc (no load )

Vm/

2Vm/

2Vm/

Ripple factor Output Frequency

1.21

0.482

0.482

2f

2f

Efficiency Transformer Utilization Factor(TUF) Peak factor

0.406

0.812

0.812

0.287

0.693

0.812

Table 3.2.1 Comparison of rectifier circuits

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally. A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig (a) to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally.

17

Fig 3.2(d) Bridge arrangement

Operation:
During positive half cycle of secondary, the diodes D2 and D3 are in forward biased while D1 and D4 are in reverse biased as shown in the fig(b). The current flow direction is shown in the fig (b) with dotted arrows.

Fig 3.2(e) Positive cycle During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward biased while D2 and D3 are in reverse biased as shown in the fig(c). The current flow direction is shown in the fig (c) with dotted arrows.

18

Fig 3.2(f) Negative cycle

3.2.3 Filter Capacitor:


A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load. Ripples can be removed by one of the following methods of filtering. (a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the d.c.to appears the load. (b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c) (c) Various combinations of capacitor and inductor, such as L-section filter section

filter, multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier. Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value).

19

Fig 3.2(g) Filter Capacitor In our circuit we are using 1000F. Hence large value of capacitor is placed to reduce ripples and to improve the DC component.

3.2.4 Voltage Regulator:


Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulators ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.

20

Fig 3.2(h) A Three Terminal Voltage Regulator

3.2.5 IC LM7805:78XX:
The 78xx (also sometimes known as LM78xx) series of devices is a family of selfcontained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular choice for many electronic circuits which require a regulated power supply, due to their ease of use and relative cheapness. When specifying individual ICs within this family, the xx is replaced with a two-digit number, which indicates the output voltage the particular device is designed to provide (for example, the 7805 has a 5 volt output, while the 7812 produces 12volts). The 78xx line are positive voltage regulators, meaning that they are designed to produce a voltage that is positive relative to a common ground. There is a related line of 79xx devices which are complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to provide both positive and negative supply voltages in the same circuit, if necessary.

Features:
Output Current of 1.5A Internal thermal overload protection Internal Short-Circuit Limited

21

No External Component Output Voltage 5.0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V Direct Replacement for LM78XX

3.3 LM35 (Temperature Sensor):


Temperature Sensor which converts temperature value into electrical signals.We used IC called LM 35 as a temperature sensor. LM35 series sensors are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to the Celsius temperature. The LM35 requires no external calibration since it is internally calibrated. . The LM35 does not require any external calibration or trimming to provide typical accuracies of 14C at room temperature and 34C over a full 55 to +150C temperature range. The LM35s low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 A from its supply, it has very low self-heating, less than 0.1C in still air. LM35 is precision integrated circuit temperature sensor. Its output voltage is linearly proportional to temperature(in celsius). The LM35 thus has anadvantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 14C at room temperature and 34C over a full 55 to +150C temperature range It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 A from its supply, it has very low self-heating, less than 0.1C in still air.

22

Fig 3.3(a): Temperature Sensor

Features:
Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guaranteed (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 Nonlinearity only 14C typical

Characteristics:

23

For each degree of centigrade temperature it outputs 10milli volts.ADC accepts the output from LM35 and converts that data into digital form which is sent to microcontroller for further processing.

3.4 ADC MODULE


ADC is short for Analog Digital Converter, Sometimes called a A-D or A to D Converter. An ADC is a device that converts a continuous analog signal to a multi-level digital signal without altering its content. The signals that are monitored are sounds, movement, and temperature into binary code for the PC. (or) Analog to digital (A/D, ADC) converters are electrical circuit devices that convert continuous signals, such as voltages or currents, from the analog domain to the digital domain where the signals are represented by numbers Most processing equipment today are digital in nature, and they work with signals which are binary valued. In a digital or binary representation, a signal is represented by a word, which is composed of a finite number of bits. The processing of signals is preferably carried out in the digital domain because digital processing is fast, accurate and reliable. Analog to digital converters are widely used for converting analog signals to corresponding digital signals for many electronic circuits. Analog to digital converters allow the use of sophisticated digital signal processing systems to process analog signals, which are common in the real world. Many modern electronic systems require conversion of signals from analog to digital or from digital to analog form. Circuits for performing these functions are now required in numerous common consumer devices such as digital cameras, cellular telephones, wireless data network equipment, audio devices such as MP3 players, and video equipment such as digital video disk (DVD) players, high definition digital television (HDTV), and numerous other products. Analog to digital converters (ADC's) form an essential link in the signal processing pathway at the interface between the analog and digital domains. Advances in ADC technology have

24

increased the speed, lowered the cost, and reduced the power requirements of analog to digital converters, and resulted in a proliferation of ADC applications. Conversion involves quantizing and encoding. Quantizing means partitioning the analog signal range into a number of discrete quanta and determining to which quantum the input signal belongs. Encoding means assigning a unique digital code to each quantum and determining the code that corresponds to the input signal. The most common system is binary, in which there are 2n quanta (where n is some whole number), numbered consecutively; the code is a set of n physical two-valued levels or bits (1 or 0) corresponding to the binary number associated with the signal quantum. The illustration shows a typical three-bit binary representation of a range of input signals, partitioned into eight quanta. For example, a signal in the vicinity of 3/8; full scale (between 5/16 and 7/16) will be coded 011 (binary 3).

Fig 3.4(a): A three-bit binary representation of a range of input signals

Applications of ADC:
Digital camera or scanner uses A/D converters to transform the variable charges in CCD and CMOS chips into the binary data that represent pixels. Cell phone and digital desk phone has an ADC converter that converts the pressure of sound waves into PCM code Etc. 3.4.1 ADC0808: This is 8-Bit P Compatible A/D Converters with 8-Channel Multiplexer. The ADC0808 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter,8-channel multiplexer and microprocessor compatible Control logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The converter features a high impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree and a successive approximation register. 25

The 8-channel multiplexer can directly access any of 8-single-ended analog signals. The device eliminates the need for external zero and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL TRI-STATE outputs.

Features:
Easy interface to all microprocessors Operates ratio metrically or with 5 VDC or analog span adjusted voltage reference No zero or full-scale adjust required 8-channel multiplexer with address logic 0V to 5V input range with single 5V power supply Outputs meet TTL voltage level specifications ADC0808 equivalent to MM74C949 ADC0809 equivalent to MM74C949-1

3.4.2 FUNCTIONAL DESCRIPTION:


The ADC0808 shown in figure can be functionally divided into 2 basic sub circuits. These two sub circuits are an analog multiplexer and an A/D converter. The multiplexer uses 8 standard CMOS analog switches to provide to up to 8 analog inputs. The switches are selectively turned on, depending on the data latched into a 3-bit multiplexer address register. The second functional block, the successive approximation A/D converter, transforms the analog output of the multiplexer to an 8-bit digital word. The output of the multiplexer goes to one of two comparator inputs. The other input is derived from a 256R resistor ladder, which is tapped by a MOSFET transistor switch tree. The converter control logic controls the switch tree, funneling a particular tap voltage to comparator. Based on the result of this comparison, the control logic and the successive approximation register (SAR) will decide whether the next tap to be selected should be higher or lower than the present tap on the resistor ladder. This algorithm is executed 8 times per conversion, once every 8-clock period, yielding a total conversion time of clock periods. 26

When the conversion cycle is complete the resulting data is loaded into the TRISTATE output latch. The data in the output latch can be then be read by the host system any time before the end of the next conversion. The TRI-STATE capability of the latch allows easy interfaces to bus oriented systems. The operation on these converters by a microprocessor or some control logic is very simple. The controlling device first selects the desired input channel. To do this, a 3bit channel address is placed on the A, B, C in and out pins; and the ALE input is pulsed positively, clocking the address into the multiplexer address register. To begin the conversion, the START pin is pulsed. On the rising edge of this pulse the internal registers are cleared and on the falling edge the start conversion is initiated. As mentioned earlier, there are 8 clock periods per approximation. Even though there is no conversion in progress the ADC0808 is still internally cycling through these 8 clock periods. A start pulse can occur any time during this cycle but the conversion will not actually begin until the converter internally cycles to the beginning of the next 8 clock period sequence. As long as the start pin is held high no conversion begins, but when the start pin is taken low the conversion will start within 8 clock periods. The EOC output is triggered on the rising edge of the start pulse. It, too, is controlled by the 8 clock period cycle, so it will go low within 8 clock periods of the rising edge of the start pulse. One can see that it is entirely possible for EOC to go low before the conversion starts internally, but this is not important, since the positive transition of EOC, which occurs at the end of a conversion, is what the control logic is looking for. Once EOC does go high this signals the interface logic that the data resulting from the conversion is ready to be read. The output enable(OE) is then raised high. This enables the TRI-STATE outputs, allowing the data to be read. Figure shows the timing diagram.

27

CONTROL

MUX address register

CONTROL LOGIC

SAR 8x1 analog MUX TRISTATE Output Latch

Fig 3.4(b) : Functional block diagram of ADC

3.4.3 PIN DIAGRAM:

Fig 3.4(c): Pin Diagram of ADC 0808

28

SC (Chip Selection):
By using this selection Bit you can select the Chip. After selecting this bit the chip is ready to do operation. By using HIGH (1) you can select the this pin as a active high.

ALE (Address Latch Enable):


ALE is to enable address latch of ADC, so that the selected channel is activated. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency, and can be used for external timing or clocking. Note that one ALE pulse is skipped during each access to external data memory. This pin is also the Program Pulse input (PROG) during Flash programming.

EOC (End of Conversion):


After End of ADC Conversion EOC bit is set to high.

CHANNEL SELECTION:

Tabel 3.4.1 Selection of channel

29

CONNECTION DIAGRAM:
SC IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7 ALE EOC CHA CHB

ADC

EMBEDDED CONTROLLER

CHC

Data(D0-D7)

Fig 3.4(d): Interfacing of ADC 0808 to micro controller

Fig 3.4(e): Timing Diagram of ADC

30

3.5 LCD (Liquid Crystal Display) 16 * 2 Alphanumeric LCD Description


Liquid crystal display is very important device in embedded system. It offers high flexibility to user as he can display the required data on it. A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals (LCs). LCs do not emit light directly. LCDs therefore need a light source and are classified as "passive" displays. Here the lcd has different memories to display data, those are discussed below. Liquid crystal displays (LCD s) have materials which combine the properties of both liquids and crystals. Rather than having a melting point, they have a temperature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped together in an ordered form similar to a crystal. An LCD consists of two glass panels, with the liquid crystal material sand witched in between them. The inner surface of the glass plates are coated with transparent electrodes which define the character, symbols or patterns to be displayed polymeric layers are present in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to maintain a defined orientation angle. One each polarisers are pasted outside the two glass panels. These polarisers would rotate the light rays passing through them to a definite angle, in a particular direction When the LCD is in the off state, light rays are rotated by the two polarisers and the liquid crystal, such that the light rays come out of the LCD without any orientation, and hence the LCD appears transparent. When sufficient voltage is applied to the electrodes, the liquid crystal molecules would be aligned in a specific direction. The light rays passing through the LCD would be rotated by the polarisers, which would result in activating / highlighting the desired characters. The LCDs are lightweight with only a few millimeters thickness. Since the LCDs consume less power, they are compatible with low power electronic circuits, and can be powered for long durations.

31

The LCD s wont generate light and so light is needed to read the display. By using backlighting, reading is possible in the dark. The LCDs have long life and a wide operating temperature range. Changing the display size or the layout size is relatively simple which makes the LCDs more customer friendly. The LCD s used exclusively in watches, calculators and measuring instruments is the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCD s being extensively used in telecommunications and entertainment electronics. The LCD s has even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV applications.

3.5.1 LCD operation:


In recent years the LCD is finding widespread use replacing LED s (seven-segment LED or other multi segment LED s). This is due to the following reasons: 1. The declining prices of LCD s. 2. The ability to display numbers, characters and graphics. This is in contract to LED s, which are limited to numbers and a few characters. 3. Incorporation of a refreshing controller into the LCD, there by relieving the CPU of the task of refreshing the LCD. In the contrast, must be refreshed by the CPU to keep displaying the data. 4. Ease of programming for characters and graphics. the LED

3.5.2 LCD pin description:


The LCD discussed in this section has 14 pins. The function of each pin is given in table.

32

Pin 1 2 3 4

symbol Vss Vcc VEE RS

I/O ---I

Description Ground +5V power supply Power supply to control contrast RS=0 to select command register RS=1 to select data register R/W=0 for write

5 6 7 8 9 10 11 12 13 14

R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7

R/W=1 for read I/O Enable I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus I/O The 8-bit data bus TABLE 3.5.1 Pin description for LCD

Code (hex) 1 2 4 6 5 7 8 A C

Command to LCD Instruction Register

Clear display screen Return home Decrement cursor Increment cursor Shift display right Shift display left Display off, cursor off Display off, cursor on Display on, cursor off

33

E F 10 14 18 1C 80 C0 38

Display on, cursor on Display on, cursor blinking Shift cursor position to left Shift cursor position to right Shift the entire display to the left Shift the entire display to the right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 2 lines and 5x7 matrix TABLE 3.5.2 LCD Command Codes

3.5.3 LCD INTERFACING:


Sending commands and data to LCDs with a time delay:

Fig 3.5 LCD INTERFACING

To send any command from table 2 to the LCD, make pin RS=0. For data, make RS=1.Then place a high to low pulse on the E pin to enable the internal latch of the LCD.

Uses:
34

The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. The LCDs have even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV applications.

3.6 H-BRIDGE (Motor Driver):


DC motors are typically controlled by using a transistor configuration called an "H-bridge". This consists of a minimum of four mechanical or solid-state switches, such as two NPN and two PNP transistors. One NPN and one PNP transistor are activated at a time. Both NPN and PNP transistors can be activated to cause a short across the motor terminals, which can be useful for slowing down the motor from the back EMF it creates. H-bridge. Sometimes called a "full bridge" the H-bridge is so named because it has four switching elements at the "corners" of the H and the motor forms the cross bar. There are four switching elements within the bridge. These four elements are often called, high side left, high side right, low side right, and low side left (when traversing in clockwise order). The switches are turned on in pairs, either high left and lower right, or lower left and high right, but never both switches on the same "side" of the bridge. If both switches on one side of a bridge are turned on it creates a short circuit between the battery plus and battery minus terminals. If the bridge is sufficiently powerful it will absorb that load and your batteries will simply drain quickly. Usually however the switches in question melt. To power the motor, you turn on two switches that are diagonally opposed. In the picture to the right, imagine that the high side left and low side right switches are turned on. 35

The current flows and the motor begins to turn in a "positive" direction. Turn on the high side right and low side left switches, then Current flows the other direction through the motor and the motor turns in the opposite direction.Actually it is just that simple, the tricky part comes in when you decide what to use for switches. Anything that can carry a current will work, from four SPST switches, one DPDT switch, relays, transistors, to enhancement mode power MOSFETs. High Side Right Off On On Off Low Side Left Off On Low Side Right On Off

High Side Left On Off On Off

Quadrant Description Forward Running Backward Running Braking Braking

Off Off On On Table 3.6.1 operation of H-bridge

The last two rows describe a maneuver where you "short circuit" the motor which causes the motors generator effect to work against itself. The turning motor generates a voltage which tries to force the motor to turn the opposite direction. This causes the motor to rapidly stop spinning and is called "braking" on a lot of Hbridge designs. Of course there is also the state where all the transistors are turned off. In this case the motor coasts freely if it was spinning and does nothing if it was doing nothing.

3.7 DC Motors:
The brushed DC motor is one of the earliest motor designs. Today, it is the motor of choice in the majority of variable speed and torque control applications.

Advantages:
Easy to understand design

36

Easy to control speed Easy to control torque Simple, cheap drive design

Easy to understand design The design of the brushed DC motor is quite simple. A permanent magnetic field is created in the stator by either of two means: Permanent magnets Electro-magnetic windings

If the field is created by permanent magnets, the motor is said to be a "permanent magnet DC motor" (PMDC). If created by electromagnetic windings, the motor is often said to be a "shunt wound DC motor" (SWDC). Today, because of cost-effectiveness and reliability, the PMDC motor is the motor of choice for applications involving fractional horsepower DC motors, as well as most applications up to about three horsepower. At five horsepower and greater, various forms of the shunt wound DC motor are most commonly used. This is because the electromagnetic windings are more cost effective than permanent magnets in this power range. Caution: If a DC motor suffers a loss of field (if for example, the field power connections are broken), the DC motor will immediately begin to accelerate to the top speed which the loading will allow. This can result in the motor flying apart if the motor is lightly loaded. The possible loss of field must be accounted for, particularly with shunt wound DC motors. Opposing the stator field is the armature field, which is generated by a changing electromagnetic flux coming from windings located on the rotor. The magnetic poles of the armature field will attempt to line up with the opposite magnetic poles generated by the stator field. If we stopped the design at this point, the motor would spin until the poles were opposite one another, settle into place, and then stop -- which would make a pretty useless motor!

37

However, we are smarter than that. The section of the rotor where the electricity enters the rotor windings is called the commutator. The electricity is carried between the rotor and the stator by conductive graphite-copper brushes (mounted on the rotor) which contact rings on stator. Imagine power is supplied: The motor rotates toward the pole alignment point. Just as the motor would get to this point, the brushes jump across a gap in the stator rings. Momentum carries the motor forward over this gap. When the brushes get to the other side of the gap, they contact the stator rings again and -- the polarity of the voltage is reversed in this set of rings! The motor begins accelerating again, this time trying to get to the opposite set of poles. (The momentum has carried the motor past the original pole alignment point.) This continues as the motor rotates. In most DC motors, several sets of windings or permanent magnets are present to smooth out the motion. Easy to control speedControlling the speed of a brushed DC motor is simple. The higher the armature voltage, the faster the rotation. This relationship is linear to the motor's maximum speed. The maximum armature voltage which corresponds to a motor's rated speed (these motors are usually given a rated speed and a maximum speed, such as 1750/2000 rpm) are available in certain standard voltages, which roughly increase in conjuntion with horsepower. Thus, the smallest industrial motors are rated 90 VDC and 180 VDC. Larger units are rated at 250 VDC and sometimes higher. specialty motors for use in mobile applications are rated 12, 24, or 48 VDC. Other tiny motors may be rated 5 VDC. Most industrial DC motors will operate reliably over a speed range of about 20:1 -- down to about 5-7% of base speed. This is much better performance than the comparible AC motor. This is partly due to the simplicity of control, but is also partly due to the fact that most industrial DC motors are designed with variable speed operation in mind, and have added heat dissipation features which allow lower operating speeds.

Easy to control torque


In a brushed DC motor, torque control is also simple, since output torque is proportional to current. If you limit the current, you have just limited the torque which the motor can

38

achieve. This makes this motor ideal for delicate applications such as textile manufacturing.

Simple, cheap drive design


The result of this design is that variable speed or variable torque electronics are easy to design and manufacture. Varying the speed of a brushed DC motor requires little more than a large enough potentiometer. In practice, these have been replaced for all but subfractional horsepower applications by the SCR and PWM drives, which offer relatively precisely control voltage and current. Common DC drives are available at the low end (up to 2 horsepower) for under US$100 -- and sometimes under US$50 if precision is not important. Large DC drives are available up to hundreds of horsepower. However, over about 10 horsepower careful consideration should be given to the price/performance tradeoffs with AC inverter systems, since the AC systems show a price advantage in the larger systems. (But they may not be capable of the application's performance requirments).

Disadvantages
Expensive to produce Can't reliably control at lowest speeds Physically larger High maintenance Dust

3.7.1 Working of a DC Motor:


When the coil is powered, a magnetic field is generated around the armature. The left side of the armature is pushed away from the left magnet and drawn towards the right, causing rotation. When the coil turns through 90 0, the brushes lose contact with the commutator and the current stops flowing through the coil.However the coil keeps

39

turning because of its own momentum. Now when the coil turns through 180 0, the sides get interchanged. As a result the commutator ring is now in contact with brush and commutator ring is in contact with brush . Therefore, the current continues to flow in the same direction.

Fig 3.7(b) working of dc motor

Principle:
When a rectangular coil carrying current is placed in a magnetic field, a torque acts on the coil which rotates it continuously. When the coil rotates, the shaft attached to it also rotates and thus it is able to do mechanical work.

3.7.2 Parts of a DC Motor: Armature:


A D.C. motor consists of a rectangular coil made of insulated copper wire wound on a soft iron core. This coil wound on the soft iron core forms the armature. The

40

coil is mounted on an axle and is placed between the cylindrical concave poles of a magnet.

Commutator:
A commutator is used to reverse the direction of flow of current. Commutator is a copper ring split into two parts C 1 and C2. The split rings are insulated form each other and mounted on the axle of the motor. The two ends of the coil are soldered to these rings. They rotate along with the coil. Commutator rings are connected to a battery. The wires from the battery are not connected to the rings but to the brushes which are in contact with the rings.

Brushes:
Two small strips of carbon, known as brushes press slightly against the two split rings, and the split rings rotate between the brushes.The carbon brushes are connected to a D.C. source.

Fig 3.7(c) parts of dc motor

PARAMETRS OF THE DC MOTRS:


Direction of rotation Motor Speed

41

Motor Torque Motor Start and Stop

3.7.3 DIFFERENT TYPES OF MOTORS:


In below figure different types of motors is there in this we are using FF-N30SA-1555 motor i.e. mentioned in the below.

Fig 3.7(d) Types of motor

42

Fig 3.7(e) Flat type dc motor Flat Type DC motor for Audio and Visual Equipments, toys and aviation aerial models, household appliances. Model: FF-N30SA-1555 Flat type diameter: 12mm(D) x 19.8mm(L) Voltage(V): 3V Operation voltage: 2-5V No load speed: 20800rpm current: 0.10A, At maximum efficiency speed: 17240rpm, current: 0.434A, torque: 28gcm Stall torque: 28gcm

43

3.8 DC FAN:

Fig 3.8 DC fan

44

Technical/Catalog Information 3610KL-04W-B10-D00 Vendor NMB Technologies Corporation Category Fans, Thermal Management Voltage - Rated 12VDC Power (Watts) 0.88W Bearing Type Ball Size / Dimension Square - 92mm L x 92mm H x 25mm W Air Flow 26.5 CFM (0.750m³/min) Features Termination 2 Wire Leads Fan Type Tubeaxial Noise 25 dB RPM 1750 RPM Static Pressure 0.057 in H2O (14.2 Pa) Weight 0.209 lb (94.8g) Current Rating 73mA Voltage Range 6 ~ 13.8VDC Operating Temperature 14 ~ 158F (-10 ~ 70C) Life Expectancy 70000 hrs @ 25C Lead Free Status Lead Free RoHS Status RoHS Compliant 3610KL 04W B10 D00 3610KL04WB10D00 Other Names P13415 ND P13415ND P13415 Table 3.8 DC fan description

3.8.1 Features:
Using of High-Precision Bearings Internal Sourcing of All Parts

45

3.8.2 Application:

Personal Computers (Desk top type/Note book type). Printers.

Communication Equipment.

Machine tools.

Portable amusements.

Servers.

Copy machines.

Facsimile machines.

Projectors.

46

Chapter 4 SOFTWARE

SOFTWARE EXPLANATION: 4.1 ABOUT KEIL SOFTWARE


It is possible to create the source files in a text editor such as Notepad, run the Compiler on each C source file, specifying a list of controls, run the Assembler on each Assembler source file, specifying another list of controls, run either the Library Manager or Linker (again specifying a list of controls) and finally running the Object-HEX Converter to convert the Linker output file to an Intel Hex File. Once that has been completed the Hex File can be downloaded to the target hardware and debugged. Alternatively KEIL can be used to create source files; automatically compile, link and covert using options set with an easy to use user interface and finally simulate or perform debugging on the hardware with access to C variables and memory. Unless you have to use the tolls on the command line, the choice is clear. KEIL Greatly simplifies the process of creating and testing an embedded application. Softwares used are: *Keil software for c programming. *Proteus for simulation purpose.

47

Vision4:
Vision3 adds many new features to the Editor like Text Templates, Quick Function Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and debugger setup. Vision3 is fully compatible to Vision4 and can be used in parallel with Vision4.Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components:

A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

Building an Application in Vision4


To build (compile, assemble, and link) an application in Vision4, you must: Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV4). Select Project - Rebuild all target files or Build target.

4.2 KEIL SOFTWARE TOOL (STEPS):


Click on the Keil vision Icon on Desktop The following fig will appear

48

Click on the Project menu from the title bar Then Click on New Project

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

49

Then Click on save button above. Select the component for u r project. I.e. Atmel Click on the + Symbol beside of Atmel

Select AT89C52 as shown below

50

Then Click on OK The Following fig will appear

Then Click either YES or NOmostly NO Now your project is ready to USE Now double click on the Target1, you would get another option Source group 1 as shown in next page.

51

Click on the file option from menu bar and select new

The next screen will be as shown in next page, and just maximize it by double clicking on its blue boarder.

52

Now start writing program in either in C or ASM For a program written in Assembly, then save it with extension . asm and for C based program save it with extension .C

Now right click on Source group 1 and click on Add files to Group Source

53

Now you will get another window, on which by default C files will appear.

Now select as per your file extension given while saving the file Click only one time on option ADD Now Press function key F7 to compile. Any error will appear if so happen.

54

If the file contains no error, then press Control+F5 simultaneously. The new window is as follows

Then Click OK Now Click on the Peripherals from menu bar, and check your required port as shown in fig below

55

Drag the port a side and click in the program file.

Now keep Pressing function key F11 slowly and observe. You are running your program successfully.

4.3 PROTEUS:

56

Proteus is software for microprocessor simulation, schematic capture, and printed circuit board (PCB) design. It is developed by Labcenter Electronics. The XGameStation Micro Edition was designed using Labcenter's Proteus schematic entry and PCB layout tools. A application framework lets you view modules of Proteus as tabs in a single window or, via drag and drop, as separate windows for a side-by-side view A common parts database enables sharing of information between schematic and PCB so that changes to data are instantly reflected across the software. A live netlist means changes to connectivity in the schematic can be instantly reflected in the PCB, the Bill of Materials and the Design Explorer. The integrated VSMStudio IDE binds your firmware project to your schematic design and Active Popups bring the schematic into your VSMStudio debug session.

57

Fig 4.3 design of proteus

CHAPTER-5 CONCLUSION & FUTURE SCOPE

58

5.1 Conclusion:
The project TEMPERATURE DEPENDENT DC FAN SPPED CONTROL has been successfully designed and tested. As the technology is going on developing day by day we prefer things to be done automatically and in the same way our project reduces the work to mankind. Secondly, using highly advanced ICs and with the help of growing technology the project has been successfully implemented. Precautions must be taken under every step of soldering the circuit.

5.2 FUTURE SCOPE:


In the future, this type of circuit can be used for the design of smart-house concept by various other sensors. This circuit can also continue to vary for the design temperature measurement fan whose speed is implemented as per the requirement of the people

BIBLIOGRAPHY

1. The 8051 Micro controller and Embedded Systems 59

By, Muhammad Ali Mazidi and Janice Gillispie Mazidi. 2.The 8051 Micro controller Architecture, Programming & Applications By, Kenneth J.Ayala. 3.Fundamentals Of Micro processors and Micro computers By, B.Ram . 4.Micro processor Architecture, Programming & Applications By, Ramesh S. Gaonkar. 5.Electronic Components By, D.V.Prasad. References on the Web: 8. www.national.com 9. www.atmel.com 10. www.microsoftsearch.com 11. www.geocities.com

APPENDIX

60

/* ADC 0808 Code LCD----->PORT0 RS--->P3^0 EN----->P3^1 >P2^0 RW Connected to ground externally ADD B---->P2^1 ADD C---->P2^2 ALE------>P2^3 OE------->P2^4 EOC------>P2^5 START---->P2^6 CLOCK---->P2^0 */ #include<reg51.h> sbit ale=P3^3; //address latch enable sbit oe=P3^6; //output enable sbit sc=P3^4; //start conversion sbit eoc=P3^5; //end of conversion sbit clk=P3^7; // clock sbit ADD_A=P3^0; // Address pins for selecting input channels. sbit ADD_B=P3^1; sbit ADD_C=P3^2; sfr input_port= 0X90; // Output Of ADC connected to P1 sbit rs=P2^0; sbit en=P2^1; #define ldata P2 sbit light = P0^0;

ADD A----

unsigned char value; void timer0() interrupt 1 // Function to generate clock of frequency 500KHZ using Timer 0 interrupt. { clk=~clk; } void delay(unsigned int count) // Function to provide time delay in msec. { unsigned int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); } void pwm(unsigned char x,unsigned char y) { light=0;

61

delay(x); light=1; delay(y); } void cmd_lcd(unsigned char value) { ldata = value&0XF0; rs =0; en =1; delay(5); en =0; ldata = (value<<4)&(0x0f0); rs =0; en =1; delay(5); en =0; } void write_lcd(unsigned char value) { ldata = value&0XF0; rs =1; en =1; delay(5); en =0; ldata = (value<<4)&(0x0f0); rs =1; en =1; delay(5); en =0; } void init_lcd(void) { cmd_lcd(0x02); delay(10); cmd_lcd(0x28); delay(10); cmd_lcd(0x01);

62

delay(10); cmd_lcd(0x0c); delay(10); cmd_lcd(0x06); delay(10); } void display_lcd(unsigned char *p) { while(*p) { write_lcd(*p++); } } /*void cmd(unsigned char v) { P3=v; rs=0; en=1; delay(5); en=0; } void dat(unsigned char v) { P3=v; rs=1; en=1; delay(5); en=0; } void lcd_init() { cmd(0x38); cmd(0x0e); cmd(0x06); cmd(0x01); cmd(0x80); }*/ void candd(unsigned int value) { unsigned int i,j,x,k,l; i=value/100; x=i|0x30; write_lcd(x);

63

//delay(5); j=value%100; k=j/10; x=k|0x30; write_lcd(x); //delay(5); l=j%10; x=l|0x30; write_lcd(x); } void adc(unsigned char a,unsigned char b,unsigned char c) { // cmd(0xC5); ADD_C=c; // Selecting input channel 2 using address lines ADD_B=b; ADD_A=a; delay(2); ale=1; delay(2); sc=1; delay(1); ale=0; delay(1); sc=0; while(eoc==1); while(eoc==0); oe=1; value=input_port; candd(value); delay(2); oe=0; } void main() { input_port=0xFF; light=0; init_lcd(); cmd_lcd(0x01); display_lcd(" WELCOME TO "); cmd_lcd(0xc0); display_lcd(" TEMP BASED FSC"); delay(200); cmd_lcd(0x01);

64

display_lcd("TEMP:"); eoc=1; ale=0; oe=0; sc=0; TMOD=0x02; //timer0 setting for generating clock of 500KHz using interrupt enable mode. TH0=0xFD; IE=0x82; TR0=1; while(1) { cmd_lcd(0x85); adc(0,0,0); if(value < 27) { lcdcmd(0xc0); lcddisplay("fan speed 20 rpm"); pwm(30,2); } if(value >= 27 && value < 35) { lcdcmd(0xc0); lcddisplay("fan speed 25 rpm"); pwm(50,1); } if(value >= 20 && value < 25) { lcdcmd(0xc0); lcddisplay("fan speed 20rpm"); pwm(50,10); } if(value >= 25 && value < 30) { lcdcmd(0xc0); lcddisplay("fan speed 50rpm"); pwm(50,20); } if(value >= 30 && value< 35) { lcdcmd(0xc0); lcddisplay("fan speed 55rpm");

65

pwm(50,30); } if(value >= 35 && value < 40) { lcdcmd(0xc0); lcddisplay("fan speed 55rpm"); pwm(50,50); } if(value >= 40 && value< 45) { lcdcmd(0xc0); lcddisplay("fan speed 55rpm"); pwm(20,50); } if(value >= 45 && value < 50) { lcdcmd(0xc0); lcddisplay("fan speed 55rpm"); pwm(10,50); } if(value>=50 && value< 55) { lcdcmd(0xc0); lcddisplay("fan speed 55rpm"); pwm(1,50); } if(value>=55) { pwm(1,60); } } }

66

Das könnte Ihnen auch gefallen