Вы находитесь на странице: 1из 42

CHAPTER I

INTRODUCTION

1
INTRODUCTION

Embedded systems are finding increasing application not only in domestic


applications but also in areas of industrial automation, automobiles, power
electronics, defence and space equipments. Micro controllers are the basic building
blocks for many embedded systems.

In spite of revolutionary advances in the field of electronics,


micro controllers play a major role in the design of embedded control systems during
the past two decades. They are available in 8-bit, 16-bit and 32-bit versions and are
manufactured by a number of leading companies like Intel, Motorola, Philips, Hitachi,
Atmen, Microchip, Dallas, Siemens etc., . They are available in the market with
various configurations for different applications.

1.1 How the data is collected?

Sensors are used to input the data into the data-logging equipment.
Almost any physical property can be measured with the correct sensor. The data
logger collects the data at regular intervals (the logging interval) for a set length of
time (the logging period).There are two categories of sensors:

Digital sensors - these are either on or off i.e. a light gate sensing something breaking
a light beam. Such sensors can often be connected directly to a computer as the data
output is already digital
Analog sensors - these measure some physical quantity by converting it into a voltage.
The voltage signal is then converted into digital form by an interface and either stored
or transferred directly to a computer. The vast majority of sensors are of this type.

1.2 How the data is stored?

The data that is logged is usually stored in RAM memory or on some


form of backing storage as it is collected .Some data-logging equipment is designed to
be linked directly to a computer (this could be a wireless link). This would be suitable

2
if an experiment is taking place in the laboratory for example .If you wanted to record
data out in the field then battery powered data-logging equipment would be needed
that could measure and store the data until the unit is collected. The equipment would
then be connected to a computer so the data can be down-loaded. This data collection
could still be done out in the field if a portable computer was used to collect the data.

1.3 How the data can be displayed?

Once downloaded to a computer, the different types of data and are display it
more clearly by the hyper terminal.

3
RELAY ADC0808
FAN

SENSORS

8051
MICROCONTROLLER

REGULATED
POWER
SUPPLY

4
CHAPTER II
INTRODUCTION TO EMBEDDED SYSTEM AND
MICROCONTROLLER

5
2.1 INTRODUCTION TO EMBEDDED SYSTEM

2.1.1 EMBEDDED SYSTEM

An embedded system is a special-purpose computer system designed to perform one


or a few dedicated functions, sometimes with real-time computing constraints. It is
usually embedded as part of a complete device including hardware and mechanical
parts. In contrast, a general-purpose computer, such as a personal computer, can do
many different tasks depending on programming. Embedded systems have become
very important today as they control many of the common devices we use.
Since the embedded system is dedicated to specific tasks, design engineers can
optimize it, reducing the size and cost of the product, or increasing the reliability and
performance. Some embedded systems are mass-produced, benefiting from
economies of scale.

Physically, embedded systems range 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. Complexity varies from
low, with a single microcontroller chip, to very high with multiple units, peripherals
and networks mounted inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many


systems have some element of programmability. For example, Handheld computers
share some elements with embedded systems — such as the operating systems and
microprocessors which power them — but are not truly embedded systems, because
they allow different applications to be loaded and peripherals to be connected.

An embedded system is some combination of computer hardware and


software, either fixed in capability or programmable, that is specifically designed for a
particular kind of application device. Industrial machines, automobiles, medical
equipment, cameras, household appliances, airplanes, vending machines, and toys (as
well as the more obvious cellular phone and PDA) are among the myriad possible

6
hosts of an embedded system. Embedded systems that are programmable are provided
with a programming interface, and embedded systems programming is a specialized
occupation.

Certain operating systems or language platforms are tailored for the embedded
market, such as Embedded Java and Windows XP Embedded. However, some low-
end consumer products use very inexpensive microprocessors and limited storage,
with the application and operating system both part of a single program. The program
is written permanently into the system's memory in this case, rather than being loaded
into RAM (random access memory), as programs on a personal computer.

2.1.2 MICROCONTROLLERS FOR EMBEDDED SYSTEMS

