Sei sulla pagina 1di 51

CONTENTS

SL. PARTICULAR PAGE


NUM. NUM.
1 Introduction

2 DC Motor speed measurement

3 DC Motor

4 LCD 16*2

5 Power Supply

6 Principle of Operation and construction

7 Proximity sensor

8 KEIL Software and Flashing

9 Conclusion

Bibliography
Tachometer

A tachometer is an instrument designed to measure the rotation


speed of an object, such as a gauge in an automobile that
measures the revolutions per minute (RPMs) of the engine's
crankshaft. The word "tachometer" is derived from the Greek
words tachos, meaning "speed," and metron, meaning "to
measure." This device traditionally is laid out with a dial, a needle
that indicates the current reading and markings that indicate safe
and dangerous levels. Digital tachometers have become more
common, however, and they give numerical readings instead of
using dials and needles.

Contents

1 History

2 Advantages

3 Applications

1. History

The first mechanical tachometers were based on measuring


the centrifugal force, similar to the operation of a centrifugal
governor. The inventor is assumed to be the German
engineer Dietrich Uhlhorn; he used it for measuring the
speed of machines in 1817. Since 1840, it has been used to
measure the speed of locomotives.
2. Advantages

 It avoids the accidents


 Any inter locks in between the Motor and Tachometer
may cause for accident.
 If spark is liberating from the tip of the normal
tachometer there may chances of fire catch (in some
critical paces chances of blast).
 It gives the accurate value.
 Output of meter requires less than 1 second.
 Simple in construction.
 Mobile meter(small in size too handy)
 No need of any skilled person to operate this equipment
 Cheap in cost.
 Less maintenance (changing of batteries periodically).

3. Applications

 Used in auto mobiles (bus, car, bikes).


 Used in locomotive trains.
 Used in industries for special cases.
 Used in almost rotary parts or moving cases.
DC MOTOR SPEED MEASUREMENT

INTRODUCTION
In this project we are measuring the dc motor speed. Because in some
process industries there is a limitation to the motor speed suppose it exceeds
specified limit then it will affect whole process from this project we can over come
this problem

DESCRIPTION
This project “DC MOTOR SPEED MEASUREMENT” is a system used for
measuring of DC MOTOR speed using opto coupler.

Working of this module has follows, here we were connected blade to DC


MOTOR shaft and we have fix the motor module such that blade has move in
between opto coupler then opto coupler will give high output for each rotation.
This signal we are giving to microcontroller then microcontroller count those
pulses in one minute and this data is displaying in the LCD. Here we using
P89V51RD2 microcontroller for processing information.

8051 architecture based AT89S52(or AT89C52) microcontroller from NxP


is used to implement this project. Microcontroller acts as the heart of the project,
which controls the whole system. It contains 1k RAM, 64k Flash, 3 Timers, 2
external interrupts, 1 UART, 32 GPIO’s, ISP programming support etc. KEIL IDE
is used to program the microcontroller and the coding will be done using
Embedded C.
COMPONENTS USED

1. Microcontroller - AT89S52 (or AT89C52)


2. GSM module
3. Driver circuit for motor
4. AC motor

BLOCK DIAGRAM

SOFTWARES USED

1. Embedded C
2. Keil Compiler
3. Flash Magic
2.5 DRIVER CIRCUITS
Here the driver circuits are used to control the operations of firing unit, laser
unit & audio reception unit present on the robotic module. Here three types of
driver circuits are used they are ground driver, laser driver and motor driver circuit.

2.5.1 MOTOR DRIVER CIRCUIT

The Device is a monolithic integrated high voltage, high current four


channel driver designed to accept standard DTL or TTL logic levels and drive
inductive loads (such as relays solenoids, DC and stepping motors) and switching
power transistors. We have used this driver circuit too drive the motors of the
robot. Each L293D is used to drive two motors.

Figure 4.7: Motor Driver Circuit


Two L293D’s are used to drive four motors. When both the inputs are low
the motor will be in the halt state, when the first input is high and the second input
is low the motor will move in the forward direction, when first input is low and
second input is high the motor will move in the reverse direction and when both
the inputs are low the motor will be in the halt state.
2.6 MOTORS
NR-DC-ECO is high quality low cost DC geared motor. It contains Brass
gears and steel pinions to ensure longer life and better wear and tear properties.
The gears are fixed on hardened steel spindles polished to a mirror finish. These
spindles rotate between bronze plates which ensures silent running. The output
shaft rotates in a sintered bushing. The whole assembly is covered with a plastic
ring. All the bearings are permanently lubricated and therefore require no
maintenance. The motor is screwed to the gear box from inside.

