99
Temperature Measurement & control Introduction: The purpose of this project is to measure the temperature, display it on LCD & also control the temperature through on or off any 220V device like AC or heater. This project is divided into two sections (a) Hardware and (b) Software. In hardware section I have made a microcontroller kit, which is interfaced with Analog to Digital converter (ADC), LCD, three switches keypad and relay through isolator circuit. In software section I have made a program code for measuring Temperature and displaying it on LCD and then comparing it with the preset value. The program code is written in high level language “embedded c” with the help of Keil compiler. Block Diagram of the Project: Various modules of the project are shown in the block diagram given below:

Report Thermal Controller

Embed Size (px)

Citation preview

Page 1: Report Thermal Controller

Temperature Measurement & control

Introduction:

The purpose of this project is to measure the temperature, display it on

LCD & also control the temperature through on or off any 220V device

like AC or heater.

This project is divided into two sections (a) Hardware and (b) Software.

In hardware section I have made a microcontroller kit, which is interfaced

with Analog to Digital converter (ADC), LCD, three switches keypad and

relay through isolator circuit. In software section I have made a program

code for measuring Temperature and displaying it on LCD and then

comparing it with the preset value. The program code is written in high

level language “embedded c” with the help of Keil compiler.

Block Diagram of the Project:

Various modules of the project are shown in the block diagram given

below:

MICROCONTROLLER UNIT

LCDPOWER

SUPPLY1TEMPERATURE

SENSOR

ADC

POWER SUPPLY2

ISOLATOR

AMPLIFIER

SOCKET

RELAY

SWITCH PANEL

Page 2: Report Thermal Controller

Interfacing with switches (keypad):

Interfacing with keypad makes instrument menu driven user friendly.

This will help to the user to select the preset temperature and also to

move to the measurement stage.

Interfacing with LCD

LCD makes this instrument user friendly by displaying everything on the

display. It is an intelligent LCD module, as it has inbuilt controller which

convert the alphabet and digit into its ASCII code and then display it by

its own i.e. we do not required to specify which LCD combination must

glow for a particular alphabet or digit.

Interfacing with Analog to Digital Converter

The analog to digital converter takes the input from the sensor which is in

analog form. It takes 0V for 0 digital level and take 5V for 1 digital level.

555 Timer is used to provide clock to ADC.

Temperature Sensor:

For continuous temperature monitoring applications, time response is less

concern, sensors that remain in place for long periods can achieve a

relatively steady state because actual temperature changes slowly.

The sensor type most commonly used for medical applications is the

thermistor. A thermistor is a thermally sensitive resistor, whose resistance

alters markedly with changes of its ambient temperature. Thermistors are

composites of selected metal oxides characterized by large negative

temperature-coefficients and high sensitivity i.e. resistance decreases with

increasing temperature. In practice, a thermistor designed for use in a

body temperature probe might consist of a small bead of semiconductor

material sealed into the tip of a thin glass envelope for protection.

Platinum leads are fused into the bead and led out of the envelope. The

bead material could consist of a mixture of nickel, cobalt and manganese

oxides fused together in a furnace. A typical bead resistance might be

Page 3: Report Thermal Controller

2000 ohms at 20 degrees Celsius which would fall to 1400 ohms at 40

degree Celsius, the variation of the thermistor resistance with temperature

is inherently non linear. Thermistor sensors now in use clinically are

typically specified as accurate to within 0.2oC to 37oC.

Thermistors are non-linear. In addition, the outputs of these sensors are

not linearly proportional to any temperature scale. Early monolithic

sensor such as LM 3911, LM134 and LM135 over come these difficulties

but their outputs are related to Kelvin temperature scale.

In this circuit LM35 precision centigrade temperature has been used as

temperature sensor.

Switching of 220V device:

ON/OFF switching of a 220V device is controlled by the Microcontroller.

Device is isolated from Microcontroller by optocoupler and is connected

through Relay. Switching of mains is done, by using relays. Temperature

is compared with the preset desired value. If temperature is greater than

the required value then the relay corresponding to the ‘AC’ is made ON

by the MCU and the relay corresponding to the ‘HEATER’ is made OFF

by the MCU. If the temperature is less than the desired temperature then

reverse is done by the MCU.

Features of the Project:

Powered by +5 volt, 12volt supply

Current consumption 0.45mA for Microcontroller circuit, 0.75mA for

switching circuit, 200mA for amplification circuit

User interface using LCD and switches

Maintenance of the temperature at the desired value through on/off an

AC or Heater

Page 4: Report Thermal Controller

Various Components used in various Modules of the Project along

with specifications and quantity:

Power Supply Unit1 (+5V):

S. No. Component Specification Qty.1. PCB Designed 12. Transformer 9-0-9, 500mA 13. Diode 1N4007 44. Cap. 1000 µF 15. Regulator 7805 1

Power Supply Unit2 (+12V):

S. No. Component Specification Qty.1. PCB Designed 12. Transformer 9-0-9, 500mA 13. Diode 1N4007 44. Cap. 1000 µF 15. Regulator 7812 1

Microcontroller Unit:

S. No. Component Specification Qty.1. PCB Designed 12. Base 40 Pin 13. Crystal 11.0592MHZ 14. Cap. 33 PF 2

10µF 15. MCU AT89s52 16. Micro switch 17. Resistance 10K Ω 1

LCD Module:

S. No. Component Specification Qty.1. LCD Connector 16 Pin 12. LCD 16 x 2 1

Switching Circuit:

Page 5: Report Thermal Controller

S. No. Component Specification Qty.1. PCB Designed 12. Base 6 Pin 23. Optocoupler 817 24. Resistance 470Ω 25. Transistor 369 26. Relay 12V 27. Extension 2 pin 1

Keypad Module:

S. No. Component Specification Qty.1. PCB G.P.PCB 12. Micro Switches 2 Pin 3ADC Module:

S. No. Component Specification Qty.1. PCB Designed (FT4) 12. Base 28 Pin 1

8 Pin 13. IC ADC 0808 14. IC Timer 555 15. Temp. Sensor LM35 16. Resistance 1K Ω 27. Capacitor 103 (0.01 µF) 2

Detailed Hardware Description:

Sensor for temperature measurement (LM35):

General Description

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 ±1⁄4°C at room temperature and ±3⁄4°C

Page 6: Report Thermal Controller

over a full −55 to +150°C temperature range. Low cost is assured by

trimming and calibration at the wafer level. The LM35’s low output

impedance, linear output, and precise inherent calibration make

interfacing to readout or control circuitry especially easy. It can be used

with single power supplies, or with plus and minus supplies. As it draws

only 60 μA from its supply, it has very low self-heating, less than 0.1°C

in still air. The LM35 is rated to operate over a −55° to +150°C

temperature range, while the LM35C is rated for a −40° to +110°C range