In the Literature discussing microprocessors, we often see the term Embedded


System. Microprocessors and Microcontrollers are widely used in embedded system
products. An embedded system product uses a microprocessor (or Microcontroller) to
do one task only. A printer is an example of embedded system since the processor
inside it performs one task only; namely getting the data and printing it. Contrast this
with a Pentium based PC. A PC can be used for any number of applications such as
word processor, print-server, bank teller terminal, Video game, network server, 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 memory and lets the
CPU run it.

In an Embedded system, there is only one application software that is typically


burned into ROM. An x86 PC contains or is connected to various embedded products
such as keyboard, printer, modem, disk controller, sound card, CD-ROM drives,
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. Table 1-1 lists
some embedded products.

7
2.2 8051 ARCHITECTURE

The generic 8051 architecture supports a Harvard architecture, which


contains two separate buses for both program and data. So, it has two
distinctive memory spaces of 64K X 8 size for both programmed and data. It is
based on an 8 bit central processing unit with an 8 bit Accumulator and
another 8 bit B register as main processing blocks. Other portions of the
architecture include few 8 bit and 16 bit registers and 8 bit memory
locations.

Each 8051 device has some amount of data RAM built in the device for
internal processing. This area is used for stack operations and temporary
storage of data.
This bus architecture is supported with on-chip peripheral functions like I/O
ports, timers/counters, versatile serial communication port. So it is clear that
this 8051 architecture was designed to cater many real time embedded needs.

2.21 FEATURES OF 8051 ARCHITECTURE


 Optimized 8 bit CPU for control applications and extensive Boolean
processing capabilities.
 64K Program Memory address space.
 64K Data Memory address space.
 128 bytes of on chip Data Memory.
 32 Bi-directional and individually addressable I/O lines.
 Two 16 bit timer/counters.
 Full Duplex UART.
 6-source / 5-vector interrupt structure with priority levels.
 On chip clock oscillator.
Now we may be wondering about the non-mentioning of memory space
meant for the program storage, the most important part of any embedded
controller. Originally this 8051 architecture was introduced with on-chip, ‘one

8
time programmable’ version of Program Memory of size 4K X 8. Intel
delivered all these microcontrollers (8051) with user’s program fused inside
the device. The memory portion was mapped at the lower end of the Program
Memory area. But, after getting devices, customers couldn’t change any thing
in their program code, which was already made available inside during
device fabrication.

2.2.2 BLOCK DIAGRAM OF 8051

Figure 4.1 - Block Diagram of the 8051 Core


So, very soon Intel introduced the 8051 devices with re-programmable
type of Program Memory using built-in EPROM of size 4K X 8. Like a regular
EPROM, this memory can be re-programmed many times. Later on Intel started
manufacturing these 8031 devices without any on chip Program Memory.

2.3 MICROPROCESSOR
A microprocessor as a term has come to be known is a general-purpose digital
computer central processing unit. Although popularly known as a computer on a chip.

The microprocessor contains arithmetic and logic unit, program counter, Stack
pointer, some working registers, clock timing circuit and interrupt circuits.

9
To make a complete computer one must add memory usually RAM & ROM,
memory decoders, an oscillator and number of I/O devices such as parallel and serial
data ports in addition special purpose devices such as interrupt handlers and counters.

The key term in describing the design of the microprocessor is “general


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

The prime use of microprocessor is to read data, perform extensive


calculations on that data and store those calculations in a mass storage device. The
programs used by the microprocessor are stored in the mass storage device and loaded
in the RAM as the user directs. A few microprocessor programs are stored in the
ROM. The ROM based programs are primarily are small fixed programs that operate
on peripherals and other fixed device that are connected to the system
BLOCK DIAGRAM OF MICROPROCESSOR