Figure3.7: 12v 100 rpm DC Geared Motor


ALPHA-NUMERIC LCD DISPLAY

A liquid crystal display (LCD) is a flat panel display, electronic visual


display, based on on Liquid Crystal Technology.

A liquid crystal display consists of an array of tiny segments (called pixels) that
can be manipulated to present information. Liquid crystals do not emit light
directly instead they use light modulating techniques.

LCDs are used in a wide range of applications, including computer monitors,


television, instrument panels, aircraft cockpit displays, signage, etc. They are
common in consumer devices such as video players, gaming devices, clocks,
watches, calculators, and telephones.

LCDs are preferred to cathode ray tube (CRT) displays in most applications
because

1. The sizes of LCDs come in wider varieties.


2. They do not use Phosphor; hence images are not burnt-in.
3. Safer disposal
4. Energy Efficient
5. Low Power Consumption

It is an electronically modulated optical device made up of any number of


segments filled with liquid crystals and arrayed in front of a light source
(backlight) or reflector to produce images in color or monochrome.
Reflective twisted nematic liquid crystal display.

1. Polarizing filter film with a vertical axis to polarize light as it enters.


2. Glass substrate with ITO electrodes. The shapes of these electrodes will
determine the shapes that will appear when the LCD is turned ON. Vertical
ridges etched on the surface are smooth.
3. Twisted nematic liquid crystal.
4. Glass substrate with common electrode film (ITO) with horizontal ridges to
line up with the horizontal filter.
5. Polarizing filter film with a horizontal axis to block/pass light.
6. Reflective surface to send light back to viewer. (In a backlit LCD, this layer
is replaced with a light source.)

JHD162A is one such LCD which is used here.

It has a Panel with 2 rows and 16 column and with blocks as shown below with
5x8 pixel-selection pattern .
Operating Voltage
Pin Details
Timing Diagram

Write Mode
Read Mode

Pixel selection pattern


Interfacing JHD162A with Microcontroller

Alpha Numeric displays form an integral part of the Embedded Systems.


The Data displayed here is controlled by the Microcontroller.
The Control pins like Read Strobe, Read/Write and Enable are controlled through
the Microcontroller Ports as per the waveforms above.
The 8 data is also provided through a Microcontroller Port.
General Circuit and settings of jhd162a

10K VR1
3 1 +5V

U1
2

VSS
VDD
V0
ALCD_RS RS
ALCD_R/W R/W
ALCD_E E
DB0 DB0
DB1 DB1
DB2 DB2
DB3 DB3
DB4 DB4
DB5 DB5
DB6 DB6
DB7 DB7
LED A
LED K
16x2 ALPHA LCD

ALPHA NUMERIC LCD

Make sure that 5V and GND lines are properly connected otherwise you may
end up in damaging parallel port.

If you want backlight than connect pin 15 of LCD to 5V and pin 16 of LCD to
GND. By adjusting 10k resistor make pin 3 of LCD at 0V. If connections are
proper you will see this after power on.
Flow Chart Connect VDD, VSS, LEDA,LEDK Pins for
Power and Contrast Adjustments

RS , EN, R/W And data Pins Assigned to


Ports

EN=1, RS=1 , R/W=0 for data write

Data in DB0-7 is sent through Port Pins

Data is Displayed on the Panel

LCD initialization

Void ALCD_Init( void )

ALCD_Comm( 0x38 ); Command transmitted


serially to LCD through data lines, This
command will select 2lines,5x7matrix

ALCD_Comm( 0x0E ); This command will make


the display on, cursor blinking

ALCD_Comm( 0x01 ); This command will clear


the LCD display

ALCD_Comm( 0x06 ); This command will shift


the cursor to right
LCD message function

Void ALCD Message (unsigned char addr, unsigned char *data_ptr)

ALCD_Comm( addr ); Address location of LCD is


transmitted to LCD through data lines

while( *data_ptr != '\0' ) Data_ptr points to the


starting character of the message, until it is
equal to null character loop will be repeated

ALCD_Data( *data_ptr ); Data to be displayed is


transmitted to the LCD through the data lines