(−10° with improved accuracy). The LM35 series is available packaged

in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and

LM35D are also available in the plastic TO-92 transistor package. The

LM35D is also available in an 8-lead surface mount small outline

package and a plastic TO-220 package.

Features:

Calibrated directly in ° Celsius (Centigrade) Linear + 10.0 mV/°C scale factor 0.5°C accuracy guarantee able (at +25°C) Rated for full −55° to +150°C 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.08°C in still air Nonlinearity only ±1⁄4°C typical Low impedance output, 0.1 W for 1 mA load

Typical Applications:

Page 7: Report Thermal Controller

Basic Centigrade temperature sensor

(+2°C to +150°C)

Full-Range Centigrade Temperature Sensor

A/D converter

As the output signal from the transducer LM35 is in analog form and the

data can be fed to the controller in digital form only so an analog to

digital converter is to be used. The A/D conversion is a quantizing

process where by an analog signal is represented by equivalent binary

states. A/D converter can be classified into two groups based on

conversion technique.

One technique involves comparing a given analog signal with the

internally generated equivalent signal. This group includes Successive

approximation Register, counter and Flash type converters.

The second technique involves changing an analog signal into time or

frequency and comparing these parameters to known values. This group

includes Integrator and Voltage to Frequency Converters.

First type is used for data loggers and instrumentation, while the second

type is used in digital meters, panel meters and monitoring system.

Successive Approximation A/D converter ( ADC0808)

Page 8: Report Thermal Controller

This is the most popular method of analog to digital conversion. It has an

excellent compromise between accuracy and speed. An unknown voltage

Vin is compared with a fraction of reference voltage, Vr For n-bit digital

output , comparison is made in times with different fractions of Vr and the

value of a particular bit is set to 1, if V in is greater than the set fraction of

Vr. It includes three major elements

The D/A converter.

The successive Approximation Register.

The comparator.

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 voltage

divider with analog switch tree and a successive approximation register.

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.

The design of the ADC0808 has been optimized by incorporating the

most desirable aspects of several A/D conversion Techniques. The

ADC0808, ADC0809 offers high speed. High accuracy, minimal

temperature dependence, excellent long-term accuracy and repeatability,

and consumes minimal power. These features make this device ideally

Page 9: Report Thermal Controller

suited to applications from process and machine control to consumer and

automotive applications.

Key specifications

Easy interface to all microprocessors.

Operates with 5 V DC.

Adjusted voltage reference.

No zero or full scale adjust required.

8-channel multiplexer with address logic.

0V to 5V input range with single 4V power supply.

Outputs meet TTL voltage level specifications.

Resolution 8 Bits.

Total Unadjusted Error = ½ LSB.

Single supply 5 V DC.

Low Power 15m W, conversion time 100s.

Page 10: Report Thermal Controller

Architecture of ADC0808

Clock input

The clock input to the ADC is provided by using a 555 TIMER. The

LM555 is a highly stable device for generating accurate time delays or

oscillation. Additional terminals are provided for triggering or resetting if

desired. For astable operation as an oscillator, the free running frequency

and duty cycle are accurately controlled with two external resistors and

one capacitor. The circuit may be triggered and reset on falling

waveforms, and the output circuit can source or ink up to 200mA or drive

TTL circuits.

Astable Operation

If the circuit is connected as shown in Figure (pins 2 and 6 connected) it

will trigger itself and free run as a multivibrator. The external capacitor

charges through RA+ RB and discharges through RB. Thus the duty cycle

Page 11: Report Thermal Controller

may be precisely set by the ratio of these two resistors. In this mode of

operation, the capacitor charges and discharges between 1/3 VCC and 2/3

VCC. The time during which the capacitor charges from 1/3 Vcc to 2/3

Vcc is equal to the time the output is high and is given by:

tc= 0.69 (RA+RB)C ………1

Where RA and RB are in ohms and C is in farads. Similarly, the time

during which the capacitor discharges from 2/3 Vcc to 1/3 Vcc is equal to

the time the output is low is given by:

td= 0.69 (RB)C ………2

As in the triggered mode, the charge and discharge times, and therefore

the frequency are independent of the supply voltage.

Thus the total period is

T=tc+td= 0.69 (RA+2RB) C ………3

The frequency of oscillation:

………4

The duty cycle is the ratio of the time during which the output is high to

the total time period T.

Page 12: Report Thermal Controller

Diagram of 555 timer in astable mode

555Timer:

The 8-pin 555 timer must be one of the most useful ICs ever made and it

is used in many projects. With just a few external components it can be

used to build many circuits, not all of them involve timing!

A popular version is the NE555 and this is suitable in most cases where a

'555 timer' is specified. The 556 is a dual version of the 555 housed in a

14-pin package, the two timers (A and B) share the same power supply

pins. The circuit diagrams on this page show a 555, but they could all be

adapted to use one half of a 556.

Page 13: Report Thermal Controller

Low power versions of the 555 are made, such as the ICM7555, but these

should only be used when specified (to increase battery life) because their

maximum output current of about 20mA (with a 9V supply) is too low for

many standard 555 circuits. The ICM7555 has the same pin arrangement

as a standard 555.

The circuit symbol for a 555 (and 556) is a box with the pins arranged to

suit the circuit diagram: for example 555 pin 8 at the top for the +Vs

supply, 555 pin 3 output on the right. Usually just the pin numbers are

used and they are not labeled with their function.

The 555 and 556 can be used with a supply voltage (Vs) in the range 4.5

to 15V (18V absolute maximum).

Standard 555 and 556 ICs create a significant 'glitch' on the supply when

their output changes state. This is rarely a problem in simple circuits with

no other ICs, but in more complex circuits a smoothing capacitor (eg

Page 14: Report Thermal Controller

100µF) should be connected across the +Vs and 0V supply near the 555

or 556.

The input and output pin functions are described briefly below and there

are fuller explanations covering the various circuits:

Astable - producing a square wave

Monostable - producing a single pulse when triggered

Bistable - a simple memory which can be set and reset

Buffer - an inverting buffer (Schmitt trigger)

Inputs of 555/556

Trigger input: when < 1/3 Vs ('active low') this makes the output high

(+Vs). It monitors the discharging of the timing capacitor in an astable

circuit. It has a high input impedance > 2M .

Threshold input: when > 2/3 Vs ('active high') this makes the output low

(0V)*. It monitors the charging of the timing capacitor in astable and

monostable circuits. It has a high input impedance > 10M .

* providing the trigger input is > 1/3 Vs, otherwise the trigger input will

override the threshold input and hold the output high (+Vs).

Page 15: Report Thermal Controller

Reset input: when less than about 0.7V ('active low') this makes the

output low (0V), overriding other inputs. When not required it should be

connected to +Vs. It has an input impedance of about 10k .

Control input: this can be used to adjust the threshold voltage which is

