Escolar Documentos
Profissional Documentos
Cultura Documentos
Projectee:
1
ACKNOWLEDGEMENT
Date:
APPROVED BY:
HOD……
2
CONTENTS
TABLE OF CONTENTS...................................................................4
OVERVIEW………………………………………………………..…….6
CHAPTER1:
INTRODUCTION ...........................................................................7
REQUIREMENTS...........................................................................9
2.1 Introduction.........................................................................10
2.2 Analog to digital conversion ........................12
2.3 Useful Analog sensors.......................................................13
CHAPTER 3: MICROCONTROLLER
3.1 Introduction…………………………………………………..….23
3.2 P89V51RD2FN Microcontroller......................................................24
3.3 Pin Diagram..........................................................................25
3.4 Pin Descriptions………………………………………………...26
3.5 Data table………………………………………………………….29
CHAPTER 4: ICs
4.1 MAX232……………………………………....…36
4.2 ULN2803……………………………………………………..37
4.3 PCF8591………………………………………………………….37
CONCLUSIONS.............................................................................44
REFERENCES...............................................................................45
TOOLS AND DEVELOPMENT......................................................45
3
OVERVIEW
4
PART 1
INTRODUCTION
1. Analog Sensors
2. Digital Sensors
An analog sensor, such as a CdS cell (Cadmium Sulfide cells measure light
intensity), might be wired into a circuit in a way that it will have an output that
ranges from 0 volts to 5 volts. The value can assume any possible value between 0
and 5 volts. An 'Analog Signal' is one that can assume any value in a range. An
interesting way to think about this is an Analog Signal works like a tuner on an
older radio. You can turn it up or down in a continuous motion. You can fine tune it
by turning the knob ever so slightly.
5
Digital sensors generate what is called a 'Discrete Signal'. This means that there is a
range of values that the sensor can output, but the value must increase in steps.
There is a known relationship between any value and the values preceding and
following it. 'Discrete Signals' typically have a stair step appearance when they are
graphed on chart. If you consider a television sets tuner, it allows you to change
channels in steps.
6
REQUIREMENTS
Computer Interfacing.
Potentiometer (10kohm).
P89V51RD2FN microcontroller.
7
PART 2
ANALOG SENSOR
2.1 INTRODUCTION:
Analog sensors that measure continuous information. An example of this kind of a
sensor is a light sensor which monitors the amount of light over time. Analog
sensors are often distinguished from digital sensors which use discrete
(discontinuous) values to represent information for input. Often though either
approach can be used to provide similar types of information. For example, film
cameras are analog devices, while Web cameras are digital devices.
Consider a push button switch. This is one of the simplest forms of sensors. It has
two discrete values. It is on, or it is off. Other 'discrete' sensors might provide you
with a binary value. A digital compass, for example, may provide you with your
current heading by sending a 9 bit value with a range from 0 to 359. In this case, the
Discrete Signal has 360 possibilities.
The most common discrete sensors used in robotics provide you with a binary
output which has two discrete states. Much of this article assumes a digital signal to
be a binary signal.
8
The function of the A/D converter is to convert an Analog signal into a digital
value. It does this with a mapping function that assigns discrete values to the entire
range of voltages. It is typical for the range of an A/D converter to be 0 to +5 volts.
The A/D converter will divide the range of values by the number of discrete
combinations. For example, the table on the right shows 5 samples of an Analog
Signal that have been converted into digital values.
The range of the Analog Signal is 0 to +5 volts. It is a 8-bit A/D converter, which
has 256 discrete values. Therefore, the A/D converted divides 5 volts by 256 to
yield approximately .0195 volts per unit. The table shows how voltages map to
specific conversion values. I have only included the first five, but the table would
continue up to conversion value 255.
The Chart on the bottom shows the results of the A/D conversions for 14 samples.
The sample numbers are shown along the X axis at the bottom. The left hand Y axis
indicates the voltage of the Analog sample that was fed into the A/D converter. On
the right hand side, the 8-bit value assigned to the conversion is show.
As you can see from the blue line, this was an analog function just like the original
Analog Signal graph shown above. The A/D converter has mapped a set of discrete
values onto this graph.
There are many types of A/D converters on the market. An important feature is the
resolution of the converter. An 8-bit converter is fairly common on
Microcontrollers. There are others. A 10-bit converter, for example, will divide by
1024 samples. A 16-bit A/D converter can do 65356 discrete values. The resolution
required for your application depends on the accuracy your sensor requires. The
higher the resolution, the greater the accuracy
9
2.3 Useful Analog Sensors:
All of the circuits shown in this section are intended to be connected to a A/D
converter port.
CdS cells:
Cadmium-Sulfide is an interesting compound. Its resistance changes readily when
exposed to light energy. Typically, the more light, the lower the resistance. This is
useful for measuring the intensity of light.
10
The CdS cell, shown as P1 in the schematic to the left, has a resistance of 10k in
average operating light. I have chosen R1 to have the value of 10k based on this.
You should test the CdS cell that you are planning to use to determine its average
value. By setting the values close to each other, the average value will be halfway
through the range of possible values.
For example, in average light, the CdS cell has resistance of 10k. Using a resistor
divider equation, I know that the voltage going to the A/D port will be. V = Vcc *
P1 / (P1 + R1) = 5.0 * (10k / (10k + 10k)) = 2.5 volts. Therefore, the A/D port
should read around 128 in average light
In Summary, choosing the value for R1 based on the average reading for the CdS
cell will center the 'average' reading at half of Vcc. Doing so allows you to have
maximum range on your sensor.
11
Potentiometers:
An often overlooked but extremely useful sensor is the good old POT. They are
especially useful for making angular measurements, since most pots only turn
approximately 270 degrees or so. They are great for determining the angles of a
robot arm, for example.
As with the CdS cell, a Potentiometer is a resistive sensor. Almost all resistive
sensors are wired in a similar fashion. As you can see by comparing the schematic
on the right with the CdS schematic, the key is to make the resistive sensor part of a
voltage divider.
The circuit works just like the CdS example. A few things to point out. It is
important that the POT be connected to both Vcc and GND. Otherwise, the divider
network is broken and will not function properly. You also want to insure your POT
is large enough not to allow too much current to flow. A POT with a resistance of >
1k should be fine. A POT with > 100k of resistance is also a good choice, since the
amount of current consumed by the circuit is extremely low.
Notice in this circuit the current limiting resistor R3. This resistor is there to handle
the case when the sweep on the POT is turned all the way to the 'top' position.
Without it, a large amount of current could flow if the output was accidentally
connected to the wrong port, or if the A/D port on your Microcontroller was by-
directional.
12
Using the values in the shown schematic, you can calculate what the voltage ranges
the pot will allow. With the sweep all the way to the 'top', the value for R2 at the
sweep is 10k. The voltage drop across R2 = Vcc * (R2 / (R2 + R3)) = 5.0 * (10k /
(10K + 330)) = 4.84 volts. Thus, the highest digital value will be 4.84 / 0.0195 =
248. Actually, it will be 247 since the A/D conversions are zero based. The lowest
value should be zero, since with the sweep all the way to the bottom, the A/D port
will be connected to GND. Thus, the limiting resistor has reduced the useful range
of the POT.
To increase the range, you can increase the value of R2. For example, using a 100K
pot means 5.0 * (100k / (100k + 330)) = 4.98 volts. Thus, 4.97 / .0195 = 255, which
will be 254 when adjusted for the zero based conversion.
There are two types of potentiometers on the market. Audio and Linear. A Linear
pot changes its value at a linear rate. There is an easy mathematical relationship
between the angular position and the resistance.
An 'Audio Taper' or 'Audio' pot changes its value on a logarithmic scale. These are
not well suited as positional sensors.
13
PART 3
MICROCONTROLLER
3.1 INTRODUCTION:
Microcontrollers are "special purpose computers." Microcontrollers do one
thing well. There are a number of other common characteristics that define
microcontrollers. If a computer matches a majority of these characteristics,
then you can call it a "microcontroller":
Microcontrollers are "embedded" inside some other device (often
a consumer product) so that they can control the features or actions of the
product. Another name for a microcontroller, therefore, is "embedded
controller."
Microcontrollers are dedicated to one task and run one specific
program. The program is stored in (read-only memory) and generally does
not change.
Microcontrollers are often low-power devices. A desktop
computer is almost always plugged into a wall socket and might consume
50 watts of electricity. A battery-operated microcontroller might consume 50
milliwatts.
A microcontroller has a dedicated input device and often (but not
always) has a small LED or LCD display for output. A microcontroller also
takes input from the device it is controlling and controls the device by
sending signals to different components in the device.
In our project we are using P89C51RD2 MICROCONTROLLER.
14
3.2 P89V51RD2FN MICROCONTROLLER
The P89C51RD2 is a low-power, high-performance CMOS 8-bit
microcontroller with 8K bytes of Flash programmable and erasable read
only memory (PEROM). The device is manufactured using Philips’ high-
density nonvolatile memory technology and is compatible with the industry-
standard MCS-51 instruction set and pinout. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Philips P89V51RD2FN is a powerful
microcomputer which provides a highly-flexible and cost-effective solution to
many embedded control applications.
15
3.3 PIN DIAGRAM
16
3.4 PIN DESCRIPTION
VCC:
Supply voltage.
GND:
Ground.
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins
can be used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order address/data
bus during accesses to external program and data memory. In this mode P0
has internal pull ups.
Port 0 also receives the code bytes during Flash programming, and outputs
the code bytes during program verification. External pull ups are required
during program verification.
Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 pins
are pulled high by the internal pull-ups when ‘1’s are written to them and
can be used as inputs in this state. As inputs, Port 1 pins that are externally
pulled LOW will source current (IIL) because of the internal pull-ups. P1.5,
P1.6, P1.7 have high current drive of 16 mA. Port 1 also receives the low-
order address bytes during the external host mode programming and
verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port
2 pins they are pulled high by the internal pull ups and can be used as
inputs. As inputs, Port 2 pins that are externally being pulled low will source
current (IIL) because of the internal pull ups. Port 2 emits the high-order
address byte during fetches from external program memory and during
accesses to external data memory that use 16-bit addresses. In this
application, it uses strong internal pull ups when emitting 1s. During
accesses to external data memory that use 8-bit addresses (MOVX @ RI),
17
Port 2 emits the contents of the P2 Special Function Register. Port 2 also
receives the high-order address bits and some control signals during Flash
programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port
3 pins they are pulled high by the internal pull ups and can be used as
inputs. As inputs, Port 3 pins that are externally being pulled low will source
current (IIL) because of the pull ups. Port 3 also serves the functions of
various special features of the AT89C51 as listed below:
Port 3 also receives some control signals for Flash programming and
verification.
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse
input (PROG) during Flash programming. In normal operation ALE is
emitted at a constant rate of 1/6 the oscillator frequency, and may be used
for external timing or clocking purposes. Note, however, that one ALE pulse
is skipped during each access to external Data Memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC
18
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable
bit has no effect if the microcontroller is in external execution mode.
PSEN:
Program Store Enable is the read strobe to external program memory.
When the microcontroller is executing code from external program memory,
PSEN is activated twice each machine cycle, except that two PSEN
activations are skipped during each access to external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable
the device to fetch code from external program memory locations starting at
0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will
be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin
also receives the 12-volt programming enable voltage(VPP) during Flash
programming, for parts that require12-volt VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2:
Output from the inverting oscillator amplifier.
19
DATA TABLE:
20
OPERATING RANGE:
RELIABILITY CHARACTERISTICS:
21
POWER-UP TIMING:
PIN IMPEDANCE:
22
STATIC CHARACTERISTICS:
23
SPECIAL FUNCTION REGISTERS:
24
25
26
PART 4
ICs
INTRODUCTION:
They are supplied in 16 pin plastic DIP packages with a copper lead frame
to reduce thermal resistance.
27
PIN CONNECTION:
FUNCTION TABLE:
28
29
4.2 ULN 2803
INTRODUCTION:
The ULN2803APG / AFWG Series are high voltage, high current Darlington
drivers comprised of eight NPN Darlington pairs.
All units feature integral clamp diodes for switching inductive loads.
Applications include relay, hammer, lamp and display (LED) drivers.
FEATURES:
30
PIN CONNECTION:
31
32
4.3 PCF8591
INTRODUCTION
The PCF8591 is a single-chip, single-supply low power 8-bit CMOS data
acquisition device with four analog inputs, one analog output and a serial I2C-bus
interface. Three address pins A0, A1 and A2 are used for programming the
hardware address, allowing the use of up to eight devices connected to the I2C-bus
without additional hardware. Address, control and data to and from
the device are transferred serially via the two-line bidirectional I2C-bus.
The functions of the device include analog input multiplexing, on-chip track and
hold function, 8-bit analog-to-digital conversion and an 8-bit digital-to-analog
conversion. The maximum conversion rate is given by the maximum speed of the
I2C-bus
FEATURES
· Single power supply
· Operating supply voltage 2.5 V to 6 V
· Low standby current
· Serial input/output via I2C-bus
· Address by 3 hardware address pins
· Sampling rate given by I2C-bus speed
· 4 analog inputs programmable as single-ended or differential inputs
· Auto-incremented channel selection
· Analog voltage range from VSS to VDD
· On-chip track and hold circuit
· 8-bit successive approximation A/D conversion
· Multiplying DAC with one analog output
33
APPLICATIONS
· Closed loop control systems
· Low power converter for remote data acquisition
· Battery operated equipment
· Acquisition of analog values in automotive, audio and TV applications.
PIN CONNECTION:
34
Block Diagram:
35
PART 5
OVER ALL SYSTEM
36
5.2 HARDWARE
Interfacing
Interfacing is an important task to be accomplished in almost all
automation applications. The digital signals are to be generated to make the
hardware run as per the instructions of program.
In the present application, the programming is done in .C. programming
language. .C. is chosen for its simplicity and ruggedness. It offers simple
methods to interact with the serial port through which the interfacing is
done.
CONCLUSION
The project was successfully completed after a lot of efforts and work hours. This
project underwent compiling, debugging, removing errors, make it bug free, adding
more facilities & interactivity, make it more reliable and user friendly.
Guidance was taken from faculty; help from the friend were accepted at the various
project development phases. Many books related to controlling of microcontroller
were referred to get the desired results.
37
REFERENCES
SITES:
http://www.google.com
http://www.wikipedia.com
BOOKS:
39