data_ptr++; Data pointer will be incremented


after each character is displayed

LCD command function

Void ALCD_Comm( char comm_data )

P1 = comm_data; comm_data present on port


P1 is transmitted to the LCD through datalines

ALCD_RS = 0; Command register will be selected

ALCD_Enable = 1; ALCD_Enable = 0; in order to


access the data present on data lines enable pin
should have high to low pulse
POWER SUPPLY

LM7805 Positive Voltage Regulator

The LM78XX series of three terminal positive regulators are


available in the TO-220 package and with several fixed output
voltages, making them useful in a wide range of applications.
Each type employs internal current limiting, thermal shut down
and safe operating area protection, making it essentially
indestructible. If adequate heat sinking is provided, they can
deliver over 1A output current. Although designed primarily as
fixed voltage regulators, these devices can be used with external
components to obtain adjustable voltages and currents.
Features

 Output current in excess of 0.5A


 No external components
 Internal thermal overload protection
 Internal short circuit current-limiting
 Output transistor safe-area compensation
 Available in TO-220, TO-39, and TO-252 D-PAK packages
 Output voltages of 5V, 12V, and 15V

Power supply circuit:

From a 12V Adaptor, input is taken into the power supply unit via
a DC Socket.

A 5V regulator circuit is designed using LM7805 as shown below


which is needed for microcontroller as supply voltage.

A 12V Bridge rectifier in between the DC Socket and LM7805 is


used.

This Bridge continues to provide supply even in case of Power-


pin polarity inversion at the DC Socket.

+12V

LED1
1 R1 2 1 2
1K
LED
1

CON1 U1 +12V +5V


1 U2 LM7805
2 4 - + 2 1 3
GND

3 VIN VOUT
1

3 PIN DC SOCKET
1

BRIDGE C4 + C2
2

C3 + 10uF/63V
470uF/35V 0.1uF
3

2
2
The capacitor C3 is used to filter the Bridge Rectifier o/p

C4 is to filter the ripples at the input of LM7805.

C2 at the LM7805 o/p is again to get a smooth DC o/p.

A general Ckt and output waveform of a Bridge rectifier is as


shown below:

The Positive Half-cycle

During the negative half cycle of the supply, diodes D3 and D4


conduct in series, but diodes D1 and D2 switch "OFF" as they are
now reverse biased. The current flowing through the load is the
same direction as before.
The Negative Half-cycle

As the current flowing through the load is unidirectional, so the


voltage developed across the load is also unidirectional the same
as for the previous two diode full-wave rectifier, therefore the
average DC voltage across the load is 0.637Vmax. However in
reality, during each half cycle the current flows through two
diodes instead of just one so the amplitude of the output voltage
is two voltage drops ( 2 x 0.7 = 1.4V ) less than the input VMAX
amplitude. The ripple frequency is now twice the supply
frequency (e.g. 100Hz for a 50Hz supply)
IR Transmitter & Receiver

Infrared (IR) light is electromagnetic radiation with a wavelength


longer than that of visible light, measured from the nominal edge
of visible red light at 0.74 micrometers ( µm), and extending
conventionally to 300 µm. These wavelengths correspond to a
frequency range of approximately 1 to 400 THz, and include most
of the thermal radiation emitted by objects near room
temperature. Microscopically, IR light is typically emitted or
absorbed by molecules when they change their rotational-
vibrational movements.

IR Transmitting LED

Common infrared LED that emits infrared rays has the same
appearance with visible light LED. Its appropriate operating
voltage is around 1.4V and the current is generally smaller than
20mA. Current limiting resistances are usually connected in series
in the infrared LED circuits to adjust the voltages, helping the
LEDs to be adapted to different operating voltages.
IR Receiver LED

Ordinary infrared LEDs can be divided into the following three


types:

Small power one (1mW-10mW),

Medium power LED (10mW-50mW) and

Large Power LED (50mW-100mW and above).

These IR Receiver LEDs receive the IR modulated light


generated by adding pulse voltage with specific frequency on the
IR Transmitting diode.
They should be placed at a distance which is in direct facing
with the IR emitting LEDs.

In order to lengthen its controlling distance, infrared LED


should be operated under pulse state as the effective transmitting
distance of the pulsed light (modulated light) is in proportion with
the wind-induced current of the pulses. Thus, by increasing the
peak value (Ip) of the pulses, the emitting distance of the
infrared LED can also be lengthened. One way to increase Ip is to
diminish the duty ratio of the pulse; that is to reduce the width of
the pulse (T).