10
2.4 MICROCONTROLLER
Micro controller is a true computer on a chip the design incorporates all of the
features found in a microprocessor CPU: arithmetic and logic unit, stack pointer,
program counter and registers. It has also had added additional features like RAM,
ROM, serial I/O, counters and clock circuit.
Like the microprocessor, a microcontroller is a general purpose device, but
one that is meant to read data, perform limited calculations on that data and control
it’s environment based on those calculations. The prime use of a microcontroller is
to control the operation of a machine using a fixed program that is stored in ROM
and that does not change over the lifetime of the system.
The design approach of a microcontroller uses a more limited set of single byte
and double byte instructions that are used to move code and data from internal
memory to ALU. Many instructions are coupled with pins on the IC package; the
pins are capable of having several different functions depending on the wishes of
the programmer.

The microcontroller is concerned with getting the data from and on to its own
pins; the architecture and instruction set are optimized to handle data in bit and byte
size.

11
2.4.1 FUNCTIONAL BLOCKS OF A MICROCONTROLLER

2.4.2 CRITERIA FOR CHOOSING A MICROCONTROLLER

1. The first and foremost criterion for choosing a microcontroller is that it must
meet task at hands efficiently and cost effectively. In analyzing the needs of a
microcontroller based project we must first see whether it is an 8-bit, 16-bit or
32-bit microcontroller and how best it can handle the computing needs of the
task most effectively. The other considerations in this category are:

12
(a) Speed: The highest speed that the microcontroller supports
(b) Packaging: Is it 40-pin DIP or QPF or some other packaging format?
This is important in terms of space, assembling and prototyping the
End product.
(c) Power Consumption: This is especially critical for battery-powered
Products.
(d) The amount of RAM and ROM on chip
(e) The number of I/O pins and timers on the chip.
(f) Cost per unit: This is important in terms of final product in which
a microcontroller is used.
2. The second criteria in choosing a microcontroller are how easy it is to develop
products around it. Key considerations include the availability of an
assembler, debugger, a code efficient ‘C’ language compiler, emulator,
technical support and both in house and outside expertise. In many cases third
party vendor support for chip is required.

3. The third criteria in choosing a microcontroller is it readily available in


needed quantities both now and in future. For some designers this is even
more important than first two criteria’s. Currently, of leading 8–bit
microcontrollers, the 89C51 family has the largest number of diversified
(multiple source) suppliers. By suppliers meant a producer besides the
originator of microcontroller in the case of the 89C51, which was originated
by Intel, several companies are also currently producing the 89C51. Viz:
INTEL, ATMEL, These companies include PHILIPS, SIEMENS, and
DALLAS-SEMICONDUCTOR. It should be noted that Motorola, Zilog and
Microchip Technologies have all dedicated massive resource as to ensure
wide and timely availability of their product since their product is stable,
mature and single sourced. In recent years they also have begun to sell the
ASIC library cell of the microcontroller.

13
CHAPTER III

 INTRODUCTION TO ANALOG TO DIGITAL


CONVERSION
 DESCRIPTION OF ADC0808

14
3.1 ANALOG TO DIGITAL CONVERTER ADC:
INTRODUCTION
ADC0808:
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. 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,
ADC0809 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
suited to applications from process and machine control to consumer and automotive
applications.

PIN DIAGRAM

Channel selection:
15
The device contains an 8-channel single-ended analog signal
multiplexer. A particular input channel is selected by using the address decoder. Table
1shows the input states for the address lines to select any channel. The address is
latched into the decoder on the low-to-high transition of the address latch enable
signal.

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

• Standard hermetic or molded 28-pin DIP package

• 28-pin molded chip carrier package

Specifications:

• Resolution 8 Bits

• Total Unadjusted Error ±1⁄2 LSB

• Single Supply 5 VDC

• Low Power 15 mW

• Conversion Time 100 µs

3.2 TEMPERATURE SENSOR

The LM35 series are precision integrated-circuit temperature sensors, whose


output voltage is linearly proportional to the Celsius (Centigrade) temperature. The
LM35 thus has an advantage over linear temperature sensors calibrated in § Kelvin, as