set internally to be 2/3 Vs. Usually this function is not required and the

control input is connected to 0V with a 0.01µF capacitor to eliminate

electrical noise. It can be left unconnected if noise is not a problem.

The discharge pin is not an input, but it is listed here for convenience. It

is connected to 0V when the timer output is low and is used to discharge

the timing capacitor in astable and monostable circuits.

Output of 555/556

The output of a standard 555 or 556 can sink and source up to 200mA.

This is more than most ICs and it is sufficient to supply many output

transducers directly, including LEDs (with a resistor in series), low

current lamps, piezo transducers, loudspeakers (with a capacitor in

series), relay coils (with diode protection) and some motors (with diode

protection). The output voltage does not quite reach 0V and +Vs,

especially if a large current is flowing.

To switch larger currents you can connect a transistor .

The ability to both sink and source current means that two devices can be

connected to the output so that one is on when the output is low and the

other is on when the output is high. The diagram shows two LEDs

connected in this way. This arrangement is used in the Disco Lights

project to make the LEDs flash alternately.

Page 16: Report Thermal Controller

555/556 Astable

An astable circuit produces a

'square wave', this is a digital

waveform with sharp transitions

between low (0V) and high (+Vs).

Note that the durations of the low

and high states may be different.

The circuit is called an astable

because it is not stable in any

state: the output is continually

changing between 'low' and 'high'.

The time period (T) of the square wave is the time for one

complete cycle, but it is usually better to consider frequency (f)

which is the number of cycles per second.

T = 0.7 × (R1 + 2R2) × C1 and f = 1.4

(R1 + 2R2) × C1

T = time period in seconds (s) f = frequency in hertz (Hz) R1 = resistance in ohms ( ) R2 = resistance in ohms ( ) C1 = capacitance in farads (F)

555 astable output, a square wave(Tm and Ts may be different)

555 astable circuit

Page 17: Report Thermal Controller

The time period can be split into two parts: T = Tm + Ts Mark time (output high): Tm = 0.7 × (R1 + R2) × C1 Space time (output low): Ts = 0.7 × R2 × C1

Many circuits require Tm and Ts to be almost equal; this is achieved if R2 is much larger than R1.

For a standard astable circuit Tm cannot be less than Ts, but this is not

too restricting because the output can both sink and source current. For

example an LED can be made to flash briefly with long gaps by

connecting it (with its resistor) between +Vs and the output. This way the

LED is on during Ts, so brief flashes are achieved with R1 larger than

R2, making Ts short and Tm long. If Tm must be less than Ts a diode can

be added to the circuit as

explained under duty cycle below.

Choosing R1, R2 and C1R1 and R2 should be in the range 1k to 1M . It is best to choose C1

first because capacitors are available in just a few values.

Choose C1 to suit the frequency range you require (use the table as

a guide).

Choose R2 to give the frequency (f) you require. Assume

that R1 is much smaller than R2 (so that Tm and Ts are

almost equal), then you can use:

555 astable frequencies

C1R2 = 10kR1 = 1k

R2 = 100kR1 = 10k

R2 = 1MR1 = 100k

0.001µF 68kHz 6.8kHz 680Hz

0.01µF 6.8kHz 680Hz 68Hz

0.1µF 680Hz 68Hz 6.8Hz

1µF 68Hz 6.8Hz 0.68Hz

10µF 6.8Hz0.68Hz

(41 per min.)0.068Hz

(4 per min.)

Page 18: Report Thermal Controller

R2 = 0.7 f × C1

Choose R1 to be about a tenth of R2 (1k min.) unless you want

the mark time Tm to be significantly longer than the space time Ts.

If you wish to use a variable resistor it is best to make it R2.

If R1 is variable it must have a fixed resistor of at least 1k in

series

(this is not required for R2 if it is variable).

With the output high (+Vs) the capacitor C1 is charged by current

flowing through R1 and R2. The threshold and trigger inputs monitor the

capacitor voltage and when it reaches 2/3Vs (threshold voltage) the output

becomes low and the discharge pin is connected to 0V.

The capacitor now discharges with current flowing through R2 into the

discharge pin. When the voltage falls to 1/3Vs (trigger voltage) the output

becomes high again and the discharge pin is disconnected, allowing the

capacitor to start charging again.

This cycle repeats continuously unless the reset input is connected to 0V

which forces the output low while reset is 0V.

Page 19: Report Thermal Controller

An astable can be used to provide the clock signal for circuits such as

counters.

A low frequency astable (< 10Hz) can be used to flash an LED on and

off, higher frequency flashes are too fast to be seen clearly. Driving a

loudspeaker or piezo transducer with a low frequency of less than 20Hz

will produce a series of 'clicks' (one for each low/high transition) and this

can be used to make a simple metronome.

An audio frequency astable (20Hz to 20kHz) can be used to produce a

sound from a loudspeaker or piezo transducer. The sound is suitable for

buzzes and beeps. The natural (resonant) frequency of most piezo

transducers is about 3kHz and this will make them produce a particularly

loud sound.

Duty cycle

The duty cycle of an astable circuit is the proportion of the complete

cycle for which the output is high (the mark time). It is usually given as a

percentage.

For a standard 555/556 astable circuit the mark time (Tm) must be greater

than the space time (Ts), so the duty cycle must be at least 50%:

Duty cycle = Tm

= R1 + R2

Tm + Ts R1 + 2R2

Page 20: Report Thermal Controller

555/556 MonostableA monostable circuit produces a single output pulse when triggered. It is

called a monostable because it is stable in just one state: 'output low'. The

'output high' state is temporary.

555 monostable out, a single pulse

555 monostable circuit with manual trigger

The duration of the pulse is called the time period (T) and this is determined

by resistor R1 and capacitor C1:

time period, T = 1.1 × R1 × C1

T = time period in seconds (s)

R1 = resistance in ohms ( )

C1 = capacitance in farads (F)

The maximum reliable time period is about 10 minutes.

Page 21: Report Thermal Controller

Why 1.1? The capacitor charges to 2/3 = 67% so it is a bit longer than the

time constant (R1 × C1) which is the time taken to charge to 63%.

Choose C1 first (there are relatively few values available).

Choose R1 to give the time period you need. R1 should be in the

range 1k to 1M , so use a fixed resistor of at least 1k in series if

R1 is variable.

Beware that electrolytic capacitor values are not accurate, errors of

at least 20% are common.

Beware that electrolytic capacitors leak charge which substantially

increases the time period if you are using a high value resistor - use

the formula as only a very rough guide!

Monostable operation

The timing period is triggered (started) when the trigger input (555 pin 2)

is less than 1/3 Vs, this makes the output high (+Vs) and the capacitor C1

starts to charge through resistor R1. Once the time period has started

further trigger pulses are ignored.

The threshold input (555 pin 6) monitors the voltage across C1 and when