The duty ratios of the working pulses for some color TV’s
infrared remote controllers are around 1/3-1/4; and for some
other electronic products, the duty ratios of the infrared remote
controllers can even be as small as 1/10.

Through reducing the duty ratio of the pulses, the emitting


distance for small power infrared LED can also be increased in a
large extent.

Infrared LED chips with different wavelengths can be applied in


extensive devices, for example:

1. Infrared LED chip with wavelength of 940nm: suitable to be


used in remote controller, such as remote controllers for
household appliances.
2. 808nm: suitable to be used in medical treatment appliances,
space optical communication, infrared illumination and the
pumping sources of the solid-state lasers.

3. 830nm: suitable to be used in the automated card reader


system in freeway.

4. 840nm: suitable to be used in colored zoom infrared


waterproof video camera.

5. 850nm: suitable to be used in video cameras that are


applied in digital photography, monitoring system, door phone,
theftproof alarm and so on.

6. 870nm: suitable to be used in video cameras in marketplace


and crossroad.

Interface with Microcontroller

These IR Transmit and Receiver LEDs can be used in various


applications by interfacing them with a Microcontroller.

For Example:

To monitor Traffic Density:

IR Tx and Rx are kept face to face, at some distance apart


across the pathways. They are kept at some regular intervals.
This will help to observe the traffic density at different places.

The Tx continuously transmits the Infra Red Radiations. The Tx


led’s radiation gets blocked to the receiver when any movement
occurs. The output of Receiver can be fed to a Microcontroller for
data analysis.

The IR receivers are connected to the comparator circuit, to get


digital signals. A low power operational amplifier LM324 IC has
been used to develop a comparator circuit.

A general Ckt of IR TX RX is as shown below.

+5V +5V
1

1
R3 R3 R3 R3
1K 10K 10K 1K
2

2
U23 LM324
1

1
Rx1_1 1 14 Rx2_2
U20 IR1 OUT A OUT D IR2 U17
1

Tx1_1 Rx1_1 Rx2_2 Tx2_2

VR2 2 A D
10K
-

-
2

2
2 13
+5V IN A- IN D-
3

3 12
4 IN A+ IN D+ 11 +5V
+5V 5 V+ V- 10
IN B+ IN C+
6 9

1
IN B- IN C-
1

R3 R3
R3 R3 B C 10K 1K
1K 10K

2
Rx1_2 7 8 Rx2_1
2

OUT B OUT C

1
1

IR2 U17
U17 IR2 Rx2_1 Tx2_1
Tx1_2 Rx1_2
1

2
2

1
Example flow Chart

FLOW CHART

Infrared sensor has 3 pins, 5V, GND, O/P.

The Rx and Tx are place straight opposite

which in results in the IR wave connection

If any object or thing cross over the IR path,

The continuity of Tx and Rx Disturbed

O/P of IR Rx is connected to the port pin of microcontroller

The change in voltage of the Pin results the

OutputDiscontinuous
is displayed inofLCD
IR path
or Buzzer
Contact less tachometer principle of operation

The idea behind most


digital counting device,
frequency meters and
tachometers, is a micro-
controller, used to count
the pulses coming from a
sensor or any other
electronic device.

In the case of this


tachometer, the counted
pluses will come from
proximity sensor, which
will detect any reflective
element passing in front of it, and thus, will give an output pulse for each and
every rotation of the shaft, as show in the picture. Those pulses will be fed to the
microcontroller and counted.

To understand how a microcontroller counts pulses, and deduce the frequency of


those pulse, please refer to this tutorial about building a frequency meter, that
elaborates the process of frequency counting.

The main difference between this tutorial about tachometer and frequency
meters, is that we need the reading in pulses per minutes (to count revolutions per
minutes), but in the same time, we don't want to wait a whole minute before getting
a correct reading. Thus we need some additional processing to predict the number
of revolutions per minute in less than a second.
Instantaneous measurement algorithm
To be able to deduce an RPM reading in less than second, while constantly refining
the reading's accuracy, a simple algorithm have been developed, where a counter
and a timer are used. Counter and timers are part of the internal features of a
micro-controller, (like the AT89C52 used in this project) and they can be easily
configured through programming.
The schematic below, shows how the timer and the counter are used for this task;
The counter is connected i such a way to count pulses coming from the proximity
sensor, while the timer is used to precisely feed the counted value to the
microcontroller every filth of a second, and reset the counter to 0. The
microcontroller can now take an average of the last 3 readings (saved in C1, C2
and C3) and calculate the average numbers of pulses per fifth second, then
multiply this value by 5, to get the number of pulses per second, then multiply this
value by 60 to get the number of pulses per minute, which represents the measured
RPM. The only purpose of calculating an average reading is that it will allow
getting more stable reading and preventing display flickering.

