Вы находитесь на странице: 1из 110

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

INDEX
Page No
1. INTRODUCTION

01

2. WORKING PRINCIPLE

10

3. DESIGN PROCEDURE
3.1 Microcontroller

14

3.2 LCD

32

3.3 power supply

36

3.4 motor driving circuit

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

BIBLIOGRAPHY

CHAPTER-1
2
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

keeps the classical motor going in the proper direction. (See the diagrams below.)

Asimple DC electric motor. When the coil is powered, a magnetic field is


generated around the armature.
5
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

The left side of the armature is pushed away from the left magnet and
drawn toward the right, causing rotation.

The armature continues to rotate.

6
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

When the armature becomes horizontally aligned, the commutator reverses the direction
of current through the coil, reversing the magnetic field. The process then repeats

Wound field DC motor


The permanent magnets on the outside (stator) of a DC motor may be replaced by
electromagnets. By varying the field current it is possible to alter the speed/torque ratio
the motor. Typically the field winding will be placed in series (series wound) with the
armature winding to get a high torque low speed motor, in parallel (shunt wound)
the armature to get a high speed low torque motor, or to have a winding partly in parallel,
and partly in series (compound wound) for a balance that gives steady speed over a range
of loads. Further reductions in field current are possible to gain even higher speed but
correspondingly lower torque, called "weak field" operation.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

Continuous speed control of a universal motor running on AC is very


easily accomplished using a thyristor circuit while stepped speed control can be
accomplished using multiple taps on the field coil. Household blenders that advertise
many speeds frequently combine a field coil with several taps and a diode that can be
inserted in series with the motor (causing the motor to run on half-wave DC with half the
RMS voltage of the AC power line).
Unlike AC motors, universal motors can easily exceed one revolution per cycle of the
mains current. This makes them useful for appliances such as blenders, vacuum cleaners,
and hair dryers where high-speed operation is desired. Many vacuum cleaner and weed
trimmer motors will exceed 10,000 RPM, Dremel and other similar miniature grinders
9
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

CHAPTER-2

11
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Operation principle of Speed control of DC motor


In this system, a micro controller is interfaced with a LCD, Keypad and DC motor
driver. The Micro controller is used for controlling the DC motor by produsing the
PWM pulses. These pulse widths are produced according to the key pad register
values which are allotted by MC. The LCD is used for user interface. Linear
power supply is used to provide operating voltages (+5V & +12V).

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Block diagram of Speed control of DC motor

LCD

DC Motor
driver circuit
89C51 Micro
Controller

DC Motor

14
www.final-yearproject.com | www.finalyearthesis.com
Keypad

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Block diagram Description of Speed control of DC motor:


In this project at89C51 micro controller is used as speed controller. In this block
diagram we are using one keypad, LCD, one driver circuit for DC motor and
DCMotor.
Here the keypad is used for adjusting the speed of DC motor i.e. one key for
incrementing and one for decrementing.

15
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

CHAPTER-3

DESIGN PROCEDURE

8 bit micro controller


Looking back into the history of microcomputers, one would at first come across the
development of microprocessor i.e. the processing element, and later on the peripheral
16
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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:

4k ROM (EPROM on 8751)

128 byte RAM

UART

32 input-output port lines

Two, 16-bit timer/counters

Six interrupt sources and

On-chip clock oscillator and power on reset circuitry.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

The above circuit is the pin configuration of AT89c51.


19
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Internal Block diagram

20
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Fig 5.4 AT89C51 internal block diagram

Salient features

21
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

20-2F: The 16 bytes may be used as 128 bits of individually addressable


locations. These are extremely useful for bit oriented programs.

30- 7F: This area is used for temporary storage, pointers and stack. On
reset, the stack starts at 08 and gets incremented during use.

The list of special function registers along with their hex


addresses is given :
Addr.
80
81
82
83
88
89
8A
8B
8C
8D
90
98
99
A0
A8
B0
B8
D0
E0
F0

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

AT89C51 Serial port pins:


PIN
P3.ORXD
P3.ITXD
P3.2INTO
P3.3INT1
P3.4TO
P3.5T1
P3.6WR
P3.7RD

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

Writing the software


