Академический Документы
Профессиональный Документы
Культура Документы
INTRODUCTION
1
INTRODUCTION
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.
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.
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
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.
7
2.2 8051 ARCHITECTURE
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.
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.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.
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
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.
13
CHAPTER III
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
Specifications:
• Resolution 8 Bits
• Low Power 15 mW
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
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.
Features
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.
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
1) LATCHING RELAY
2) REED RELAY
3) POLE & THROW
21
fig
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.
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.
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.
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
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.
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
#define LEVELO O
#define LEVEL1 1
#define LEVEL2 2
#define LEVEL1_TEMP 50
#define LEVEL2_TEMP 70
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 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
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;
}
38
Lcd Interfacing Module:
#include<8052.h>
#ifndef<LCD_V1>
#define<LCD_V1>
#define LCD_PERT P0
#define RS P0_0
#define RW P0_1
#define EN P0_2
39
EN = 1;
}
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);
}
40
}
if(x == 0)
{
LcdCmd(0*80 + y);
}
if(x == 1)
{
LcdCmd(0*c0 + y);
}
}
Void LcdClear(void)
{
LcdCmd(0x01)
}
#endif
41
REFERENCES
42