C1, C2 and C3 are used to store the last 3 reading


The electronic Circuits

This device is composed of 2 electronic circuits: the Sensor, which is a slightly


modified proximity, and the microcontroller board, which analyses pulses
coming from the sensor, process them and display the result on the LCD
display.
Circuit explanation:

The LCD connections in the green shading is a standard for


most of alpha numeric LCDs, the only feature I added is to be
able to control the back light via the 80c52 microcontroller. The
LCD protocol can seem complicated to some of you, and an article
should be released soon to explain it.

The part in the blue shading is also standard in any 8051


microcontroller circuit, which includes the reset circuitry along
with the crystal resonator that generates the clock pulses
required.

The power supply, shaded in light red, regulates a 9V


rechargeable Ni-CD battery and also provides a very simple
battery monitor, with a green and a red LED, showing whether
the battery need to be recharged or not.

The switch SW1, shown in the upper yellow circle, is used to


enable/disable the measurement or the counting process. When
the switch is pressed, the device measures the RPM of the shaft
under test, and constantly updates the reading on the LCD, when
the switch is released, the last reading is held unchanged on the
display, as long as the device stays on. When the switch is
pressed again the old reading is replaced by the new one.
The wire connection P1, which is connected to the output of the
sensor, is connected to the pin 3.4 of the microcontroller, this pin
has a dual function which is to count incoming pulses and
increment a 8, 13, or 16 bit register according to the
configuration of the timer T0.
As you may have noticed, this schematics misses tow important
items to be called a tachometer: The C code loaded into the
microcontroller, which will be discussed later, and the proximity
sensor, which will feed the pulses to be counted.

The modified IR proximity sensor:

This schematic show the slight modification over the one


proposed in this tutorial, which is the fact that the emitter LED
uses a current limiting resistor of a higher value, to allow it to be
turned on for a long period of time, because in this specific
application, we need to turn the IR emissions on or off, but we
don't need to inject high currents to reach high ranges... I
recommend the reading of this article that fully covers all the
aspects of this sensor.

The CTRL line, is an input coming from the microcontroller (at the
wire connection: P4), turning the IR emissions ON and OFF, and
the OUT line, is the output of the sensor, which is fed to the
microcontroller (at the wire connection: P1).

After analyzing both the main board holding the microcontroller


and the sensor, here is a simple
Diagram showing how they are connected together. You will have
to refer to the above schematics to see where P1, P2, P3 and P4
go in the main board, as well as the other lines concerning the
sensor.

The software

Here are only small relevant parts of the full C program, that
was loaded into the microcontroller after being compiled to a HEX
file. Those part of the code were selected as the ones that
emphasize the main purpose of a microcontroller in such an
application. For examples, function dealing with the LCD
operation are not included in this description. Comments in green
explains the program. The full code is available in the Project
folder, downloadable at the bottom of this article .
#include <REGX51.h>
#include <math.h>

unsigned int clk_tmp,clk_tmp2,clk_sec,clk_sec2;


unsigned intex_pulses,rps,rps_tmp,temp,rps_avg,rps_max;
unsigned int rps_his[5];
char a,b,c,d,e;
unsigned char count1,count2;
unsigned char scale = 4;

delay(y){ // A function to make software delays


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

setup_interrupts(){ // This function initialises the


TIMER and the COUNTER to
EA = 1; // be used in in the trachometre
ET0 = 1; //set the Timer/counter 0
TR0 = 1; //Enable Timer/counter 0 to count
TMOD = 0X25; //counter 0 in mode 1 (16 bit counter),
//timer 1 in mode 2 (auto reload from
TH1)
TH1 = 0; //start counter from 0
ET1 = 1; //enable timer 1
TR1 = 1; //Enable Timer/counter 1 to count
PT0 = 1; //Setup the priorities of timer 1 and
timer 0, a 0 gives a
PT1 = 0; //higher priority.
}

