P 3483 Line Following Robot
P 3483 Line Following Robot
P 3483 Line Following Robot
CERTIFICATE
Certified that the project work entitled LINE FOLLOWING ROBOT carried out by Mr
Amithash E, Prasad USN 1GA01EC002 a bonafide student of 8 th Semester in partial
fulfillment for the award of Bachelor of Engineering in Electronics and Communication of
Visvesvaraya Technological University, Belgaum, during the year 2005. It is certified that the
corrections/suggestions indicated for Internal Assessment have been incorporated in the
Report department library. The project report has been approved as it satisfies the academic
requirements in respect of project work prescribed for the said degree.
External Viva
Signature of the Guide
(Dr.T.R.Seetharam)
ACKNOWLEDGEMENT
An endeavor over long period can be successful only with advice and guidance of many well
wishers.
My sincere thanks to the management and Dr. T. S. Seetharam, principal, Global Academy of
Technology, for providing me the opportunity to conduct my project work.
I am highly indebted to N.Narasimha Swamy, H.O.D, Electronics & Communication
Department, GAT for his assistance and constant source of encouragement.
I wish to express my profound and deep sense of gratitude to H. S. Manjunatha Reddy,
Assistant professor, Department of Electronics and Communication, Project Co-ordinator, for
sparing his valuable time to extend help in every step of my project work.
I whole heartedly express my thanks to, B. N. Manjunatha Reddy, Assistant Professor,
Electronics & Communication Department, GAT for sparing time to go through every tiny
detail and give his valuable suggestions to make this project and report a success.
I would also like to thank the staff of E& C Dept for their generous guidance.
Id like to thank Prof. A. J. Menon, Instrumentation department, IISC, Bangalore, for his
valuable support and guidance throughout the project.
Last but not the least we would like to thank our friends and family for their help in every way
for the success of this project report.
AMITHASH E. PRASAD
CONTENTS
1. SYNOPSIS..................................................................................................... 01
2. PREAMBLE................................................................................................... 03
2.1 INTRODUCTION.................................................................................... 03
2.2 PROBLEM DEFINITION........................................................................ 04
2.3 OBJECTIVES OF THE STUDY............................................................. 04
2.4 SCOPE OF STUDY................................................................................. 05
2.5 REVIEW OF LITERATURE................................................................... 05
2.6 APPLICATIONS...................................................................................... 06
2.7 LIMITATIONS......................................................................................... 06
2.8 METHODOLOGY................................................................................... 07
3. THEORY........................................................................................................ 09
3.1 THE DIFFRENTIAL STEERING SYSTEM........................................... 09
3.2 D.C. MOTORS......................................................................................... 10
3.3 H-BRIDGE MOTOR CONTROL............................................................ 11
3.4 INTELLIGENCE..................................................................................... 14
3.5 THE PIC 16F873 MICROCONTROLLER............................................. 16
3.6 PWM SPEED CONTROL....................................................................... 18
3.7 THE PICMICRO CCP MODULES......................................................... 18
4. DESIGN AND IMPLEMENTATION............................................................ 22
4.1 SCHEMATIC........................................................................................... 22
4.2 PROCESS EXPLANATION.................................................................... 35
4.3 FLOW CHART......................................................................................... 37
4.4 CODE 40
4.5 CODE EXPLANATION.......................................................................... 51
5. RESULT & CONCLUSION........................................................................... 55
6. BIBLIOGRAPHY.......................................................................................... 56
7. APPENDIX
1. SYNOPSIS
LINE FOLLOWING
ROBOT
1
Department of Electronics & Communication, GAT, Bangalore - 98
Main
Power
Supply
Clock 4
MHz
PIC 16F873
Microcontroller
hi
Motor
Power
Supply
Left
Motor
H - Bridge
DC Motor
Control
HEX
Inverter
Right
Motor
7T
Priority
Encoder
NOR
Gate
Analog
Comparators
Threshold
Voltage
7T
Sensor Array
2. PREAMBLE
2.1.
LINE FOLLOWING
ROBOT
INTRODUCTION
The robots of the movies, such as C-3PO and the Terminator are portrayed as
fantastic, intelligent, even dangerous forms of artificial life. However, robots of today are
not exactly the walking, talking intelligent machines of movies, stories and our dreams.
In the 1970s scientists proposed that in the year 2000 we would have created
artificial life forms, almost perfect in terms of intelligence and capabilities. The dream of
free and efficient labor made the researchers of the time go on day and night to bring the
dream to existence. But the task was futile due to the lack of compact processors to carry
out the calculations which were oh so necessary. Now in the year 2000, the microprocessor
technology is thousands of times more advanced than what existed back then. But still the
robots of today are no way close to what our movies portray them to be. This is not only
due to drawbacks in processor technology, but also in various other fields such as vision,
motor control so and so forth.
Robots may never make it to our kitchens or living rooms as personal slaves, but
they certainly have made their way to the manufacturing industry, aero-space industry, and
yes to the work benches of robotic hobbyists. Robots are now working in dangerous
places, such as nuclear disposal, space explorers, fire fighting, etc.
The word "robot" originates from the Czech word for forced labor or serf. Robots
are electronic devices intended to perform a desired function. Many refer to them as
"machines", however, a drill press is a machine, yet it requires an operator to perform its
function, where robots can be programmed to do it themselves. Robots have the potential
to change our economy, our health, our standard of living, our knowledge and the world in
which we live. As the technology progresses, we are finding new ways to use robots. Each
new use brings new hope and possibilities, but also potential dangers and risks. Robotics is
not only a science, but it is also an art. The bots we build reflect the ideas and personalities
we portray. There are many different versions of robots that can be made. From turtle bots
to vehicles like the Mars rovers to rovers like R2-D2. From walkers that have anywhere
from 1 to 10 legs to robotic arms to androids. Whatever you can dream, you can create.
The level of expertise you want your robot to have and how much learning and research
3
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
you want to do is up to you. For those who have relative experience in computer
programming and electronics, this may come easier to you than anyone new to the hobby.
Those who build models, RC vehicles, and other artwork will find it challenging to modify
some of their previous projects.
We have seen how ants always travel in a line, following an invisible route in
search of food, or back home. How on roads we follow lanes to avoid accidents and traffic
jams. Ever thought about a robot which follows line? A perfect or near perfect mimic of
mother-nature? After all the purpose of robotics is to recreate in terms of machines what
we see around to solve a problem or fulfill a requirement.
Programming intelligence into a robot (or computer) is a difficult task and one that
has not been very successful to date even when supercomputers are used. This is not to say
that robots cannot be programmed to perform very useful, detailed, and difficult tasks;
they are. Some tasks are impossible for humans to perform quickly and productively. For
instance, imagine trying to solder 28 filament wires to a 1/4in square sliver of silicon in 2 s
to make an integrated circuit chip. Its not very likely that a human would be able to
accomplish this task without a machine. But machine task performance, as impressive as it
is, isnt intelligence.
2.2.
PROBLEM DEFINITION
In the industry carriers are required to carry products from one manufacturing
plant to another which are usually in different buildings or separate blocks.
Conventionally, carts or trucks were used with human drivers. Unreliability and
inefficiency in this part of the assembly line formed the weakest link. The project is to
automate this sector, using carts to follow a line instead of laying railway tracks which are
both costly and an inconvenience.
2.3.
It must be prepared of a situation that it runs into a territory which has no line to
follow. (Barren land syndrome)
The robot must also be capable of following a line even if it has breaks.
4
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
The robot must be insensitive to environmental factors such as lighting and noise.
The color of the line must not be a factor as long as it is darker than the
surroundings.
2.4.
SCOPE OF STUDY
The robot can be further enhanced to let the user decide whether it is a dark line on
a white background or a white line on a dark background. The robot can also be
programmed to decide what kind of line it is, instead of a user interface. The motor control
could be modified to steer a convectional vehicle, and not require a differential steering
system. The robot could be modified to be a four wheel drive. Extra sensors could be
attached to allow the robot to detect obstacles, and if possible bypass it and get back to the
line. In other words, it must be capable predicting the line beyond the obstacle. Speed
control could also be incorporated. Position and distance sensing devices could also be
built in which can transmit information to a mother station, which would be useful in
tracking a lost carrier.
2.5.
REVIEW OF LITERATURE
First and foremost, no robot could have been built to completion without a strong
hold on the microcontroller used. Most of the basic, intermediate, and advanced literature
about the PIC microcontroller was found in the book Programming and Customizing the
PIC Microcontroller by Myke Predko. His detailed explanation of every topic made it
possible to overcome many problems which were encountered during design and
implementation. The book also provided a programmer for the PIC microcontroller which
was an indispensable tool helping me experiment with algorithms rather than blindly copy
code from the NET.
The next resource for the PIC microcontroller was the MIDRANGE MANUAL
which provides a detailed explanation of each and every hardware feature and the
instruction set. The most helpful is the design tips section which answered most of the
questions which were bogging my head down.
Looking through the library on books on robotics, there was one thing I noticed.
5
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
There are no books which deal with understandable basics, or implementation. After a lot
of search, I found PIC Robotics, A beginners guide to robotics projects using the
PICmicro by John Iovine on the net in the form of an e-Book, which I later printed out
and got it bound! This book is an excellent compliment to the book by Predko.
Robotics by C. K. Kuo was another book I referred for this project. Even though it
was of no direct use to this project, it made me understand many aspects of robotics which
Id have ignored otherwise. Hopefully, the knowledge I have gained by this book will
come in handy in my next robotic endeavor.
Last but definitely not the least, the Internet. This is where I found websites giving
detailed explanations on a few terminologies. Reference of similar projects created by
others and badly needed tutorials. There is no other place to easily get the data sheets of
the used components. I have listed out a few websites which were of most help for the
project. And in the finale, a huge thanks to Google.com, no other search engine is even
close! No I could not have done anything without the NET even if I had a million books.
The NET is worth much more.
2.6.
APPLICATION
Automated cars.
2.7.
LIMITATIONS
software.
Calibration is difficult, and it is not easy to set a perfect value.
The steering mechanism is not easily implemented in huge vehicles and impossible
Lack of a four wheel drive, makes it not suitable for a rough terrain.
Use of IR even though solves a lot of problems pertaining to interference, makes it
hard to debug a faulty sensor.
6
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
Lack of speed control makes the robot unstable at times.
2.8.
METHODOLOGY
The first idea was to use optical imaging (CCD cameras) to see the line. This was
later given up due to various reasons including complexity and unavailability of
components. Later a choice was made to use an array of sensors which solved most of
the problems pertaining to complexity.
The resistor values used in the sensor array were experimentally determined rather
than theoretical mathematical design calculations. This was done as the data sheets of
the proximity sensor was not available anywhere and most of the parameters had to be
determined experimentally.
The L293D chip is used as it was a much better option than forming an H-Bridge
out of discrete transistors, which would make the design unstable and prone to risk of
damage.
The PIC microcontroller was used as it is the only device I have a full practical
knowledge about, and most of all a RISC processor which are better suited for realtime operations. Thus the midrange devices were chosen. The part 16F873 was used as
it has 2 CCP modules which I could use in PWM mode thus simplifying the software
routines which Id otherwise had to write to generate the PWM control for the motors.
A priority encoder was used to reduce the number of I/O lines used, which reduces
it to 5 which otherwise would require 7 and a lot of additional complexity in software
which only results is sluggish operation and inefficiency.
Extra hardware was added to let the robot know if it is on a surface or not. This
helps it from not running off a table or preserving battery if manually lifted off the
floor.
Software was coded day and night, deciding on a few algorithms and few tiny
details which gradually got the robot to do what was required. Then extra code was put
to find a line if it is not on one.
The PCB is the only thing in the whole project for which I turned for outside help.
7
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
By the time the design became successful, time had run out. I no longer had time or
resources to create a PCM myself. This was done by JI Electronics.
The project was entirely (other than PCB) designed, created, soldered, tested and
coded by me. For which Im thankful for, as I have learnt much more in the processes and
not to mention the fun had.
8
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
3. THEORY
3.1.
The differential steering system is familiar from ordinary life because it is the
arrangement used in a wheelchair. Two wheels mounted on a single axis are independently
powered and controlled, thus providing both drive and steering. Additional passive wheels
(usually casters) are provided for support. Most of us have an intuitive grasp of the basic
behavior of a differential steering system. If both drive wheels turn in tandem, the robot
moves in a straight line. If one wheel turns faster than the other, the robot follows a curved
path. If the wheels turn at equal speed, but in opposite directions, the robot pivots.
= (r + b/ 2)
where SS&give the displacement (distance traveled) for the left and right wheels
respectively, r is the turn radius for the inner (left) wheel, ^is the distance between wheels
(from center-to-center along the length of the axle), and ^is the angle of the turn
in radians (
V1S0) )
axle. In this discussion, we will treat the axle's center point as the origin of the simulated
9
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
Once we've established the simple geometry for the differential steering system, it
is easy to develop algorithms for controlling the robot's path. Note, though, that we did
make an important simplifying assumption: the wheels maintain a steady velocity. We
neglected the effects of acceleration. If the wheels are allowed to accelerate, the curve
which describes the robot's trajectory can become much more complicated. When working
with very light robots, where the mass (and inertia) of the platform is small, we can often
get away with treating changes in speed as nearly instantaneous. The path that the robot
follows will not be truly circular, but it will be close enough for many applications. For
larger and heavier robots, of course mass is important and acceleration must be considered.
If the right wheel is moving at a velocity of V R and the left wheel at a velocity of V L, then
the following equation can be derived.
Where a positive 0 implies counter-clockwise rotation; the above equation clearly shows
that the angle of the turn can be increased by either,
Keep the wheels at the different velocity for a longer time (t)
All this while b remains constant; in the line following robot, both these parameters are
dynamically changed by the sensors in order to keep the robot on the line.
3.2.
D.C. MOTORS
DC motors are widely used, inexpensive, small and powerful for their size.
Reduction gearboxes are often required to reduce the speed and increase the torque output
of the motor. Unfortunately more sophisticated control algorithms are required to achieve
accurate control over the axial rotation of these motors. Although recent developments in
stepper motor technologies have come a long way, the benefits offered by smooth control
and high levels of acceleration with DC motors far outweigh any disadvantages.
Several characteristics are important when selecting DC motors and these can be
split into two specific categories. The first category is associated with the input ratings of
the motor and specifies its electrical requirements, like operating voltage and current. The
second category is related to the motor's output characteristics and specifies the physical
limitations of the motor in terms of speed, torque and power.
10
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
Example specifications of the motors used are given below:
Characteristic
Value
Operating Voltage:
6 V to 12V
Operating Current:
2A Max. (Stall)
Speed:
2400 rpm
Torque:
30 gm-cm
As noticed, the torque provided can hardly move 30gm of weight around with
wheel diameter of about 2cm. This is a fairly a huge drawback as the robot could easily
weigh about a kg. This is accomplished by gears which reduce the speed (2400 rpm is
highly impractical) and effectively increase the torque. If the speed is reduced by using a
gear system by a factor of p then the torque is increased by the same factor. For example, if
the speed is reduced from 2400 rpm, to 30 rpm, then the torque is increased by a factor of
(2400/30 = 80) in other words the torque becomes 30 x 80 2400 gm-cm or 2.4 kg-cm
which is more than sufficient.
3.3.
DC motors are generally bi-directional motors. That is, their direction of rotation
can be changed by just reversing the polarity. But once the motors are fixed, control
becomes tricky. This is done using the H-Bridge. The figure is given below.
A
0/1
0/1
1/0
1/0
ACTION
CLOCKWISE
COUNTER-CLOCKWISE
BRAKE
FORBIDDEN
11
Department of Electronics & Communication, GAT, Bangalore - 98
The Explanation is simple, If A & D are turned on, then the current flows in the direction
shown in the figure below.
Figure 3.3: Clockwise rotation
If B & C are turned on, then the motor rotates in counter clockwise direction.
Figure 3.4: Counter-Clockwise rotation
If you turn on the two upper circuits, the motor resists turning, so you effectively
have a breaking mechanism. The same is true if you turn on both of the lower circuits. This
is because the motor is a generator and when it turns it generates a voltage. If the terminals
of the motor are connected (shorted), then the voltage generated counteracts the motors
freedom to turn. It is as if you are applying a similar but opposite voltage to the one
generated by the motor being turned. In other words, it acts like a brake. Any other state
like A & C = ON or B & D = ON will cause a direct path to ground causing a very high
current to pass through the relays thus causing a burnt fuse (if it exists).
The following figure shows an H-Bridge using only transistors. The same theory
applies.
Usually, the above circuitry can be used only for direction control. The Existing H-Bridge
is further modified to include another transistor, now making speed control possible too.
This is shown in the figure below.
The same direction rules apply, but now the motor will behave as per the direction
control only when a 1 is given to the EN input. Speed control is usually done by giving a
PWM signal, and the duty cycle is varied to vary the speed of the motor. Usually
protection diodes are also incorporated across the transistors to catch the back voltage that
is generated by the motor's coil when the power is switched on and off. This fly-back
voltage can be many times higher than the supply voltage! If diodes are not used, the
transistors have a good chance to get burnt.
3.4.
INTELLIGENCE
place, such as a trash receptacle or chair that has been moved. In this situation the real
world does not match the robots internal map. Similar problems occur if new objects are
left on the floor such as a bag, toy, or pet.
Even so, these obstacles would not present too much of a problem for an expert
system. To compensate, a secondary collision detection subprogram could be written to
detect, map, and go around an obstacle not existing on the internal map. The robot
continues to move and vacuum the floor. Keep in mind that as the robot navigates around
new obstacles, its continually updating its internal map as it travels, to maintain its
location integrity. These tasks are gobbling up computer time and memory.
The robot vacuum accomplished its task. Now suppose you w ant to share this
robot or rent it. Now you have a problem. Each new house and every room in the new
house would require its own electronic map. Although expert programming does work, it
tends to be inflexible and not adaptive toward new or innovative situations.
Now lets try the other approach that uses behavior based or bottom-up
programming. Instead of programming internal maps, we program sensor responses and
behavior based algorithms (feed-forward and feedback loops) for sensing and traveling
around obstacles and avoiding getting stuck underneath furniture or trapped in corners.
Without any internal map we allow the robot to travel and move around the house in a
random manner. The idea is that while traveling in a haphazard manner, it will eventually
make its way throughout the rooms, cleaning the floor as it goes. Because the robot travels
randomly, it will take longer for the robot to vacuum the entire floor, and it may miss a
spot here and there, but it gets the job done. Since this behavior based type of robot
vacuum isnt programmed for a particular house or room, it may be used in any house in
any room at any time.
While our example is simple, it does illustrate the main differences between expert
and behavior based (neural) programming. But lets look at just one more example before
we move on.
Expert systems typically have all the answers that the designers believe will be required by
the system programmed into the system before it begins. It may store and categorize new
information, but based on previously determined categories and existing knowledge. An
example of this system could be a rock identification system. The robot examines
unknown rocks based on known characteristics of rocks, such as color, hardness,
scratchability, acid reaction tests, mass, etc. The expert system fails if it inadvertently picks
up a piece of ice that melts to water during the tests. Well, it fails as long as the designer(s)
never anticipated the robot picking up a piece of ice by mistake and made allowances for
it.
Neural (behavior based) systems are not programmed and are more adaptive, as
shown in the previous example. But is a neural system suitable for this task of rock
identification? Probably not! There are instances in which expert systems are the method
of choice. One shouldnt blindly assume one system is better than the other in all cases.
To date, behavior based robots are more successful at task accomplishments such
as traveling over unfamiliar and rough terrain than are programmed robots. (Other neural
based intelligence includes speech recognition, artificial vision, speech generation,
complex analysis of stock market data, and life insurance policies.)
The line following robot uses behavior based programming, to accomplish the task
at hand. For one, the system may not be a neural system pre say. But this is simulated in
software.
3.5.
All single cycle instructions except for program branches which are two cycle
Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
Peripheral Features:
Timer1: 16-bit timer/counter with pre-scalar, can be incremented during SLEEP via
external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register, pre-scalar and postscalar
Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave)
status or allows configuring of the microcontroller. The rest of the features are explained as
they are used in the following sections. The programming is done via an ICSP compatible
programmer. The Line following robot was programmed using the ElCheapo programmer.
3.6.
f + 5dt
A=
A = 12
= 12V xp
Where p is the duty cycle of the PWM control signal; this shows that by varying the duty
cycle of the PWM control, we effectively vary the DC voltage supplied to the motors, thus
controlling their speed. This is generated by the microcontroller built-in hardware.
3.7.
CCP1
CCP2
Comment
CCPxCON
CCP1CON
CCP2CON
CCPRxH
CCPR1H
CCPR2H
CCPRxL
CCPR1L
CCPR2L
CCPx
CCP1
CCP2
CCP pin
The PIC 16F873 has 2 CCP modules, with a common timer resource. Thus, if both
the CCP modules are configured as PWM modules, then both of they will have the same
period, but can have different duty cycles. In PWM mode, the timer 2 resource is used and
hence should not be used for other purposes.
In Pulse Width Modulation (PWM) mode, the CCPx pin produces up to a 10-bit
resolution PWM output. Since the CCPx pin is multiplexed with the PORT data latch, the
corresponding TRIS bit must be cleared to make the CCPx pin an output. The PWM
modules block diagram is shown in the figure below.
Duty Cycle =
DCxB9:DCxBO
II IT
1
1
PWM period = [(PR2) - 1] * 4 Tosc * (TMR2 prescale value), specified in units of time PWM duty cycle =
(DCNB9 DCxBO bits value) * Tost * (TMR2 prescale value), in units of time
p s = [(PR2) + 1] 4 50 ns 1
To achieve a 25% duty cycle, then PWM duty cycle = 12.8J sx= 3.2 jus .
3.2 J s = [DCx] 50 ns 1 DCx = 64 = 1000000b
Thus, clear the bits DCxB1 & DCxB0 and load 10000b i.e. 16 into the CCPRxL register.
LINE FOLLOWING
ROBOT
The schematic of the Line following robot is shown in the figure. The main
component is the PIC 16F873 microcontroller. Due to page limitations, the schematic is
divided into two sections; one the Sensor Array Board, and the other the motor-control or
main board.
The main features incorporated into the hardware are given below:
The 74HCTXX versions of the ICs are used whenever possible. This is due to their
higher speed and better TTL and CMOS compatibility. The 74HCXX versions are used
only when the corresponding HCT version is not available. Note that the 74LSXX are
TTL logic ICs where as their HC & HCT counterparts are CMOS logic ICs.
Each of the hardware is dissected and was designed/implemented separately for their
functional and later incorporated as one whole application. This helped in the debugging
processes. In similar fashion the separate modules forming the ensemble will be explained
separately.
22
Department of Electronics & Communication, GAT, Bangalore - 98
E
V
12V
OU
12V
1,2AH
BATTERY
7S05
13
ptf
LINE FOLLOWING
ROBOT
GND
- 33pJ
0.1
ptf
-12 V -EV
-70E
zzpF
zzpF
I1CLR
vcc
Vdd
DU
T1
OS
C1
R
A1
:
:SC2
L293D
U2
OU
T2
R G-
MO
OR
PIC
16F373
U1
RBE
R6RB2
RBI
CC
P1
EM
12
CC
P2
EN
34 GND
DUT3
OU
T4
.E1
10 OR
RB
O
Vcc
74HC14B
D >
GND
NOR GATE
U4
LINE FOLLOWING
ROBOT
4.1.1.
LINE FOLLOWING
ROBOT
THE MICROCONTROLLER
The PIC microcontroller was used as its a RISC processor which is better suited
for real-time operations. Thus the midrange devices were chosen. The part 16F873 was
used as it has 2 CCP modules which could be used in PWM mode thus simplifying the
software routines to generate the PWM control for the motors.
4.1.2
CRYSTAL OSCILLATOR
XI
4MH 2
I:
nf Ti
PIC16F873
0SC1
0SC2
u s.
4.1.3. BATTERY
Motors on a robot consume most of the power. For most of them, each DC motor
typically consumes 1.5W on the average. For differential steering, two DC motors consume
up to 3W. By comparison, the logic components typically draw a total of about 80mA.
Even at a supply voltage of 12V, the logic component only consumes 1W.
If we assume the whole robot consume 5W, it requires 4500J of energy to last 15
minutes. If we use a 12V battery, it must have a capacity of 4500J/12V=375Asec or
104mAH. This may imply that getting a battery of 150mAH is sufficient. Unfortunately,
the discharge curve of a 150mAH will not sustain the required voltage for 15 minutes.
Thus a Lead Acid battery was used of rating of 1.2AH for the robot to last longer
than 15min and also to take practical situations into considerations.
4.1.4. VOLTAGE REGULATOR
25
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
It has been shown that practically all electronic devices need DC supply. A direct
voltage of constant magnitude requires to be supplied, for the smooth and efficient
functioning of these devices. A properly designed voltage regulator ensures that,
irrespective of change in supply voltage, load impedance or temperature, the DC supply is
maintained at a constant level. This is achieved by incorporating some type of feedback in
the regulator circuit.
An IC voltage regulator unit contains all the circuitry required in a single IC. Thus
there are no discrete components and the circuitry needed for the reference source, the
comparator and control elements are fabricated on a single chip. Even the over load and
short-circuit protection mechanism is integrated into the IC. IC voltage regulators are
designed to provide either a fixed positive or negative voltage, or an adjustable voltage
which can be set for any value ranging between two voltage levels.
uF
capacitor at the output is to maintain stability and improve regulation. These are standard
values. The 0.1 uF capacitor is used at the input because of the fact that high value
capacitors have poor high frequency response.
26
Department of Electronics & Communication, GAT, Bangalore - 98
The entire motor control circuitry is shown in the above figure along with the
internal circuitry of the L293D motor control IC. The table below clearly indicated the
operation of the IC.
OPERATION
BOTH MOTORS FORWARD
(MOVE FORWARD)
The total number of directional control signals required is 4; but as it can be observed in the
above table, IN1 & IN2 are complimentary (and so is IN3 & IN4) that is, both the inputs
have to take the opposite states for a safe operation. This is done by connecting D L to IN1
and DL to IN2. The same is done to IN3 & IN4. Now we have 1 directional control per
motor. The ENABLE of each motor section is given PWM inputs to further improve on the
control. Now, each motor has a direction control and a speed control. The clamping diodes
are built into the chip which prevent the back EMF generated by the motors to harm the Hbridge. The inversion was achieved using the 74HCT04 HEX inverter IC having a slew rate
of about 6ns which is negligible compared to the reaction time of the H-bridge itself.
4.1.7.
The L293D chip can operate on PWM signals up to 5kHz, which was decided to be used.
PWM period = [(PR2) + - 1 ] * 4 To&c * [TMR2 prescale value), specified in units of time
cycles are 0%, 50% & 96%. These calculations are shown below.
For 0% duty cycle the value to be loaded is obviously zero,
For 50 % duty cycle,
PWM duty cycle = 200 u s x - 50- = 100 us .
100
100 us = [DCx] 0.25 us 1 DCx = 400 = 110010000b
Thus, clear the bits DCxB1 & DCxB0 and load 1100100b i.e. 100 into the CCPRxL
register.
For 96 % duty cycle,
96
PWM duty cycle = 200 us x------= 192 us .
100
192 us = [DCx] *0.25 us 1 DCx = 768 = 1100000000b
Thus, clear the bits DCxB1 & DCxB0 and load 11000000b i.e. 192 into the CCPRxL
register.
4.1.8.
THE IR SENSORS
LINE FOLLOWING
ROBOT
detector is normally 4.6 V, when an object reflects the rays towards the detector, then the
potential drops to 0.6V. The output is obviously analog in nature.
4.1.9.
COMPARATOR
Vref
----------->
Vin
The sensor circuit is redrawn using the comparator, and this is shown below.
LINE FOLLOWING
ROBOT
4.1.10.
SENSOR ARRAY
7 sensors are totally used. They are in the form shown in the figure below, also
their outputs are also shown. The top view is chosen as it would be easier to infer the
process involved.
,
i'n
ACEGFD
Figure 4.12: The sensor array The sensors are mounted on a separate board along with the
biasing resistors and a 2 pin connector supplies the power to the sensor array. And the
output of each sensor is connected to the main board via an 8 pin connector to the
comparators on the main board.
4.1.11.
This priority encoder accepts 8 input request lines 0-7 and outputs 3 lines A0-A2.
The priority encoding ensures that only the highest order data line is encoded. The extreme
sensors are given to the higher order inputs so that they are given a higher priority
compared to the inner sensors so that no required turn is left out of the priority process.
This is shown in the figure shown below. The truth table is also shown.
32
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
inputs
E
l
H
Outputs
L
L
X
X
X
X
X
X
X
X
2
H
X
X
X
L
L
H
H
H
L
L
L
L
X
X
X
X
X
L
L
H
H
H
H
H
H
H
A
1
A
O
H
H
L
L
L
H
H
H
H
H
H
L
H
L
L
H
H
G
S
E
O
33
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
As can be noticed from the truth table, the 74HC148 is an active low priority
encoder. The chip has an active low enable (EI) input which is always grounded. If the
robot is not on any line, all the input lines will be high, thus the GS line will go high. This
pin is used as the input to the microcontroller for it to decide if it is on a line or not. The
0th input is always connected to +Vcc = 5 V thus allowing the other inputs to generate an
output from 0 to 6. The chip used is 74HC148 which is a high speed CMOS priority
encoder.
4.1.12.
>
NOR
GATE
HO SURFACE
<
U4
>
<
G
>
Noticing the placement of the sensors A, B & G, it can be noticed that under no
conditions will all of them detect a line (go low). This will only happen when the line is
too thick, or when the robot is lifted off the surface. Only when all the lines go low, will
the NOR gates output go high. This line is used by the microcontroller to sense a surface.
The NOR gate used is the 74HCT27 which is a high speed CMOS gate.
34
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
4.1.13.
Thus totally the microcontroller gets 5 inputs from the sensor circuitry, 3 (A2 - A0) decide
what to do when on the line, The GS output tells whether the robot is on the line or not,
and finally the NO_SURFACE output from the NOR gate tells the microcontroller
whether the robot sees a surface or not. Below is the complete description about what each
input mean and what needs to be done.
NS
GS
A2
A1
A0
STATE IN
ACTION
No surface is detected
No line is detected
Turn left
Turn right
Move left
Move right
Go straight
Forbidden state
The process involved is taken care of the software. The comparator outputs could have
been directly connected to the microcontroller and all these operations could have been
35
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
accomplished in software. But considering that the software would require at least a few
36
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
tens of micro seconds whereas the hardware accomplishes the same in say a 100ns. Thus
due to speed considerations, the present design was arrived at.
LINE FOLLOWING
ROBOT
radius is continuously incremented every second. Thus the robot follows the path of a
spiral. This process is continued till either a line is reached or till the robot has achieved a
maximum radius of curvature (is traveling in straight line) when the process is reset and
the robot is made to turn in the starting circle, but now at a different point. This is the
algorithm with minimum complexity considering speed requirements.
36
Department of Electronics & Communication, GAT, Bangalore - 98
4.4. CODE
The code is divided into 4 modules.
LFR.ASM = this has the main code (Initialization). The rest of the work is done by the TMR0 interrupt service routine.
LFR.INC = this is an include file holding all the macro definitions, defines and constant declarations used in the program.
ROUTINE.INC = this is the TMR0 interrupt service routine, does the entire work. SUBROUTINES.INC = this has all the
subroutines used in the program, one delay subroutine and the motor subroutine.
4.4.1.
LFR.ASM
^^^^^^^^^^^^^^^'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
; ;
;+CODE BY: AMITHASH E. PRASAD, ELECTRONICS & COMMUNICATION;
;++++++++++GLOBAL ACADEMY OF TECHOLOGY+++++++++++++++++++++;
^^^^^^^^^^^^^^^^'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
DELL
0 DESCRIPTION
X
X
X
X
X
X
X
X
X
X
0
0
0
0
1 TURN RIGHT
0 MOVE
1 MOVE
X
X
X
X
X
X
X
X
X
X
0 GO STRAIGHT
DONT
1
|
ENDC
LEFT
RIGHT
CARE
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
ORG 0
GOTO INITIALIZATION ORG 4
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
MOVLW 0X0C8
MOVWF PR2 INBANK1 ;A PERIOD OF 200 MICRO SECONDS
;(FOR 5KhZ PWM) PUT IN PR REG...
BANK0 CLRF TMR0 MOVLW 0X20
MOVWF INTCON ;ENABLE TMR0 INTERRUPT,
;BUT KEEP MASKED BY CLEARING GIE
NOP
CLRF T2CON ;POSTSCALAR & PRESCALE SET TO 1:1,
;TMR2 = OFF
BSF T2CON,TMR2ON ; TURN ON TMR 2
CLRF CCP1CON
CLRF CCP2CON
MODULE ;00001100
MOVLW 0X0C
MOVWF CCP1CON
MOVWF CCPR2L
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
#INCLUDE "SUBROUTINES.INC
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
END
4.4.2.
LFR.INC
;MACRO DEFINITIONS
;GENERAL MACROS AND DEFINES....
;BANK SELECT MACROS BANK0 MACRO
BCF
STATUS,IRP
BCF
STATUS,RP1
BCF
BCF
STATUS,RP1
BSF
BSF
STATUS,RP1
BCF
BSF
STATUS,RP1
BSF
STATUS,RP0 ENDM
BANK1 MACRO
BCF
STATUS,IRP
STATUS,RP0 ENDM
BANK2 MACRO
BSF
STATUS,IRP
STATUS,RP0 ENDM
BANK3 MACRO
BSF
STATUS,IRP
STATUS,RP0 ENDM
;DEFINES TO USE FOR REGISTERS NOT IN BANK0 #DEFINE INBANK1
0X080 #DEFINE INBANK2 A 0X100 #DEFINE INBANK3
;16BIT MANUPILATOR MACROS
INC16F MACRO VAR
0X180
;
001
;
000
;
001
=>
= TEMP_FLAG,1 =>
1 -> NO
ROUTINE.INC
TMR0_ROUTINE:
BTFSS INTCON,T0IF GOTO INITIALIZATION
;RESET IF A WRONG INTERRUPT IS ENCOUNTERED, ;ELSE CONTINUE WITH
ROUTINE CLRF TMR0
SURFACE_CHECK:
BTFSS NO_SURFACE GOTO LINE_CHECK CLRF CCPR2L
CLRF CCPR1L ;STOP BOTH MOTORS IF NO SURFACE IS DETECTED GOTO EXIT_T0
LINE_CHECK:
BCF NO_LINE_PA ;DEBOUNSING CODE OF THE NO_LINE INPUT BTFSC NO_LINE BSF
NO_LINE_PA
CALL DELAY_FF_US ;TMP_FLAG,1 IS THE DEBOUNCED INPUT
;IF THE DEBOUNCED INPUT IS 1,
;THEN ROBO SEES NO LINE
BSF NO_LINE_PR
BTFSC NO_LINE_PA ;ELSE ITS JUST A FLICKER,
;CONTINUE TO MODIFIERS
BTFSS NO_LINE BCF NO_LINE_PR NOP
BTFSC NO_LINE_PR GOTO NO_LINE_CODE MODIFIERS:
BCF LINE_FIND_MODE BCF NOT_LF_FIRST MOV16LW TIME_COUNT,0X094C MOVF PORTB,W
ANDLW 0X07
LINE FOLLOWING
ROBOT
MOVWF COMMAND_WORD XORWF PREV_COMMAND_WORD,W BTFSC
STATUS,Z GOTO EXIT_T0
MOVF COMMAND_WORD,W MOVWF PREV_COMMAND_WORD CALL MOTORS
;16us
SUBLW 0X00 BTFSS STATUS,Z
GOTO INITIALIZATION ;THE DONT CARE STATE IS REACHED,
;PROBABLY ERROR IN INPUTS ;GOTO
INITIALIZATION JUST TO MAKE ;SURE
IT IS NOT A SOFTWARE PROBLEM.
;ELSE CARRY ON
GOTO EXIT_T0 NO_LINE_CODE:
;NO LINE CODE
BTFSC
LINE_FIND_MODE ;IF IN
LINE FIND MODE, SKIP
THE COUNTING CODE GOTO
NLA
DEC16F TIME_COUNT
BTFSS STATUS,Z
NLA:
BSF
LINE_FIND_MODE
LINE FOLLOWING
ROBOT
MOV16LW TIME_COUNT,0X01DC ;INITILIZE TIME_COUNT
;TO TURN ZERO EVERY SECOND
SKIP_INI:
BSF NOT LF FIRST
DEC16F TIME_COUNT
BTFSS STATUS,Z
GOTO EXIT_T0
MOV16LW TIME_COUNT,0X01DC ;INITILIZE TIME_COUNT TO
;TURN ZERO EVERY SECOND
MOVF CCPR2L,W
ADDLW 0X0A
MOVWF CCPR2L SUBLW
HIGHSPEED BTFSC
STATUS,C GOTO
EXIT_T0 CLRF CCPR2L
EXIT_T0:
BCF INTCON,T0IF
RETFIE
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
4.4.4.
SUBROUTINES.INC
ORG 0X074
DELAY_FF_US:
;256uS DELAY
MOVLW 0X0FF MOVWF
DELL DELLOOP:
DECFSZ DELL,1
GOTO DELLOOP
NOP
RETURN
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
48
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
MOTORS:
;TABLE
;COMMAND IS IN W
BEFORE CALLING,
FORWARD BTFSC
PREVIOUS_STATE
PREVIOUS_STATE
RETLW 0X00
MOVE_LEFT
MOVLW HIGHSPEED
0X00
;RETURN FROM KNOWN STATE
49
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
TURN_RIGHT
CLRF CCPR2L
MOVLW HIGHSPEED
MOVWF CCPR1L
MOVLW FORWARD
BTFSC PREVIOUS_STATE
MOVWF PORTA
BCF PREVIOUS_STATE
NOP
RETLW 0X00
TURN_LEFT
MOVLW HIGHSPEED
MOVWF CCPR2L
CLRF CCPR1L
MOVLW FORWARD
BTFSC PREVIOUS_STATE
MOVWF PORTA
BCF PREVIOUS_STATE
NOP
RETLW 0X00
SHARP_TURN_RIGHT
MOVLW HIGHSPEED
MOVWF CCPR2L
MOVWF CCPR1L
MOVLW ST_RIGHT
MOVWF PORTA BSF
PREVIOUS_STATE
NOP NOP
RETLW 0X00
50
Department of Electronics & Communication, GAT, Bangalore - 98
SHARP_TURN_LEFT
MOVLW HIGHSPEED
NOP
RETLW 0X00
GO_STRAIGHT
MOVLW
HIGHSPEED
MOVWF CCPR2L
MOVWF CCPR1L
MOVLW FORWARD
BTFSC
PREVIOUS
STATE
;CHANGE
PORTA ONLY
IF
DIFFERENT
MOVWF PORTA
BCF PREVIOUS_STATE
NOP
RETLW 0X00
'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k 'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k'k
CBLOCK directive was used for the definition of the work-area. When using this directive, work-areas which were
defined between CBLOCK and ENDC are automatically allocated in the order from the address which was specified by the
operand of CBLOCK.
INITILIZATION PROCESS
Timer 2 is turned ON and is made to have a pre & post scale of 1:1
Once done the goto $ will cause the processor to loop indefinitely and thus waiting for an interrupt.
4.5.2.
LFR.INC
Bank0 to bank3 macros are used to set the bank select bits in the status register to put the processor in the required
bank.
The INBANK1 to INBANK3 defines are used whenever a register not in bank 0 is accessed. This removes the
messages shown after build.
The 16 bit macros are used to simplify the code whenever 16bit numbers and variables are manipulated. The macros
are
MOV16LW - loads the 16 bit variable in small end-in format with the specified immediate 16 bit number
The rest of the defines and constant declarations are used to make understanding the code easier. But the purpose is lost if
the reader skips this section. In fact, even though this section is the second one presented, it must be the first one to read.
4.5.3.
ROUTINE.INC
The first lines of the code check if the interrupt was actually a timer 0 overflow interrupt just to make sure that no
rogue interrupt has occurred. Then the NO_SURFACE pin is checked; if high, both the motors are stopped and the routine
is exited. If the NO_SURFACE pin is low, it implies that the robot is actually on a surface and the routine can continue.
Next, the NO_LINE pin is de-bounced high in software. That is, the pin is read, then sampled again after 256 /ns
and compared with the previous value. The no line section of the code is executed only when both the past and the present
inputs were the same and equal to 1. Otherwise it is assumed that the robot can see the line, and thus continued onto the
modifiers section of the code.
PORT B is read and copied into the COMMAND_WORD register. Then it is masked to keep only the lower 3 bits
and set all others to 0. This register is now compared with its previous value stored at PREV_COMMAND_WORD. If they
are the same, then there is no point in instructing the motors again, thus exiting the routine; if they are different then,
COMMAND_WORD is loaded into the W register and the motor subroutine is called which modifies the motors
appropriately.
In the NO_LINE_CODE section, a 16 bit variable called TIME_COUNT is used. As the timer 0 interrupts every
2.1ms, to get a delay of 5 seconds, a value of 2380 (0X094C) is put in the TIME_COUNT register initially. This is
decremented, till it goes to zero, the routine is exited. This is an indirect way of achieving a 5 second delay. Once the 5
seconds are over, then a new section of the code is entered. A few user defined flag bits are used to remember which mode
was going on.
Once the 5 seconds are up, the NLA section of the code is reached. In this the TIME_COUNT is initialized to 476
(0X01DC) so as to give a delay of 1 second and the motor subroutine is called to set the motors to TURN RIGHT. Once
this is done this section of the code is skipped from the next second onwards. Every time TIME_COUNT goes to zero (1
second), it is initialized back to 476, and CCPR2L is incremented by 10 thus increasing the radius of curvature of the curve
the robot is tracing. CCPR2L is reset back to zero when it incremented beyond HIGHSPEED. Note that every time, the
timer 0 routine is exited.
4.5.4.
SUBROUTINES.INC
The first subroutine is a simple 256 /ns delay routine using just a single 8 bit register. The second is the main one
called the MOTOR subroutine. This is the one responsible to modifying the PORT A pins and the PWM duty cycles to
achieve the required turns. Before the subroutine is called, the W register must hold the COMMAND_WORD. This value
is added to the PCL register, thus causing a jump dependent on the value. For example if W contained 0, then the
immediate instruction is executed. This is a table of gotos causing the control to shift to the appropriate locations. The
operations performed by each leg of the subroutine are as shown in the table below. A user defined flag remembers if the
last operation was a forward or something else. This makes sure that the PORT A bits are not unnecessarily changed. NOPs
are added to each leg so that each of them are of the same length, thus making the subroutine execute in the same number
of cycles for every command word.
COMMAND WORD
0
SHARP TURN LEFT
1
SHARP TURN RIGHT
2
TURN LEFT
3
TURN RIGHT
4
MOVE LEFT
5
MOVE RIGHT
6
GO STRAIGHT
7
ERROR
ACTION
Left motor = reverse, RA1 = 0
Right motor = forward, RA0 = 1
Both motors = high speed.
(CCPR1L & CCPR2L)
Left motor = forward, RA1 = 1
Right motor = reverse, RA0 = 0
Both motors = high speed.
(CCPR1L & CCPR2L)
Both motors = forward, RA1 & RA0 = 1
Left motor = zero speed (CCPR2L)
Right motor = high speed (CCPR1L)
Both motors = forward, RA1 & RA0 = 1
Left motor = high speed (CCPR2L)
Right motor = zero speed (CCPR1L)
Both motors = forward, RA1 & RA0 = 1
Left motor = low speed (CCPR2L)
Right motor = high speed (CCPR1L)
Both motors = forward, RA1 & RA0 = 1
Left motor = high speed (CCPR2L)
Right motor = low speed (CCPR1L)
Both motors = forward, RA1 & RA0 = 1
Both motors = high speed (CCPR2L &
CCPR1L)
Return with 0XFF in W register
This completes the code explanation. The code occupies 191 program memory words.
LINE FOLLOWING
ROBOT
The Line following robot was finally completed. A lot of effort was put into the
design, implementation and days of toil in front of the computer, writing and debugging
the code. The robot was finally running with a few glitches here and there which were
sorted in the later revisions of the firmware. The line following robot still has a few shortcomings but achieves most of the objectives.
I earned a lot of knowledge on micro-controllers, a deeper & clearer view of the
architecture, ports & all other functional blocks was achieved. Did a lot of research on
robotics and already have my next project planned. had a peek look at all simple
functional parts of the project like the crystal oscillator, logic gates and the works. Well,
these were the topics that we have already dealt with, but I must be honest and admit that
there were various practical issues which one would learn only during a project. Theres a
lot of learning & yet not the end, learning is a continuous never ending process but is
definitely fun.
55
Department of Electronics & Communication, GAT, Bangalore - 98
6. BIBLIOGRAPHY
LINE FOLLOWING
ROBOT
BOOKS
Programming and Customizing the PIC microcontroller by Myke Predko Second edition McGraw Hill
PICmicro Mid-Range MCU Family Reference Manual by MICROCHIP
Design with PIC microcontrollers
by John B. Peatman - PEARSON Education
PIC Robotics, A beginners guide to robotics projects using the PICmicro by John Iovine McGraw Hill
Digital logic and computer design
by M. Morris Mano - Prentice - Hall of India PVT limited Digital Systems Principles &
applications
by Ronald J. Tocci Sixth Edition - Prentice - Hall of India PVT limited
WEBSITES REFERRED
The Seattle Robotics Society Encoder library of robotics articles
http://www.seattlerobotics.org/encoder/library.html
Dallas Personal Robotics Group. Most of these tutorials and articles were referred.
http://www.dprg.org/articles/index.html
http://www.dprg.org/tutorials/index.html
Go Robotics.NET, this page has many useful links to robotics articles.
http://www.gorobotics.net/articles/index.php
Carnegie Mellon Robotics Club. This is the links page with lots of useful resources
http://www.roboticsclub.org/links.html
56
Department of Electronics & Communication, GAT, Bangalore - 98
LINE FOLLOWING
ROBOT
This page is called the Micro-mouse Handbook and an excellent tutorial for small scale
robotics.
http://www.drtak.org/teaches/UCD/book/book/
This is the main website of microchip. Thousands of application notes, tutorials &
manuals can be found here.
http://www.microchip.com
57
Department of Electronics & Communication, GAT, Bangalore - 98
PCB LAYOUT
Top Side
lio following robot-*oldr tide
Bottom Side
LFR.HEX
020000040000FA
02000000512885
080008000B1D51288101061EA9
100010000C289B0195014F28241086192414742064
10002000A4142418861DA4100000A4182A28A411C2
1000300024120930A6004C30A50006080739A30099
10004000220603194F282308A2007A20003C031D32
1000500051284F28A4193328A503250A0319A603FC
10006000031D4F282412A4150330241E7A20241ABD
100070003D280130A600DC30A5002416A503250A82
100080000319A603031D4F280130A600DC30A5008C
100090001B080A3E9B00C03C03184F289B010B1114
1000A000090083130313831687011F30860085011F
1000B00002308100C8309200831303138312810140
1000C00020308B0000009201121597019D010C3029
1000D00097009D00C03095009B008B17A501A601DD
1000E0000730A200A4017328FF30A100A10B7628DD
1000F000000008008207B028A7289E2895288C2891
100100008328B928FF3464309B00C0309500033049
100110002419850024110034C0309B006430950000
10012000033024198500241100349B01C030950050
10013000033024198500241100000034C0309B00D6
100140009501033024198500241100000034C030CB
100150009B0095000130850024150000000000344C
10016000C0309B009500023085002415000000007F
100170000034C0309B009500033024198500241101
040180000000003447
02400E00723FFF
00000001FF
PIC16F87X
MICROCHIP
PIC16F873
PIC16F876
PIC16F874
PIC16F877
PDIP
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREFRA3/AN3/VREF+
RA4/T0CKI
RA5/AN4/SS
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKIN
OSC2/CLKOUT
RC0/T10SO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0
RD1/PSP1
RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
instructions to learn
All single cycle
instructions except for
program branches which
are two cycle
Operating speed: DC - 20
MHz clock input
DC - 200 ns
instruction
cycle
Up to 8K x 14 words of
FLASH Program Memory,
Up to 368 x 8 bytes of
Data Memory (RAM)
Up to 256 x 8 bytes of EEPROM
Data Memory
PIC16C73B/74B/76/77
Selectable oscillator
options
Low power, high speed
CMOS FLASH/EEPROM
technology
Fully static design
In-Circuit Serial
Programming (ICSP) via
two pins
Single 5V In-Circuit Serial
Programming capability
Processor read/write
access to program
memory
Pin Diagram
resolution is 200 ns
-PWM max. resolution is 10-bit
Peripheral Features:
PWM modules
-Capture is 16-bit, max.
resolution is 12.5 ns
-Compare is 16-bit, max.
10-bit multi-channel
Analog-to-Digital converter
Synchronous Serial Port
(SSP) with SPI (Master
mode) and I2C
(Master/Slave)
Universal Synchronous
Asynchronous Receiver
Transmitter (USART/SCI)
with 9-bit address
detection
Parallel Slave Port (PSP)
8-bits wide, with external
RD, WR and CS controls
(40/44-pin only)
Brown-out detection
circuitry for Brown-out
Reset (BOR)
Pin Diagrams
MCLR/VPP
RA0/AN0"*
RA1/AN1
RA2/AN2/VREF--*'
RA3/AN3/VREF+ ^ ^
RA4/T0CKI-*
RA5/AN4/SS "
VSS
OSC1/CLKIN
-----------------------
OSC2/CLKOUT -------1
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2-*
RC2/CCP1
RC3/SCK/SCL-*
c 1
c 23
c4
c5
c6
c
c8
c9
c 10
c 11
c 12
c 13
c 14
c
PIC16F876/873
PDIP, SOIC
RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
28
27
-----
26
25
24
23
22
21
20
19
18
17
16
15
oc oc > >
COCMtOA
zzzz<
PLCC
QO
00
Q.
5
< 5
< S
< SI
< a:
O O C Q CQQ- C Q C Q
O
Q1Q1Q1
CO
C M MS
f ZQ1Q1Q1Q1Z
CD
ID
ttttl till
nnnnnnnnnnn
VDD
VSS
RA4/T0CKI
RA5/AN4/SS
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
OSC1/CLKIN
OSC2/CLKOUT
RC0/T1OSO/T1CK1
NC
C7 C
8C9
C 10 C
11 C
12 C
13 H
14 C
15 C
16 C
PIC16F877
PIC16F874
17m
'39
38
37
36
35
34
33
32
31
30
29
''
<
Q
C/5 CO
, _ (W \ / V N '
'w'
' O ^CN
Q.Q.Q.Q.XQ.
!00(/5(/5(/5(/500
imtimt
Q_
O
O
05
o.
COCOQ-Q-Q-Q-COO
ilS^ TCOCM^OCOCM
QFP
iQOQQQQOO
1 0 :0 :0 :0 :0 :0 :0 :0 :
O O
o: z
a:?o
a:
RC7/RX/DT
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
VSS
VDD
RB0/INT
RB1
RB2
RB3/PGM
0.0
OJ-CMCO<O^O
D.Q.D.Q.QQQ2
05 05 05 o5 m^
o O
o _C/5
0. 0. 0. 0. ^ ^ <
TS CM
n
oT
Q Q Q Q C O o: o
CM
O O o: o: o: o: ^
o:
05
o
NC
RC0/T10SO/T1CKI
OSC2/CLKOUT
OSC1/CLKIN
VSS
VDD __________
RE2/AN7/CS
RE1/AN6/WR
RE0/AN5/RD
RA5/AN4/SS
RA4/T0CKI
o:
05
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
PIC16F87X
1.0 DEVICE OVERVIEW
This document contains device specific information.
Additional information may be found in the PICmicro
Mid-Range Reference Manual (DS33023), which may be
obtained from your local Microchip Sales Representative
or downloaded from the Microchip website. The
Reference Manual should be considered a complementary document to this data sheet, and is highly recommended reading for a better understanding of the device
architecture and operation of the peripheral modules.
FIGURE 1-1:
RA0/AN0
RA1/AN1
RA2/AN2/VREFRA3/AN3/VREF+
RA4/T0CKI_
RA5/AN4/SS
RB0/INT
RB1
RB2
RB3/PGM
RB4
RB5
RB6/PGC
RB7/PGD
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
RC7/RX/DT
DS30292C-page 5
PIC16F87X
TABLE 1-1:
Pin Name
OSC1/CLKIN
OSC2/CLKOUT
DI
P
Pin
9
10
SOIC
Pin#
9
10
I/O/P
Type
I
O
Buffer
Type
ST/CMOS(3)
Description
Oscillator crystal input/external clock source input.
Oscillator crystal output. Connects to crystal or resonator in crystal
oscillator mode. In RC mode, the OSC2 pin outputs CLKOUT which has
1 /4 the frequency of OSC1, and denotes the instruction cycle rate.
MCLR/VPP
I/P
ST
RA0/AN0
I/O
TTL
RA1/AN1
I/O
TTL
RA2/AN2/VREF-
I/O
TTL
RA3/AN3/VREF+
I/O
TTL
I/O
ST
I/O
TTL
RA4 can also be the clock input to the Timer0 module. Output is
open drain type.
RA5 can also be analog input4 or the slave select for the
synchronous serial port.
PORTB is a bi-directional I/O port. PORTB can be software programmed
for internal weak pull-up on all inputs.
RB0/INT
21
RB1
21
I/O
TTL/ST(1)
TTL
RB2
22
23
22
23
I/O
I/O
TTL
RB3/PGM
24
24
I/O
TTL
RB4
25
25
I/O
TTL
Interrupt-on-change pin.
RB5
26
26
I/O
TTL
Interrupt-on-change pin.
RB6/PGC
27
27
I/O
TTL/ST(2)
I/O
TTL/ST(2)
RB7/PGD
28
28
11
11
RC0/T1OSO/T1CKI
I/O
ST
I/O
ST
RC0 can also be the Timer1 oscillator output or Timer1 clock input.
RC1/T1OSI/CCP2
12
12
RC2/CCP1
13
13
I/O
ST
RC3/SCK/SCL
14
14
I/O
ST
RC4/SDI/SDA
15
15
I/O
ST
RC5/SDO
16
16
I/O
ST
RC6/TX/CK
17
17
I/O
ST
I/O
ST
18
18
P
RC4 can also be the SPI Data In (SPI mode) or data I/O (I2C mode).
RC5 can also be the SPI Data Out (SPI mode).
RC6 can also be the USART Asynchronous Transmit or
Synchronous Clock.
RC7/RX/DT
VSS
8,
19
20
VDD
Legend: I = input O = output
= Not used
Note 1:
2:
3:
8, 19
20
I/O = input/output
P = power
ST = Schmitt Trigger input
Trigger
Trigger
Trigger
DS30292C-page 7
8-bit timer/counter
PIC16F87X
REGISTER 5-1:
5.3 Prescaler
Note:
R/W-1
INTED
G
R/W1
T0SE
R/W-1
PSA
R/W1
PS2
R/W1
PS1
R/W1
PS0
bit 0
RBPU
INTEDG
TOCS: TMR0 Clock Source Select bit
Legend:
R = Readable bit
- n = Value at POR
Note:
R/W1
T0CS
W = Writable bit
'1' = Bit is set
U = Unimplemented bit,
read as '0'
= Bit is unknown
To avoid an unintended device RESET, the instruction sequence shown in the PICmicro Mid-Range MCU
Family Reference Manual (DS33023) must be executed when changing the prescaler assignment from Timer0 to
the WDT. This sequence must be followed even if the WDT is disabled.
DS30292C-page 9
PIC16F87X
Register 7-1 shows the Timer2 control register.
FIGURE 7-1:
DIAGRAM
TIMER2 BLOCK
REGISTER 7-1:
T2CON:
REGISTER (ADDRESS 12h)
U-0
bit 7
0
bit 7
0
1
TIMER2
R/W-0
TOUTPS
3
CONTROL
R/W-0
TOUTPS
2
R/W-0
TOUTPS
1
R/W-0
TOUTPS
0
R/W-0
TMR2ON
R/W-0
T2CKPS
1
R/W-0
T2CKPS
0
bit
0
1
Timer2 is off
bit 1-0 T2CKPS1:T2CKPS0: Timer2 Clock Prescale Select bits
= Prescaler is 1
= Prescaler is 4 1x = Prescaler is 16
Legend:
R = Readable bit
- n = Value at POR
W = Writable bit
'1' = Bit is set
DS30292C-page 10
U = Unimplemented bit,
read as '0'
= Bit is unknown
PIC16F87X
TABLE 7-1:
Address
0Bh,8Bh,
10Bh,18B
h
0Ch
Bit 7
INTCON
GIE
Bit 6
PEIE
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on:
POR,
BOR
Value
on
all
other
RESETS
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
0000 000u
CCP1IF
TMR2IF
TMR1IF
0000 0000
0000 0000
CCP1IE
TMR2IE
TMR1IE
0000 0000
0000 0000
(1)
ADIF
RCIF
TXIF
ADIE
RCIE
TXIE
SSPI
F
SSPI
E
PIR1
PSPIF
8Ch
PIE1
PSPIE(1)
11h
12h
TMR2
T2CON
0000 0000
-000 0000
0000 0000
-000 0000
92h
PR2
1111 1111
1111 1111
Legend:
x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by the Timer2 module.
Note 1: Bits PSPIE and PSPIF are reserved on the PIC16F873/876; always maintain these bits clear.
8.0 CAPTURE/COMPARE/PWM
MODULES
Each Capture/Compare/PWM (CCP) module contains a
16-bit register which can operate as a:
CCP2 Module:
Capture/Compare/PWM Register2 (CCPR2) is comprised
of two 8-bit registers: CCPR2L (low byte) and CCPR2H
(high byte). The CCP2CON register controls the operation
of CCP2. The special event trigger is generated by a
compare match and will reset Timer1 and start an A/D
conversion (if the A/D module is enabled).
Additional information on CCP modules is available in the
PICmicro Mid-Range MCU Family Reference Manual
(DS33023) and in application note AN594, Using the
CCP Modules (DS00594).
TABLE 8-1:
CCP Mode
Timer Resource
Capture
Compare
PWM
Timer1
Timer1
Timer2
DS30292C-page 11
PIC16F87X
TABLE 8-2:
CCPx
Mode
Interaction
Capture
Compar
e
PWM
Compar
e
Compar
e
PWM
PWM
Capture
None
PWM
Compar
e
None
Capture
Capture
DS30292C-page 12
The compare(s) should be configured for the special event trigger, which clears TMR1
The PWMs will have the same frequency and update rate (TMR2 interrupt)
PIC16F87X
REGISTER 8-1:
U-0
bit 7
0
R/W-0
CCPx
X
R/W-0
CCPx
Y
R/W-0
CCPxM3
R/W0
CCPxM
2
R/W-0
R/W-0
CCPxM1
CCPxM0
bit
CCPxX:CCPxY:
Legend:
R = Readable bit
- n = Value at POR
W = Writable bit
'1' = Bit is set
U = Unimplemented bit,
read as '0'
= Bit is unknown
DS30292C-page 13
Note:
The PWM period is specified by writing to the PR2 register. The PWM period can be calculated using the following formula:
TMR2 is cleared
FIGURE 8-3:
BLOCK
DIAGRAM
SIMPLIFIED PWM
Note:
FIGURE 8-4:
PWM OUTPUT
Period
H*------------------------------
r*-------------------;
Duty Cycle
When the CCPR1H and 2-bit latch match TMR2, concatenated with an internal 2-bit Q clock, or 2 bits of the
TMR2 prescaler, the CCP1 pin is cleared.
The maximum PWM resolution (bits) for a given PWM
frequency is given by the formula:
Resolution
Note:
TMR2 = PR2
bits
log(2)
TMR2 = PR2
TMR2 = Duty Cycle
FOSC log
FPWM
PIC16F87X
8.3.3 SETUP FOR PWM OPERATION
2.
3.
4.
5.
TABLE 8-3:
PWM Frequency
Timer Prescaler (1, 4, 16)
PR2 Value
Maximum Resolution (bits)
1.22
kHz
4.88 kHz
16
0xFFh
4
0xFFh
10
10
19.53
kHz
78.12kH
z
156.3
kHz
208.3 kHz
1
0xFFh
1
0x3Fh
1
0x1Fh
1
0x17h
10
5.5
DS30292C-page 15
PIC16F87X
TABLE 8-4:
Address
INTCON
0Bh,8Bh,
Bit
7
Bit
6
Bit 5
GIE
PEI
E
T0IE
PSPIF(1)
ADI
F
RCIF
ADI
E
RCIE
Bit 4
INTE
Bit 3
RBIE
Bit
2
Bit
1
Bit
0
Value on:
POR,
BOR
Value on
all other
RESETS
T0IF
INTF
RBIF
0000 000x
0000 000u
10Bh, 18Bh
0Ch
PIR1
0Dh
PIR2
8Ch
PIE1
PSPIE(1)
8Dh
PIE2
87h
TRISC
0Eh
TMR1L
0Fh
TMR1H
TXIF
0000 0000
0000 0000
CCP2IF
------------ - - 0
------------ - - 0
TMR1IE
0000 0000
0000 0000
CCP2IE
------------ - - 0
------------ - - 0
1111 1111
1111 1111
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
--00 0000
- - u u uuuu
xxxx xxxx
uuuu uuuu
T1CKPS
0
T1CON
CCPR1L
16h
CCPR1H
17h
1Bh
CCP1CO
N
CCPR2L
CCP1
Y
Capture/Compare/PWM Register2 (LSB)
1Ch
CCPR2H
T1CKPS
1
15h
1Dh
TMR1IF
TMR2IE
CCP1X
TMR2IF
TXIE
10h
Legend:
CCP1IF
CCP1IE
SSPIF
SSPIE
T1OSCE
N
TMR1C
S
T1SYNC
CCP1M
2
CCP1M3
CCP1M1
TMR1O
N
CCP1M0
CCP2CO
CCP2
CCP2M
CCP2X
CCP2M3
CCP2M1
CCP2M0
N
Y
2
x = unknown, u = unchanged, - = unimplemented, read as '0'. Shaded cells are not used by Capture and Timer1.
xxxx xxxx
uuuu uuuu
--00 0000
--00 0000
xxxx xxxx
uuuu uuuu
xxxx xxxx
uuuu uuuu
--00 0000
--00 0000
Note 1: The PSP is not implemented on the PIC16F873/876; always maintain these bits clear.
TABLE 13-2:
Mnemonic,
Operands
ADDWF
ANDWF
CLRF
CLRW
COMF
DECF
DECFSZ
INCF
INCFSZ
IORWF
MOVF
MOVWF
NOP
RLF
RRF
SUBWF
SWAPF
XORWF
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
Description
Cycles
Add W and f
AND W with f
Clear f
Clear W
Complement f
Decrement f
Decrement f, Skip if 0
Increment f
Increment f, Skip if 0
Inclusive OR W with f
Move f
Move W to f
No Operation
Rotate Left f through Carry
Rotate Right f through Carry
Subtract W from f
Swap nibbles in f
Exclusive OR W with f
1
1
1
1
1
1
1(2
1)
1(2
1)
1
1
1
1
1
1
1
1
14-Bit Opcode
MS
b
BYTE-ORIENTED FILE REGISTER OPERATIONS
0
0
0
0
0
0
0
0
0
0
0
00
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
00
0
0
0
LS
b
0111
dfff
ffff
0101
dfff
ffff
0001
0001
lfff
0xxx
ffff
xxxx
1001
0011
dfff
dfff
ffff
ffff
1011
dfff
ffff
1010
dfff
ffff
1111
dfff
ffff
0100
dfff
ffff
1000
dfff
ffff
0000
lfff
0xx0
dfff
ffff
dfff
ffff
0010
dfff
ffff
1110
0110
dfff
dfff
ffff
ffff
0 0bb
bfff
ffff
01bb
bfff
ffff
0000
1101
1100
0000
ffff
Status
Affected
Not
es
C,DC,
ZZ
1,2
1,2
2
Z
Z
Z
Z
Z
Z
Z
C
C
C,DC,
Z
Z
1,2
1,2
1,2,
31,2
1,2,
31,2
1,2
1,2
1,2
1,2
1,2
1,2
f, b
f, b
DS30292C-page 136
Bit Clear f
Bit Set f
1
1
0
1
0
1
1,2
1,2
BTFSC
BTFSS
f, b
f, b
ADDLW
ANDLW
CALL
CLRWDT
GOTO
IORLW
MOVLW
RETFIE
RETLW
RETURN
SLEEP
SUBLW
XORLW
k
k
k
k
k
k
k
k
k
0
1
1
0
(2)
1
1
(2)
LITERAL AND CONTROL OPERATIONS
1
Add literal and W
1
1
1
AND literal with W
1
1
1
Call subroutine
2
0
0
Clear Watchdog Timer
1
0
1
Go to address
2
0
1
Inclusive OR literal with W
1
1
1
Move literal to W
1
1
0
Return from interrupt
2
0
1
Return with literal in W
2
1
0
Return from Subroutine
2
0
0
Go into standby mode
1
0
1
Subtract W from literal
1
1
1
Exclusive OR literal with W
1
1
10bb
11bb
bfff
bfff
ffff
ffff
111x
kkkk
kkkk
1001
kkkk
kkkk
0kkk
kkkk
kkkk
0000
0110
0100
1kkk
kkkk
kkkk
kkkk
kkkk
0 0xx
kkkk
kkkk
0000
0000
1001
01xx
kkkk
kkkk
0000
0000
1000
0000
0110
0011
110x
kkkk
kkkk
kkkk
kkkk
1000
1010
3
3
C,DC,
ZZ
TO,P
D
Z
TO,P
D
C,DC,
ZZ
Note 1: When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, 1), the value used will be that value present on the pins themselves.
For example, if the data latch is '1' for a pin configured as input and is driven low by an external device, the data will be written back
with a '0'.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared if assigned to the Timer0
module.
3: If Program Counter (PC) is modified, or a conditional test is true, the instruction requires two cycles. The second cycle is executed as a
NOP.
Note:
Additional information on the mid-range instruction set is available in the PICmicro Mid-Range MCU
Family Reference Manual (DS33023).
/=T SGS-THOMSON
^7/. M(5[sMgH[gCT[Rl(o)M(5gi
L293D
L293DD
1/7
SO(12+4+4)
(12+2+2)
ORDERING NUMBERS:
L293DD
DESCRIPTION
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 solenoides, DC
and stepping motors) and switching power transistors.
To simplify use as two bridges each pair of channels is equipped with an enable input. A separate
supply input is provided for the logic, allowing operation at a lower voltage and internal clamp diodes are included.
This device is suitable for use in switching applications at frequencies up to 5 kHz.
Powerdip
L293D
June 1996
L293D - L293DD
ABSOLUTE MAXIMUM RATINGS
Symbol
Supply Voltage
36
36
Vi
Input Voltage
Enable Voltage
Io
tot
stg, Tj
OUTPUT 1 d
2
3
GND d
GND d
GND d
GND d
OUTPUT 2 d
INPUT 2 d
Us d
H32L293D1-02
1.2
-40 to 150
16
ENABLE 1 (
INPUT 1 d
Uni
t
VS
ENABLE 1 d
Value
VSS
Ven
Parameter
6
7
8
9
18
-----------
20
19
18
17
16
15
14
13
12
11
ID
ID
ID
ID
ID
ID
ID
ID
ID
ID
Uss
INPUT 1
16
OUTPUT 1
14
INPUT 4
OUTPUT 4
GND
GND
GND
GNO
13
GNO
12
GND
OUTPUT 3
INPUT 3
ENABLE 2
OUTPUT 2
INPUT 2
11
10
SS
GNO
OUTPUT 3 INPUT 3 ENABLE 2
S.6574
SO(12+4+4)
Powerdip(12+2+2)
THERMAL DATA
Symbol
Decription
SO
max.
14
max.
max.
80
14
50 (*)
-
th j-pins
th j-amb
R
th j-case
2/7
DIP
nz7 SGS-THOMSON
t8ilDCR@lllLiCn^KIDCS
Uni
t
C/
W
C/
W
AI/IBIKA TRADING
CO.,
Gear series CS33 & CS28 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
requires no maintenance. The motor is screwed to the gear box from
inside. Any small standard motor can be used in combination with the
gear box. However the most popular ones are mentioned in the table
below.
Voltag
e
DC3
DC3
3
DC3
3
DC3
3
DC2
5
DC2
5
6
6
'
Direction
Spe
ed
240
240
0
240
0
750
0
220
0
850
0
CWorAC
1
Reversibl
CWorAC
W
Reversibl
e
Reversibl
e
Reversibl
e
12
12
2.5
6
Torque
30gm-cm
30 gm-cm
50 gm-cm
25 gm-cm
3.2 gm-cm
4.0 gm-cm
Motor Data
Standard Data
kg-cm
GearTorque
Mot
or
Combination motor
Mounting
/
Standard small DC motor Dia 33 availiable in 6 V, 9 V or 12 V DC
any position
Weight
gm
Axial thrust
150
kg
2 . .................................................................: "
Radial torque
kg
Lateral torque
kg-cm
Output shafts
Ambient temperature operation
0
*C
Transmission ratios
1155
410
385
205
35
14
11
185
155
120
100
62
Dimensional Drawing
On 17 PCD
'T
s5'
MOTOR DC 33
oS
25
sia
28 1
52
42
http://onsemi.com
These comparators are designed for use in level detection, low-level sensing and memory applications in
consumer, automotive, and industrial electronic applications.
Features
SOIC-14
D SUFFIX
CASE 751A
PDIP-14 N,
P SUFFIX
CASE 646
1
TSSOP-14
DTB
SUFFIX
CASE 948G
PIN CONNECTIONS
Output 2
Output 1
CC
- Input 1
+
In
put
1
- Input 2
(Top View)
+
ORDERING INFORMATION
In
put
2
DEVICE
MARKING INFORMATION
See general marking information in the device marking section on page 8 of
this data sheet.
*For additional information on our Pb-Free strategy and soldering details, please download the
ON Semiconductor Soldering and Mounting Techniques Reference Manual, SOLDERRM/D.
LM339/D
74HC/HCT27
SYMBOL
1,3, 9
1A to 3A
data inputs
2, 4, 10
1B to 3B
data inputs
13, 5, 11
7
1C to 3C
GND
data inputs
ground (0 V)
12, 6, 8
14
1Y to 3Y
data outputs
oo<
PIN DESCRIPTION
PIN NO.
Fig.4 Functional
diagram.
FUNCTION TABLE
INPUTS
n
n
n
A
B
C
OUT
PUT
nY
L
X
L
X
L
H
H
L
X
H
H
X
X
X
L
L
Notes
1. H = HIGH voltage level L =
LOW voltage level X =
don't care
M
M
74
H
C1
48
83
Li
ne
Pri
ori
ty
En
co
de
r
MM74HC148
8-3 Line Priority Encoder
General Description
The MM74HC148 priority encoder utilizes advanced silicon-gate
CMOS technology. It has the high noise immunity and low power
consumption typical of CMOS circuits, as well as the speeds and
output drive similar to LB-TTL.
This priority encoder accepts 8 input request lines 0-7 and
outputs 3 lines A0-A2. The priority encoding ensures that only the
highest order data line is encoded. Cascading circuitry (enable
input EI and enable output EO) has been provided to allow octal
expansion without the need for external circuitry. All data inputs
and outputs are active at the low logic level.
All inputs are protected from damage due to static discharge by
internal diode clamps to VCC and ground.
Features
Ordering Code:
Order Number
Package Number
Package Description
MM74HC148M
M16A
16-Lead Small Outline Integrated Circuit (SOIC), JEDEC MS-012, 0.150" Narrow
MM74HC148N
N16E
Connection Diagram
Truth Table
Inputs
E
I
H
L
0 1 2
Outputs
4
X X X X X X X X
H H H H H H H H
A
2
H
H
A
1
H
H
A
0
H
H
G
S
H
H
E
O
H
L
X X
X X
X X
H H
X X
H H H
X X
H H H H
X X
H H H H H
X L
H H H H H H
H H H H H H H
www.fairchildsemi.com
74HC04; 74HCT04
>
Hex inverter
1Y
ID
2A
2Y
3A
3Y
6
Top view
1A
C
D
GND(1)
12
6Y
11
5A
10
5Y
RR
GND 4Y
6A
4A
2A
3A
4A
11
5A
13
6A
MBL760
>
>
>
>
>
>
1Y
10
12
MNA342
(1) The die substrate is attached to this pad using conductive die attach material. It can not be used as a supply pin or input.
10
12
MNA343
LM78XX
Series Voltage Regulators
General Description
The LM78XX series of three terminal regulators is available with
several fixed output voltages making them useful in a wide
range of applications. One of these is local on card regulation,
MNA34
1
L
M
78
X
X
S
er
ie
s
V
ol
ta
g
e
Features
12V
LM7815C
15V
Voltage Range
Connection Diagrams
Metal Can Package
TO-3 (K)
Aluminum
DS007746-2
Bottom View
Order Number LM7805CK,
LM7812CK or LM7815CK
See NS Package Number KC02A
Plastic Package
TO-220 (T)
DS007746-3
Top View
Order Number LM7805CT,
LM7812CT or LM7815CT
See NS Package Number T03B
www.national.com