Escolar Documentos
Profissional Documentos
Cultura Documentos
ON
CELLPHONE OPERATED LAND ROVER
(Code: R-05B)
Submitted in partial fulfillment for award of degree of Bachelor of
Engineering (Electronics and Communication Branch)
Awarded by:
Maharishi Dayanand University
Rohtak
During Academic Session 2006-2010
Submitted by:
Chandra Kant Pandey, 6EC-31
Kamal Negi, 6EC-52
Rohit Kalra, 6EC-86
Arpit Kohli, 6EC-24
Under the guidance of
Ms. Meenakshi Bhat
Submitted to:
Dr. S.V.A.V. Prasad
(HOD)
Ms. Pragati Kapoor
(Project Coordinator)
Mr. Ajay Dagar
(Project Coordinator)
Department of Electronics and Communication Engineering
PROJECT REPORT
ON
CELLPHONE OPERATED LAND ROVER
(HOD)
(Project Coordinator)
(Project Coordinator)
P R O J E C T R E P O RT O N
C E L L P H O N E O P E R AT E D
L A N D R OV E R P R O G R E SS
R E P O RT
L I N G AYA S
UNIVERSITY
ABSTRACT
Conventionally, wireless-controlled robots use RF circuits, which have the drawbacks of limited
working range, limited frequency range and limited control. Use of a mobile phone for robotic
control can overcome these limitations. It provides the advantages of robust control, working
range as large as the coverage area of the service provider, no interference with other controllers
and up to twelve controls.
In this project, the robot is so controlled by a mobile phone that makes a call to the mobile
phone attached to the robot. In the course of a call, if any button is pressed, a tone corresponding
to the button pressed is heard at the other end of the call. This tone is called dual tone multiple
frequency (DTMF) tone. The robot perceives this DTMF tone with the help of the phone
stacked in the robot.
The receiver tone is processed by 8051microcontroller with the help of a DTMF decoder
CM8870. The decoder decodes the DTMF tone into its equivalent binary digit and this binary
number is sent to the microcontroller. The microcontroller is preprogrammed to take a decision
for any given input and outputs its decision to motor drivers in order to drive the motors for
forward or backward motion or a turn.
The mobile that makes a call to the mobile phone stacked in the robot acts as a remote. So this
simple robotic project does not require the construction of receiver and transmitter units.
ABOUT PROJECT
In this project, the robot is controlled by a mobile phone that makes a
call to the mobile phone attached to the robot
Conventionally, wireless-controlled robots use RF circuits, which have
the drawbacks of limited working range, limited frequency range and
limited control.
Use of a mobile phone for robotic control can overcome these
limitations.
It provides the advantages of robust control, working range as large as
the coverage area of the service provider, no interference with other
controllers and up to twelve controls.
PROJECT DISCRPTION
BASIC OPERATION
In order to control the robot, you need to make a call to the cell phone attached to the robot
(through headphone) from any phone, which sends DTMF tunes on pressing the numeric
buttons. The cell phone in the robot is kept in 'auto answer' mode.( if the mobile does not have
the auto answering facility ,receive the call by 'OK' key on the rover connected mobile and then
made it in hands-free mode.) so after a ring, the cell phone accepts the call. Now you may press
any button on your mobile to perform actions as listed in the table. The DTMF tones thus
produced are received by the cell phone in the robot. These tones are fed to the circuit by headset
of the cell phone. The MT8870 decodes the received tone and sends the equivalent binary
number to the microcontroller. According to the program in the microcontroller, the robot starts
moving. When you press key '2' (binary equivalent 00000010) on your mobile phone, the
microcontroller outputs '10001001'binary equivalent. Port pins PD0, PD3 and PD7 are high. The
high output at PD7 of the microcontroller drives the motor driver (L293D). port pins PD0 and
PD3 drive motors M1 and M2 in forward direction( as per table ).Similarly, motors M1 and M2
move for left turn, right turn, backward motion and stop condition as per table.
COMPONENTS USED
1. Semiconductors
IC1-MT8870 DTMF decoder
IC2-ATMEL89S52
IC3-L293D motor drive
7805 regulator ic
3. Capacitors:
C1-0.47uF ceramic disk
C2, C3, C5, C6-15pF ceramic disk
C4, C10-0.1uF ceramic disk
C7, C9-10uF ceramic disk
C8-330uF ceramic disk
4. Miscellaneous:
Xtal1-3.57MHz crystal
Xtal2-16MHz crystal
S1, S2, S3-push to on switch
M1, M2-6V, 50-rpm geared DC motor
Batt-6V, 4.5Ah battery
Batt-9V (6FF2) battery
2 pin male and female connector
DTMF DECODER
The M-8870 is a full DTMF Receiver that integrates both band split filter and decoder functions
into a single 18-pin DIP or SOIC package. Manufactured using CMOS process technology, the
M-8870 offers low power consumption (35 mW max) and precise data handling. Its filter section
uses switched capacitor technology for both the high and low group filters and for dial tone
rejection. Its decoder uses digital counting techniques to detect and decode all 16 DTMF tone
pairs into a 4-bit code. External component count is minimized by provision of an on-chip
differential input amplifier, clock generator, and latched tri-state interface bus. Minimal external
components required include a low-cost 3.579545 MHz color burst crystal, a timing resistor, and
a timing capacitor.
The M-8870-02 provides a power-down option which, when enabled, drops consumption to
less than 0.5 mW. The M-8870-02 can also inhibit the decoding of fourth column digits
CIRCUIT DIAGRAM
Circuit making
Compiling in Keil
uvision 3
1. Open keil
4. Write program
5. Compile
6. Simulate
Application
AT89S52
8-bit Microcontroller with 8K Bytes In-System
Programmable Flash
Features
Compatible
Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of
in-system programmable Flash memory. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry- standard 80C51 instruction
set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or
by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with insystem programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many embedded
control applications. The AT89S52 provides the following standard features: 8K bytes of Flash,
256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters,
a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode stops the
CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue
functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling
all other chip functions until the next interrupt or hardware reset.
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. The L293D is assembled
in a 16 lead plastic packaage which has 4 center pins connected together and used for heatsinking
The L293DD is assembled in a 20 lead surface mount which has 8 center pins connected together
and used for heatsinking
Specifications
HARDWARE PART
PHYSICAL MODEL
1. We have collected some hardware needed for the project which include
Two geared motors of 6v/50rpm (Why only geared motor? because simple
motors have very high rpm which can cause trouble in rover movement.
Thus we decrease the rpm of motor by using two gears, small one
connected to axle of motor and bigger one connected to small one and
drives the wheels with reduced rpm of almost 50rpm motor is of 6V)
Two main rear wheels (diameter 74mm, thickness 13mm/plastic wheels )
One multidirectional wheel(made of steel with a ball in bottom giving free
motion to be fitted in front of rover)
One battery of 6v/4.5Ah/1.35A
One solid board for base
Two tin clamps for holding motor on board
Some screws and bolts
Wires
(a)motors
(b)wheels
(d)clamps
2.1 Introduction
The term microcomputer is used to describe a system that includes at minimum a
microprocessor, program memory, data memory, and an input-output (I/O) device. Some
microcomputer systems include additional components such as timers, counters, and analog-todigital converters. Thus, a microcomputer system can be anything from a large computer having
hard disks, floppy disks, and printers to a single-chip embedded controller.
We are going to consider only the type of microcomputers that consist of a single silicon chip.
Such microcomputer systems are also called microcontrollers, and they are used in many
household goods such as microwave ovens, TV remote control units, cookers, hi-fi equipment,
CD players, personal computers, and refrigerators. Many different microcontrollers are available
on the market. In this book we shall be looking at programming and system design for the 8051
series of microcontrollers .
The input components would consist of digital devices such as, switches, push buttons, pressure
mats, float switches, keypads, radio receivers etc. and analogue sensors such as light dependent
resistors, thermistors, gas sensors, pressure sensors, etc.
The control unit is of course the microcontroller. The microcontroller will monitor the inputs and
as a result the program would turn outputs on and off. The microcontroller stores the program in
its memory, and executes the instructions under the control of the clock circuit.
The output devices would be made up from LEDs, buzzers, motors, alpha numeric displays,
radio transmitters, 7 segment displays, heaters, fans etc.
The most obvious choice then for the microcontroller is how many digital inputs, analogue inputs
and outputs does the system require. This would then specify the minimum number of inputs and
outputs (I/O) that the microcontroller must have. If analogue inputs are used then the microcontroller
must have an Analogue to Digital (A/D) module inside.
The next consideration would be what size of program memory storage is required. This should not
be too much of a problem when starting out, as most programs would be relatively small.
The clock frequency determines the speed at which the instructions are executed. This is important if
any lengthy calculations are being undertaken. The higher the clock frequency the quicker the micro
will finish one task and start another.
Other considerations are the number of interrupts and timer circuits required how much data
EEPROM if any is needed.
Microcontrollers have traditionally been programmed using the assembly language of the target
device. Although the assembly language is fast, it has several disadvantages. An assembly program
makes learning and maintaining a program written using the assembly language difficult. Also,
microcontrollers manufactured by different firms have different assembly languages, so the user must
learn a new language with every new microcontroller he uses.
Microcontrollers can also be programmed using a high-level language, such as BASIC, PASCAL, or
C. High-level languages are much easier to learn than assembly languages. They also facilitate the
development of large and complex programs.
A microcontroller is a very powerful tool that allows a designer to create sophisticated input-output
data manipulation under program control. Microcontrollers are classified by the number of bits they
process. 12
Microcontrollers with 8 bits are the most popular and are used in most microcontroller-based
applications. Microcontrollers with 16 and 32 bits are much more powerful, but are usually more
expensive and not required in most small- or medium-size general purpose applications that call for
microcontrollers.
Instruction Decoder: is a part of electronics which recognizes program instructions and runs
other circuits on the basis of that. The instruction set which is different for each
microcontroller family expresses the abilities of this circuit.
Arithmetical Logical Unit (ALU): performs all mathematical and logical operations upon
data.
Accumulator: is a SFR closely related to the operation of ALU. It is a kind of working desk
used for storing all data upon which some operation should be performed (addition,
shift/move etc.). It also stores results ready for use in further processing.
Status Register (PSW): One of SFRs is close to the accumulator. It shows at any moment
the status of a number stored in the accumulator (number is greater or less than zero etc.)..
2.4.2.1 RAM
RAM, random access memory, is a general purpose memory that usually stores the user data in a
program. RAM memory is volatile in the sense that it cannot retain data in the absence of power (i.e.,
data is lost after the power is turned off). Most microcontrollers have some amount of internal RAM,
256 bytes being a common amount, although some microcontrollers have more, some less. The
AT89C52 microcontroller, for example, has 256 bytes of RAM. Memory can usually be extended by
adding external memory chips.
2.4.2.2 ROM
ROM, read only memory, usually holds program or fixed user data. ROM is nonvolatile. If power is
removed from ROM and then reapplied, the original data will still be there. ROM memory is
programmed during the manufacturing process, and the user cannot change its contents. ROM
memory is only useful if you have developed a program and wish to create several thousand copies
of it.
2.4.2.3 PROM
PROM, programmable read only memory, is a type of ROM that can be programmed in the field,
often by the end user, using a device called a PROM programmer. Once a PROM has been
programmed, its contents cannot be changed. PROMs are usually used in low production applications
where only a few such memories are required.
2.4.2.4 EPROM
EPROM, erasable programmable read only memory, is similar to ROM, but EPROM can be
programmed using a suitable programming device. An EPROM memory has a small clear-glass
window on top of the chip where the data can be erased under strong ultraviolet light. Once the
memory is programmed, the window can be covered with dark tape to prevent accidental erasure of
the data. An EPROM memory must be erased before it can be reprogrammed. Many developmental
versions of microcontrollers are manufactured with EPROM memories where the user program can
be stored. These memories are erased and reprogrammed until the user is satisfied with the program.
Some versions of EPROMs, known as OTP (one time programmable), can be programmed using a
suitable programmer device but cannot be erased. OTP memories cost much less than EPROMs. OTP
is useful after a project has been developed completely and many copies of the program memory
must be made.
2.4.2.5 EEPROM
EEPROM, electrically erasable programmable read only memory, is a nonvolatile memory that can
be erased and reprogrammed using a suitable programming device. EEPROMs are used to save
configuration information, maximum and minimum values, identification data, etc. Some
microcontrollers have built-in EEPROM memories. For instance, the PIC18F452 contains a 256-byte
EEPROM memory where each byte can be programmed and erased directly by applications software.
EEPROM memories are usually very slow. An EEPROM chip is much costlier than an EPROM chip.
Most microcontrollers operate with the standard logic voltage of + 5V. Some
microcontrollers can operate at as low as + 2.7V, and some will tolerate + 6V without any
problem. The manufacturers data sheet will have information about the allowed limits of
the power supply voltage. At89c52 microcontrollers can operate with a power supply of +
2V to 5.5V. Usually, a voltage regulator circuit is used to obtain the required power supply
voltage when the device is operated from a mains adapter or batteries. For example, a 5V
regulator is required if the microcontroller is operated from a 5V supply using a 9V battery.
2.5.3 Timers
Timers are important parts of any microcontroller. A timer is basically a counter which is driven
from either an external clock pulse or the microcontrollers internal oscillator. A timer can be 8
bits or 16 bits wide. Data can be loaded into a timer under program control, and the timer can be
stopped or started by program control. Most timers can be configured to generate an interrupt
when they reach a certain count (usually when they overflow). The user program can use an
interrupt to carry out accurate timing-related operations inside the microcontroller.
Microcontrollers in the 8051 series have at least three timers. For example, the AT89C52
microcontroller has three built-in timers. Some microcontrollers offer capture and compare
facilities, where a timer value can be read when an external event occurs, or the timer value can
be compared to a preset value, and an interrupt is generated when this value is reached.
2.5.5 Interrupts
Interrupts are an important concept in microcontrollers. An interrupt causes the microcontroller to
respond to external and internal (e.g., a timer) events very quickly. When an interrupt occurs, the
microcontroller leaves its normal flow of program execution and jumps to a special part of the
program known as the interrupt service routine (ISR). The program code inside the ISR is executed,
and upon return from the ISR the program resumes its normal flow of execution.
The ISR starts from a fixed address of the program memory sometimes known as the interrupt vector
address. Some microcontrollers with multi-interrupt features have just one interrupt vector address,
while others have unique interrupt vector addresses, one for each interrupt source. Interrupts can be
nested such that a new interrupt can suspend the execution of another interrupt. Another important
feature of multi-interrupt capability is that different interrupt sources can be assigned different levels
of priority. The at89c52 microcontroller has 8 interrupts source.
started by the user program and may take several hundred microseconds to complete. A/D
converters usually generate interrupts when a conversion is complete so the user program
can read the converted data quickly. A/D converters are especially useful in control and
monitoring applications, since most sensors (e.g., temperature sensors, pressure sensors,
force sensors, etc.) produce analog output voltages.
necessary to apply a logic one (1) to appropriate port. In this case, voltage level on
appropriate pin will be 5V (as is the case with any TTL input.
Port 0
The P0 port is characterized by two functions. If external memory is used then the lower address
byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are configured as
inputs/outputs.
The other function is expressed when it is configured as an output. Unlike other ports consisting
of pins with built-in pull-up resistor connected by its end to 5 V power supply, pins of this port
have this resistor left out. This apparently small difference has its consequences:
If any pin of this port is configured as an input then it acts as if it floats. Such an input has
unlimited input resistance and in determined potential.
When the pin is configured as an output, it acts as an open drain. By applying logic 0 to a port
bit, the appropriate pin will be connected to ground (0V). By applying logic 1, the external
output will keep on floating. In order to apply logic 1 (5V) on this output pin, it is necessary to
built in an external pull-up resistor.
Port 1
P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but
can be configured as general I/O only. It has a pull-up resistor built-in and is completely
compatible with TTL circuits.
Port 2
P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses
intended for external memory chip. This time it is about the higher address byte with addresses
A8-A15. When no memory is added, this port can be used as a general input/output port showing
features similar to P1.
Port 3
All port pins can be used as general I/O, but they also have an alternative function. In order to
use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3
register. In terms of hardware, this port is similar to P0, with the difference that its pins have a
pull-up resistor built-in.
has only 21 such registers. Rest of locations are intentionally left unoccupied in order to enable
the manufacturers to further develop microcontrollers keeping them compatible with the
previous versions. It also enables programs written a long time ago for microcontrollers which
are out of production now to be used today.
A Register (Accumulator)
A register is a general-purpose register used for storing intermediate results obtained during
operation. Prior to executing an instruction upon any number or operand it is necessary to store it
in the accumulator first. All results obtained from arithmetical operations performed by the ALU
are stored in the accumulator. Data to be moved from one register to another must go through the
accumulator. In other words, the A register is the most commonly used register and it is
impossible to imagine a microcontroller without it. More than half instructions used by the 8051
microcontroller use somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in the A and B registers.
All other instructions in the program can use this register as a spare accumulator (A).
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even though they are
not true SFRs, they deserve to be discussed here because of their purpose. They occupy 4 banks
within RAM. Similar to the accumulator, they are used for temporary storing variables and
intermediate results during operation. Which one of these banks is to be active depends on two
bits of the PSW Register. Active bank is a bank the registers of which are currently used.
The following example best illustrates the purpose of these registers. Suppose it is necessary to
perform some arithmetical operations upon numbers previously stored in the R registers:
(R1+R2) - (R3+R4). Obviously, a register for temporary storing results of addition is needed.
This is how it looks in the program:
PSW register is one of the most important SFRs. It contains several status bits that reflect the
current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register
bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit:
If a number stored in the accumulator is even then this bit will be automatically set (1),
otherwise it will be cleared (0). It is mainly used during data transmit and receive via serial
communication.
Bit 1:
occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one
register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0).
RS0, RS1 - Register bank select bits:
These two bits are used to select one of four register banks of RAM. By setting and clearing
these bits, registers R0-R7 are stored in one of four banks of RAM.
F0 - Flag 0:
CY - Carry Flag:
is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions.
DPTR register is not a true one because it doesn't physically exist. It consists of two separate
registers: DPH (Data Pointer High) and (Data Pointer Low). For this reason it may be treated as a
16-bit register or as two independent 8-bit registers. Their 16 bits are primarily used for external
memory addressing. Besides, the DPTR Register is usually used for storing data and
intermediate results.
A value stored in the Stack Pointer points to the first free stack address and permits stack
availability. Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops
decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack Pointer,
which means that the space of RAM reserved for the stack starts at this location. If another value
is written to this register, the entire Stack is moved to the new memory location.
If neither external memory nor serial communication system are used then 4 ports with in total of
32 input/output pins are available for connection to peripheral environment. Each bit within these
ports affects the state and performance of appropriate pin of the microcontroller. Thus, bit logic
state is reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on a pin
reflects the state of appropriate port bit.
As mentioned, port bit state affects performance of port pins, i.e. whether they will be configured
as inputs or outputs. If a bit is cleared (0), the appropriate pin will be configured as an output,
while if it is set (1), the appropriate pin will be configured as an input. Upon reset and power-on,
all port bits are set (1), which means that all appropriate pins will be configured as inputs.
2.6.7 Counters and Timers
As you already know, the microcontroller oscillator uses quartz crystal for its operation. As the
frequency of this oscillator is precisely defined and very stable, pulses it generates are always of
the same width, which makes them ideal for time measurement. Such crystals are also used in
quartz watches. In order to measure time between two events it is sufficient to count up pulses
coming from this oscillator. That is exactly what the timer does. If the timer is properly
programmed, the value stored in its register will be incremented (or decremented) with each
coming pulse, i.e. once per each machine cycle. A single machine-cycle instruction lasts for 12
quartz oscillator periods, which means that by embedding quartz with oscillator frequency of
12MHz, a number stored in the timer register will be changed million times per second, i.e. each
microsecond.
The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest, their
main purpose is to measure time and count external events. Besides, they can be used for
generating clock pulses to be used in serial communication, so called Baud Rate.
Timer T0
As seen in figure below, the timer T0 consists of two registers TH0 and TL0 representing a low
and a high byte of one 16-digit binary number.
Accordingly, if the content of the timer T0 is equal to 0 (T0=0) then both registers it consists of
will contain 0. If the timer contains for example number 1000 (decimal), then the TH0 register
(high byte) will contain the number 3, while the TL0 register (low byte) will contain decimal
number 232.
Since the timer T0 is virtually 16-bit register, the largest value it can store is 65 535. In case of
exceeding this value, the timer will be automatically cleared and counting starts from 0. This
condition is called an overflow. Two registers TMOD and TCON are closely connected to this
timer and control its operation.
The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure
below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to
the timer 1. There are 4 operational modes and each of them is described herein.
T1M0
MODE
DESCRIPTION
13-bit timer
16-bit timer
8-bit auto-reload
Split mode
GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2):
T0M0
MODE
DESCRIPTION
13-bit timer
16-bit timer
8-bit auto-reload
Split mode
1 - Timer 1 is enabled.
0 - Timer 1 is disabled.
1 - Timer 0 is enabled.
0 - Timer 0 is disabled.
Referring to figure above, the timer 0 operates in mode 1 and counts pulses generated by internal clock
the frequency of which is equal to 1/12 the quartz frequency.
Turn on the timer:
The TR0 bit is set and the timer starts operation. If the quartz crystal with frequency of 12MHz is
embedded then its contents will be incremented every microsecond. After 65.536 microseconds, the both
registers the timer consists of will be loaded. The microcontroller automatically clears them and the timer
keeps on repeating procedure from the beginning until the TR0 bit value is logic zero (0).
IE Register (Interrupt
Enable)
Interrupt Priorities
It is not possible to forseen when an interrupt request will arrive. If several interrupts are enabled, it may
happen that while one of them is in progress, another one is requested. In order that the microcontroller
knows whether to continue operation or meet a new interrupt request, there is a priority list instructing it
what to do.
The priority list offers 3 levels of interrupt priority:
1. Reset! The apsolute master. When a reset request arrives, everything is stopped and the
microcontroller restarts.
2. Interrupt priority 1 can be disabled by Reset only.
3. Interrupt priority 0 can be disabled by both Reset and interrupt priority 1.
The IP Register (Interrupt Priority Register) specifies which one of existing interrupt sources have higher
and which one has lower priority. Interrupt priority is usually specified at the beginning of the program.
According to that, there are several possibilities:
If two interrupt requests, at different priority levels, arrive at the same time then the
higher priority interrupt is serviced first.
If the both interrupt requests, at the same priority level, occur one after another, the one
which came later has to wait until routine being in progress ends.
If two interrupt requests of equal priority arrive at the same time then the interrupt to be
serviced is selected according to the following priority list:
1. External interrupt INT0
2. Timer 0 interrupt
3. External Interrupt INT1
4. Timer 1 interrupt
5. Serial Communication Interrupt
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Priority 0
Priority 1
Handling Interrupt
When an interrupt request arrives the following occurs:
VECTOR (ADDRESS)
IE0
3h
TF0
Bh
TF1
1B h
RI, TI
23 h
From the moment an interrupt is enabled, the microcontroller is on alert all the time. When an interrupt
request arrives, the program execution is stopped, electronics recognizes the source and the program
jumps to the appropriate address (see the table above). This address usually stores a jump instruction
specifying the start of appropriate subroutine. Upon its execution, the program resumes operation from
where it left off.
Arithmetic Instructions
Branch Instructions
Logic Instructions
Bit-oriented Instructions
The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copy,
addition, logic operation etc.). Mnemonics are abbreviations of the name of operation being executed. For
example:
LJMP LAB5 - Means: Long Jump LAB5 (long jump to the address marked as LAB5);
JNZ LOOP - Means: Jump if Not Zero LOOP (if the number in the accumulator is not 0,
jump to the address marked as LOOP);
The other part of instruction, called OPERAND is separated from mnemonic by at least one whitespace
and defines data being processed by instructions. Some of the instructions have no operand, while some
of them have one, two or three. If there is more than one operand in an instruction, they are separated by
a comma. For example:
JZ TEMP - if the number in the accumulator is not 0, jump to the address marked as
TEMP;
CJNE A,#20,LOOP - compare accumulator with 20. If they are not equal, jump to the
address marked as LOOP;
Arithmetic instructions
Arithmetic instructions perform several basic operations such as addition, subtraction, division,
multiplication etc. After execution, the result is stored in the first operand. For example:
ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator.
ARITHMETIC INSTRUCTIONS
Mnemonic
Description
Byte
Cycle
ADD A,Rn
ADD A,direct
ADD A,@Ri
ADD A,#data
ADDC A,Rn
ADDC A,direct
ADDC A,@Ri
ADDC A,#data
SUBB A,Rn
SUBB A,direct
SUBB A,@Ri
SUBB A,#data
INC A
INC Rn
INC Rx
INC @Ri
DEC A
DEC Rn
DEC Rx
DEC @Ri
INC DPTR
MUL AB
Multiplies A and B
DIV AB
Divides A by B
DA A
Branch Instructions
There are two kinds of branch instructions:
Unconditional jump instructions: upon their execution a jump to a new location from where the program
continues execution is executed.
Conditional jump instructions: a jump to a new program location is executed only if a specified condition is
met. Otherwise, the program normally proceeds with the next instruction.
BRANCH INSTRUCTIONS
Mnemonic
Description
Byte
Cyc
ACALL addr11
LCALL addr16
RET
RETI
AJMP addr11
Absolute jump
LJMP addr16
Long jump
SJMP rel
Short jump (from 128 to +127 locations relative to the following instruction)
JC rel
JNC rel
JB bit,rel
JBC bit,rel
JMP @A+DPTR
JZ rel
JNZ rel
CJNE A,direct,rel
Compares direct byte to the accumulator and jumps if not equal. Short jump.
CJNE A,#data,rel
Compares immediate data to the accumulator and jumps if not equal. Short jump.
CJNE Rn,#data,rel
Compares immediate data to the register and jumps if not equal. Short jump.
CJNE @Ri,#data,rel
Compares immediate data to indirect register and jumps if not equal. Short jump.
DJNZ Rn,rel
DJNZ Rx,rel
NOP
No operation
Description
Byte
Cyc
MOV A,Rn
MOV A,direct
MOV A,@Ri
MOV A,#data
MOV Rn,A
MOV Rn,direct
MOV Rn,#data
MOV direct,A
MOV direct,Rn
MOV direct,direct
MOV direct,@Ri
MOV direct,#data
MOV @Ri,A
MOV @Ri,direct
MOV @Ri,#data
MOV DPTR,#data
MOVC A,@A+DPTR
Moves the code byte relative to the DPTR to the accumulator (address=A+DPTR)
MOVC A,@A+PC
MOVX A,@Ri
3-10
MOVX A,@DPTR
3-10
MOVX @Ri,A
4-11
MOVX @DPTR,A
4-11
PUSH direct
POP direct
XCH A,Rn
XCH A,direct
XCH A,@Ri
XCHD A,@Ri
Logic Instructions
Logic instructions perform logic operations upon corresponding bits of two registers. After execution, the
result is stored in the first operand.
LOGIC INSTRUCTIONS
Mnemonic
Description
Byte
Cycle
ANL A,Rn
ANL A,direct
ANL A,@Ri
ANL A,#data
ANL direct,A
ANL direct,#data
ORL A,Rn
OR register to accumulator
ORL A,direct
ORL A,@Ri
ORL direct,A
ORL direct,#data
XRL A,Rn
XRL A,direct
XRL A,@Ri
XRL A,#data
XRL direct,A
XORL direct,#data
CLR A
CPL A
SWAP A
RL A
RLC A
RR A
RRC A
Bit-oriented Instructions
Similar to logic instructions, bit-oriented instructions perform logic operations. The difference is that these
are performed upon single bits.
BIT-ORIENTED INSTRUCTIONS
Mnemonic
Description
Byte
Cycle
CLR C
CLR bit
SETB C
SETB bit
CPL C
CPL bit
ANL C,bit
ANL C,/bit
ORL C,bit
ORL C,/bit
MOV C,bit
MOV bit,C
A - accumulator;
Rn - is one of working registers (R0-R7) in the currently active RAM memory bank;
Direct - is any 8-bit address register of RAM. It can be any general-purpose register or a
SFR (I/O port, control register etc.);
addr11 - is an 11-bit address. May be within the same 2KB page of program memory as
the first byte of the following instruction;
rel - is the address of a close memory location (from -128 to +127 relative to the first
byte of the following instruction). On the basis of it, assembler computes the value to add
or subtract from the number currently stored in the program counter;
VOLTAG REGULATORS
Voltage regulators produce fixed DC output voltage from variable DC (a small amount of
AC on it). Normally we get fixed output by connecting the voltage regulator at the output
of the filtered DC (see in above diagram). It can also used in circuits to get a low DC
voltage from a high DC voltage (for example we use 7805 to get 5V from 12V).
There are two types of voltage regulators
1. fixed voltage regulators (78xx, 79xx)
2. Variable voltage regulators (LM317)
In fixed voltage regulators there is another classification
1. +ve voltage regulators
2. -ve voltage regulators
POSITIVE VOLTAGE REGULATORS
This include 78xx voltage regulators. The most commonly used ones are 7805 and 7812.
7805 gives fixed 5V DC voltage if input voltage is in (7.5V,20V). You may sometimes
have questions like, what happens if input voltage is <7.5 V or some 3V, the answer is
that regulation won't be proper. Suppose if input is 6V then output may be 5V or 4.8V,
but there are some parameters for the voltage regulators like maximum output current
capability, line regulation etc.. , that parameters won't be proper. When I applied 3.55V
input, i got around 3.5V. Remember that electronics components should be used in the
proper voltage and current ratings as specified in datasheet. You can work without
following it, but you won't be able to get some parameters of the component. Get
datasheet from google by searching '7805 datasheet' or from www.alldatasheet.com
Next task is to identify the leads of the 7805. So first u have to keep the lead downward
and the writing to your side,see the figure below. You can see the heat sink above the
voltage regulator.(1-input,2-gnd,3-output)
This is the same way of lead identification for all 3 terminal IC's (for eg.
Power transistor).
The above diagram shows how to use 7805 voltage regulator. In this you can see that
coupling capacitors are used for good regulation. But there is no need for it in normal
case ( I never used these capacitors). But if you are using 7805 in analog circuit you
should use capacitor, otherwise the noise in the output voltage will be high. The mainly
available 78xx IC's are 7805, 7809, 7812, 7815, 7824.
Most commonly variable voltage regulator is LM317 although other variable voltage
regulators are available. The advantage of variable voltage regulator is that you can get a
variable voltage supply by just varying the resistance only.
http://focus.ti.com/docs/prod/folders/print/lm317.html
http://www.national.com/pf/LM/LM317.html
http://www.electronics-lab.com/articles/LM317/
From the above the equation you can see that output voltage is proportional to R1 and
R2. But in the above equation we can neglect I adj. So Vout=1.25(1+R2/R1). If you put
R1=R2=1Kohm Vout=2.5V. LM317 can be used to drive motor because it can handle
output current up to 1.5A. In some low power devices like image sensor or USB we
require 3.3V, in that circuit we use LM317.In a line follower we introduce some speed
variations for motor for different bendings, you can do it by either using PWM or using
the above circuit.
NOTE:
Remember about the input voltage limitations.
Remember about the heat sink of the voltage regulators before touching the voltage
regulator IC because it will be in the heated state normally. Your hand will get burned
(not big burn,some small) if we touch the heat sink of the voltage regulator. So first touch
the heat sink gently and confirm it is not heated, and then only remove the IC from the
breadboard. If you are driving high power circuits and motors from the output of the
voltage regulator screw an external heat sink to the voltage regulator. Size, of the heat
sink depends on the output power driving
RESISTOR
Now let's see how you can measure the resistance of a resistor. This is
done by color coding over the resistor or you can multimeter to
measure
resistance. As a beginner you should use color coding. See the
following
diagrams carefully, you can see that 4-band code, 5--band code and 6-band code( see next diagram). But we mainly get resistors of 4-band
code.
You can get a 1/4W resistor for Ps.20 irrespective of the value of its
resistance. Due to the aging and other temperature effects, value of a
Remember that all the values of fixed resistances are not available.
Suppose if you want a 2Kohm resistor in your circuit, you can use a
variable resistor(potentiometer) or two 1Kohm resistor in series. Only
the
following resistances are available.