void int_to_digits(unsigned int number){ //store the 5


digits of an integer
float itd_a,itd_b; //number in
the variable a,b,c,d,e
itd_a = number / 10.0;
e = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
d = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
c = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
b = floor((modf(itd_a,&itd_b)* 10)+0.5);
itd_a = itd_b / 10.0;
a = floor((modf(itd_a,&itd_b)* 10)+0.5);
}

clk() interrupt 3 //timer 1 interrupt


{
clk_tmp++; //Software counter for the timing
of the tachometer readings
clk_tmp2++; //Software counter for the display
refresh rate
if (clk_tmp2 > (1236)){ // update display
clk_tmp2 = 0;
rps_avg = floor(((rps_his[0] + rps_his[1] + rps_his[2]
+ rps_his[3] + ___
___rps_his[4])/5)*60);
}

if (clk_tmp > (6584/scale)){ // update the measured RPM


clk_tmp = 0;
if (P2_0 == 0){
rps = TL0;
temp = TH0;
temp = temp * 256;
rps = (rps + temp)* scale;
rps_his[4] = rps_his[3];
rps_his[3] = rps_his[2];
rps_his[2] = rps_his[1];
rps_his[1] = rps_his[0];
rps_his[0] = rps;
}
TL0 = 0;
TH0 = 0;
}
}

count_pulses() interrupt 1 //counter 0 interrupt


{
if (scale < 10) // If the pulses are so fast that
the internal counter
scale++; // overflows, increase the
variable 'scale' so that
} // so that readings are recorded
at a higher rate

void main(){
scale = 10 ;
P3_3 = 0; // ini proximity sensor, OFF
P3_4 = 1; // ini sensor input
P1_1 = 0; //turn LCD backlight ON
P2_0 = 1; //ini count/hold button
ini_lcd(); // ini the LCD
setup_interrupts();

while(1){
P3_3 = ~P2_0;
if (P2_0 == 1){
scale= 4;
}
}
}

To understand the functioning of this source code, you must


have some basic microcontroller and C language skills.
The variable scale is used to control the rate at which the
tachometer reads and resets the counter.
Infra-Red Proximity Sensor

This sensor can be used for most indoor applications where no


important ambient light is present. For simplicity, this sensor
doesn't provide ambient light immunity, but a more complicated,
ambient light ignoring sensor should be discussed in a coming
article. However, this sensor can be used to measure the speed of
object moving at a very high speed, like in industry or in
tachometers. In such applications, ambient light ignoring sensor,
which rely on sending 40 KHz pulsed signals cannot be used
because there are time gaps between the pulses where the
sensor is 'blind'...

The solution proposed doesn't contain any special components,


like photo-diodes, photo-transistors, or IR receiver ICs, only a
couple if IR led’s, an Op amp, a transistor and a couple of
resistors. In need, as the title says, a standard IR led is used for
the purpose of detection. Due to that fact, the circuit is extremely
simple, and any novice electronics hobbyist can easily understand
and build it.

Object Detection using IR light

It is the same principle in ALL Infra-Red proximity sensors. The


basic idea is to send infra red light through IR-LEDs, which is
then reflected by any object in front of the sensor.

Then all you have to do is to pick-up the reflected IR light. For


detecting the reflected IR light, we are going to use a very
original technique: we are going to use another IR-LED, to
detect the IR light that was emitted from another led of the exact
same type!
This is an electrical property of Light Emitting Diodes (LEDs)
which is the fact that a led Produce a voltage difference across its
leads when it is subjected to light. As if it was a photo-cell, but
with much lower output current. In other words, the voltage
generated by the led’s can't be - in any way - used to generate
electrical power from light, It can barely be detected. that's why
as you will notice in the
Schematic, we are going to use a Op-Amp (operational Amplifier)
to accurately detect very small voltage changes.

The electronic Circuit

Two different designs are proposed, each one of them is more


suitable for different applications. The main difference between
the 2 designs is the way infra-red (IR) light is sent on the object.
The receiver part of the circuit is exactly the same in both
designs.
Note: Both the sender and the receiver are constructed on the
same board. They are separated in the schematics for
simplification.

Low range, Always ON