this reaches 2/3 Vs the time period is over and the output becomes low. At

the same time discharge (555 pin 7) is connected to 0V, discharging the

capacitor ready for the next trigger.

Page 22: Report Thermal Controller

The reset input (555 pin 4) overrides all other inputs and the timing may

be cancelled at any time by connecting reset to 0V, this instantly makes

the output low and discharges the capacitor. If the reset function is not

required the reset pin should be connected to +Vs.

SWITCHING CIRCUIT FOR MAINS

OPTOISOLATOR IC (MCT- 2E)

POWER AMPLIFIER USING BC369 TRANSISTOR

ELECTROMAGNETIC RELAY

SOCKET

Page 23: Report Thermal Controller

The switching circuit is comprises of an optocoupler which will isolate

the controller from the outer spikes or fluctuations or from the external

hardware and at the same time it drives a power transistor i.e. make it on

when a signal from the controller pin is applied to it. Optocoupler

actually comprises of a diode and a phototransistor. It comes in a DIP IC

package. Thus signal from the MCU is given to the LED part or the

driving part. When LED begins to glow then the phototransistor acts as

on switch or short circuit. This output is given to power transistor, which

will amplify the current of the signal and then use it to drive a relay. Now

from the mains one wire is directly connected to the room normally this is

the neutral wire and the other wire i.e. is the phase wire is given to the

relay and then from the relay given to the socket. Thus before the

switchboard of a room the phase has to pass through a relay.

If MCU wants to switch ON the device, then microcontroller sends a low

signal to the optocoupler then the relay will get on and ultimately the

switch panel is provided with phase voltage. Reverse is the case when

MCU does not send any signal and thus, not any phase will be available

at the switchboard.

Page 24: Report Thermal Controller

Optocoupler:

It has one IR LED and a photo- transistor. One pin of the LED is connected to the

MCU to get a signal (0 or 1) and the pin is given ground. When the signal from the

MCU is 0, then LED emits light. This light will turn on the NPN transistor. Emitter of

the transistor is grounded. Collector is connected to the PNP transistor whose emitter

is connected to Vcc and collector to the relay.

The purpose of using the optocouplers is to pass the supply from the

PC/MCU to the appliances & is for isolation of the port of the PC/MCU

from an external hardware. The voltage signal from the PC/MCU is being

converted into light by the LED and then further converted into voltage

by the phototransistor. This ensures that there is no physical connection

between the PC and the appliances. The signal from the PC/MCU is

coupled only through light so that if in any case the external hardware (

in this case :appliances) produces an error voltage it will not be passed

over to the port of the PC/MCU and will not damage the internal

circuitry of the PC/MCU.

Page 25: Report Thermal Controller

MCT-2E Pin Diagram

The MCT2XXX series optoisolators

consist of a gallium arsenide

infrared emitting diode driving a silicon phototransistor in a 6-pin dual in-

line package. There is no electrical connection between the two, just a

beam of light. The light emitter is nearly always an LED. The light

sensitive device may be a photodiode, phototransistor, or more esoteric

devices such as thyristors, triacs etc. To carry a signal across the isolation

barrier, optocouplers are operated in linear mode.

Pin Description of MCT2E

The IC package may also be called an IC or a chip. It is important to note

that each type of optocoupler may use different pin assignments. For

carrying a linear signal across isolation barrier there are two types of

optocouplers. Both types use an infrared light emitting diode (LED) to

generate and send a light signal across an isolation barrier. The difference

Pin no. Function

1 Anode

2 Cathode

3 NC

4 Emitter

5 Collector

6 Base

Page 26: Report Thermal Controller

is in the detection method. Some optocouplers use a phototransistor

detector while others use a photodiode detector which drives the base of a

transistor.

The phototransistor detector uses the transistors collector base

junction to detect the light signal. This necessitates that the base area be

relatively large compared to a standard transistor. The result is a large

collector to base capacitance which slows the collector rise time and

limits the effective frequency response of the device. In addition the

amplified photocurrent flows in the collector base junction and modulates

the response of the transistor to the photons. This cause the transistor to

behave in a non-linear manner. Typical phototransistor gains range from

100 to 1000.

The photodiode/transistor detector combination on the other hand

uses a diode to detect the photons and convert them to a current to drive

the transistor base. The transistor no longer has a large base area. The

response of this pair is not affected by amplified photocurrent and the

photodiode capacitance does not impair speed.

Optocoupler Operation:

Optocouplers are good devices for conveying analog information

across a power supply isolation barrier, they operate over a wide

temperature range and are often safety agency approved they do,

however, have many unique operating considerations.

Optocouplers are current input and current output devices. The

input LED is excited by changes in drive current and maintains a

relatively constant forward voltage. The output is a current which is

proportional to the input current. The output current can easily be

converted to a voltage through a pull-up or load resistor.

Page 27: Report Thermal Controller

Applications:

AC mains detection

Reed relay driving

Switch mode power supply feedback

Telephone ring detection

Logic ground isolation

Logic coupling with high frequency noise rejection.

Features:

Interfaces with common logic families

Input-output coupling capacitance < 0.5 pF

Industry Standard Dual-in line 6-pin package

5300 VRMS isolation test voltage

Lead-free component

Optocoupler (817)

Description

The HCPL-817 contains a light emitting diode optically coupled to a

phototransistor. It is packaged in a 4-pin DIP package and available in

wide-lead spacing option. Input-output isolation voltage is 5000 Vrms.

Response time (tr), is typically 4 ms and minimum CTR (Current transfer

ratio) is 50% at input current of 5 mA.

Page 28: Report Thermal Controller

Electromagnetic Relay

A relay is simply an electrically operated on/off switch. The relay

used in this hardware circuit is SPDT (single pole double throw) relay.

Short circuit and other abnormal conditions often occur on a power

system. The heavy current associated with short circuit is likely to cause

damage to equipment if suitable protective relays and circuit breakers are

not provided for the protection of each section of power system. If a fault

occurs in an element of power system, an automatic protective device is

needed to isolate the faulty equipment as quickly as possible to keep the

healthy section of the system in normal operation.

The electromagnetic relay consists of a multi-turn coil, wound on

an iron core, to form an electromagnet. When the coil is energized, by

passing current through it, the core becomes temporarily magnetized.

The magnetized core attracts the iron armature. The armature is pivoted

which causes it to operate one or more sets of contacts. When the coil is

de-energized the armature and contacts are released.

The coil can be energized from a low power source such as a

transistor while the contacts can switch high powers such as the mains

supply. The relay can also be situated remotely from the control source.

Page 29: Report Thermal Controller

Relays can generate a very high voltage across the coil when switched

off. This can damage other components in the circuit. To prevent this

diode is connected across the coil. The cathode of the diode is connected

to the most positive end of the coil.

Electromagnetic Relay

Relay Contacts