The 89C51 has been specifically developed for control applications. As mentioned
earlier, out of the 128 bytes of internal RAM, 16 bytes have been organized in such a way
that all the 128 bits associated with this group may be accessed bit wise to facilitate their
use for bit set/reset/test applications. These are therefore extremely useful for programs
involving individual logical operations. One can easily give example of lift for one such
application where each one of the floors, door condition, etc may be depicted by a single
hit. The 89C51 has instructions for bit manipulation and testing. Apart from these, it has
8-bit multiply and divide instructions, which may be used with advantage. The 89C51 has
short branch instructions for 'within page' and conditional jumps, short jumps and calls
within 2k memory space which are very convenient, and as such the controller seems to
favor programs which are less than 2k byte long. Some versions of 8751 EPROM devices
have a security bit which can be programmed to lock the device and then the contents of
25
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

32
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

Programming the Flash


The AT89C51 is normally shipped with the on-chip Flash memory array in the erased
state (that is, contents = FFH) and ready to be programmed. The programming interface
accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal.
The low-voltage programming mode provides a convenient way to program the
AT89C51 inside the users system, while the high-voltage programming mode is
compatible with conventional thirdparty Flash or EPROM programmers. The AT89C51
is shipped with either the high-voltage or low-voltage programming mode enabled. The
respective top-side marking and device signature codes are listed in the following table.

34
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

The AT89C51 code memory array is programmed byte-byte in either programming


mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory
must be erased using the Chip Erase Mode.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

Central Processing Unit


Let add 3 more memory locations to a specific block that will have a built in capability to
multiply, divide, subtract, and move its contents from one memory location onto another.
The part we just added in is called central processing unit (CPU). Its memory locations
are called registers.
37
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

A general purpose alphanumeric LCD, with two lines of 16 characters.


LCDs with a small number of segments, such as those used in digital watches and pocket
calculators, have a single electrical contact for each segment. An external dedicated
circuit supplies an electric charge to control each segment. This display structure is
unwieldy for more than a few display elements.
Small monochrome displays such as those found in personal organizers, or older laptop
screens have a passive-matrix structure employing supertwist nematic (STN) or doublelayer STN (DSTN) technology (DSTN corrects a color-shifting problem with STN).
row or column of the display has a single electrical circuit.

39
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

The pixels are addressed at a time by row and column addresses


This type of display is called a passive matrix
because the pixel must retain its state between refreshes without the benefit of a steady
electrical charge. As the number of pixels (and, correspondingly, columns and rows)
increases, this type of display becomes increasingly less feasible. Very slow response
times and poor contrast are typical of passive-matrix LCDs.

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.

The pins are wired as:


40
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Pins

Description

Ground

Vcc

Contrast Voltage

"R/S" _Instruction/Register Select

"R/W" _Read/Write LCD Registers

"E" Clock

7 - 14

Data I/O Pins

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

* Return Cursor and LCD to Home Position

1 ID S Set Cursor Move Direction

1 SC RL *

1 DL N

A A A A Move Cursor into CGRAM

A A

A A A A Move Cursor to Display

BF *

D D D

D D D D

Write a Character to the Display at the


Current Cursor Position

D D D

D D D D

Read the Character on the Display at the


Current Cursor Position

C B Enable Display/Cursor

* Move Cursor/Shift Display


* Set Interface Length

* Poll the "Busy Flag"

43
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Power supply

Power supply unit provides 5V regulates power supply to the systems. It consists
of two parts namely,

1. Rectifier

2. Monolithic voltage regulator

44
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Monolithic IC voltage regulator


A voltage regulator is a circuit that supplies a constant voltage regardless
of changes in load currents. Although voltage regulators can be designed using
op-amps, it is quicker and easier to use IC voltage regulators. Furthermore, IC voltage
regulators are versatile and relatively inexpensive and are available with features such as
programmable output, current/voltage boosting, internal short-circuit current limiting,
thermal shutdown and floating operation for high voltage applications.

The MC78XX/LM78XX/MC78XXA series of three terminal positive regulators are


available in the TO-220/D-PAK package and with several fixed output voltages, making
them useful in a wide range of applications. Each type employs internal current limiting,
thermal shut down and safe operating area protection, making it essentially indestructible.
If adequate heat sinking is provided, they can deliver over 1A output current. Although
designed primarily as fixed voltage regulators, these devices can be used with external
components to obtain adjustable voltages and currents.

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.

Temperature stability or average temperature coefficient of output voltage (TCVo) is the


change in output voltage per unit change in temperature and is expressed in either milli
46
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

DC Motor driver circuit

47
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

