Академический Документы
Профессиональный Документы
Культура Документы
INDEX
Page No
1. INTRODUCTION
01
2. WORKING PRINCIPLE
10
3. DESIGN PROCEDURE
3.1 Microcontroller
14
3.2 LCD
32
36
39
3.5 Buzzer
42
4 RESULT
61
5 APPLICATIONS, ADVANTAGES
64
6 CONCULSION
66
7 ALP PROGRAM
69
1
www.final-yearproject.com | www.finalyearthesis.com
BIBLIOGRAPHY
CHAPTER-1
2
www.final-yearproject.com | www.finalyearthesis.com
INTRODUCTION
One of the first electrmagnetic rotary motors was invented by Michael Faraday in 1821
and consisted of a free-hanging wire dipping into a pool of mercury. A permanent
magnet was placed in the middle of the pool. When a current was passed through the
wire, the wire rotated around the magnet, showing that the current gave rise to a circular
magnetic field around the wire. This motor is often demonstrated in school physics
classes, but brine is sometimes used in place of the toxic mercury. This is the simplest
form of a class of electric motors called homopolar motors. A later refinement is the
Barlow's Wheel.
The modern DC motor was invented by accident in 1873, when Znobe
connected a spinning dynamo to a second similar unit, driving it as a motor.
3
www.final-yearproject.com | www.finalyearthesis.com
DC motor
Dc motor is an electric motor converts electrical energy into mechanical motion.
The reverse task that of converting mechanical motion into electrical energy, is
accomplished by a generator or dynamo. In many cases the two devices are
identical except for their application and minor construction details.
DC motors are used when there is positioning requirement and also changes in load
and torque. DC motors can be conveniently interfaced to Bipolar DAC, or MPUs
can generate PWMs to control them.
The classic DC motor has a rotating legature in the form of an electromagnet. A rotary
switch called a commutator reverses the direction of the electric current twice every
cycle, to flow through the armature so that the poles of the electromagnet push and
against the permanent magnets on the outside of the motor. As the poles of the armature
electromagnet pass the poles of the permanent magnets, the commutator reverses the
polarity of the armature electromagnet. During that instant of switching polarity, inertia
4
www.final-yearproject.com | www.finalyearthesis.com
keeps the classical motor going in the proper direction. (See the diagrams below.)
The left side of the armature is pushed away from the left magnet and
drawn toward the right, causing rotation.
6
www.final-yearproject.com | www.finalyearthesis.com
When the armature becomes horizontally aligned, the commutator reverses the direction
of current through the coil, reversing the magnetic field. The process then repeats
Speed control
Generally speaking the rotational speed of a DC motor is proportional to the voltage
applied to it, and the torque is proportional to the current. Speed control can be achieved
by variable voltage source, resistors or electronic controls. The
direction of a wound field DC motor can be changed by reversing either the field or
armature connections but not both, this is commonly done with a special set of contactors
(direction contactors).
Effective voltage can be varied by inserting a series resistor or by an electronically7
www.final-yearproject.com | www.finalyearthesis.com
controlled switching device made of thyristors, transistors, or, historically, mercury arc
rectifiers. In a circuit known as a chopper, the average voltage applied to the motor is
varied by switching the supply voltage very rapidly. As the "on" to "off" ratio is varied
to alter the average applied voltage, the speed of the motor varies.
The rapid switching wastes less energy than series resistors. Output filters smooth
the average voltage applied to the motor and reduce motor noise.
Since the series-wound DC motor develops its highest torque at low speed, it is often
used in traction applications such as electric locomotives, and trams. Another application
is starter motors for petrol and small diesel engines.
Universal motors
A variant of the wound field DC motor is the universal motor. The name derives from
the fact that it may use AC or DC supply current, although in practice they are nearly
always used with AC supplies. The principle is that in a wound field DC motor the
current in both the field and the armature (and hence the resultant magnetic fields) will
alternate (reverse polarity) at the same time, and hence the mechanical force generated is
always the same. In practice the motor must be specially designed to cope with the AC
current (impedance must be taken into account), and the resultant motor is generally less
efficient than an equivalent pure DC motor. The maximum output of universal motors is
8
www.final-yearproject.com | www.finalyearthesis.com
limited, and motors exceeding one kilowatt are rarely operated on commercial power
frequency.The advantage of the universal motor is that AC supplies may be used on
motors which have the typical characteristics of DC motors, specifically high starting
torque and very compact design if high running speeds are used. The negative aspect is
the maintenance and short life problems caused by the commutator. As a result such
motors are usually used in AC devices such as food mixers and power tools, which are
only used intermittently.
will often exceed 30,000 RPM. A universal motor allowed to operate with no mechanical
load will overspeed, which may damage it.
With the very low cost of semiconductor rectifiers, some applications that would have
previously used a universal motor now use a pure DC motor, usually with a permanent
magnet field. This is especially true if the semiconductor circuit is also used for variablespeed control.
The advantages of the universal motor and alternating current distribution made
installation of a low-frequency traction current distribution system economical for some
railway installations.
10
www.final-yearproject.com | www.finalyearthesis.com
CHAPTER-2
11
www.final-yearproject.com | www.finalyearthesis.com
When we switch on the power, Micro controller (MC) is reset by power through
the reset circuit. It produces one high pulse and continues low pulse. During the
high pulse the program counter is set to 0000h. During low pulse the program
counter starts its count and the remaining operations are executed.
12
www.final-yearproject.com | www.finalyearthesis.com
First the MC sends the signals to the LCD to display the message, such as project
title etcthis also indicate the reset of MC to the user. Next it monitors the
keypad. If the up or down key is pressed by the user the MC update the
corresponding registors .
If not it will take the existed values of register and produce PWM signals to DC motor
driver circuit . the DC motor circuits transistor will on\off according to PWM pulses.the
MOSFET ON when the transistor is off state and it is in off condition when the transistor
is in on state. Here by rapid switching of MOSFET, the effective voltage is created and
used to run the DC motor, which is given through MOSFET.
The resultant effective voltage is vary according to the duration of the ON period of the
each pulse.if the ON pulse is decresses ,the effective voltage will decreases so, speed of
the DC motor will decreases and vise versa.
The pulse width is depending on the up and down keys registers value. User edits these
values by pressing the keypad. The process is continuous.
13
www.final-yearproject.com | www.finalyearthesis.com
LCD
DC Motor
driver circuit
89C51 Micro
Controller
DC Motor
14
www.final-yearproject.com | www.finalyearthesis.com
Keypad
15
www.final-yearproject.com | www.finalyearthesis.com
CHAPTER-3
DESIGN PROCEDURE
devices. The three basic elements-the CPU, I/O devices and memory-have developed in
distinct directions. While the CPU has been the proprietary item, the memory devices fall
into general-purpose category and the I/O devices may be grouped somewhere inbetween.
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pin out. 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 Flash on a
monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a
highly flexible and cost-effective solution to many embedded control applications.
The AT89C51 provides for 4k EPROM/ROM, 128 byte RAM and 32 I/O lines. It also
includes a universal asynchronous receive-transmit (UART) device, two 16-bit
timer/counters and elaborate interrupt logic.
Lack of multiply and divide instructions which had been always felt in 8-bit
microprocessors/micro controllers, has also been taken care of in the 89C51- Thus the
17
www.final-yearproject.com | www.finalyearthesis.com
89C51 may be called nearly equivalent of the following devices on a single chip: 8085 +
8255 + 8251 + 8253 + 2764 + 6116.
In short, the AT89C51 has the following on-chip facilities:
UART
Description
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K
bytes of flash programmable and erasable read only memory (PEROM). The device
is manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the industry standard MCS-51 instruction set and pinout. The onchip 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 Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer
which provides a highly-flexible and cost-effective solution to many embedded
control applications.
18
www.final-yearproject.com | www.finalyearthesis.com
20
www.final-yearproject.com | www.finalyearthesis.com
Salient features
21
www.final-yearproject.com | www.finalyearthesis.com
The 89C51 can be configured to bypass, the internal 4k ROM and run solely with
external program memory. For this its external access (EA) pin has to be grounded,
which makes it equivalent to 8031. The program store enable (PSEN) signal acts as read
pulse for program memory. The data memory is external only and a separate RD*
signal is available for reading its contents.
Use of external memory requires that three of its 8-bit ports (out of four) are configured
to provide data/address multiplexed bus. Hi address bus and control signals related to
external memory use. The RXD and TXD ports of UART also appear on pins 10 and
11 of 8051 and 8031, respectively. One 8-bit port, which is bit addressable and,
extremely useful for control applications.
The UART utilizes one of the internal timers for generation of baud rate. The crystal used
for generation of CPU clock has therefore to be chosen carefully. The 11.0596 MHz
crystals; available abundantly, can provide a baud rate of 9600.
The 256-byte address space is utilized by the internal RAM and special function registers
(SFRs) array which is separate from external data RAM space of 64k. The 00-7F space
is occupied by the RAM and the 80 - FF space by the SFRs. The 128 byte internal RAM
has been utilized in the following fashion:
00-IF: Used for four banks of eight registers of 8-bit each. The four banks may
be selected by software any time during the program
22
www.final-yearproject.com | www.finalyearthesis.com
30- 7F: This area is used for temporary storage, pointers and stack. On
reset, the stack starts at 08 and gets incremented during use.
Port/Register
P0 (Port 0)
SP (stack pointer)
DPH (data pointer High)
DPL (data pointer Low)
TCON (timer control)
TMOD (timer mode)
TLO (timer 0 low byte)
TL1 (timer 1 low byte)
TH0 (timer 0 high byte)
TH1 (timer 1 high byte)
P1 (port 1)
SCON (serial control)
SBUF (serial buffer)
P2 (port 2)
Interrupt enable (IE)
P3 (port 3)
Interrupt priority (IP)
Processor status word (PSW)
Accumulator (ACC)
B register
Table AT89C51 SFR
23
www.final-yearproject.com | www.finalyearthesis.com
Hardware details
The on chip oscillator of 89C51 can be used to generate system clock. Depending upon
version of the device, crystals from 3.5 to 12 MHz may be used for this purpose. The
system clock is internally divided by 6 and the resultant time period becomes one
processor cycle. The instructions take mostly one or two processor
cycles to execute, and very occasionally three processor cycles. The ALE (address
latch enable) pulse rate is 16th of the system clock, except during access of internal
program memory, and thus can be used for timing purposes.
ALTERNATE USE
Serial data input
Serial data output
External interrupt 0
External interrupt 1
External timer 0 input
External timer 1 input
External memory write pulse
External memory read pulse
Table AT89C51 serial port pins
SFR
SBUF
SBUF
TCON-1
TCON- 2
TMOD
TMOD
------------
The two internal timers are wired to the system clock and prescaling factor is decided by
the software, apart from the count stored in the two bytes of the timer control registers.
One of the counters, as mentioned earlier, is used for generation of baud rate clock for the
24
www.final-yearproject.com | www.finalyearthesis.com
UART. It would be of interest to know that the 8052 have a third timer, which is usually
used for generation of baud rate.
The reset input is normally low and taking it high resets the micro controller, In the
present hardware, a separate CMOS circuit has been used for generation of reset signal so
that it could be used to drive external devices as well.
internal program EPROM cannot be read. The device has to be erased in full for further
alteration, and thus it can only be reused but not copied. EEPROM and FLASH memory
versions of the device are also available now.
Memory unit
Memory is part of the micro controller whose function is to store data. The easiest way
to explain it is to describe it as one big closet with lots of drawers. If we suppose that we
marked the drawers in such a way that they cannot be confused, any of their contents will
then be easily accessible. It is enough to know the designation of the drawer and so its
contents will be known to us for sure.
Memory components are exactly like that. For a certain input we get the contents of a
certain addressed memory location and thats all. Two new concepts are brought to us:
addressing and memory location. Memory consists of all memory locations, and
addressing is nothing but selecting one of them. This means that we need to select the
desired memory location on one hand, and on the other hand we need to wait for the
contents of that location. Besides reading from a memory location, memory must also
provide for writing onto it. This is done by supplying an additional line, called control
26
www.final-yearproject.com | www.finalyearthesis.com
line. We will designate this line as R/W (read/write). Control line is used in the following
way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory
location.Memory is the first element, and we need a few operation of our micro
controller.
Pin Description
VCC
Supply voltage.
GND
Ground.
Port 0
1.Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink
eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs.
2.Port 0 may also be configured to be the multiplexed low order address/data bus during
accesses to external program and data memory. In this mode P0 has internal pull-ups.
3.Port 0 also receives the code bytes during Flash programming, and outputs the code
bytes during program verification. External pull-ups are required during program
verification.
Port 1
1.Port 1 is an 8-bit bi-directional I/O port with internal pullups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high
27
www.final-yearproject.com | www.finalyearthesis.com
by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are
externally being pulled low will source current (IIL) because of the internal pull-ups
Port 1 also receives the low-order address bytes during Flash programming and
verification.
Port 2
1.Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high
by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally
being pulled low will source current (IIL) because of the internal pullups.
2.Port 2 emits the high-order address byte during fetches from external program memory
and during accesses to external data memory that use 16-bit addresses (MOVX @DPTR).
In this application, it uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents
of the P2 Special Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
Port 3
1.Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high
by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally
being pulled low will source current (IIL) because of the pullups.
2.Port 3 also serves the functions of various special features of the AT89C51 as listed
below:
28
www.final-yearproject.com | www.finalyearthesis.com
Port 3 also receives some control signals for Flash programming and verification.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during
Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during each access to external Data Memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit
set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
29
www.final-yearproject.com | www.finalyearthesis.com
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89C51 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the
12-volt programming enable voltage (VPP) during Flash programming, for parts that
require 12-volt VPP.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a
quartz crystal or ceramic resonator may be used. To drive the device from an external
clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in
Figure 2.There are no requirements on the duty cycle of the external clock signal, since
30
www.final-yearproject.com | www.finalyearthesis.com
the input to the internal clocking circuitry is through a divide-by-two flip-flop, but
minimum and maximum voltage high and low time specifications must be observed.
Idle Mode
In idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active.
The mode is invoked by software. The content of the on-chip RAM and all the special
functions registers remain unchanged during this mode. The idle mode can be terminated
by any enabled interrupt or by a hardware reset. It should be noted that when idle is
terminated by a hard ware reset, the device normally resumes program execution, from
where it left off, up to two machine cycles before the internal reset algorithm takes
control. On-chip hardware inhibits access to internal RAM in this event, but access to the
port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin
when Idle is terminated by reset, the instruction following the one that invokes Idle
should not be one that writes to a port pin or to external memory.
31
www.final-yearproject.com | www.finalyearthesis.com
32
www.final-yearproject.com | www.finalyearthesis.com
Power-down Mode
In the power-down mode, the oscillator is stopped, and the instruction that invokes
power-down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the power-down mode is terminated. The only exit from
power-down is a hardware reset. Reset redefines the SFRs but does not change the onchip RAM. The reset should not be activated before VCC is restored to its normal
operating level and must be held active long enough to allow the oscillator to restart and
stabilize.
Program Memory Lock Bits
On the chip are three lock bits which can be left unprogrammed (U) or can be
programmed (P) to obtain the additional features listed in the table below.
33
www.final-yearproject.com | www.finalyearthesis.com
1.When lock bit 1 is programmed, the logic level at the EA pins sampled and latched
during reset. If the device is powered up without a reset, the latch initializes to a random
value, and holds that value until reset is activated. It is necessary that the latched value of
EA be in agreement with the current logic level at that pin in order for the device to
function properly.
34
www.final-yearproject.com | www.finalyearthesis.com
Programming Algorithm
Before programming the AT89C51, the address, data and control signals should be set
up according to the Flash programming mode table and Figure 3 and Figure 4. To
program the AT89C51, take the following steps.
1. Input the desired memory location on the address lines.
2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V for the high-voltage programming mode.
5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The bytewrite cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through
35
www.final-yearproject.com | www.finalyearthesis.com
5, changing the address and data for the entire array or until the end of the object file is
reached.
Data Polling:
The AT89C51 features Data Polling to indicate the end of a write cycle. During a write
cycle, an attempted read of the last byte written will result in the complement of the
written datum on PO.7. Once the write cycle has been the next cycle may begin. Data
Polling may begin any time completed, true data are valid on all outputs, and after a write
cycle has been initiated.
Ready/Busy:
The progress of byte programming can also be monitored by the RDY/BSY output
signal. P3.4 is pulled low after ALE goes high during programming to indicate BUSY.
P3.4 is pulled high again when programming is done to indicate READY.
Program Verify:
If lock bits LB1 and LB2 have not been programmed, the programmed code data can be
read back via the address and data lines for verification. The lock bits cannot be verified
directly. Verification of the lock bits is achieved by observing that their features are
enabled.
Chip Erase:
The entire Flash array is erased electrically by using the proper combination of control
signals and by holding ALE/PROG low for 10 ms. The code array is written with all
1s. The chip erase operation must be executed before the code memory can be reprogrammed.
Reading the Signature Bytes:
36
www.final-yearproject.com | www.finalyearthesis.com
The signature bytes are read by the same procedure as a normal verification of locations
030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The
values returned are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 51H indicates 89C51
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
Programming Interface
Every code byte in the Flash array can be written and the entire array can be erased by
using the appropriate combination of control signals. The write operation cycle is
selftimed and once initiated, will automatically time itself to completion. All major
programming vendors offer worldwide support for the Atmel microcontroller series.
Please contact your local programming vendor for the appropriate software revision.
Registers are therefore memory locations whose role is to help with performing various
mathematical operations or any other operations with data wherever data can be found.
Look at the current situation. We have two independent entities (memory and CPU),
which are interconnected, and thus any exchange of data is hindered, as well as its
functionality. If, for example, we wish to add the contents of two memory locations and
return the result again back to memory, we would need a connection between memory
and CPU. Simply stated, we must have some way through data goes from one block to
another.
Bus
That way is called bus. Physically, it represents a group of 8, 16, or more wires.
There are two types of buses: address and data bus. The first one consists of as many
lines as the amount of memory we wish to address, and the other one is as wide as data,
in our case 8 bits or the connection line. First one serves to transmit address from CPU
memory, and the second to connect all blocks inside the micro controller.
Input-output unit
Those locations weve just added are called ports. There are several types of ports:
input, output or bi-directional ports. When working with ports, first of all it is necessary
38
www.final-yearproject.com | www.finalyearthesis.com
to choose which port we need to work with, and then to send data to, or take it from the
port.
When working with it the port acts like a memory location. Something is simply
being written into or read from it, and it could be noticed on the pins of the microcontroller.
LCD
39
www.final-yearproject.com | www.finalyearthesis.com
For high-resolution color displays such as modern LCD computer monitors and
televisions, an active matrix structure is used. A matrix of thin-film transistors (TFTs) is
added to the polarizing and color filters. Each pixel has its own dedicated transistor,
which allows each column line to access one pixel. When a row line is activated, all of
the column lines are connected to a row of pixels and the correct voltage is driven onto
all of the column lines. The row line is then deactivated and the next row line is activated.
All of the row lines are activated in sequence during a refresh operation. Active-matrix
displays are much brighter and sharper than passive-matrix displays of the same size, and
generally have quicker response times.
The most common connector used for the 44780 based LCDs is 14 pins in a row, with pin
centers 0.100" apart.
Pins
Description
Ground
Vcc
Contrast Voltage
"E" Clock
7 - 14
As you would probably guess from this description, the interface is a parallel bus,
allowing simple and fast reading/writing of data to and from the LCD.
This waveform will write an ASCII Byte out to the LCD's screen. The ASCII
code to be displayed is eight bits long and is sent to the LCD either four or eight
bits at a time.
If four bit mode is used, two "nybbles" of data (Sent high four bits
and then low four bits with an "E" Clock pulse with each nybble) are sent to make
up a full eight bit transfer. The "E" Clock is used to initiate the data transfer
within the LCD.
Sending parallel data as either four or eight bits are the two primary modes of
operation. While there are secondary considerations and modes, deciding how to
send the data to the LCD is most critical decision to be made for an LCD interface
41
www.final-yearproject.com | www.finalyearthesis.com
application.
Eight bit mode is best used when speed is required in an application and at least
ten I/O pins are available. Four bit mode requires a minimum of six bits. To wire
a microcontroller to an LCD in four bit mode, just the top four bits (DB4-7) are
written .
The "R/S" bit is used to select whether data or an instruction is being transferred
between the microcontroller and the LCD. If the Bit is set, then the byte at the
current LCD "Cursor" Position can be read or written. When the Bit is reset,
either an instruction is being sent to the LCD or the execution status of the last
instruction is read back (whether or not it has completed).
42
www.final-yearproject.com | www.finalyearthesis.com
The different instructions available for use with the 44780 are shown in the table
below:
R/S R/W D7 D6 D5 D4 D3 D2 D1 D0
Instruction/Description
14 13 12 11 10 9
7 Pins
1 Clear Display
1 SC RL *
1 DL N
A A
BF *
D D D
D D D D
D D D
D D D D
C B Enable Display/Cursor
43
www.final-yearproject.com | www.finalyearthesis.com
Power supply
Power supply unit provides 5V regulates power supply to the systems. It consists
of two parts namely,
1. Rectifier
44
www.final-yearproject.com | www.finalyearthesis.com
Rectifier
Here the step down transformer 230-0v/12v-0-12v and gives the secondary current up to
1000mA, to the Rectifier. The Transformer secondary is provided with a center tap.
Hence the voltage V1 and V2 are equal and are having a phase difference of 180 0. So it
is anode of Diode D1 is positive with respect to the center tap, the anode of the other
diode d2 will be negative with respect to the center tap.
During the positive half cycle of the supply D1 conducts and current flows through the
center tap D1 and load. During this period D2 will not conduct as its anode is at a
negative potential. During the negative half cycle of the supply voltage, the voltage on
the diode D2 will be positive and hence D2 conducts. The current flows through the
transformer winding, Diode D2 and load. It is to be noted that the current i1 and i2 are
flowing in the same direction in load.
The average of the two current i1 and i2 flows through the load producing a voltage drop,
which is the D.C. output voltage of the rectifier. Using capacitor filters the ripple in the
out waveform can be minimized. The voltage can be regulated by using monolithic IC
voltage regulators.
45
www.final-yearproject.com | www.finalyearthesis.com
Typical performance parameters for voltage regulators are line regulation, load
regulation, temperature stability and ripple rejection. Line regulation is defined as the
change in output voltage for a change in the input voltage and is usually expressed in
milli volts or as a percentage of Vo.
volts/C or parts per million (PPM/C). ripple rejection is the measure of a regulators
ability to reject ripple voltage. It is usually expressed in decibels. The smaller the values
of line regulation, load regulation and temperature stability the better the regulation.
47
www.final-yearproject.com | www.finalyearthesis.com
The above circuit is for driving the DC motor .in this circuit the MOSFET is used as
switch for DC motor with high current handling capacity. The transistor is used as switch
for MOSFET to on or off according to the micro controller control signals.
MOSFET
The metal oxide semiconductor field-effect transistor (MOSFET), is by far the most
common field-effect transistor in both digital and analog circuits. The MOSFET is
composed of a channel of n-type or p-typesemiconductor material (see article on
semiconductor devices), and is accordingly called an NMOSFET or a PMOSFET.
48
www.final-yearproject.com | www.finalyearthesis.com
(The 'metal' in the name is an anachronism from early chips where gates were metal;
modern chips use polysilicon gates, but are still called MOSFETs).
Usually the semiconductor of choice is silicon, but some chip manufacturers, most
notably IBM, have begun to use a mixture of silicon and germanium (SiGe) in MOSFET
channels. Unfortunately, many semiconductors with better electrical properties than
silicon, such as gallium arsenide, do not form good gate oxides and thus are not suitable
for MOSFETs. IGFET is a related term meaning insulated-gate field-effect transistor,
and is almost synonymous with "MOSFET", though it can refer to FETs with a gate
insulator that is not oxide.
The gate terminal is a layer of polysilicon (polycrystalline silicon; why polysilicon is
used will be explained below) placed over the channel, but separated from the channel by
a thin insulating layer of what was traditionally silicon dioxide, but more advanced
technologies used silicon oxynitride.
When a voltage is applied between the gate and source terminals,
the electric field generated penetrates through the oxide and creates a
so-called "inversion channel" in the channel underneath. The inversion channel is of the
same typep-type or n-typeas the source and drain, so it provides a conduit through
which current can pass. Varying the voltage between the gate and body modulates the
conductivity of this layer and makes it possible to control the current flow between drain
49
www.final-yearproject.com | www.finalyearthesis.com
and source.
If the output of the controller is low, the base current I is zero, thus providing voltage
drop less then 0.1V across the Ve junction, thus the transistor goes in to cut-off mode.
So the Ic is minimum and the voltage drop across the Vce junction is maximum. I.e. the
input to MOSFET is almost Vcc. So the MOSFET will conduct and stepper motor coil
get energized.
50
www.final-yearproject.com | www.finalyearthesis.com
For driving of motor coils, we used IRF540 MOSFET, which are having low on-state
resistance so that the dissipation is less, fast switching and low thermal resistance.
This MOSFET is driven by BC548 transistor. For each motor four MOSFET sections are
required.
BUZZER
The buzzer is a sound-producing module it will generate continuous sound when the +5V
is available. The transistor act as a switch and it follows the commands from MC. if the
base of the transistor is low the buzzer in off condition due to transistor in cutoff state,
and it will give sound when the base is in high logic due to transistor is in active state.
Resistor act as a current limiter for transistor.
51
www.final-yearproject.com | www.finalyearthesis.com
Speed Controllers
Introduction
The purpose of a motor speed controller is to take a signal representing the demanded
52
www.final-yearproject.com | www.finalyearthesis.com
speed, and to drive a motor at that speed. The controller may or may not actually measure
the speed of the motor. If it does, it is called a Feedback Speed Controller or Closed Loop
Speed Controller, if not it is called an Open Loop Speed Controller. Feedback speed
control is better, but more complicated, and may not be required for a simple robot
design.
Motors come in a variety of forms, and the speed controller's motor drive output will be
different dependent on these forms. The speed controller presented here is designed to
drive a simple cheap starter motor from a car, which can be purchased from any scrap
yard. These motors are generally series wound, which means to reverse them, they must
be altered slightly.
Below is a simple block diagram of the speed controller. We'll go through the important
parts block by block in detail.
53
www.final-yearproject.com | www.finalyearthesis.com
time as it is closed, the motor will see an average of 6 Volts, and will run more slowly
accordingly.
As the amount of time that the voltage is on increases compared with the amount of time
that it is off, the average speed of the motor increases.
This on-off switching is performed by power MOSFETs. A MOSFET (Metal-OxideSemiconductor Field Effect Transistor) is a device that can turn very large currents on
and off under the control of a low signal level voltage. For more detailed information, see
the dedicated chapter onMOSFETS)
The time that it takes a motor to speed up and slow down under switching conditions is
dependant on the inertia of the rotor (basically how heavy it is), and how much friction
and load torque there is. The graph below shows the speed of a motor that is being turned
on and off fairly slowly:
55
www.final-yearproject.com | www.finalyearthesis.com
You can see that the average speed is around 150, although it varies quite a bit. If the
supply voltage is switched fast enough, it wont have time to change speed much, and the
speed will be quite steady. This is the principle of switch mode speed control. Thus the
speed is set by PWM Pulse Width Modulation.
Inductors
Before we go on to discuss the circuits, we must first learn something about the action of
inductive loads, and inductors. Inductors do not allow the current flowing through them
to change instantly (in the same way capacitors do not allow the voltage across them to
56
www.final-yearproject.com | www.finalyearthesis.com
change instantly). The voltage dropped across an inductor carrying a current i is given by
the equation
where di/dt is the rate of change of the current. If the current is suddenly changed by
opening a switch, or turning a transistor off, the inductor will generate a very high
voltage across it. For example, turning off 100 Amps in 1 microsecond through a 100
microHenry inductor generates 10kV!
PWM frequency
The frequency of the resulting PWM signal is dependant on the frequency of the ramp
waveform. What frequency do we want? This is not a simple question. Some pros and
cons are:
Frequencies between 20Hz and 18kHz may produce audible screaming from the
speed controller and motors - this may be an added attraction for your robot!
RF interference emitted by the circuit will be worse the higher the switching
frequency is.Each switching on and off of the speed controller MOSFETs results
in a little power loss. Therefore the greater the time spent switching compared
with the static on and off times, the greater will be the resulting 'switching loss' in
the MOSFETs.
57
www.final-yearproject.com | www.finalyearthesis.com
The higher the switching frequency, the more stable is the current waveform in
the motors. This waveform will be a spiky switching waveform at low
frequencies, but at high frequencies the inductance of the motor will smooth this
out to an average DC current level proportional to the PWM demand. This
spikyness will cause greater power loss in the resistances of the wires, MOSFETs,
and motor windings than a steady DC current waveform.
This third point can be seen from the following two graphs. One shows the worst case onoff current waveform, the other the best case steady DC current waveform:
Both waveforms have the same average current. However, when we work out the power
dissipation in the stray resistances in our motor and speed controller, for the DC case:
Regeneration
In this circuit, energy can flow only one way, from the battery to the motor. When the
speed demand of the motor drops suddenly, the momentum of the robot will drive the
motor forwards, and the motor will act as a generator. In the circuit above, this power
cannot go anywhere. Although this isnt a problem, it is desirable that this power be put
back into the battery. This is called regenerative braking and needs some extra
components. The following circuit allows regenerative braking:
In this circuit, Q1 and D1 perform the same function as in the previous circuit. Q2 is
turned on in antiphase to Q1. This means that when Q1 is on, Q2 is off, and when Q1 is
59
www.final-yearproject.com | www.finalyearthesis.com
off, Q2 is on.
In this circuit, when the robot is slowing down, Q1 is off and the motor is acting as a
generator. The current can flow backwards (because the motor is generating) through Q2
which is turned on. When Q2 turns off, this current is maintained by the inductance, and
current will flow up through D2 and back into the battery. A graph of motor current as
the motor is slowing down is shown below:
If you are driving starter motors, or any type of series-field motor, regeneration is harder
to make work. For a motor to work as a generator, it must have a magnetic field,
generated by the field coil. In a series motor this is in series with the armature coil, so to
generate a voltage, a suitable current must be flowing. The current that will flow depends
on the load, which during regeneration is the battery, so it depends on how much the
60
www.final-yearproject.com | www.finalyearthesis.com
battery is charged up - how much current the battery will draw into it. Alternatively, a
dummy resistive load can be switched in at the approriate time, but this is all a little too
complicated for a robot!
Reversing
To reverse a DC motor, the supply voltage to the armature must be reversed, or the
magnetic field must be reversed. In a series motor, the magnetic field is supplied from the
supply voltage, so when that is reversed, so is the field, therefore the motor would
continue in the same direction.
We must switch either the field windings supply, or the
armature windings supply, but not both.
When the relays are in the position shown, current will flow vertically upwards through
the field coil. To reverse the motor the relays are switched over. Then the current will be
flowing vertically downwards through the field coil, and the motor will go in reverse.
61
www.final-yearproject.com | www.finalyearthesis.com
However, when the relays open to reverse the direction, the inductance of the motor
generates a very high voltage which will spark across the relay contact, damaging the
relay. Relays which can take very high currents are also quite expensive. Therefore this is
not a very good solution. A better solution is to use what is termed a full-bridge circuit
around either the field winding, or the armature winding. We will put it around the
armature winding and leave the field winding in series.
diodes, there is a fixed voltage across them - the voltage drop of a diode, about 0.8 volts.
This causes quite a large power dissipation (volts x amps). A feature of MOSFETs is that
they will conduct current from source to drain as well as drain to source, as long as the
Vgs is greater than 10-12 volts. Therefore, if the MOSFETs that are carrying reversed
current through their diodes are turned on, then they will dissipate a lot less heat. The
heat will be dissipated in the wires and the motor itself instead. This extra switching is
performed by the TD340 full bridge driver.
Analogue electronics
The PWM signal is generated by comparing a triangular wave signal with a DC signal.
The DC signal can range between the minimum and maximum voltagesof the triangle
wave.
63
www.final-yearproject.com | www.finalyearthesis.com
When the triangle waveform voltage is greater than the DC level, the output of the opamp swings high, and when it is lower, the output swings low. From the graph it can be
seen that if the DC level went higher, the pulses would get even thinner.
An example circuit for this is shown below. This uses a counter and weighted resistor
ladder to generate the triangle wave (in fact it will generate a sawtooth, but you'll still get
a PWM signal at the end of it). The actual resistor values which are unavailable (40k,
80k) can be made up with 20k resistors, or close approximations can be used, which may
distort the sawtooth somewhat, but this shouldn't matter too much.
The 74HC14 is a Schmitt input inverter, which is connected to act as a simple oscillator.
The frequency of oscillation is roughly
f = 1/(2.PI.R.C)
but it doesnt matter a great deal within a few tens of percent. This square wave generated
feeds the 74HC163 binary 4-bit counter.
64
www.final-yearproject.com | www.finalyearthesis.com
You may be able to tap into the PWM signal which comes out of the radio receiver
before it goes into the servo, and use this to drive the input to the MOSFET driver.
However, this gives you no choice of switching frequency. Alternatively, the
potentiometer can generate a voltage to feed into the PWM generator.
A more advanced method if you have a microcontroller on board the robot is to take the
PWM signal from the radio receiver and connect it to a timer input of the micro. The
microcontroller should be able to decode this waveform, and generate a proportional
analogue output value (if it has ADCs, or if an external ADC is fitted). Another even
65
www.final-yearproject.com | www.finalyearthesis.com
more advanced method is to send serial communications data through the radio channel.
The radio control handset will need to have a microcontroller in. The microcontroller
should read the pots and switches on the handset, and send suitable commands out of its
UART. This connects to the radio transmitter. At the receiver, the demodulated output is
sent to the robot's microcontroller's UART, and the data is decoded.
Current limiting
Current limiting is absolutely essential. If the motor is stalled, it can take huge currents
which would destroy the MOSFETs very quickly. The form of current limiting presented
here is to measure the current that the motor is taking, and if it is above a preset
threshold, turn the MOSFETs in the bridge off. If you have a microcontroller on board
which generates the PWM ratio, it would be an advantage if the software could detect the
over- current status, and reduce the PWM ratio by, say, 10%.
Some circuits you may see sample the current going through the main power MOSFET
by placing a much lower power MOSFET in parallel with it. This works OK, but the
problem is the actual limiting
current is dependant on the value of Rds(on) of the MOSFET. If Rds(on) was only half
the value we were expecting it to be, then twice as much current would flow before the
67
www.final-yearproject.com | www.finalyearthesis.com
limiting circuit took effect. Also the Rds(on) value depends very much on the current that
is passing through the MOSFET, and on the temperature. Any variation in Rds(on) will
change the limiting current.
The Rds(on) figure is quoted as a maximum value on the datasheet, but it is not a designsafe parameter.
This means that it is not within defined limits which are published on the
datasheet. For example, CMOS digital logic guarantees that the output voltage, Vo, will
be between Vcc-0.5v and Vcc, and that figure can be used to design circuits which rely
on that figure. However, with Rds(on), we only know that it will be between 0 and the
quoted value. We cannot rely on a minimum value of it, yet it is the minimum value
which controls the current limit. Therefore, using a separate shunt resistor is a much safer
method.
One problem with the circuit presented above is that you may want to provide a larger
current during acceleration, or in emergencies. This can be solved by disabling the
current limiting using a separate line from any onboard microcontroller, or by adding a
circuit which allows an over-current condition for just a short time. The amount of time
that this is allowed must be carefully calculated to prevent damage to the MOSFETs, and
must take into account the cooling system that you have provided.
An alternative to using the op-amp differential amplifier circuit used above is to use an
68
www.final-yearproject.com | www.finalyearthesis.com
As the load torque increases, the speed drops - we are following the line in the torque
speed characteristic from the left hand side towards the right, drooping down. This is the
same as the uncontrolled motor. The motor torque always equals the load torque when
the motor is running at constant speed (this follows from Newton's first law - "An object
69
www.final-yearproject.com | www.finalyearthesis.com
in motion tends to stay in motion with the same speed and in the same direction unless
acted upon by an unbalanced force." The motor torque and load torque must be balanced
out if the speed is not changing).
Let's call the current limit value iL and the equivalent torque value on the torque-current
graph at this current is TL. When the load torque exceeds TL, the motor can no longer
create an equal and opposite torque, and so the load will push the motor backwards in the
opposite direction - we are now following the line as it drops downwards into negative
speed.
Let's take an example; an opponent's robot is more powerful than ours (or his current
limit is set higher), and we are in a pushing match. As each pushes harder, our speed
controller reaches its current limit first. Our robot is now pushing at a constant force
(since the motor torque is now constant at its highest value).
As the opponent pushes harder, our wheels start to rotate backwards, and the pair of
robots accelerates backwards at a rate given by Newton's second law:
F=ma or a=F/m
where F is the difference between the forces of the two robots pushing, and m is the total
mass of the two robots.
70
www.final-yearproject.com | www.finalyearthesis.com
The speed demand is a DC voltage, which is fed to the PWM generator for motor A.
Drives motor A at a speed dependant on the demand voltage. The speed of motor A is
sampled using an optical encoder. This has a frequency output, which is proportional to
the speed of the motor.
If we assume that motor B is already running at some speed, then the optical encoder on
71
www.final-yearproject.com | www.finalyearthesis.com
its shaft will be producing a frequency also. The phase comparator compares the two
frequencies, effectively comparing the speeds of the two motors. Its output is a signal
which gets larger as the two input frequencies get further apart. If the two frequecies are
the same, it has a zero output.
The integrator adds the output of the phase comparator to whatever its output was before.
For example, if the integrator output was previously 3 volts, and its input is 0 volts, then
its output will be 3 volts. If its input changed to 1 volts, then its output would change to
2 volts.
Lets assume that motor B is running slower than motor A. Then the output of the phase
comparator will be positive, and the output of the integrator will start to rise.The speed
of motor B will then increase. If it increased to a speed greater than that of motor A, then
the output of the phase comparator would become negative, and the output of the
integrator would start to fall, thereby reducing the speed of motor B. In this manner, the
speed of motor B is kept the same as the speed of motor A, and the robot will go in a
straight line (as long as its wheels are the same size!).
This method can be expanded to use any number of wheels. One motor will always be the
directly driven one (in this case motor A), and the others will have their speed locked to
this one. Note that if the directly driven motor is faster, or more free-running, than the
others, then when it is driven at its fastest speed (the PWM signal is always ON), then the
other motors will never be able to keep up, and the robot will still swerve. It is best,
72
www.final-yearproject.com | www.finalyearthesis.com
therefore, to directly drive the slowest motor. An analogue feedback speed controller
such as this is quite difficult to make, and keep stable. It is easier to perform this function
using software in an onboard microcontroller.
CHAPTER-4
73
www.final-yearproject.com | www.finalyearthesis.com
RESULTS
The following steps are included in output of project:
74
www.final-yearproject.com | www.finalyearthesis.com
When the input is given through keypad steps will be incremented,this indicates the speed
of the motor as shown
75
www.final-yearproject.com | www.finalyearthesis.com
76
www.final-yearproject.com | www.finalyearthesis.com
CHAPTER-5
77
www.final-yearproject.com | www.finalyearthesis.com
APPLICATIONS
3.Easy to operate.
DISADVANTAGES
1.Torque is less
79
www.final-yearproject.com | www.finalyearthesis.com
CHAPTER-6
CONCLUSION
80
www.final-yearproject.com | www.finalyearthesis.com
Finally we conclude that this method is one of the best methods for controlling
the speed of the DC motor.
81
www.final-yearproject.com | www.finalyearthesis.com
FUTURE SCOPE
Speed control of DC motor by using microcontroller can deal with
robotics while moving their arms and joints.we can move their arms in
whatever directions we want to move it.By just changing the power
supply connections in the circuit we can move the arms of a robot in
any direction.
This will become the more important technique used in robotics and
plays a prominent role in their movement.within no time this will shows
their importance in the industrial area by using this technique with
changes in the circuit diagram.
82
www.final-yearproject.com | www.finalyearthesis.com
ALP PROGRAM
;
;>
;> TITLE
;> TARGET
: AT89C51
;> STARTED
: 28-02-2006
;>
;
;>
;>
INCLUDES
$MOD51
;>
;
83
www.final-yearproject.com | www.finalyearthesis.com
;>
;>
DISPLAY ENEBLE
DEN
;>
BIT
BIT
P2.7
BIT
P2.1
P1.0
- P1.1
BIT
KEY I/P 3
KEY3
- P2.1
- P1.0
KEY I/P 2
KEY2
;>
- P2.7
P2.0
KEY I/P 1
KEY1
;>
P2.6
BUZZER CONTROL
BUZ
;>
BIT
- P2.6
FFC1
;>
BIT
;>
P2.5
DISPLAY READ/WRITE
DRW
;>
BIT
- P2.5
P1.1
- P1.2
BIT
P1.2
;>
;
84
www.final-yearproject.com | www.finalyearthesis.com
FLAGS
:
BUSY_CHEK
BIT
00h
;>
;
;>
;>
VARIABLES
INC_VAL
DATA 30H
VAL1
DATA 31H
VAL2
DATA 32H
CNL
DATA 33H
CNH
DATA 34H
SPEED_CNL
DATA 35H
SPEED_CNH
DATA 36H
TCNT
DATA 37H
TCNT1
DATA 38H
;>
;
;>
;>
DEFINITIONS
85
www.final-yearproject.com | www.finalyearthesis.com
EQU
65H
PSET
EQU 0FFH
PRSET
EQU
00H
COM
EQU 0fch
DAT
EQU 0fdh
; data
EOL
EQU 0feh
; end of line
; command
;display headers
;>
;
;>
;>
VECTOR ADDRESESS:
ORG
0000H
ljmp
RESET
ORG
0003H
; ZCD 1 INTR
lcall INT_0
reti
ORG
clr
000BH
TR0
86
www.final-yearproject.com | www.finalyearthesis.com
FFC1
reti
ORG
001BH
push
ACC
push
PSW
setb
FFC1
mov
TL0, VAL2
mov
TH0, VAL1
setb
TR0
mov
TL1, #065H
mov
TH1, #0EDH
inc
TCNT
mov
mov
inc
mov
mov
TCNT1, #00H
mov
SPEED_CNL, CNL
A, TCNT
TCNT, #00H
TCNT1
A, TCNT1
87
www.final-yearproject.com | www.finalyearthesis.com
mov
SPEED_CNH, CNH
mov
CNL, #00H
mov
CNH, #00H
READ_VAL:
pop
PSW
pop
ACC
reti
;>
;
;>
RESET:
mov
P3, #0FFH
mov
P2, #PSET
mov
P1, #PSET
mov
P0, #PSET
mov
sp, #SPTR
mov
VAL1, #00H
mov
VAL2, #00H
88
www.final-yearproject.com | www.finalyearthesis.com
TCNT, #00H
mov
TCON, #05H
mov
TMOD, #11H
mov
IE, #8Bh
mov
TL1, #065H
mov
setb
; reset interrupts
TH1, #0EDH
TR1
mov
INC_VAL, #00h
mov
TL0, VAL1
mov
TH0, VAL2
clr
mov
BUZ
dptr, #INITIALISE
lcall MESSAGE
mov
dptr, #NAME
lcall MESSAGE
lcall DLY1
mov
dptr, #COLLEGE
lcall MESSAGE
lcall DLY1
89
www.final-yearproject.com | www.finalyearthesis.com
mov
dptr, #NAME1
lcall MESSAGE
lcall DLY1
mov
dptr, #NAME2
lcall MESSAGE
lcall DLY1
mov
dptr, #HODD
lcall MESSAGE
lcall DLY1
mov
dptr, #CLRSCR
lcall MESSAGE
mov
dptr, #SPD0
lcall MESSAGE
mov
SPEED_CNL, #00H
mov
SPEED_CNH, #00H
;>
90
www.final-yearproject.com | www.finalyearthesis.com
ljmp
MAIN
;>
;
;>
KBREAD:
jb
KEY1, HOLD_VAL_UP
SELECT_KEY1:
jnb
KEY1, SELECT_KEY1
setb
BUZ
lcall DLY
clr
BUZ
inc
INC_VAL
mov
A, INC_VAL
91
www.final-yearproject.com | www.finalyearthesis.com
A, #11H, HOLD_VAL_UP
INC_VAL, #10H
BUZ
lcall DLY
lcall DLY
lcall DLY
clr
BUZ
HOLD_VAL_UP:
jb
KEY2, HOLD_VAL_DOWN
SELECT_KEY2:
jnb
KEY2, SELECT_KEY2
setb
BUZ
lcall DLY
clr
BUZ
dec
INC_VAL
mov
cjne
mov
setb
A, INC_VAL
A, #0FFH, HOLD_VAL_DOWN
INC_VAL, #00H
BUZ
92
www.final-yearproject.com | www.finalyearthesis.com
BUZ
HOLD_VAL_DOWN:
jb
mov
KEY3, STOP_DC_MOT
INC_VAL, #00H
STOP_DC_MOT:
ret
;>
;
;>
INT_0:
push
ACC
push
PSW
cpl
BUZ
mov
TL0, #00H
mov
TH0, #60H
inc
mov
CNL
A, CNL
93
www.final-yearproject.com | www.finalyearthesis.com
DA
mov
CNL, A
jnc
SKIP_INC1
inc
CNH
mov
clr
A, CNH
C
DA
mov
CNH, A
SKIP_INC1:
pop
PSW
pop
ACC
RET
;>
;
;>
SELECT_SPEED:
mov
cjne
A, INC_VAL
A, #00H, NEXT_SPEED1
94
www.final-yearproject.com | www.finalyearthesis.com
VAL1, #00H
mov
VAL2, #00H
mov
DPTR, #SPD0
lcall MESSAGE
NEXT_SPEED1:
mov
A, INC_VAL
cjne
A, #01H, NEXT_SPEED5
mov
VAL1, #0F0H
mov
VAL2, #43H
mov
DPTR, #SPD1
; 75%
lcall MESSAGE
NEXT_SPEED5:
mov
cjne
A, INC_VAL
A, #02H, NEXT_SPEED6
mov
VAL1, #0F2H
mov
VAL2, #0FH
mov
DPTR, #SPD2
; 70%
lcall MESSAGE
NEXT_SPEED6:
mov
A, INC_VAL
95
www.final-yearproject.com | www.finalyearthesis.com
A, #03H, NEXT_SPEED7
mov
VAL1, #0F4H
mov
VAL2, #0D7H
mov
DPTR, #SPD3
; 65%
lcall MESSAGE
NEXT_SPEED7:
mov
cjne
A, INC_VAL
A, #04H, NEXT_SPEED8
mov
VAL1, #0F6H
mov
VAL2, #09FH
mov
; 60%
DPTR, #SPD4
lcall MESSAGE
NEXT_SPEED8:
mov
cjne
A, INC_VAL
A, #05H, NEXT_SPEED9
mov
VAL1, #0F7H
mov
VAL2, #067H
mov
DPTR, #SPD5
; 55%
lcall MESSAGE
NEXT_SPEED9:
96
www.final-yearproject.com | www.finalyearthesis.com
A, INC_VAL
A, #06H, NEXT_SPEEDA
mov
VAL1, #0F8H
mov
VAL2, #02FH
mov
DPTR, #SPD6
; 50%
lcall MESSAGE
NEXT_SPEEDA:
mov
cjne
A, INC_VAL
A, #07H, NEXT_SPEEDB
mov
VAL1, #0F8H
mov
VAL2, #0F7H
mov
DPTR, #SPD7
; 45%
lcall MESSAGE
NEXT_SPEEDB:
mov
cjne
A, INC_VAL
A, #08H, NEXT_SPEEDC
mov
VAL1, #0F9H
mov
VAL2, #0BFH
mov
DPTR, #SPD8
; 40%
lcall MESSAGE
97
www.final-yearproject.com | www.finalyearthesis.com
A, INC_VAL
A, #09H, NEXT_SPEEDD
mov
VAL1, #0FAH
mov
VAL2, #087H
mov
DPTR, #SPD9
; 35%
lcall MESSAGE
NEXT_SPEEDD:
mov
cjne
A, INC_VAL
A, #0AH, NEXT_SPEEDE
mov
VAL1, #0FBH
mov
VAL2, #047H
mov
DPTR, #SPD10
; 30%
lcall MESSAGE
NEXT_SPEEDE:
mov
cjne
A, INC_VAL
A, #0BH, NEXT_SPEEDF
mov
VAL1, #0FCH
mov
VAL2, #17H
mov
DPTR, #SPD11
; 25%
98
www.final-yearproject.com | www.finalyearthesis.com
A, INC_VAL
A, #0CH, NEXT_SPEED10
mov
VAL1, #0FCH
mov
VAL2, #0DFH
mov
DPTR, #SPD12
; 20%
lcall MESSAGE
NEXT_SPEED10:
mov
cjne
A, INC_VAL
A, #0DH, NEXT_SPEED11
mov
VAL1, #0FDH
mov
VAL2, #0A7H
mov
DPTR, #SPD13
; 15%
lcall MESSAGE
NEXT_SPEED11:
mov
cjne
A, INC_VAL
A, #0EH, NEXT_SPEED12
mov
VAL1, #0FEH
mov
VAL2, #06FH
mov
DPTR, #SPD14
; 10%
lcall MESSAGE
99
www.final-yearproject.com | www.finalyearthesis.com
A, INC_VAL
cjne
A, #0FH, NEXT_SPEED13
mov
VAL1, #0FFH
mov
VAL2, #037H
mov
DPTR, #SPD15
; 05%
lcall MESSAGE
NEXT_SPEED13:
mov
cjne
A, INC_VAL
A, #10H, NEXT_SPEED14
mov
VAL1, #0FFH
mov
VAL2, #0E7H
mov
DPTR, #SPD16
; 00%
lcall MESSAGE
NEXT_SPEED14:
ret
;>
;
;>
DLY:
100
www.final-yearproject.com | www.finalyearthesis.com
r4, #05H
GONE: mov
OUT: mov
IN:
djnz
r5, #3FH
r6, #00H
r6, IN
DLY1:
mov
r4, #1FH
GONE1: mov
OUT1: mov
IN1:
djnz
r5, #00H
r6, #00H
r6, IN1
101
www.final-yearproject.com | www.finalyearthesis.com
movc
; Clr accumulator
a, @a+dptr
inc
dptr
cjne
a, #EOL, COMD
pop
acc
ret
;
; If the data is not end of line goto comd
COMD:
cjne
a, #COM, DDATA
clr
DRS
clr
BUSY_CHEK
sjmp
MESSAGE1
DDATA:
cjne
a, #DAT, SENDIT
setb
DRS
setb
BUSY_CHEK
sjmp
MESSAGE1
102
www.final-yearproject.com | www.finalyearthesis.com
SENDIT:
mov
clr
;
p0, a
DRW
nop
setb
clr
sjmp
DEN
DEN
MESSAGE1
;>
;
;>
READY:
clr
mov
clr
setb
DEN
p0, #0ffh
setb
jb
DRS
DRW
WAIT:
clr
;
DEN
DEN
p0.7, WAIT
103
www.final-yearproject.com | www.finalyearthesis.com
DEN
jnb
BUSY_CHEK, NO_DRS_SET
setb
DRS
NO_DRS_SET:
ret
; return to message
;>
;
;>
DISP_LET:
lcall READY
setb
DRS
setb
BUSY_CHEK
mov
clr
P0, R7
DRW
nop
setb
clr
ret
DEN
DEN
;>
;
;>
104
www.final-yearproject.com | www.finalyearthesis.com
clr
DRS
clr
BUSY_CHEK
mov
clr
P0, R7
DRW
nop
setb
clr
DEN
DEN
ret
; return to message
;>
;
;>
;> ROM TABLE AREA
;>
INITIALISE:
db COM, 30h, 30h, 30h, 30h, 3ch, 06h, 0ch, 01h, EOL
NAME:
db COM, 80h, DAT, 'SPEED CONTROL OF', COM, 0C0H, DAT,' D.C. MOTOR ',
EOL
COLLEGE:
db COM, 80h, DAT, ' SRTIST
', EOL
NAME1:
105
www.final-yearproject.com | www.finalyearthesis.com
', EOL
', EOL
NAME2:
db COM, 80h, DAT, ' M.ARUN
HODD:
db COM, 80h, DAT, 'OUR HOD....
EOL
SPD0:
db COM, 80h, DAT, 'MOTOR OFF
EOL
SPD1:
db COM, 80h, DAT, 'STEP 1
SPD2:
SPD3:
SPD4:
SPD5:
SPD6:
SPD7:
106
www.final-yearproject.com | www.finalyearthesis.com
SPD8:
SPD9:
SPD10:
107
www.final-yearproject.com | www.finalyearthesis.com
BIBLIOGRAPHY
5. A.K.Ray
and
K.M.Bhurchandi.
Advanced
Micro
Processors
and
Peripherals, TMH,2000.
6. The 8051 Microcontroller and Embedded Systems Using Assembly and
C , second edition Muhammad Ali Mazidi., Janice Gillispie Mazidi, Rolin
D. McKinlay
Websites
1. www.nationalsemicondutor.com
2. www.atmel.com
3. www.wikipedia.org
4. www.stepperworld.com
5. www.discovercircuits.com
109
www.final-yearproject.com | www.finalyearthesis.com
110
www.final-yearproject.com | www.finalyearthesis.com