The spring sets (contacts) can be a mixture of N.O. N.C. and C.O.

various coil operating voltages (ac and dc) are available. The actual

contact points on the spring sets are available for high current and low

current operation.

There are two different kinds of contacts:

Normally closed

Changeover

Normally open

Page 30: Report Thermal Controller

NO normally open: The contacts are open until the coil of the relay is

energized, whereupon they are closed to complete the outside circuit

NC normally closed : The contacts are closed until the coil of the relay is

energized, whereupon they are opened to break the outside circuit,

switching it off.

Many relays have multiple contacts, half of which are NO and half

NC. Relays are electromagnetic devices which have a certain amount of

inductance .When they are turned off; the collapse of the magnetic field

can produce a momentary “spike” of high reverse voltage that can wreck

a transistor or integrated circuit. Therefore a reverse biased diode is

placed in parallel to short out the voltage spike, thereby protecting the

circuit.

Diode Used As Protective Circuit

Advantages of Relays:

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.Power Transistor (BC 369):

High current gain

Page 31: Report Thermal Controller

High collector current

Low collector-emitter saturation voltage

Complementary type: BC 368 (NPN)

POWER SUPPLY

Power supplies are designed to convert high voltage AC mains to a

suitable low voltage supply for electronics circuits and other devices.

A power supply can be broken down into a series of blocks, each of

which performs a particular function.

For example a 5V regulated supply:

Page 32: Report Thermal Controller

Each of the block has its own function as described

below

1. Transformer – steps down high voltage AC mains to low voltage

AC.

2. Rectifier – converts AC to DC, but the DC output is varying.

3. Smoothing – smoothes the DC from varying greatly to a small

ripple.

4. Regulator – eliminates ripple by setting DC output to a fixed

voltage.

TRANSFORMER

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. The two types of

transformers

Step-up transformers increase voltage,

Step-down transformers reduce voltage.

Page 33: Report Thermal Controller

Transformer

Most power supplies use a step-down transformer to

reduce the dangerously high mains voltage (230V in UK) 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 turn 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.

Turns ratio = Vp = Np Vs Ns

And Power Out = Power In

Page 34: Report Thermal Controller

Vs ´ Is = Vp ´ Ip

Where

Vp = primary (input) voltage

Np = number of turns on primary coil

Ip = primary (input) current

Ns = number of turns on secondary coil

Is = secondary (output) current

Vs = secondary (output) voltage

BRIDGE RECTIFIER

A bridge rectifier can be made using four individual diodes, but it is also

available in special packages containing the four diodes required. It is

called a full-wave rectifier because it uses all AC wave (both positive and

negative sections). 1.4V is used up in the bridge rectifier because each

diode uses 0.7V when conducting and there are always two diodes

conducting, as shown in the diagram below. Bridge rectifiers are rated by

the maximum current they can pass and the maximum reverse voltage

they can withstand (this must be at least three times the supply RMS

voltage so the rectifier can withstand the peak voltages). In this alternate

pairs of diodes conduct, changing over the connections so the alternating

directions of AC are converted to the one direction of DC.

Page 35: Report Thermal Controller

OUTPUT – Full-wave Varying DC

SMOOTHING

Smoothing 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 diagram shows the unsmoothed varying DC (dotted line) and the

smoothed DC (solid line). The capacitor charges quickly near the peak of

the varying DC, and then discharges as it supplies current to the output.

Note that smoothing significantly increases the average DC voltage to

almost the peak value (1.4 × RMS value). For example 6V RMS AC is

rectified to full wave DC of about 4.6V RMS (1.4V is lost in the

bridge rectifier), with smoothing this increases to almost the peak value

giving 1.4 × 4.6 = 6.4V smooth DC.

Page 36: Report Thermal Controller

Smoothing is not perfect due to the capacitor voltage falling a little as it

discharges, giving a small ripple voltage. For many circuits a ripple

which is 10% of the supply voltage is satisfactory and the equation

below gives the required value for the smoothing capacitor. A larger

capacitor will give fewer ripples. The capacitor value must be doubled

when smoothing half-wave DC.

Smoothing capacitor for 10% ripple, C = 5 × Io

Vs × f

Where

C = smoothing capacitance in farads (F)

Io = output current from the supply in amps (A)

Vs = supply voltage in volts (V), this is the peak value of the unsmoothed

DC

f = frequency of the AC supply in hertz (Hz), 50Hz in the UK

REGULATOR

Voltage regulator ICs are available with fixed (typically 5, 12 and 15V)

or variable output voltages. They are also rated by the maximum current

they can pass. Negative voltage regulators are available, mainly for use in

dual supplies. Most regulators include some automatic protection from

Page 37: Report Thermal Controller