As the name implies, the sensor is always ON, meaning that the
IR led is constantly emitting light. This design of the circuit is
suitable for counting objects, or counting revolutions of a
rotating object, that may be of the order of 15,000 rpm or much
more. However this design is more power consuming and is not
optimized for high ranges. in this design, range can be from 1 to
10 cm, depending on the ambient light conditions.
As you can see the schematic is divided into 2 parts
the sender and the receiver.

The sender is
composed of an IR
LED (D2) in series
with a 470 Ohm
resistor, yielding a
forward current
of7.5 mA.

The
receiver part is
more complicated,
the 2 resistors R5
and R6 form a
voltage divider
which provides 2.5V at the anode of the IR LED (here, this led will
be used as a sensor). When IR light falls on the LED (D1), the
voltage drop increases, the cathode's voltage of D1 may go as
low as 1.4V or more, depending on the light intensity. This
voltage drop can be
Detected using an Op-Amp (operational Amplifier LM358). You
will have to adjust the variable resistor (POT.) R8 so the the
voltage at the positive input of the Op-Amp (pin No. 5) would be
somewhere near 1.6 Volt. if you understand the functioning of
Op-Amps, you will notice that the output will go High when the
volt at the cathode of D1 drops under 1.6. So the output will be
high when IR light is detected, which is the purpose of the
receiver.

In case you're not familiar with op-amps, here is shortly


and in a very simplified manner, what you need to know to
understand how this sensor functions: The op-amp has 2 input,
the +ve input, and the -ve input. If the +ve input's voltage is
higher than the -ve input's voltage, the output goes High
(5v, given the supply voltage in the schematic), otherwise,
if the +ve input's voltage is lower than the -ve input's
voltage, then the output of the Op-Amp goes to Low (0V).
It doesn't matter how big is the difference between the +ve and -
ve inputs, even a 0.0001 volts difference will be detected, and
the the output will swing to 0v or 5v according to which input has
a higher voltage.

Contact-Less tachometer
this is a tachometer that counts the revolutions per minute of a
rotating object, given that the object has a reflective stripe glued
on it that will pass in front of the IR sensor for each and every
revolution, giving a pulse per revolution. Again a microcontroller
will have to be used to 'understand' the data provided by the
sensor and display it.
C Code for 8051 microcontrollers

#include <REGX51.h>
#include <math.h>

unsigned char ir; // to store the final result


bit ir1,ir2; // the 2 recording point
required for our algorithm