(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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

and source.

Operation of the circuit


When the output of the controller is high, the base current I flows in to base of the
transistor, thus providing voltage drop more then 0.7V across the Ve junction, thus the
transistor goes in to saturation mode. So the Ic is maximum and the voltage drop across
the Vce junction is zero. I.e. the input to MOSFET is zero. So the MOSFET will not
conduct and stepper motor coil will not energize.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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 CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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 CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Theory of DC motor speed control


The speed of a DC motor is directly proportional to the supply voltage, so if we reduce
the supply voltage from 12 Volts to 6 Volts, the motor will run at half the speed. How can
this be achieved when the battery is fixed at 12 Volts?
The speed controller works by varying the average voltage sent to the motor. It could do
this by simply adjusting the voltage sent to the motor, but this is quite inefficient to do. A
better way is to switch the motor's supply on and off very quickly. If the switching is fast
enough, the motor doesn't notice it, it only notices the average effect.
When you watch a film in the cinema, or the television, what you are actually seeing is a
series of fixed pictures, which change rapidly enough that your eyes just see the average
effect - movement. Your brain fills in the gaps to give an average effect.
Now imagine a light bulb with a switch. When you close the switch, the bulb goes on and
is at full brightness, say 100 Watts. When you open the switch it goes off (0 Watts). Now
if you close the switch for a fraction of a second, then open it for the same amount of
time, the filament won't have time to cool down and heat up, and you will just get an
average glow of 50 Watts.
This is how lamp dimmers work, and the same principle is
used by speed controllers to drive a motor. When the switch is closed, the motor sees 12
Volts, and when it is open it sees 0 Volts. If the switch is open for the same amount of
54
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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:

and for the switching case, the average power is


58
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

One method is to switch the field coil using relays:

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

The full bridge circuit


A full bridge circuit is shown in the diagram below. Each side of the motor can be
connected either to battery positive, or to battery negative. Note that only one MOSFET
on each side of the motor must be turned on at any one time otherwise they will short out
the battery and burn out!

Reducing the heat in the MOSFETs


When the MOSFETs in the diagrams above are on and current is flowing through them in
a top-to-bottom direction, they have a very low resistance and are dissipating hardly any
heat at all.
However, when the current is flowing bottom-to-top through the intrinsic
62
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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.

Generating PWM signals


The PWM signals can be generated in a number of ways. It is possible that your radio
receiver already picks up a PWM waveform from the handest transmitter. If there is a
microcontroller on the robot, this may be able to generate the waveform, although if you
have more than a couple of motors, this may be too much of a load on the
microcontrollers resources. Several methods are described below.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Interfacing to the radio control receiver


Many roboteers will be using commercial radio control sets. The receivers of these
generally connect to servos, which respond to the radio signal (which may also be
PWM)

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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%.

The shunt resistor


The shunt resistor R7 in the cicuit must be a very low value if we want large currents to
be able to flow, up to 100 Amps for example. It must not drop too much voltage, thereby
robbing power from the motor, and it must be capable of dissipating the power without
buring out when large currents are passed through. Some suitable resistors are available
from Farnell, code 156-267. These are still too large a resistance (and too low power), so
we can place eight in parallel. The power handling capabilty is then increased eightfold,
66
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

and the resistance decreased eightfold.An alternative is to use a piece of wire of an


appropriate thickness and length.
The V5 threshold voltage was chosen to set a current limit of 30 Amps.
The square wave is the PWM voltage and the slopey waveform is the drain
(motor) current. The spikey bits at the top of the slopey waveform is when the current
limiting is switching in and out.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

integrated current sense monitor IC.

Current limited torque speed characteristics


If a DC motor is being driven by a speed controller with current limiting active, what
happens to the torque speed characteristic graph.
The DC Motors page describes the normal motor torque speed graph, and how the torque
of a permanent magnet DC motor is proportional to the current. If the current is limited
however, the torque must also be limited, at the value coincident with the limited current
on the torque-current graph. The effect that this has on the torque speed graph is shown
below:

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Feedback Speed Control


To stop a robot swerving in an arc when you want it to go forwards, you need to have
feedback control of the motor speeds. This means that the actual speed of each wheel is
measured, and compared with all the other wheels. Obviously to go in a straight line, the
motor speeds must be equal. However, this does not necessarily mean that the speed
demand for each motor should be the same. The motors will have different amounts of
friction, and so a stiffer motor will require a higher speed demand to go as fast as a
more free-running motor.

A block diagram of an analogue feedback speed controller is shown below

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

RESULTS
The following steps are included in output of project:

When power is switched ON,LCD displays the output as shown.

74
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

When the input is given through keypad steps will be incremented,this indicates the speed
of the motor as shown

When the final step given from the keypad

75
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

Our Project Kit is shown below

76
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

CHAPTER-5

77
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

APPLICATIONS

1.In robotics for moving the arms.


2.Used in Tape Drivers.
3.Used in Bar Graphs indicated in Recorders.
ADVANTAGES

1.Low power consumption.


2.Cost is low.
78
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

3.Easy to operate.
DISADVANTAGES

1.Torque is less

79
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

CHAPTER-6

CONCLUSION
80
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

The project Speed Control of DC motor using microcontroller by using


PWM has been successfully designed and tested.
It is quite clear from the above discussion that Speed Control Of DC motor using
microcontroller by using PWM may be a comprehensive system that controls the
speed of a motor by giving instructions to the microcontroller to reduce the
manual work. The technology saves money too and gives a return on investment.
This system have a great deal in common with one another,12V is used in this
process of speed control of dc motor.Implemenation of this process is easy.Using
this technique,by changing some changes in the circuit we can implement this in
industries. So by using micro controller we control the speed of a DC motor using
MOSFET. By applying a PWM pulse to gate of the MOSFET, the speed of the
motor varies.We used an LCD for displaying the varying speed of the DC motor
and a keypad for varying the speed. If we press up or down key, micro controller
varies the duty cycle of the PWM accordingly so that the average power will vary
resulting variations in the speed.

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

ALP PROGRAM

;
;>
;> TITLE

: SPEED CONTROL OF DC MOTOR USING PWM

;> TARGET

: AT89C51

;> STARTED

: 28-02-2006

;>
;
;>
;>

INCLUDES

$MOD51
;>
;

83
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


;>
;> HARD WARE DETAILS

;>
;>

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

FET FIRING CONTROL PLS1 - P2.0

FFC1
;>

BIT

DISPLAY REG SELECT


DRS

;>

P2.5

DISPLAY READ/WRITE
DRW

;>

BIT

- P2.5

P1.1
- P1.2

BIT

P1.2

;>
;

84
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


;>
;>

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


SPTR

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


clr

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

cjne A, #46D, READ_VAL

mov

inc

mov

cjne A, #30D, READ_VAL

mov

TCNT1, #00H

mov

SPEED_CNL, CNL

A, TCNT

TCNT, #00H
TCNT1
A, TCNT1

87
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


;

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

; init stack pointer

88
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


mov

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


;
;>
MAIN:
lcall KBREAD
lcall SELECT_SPEED

ljmp

MAIN

;>
;
;>
KBREAD:

jb

; key board sub

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


cjne
mov
setb

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


lcall DLY
lcall DLY
lcall DLY
clr

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


clr

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


mov

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


cjne

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


mov
cjne

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


NEXT_SPEEDC:
mov
cjne

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


lcall MESSAGE
NEXT_SPEEDF:
mov
cjne

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


NEXT_SPEED12:
mov

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


mov

r4, #05H

GONE: mov
OUT: mov
IN:

djnz

r5, #3FH
r6, #00H

r6, IN

djnz r5, OUT


djnz r4, GONE
ret

DLY1:
mov

r4, #1FH

GONE1: mov
OUT1: mov
IN1:

djnz

r5, #00H
r6, #00H

r6, IN1

djnz r5, OUT1


djnz r4, GONE1
ret
;>
;
;>
MESSAGE:
push

; sub for sending charactors to display


acc

101
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


MESSAGE1:
lcall READY
clr

; Check weather display is ready

movc

; Clr accumulator
a, @a+dptr

; Load accumulator with the contents of dptr

inc

dptr

cjne

a, #EOL, COMD

pop

acc

ret

;
; If the data is not end of line goto comd

; if the data is end of line stop sending

COMD:

cjne

a, #COM, DDATA

clr

DRS

clr

BUSY_CHEK

sjmp

MESSAGE1

; if the data is not command goto data

; goto message again

DDATA:

cjne

a, #DAT, SENDIT

setb

DRS

setb

BUSY_CHEK

sjmp

MESSAGE1

; if the data is not data to be send goto comd

; goto message again

102
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

SENDIT:
mov
clr

;
p0, a

; place the data at port 1

DRW

nop
setb
clr
sjmp

DEN
DEN

; send enable strobe


;

MESSAGE1

; goto message again

;>
;
;>
READY:

; sub to check display busy

clr
mov

clr
setb

DEN
p0, #0ffh

setb
jb

; set port1 in read mode

DRS
DRW

WAIT:
clr

; disable display buffer

;
DEN
DEN
p0.7, WAIT

; send enable strobe


;
; if display is not send ready signal be in loop

103
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


clr

DEN

; disable display buffer

jnb

BUSY_CHEK, NO_DRS_SET

setb

DRS

NO_DRS_SET:
ret

; return to message

;>
;
;>
DISP_LET:
lcall READY

; Check weather display is ready

setb

DRS

setb

BUSY_CHEK

mov
clr

P0, R7

; place the data at port 1

DRW

nop
setb
clr
ret

DEN
DEN

; send enable strobe


;
; return to message

;>

;
;>

104
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


DISP_COM:
lcall READY

; Check weather display is ready

clr

DRS

clr

BUSY_CHEK

mov
clr

P0, R7

; place the data at port 1

DRW

nop
setb
clr

DEN

; send enable strobe

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

', COM, 0C0H, DAT,'

', EOL

NAME1:

105
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


db COM, 80h, DAT, 'PROJECT BY..

', COM, 0C0H, DAT,'P.KISHAN

', EOL

',COM, 0C0H, DAT,'K.HEMANTH

', EOL

NAME2:
db COM, 80h, DAT, ' M.ARUN
HODD:
db COM, 80h, DAT, 'OUR HOD....

', COM, 0C0H, DAT,'Mr.LACHI REDDY',

EOL
SPD0:
db COM, 80h, DAT, 'MOTOR OFF

', COM, 0C0H, DAT,'START OPERATION ',

EOL
SPD1:
db COM, 80h, DAT, 'STEP 1

@ 0100', COM, 0C0H, DAT,'-_______________', EOL

db COM, 80h, DAT, 'STEP 2

@ 0200', COM, 0C0H, DAT,'--______________', EOL

db COM, 80h, DAT, 'STEP 3

@ 0400', COM, 0C0H, DAT,'---_____________', EOL

db COM, 80h, DAT, 'STEP 4

@ 0600', COM, 0C0H, DAT,'----____________', EOL

db COM, 80h, DAT, 'STEP 5

@ 0800', COM, 0C0H, DAT,'-----___________', EOL

db COM, 80h, DAT, 'STEP 6

@ 1000', COM, 0C0H, DAT,'------__________', EOL

SPD2:

SPD3:

SPD4:

SPD5:

SPD6:

SPD7:

106
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


db COM, 80h, DAT, 'STEP 7

@ 1200', COM, 0C0H, DAT,'-------_________', EOL

db COM, 80h, DAT, 'STEP 8

@ 1400', COM, 0C0H, DAT,'--------________', EOL

db COM, 80h, DAT, 'STEP 9

@ 1600', COM, 0C0H, DAT,'---------_______', EOL

SPD8:

SPD9:

SPD10:

db COM, 80h, DAT, 'STEP 10 @ 1800', COM, 0C0H, DAT,'----------______', EOL


SPD11:
db COM, 80h, DAT, 'STEP 11 @ 1900', COM, 0C0H, DAT,'-----------_____', EOL
SPD12:
db COM, 80h, DAT, 'STEP 12 @ 2000', COM, 0C0H, DAT,'------------____', EOL
SPD13:
db COM, 80h, DAT, 'STEP 13 @ 2100', COM, 0C0H, DAT,'-------------___', EOL
SPD14:
db COM, 80h, DAT, 'STEP 14 @ 2200', COM, 0C0H, DAT,'--------------__', EOL
SPD15:
db COM, 80h, DAT, 'STEP 15 @ 2300', COM, 0C0H, DAT,'---------------_', EOL
SPD16:
db COM, 80h, DAT, 'STEP 16 @ 2400', COM, 0C0H, DAT,'----------------', EOL
CLRSCR:

107
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM


db COM, 01h, EOL
;>
;
;>
END

BIBLIOGRAPHY

1. kennedy,Electronic Communication Systems, McGraw-Hill Publ, 2001


2. D.Roy Chowdhury, Linear Integrated Circuits, New Age International (P)
Ltd., 2003
3. Kenneth J.Ayala,The 8051 MicroController,Penram International, Second
edition, 1997
4. Douglas V. Hall,Micro Processor and Interfacing, TMH, Second Edition.
108
www.final-yearproject.com | www.finalyearthesis.com

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

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

SPEED CONTROL OF DC MOTOR USING MICRO CONTROLLER BY USING PWM

110
www.final-yearproject.com | www.finalyearthesis.com

Вам также может понравиться