16
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 g(/4§Cat room temperature and g*/4§C over
a full b55 to a150§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 mA 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 b55§ to a150§C temperature range, while the
LM35C is rated for a b40§ to a110§C Range (b10§ 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

LM35 Precision Centigrade Temperature Sensors 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
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
theLM35C 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-92transistor

17
package. The LM35D is also available in an 8-leadsurface mount small outline
package and a plastic TO-220 Package.

Figure:3.1 Small outline modified package

Features

• Calibrated directly in ° Celsius (Centigrade)

• Linear + 10.0 mV/°C scale factor

• 0.5°C accuracy guaranteeable (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 for 1 mA load

3.3 RELAY UNIT

What is a relay?

18
A relay is a simple electromechanical switch made up of an electromagnet and a set
of contacts. Relays are found hidden in all sorts of devices. In fact, some of the first
computers ever built used relays to implement Boolean gates.

Fig: An open relay

Fig: Relay description

19
Relay Applications

In general, the point of a relay is to use a small amount of power in the electromagnet
coming, say, from a small dashboard switch or a low-power electronic circuit -- to
move an armature that is able to switch a much larger amount of power. For example,
you might want the electromagnet to energize using 5 volts and 50 milliamps (250
mill watts), while the armature can support 120V AC at 2 amps (240 watts).
Relays are quite common in home appliances where there is an electronic control
turning on something like a motor or a light. They are also common in cars, where the
12V supply voltage means that just about everything needs a large amount of current.
In later model cars, manufacturers have started combining relay panels into the fuse
box to make maintenance easier. For example, the six gray boxes in this photo of a
Ford Windstar fuse box are all relays:
In places where a large amount of power needs to be switched, relays are
often cascaded. In this case, a small relay switches the power needed to drive a much
larger relay, and that second relay switches the power to drive the load.
Relays can also be used to implement Boolean logic.

A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by an electro magnet to
open or close one or many sets of contacts. It was invented by Joseph Henry in 1835.
Because a relay is able to control an output circuit of higher power than the input
circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier.

OPERATION:
When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either makes
or breaks a connection with a fixed contact. When the current to the coil is switched
off, the armature is returned by a force approximately half as strong as the magnetic
force to its relaxed position. Usually this is a spring, but gravity is also used
commonly in industrial motor starters. Most relays are manufactured to operate
quickly. In a low voltage application, this is to reduce noise. In a high voltage or high
current application, this is to reduce arcing.

20
If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a spike of voltage and might cause damage to circuit components.
Some automotive relays already include that diode inside the relay case. Alternatively
a contact protection network, consisting of a capacitor and resistor in series, may
absorb the surge. If the coil is designed to be energized with AC, a small copper ring
can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-
phase current, which increases the minimum pull on the armature during the AC
cycle. By analogy with the functions of the original electromagnetic device, a solid-
state relay is made with a thyristor or other solid-state switching device. To achieve
electrical isolation an optocoupler can be used which is a light-emitting diode (LED)
coupled with a photo transistor

TYPES OF RELAY:

fig

Small relay as used in electronics

1) LATCHING RELAY
2) REED RELAY
3) POLE & THROW

21
fig

Circuit symbols of relays.


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

22
CHAPTER IV
LCD INTERFACING

23
4.1 Introduction
The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will
discuss about character based LCDs, their interfacing with various microcontrollers,
various interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with
these simple looking LCDs which can give a new look to your application.

Pin Description
The most commonly used LCD’s found in the market today are 1 Line, 2 Line or 4
Line LCDs which have only 1 controller and support at most of 80 characters,
whereas LCDs supporting more than 80 characters make use of 2 HD44780
controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections). Pin description is shown in the
table below.

Pin No. Name Description


Pin no. 1 VSS Power supply (GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
0 = Instruction input
Pin no. 4 RS
1 = Data input
0 = Write to LCD module
Pin no. 5 R/W
1 = Read from LCD module
Pin no. 6 EN Enable signal
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)

DDRAM - Display Data RAM

24
Display data RAM (DDRAM) stores display data represented in 8-bit character codes.
Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM
(DDRAM) that is not used for display can be used as general data RAM. So whatever
you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only
16 characters are visible, so whatever you write after 16 chars is written in DDRAM
but is not visible to the user.

4-bit programming of LCD