delay(y){ // simple delay function

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

void main(){
//P2.0 IR control pin going to the sensor
//P2.1 IR output pin coming from the sensor

while(1){
P2_0 = 1; //send IR
delay(20);
ir1 = P2_1;
P2_0 = 0; //stop IR
delay(98);
ir2 = P2_1;

if ((ir1 == 1)&(ir2 == 0)){


ir = 1; // Obstacle detected
P2_3 = 1; // Pin 3 of PORT 2 will go
HIGH turning ON a LED.
if ((ir1 == 1)&(ir2 == 1)){
ir = 2; // Sensor is saturated by
ambient light
}else{
ir = 0; // The way is clear in front
of the sensor.
}
}
}
Components positioning:

The correct positioning of the sender LED, the receiver LED with
regard to each other and to the Op-Amp can also increase the
performance of the sensor. First, we need to adjust the position
of the sender LED with respect to the receiver LED, in such a way
they are as near as possible to each others , while preventing any
IR light to be picked up by the receiver LED before it hit and
object and returns back. The easiest way to do that is to put the
sender(s) LED(s) from one side of the PCB, and the receiver LED
from the other side, as shown in the 3D model below.

This 3D model shows the position of the LEDs. The green


plate is the PCB holding the electronic components of the sensor.
You can notice that the receiver LED is positioned under the PCB,
this way, there won’t be ambient light falling directly on it, as
ambient light usually comes from the top.

It is also clear that this way of positioning the LEDs prevent the
emitted IR light to be detected before hitting an eventual
obstacle.
4.3 KEIL Development Tool

Keil software provides the ease of writing the code in either


C or
ASSEMBLY. U-VISION 2, the new IDE from Keil Software
combines Project
management, Source Code Editing and Program Debugging in
one powerful

Environment. It acts as a CROSS-COMPILER.

4.3.1 How to Create a New Project

1. Select the Project from the menu bar.


2. Select New Project.
3. Give the File Name. A project with extension of .uv2 will be
created
4.3.2 Selecting the Device

1. After giving the file name the device list windows opens.
2. Select the respective company’s microcontroller IC that is
going to be implemented in hardware.
3. From the drop down arrow, we get a list of all the chips from
that particular manufacturer. Choose the appropriate one.
4. Now the target is ready.
5. The data sheets and user manuals are automatically added.
4.3.3 Configuring the essentials

1. Right Click on Target to view the options for Target 1.


2. The Target tab enables to give the Starting address and size
of RAM and ROM. We also have to specify the frequency of
the crystal used which in our case is 11.0592Hz.
3. The Output tab has the option to create the HEX file.
Confirm the check box given beside it.
4. The A166 and C51 tabs shows the compiler options.
4.3.4 Addition of files in Source group

1. After the Target is created the source group is added to it.


2. Select the file menu and choose the ‘New’ option in it to get
a page. Save the same with a .a51 or .asm extension. These
assembler files are the ones recognized by the compiler.
3. Right click on source group and select add files to include
the program. Select the assembler files created earlier and
confirm the action. The selected files appear in the left-hand
side project window.
4. These files will contain your actual program in assembly or
in embedded C language
5. Options for source group includes the compilers C51 and
A51 paths.
4.3.5 Running the program

1. Any number of sub programs can be added to source group.


2. To run the program right click on it and select Build Target.
When you
build an application with syntax errors, µVision2 will display
errors and warning messages in the Output Window – Build
page. A double click on a message line opens the source file
on the correct location in a µVision2 editor window.

3. Then select rebuild all the target files too. With the Rebuild
Target
command, all source files are translated, regardless of
modifications.

4. After the target is built, debugging is done.

5. After all the debugging the file is built again which creates a
hex file. This hex file is then used to download to the
microcontroller using a programmer kit.

4.3.6 Target Program Execution & Debugging

µVision2 lets execute your application program in several


different ways:

 With the Debug Toolbar buttons and the “Debug Menu and
Debug Commands”.
 With the Run till Cursor line command in the local menu. The
local menu opens with a right mouse click on the code line in
the Editor or Disassembly window.
 In the Output Window – Command page you can use the Go,
Ostep, Pstep, and Tstep commands.

4.3.7 Watch Window

The Watch window lets you to view and modify program


variables and lists the current function call nesting. The contents
of the Watch Window are automatically updated whenever
program execution stops. You can enable View Periodic Window
Update to update variable values while a target program is
running.

The Locals page shows all local function variables of the current
function. The

Watch pages display user-specify program variables. You add


variables in three different ways:

 Select the text <enter here> with a mouse click and wait a
second. Another mouse click enters edit mode that allows
you to add variables. In the same way you can modify
variable values.
 In an editor window open the context menu with a right
mouse click and use Add to Watch Window. µVision2
automatically selects the variable name under the cursor
position, alternatively you may mark an expression before
using that command.
 In the Output Window – Command page you can use the
Watch Set command to enter variable names.

To remove a variable, click on the line and press the Delete


key. The current function call nesting is shown in the Call Stack
page. Double clicking on a line shows the invocation an editor
window.
Flash Magic

This is a Tool from Philips for Programming the controllers that


are flash programmable and
That supports serial programming of devices.
Flash microcontroller can be erased and re-written as many times
as possible.
The Boot loader Inside the Chip understands the protocol
received from computer through serial port.
Flash Magic identifies the hardware when the controller chip is
inserted. Program for the target microcontroller can be now either
read back or sent as Intel format HEX file.
Support locking of devices can be done to prevent reading back of
programmed chip.
After locking the chip can still be erased and used again for
loading new programs.

§ Support major Philips devices


§ Lock of programs in chip supported to prevent program copying
§ ZIF socket on-board Compatible 40 pin Microcontrollers
§ Auto Erase before writing and Auto Verify after writing
§ Informative status bar and access to latest programmed file
§ Simple and Easy to use
List of Controllers to
select the Target device

Software settings
1. Install the Software Flash Magic
2. Select Serial Port - As per your Computer
3. Select the Chip (89V51RD2) (1)
4. Open the Hex file from Browse (3)
5. to program click Start (5), Then Message will appear press the
reset Switch as Shown
6. Press the Reset Switch
PRESS THE RESET SWITCH to start Programming

Programming status as Shown after the Programming is finished.

In the Controller Board Press the Reset Switch to run the Program
and Test.
Conclusion:

Potrebbero piacerti anche