A Project Report On ADAPTIVE CRUISE CONTROL Submitted in the partial fulfillment of the Requirement for the award of the Bachelor’s Of Technology In MECHANICAL ENGINEERING Submitted By Moninderjeet Singh 6851114255 Naveen Kumar 6851114257 Navjot Sharma 6851114258 Pankaj Bhardwaj 6851114260 Puneet Bhasin 6851114268 Under the guidance of Mr. Ajay Saini Lecturer in Mechanical Department S.B.B.S.I.E.T, Jalandhar 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
A
Project Report
On
ADAPTIVE CRUISE CONTROLSubmitted in the partial fulfillment of the
Requirement for the award of the
Bachelor’s Of Technology
In
MECHANICAL ENGINEERING
Submitted By
Moninderjeet Singh 6851114255
Naveen Kumar 6851114257
Navjot Sharma 6851114258
Pankaj Bhardwaj 6851114260
Puneet Bhasin 6851114268
Under the guidance of
Mr. Ajay Saini
Lecturer in Mechanical Department
S.B.B.S.I.E.T, Jalandhar
Department of Mechanical Engineering
Sant Baba Bhag Singh Institute of Engineering & Technology
Vill. Khiala, P.O. Padhiana,Distt.Jalandhar
December 2009
1
TO WHOM IT MAY CONCERN
Certificate
This is to certify that Project entitled “ADAPTIVE CRUISE CONTROL ” is submitted in Partial fulfillment for the award of degree B.Tech (Mechanical Engineering) of Punjab Technical University has been successfully completed by Mr.Moninderjeet Singh having Roll No. 6851114255.They have done a satisfactory work under my Supervision/Guidance .
Name of Guide Name of Co-ordinator Name of H.O.D
Lect. Ajay Saini Sr. Lect. Sukhjeet Singh Dr. K.D. Mannan
2
TO WHOM IT MAY CONCERN
Certificate
This is to certify that Project entitled “ADAPTIVE CRUISE CONTROL ” is submitted in Partial fulfillment for the award of degree B.Tech (Mechanical Engineering) of Punjab Technical University has been successfully completed by Mr.Naveen Kumar having Roll No. 6851114257.They have done a satisfactory work under my Supervision/Guidance .
Name of Guide Name of Co-ordinator Name of H.O.D
Lect. Ajay Saini Sr.Lect. Sukhjeet Singh Dr. K.D. Mannan
3
TO WHOM IT MAY CONCERN
Certificate
This is to certify that Project entitled “ADAPTIVE CRUISE CONTROL ” is submitted in Partial fulfillment for the award of degree B.Tech (Mechanical Engineering) of Punjab Technical University has been successfully completed by Mr. Navjot Sharma having Roll No. 6851114258.They have done a satisfactory work under my Supervision/Guidance .
Name of Guide Name of Co-ordinator Name of H.O.D
Lect. Ajay Saini Sr.Lect. Sukhjeet Singh Dr. K.D. Mannan
4
TO WHOM IT MAY CONCERN
Certificate
This is to certify that Project entitled “ADAPTIVE CRUISE CONTROL ” is submitted in Partial fulfillment for the award of degree B.Tech (Mechanical Engineering) of Punjab Technical University has been successfully completed by Mr.Pankaj Bhardwaj having Roll No. 6851114260.They have done a satisfactory work under my Supervision/Guidance .
Name of Guide Name of Co-ordinator Name of H.O.D
Lect. Ajay Saini Sr.Lect. Sukhjeet Singh Dr. K.D. Mannan
5
TO WHOM IT MAY CONCERN
Certificate
This is to certify that Project entitled “ADAPTIVE CRUISE CONTROL ” is submitted in Partial fulfillment for the award of degree B.Tech (Mechanical Engineering) of Punjab Technical University has been successfully completed by Mr.Puneet Bhasin having Roll No. 6851114268.They have done a satisfactory work under my Supervision/Guidance .
Name of Guide Name of Co-ordinator Name of H.O.D
Lect. Ajay Saini Sr. Lect. Sukhjeet Singh Dr. K.D. Mannan
6
ACKNOWLEDGEMENT
We express our sincere gratitute to our Guide Mr. Ajay Saini(Lecturer,Mechanical Engineering Department ,Sant Baba Bhag Singh Institute of Engineering and Technology ,Padhiana) For her valuable guidiance ,proper advice,constructive suggestion and constant encouragement under her tutelege.
We would also like to thanks our assistor, Medhaavi Embedded Systems,Hoshiarpur who served as our supervisor and helped us in understanding the concept & electronics portion of the project.
We would like to convey our Gratitute to Dr.K.D Manan, H.O.D of our Mechanical Depatment, Project Head Mr. Sukhjeet Singh(Sr.Lecturer,Mechanical), with those expert guidance and support, this job would have been compelling.
We also pay our deep regard to all other staff member of our lab who helpd us by providing resources at the time of need.
We do not find enough words with which we can express our feeling of thanks to entire faculty and staff of Mechanical Department,Sant Baba Bhag Singh Institute of Engineering and Technology ,for their help,inspiration and moral support, which went a long way in successfully completion of our project.
We are also thankfull to our family members anfd friends for support and encouragement.
Moninderjeet Singh
Naveen Kumar
Navjot Sharma
Pankaj Bhardwaj
Puneet Bhasin
7
Table of Contents
1. Introduction to the Project.
2. Block Diagram
3. Circuit Diagram.
4. Component List.
5. Adaptive Cruise Control
6. Notes on Microcontroller
7. Code for Microcontroller
8. References
8
1. Introduction
The underlying technology behind this idea uses an intelligent & advanced electronic system to
control the speed of car. On a long & straight road, car driver can enable this function
(Automatic Cruise Control) & can relax. Driver would no longer be required to press accelerator
pedal as the speed of car is controlled by ACC.
In summary, for modern engine control systems, the vehicle speed regulation is a comfort
functionality.
ACC supports the driver to run at constant speed without pressing the accelerator pedal.
ACC releases the driver from the continuous surveillance of the speedometer.
ACC is very helpful at traveling long distances.
It uses a radar sensor to detect the distance to obstacle/another vehicle/animal in front.
It adjusts speed of the vehicle based on output of radar sensor.
It also applies brake based on the output of radar sensor.
Car will also be equipped with sensors which will check for any obstacle/another vehicle/animal
on the road, if there is so, speed decreases automatically and results into vehicle stoppage.
9
Vehicle Control
In this project we use two small gear dc motor for drive the small car. One motor for the left
wheel and one motor for the right wheel. Here we use powerful gear dc motor instead of stepper
motor. Stepper is not suitable for the drive the vehicle. Stepper motor is suitable for positioning
sensor but gear motor is suitable for the vehicle drive.
Motors
To make the concept car we need to have motors and the control circuitry that could control the
motors. There are different kinds of motors available for different application.
1. DC motor
2. Stepper motor
3. Servo motor
89C51 MICROCONTROLLER:
Is a 40 pin version of 51 family,. Program written for this controller is same for the all 8051
family controllers.
OPTOCOUPLER ( PC 817):
In this project we use optocoupler to provide a electrical isolation between process control
circuit and motor drive circuit. In this project we use separate supply for processor and control
circuit. Pc 817 is 4 pin ic. In this coupler two pin is input and two pin is output.
CRYSTAL.
In this project we use two crystal. One for the dtmf decoder and second with the microcontroller
Main use of the crystal is to provide a external frequency for the internal oscillator. With the
dtmf decoder we use crystal 3.58 Mhz and with the microcontroller we use 12 Mhz crystal.
10
DC MOTOR:
We use slow speed dc motor to drive the movement of vehicle. In this project we use two dc
motor. One for the drive the vehicle and second motor to change the direction of the vehicle.
H BRIDGE LOGIC:
H bridge logic is basically provide a forward and reverse logic to the motor.
DC motors:
These are the motors that are commonly found in the toys and the tape recorders. These
motors change the direction of rotation by changing the polarity. Most chips can't pass enough
current or voltage to spin a motor. Also, motors tend to be electrically noisy (spikes) and can
slam power back into the control lines when the motor direction or speed is changed.
Specialized circuits (motor drivers) have been developed to supply motors with power and to
isolate the other ICs from electrical problems. These circuits can be designed such that they can
be completely separate boards, reusable from project to project.
A very popular circuit for driving DC motors (ordinary or gearhead) is called an H-bridge. It's
called that because it looks like the capital letter 'H' on classic schematics. The great ability of an
H-bridge circuit is that the motor can be driven forward or backward at any speed, optionally
using a completely independent power source.
The H-Bridge with Enable Circuitry
11
It should be clear that one would never want to enable Transistors One and Two or Transistors
Three and Four simultaneously. This would cause current to flow from Power + to Power -
through the transistors, and not the motors, at the maximum current-handling capacity of either
the power supply or the transistors. This usually results in failure of the H-Bridge. To prevent the
possibility of this failure, enable circuitry as depicted in Figure is typically used.
In this circuit, the internal inverters ensure that the vertical pairs of transistors are never enabled
simultaneously. The Enable input determines whether or not the whole circuit is operational. If
this input is false, then none of the transistors are enabled, and the motor is free to coast to a stop.
By turning on the Enable input and controlling the two Direction inputs, the motor can be made
to turn in either direction.
Note that if both direction inputs are the same state (either true or false) and the circuit is
enabled, both terminals will be brought to the same voltage (Power + or Power - , respectively).
This operation will actively brake the motor, due to a property of motors known as back emf, in
which a motor that is turning generates a voltage counter to its rotation. When both terminals of
the motor are brought to the same electrical potential, the back emf causes resistance to the
motor's rotation.
12
Stepper motors
Stepper motors are special kind of heavy duty motors having 2 or 4 coils. The motors will
be stepping each time when it get the pulse. As there are many coils in the motors we need to
energize the coils in a specific sequence for the rotation of the motor. These motors are mostly
used in heavy machines. The figure shown below consists of a 4 coil stepper motor and the arrow
mark will rotate when the coils are energized in the sequence.
Unlike DC motors stepper motors can be turned accurately for the given degrees.
Servo motors
Servo motors unlike the stepper motor it has to be controlled by the timing signal. This
motor has only one coil. It is mostly used in robots for its lightweight and low power
consumption. The servo motors can also be accurately rotated by the making the control signal of
the servo motor high for a specific time period. Actually the servo motor will be having 3 wires
where 2 are for power supply and another one is for the control signal. Driving the servomotors
is so simple that you need to make the control signal high for the specific amount of time. The
width of the pulse determines the output position of the shaft
Object Detection
Detecting objects without whiskers doesn’t require anything as sophisticated as machine vision.
Some robots use RADAR or SONAR (sometimes called SODAR when used in air instead of
water). An even simpler system is to use infrared light to illuminate the robot’s path and
determine when the light reflects off an object. The IR illuminators and detectors are readily
available and inexpensive.
13
Infrared As Headlights
The infrared object detection system we’ll build on the Bot is like a car’s headlights in several
respects. When the light from a car’s headlights reflects off obstacles, your eyes detect the
obstacles and your brain processes them and makes your body guide the car accordingly. We will
be using infrared LEDs for headlights. They emit infrared, and in some cases, the infrared
reflects off objects and bounces back in the direction of the detecter. The eyes of the
Bot( mobile) are the infrared detectors. The infrared detectors send signals to the Microcontroller
indicating whether or not they detect infrared reflected off an object. The brain of the Bot, the
microcontroller makes decisions and operates the motors based on this sensor input.
IN this project we use total tow motor so to control both the motor we require two H bridge
circuit. One for the one motor. Microcontroller sense the signal from the decimal decoder and
same output is connected to microcontroller and so on dc motor drive circuit. .
P 2 . 2 / A 1 0P 2 . 3 / A 1 1P 2 . 4 / A 1 2P 2 . 5 / A 1 3P 2 . 6 / A 1 4P 2 . 7 / A 1 5
P 3 . 0 / R XDP 3 . 1 / TXD
P 3 . 2 / I N TOP 3 . 3 / I N T1
P 3 . 4 / TOP 3 . 5 / T1
P 3 . 6 / W RP 3 . 7 / R D
P 0 . 0 / A D 0P 0 . 1 / A D 1P 0 . 2 / A D 2P 0 . 3 / A D 3P 0 . 4 / A D 4P 0 . 5 / A D 5P 0 . 6 / A D 6P 0 . 7 / A D 7
C 4
1 0 k
C 3
1 0 k
2 557
2
3
R
R
12 Mhz
1
R
TIP122
1
2
2
R
R
TIP122
TIP122
1
R
R
R
TIP122
R
B
R
557
B
R
R
TIP127
R
A
R
R
A
557
R
Rx
Rx
R
TIP127
R
TIP127
Tx
Tx
R
R
R
557
TIP127
R
R
R
16
4. List of Components:-
Component List
S.No. Component Value Quantity Cost Remark
1 Ic base 40 pins 1
2 AT89C52 40 pins 1
3 Crystal 12Mhz 1
4 Capacitor 33pf 2
5 Capacitor 10Mf 1
6 Switch 2 or 4 legs 1
7 Resistance 10k 9
8 Connector 2 pins 4
9 Transistor TIP 122 4
10 Transistor TIP 127 4
11 Transistor 557(pnp) 4
12 DC gear Motor 30-100 rpm 2
13 Resistance 4.7k 12
14 IR(Tx) 2
15 IR(Rx) 2
16 Resistance 470hm 2
17
5. An introduction to Automatic Cruise Control
(ACC)
The surround sensing problem
Almost continuously, someone in the world dies from a traffic accident; countless more suffer
injuries. Moreover, the economic losses caused by traffic accidents
are reaching astronomical proportions. Vehicle manufacturers and their suppliers have made it
their goal to avoid such accidents, or at least to mitigate their effects. Much automotive safety
improvement can be made thanks to automotive electronics developments.
Analyses of the correlations between collisions and driver reactions have shown that a
considerable number of accidents can be avoided by recognizing a hazard in sufficient time and
making appropriate driving maneuvers. Such actions can be achieved by warning signals to the
driver or by automatic longitudinal and lateral control of the vehicle (Driver Assist Systems).
Suitable sensors are a requirement if the hazardous situations to be identified. A resulting sensor
network covers the area around the vehicle in conjunction with a suitable human-machine
interface. Electronic surround sensing systems form the basis of numerous river Assistance
Systems—systems for warning or active intervention. One area of these Driver Assistance
Systems is aimed at avoiding frontal collisions, which can be significantly reduced by accident
warning systems and active braking intervention. Adaptive Cruise Control (ACC) is the first step
in this direction.
Today’s ACC systems area mainly based on radar systems in the milli- meter wave range.
Millimeter wave radar systems are divided into pulsed and continuous wave systems, which are
in turn subdivided into frequency modulated continuous wave (FMCW) and spread spectrum
systems.
18
77 GHz FMCW radar systems allow objects to be detected within a range of 1 to 150m. At the same time, their distance and speed relative to the host vehicle—and with the right number of antennas, also their angle to the longitudinal axis of the vehicle—are determined.
Surround sensing systems—
Adaptive Cruise Control
Surround sensing systems forming the basis of numerous Driver Assistance Systems are
differentiated into:
• Ultrasonic-, radar-, video- and Navigation-based systems
• Passive and active systems
• Safety and convenience system
•Driver support, passive safety, collision mitigation, and vehicle control systems, according to
their function within the system.
Adaptive cruise Control system falls within the functional area of vehicle control and actively
intervenes in the longitudinal control of the vehicle. They decelerate the vehicle if it gets closer
than a set minimum distance from preceding vehicle and accelerate it to the set speed if there is
a sufficiently large gap. ACC systems are currently installed as convenience systems.
Their braking intervention is limited to a maximum of 30% of braking force capability; the
driver is in ultimate control of the vehicle. Current ACC systems are therefore particularly
suitable for roads with less traffic density, such as Interstates or highways. With additional
sensors, future ACC systems will be suitable for driving in heavy traffic in urban areas.
19
Further developments of ACC Stop-and-Roll (S&R) an ACC Stop-and-Go (S&G) are intended
to allow automatic stopping and starting in order to make lanes safer and improve traffic flow
The ultimate aim of these Driver Assistance Systems is 360-degree coverage of the area around
the vehicle; in the area of vehicle control, the goal is to expand the ACC function to achieve
complete longitudinal control.
Sensors for surround sensing
Covering the entire area around the vehicle requires a series of different sensors. Two types of
sensor, infrared (IR) sensors and long-range radar (LRR) sensors, are particularly well suited to
ACC. IR sensors are used in LIDAR (light detection and ranging) systems and cover a range of
up to 120m; in the case of 77 GHz LRR sensors, range can be extended up to 150m. IR sensors
offer a price advantage compared with LRR sensors, but have the marked disadvantage that poor
weather (heavy rain, snow, fog, dust, etc.) considerably reduces their working range.
Radar sensors, on the other hand, are almost entirely unaffected by weather conditions. Another
important argument in favor of radar sensors is that they can be mounted concealed in the front
of the vehicle; 77 GHz radar systems allow very small antenna sizes, permitting them to be
installed almost anywhere consequently, present ACC systems primarily use 77 GHz LRR
systems.
The main task of ACC is to decelerate the car if there is insufficient following distance to a
vehicle ahead or to accelerate if there is sufficient distance between vehicles. The control
parameters required for these tasks—desired driving speed
and time gap - are set by the driver via a human-machine interface (HMI). The entire control
function takes place in the sensor control unit (SCU). The main functions of the SCU are ACC
sensor control and object recognition. Calculation of the ACC control variables and activation of
the relevant systems are carried out in the ACC electronic control unit (ECU). Further processing
is done for the signals received by the ACC sensor. During object recognition, distance and
relative speed of all potential objects are calculated from the information contained in the
signals. Distance control requires the precise selection and regulation of a single object out of all
the objects detected by the ACC radar system.
20
Selection takes place using information on the vehicle’s movement, such as acceleration, wheel
speed, steering angle, and yaw rate. Using the host vehicle’s speed and the desired time interval,
the ACC system calculates the minimum separation distance required. If the distance calculated
for the selected object is too small for the current speed, the separation distance is adjusted and
deceleration commands are given to the appropriate systems (i.e. engine management, braking).
If the following distance is sufficient the speed is adjusted until the desired speed is reached. To
do this, acceleration commands are given to the relevant actuators. The specified time interval
and warning signals if the minimum distance is not maintained are shown on the HMI display.
The diagram below shows the ACC system components and where they are installed in the
vehicle.
Note: Front wheel drive car shown ASR = acceleration slip regulator (traction control) ESP =
electronic stability program (electronic stability control)
21
FMCW radar
Today’s ACC systems are mainly based on radar systems in the millimeter wave range. The
frequency modulated continuous wave (FMCW) method is used here in the majority of cases.
FMCW radar systems allow simultaneous determination of the distance and the speed of objects
detected relative to the host vehicle. Using the appropriate number of antennas, the angle to the
longitudinal axis of the host vehicle can also be determined.
With the FMCW radar system the transmission frequency is varied linearly within the frequency
deviation, over the modulation period, the frequency curve of a transmit signal with three ramps.
In a static system where transmitter and object do not move, the frequency of the receive signal
lags behind the transmit signal. The difference between their frequencies is proportional to the
distance between transmitter and object.
Mixing transmits and receives signals results in a low-frequency intermediate frequency (IF).
The maximum frequency of the intermediate frequency is known as the beat frequency, If the
object moves relative to the transmitter, the frequency of the receive signal shifts due to the
Doppler Effect.
If the object approaches, the receive signal shifts to higher frequencies; if it moves further away,
to lower frequencies. If the distance is ignored, an approach at relative speed, Vrel, will result in
the receive signal, and consequently the constant intermediate frequency.
The superposition of the two cases in Figures B and C results in a receive signal where the
associated intermediate frequency contains both information on the distance and information on
the relative speed between transmitter and object.
The frequency curves for transmitter and object getting further apart at a relative speed, Vre The
intermediate frequency can be described using the FMCW radar equation (below) as a function
of distance, r, and relative speed. The sum describes the approach, the difference the distance
increase between transmitter and object. Where c = speed of light This is part 1 of a series.
22
6. Microcontroller (8051):-
WELCOME TO THE WORLD OF THE MICROCONTROLLERS.
Look around. Notice the smart “intelligent” systems? Be it the T.V, washing machines, video
games, telephones, automobiles, aero planes, power systems, or any application having a LED or
a LCD as a user interface, the control is likely to be in the hands of a micro controller!
Measure and control, that’s where the micro controller is at its best.
Micro controllers are here to stay. Going by the current trend, it is obvious that micro controllers
will be playing bigger and bigger roles in the different activities of our lives.
These embedded chips are very small, but are designed to replace components much bigger and
bulky In size. They process information very intelligently and efficiently. They sense the
environment around them. The signals they gather are tuned into digital data that streams
through tributaries of circuit lines at the speed of light. Inside the microprocessor collates and
calculators. The software has middling intelligence. Then in a split second, the processed streams
are shoved out.
23
What is the primary difference between a microprocessor
and a micro controller?
Unlike the microprocessor, the micro controller can be considered to be a true “Computer on a
chip”.
In addition to the various features like the ALU, PC, SP and registers found on a microprocessor,
the micro controller also incorporates features like the ROM, RAM, Ports, timers, clock circuits,
counters, reset functions etc.
While the microprocessor is more a general-purpose device, used for read, write and calculations
on data, the micro controller, in addition to the above functions also controls the environment.
The 8051:
The 8051 developed and launched in the early 80`s, is one of the most popular micro controller
in use today. It has a reasonably large amount of built in ROM and RAM. In addition it has the
ability to access external memory.
The generic term `8x51` is used to define the device. The value of x defining the kind of ROM,
i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM and x=9 indicates
EEPROM or Flash.
A note on ROM:
The early 8051, namely the 8031 was designed without any ROM. This device could run only
with external memory connected to it. Subsequent developments lead to the development of the
PROM or the programmable ROM. This type had the disadvantage of being highly
unreliable.The next in line, was the EPROM or Erasable Programmable ROM. These devices
used ultraviolet light erasable memory cells. Thus a program could be loaded, tested and erased
using ultra violet rays. A new program could then be loaded again.
24
An improved EPROM was the EEPROM or the electrically erasable PROM. This does not
require ultra violet rays, and memory can be cleared using circuits within the chip itself.
Finally there is the FLASH, which is an improvement over the EEPROM. While the terms
EEPROM and flash are sometimes used interchangeably, the difference lies in the fact that flash
erases the complete memory at one stroke, and not act on the individual cells. This results in
reducing the time for erasure.
Different microcontrollers in market.
PIC :
One of the famous microcontrollers used in the industries. It is based on RISC Architecture
which makes the microcontroller process faster than other microcontroller.
INTEL:
These are the first to manufacture microcontrollers. These are not as sophisticated other
microcontrollers but still the easiest one to learn.
ATMEL:
Atmel’s AVR microcontrollers are one of the most powerful in the embedded industry. This
is the only microcontroller having 1kb of ram even the entry stage. But it is unfortunate that in
India we are unable to find this kind of microcontroller.
25
Intel 8051
Intel 8051 is CISC architecture which is easy to program in assembly language and also has a
good support for High level languages.
The memory of the microcontroller can be extended up to 64k.
This microcontroller is one of the easiest microcontrollers to learn.
The 8051 microcontroller is in the field for more than 20 years. There are lots of books and study
materials are readily available for 8051.
Derivatives
The best thing done by Intel is to give the designs of the 8051 microcontroller to everyone. So it
is not the fact that Intel is the only manufacture for the 8051 there more than 20 manufactures,
with each of minimum 20 models. Literally there are hundreds of models of 8051
microcontroller available in market to choose. Some of the major manufactures of 8051 are
Atmel
Philips
Philips
The Philips‘s 8051 derivatives has more number of features than in any microcontroller.
The costs of the Philips microcontrollers are higher than the Atmel’s which makes us to choose
Atmel more often than Philips.
Dallas:
Dallas has made many revolutions in the semiconductor market. Dallas’s 8051 derivative is the
fastest one in the market. It works 3 times as fast as a 8051 can process. But we are unable to get
more in India.
26
Atmel:
These people were the one to master the flash devices. They are the cheapest microcontroller
available in the market. Atmel’s even introduced a 20pin variant of 8051 named 2051. The
Atmel’s 8051 derivatives can be got in India less than 70 rupees. There are lots of cheap
programmers available in India for Atmel. So it is always good for students to stick with 8051
when you learn a new microcontroller.
Architecture
Architecture is must to learn because before learning new machine it is necessary to learn the
capabilities of the machine. This is some thing like before learning about the car you cannot
become a good driver. The architecture of the 8051 is given below.
The 8051 doesn’t have any special feature than other microcontroller. The only feature is that it
is easy to learn. Architecture makes us to know about the hardware features of the
microcontroller. The features of the 8051 are
27
4K Bytes of Flash Memory
128 x 8-Bit Internal RAM
Fully Static Operation: 1 MHz to 24 MHz
32 Programmable I/O Lines
Two 16-Bit Timer/Counters
Six Interrupt Sources (5 Vectored)
Programmable Serial Channel
Low Power Idle and Power Down Modes
Let’s now move on to a practical example. We shall work on a simple practical application and
using the example as a base, shall explore the various features of the 8051 microcontroller.
Consider an electric circuit as follows,
The positive side (+ve) of the battery is connected to one side of a switch. The other side of the
switch is connected to a bulb or LED (Light Emitting Diode). The bulb is then connected to a
resistor, and the other end of the resistor is connected to the negative (-ve) side of the battery.
When the switch is closed or ‘switched on’ the bulb glows. When the switch is open or ‘switched
off’ the bulb goes off .If you are instructed to put the switch on and off every 30 seconds, how
would you do it? Obviously you would keep looking at your watch and every time the second
hand crosses 30 seconds you would keep turning the switch on and off.
Imagine if you had to do this action consistently for a full day. Do you think you would be able
to do it? Now if you had to do this for a month, a year??
No way, you would say!
The next step would be, then to make it automatic. This is where we use the Microcontroller.
But if the action has to take place every 30 seconds, how will the microcontroller keep track of
time?
28
Execution time
Look at the following instruction,
clr p1.0
This is an assembly language instruction. It means we are instructing the microcontroller to put a
value of ‘zero’ in bit zero of port one. This instruction is equivalent to telling the microcontroller
to switch on the bulb. The instruction then to instruct the microcontroller to switch off the bulb
is,
Set p1.0
This instructs the microcontroller to put a value of ‘one’ in bit zero of port one.
Don’t worry about what bit zero and port one means. We shall learn it in more detail as we
proceed.
There are a set of well defined instructions, which are used while communicating with the
microcontroller. Each of these instructions requires a standard number of cycles to execute. The
cycle could be one or more in number.
How is this time then calculated?
The speed with which a microcontroller executes instructions is determined by what is known as
the crystal speed. A crystal is a component connected externally to the microcontroller. The
crystal has different values, and some of the used values are 6MHZ, 10MHZ, and 11.059 MHz
etc.
Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per second.
The time is calculated using the formula.
No of cycles per second = Crystal frequency in HZ / 12.
For a 10MHZ crystal the number of cycles would be,
29
10,000,000/12=833333.33333 cycles.
This means that in one second, the microcontroller would execute 833333.33333 cycles.
Therefore for one cycle, what would be the time? Try it out.
The instruction clr p1.0 would use one cycle to execute. Similarly, the instruction setb p1.0 also
uses one cycle.
So go ahead and calculate what would be the number of cycles required to be executed to get a
time of 30 seconds!
Getting back to our bulb example, all we would need to do is to instruct the microcontroller to
carry out some instructions equivalent to a period of 30 seconds, like counting from zero
upwards, then switch on the bulb, carry out instructions equivalent to 30 seconds and switch off
the bulb.
Just put the whole thing in a loop, and you have a never ending on-off sequence.
Let us now have a look at the features of the 8051 core, keeping the above example as a
reference,
1. 8-bit CPU.( Consisting of the ‘A’ and ‘B’ registers)
Most of the transactions within the microcontroller are carried out through the ‘A’ register, also
known as the Accumulator. In addition all arithmetic functions are carried out generally in the
‘A’ register. There is another register known as the ‘B’ register, which is used exclusively for
multiplication and division.
Thus an 8-bit notation would indicate that the maximum value that can be input into these
registers is ‘11111111’. Puzzled?
30
The value is not decimal 111, 11,111! It represents a binary number, having an equivalent value
of ‘FF’ in Hexadecimal and a value of 255 in decimal.
We shall read in more detail on the different numbering systems namely the Binary and
Hexadecimal system in our next module.
2. 4K on-chip ROM
Once you have written out the instructions for the microcontroller, where do you put these
instructions?
Obviously you would like these instructions to be safe, and not get deleted or changed during
execution. Hence you would load it into the ‘ROM’
The size of the program you write is bound to vary depending on the application, and the number
of lines. The 8051 microcontroller gives you space to load up to 4K of program size into the
internal ROM. 4K, that’s all? Well just wait. You would be surprised at the amount of stuff you
can load in this 4K of space.
3. 128 bytes on-chip RAM
This is the space provided for executing the program in terms of moving data, storing data etc.