In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the
lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of
initialization that tells the LCD controller that user has selected 4-bit mode of
operation. We call this special sequence as resetting the LCD. Following is the reset
sequence of LCD.
 Wait for about 20mS
 Send the first init value (0x30)
 Wait for about 10mS
 Send second init value (0x30)
 Wait for about 1mS
 Send third init value (0x30)
 Wait for 1mS
 Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)
 Wait for 1mS

The busy flag will only be valid after the above reset sequence. Usually we do not use
busy flag in 4-bit mode as we have to write code for reading two nibbles from the
LCD. Instead we simply put a certain amount of delay usually 300 to 600uS. This
delay might vary depending on the LCD you are using, as you might have a different
crystal frequency on which LCD controller is running. So it actually depends on the
LCD module you are using.

In 4-bit mode, we only need 6 pins to interface an LCD. D4-D7 are the data pins
connection and Enable and Register select are for LCD control pins. We are not using
Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we have
25
made it grounded permanently. If you want to use it, then you may connect it on your
controller but that will only increase another pin and does not make any big
difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data
pins of LCD i.e. D0-D3 are connected to ground.

Sending data/command in 4-bit Mode


We will now look into the common steps to send data/command to LCD when
working in 4-bit mode. In 4-bit mode data is sent nibble by nibble, first we send
higher nibble and then lower nibble. This means in both command and data sending
function we need to separate the higher 4-bits and lower 4-bits.

The common steps are:


 Mask lower 4-bits
 Send to the LCD port
 Send enable signal
 Mask higher 4-bits
 Send to LCD port
 Send enable signal

4.2 REGULATED POWER SUPPLY

A variable regulated power supply, also called a variable bench power


supply, is one where you can continuously adjust the output voltage to your
requirements. Varying the output of the power supply is the recommended way
to test a project after having double checked parts placement against circuit
drawings and the parts placement guide.

26
This type of regulation is ideal for having a simple variable bench power
supply. Actually this is quite important because one of the first projects a
hobbyist should undertake is the construction of a variable regulated power
supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much
handier to have a variable supply on hand, especially for testing.
Most digital logic circuits and processors need a 5 volt power supply. To use
these parts we need to build a regulated 5 volt source. Usually you start with an
unregulated power To make a 5 volt power supply, we use a LM7805 voltage
regulator IC (Integrated Circuit). The IC is shown below.

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.

CIRCUIT FEATURES

Brief description of operation: Gives out well regulated +5V output, output
current capability of 100 mA
Circuit protection: Built-in overheating protection shuts down output when
regulator IC gets too hot
Circuit complexity: Very simple and easy to build

27
Circuit performance: Very stable +5V output voltage, reliable operation
Availability of components: Easy to get, uses only very common basic
components
Design testing: Based on datasheet example circuit, I have used this circuit
succesfully as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply
Power supply voltage: Unreglated DC 8-18V power supply
Power supply current: Needed output current + 5 mA
Component costs: Few dollars for the electronics components + the input
transformer cost

BLOCK DIAGRAM

EXAMPLE CIRCUIT DIAGRAM:

28
29
CHAPTER 5
PROJECT CIRCUITRY

30
31
In continuously monitoring the surrounding temperature of industrial applications
‘Data Acquisition System’ plays a vital role. A simple prototype of such system has
been designed. The system uses the temperature sensor LM35, ADC0808 + 555 timer,
microcontroller, an LCD display and FAN through a relay. The ADC0808 reads the
temperature sensor data, converts the analog data into digital and after processing the
calibrated temperature is displayed on the HyperTerminal.

5.2 Hardware design for temperature controller using P89C51:


The schematic diagram of the hardware required to implement this prototype
is given in Figure (1.The temperature sensor used is LM35. It has a resolution of
10mV/ºC when used without any external circuitry or components. P89C51 is used to
implement the controller software. Temperature sensor has been connected to the
channel zero of ADC. Microcontroller processes the data and sends to its LCD display
and depending on the temperature the speed of fan is controlled. Reset button
provides reset option for microcontroller.

32
Conclusion
Depending on the temperature the speed of fan is controlled. It would be better if we
control the AC fan, the only consideration to be taken the current capacity of the relay.
The operation of the system is perfect and there are no loop holes.

33
APPENDIX I

Industrial Monitoring And Control System:


# include<8052.h>
#include<LcdV1.h>
#include<AdcV1.h>
#include<VerV1.h>

#define LEVELO O
#define LEVEL1 1
#define LEVEL2 2

#define LEVEL1_TEMP 50
#define LEVEL2_TEMP 70

#define RELAY P2_4


#define RELAY P2_5
#define ON 0
#define OFF 1

unsigned char gucControllerstatus [2];


unsigned int guiIterations = 0;

void main(void)
{
unsigned int I =0;
unsigned int j = 0;
unsigned char ucADDrCounter = 0;
ucSensor[3];
ucAscii[4];
unsigned char ucSmsData[30];
unsigned char ucLevel = LEVEL0;

LcdInit();
DisplayVerson();
gucContollerStatus[0] = 0;
gucContollerStatus[1] = 0;

RELAY1 = OFF;
RELAY2 = OFF;

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

34
while(1)
{
guiIterations ++;
if(guiIterations > 10)
guiIterations = 10;
ReadSensorData(ucAddrCounter,& ucSensorValue [ucAddrCounter]);
ucSensorValue [ucAddrCounter](ucSensorValue[ucAddrCounter]*2);
ToAsciiDecimal(ucSensorvalue)[ ucAddrCounter], & ucAscii[0]);
LcdInit();
LcdPuts(“Temp Value :”);
LcdCmd(NEW_LINE);
LcdPuts(“ ”);
LcdPutC(ucAscii[0]);
LcdPutC(ucAscii[1]);
LcdPutC(ucAscii[2]);

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

switch(ucLevel)
{
Case LEVEL0;
if(ucSensorValue[ucAddrCounter]> LEVEL1_TEMP)
{
if(ucSensorValue[ucAddrCounter]> LEVEL2_TEMP)
ucLevel = LEVEL2;
else
ucLevel = LEVEL1;
}
LcdInit();
LcdPuts(“Temperature :”);
LcdCmd(NEW_LINE);
LcdPuts(“ LEVEL0 ”);
RELAY1 = OFF;
RELAY2 = OFF;
Break;
Case LEVEL1;
if(ucSensorValue[ucAddrCounter]> LEVEL1_TEMP)
{
ucLevel = LEVEL0;
}
if(ucSensorValue[ucAddrCounter]> LEVEL2_TEMP)
{
ucLevel = LEVEL2;
}

35
LcdInit();
LcdPuts(“ Temperature ”);
LcdCmd(NEW_LINE);
LcdPuts(“ LEVEL1 ”);
Case LEVEL2;
if(ucSensorValue[ucAddrCounter]> LEVEL2_TEMP)
{
if(ucSensorValue[ucAddrCounter]> LEVEL1_TEMP)
ucLevel = LEVEL0;
else
ucLevel = LEVEL1;
}
LcdInit();
LcdPuts(“ Temperature ”);
LcdCmd(NEW_LINE);
LcdPuts(“ LEVEL2 ”);
RELAY1 = OFF;
RELAY2 = ON;
break;
default;
ucLevel = LEVEL0;
break;
}
}
}

36
Adc Interfacing Module:

#include<8052.h>

#ifndef<ADC_V1>
#define<ADC_V1>

#define D0 P1_0
#define D1 P1_1
#define D2 P1_2
#define D3 P1_3
#define D4 P1_4
#define D5 P1_5
#define D6 P1_6
#define D7 P1_7
#define D P1

#define ADDR_A P3_4


#define ADDR_B P3_5
#define ADDR_C P3_6

#define LIGHT_SENS 1
#define TEMP_SENS 0
#define FIRE_SENS 2
#define SC P2_0
#define EOC P2_1
#define OE P2_2
#define ALE P3_7

Unsigned char gucSensor0Val = 0;


Unsigned char gucSensor1Val = 0;
Unsigned char gucSensor2Val = 0;

