Mcu Mobile Control
Mcu Mobile Control
Mcu Mobile Control
THROUGH
DTMF
[1]
CHAPTER 1.Introduction
What can be automated?
Earlier, we are looking into the face of future when we talked about automated
devices, which could do anything on instigation of a controller, but today it
has become a reality.
1. An automated device can replace good amount of human working force, moreover
humans are more prone to errors and in intensive conditions the probability of error
increases. Whereas an automated device can work with diligence, versatility and with
almost zero error.
2. This is why this project looks into construction and implementation of a system
involving hardware to control a variety of electrical and electronics instruments.
phone
keyboard for on/off the switches as per requirement. There is total 10 operations are
[2]
available. When the unit is on then circuit provide a reverse beep sound as a
acknowledgement. This beep sound is different in on and off cases. In the on
operation circuit feedback a two sound and in the off option circuit provide a single
beep sound.
[3]
DTMF DECODER
2.
MICROCONTROLLER
3.
EXCESS CON
4.
TROL CIRCUIT
5.
DTMF DECODER.
Our project is based on the dtmf signaling logic. When we press any digit from any
phone then particular frequency is generated in the tone form. These frequencys are
DTMF frequency. We receive this frequency in the form of sound at the receiver
phone. At the receiver end we decode this type of frequency
handsfree enhancement setting option. In every phone there is a option of auto answer
mode. On this mode phone is
Automatic transfer into answering mode after few bells. When the phone is automatic
on after few bell then if press any key from transmitter then same key sound is
available on the receiver end. We decode this sound with the help of the handsfree kit.
Output of handsfree kit is further connected to the DTMF decoder circuit
In DTMF decoder circuit we use 8870 IC. IC . 8870 converts the DTMF tones in
to corresponding binary outputs.
DTMF SIGNALLING.
tones rather than make/break pulse are used fro dialing, each dialed digit is uniquely
represented by a pair of sine waves tones. These tones ( one from low group for row
and another from high group fro column) are sent to the exchange when a digit is
dialed by pushing the key, these tone lies within the speech band of 300 to 3400 hz,
and are chosen so as to minimize the possibility of any valid frequency pair existing
in normal speech simultaneously. Actually, this minimisator is made possible by
forming pairs with one tone from the higher group and the other from the lower of
frequencies. A valid dtmf signal is the sum of two tones, one from a lower group
( 697-940 Hz) and the other from a a higher group ( 1209-1663 Hz). Each group
contains four individual tones. This scheme allows 10 unique combinations. Ten of
these code represent digits 1 through 9 and 0. . tones in DTMF dialing are so chose
[4]
that none of the tones is harmonic of are other tone. Therefore is no change of
distortion caused by harmonics. Each tone is sent as along as the key remains pressed.
The dtmf signal contains only one component from each of the high and low group.
This significaly simplifies decoding because the composite dtmf signal may be
separated with band pass filters into single frequency components, each of which may
be handled individually.
MT8870 OUTPUT TRUTH TABLE.
F low
F high
KEY
BCD
697
1209
0001
697
1336
0010
697
1477
0011
770
1209
0100
770
1336
0101
770
1477
0110
852
1209
0111
852
1336
1000
852
1477
1001
941
1209
1010
[5]
[6]
In this section we use two ic one is 74154 and second is IC 4017 . Both IC generate a
combination sequence by which we enable the micro-controller.
When we want to switch on the base unit by outer phone then phone is automatic on
after few bells, this is achive by another circuit. But after few bells when phone is on
and unit require a code of 8 DIGITS numbers. When we press a proper code , then
only micrcontroller allow us to switch on the circuit.
First IC of this section is IC 74154. IC 74154 is A bcd to decimal decoder. 74154 is
active low ic. Pin no 20,21,22,23 is connected to dtmf decoder ic.
Pin no 18 and 19 of this IC is connected to the collector of one NPN transistor Base of
the NPN transistor is connected to the pin no 15 of the ic 8870. When DTMF decoder
decode the signal at that time pin no 15 is on for a time and acknowledge the signal.
This signal is fed to the base of NPN transistor through 1 k ohm resistor. When this
signal is coming then 74154 is on and gives a output. Pin no 18 and 19 of the 74154 is
[7]
the enable pin of the ic. On this pin we provide a active low signal for activation If
we press the proper code in steps then at every digit of code 74154 is on and gives the
corresponding output as per the digit. Output of the ic 74154 is connected to the pnp
transistor base point through 10 k ohm resistor. Emitter of the all pnp transistor is
connected output of the decade counter circuit. Here we use ic 4017 as a decade
counter circuit. Pin no 16 is the positive supply pin and pin no 8 is the negative pin.
Pin no 14 of the ic is clock input of the ic.. On starting mode when is in on reset
mode then its start from the zero point.. O means first output is available on the pin no
3. Its means pin no 3 is positive in first output. Now ic 4017 receive a clock pulse on
pin no 14 then counter shifts its output from pin no 3 to nest output not 1 , pin no 2.
As we press the proper code then ic 74154 gives a output and this output is available
on the output pin, with the help of this output pnp transistor is on and positive output
is available on the collector point of the pnp transistor. All the pnp transistor collector
point is connected together is and reconnected to the clock input of the ic 4017
through rc network to another npn transistor. By this npn transistor we give a clock
pulse to the pin no 14 of the ic 4017. As the counter move after incoming clock pulse
then last output is available on the pin no 9. As the last output is available on the pin
no 9. After getting a voltage on the pin no 9 we switch on the next pair of npn
transistor. Output of first npn transistor is on collector is connected to the port p3.4 to
give a acknowledge signal that code lock is loaded successfully. Output of the this
npn transistor is again connected to the connected to the base of next npn transistor.
Collector of this npn transistor disable the pin no 18 of the ic to receive any further
code input of the signal
Output o ic 4017 ( with transistor circuit) not only provide a password ok signal to the
controller but at the same time switch off the ic 74154 to get another signal for
password.
Once the password section is ok then Microcontroller gets a signal and provide a
sound feedback in five beeps.
After getting a beep sound from the controller dialer person press a single digit a key
for the operation. As we press the single digit key , controller gets a signal from dtmf
decoder and further microcontroller on/off the corresponding output . All the outputs
are connected to the port P0 and P2. On these output we connect a 8 different l.e.ds.
[8]
As we press the digit code output l.e.d is on and remain on until we press the same
code again. Output is work as a toggle switch.
LED output of the microcontroller is further connected to the Triac circuit through
opto-coupler circuit. Output from the microcontroller is firstly connected to the
optocoupler pin no 1. This optocoupler is a special interface devide to interface the
controller with the triac circuit. The MOC3121( optocoupler) is optically isolated triac
driver devices. These devices contain a infra red emitting diode and a light activated
silicon bilateral switch. They are specially designed for interfacing between
electronics controls and power triac to control resistive and inductive loads for 240
volt Ac operation.
Pin no 1 is anode pin of infra red transmitter
Pin no2 is cathode pin of infra red transmitter
Pin no 4 and 6 is the output pin
Pin no 6 is output pin and connected to the gate of the triac through 100 ohm resistor.
At the output of the triac we control any 220 load. In this project its our choice, how
many optocoupler we interface this circuit. If we use 10 opto coupler then we
interface 10 load output with this circuit.
Now when ic receive any pulse then output led is on and then load is on. Again we
press the same code then led is off and load is also off.
[9]
mov a,p3
cjne a,#1,l1
jmp s1
here we use a command mov a, p3 . Here p3 means port 3 , from where we get a data
to the accumulator, We change this location as per the pcb design, If the port position
is change we change the command also, if the input is port p2 then we use mov a,p2
command
[10]
l1:
mov a,p3
anl a,#0fh
cjne a,#2,l2
call sound
s2:
mov a,p3
cjne a,#2,l2
jmp s2
l2:
mov a,p3
cjne a,#3,l3
call sound
s3:
mov a,p3
cjne a,#3,l3
jmp s3
l3:
mov a,p3
cjne a,#4,l4
call sound
s4:
mov a,p3
cjne a,#4,l4
jmp s4
l4:
mov a,p3
cjne a,#5,l5
call sound
s5:
mov a,p3
cjne a,#5,l5
jmp s5
l5:
mov a,p3
anl a,#0fh
cjne a,#6,l6
call sound
s6:
mov a,p3
[11]
cjne a,#6,l6
jmp s6
l6:
mov a,p3
cjne a,#7,l7
call sound
s7:
mov a,p3
cjne a,#7,l7
jmp s7
l7:
mov a,p3
cjne a,#8,l8
call sound
s8:
mov a,p3
cjne a,#8,l8
jmp s8
l8:
mov a,p3
anl a,#0fh
cjne a,#9,l9
call sound
s9:
mov a,p3
cjne a,#9,l9
jmp s9
l9:
mov a,p3
cjne a,#10,l10
call sound
jmp back
sound:
[12]
mov tick,#2
go_back:call delay100ms
go:
mov tick,#1
jmp go_back
clr buzzer
call delay
setb buzzer
call delay
ret
delay:
mov r0,#20
loop: djnz r0,loop
ret
mov r5,#4
sim_4: call delay100ms
djnz r5,sim_4
[13]
[14]
COMPONENTS USED:
STEP DOWN TRANSFORMER 220 AC TO 12 VOLT AC.
DIODE IN 4007 ( 4)
CAPACITOR 1000MFD (1), 27PF(2), .01 (2)
IC= 7805 ( 5 VOLT REGULATOR), 8870 ( DTMF DECODER)
8870 DTMF DECODER
74154 BCD TO DECIMAL DECODER
89S51 ( 8051 CONTROLLER)
MOC 3021 OPTOCOUPLER(5)
TRIAC BT 136 (5)
NPN TRANSISTOR(3) BC 548
PNP TRANSISTOR (9) BC 558
L.E.D ( 14)
CRYSTAL 3.58 Mhtz for 8870.
12 Mhtz for microcontroller.
BUZZER ( acknowledgement sound)
RESISTOR: 22K,(2), 10K(20), 1K(6), 470 OHM(20),100 OHM (5)
[15]
CHAPTER 6.
HOW TO PROGRAM BLANK CHIP
First of all we select and open the assembler and wrote a program code in the file.
After wrote a software we assemble the software by using internal assembler of the
8051 editor. If there is no error then assembler assemble the software abd 0 error is
show the output window.
now assembler generate a ASM file and HEX file. This hex file is useful for us to
program the blank chip.
Now we transfer the hex code into the blank chip with the help of serial programmer
kit. In the programmer we insert a blank chip 0f 89s51 series . these chips are multi
time programmable chip. This programming kit is seperatally available in the market
and we transfer the hex code into blank chip with the help of the serial programmer
kit
[16]
[17]
[18]
CHAPTER 7.
WHAT IS DTMF: When you press a button in the mobile set
keypad, a connection is made that generates a resultant
signal of two tones at the same time. These two tones are
taken from a row frequency and a column frequency. The
resultant frequency signal is called "Dual Tone Multiple
Frequency". These tones are identical and unique. A DTMF
signal
is
the
algebraic
sum
of
two
different
audio
A0sin(2**fa*t)
------->(1)
Where
fa
and
B0sin(2**fb*t)
fb
are
two
...........
different
audio
low
and
high
frequency
groups
comprise
four
two
different
frequencies,
one
from
the
high
-------->(2)
[19]
The frequencies are chosen such that they are not the
harmonics of each other. The frequencies associated with
various keys on the keypad are shown in figure (A).
When you send these DTMF signals to the mobile exchange
through cables, the servers in the mobile exchange identifies
these signals and makes the connection to the person you
are calling.
Fig (A)
When you press the digit 5 in the keypad it generates a
resultant tone signal which is made up of frequencies 770Hz
and 1336Hz. Pressing digit 8 will produce the tone taken
from tones 852Hz and 1336Hz. In both the cases, the column
frequency 1336 Hz is the same. These signals are digital
signals which are symmetrical with the sinusoidal wave.
A Typical frequency is shown in the figure below:
[20]
Figure (B)
Along with these DTMF generator in our mobile set provides
a set of special purpose groups of tones, which is normally
not used in our keypad. These tones are identified as 'A', 'B',
'C', 'D'. These frequencies have the same column frequency
but uses row frequencies given in the table in figure (A).
These tones are used for communication signaling.
The frequency table is as follows:
Figure (C)
Due to its accuracy and uniqueness, these DTMF signals
are used in controlling systems using mobiles. By using some
DTMF generating ICs (UM91214, UM91214, etc) we can
generate DTMF tones without depending on the telepho
[21]
Look around. Notice the smart intelligent systems? Be it the T.V, washing
machines, video games, mobiles, 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
Ports,
hands
timers,
of
clock
circuits,
micro
counters,
reset
controller!
functions
etc.
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.
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
[22]
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
Dallas Dallas has made many revolutions in the semiconductor market. Dallass 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.
Atmel These people were the one to master the flash devices. They are the cheapest
microcontroller available in the market. Atmels even introduced a 20pin variant of
8051 named 2051. The Atmels 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.
8.1
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.
[24]
The 8051 doesnt 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
The 8051 has a 8-Bit CPU that means it is able to process 8 bit of data at a time. 8051
has 235 instructions. Lets 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
[25]
microcontroller.
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?
Executiontime
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.
Dont worry about what bit zero and port one means. We shall learn it in more detail
[26]
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,
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.
[27]
Thus an 8-bit notation would indicate that the maximum value that can be input into
these registers is 11111111. Puzzled?
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 ROMThe 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, thats all? Well just wait. You would be surprised at the amount of
stuff you can load in this 4K of space. Of course you could always extend the space
by connecting to 64K of external ROM if required.
3. 128 bytes on-chip RAM
This is the space provided for executing the program in terms of moving data, storing
data etc.
4. 32 I/O lines. (Four- 8 bit ports, labeled P0, P1, P2, P3)
In our bulb example, we used the notation p1.0. This means bit zero of port one. One
bit controls one bulb.
Thus port one would have 8 bits. There are a total of four ports named p0, p1, p2, p3,
giving a total of 32 lines. These lines can be used both as input or output.
5. Two 16 bit timers / counters.
A microcontroller normally executes one instruction at a time. However certain
applications would require that some event has to be tracked independent of the main
program. The manufacturers have provided a solution, by providing two timers. These
timers execute in the background independent of the main program. Once the require
time has been reached, (remember the time calculations described above?), they can
trigger a branch in the main program. These timers can also be used as counters, so
that they can count the number of events, and on reaching the required count, can
cause a branch in the main program.
6. Full Duplex serial data receiver / transmitter.
[28]
The 8051 microcontroller is capable of communicating with external devices like the
PC etc. Here data is sent in the form of bytes, at predefined speeds, also known as
baud rates.
The transmission is serial, in the sense, one bit at a time
7. 5- interrupt sources with two priority levels (Two external and three internal)
During the discussion on the timers, we had indicated that the timers can trigger a
branch in the main program. However, what would we do in case we would like the
microcontroller to take the branch, and then return back to the main program, without
having to constantly check whether the required time / count has been reached?
This is where the interrupts come into play. These can be set to either the timers, or to
some external events. Whenever the background program has reached the required
criteria in terms of time or count or an external event, the branch is taken, and on
completion of the branch, the control returns to the main program.
Priority levels indicate which interrupt is more important, and needs to be executed
first in case two interrupts occur at the same time.
8. On-chip clock oscillator.
This represents the oscillator circuits within the microcontroller. Thus the hardware is
reduced to just simply connecting an external crystal, to achieve the required pulsing
rate.
PIN FUNCTION OF IC 89C51.
Supply pin of this ic is pin no 40. Normally we apply a 5 volt regulated dc power
supply to this pin. For this purpose either we use step down transformer power supply
or we use 9 volt battery with 7805 regulator.
Ground pin of this ic is pin no 20. Pin no 20 is normally connected to the ground pin
( normally negative point of the power supply.
XTAL is connected to the pin no 18 and pin no 19 of this ic. The quartz crystal
oscillator connected to XTAL1 and
PORT0 Port 0 occupies a total of 8 pins. Pin no 32 to pin no 39. It can be used for
input or output. We connect all the pins of the port 0 with the pullup resistor (10 k
ohm) externally. This is due to fact that port 0 is an open drain mode. It is just like a
open collector transistor.
PORT1. ALL the ports in micrcontroller is 8 bit wide pin no 1 to pin no 8 because it
is a 8 bit controller. All the main register and sfr all is mainly 8 bit wide. Port 1 is
also occupies a 8 pins. But there is no need of pull up resistor in this port. Upon reset
port 1 act as a input port. Upon reset all the ports act as a input port
PORT2. port 2 also have a 8 pins. It can be used as a input or output. There is no
need of any pull up resistor to this pin.
PORT 3. Port3 occupies a totoal 8 pins from pin no 10 to pin no 17. It can be
used as input or output. Port 3 does not require any pull up resistor. The same as port
1 and port2. Port 3 is configured as an output port on reset. Port 3 has the additional
function of providing some important signals such as interrupts. Port 3 also use for
serial communication.
ALE ALE is an output pin and is active high. When connecting an 8031 to external
memory, port 0 provides both address and data. In other words, the 8031 multiplexes
address and data through port 0 to save pins. The ALE pin is used for demultiplexing
the address and data by connecting to the ic 74ls373 chip.
PSEN. PSEN stands for program store eneable. In an 8031 based system in which an
external rom holds the program code, this pin is connected to the OE pin of the rom.
EA. EA. In 89c51 8751 or any other family member of the ateml 89c51 series all
come with on-chip rom to store programs, in such cases the EA pin is connected to
the Vcc. For family member 8031 and 8032 is which there is no on chip rom, code is
stored in external memory and this is fetched by 8031. In that case EA pin must be
connected to GND pin to indicate that the code is stored externally.
[30]
8.2
SPECIAL FUNCTION REGISTER ( SFR) ADDRESSES.
ACC
ACCUMULATOR
0E0H
B REGISTER
0F0H
PSW
0D0H
SP
STACK POINTER
81H
DPTR
DPL
82H
DPH
83H
P0
PORT0
80H
P1
PORT1
90H
P2
PORT2
0A0H
P3
PORT3
0B0H
TMOD
89H
[31]
TCON
88H
TH0
8CH
TLO
8AH
TH1
8DH
TL1
8BH
SCON
SERIAL CONTROL
98H
SBUF
99H
PCON
POWER CONTROL
87H
8.3
INSTRUCTIONS
SINGLE BIT INSTRUCTIONS.
SETB BIT
CLR BIT
CPL BIT
JB BIT,TARGET
JBC BIT,TARGET
BIT
[32]
MOV INSTRUCTIONS
MOV instruction simply copy the data from one location to another location
MOV D,S
Copy the data from(S) source to D(destination)
MOV R0,A
MOV R1,A
MOV A,R3
MOV R0,#12h
MOV R5,#0F9H
ADD INSTRUCTIONS.
ADD instructions adds the source byte to the accumulator ( A) and place the result in
the Accumulator.
MOV A, #25H
ADD A,#42H ; BY this instructions we add the value 42h in Accumulator ( 42H+
25H)
ADDA,R3
ACALL,TARGET ADDRESS
By this instructions we call subroutines with a target address within 2k bytes from
the
current program counter.
LCALL, TARGET ADDRESS.
AJMP TARGET ADDRESS.
This is for absolute jump
AJMP stand for absolute jump. It transfers program execution to the target address
unconditionally. The target address for this instruction must be withib 2 k byte of
program memory.
LJMP is also for absoltute jump. It tranfer program execution to the target addres
unconditionally. This is a 3 byte instructions LJMP jump to any address within 64 k
byte location.
INSTRUCTIONS RELATED TO THE CARRY
JC TARGET
JUMP TO THE TARGET IF CY FLAG =1
JNC TARGET
JUMP TO THE TARGET ADDRESS IF CY FLAG IS = 0
INSTRUCTIONS RELASTED TO JUMP WITH ACCUMULATOR
JZ TARGET
JUMP TO TARGET IF A = 0
JNZ TARGET
JUMP IF ACCUMULATOR IS NOT ZERO
This instructions jumps if registe A has a value other than zero
INSTRUCTIONS RELATED TO THE ROTATE
RL A
ROTATE LEFT THE ACCUMULATOR
BY this instructions we rotate the bits of A left. The bits rotated out of A are rotated
back into A at the opposite end
[34]
RR A
By this instruction we rotate the contents of the accumulator from right to left from
LSB to MSB
RRC A
This is same as RR A but difference is that the bit rotated out of register first enter in
to carry and then enter into MSB
RLC A
ROTATE A LEFT THROUGH CARRY
Same as above but but shift the data from MSB to carry and carry to LSB
RET
This is return from subroutine. This instructions is used to return from a subroutine
previously entered by instructions LCALL and ACALL.
RET1
THIS is used at the end of an interrupt service routine. We use this instructions after
intruupt routine,
PUSH.
This copies the indicated byte onto the stack and increments SP by . This instructions
supports only direct addressing mode.
POP.
POP FROM STACK.
This copies the byte pointed to be SP to the location whose direct address is
indicated, and decrements SP by 1. Notice that this instructions supports only direct
addressing mode.
DPTR INSTRUCTIONS.
MOV DPTR,#16 BIT VALUE
LOAD DATA POINTER
This instructions load the 16 bit dptr register with a 16 bit immediate value
MOV C A,@A+DPTR
This instructions moves a byte of data located in program ROM into register A. This
allows us to put strings of data, such as look up table elements.
[35]
MOVC A,@A+PC
This instructions moves a byte of data located in the program area to A. the address of
the desired byte of data is formed by adding the program counter ( PC) register to the
original value of the accumulator.
INC BYTE
This instructions add 1 to the register or memory location specified by the operand.
INC A
INC Rn
INC DIRECT
DEC BYTE
This instructions subtracts 1 from the byte operand. Note that CY is unchanged
DEC A
DEC Rn
DEC DIRECT
ARITHMATIC INSTRUCTIONS.
ANL dest-byte, source-byte
This perform a logical AND operation
This performs a logical AND on the operands, bit by bit, storing the result in the
destination. Notice that both the source and destination values are byte size only
DIV AB
This instructions divides a byte accumulator by the byte in register B. It is assumed
that both register A and B contain an unsigned byte. After the division the quotient
will be in register A and the remainder in register B.
[36]
Both timer is the 89c51 share the one register TMOD. 4 LSB bit for the timer 0 and 4
MSB for the timer 1.
In each case lower 2 bits set the mode of the timer
Upper two bits set the operations.
GATE:Gating control when set. Timer/counter is enabled only while the INTX pin is
high and the TRx control pin is set. When cleared, the timer is enabled whenever the
TRx control bit is set
C/T : Timer or counter selected cleared for timer operation ( input from internal
system clock)
M1
Mode bit 1
M0
Mode bit 0
M1
M0
MODE
OPERATING MODE
13 BIT TIMER/MODE
[37]
CY
PSW.7
CARRY FLAG
AC
PSW.6
AUXILIARY CARRY
F0
PSW.5
RS1
PSW.4
RS0
PSW.3
0V
PSW.2
OVERFLOW FLAG
--
PSW.1
PSW.0
[38]
TH1
CRYSTAL FREQUENCY
256---- ____________________
384 X BAUD RATE
If the SMOD IS = 1
CRYSTAL FREQUENCY
TH1
There are two ways to increase the baud rate of data transfer in the 8051
1.
2.
PCON register is an 8 bit register . Of the 8 bits, some are unused, and some are used
for the power control capability of the 8051. the bit which is used for the serial
communication is D7, the SMOD bit. When the 8051 is powered up, D7 ( SMOD BIT)
OF PCON register is zero. We can set it to high by software and thereby double the
baud rate
BAUD RATE COMPARISION FOR SMOD = 0 AND SMOD =1
TH1
( DECIMAL)
HEX
SMOD =0
SMOD =1
-3
FD
9600
19200
-6
FA
4800
9600
-12
F4
2400
4800
-24
E8
1200
2400
[39]
EA
IE.7
IE.6
NOT implemented
ET2
IE.5
ES
IE.4
ET1
IE.3
EX1
IE.2
ET0
IE.1
EX0
IE.0
If the bit is 0, the corresponding interrupt has a lower priority and if the bit is 1 the
corresponding interrupt has a higher priority
[40]
IP.7
IP.6
PT2
IP.5
PS
IP.4
PT1
IP.3
PX1
IP.2
PT0
IP.1
PX0
IP.0
SM0
SM1
SM2
SCON.5
REN
TB8
SCON.3
Set/cleared
By software
[41]
RB8
SCON.2 In modes 2 &3, is the 9 th data bit that was received. In mode
1,
If SM2 = 0, RB8 is the stop bit that was received. In mode 0
RB8 is not used
T1
bit
Time in mode 0, or at the beginning of the stop bit in the
other
Modes. Must be cleared by software
R1
SCON.0 Receive interrupt flag. Set by hardware at the end of the 8th bit
Time in mode 0, or halfway through the stop bit time in the
other
Modes. Must be cleared by the software.
TCON
TCON.7
Timer/Counter 1
Overflows. Cleared by hardware as processor
TR1
TCON.6
TF0
TCON.5
0
Overflows. Cleared by hardware as processor
TR0
TCON.4
IE1
TCON.3
ITI
TCON.2
IE0
TCON.1
IT0
TCON.0
Description
Size
Cycles
ADD A,Rn
ADDC A,direct
ADDC A,@Ri
ADDC A,#data
SUBB A,Rn
SUBB A,direct
[43]
SUBB A,#data
INC A
INC Rn
Increment register.
INC direct
INC @Ri
Decrement ACC.
DEC A
DEC Rn
Decrement register.
DEC direct
DEC @Ri
INC DPTR
MUL AB
DIV AB
DA A
Size
Cycles
Logical Operations
Mnemonic
Description
ANL A,Rn
[44]
ANL direct,#data
ORL A,Rn
OR Register to ACC.
1
2
1
3
2
XRL A,Rn
XRL direct,#data
CLR A
CPL A
Compliment ACC.
RL A
RLC A
RR A
RRC A
SWAP A
Data Transfer
Mnemonic
Description
Size
Cycles
MOV A,Rn
MOV A,direct
2
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
MOVC A,@A+DPTR
address).
MOVC A,@A+PC
MOVX A,@Ri
MOVX A,@DPTR
MOVX @Ri,A
MOVX @DPTR,A
2
2
[47]
PUSH direct
POP direct
XCH A,Rn
XCH A,direct
XCH A,@Ri
XCHD A,@Ri
Description
Size
Cycles
CLR C
CLR bit
SETB C
SETB
CPL C
CPL bit
ANL C,bit
ANL C,/bit
ORL C,bit
[48]
ORL C,/bit
MOV C,bit
MOV bit,C
JC rel
JNC rel
JB bit,rel
JNB bit,rel
JBC bit,rel
Program Branching
Mnemonic
Description
Size
Cycles
ACALL
addr11
LCALL
addr16
RET
RETI
[49]
SJMP rel
JMP @A+DPTR
JZ rel
JNZ rel
CJNE A,direct,rel
CJNE A,#data,rel
CJNE Rn,#data,rel
CJNE @Ri,#data,rel Compare immediate byte to indirect and jump if not equal.32
DJNZ Rn,rel Decrement register and jump if not zero.
DJNZ direct,rel
Other Instructions
Mnemonic
NOP
Description
No operation. 1
Size
Cycles
[50]
CHAPTER 9
LIGHT EMITTING DIODE
Light emitting diode (LED) is basically a P-N junction semiconductor diode
particularly designed to emit visible light. There are infrared emitting LEDs which
emit invisible light. The LEDs are now available in many colours red, green and
yellow. A normal LED emits at 2.4V and consumes MA of current. The LEDs are
made in the form of flat tiny P-N junction enclosed in a semi-spherical dome made
up of clear coloured epoxy resin. The dome of a LED acts as a lens and diffuser of
light. The diameter of the base is less than a quarter of an inch. The actual
diameter varies somewhat with different makes. The common circuit symbols for
the LED are shown in Fig. It is similar to the conventional rectifier diode symbol
with two arrows pointing out. There are two leads- one for anode and the other for
cathode.
LEDs often have leads of dissimilar length and the shorter one is the cathode. All
manufacturers do not strictly adhere this to. Sometimes the cathode side has a flat
base. If there is doubt, the polarity of the diode should be identified. A simple bench
method is to use the ohmmeter incorporating 3-volt cells for ohmmeter function.
When connected with the ohmmeter: one way there will be no deflection and when
connected the other way round there will be a large deflection of a pointer. When this
occurs the anode lead is connected to the negative of test lead and cathode to the
positive test lead of the ohmmeter.
[51]
If low range (Rxl) of the ohmmeter is used the LED would light up in most
cases because the low range of ohmmeter can pass sufficient current to light up the
LED.Another safe method is to connect the test circuit shown in Fig. 2. Use any two
dry cells in series with a current limiting resistor of 68 to 100 ohms. The resistor
limits the forward diode current of the LED under test to a safe value. When the LED
under test is connected to the test terminals in any way: if it does not light up, reverse
the test leads. The LED will now light up. The anode of the LED is that which is
connected to the A terminal (positive pole of the battery). This method is safe, as
reverse voltage can never exceed 3 volts in this test.
9.1
ELECTRICAL CHARACTERISTICS OF LEDS: Electrically, a LED is similar to the conventional diode in that it has relatively low
forward voltage threshold. Once this is exceeded the junction has a low slope
resistance and conducts current readily. An external resistor must limit this current.
Forward voltage drew across red LED is nominally 1.6 V but spread with commercial
diodes, it may be as high as 2 volts or so, while the Green LED drops 2.4V. This
difference accounts for use of lower limiting resistor used with the Green LED.
Another important parameter of the LED is its maximum reverse voltage
rating. For typical Red device it is of the order of 3 volts. But for Green LED it is
somewhat higher- 5 to 10 volts.
The LED produces light only when a d.c. current is passed in the forward direction
and the amount of light emitted by a LED is proportional to the forward current over a
broad range. It means that light intensity increases in an approximately linear manner
with increasing current.
Anode
9.2
Connection
SEVEN SEGMENT DISPLAY DECIMAL DISPLAY:A popular type consists of seven small, bar-shaped LED segment arranged so that
depending on which combinations are energized, the numbers 0 to 9 light up. All the
LED cathodes (or sometimes anodes) are joined to form a common connection.
Current limiting resistors are required (e.g. 270 ohms), preferably one per segment.
Common cathode method of connecting an array of display elements.
[52]
Common Cathode
2)
3)
angle. This may be achieved by shaping the semiconductor /air interface into a
hemisphere.
[53]
The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its
body tells us the value of resistor value as given below.
COLOURS
CODE
Black-----------------------------------------------------0
Brown----------------------------------------------------1
Red-------------------------------------------------------2
Orange---------------------------------------------------3
Yellow---------------------------------------------------4
Green-----------------------------------------------------5
Blue-------------------------------------------------------6
Violet-----------------------------------------------------7
Grey------------------------------------------------------8
White-----------------------------------------------------9
The first rings give the first digit. The second ring gives the second digit. The third
ring indicates the number of zeroes to be placed after the digits. The fourth ring gives
tolerance (gold 5%, silver 10%, No colour 20%).
[55]
In variable resistors, we have the dial type of resistance boxes. There is a knob with a
metal pointer. This presses over brass pieces placed along a circle with some space
b/w each of them.
Resistance coils of different values are connected b/w the gaps. When the knob is
rotated, the pointer also moves over the brass pieces. If a gap is skipped over, its
resistance is included in the circuit. If two gaps are skipped over, the resistances of
both together are included in the circuit and so on.
A dial type of resistance box contains many dials depending upon the range, which it
has to cover. If a resistance box has to read upto 10,000, it will have three dials each
having ten gaps i.e. ten resistance coils each of resistance 10. The third dial will have
ten resistances each of 100. The dial type of resistance boxes is better because the
contact resistance in this case is small & constant.
[56]
CHAPTER 10
TRANSFORMER
10.1
PRINCIPLE OF THE TRANSFORMER:Two coils are wound over a Core such that they are magnetically coupled. The two
coils are known as the primary and secondary windings.
In a Transformer, an iron core is used. The coupling between the coils is source of
making a path for the magnetic flux to link both the coils. A core as in fig.2 is used
and the coils are wound on the limbs of the core. Because of high permeability of
iron, the flux path for the flux is only in the iron and hence the flux links both
windings. Hence there is very little leakage flux. This term leakage flux denotes the
part of the flux, which does not link both the coils, i.e., when coupling is not perfect.
In the high frequency transformers, ferrite core is used. The transformers may be stepup, step-down, frequency matching, sound output, amplifier driver etc. The basic
principles of all the transformers are same.
MINIATURE TRANSFORMER
[57]
[58]