excessive current (‘overload protection') and overheating (‘thermal

protection'). Many of the fixed voltage regulator ICs has 3 leads and look

like power transistors, such as the 7805 +5V 1A regulator shown on the

right. They include a hole for attaching a heat sink if necessary.

Working of Power Supply

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.

Transformer + Rectifier

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.

Transformer + Rectifier + Smoothing

Page 38: Report Thermal Controller

The smooth DC output has a small ripple. It is suitable for most

electronic circuits.

Transformer + Rectifier + Smoothing + Regulator

D 2

C 1

1000uf

1N4007 +5V

V

L M 7 8 0 5

1 2

3

V I N V O U T

GND

J 1

123

D 3

gnd

D 4

D 1

The regulated DC output is very smooth with no ripple. It is suitable for

all electronic circuits.

The Microcontroller:

In our day to day life the role of micro-controllers has been immense.

They are used in a variety of applications ranging from home appliances,

FAX machines, Video games, Camera, Exercise equipment, Cellular

Page 39: Report Thermal Controller

phones musical Instruments to Computers, engine control, aeronautics,

security systems and the list goes on.

Microcontroller versus Microprocessors:

What is the difference between a microprocessor and microcontroller?

The microprocessors (such as 8086, 80286, 68000 etc.) contain no RAM,

no ROM and no I/O ports on the chip itself. For this reason they are

referred as general- purpose microprocessors. A system designer using

general- purpose microprocessor must add external RAM, ROM, I/O

ports and timers to make them functional. Although the addition of

external RAM, ROM, and I/O ports make the system bulkier and much

more expensive, they have the advantage of versatility such that the

designer can decide on the amount of RAM, ROM and I/o ports needed to

fit the task at hand. This is the not the case with microcontrollers. A

microcontroller has a CPU (a microprocessor) in addition to the fixed

amount of RAM, ROM, I/O ports, and timers are all embedded together

on the chip: therefore, the designer cannot add any external memory, I/O,

or timer to it. The fixed amount of on chip RAM, ROM, and number of

I/O ports in microcontrollers make them ideal for many applications in

which cost and space are critical. In many applications, for example a TV

remote control, there is no need for the computing power of a 486 or even

a 8086 microprocessor. In many applications, the space it takes, the

Page 40: Report Thermal Controller

power it consumes, and the price per unit are much more critical

considerations than the computing power. These applications most often

require some I/O operations to read signals and turn on and off certain

bits. It is interesting to know that some microcontroller’s manufactures

have gone as far as integrating an ADC and other peripherals into the

microcontrollers.

Microcontrollers for Embedded Systems:

In the literature discussing microprocessors, we often see a term

embedded system. Microprocessors and microcontrollers are widely used

in embedded system products. An embedded product uses a

microprocessor (or microcontroller) to do one task and one task only. A

printer is an example of embedded system since the processor inside it

performs one task only: namely, get data and print it. Contrasting this

with a IBM PC which can be used for a number of applications such as

word processor, print server, network server, video game player, or

internet terminal. Software for a variety of applications can be loaded and

run. Of course the reason a PC can perform myriad tasks is that it has

RAM memory and an operating system that loads the application

software into RAM and lets the CPU run it. In an embedded system, there

is only one application software that is burned into ROM. A PC contains

or is connected to various embedded products such as the keyboard,

Page 41: Report Thermal Controller

printer, modem, disk controller, sound card, CD-ROM driver, mouse and

so on. Each one of these peripherals has a microcontroller inside it that

performs only one task. For example, inside every mouse there is a

microcontroller to perform the task of finding the mouse position and

sending it to the PC.

Although microcontrollers are the preferred choice for many

embedded systems, there are times that a microcontroller is inadequate

for the task. For this reason, in many years the manufacturers for general-

purpose microprocessors have targeted their microprocessor for the high

end of the embedded market.

Introduction to 8051:

In 1981, Intel Corporation introduced an 8-bit microcontroller called the

8051. This microcontroller had 128 bytes of RAM, 4K bytes of on-chip

ROM, two timers, one serial port, and four ports (8-bit) all on a single

chip. The 8051 is an 8-bit processor, meaning the CPU can work on only

8- bit pieces to be processed by the CPU. The 8051 has a total of four I/O

ports, each 8- bit wide. Although 8051 can have a maximum of 64K bytes

of on-chip ROM, many manufacturers put only 4K bytes on the chip.

The 8051 became widely popular after Intel

allowed other manufacturers to make any flavor of the 8051 they please

with the condition that they remain code compatible with the 8051. This

Page 42: Report Thermal Controller

has led to many versions of the 8051 with different speeds and amount of

on-chip ROM marketed by more than half a dozen manufacturers. It is

important to know that although there are different flavors of the 8051,

they are all compatible with the original 8051 as far as the instructions are

concerned. This means that if you write your program for one, it will run

on any one of them regardless of the manufacturer. The major 8051

manufacturers are Intel, Atmel, Dallas Semiconductors, Philips

Corporation, Infineon.

AT89C51 From ATMEL Corporation:

This popular 8051 chip has on-chip ROM in the form of flash memory.

This is ideal for fast development since flash memory can be erased in

seconds compared to twenty minutes or more needed for the earlier

versions of the 8051. To use the AT89C51 to develop a microcontroller-

based system requires a ROM burner that supports flash memory:

However, a ROM eraser is not needed. Notice that in flash memory you

must erase the entire contents of ROM in order to program it again. The

PROM burner does this erasing of flash itself and this is why a separate

burner is not needed. To eliminate the need for a PROM burner Atmel is

working on a version of the AT89C51 that can be programmed by the

serial COM port of the PC.

Page 43: Report Thermal Controller

Atmel Microcontroller AT89C51

Hardware features

40 pin Ic.

4 Kbytes of Flash.

128 Bytes of RAM.

32 I/O lines.

Two16-Bit Timer/Counters.

Five Vector.

Two-Level Interrupt Architecture.

Full Duplex Serial Port.

On Chip Oscillator and Clock Circuitry.

Software features

Bit Manipulations

Single Instruction Manipulation

Page 44: Report Thermal Controller

Separate Program And Data Memory

4 Bank Of Temporary Registers

Direct, Indirect, Register and Relative Addressing.

In addition, the AT89C51 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.

The Atmel Flash devices are ideal for developing, since they can be

reprogrammed easy and fast. If we need more code space for our

application, particularly for developing 89Cxx projects with C language.

Atmel offers a broad range of microcontrollers based on the 8051

architecture, with on-chip Flash program memory.

Page 45: Report Thermal Controller

Interal Architecture of AT89C51

Pin description:

The 89C51 have a total of 40 pins that are dedicated for various functions

such as I/O, RD, WR, address and interrupts. Out of 40 pins, a total of 32

pins are set aside for the four ports P0, P1, P2, and P3, where each port

Page 46: Report Thermal Controller

takes 8 pins. The rest of the pins are designated as Vcc, GND, XTAL1,

XTAL, RST, EA, and PSEN. All these pins except PSEN and ALE are

used by all members of the 8051 and 8031 families. In other words, they

must be connected in order for the system to work, regardless of whether

the microcontroller is of the 8051 or the 8031 family. The other two pins,

PSEN and ALE are used mainly in 8031 based systems.

Vcc

Pin 40 provides supply voltage to the chip. The voltage source is

+5V.

GND

Pin 20 is the ground.

Oscillator Characteristics:

Page 47: Report Thermal Controller

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. 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.

Oscillator Connections

It must be noted that there are various speeds of the 8051 family. Speed

refers to the maximum oscillator frequency connected to the XTAL. For

example, a 12 MHz chip must be connected to a crystal with 12 MHz

frequency or less. Likewise, a 20 MHz microcontroller requires a crystal

frequency of no more than 20 MHz. When the 8051 is connected to a

crystal oscillator and is powered up, we can observe the frequency on the

XTAL2 pin using oscilloscope.

RST

Pin 9 is the reset pin. It is an input and is active high (normally low).

Upon applying a high pulse to this pin, the microcontroller will reset and

terminate all activities. This is often referred to as a power –on reset.

Activating a power-on reset will cause all values in the registers to be

Page 48: Report Thermal Controller

lost. Notice that the value of Program Counter is 0000 upon reset, forcing

the CPU to fetch the first code from ROM memory location 0000. This

means that we must place the first line of source code in ROM location

0000 that is where the CPU wakes up and expects to find the first

instruction. In order to RESET input to be effective, it must have a

minimum duration of 2 machine cycles. In other words, the high pulse

must be high for a minimum of 2 machine cycles before it is allowed to

go low.

EA

All the 8051 family members come with on-chip ROM to store programs.

In such cases, the EA pin is connected to the Vcc. For family members

such as 8031 and 8032 in which there is no on-chip ROM, code is stored

on an external ROM and is fetched by the 8031/32. Therefore for the

8031 the EA pin must be connected to ground to indicate that the code is

stored externally. EA, which stands for “external access,” is pin number

31 in the DIP packages. It is input pin and must be connected to either V cc

or GND. In other words, it cannot be left unconnected.

PSEN

This is an output pin. PSEN stands for “program store enable.” It

is the read strobe to external program memory. When the microcontroller

Page 49: Report Thermal Controller

is executing from external memory, PSEN is activated twice each

machine cycle.

ALE

ALE (Address latch enable) is an output pin and is active high.

When connecting a microcontroller to external memory, port 0 provides

both address and data. In other words the microcontroller multiplexes

address and data through port 0 to save pins. The ALE pin is used for de-

multiplexing the address and data by connecting to the G pin of the

74LS373 chip.

I/O port pins and their functions

The four ports P0, P1, P2, and P3 each use 8 pins, making

them 8-bit ports. All the ports upon RESET are configured as output,

ready to be used as output ports. To use any of these as input port, it must

be programmed.

Port 0

Port 0 occupies a total of 8 pins (pins 32 to 39). It can be

used for input or output. To use the pins of port 0 as both input and

output ports, each pin must be connected externally to a 10K-ohm

pull-up resistor. This is due to fact that port 0 is an open drain,

unlike P1, P2 and P3. With external pull-up resistors connected

upon reset, port 0 is configured as output port. In order to make

Page 50: Report Thermal Controller

port 0 an input port, the port must be programmed by writing 1 to

all the bits of it. Port 0 is also designated as AD0-AD7, allowing it

to be used for both data and address. When connecting a

microcontroller to an external memory, port 0 provides both

address and data. The microcontroller multiplexes address and data

through port 0 to save pins. ALE indicates if P0 has address or

data. When ALE=0, it provides data D0-D7, but when ALE=1 it

has address A0-A7. Therefore, ALE is used for de-multiplexing

address and data with the help of latch 74LS373.

Port 1

Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used

as input or output. In contrast to port 0, this port does not require

pull-up resistors since it has already pull-up resistors internally.

Upon reset, port 1 is configures as an output port. Similar to port 0,

port 1 can be used as an input port by writing 1 to all its bits.

Port 2

Port 2 occupies a total of 8 pins (pins 21 to 28). It can be

used as input or output. Just like P1, port 2 does not need any pull-

up resistors since it has pull-up resistors internally. Upon reset port

2 is configured as output port. To make port 2 as input port, it must

be programmed as such by writing 1s to it.

Page 51: Report Thermal Controller

Port 3

Port 3 occupies a total of 8 pins (pins 10 to 17). It can be

used as input or output. P3 does not need any pull-up resistors, the

same as P1 and P2 did not. Although port 3 is configured as output

port upon reset, this is not the way it is most commonly used. Port

3 has an additional function of providing some extremely important

signals such as interrupts. Some of the alternate functions of P3 are

listed below:

P3.0 RXD (Serial input)

P3.1 TXD (Serial output)

P3.2 INT0 (External interrupt 0)

P3.3 INT1 (External interrupt 1)

P3.4 T0 (Timer 0 external input)

P3.5 T1 (Timer 1 external input)

P3.6 WR (External memory write strobe)

P3.7 RD (External memory read strobe)

Memory Space Allocation

1. Internal ROM

The 89C51 has 4K bytes of on-chip ROM. This 4K

bytes ROM memory has memory addresses of 0000 to 0FFFh.

Page 52: Report Thermal Controller

Program addresses higher than 0FFFh, which exceed the internal

ROM capacity, will cause the microcontroller to automatically

fetch code bytes from external memory. Code bytes can also be

fetched exclusively from an external memory, addresses 0000h to

FFFFh, by connecting the external access pin to ground. The

program counter doesn’t care where the code is: the circuit

designer decides whether the code is found totally in internal

ROM, totally in external ROM or in a combination of internal and

external ROM.

2. Internal RAM

The 1289 bytes of RAM inside the 8051 are assigned

addresses 00 to 7Fh. These 128 bytes can be divided into three

different groups as follows:

1. A total of 32 bytes from locations 00 to 1Fh are set aside for

register banks and the stack.

2. A total of 16 bytes from locations 20h to 2Fh are set aside for

bit addressable read/write memory and instructions.

A total of 80 bytes from locations 30h to 7Fh are used for read and write

storage, or what is normally called a scratch pad. These 80 locations of

RAM are widely used for the purpose of storing data and parameters by

8051 programmers.

Interfacing of Microcontroller with LCD

Page 53: Report Thermal Controller

The LCD, which is used as a display in the system, is LMB162A. The

main features of this LCD are: 16*2 display, intelligent LCD, used for

alphanumeric characters & based on ASCII codes. This LCD contains 16

pins, in which 8 pins are used as 8-bit data I/O, which are extended

ASCII. Three pins are used as control lines these are Read/Write pin,

Enable pin and Register select pin. Two pins are used for Backlight and

LCD voltage, another two pins are for Backlight & LCD ground and one

pin is used for contrast change.

LCD pin description

Pin Symbol I/O Description

1 VSS - Ground

2 VCC - +5V power supply

3 VEE - Power supply to control contrast

4 RS I RS=0 to select command register, RS=1 to select data

register.

5 R/W I R/W=0 for write, R/W=1 for read

6 E I/O Enable

7 DB0 I/O The 8 bit data bus

8 DB1 I/O The 8 bit data bus

9 DB2 I/O The 8 bit data bus

10 DB3 I/O The 8 bit data bus

11 DB4 I/O The 8 bit data bus

12 DB5 I/O The 8 bit data bus

13 DB6 I/O The 8 bit data bus

14 DB7 I/O The 8 bit data bus

Liquid Crystal Display:

Liquid crystal displays (LCD) are widely used in recent years as

compares to LEDs. This is due to the declining prices of LCD, the ability

Page 54: Report Thermal Controller

to display numbers, characters and graphics, incorporation of a refreshing

controller into the LCD, their by relieving the CPU of the task of

refreshing the LCD and also the ease of programming for characters and

graphics. HD 44780 based LCDs are most commonly used.

LCD pin description:

The LCD discuss in this section has the most common connector used for

the Hitachi 44780 based LCD is 14 pins in a row and modes of operation

and how to program and interface with microcontroller is describes in this

section.

Vcc

1 61 51 41 31 21 11 098

654321

7

1 61 51 41 31 21 11 0

98

654321

7

D7

E

Vcc

D4

ContrastRS

Gnd

R/W

Gnd

D0

D3

D6D5

13

2

D2D1

LCD Pin Description Diagram

VCC, VSS, VEE

The voltage VCC and VSS provided by +5V and ground respectively while

VEE is used for controlling LCD contrast. Variable voltage between

Ground and Vcc is used to specify the contrast (or "darkness") of the

characters on the LCD screen.

RS (register select)

There are two important registers inside the LCD. The RS pin is used for

their selection as follows. If RS=0, the instruction command code

register is selected, then allowing to user to send a command such as clear

Page 55: Report Thermal Controller

display, cursor at home etc.. If RS=1, the data register is selected,

allowing the user to send data to be displayed on the LCD.

R/W (read/write)

The R/W (read/write) input allowing the user to write information from it.

R/W=1, when it read and R/W=0, when it writing.

EN (enable)

The enable pin is used by the LCD to latch information presented to its

data pins. When data is supplied to data pins, a high power, a high-to-low

pulse must be applied to this pin in order to for the LCD to latch in the

data presented at the data pins.

D0-D7 (data lines)

The 8-bit data pins, D0-D7, are used to send information to the LCD or

read the contents of the LCD’s internal registers. To displays the letters

and numbers, we send ASCII codes for the letters A-Z, a-z, and numbers

0-9 to these pins while making RS =1. There are also command codes

that can be sent to clear the display or force the cursor to the home

position or blink the cursor.

We also use RS =0 to check the busy flag bit to see if the LCD is ready to

receive the information. The busy flag is D7 and can be read when R/W

=1 and RS =0, as follows: if R/W =1 and RS =0, when D7 =1(busy flag

=1), the LCD is busy taking care of internal operations and will not

accept any information. When D7 =0, the LCD is ready to receive new

information.

Interfacing of micro controller with LCD display:

In most applications, the "R/W" line is grounded. This simplifies the

application because when data is read back, the microcontroller I/O pins

have to be alternated between input and output modes.

Page 56: Report Thermal Controller

In this case, "R/W" to ground and just wait the maximum amount of time

for each instruction (4.1ms for clearing the display or moving the

cursor/display to the "home position", 160µs for all other commands) and

also the application software is simpler, it also frees up a microcontroller

pin for other uses. Different LCD execute instructions at different rates

and to avoid problems later on (such as if the LCD is changed to a slower

unit). Before sending commands or data to the LCD module, the Module

must be initialized. Once the initialization is complete, the LCD can be

written to with data or instructions as required. Each character to display

is written like the control bytes, except that the "RS" line is set. During

initialization, by setting the "S/C" bit during the "Move Cursor/Shift

Display" command, after each character is sent to the LCD, the cursor

built into the LCD will increment to the next position (either right or left).

Normally, the "S/C" bit is set (equal to "1")

Interfacing of Microcontroller with LCD

AT

89C

51

9181929

30

31

12345678

2122232425262728

1011121314151617

3938373635343332

RSTXTAL2XTAL1PSEN

ALE/PROG

EA/VPP

P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7

P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15

P3.0/RXDP3.1/TXDP3.2/INTOP3.3/INT1P3.4/TOP3.5/T1P3.6/WRP3.7/RD

P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7

123456789

10111213141516

12345678910111213141516

VCC

VCC

13

33pF

33pF

VCCVCC

22uF

VCC

8.2 K

Page 57: Report Thermal Controller

LCD Command Code

Code

(HEX)

Command to LCD Instruction

Register

1 Clear the display screen

2 Return home

4 Decrement cursor(shift cursor to left)

6 Increment cursor(shift cursor to right)

7 Shift display right

8 Shift display left

9 Display off, cursor off

A Display off, cursor on

C Display on, cursor off

E Display on, cursor blinking

F Display on, cursor blinking

10 Shift cursor position to left

14 Shift cursor position to right

18 Shift the entire display to left

1C Shift the entire display to right

80 Force cursor to the beginning of 1st line

C0 Force cursor to the beginning of 2nd line

38 2 line and 5×7 matrix

Page 58: Report Thermal Controller

Interfacing circuit of Microcontroller & ADC along with LCD:

Interfacing of switches with microcontroller

There are three micro switches in the circuit connected to the

microcontroller pin no. p0.5 to p0.7. One end of each switch is grounded

and other is connected to the microcontroller port with a 10K pull-up, as

in Figure. When switch is pressed that particular port is grounded. The

microcontroller always monitors these switches in real time (i.e. in

continuous mode)

The configuration of the micro switches is as follows:

Switch1 (S1): Increment

Switch2 (S2): Decrement

Page 59: Report Thermal Controller

Switch3 (S3): Set

Interfacing of Switches with µC

Page 60: Report Thermal Controller

Switches outVarious Hardware Tools used are:

Soldering Iron

Soldering Wire

Ribbon wire

Flux

Cutter

Tin wire

De-soldering pump

Multimeter

IC Programmer

PC

Software Tools used are:

Keil compiler

Sunrom’s software to Program the Microcontroller (AT89s52)

Embedded C Language

Basic Tutorials for Keil Software:

1. Open Keil from the Start menu

2. The Figure below shows the basic names of the windows referred in

this document

Page 61: Report Thermal Controller

Starting a new Assembler Project

1. Select New Project from the Project Menu.

Page 62: Report Thermal Controller

2. Name the project ‘Toggle.a51’

3. Click on the Save Button.

4. The device window will be displayed.

5. Select the part you will be using to test with. For now we will use the

Dallas Semiconductor part DS89C420.

Page 63: Report Thermal Controller

6. Double Click on the Dallas Semiconductor.

7. Scroll down and select the DS89C420 Part

8. Click OK

Page 64: Report Thermal Controller

Creating Source File

o Click File Menu and select New.

Page 65: Report Thermal Controller

o A new window will open up in the Keil IDE.

Page 66: Report Thermal Controller

o write any code on this file.

o Click on File menu and select Save as…

5. Name the file with extension (.asm for assembly language code & .c

for embedded C language code).

6. Click the Save Button

Page 67: Report Thermal Controller

Adding File to the Project

1. Expand Target 1 in the Tree Menu

2. Click on Project and select Targets, Groups, Files…

Page 68: Report Thermal Controller

3. Click on Groups/Add Files tab

4. Under Available Groups select Source Group 1

5. Click Add Files to Group… button

Page 69: Report Thermal Controller

6. Change file type to Asm Source file(*.a*; *.src)

7. Click on toggle.a51

8. Click Add button

9. Click Close Button

10. Click OK button when you return to Target, Groups, Files… dialog

box.

Page 70: Report Thermal Controller

11. Expand the Source Group 1 in the Tree menu to ensure that the file

was added to the project.

Creating HEX for the Part

1.Click on Target 1 in Tree menu

Page 71: Report Thermal Controller

2. Click on Project Menu and select Options for Target 1

3. Select Target Tab

4. Change Xtal (Mhz) from 50.0 to 11.0592

Page 72: Report Thermal Controller

5. Select Output Tab

6. Click on Create Hex File check box

7. Click OK Button

Page 73: Report Thermal Controller

8. Click on Project Menu and select Rebuild all Target Files

9. In the Build Window it should report ‘0 Errors (s), 0 Warnings’

10. You are now ready to Program your Part

Page 74: Report Thermal Controller