Void ReadSensorData(unsigned char ucAddr,unsigned char *ucp Value)


Void AdcDelay 1ms(void);

Void ReadSensorData(unsigned char ucAddr,unsigned char *ucp Value)


{
Unsigned int ucDelay = 0;
Unsigned int ucDelay = 0;

Switch(ucAddr)
{
Case TEMP_SENS
ADDR_A = 1;

37
ADDR_B = 1;
ADDR_C = 0;
break;
Case LIGHT_SENS
ADDR_A = 0;
ADDR_B = 0;
ADDR_C = 1;
break;
Case FIRE_SENS:
ADDR_A = 0;
ADDR_B = 0;
ADDR_C = 0;
break;
default;
break;
}
AdcDelay 1ms;
ALE = 1;
SC =1;

ALE = 0;
SC = 0;
for(ucDelay = 0; ucDelay < 10; ucDelay++)
AdcDelay 1ms();

OE = 1;
AdcDelay 1ms();
*ucp Value = D;
OE = 0;
}

Void AdcDelay 1ms(void)


{
unsigned int x,y;
for(x=0;x<1200;x++)
for(y=0;y<3;y++)
}
# endif

38
Lcd Interfacing Module:

#include<8052.h>

#ifndef<LCD_V1>
#define<LCD_V1>

#define LCD_DELAY 400

#define LCD_PERT P0
#define RS P0_0
#define RW P0_1
#define EN P0_2

#define INIT_CMD 0xoF


#define NEW_LINE 0xc0
bit gbStatus = 0;

Void Delay(unsigned int j)


{
unsigned int i;
for(i=0;i<j;i++)
}

Void LcdInitWrite(unsigned char ucCmd)


{
RS =0;
RW = 0;
LCD_PORT = ucCmd;
}

Void LcdCmd(unsigned char ucCmd)


{
insigned char ucTemp;
if(gbStatus)
{
gbStatus = 0;
goto NEXT;
}
RS = 0;
NEXT:
RW = 0;
ucTemp = ucCmd;
ucTemp & = 0xf0;
LCD_PORT1 = ucTemp;

39
EN = 1;
}

Void LcdData(unsigned char ucData)


{
gbStatus = 1;
RS = 1;
LcdCmd(ucData);
}

Void LcdInit(void)
{
Delay(Lcd_DELAY);
LcdInitWrite(0x30);
Delay(LCD_DELAY);
LcdInitWrite(0x30);
Delay(LCD_DELAY);
LcdInitWrite(0x30);
Delay(LCD_DELAY);
LcdInitWrite(0x20);
Delay(LCD_DELAY);
LcdCmd(0x28);
Delay(LCD_DELAY);
LcdCmd(0x85);
Delay(LCD_DELAY);
LcdCmd(0x85);
Delay(LCD_DELAY);
LcdCmd(6);
Delay(LCD_DELAY);
LcdCmd(1);
Delay(LCD_DELAY);
}

Void LcdPuts(unsigned char *ucStr)


{
Unsigned int I;

for(i = 0; ucStr[i] ! ; i++)


LcdData(ucStr[i]);
}

Void LcdPutc(unsigned char ucCh)


{
LcdData(ucCh);

40
}

Void LcdGotoXY(unsigned char x, unsigned char y)


{

if(x == 0)
{
LcdCmd(0*80 + y);
}
if(x == 1)
{
LcdCmd(0*c0 + y);
}
}

Void LcdClear(void)
{
LcdCmd(0x01)
}
#endif

41
REFERENCES

1. Customizing and programming ur pic microcontroller- Myke Predcko


2. Complete guide to pic microcontroller -e-book
3. C programming for embedded systems- Kirk Zurell
4. Teach yourself electronics and electricity- Stan Giblisco
5. Embedded Microcomputer system- onathan w. Valvano(2000)
6. Embedded PIC microcontroller- John Peatman
7. Microchips.com
8. http://www.mikroelektronika.co.yu/English/product/books/PICbook/O_Uvod.htm
9. How stuff works.com

42

Вам также может понравиться