Professional Documents
Culture Documents
Group Members
Prateek Nepalia
Rahul Vyas
Pranay Thanvi
CERTIFICATE
This is to certify that the work which is being presented in the Major Report
entitled “Microcontroller Based Elevator System” submitted by Prateek Nepalia,
Rahul Vyas and Pranay Thanvi of B.Tech 8th semester (Final Year) of Electronics
and Communication Engineering in partial fulfillment for the award of degree of
Bachelor of Engineering is being a record of student’s work carried out by them
under my supervision and guidance.
Date:-
Place:- Jodhpur
PREFACE
As per the curriculum of RAJASTHAN TECHNICAL UNIVERSITY IV Year
Bachelor’s Degree in Technology,we completed our major project entitled
“Microcontroller Based Elevator System”.
This is our Project which contains a detailed description of the Microcontroller
used in Elevators. While Completing this project we gained lot about the
………….. which is completely new and challenging field for a student of
electronics.
The major sources of material for preparing this report to e-books and other
internet tutorials. This Project report is initiated by providing a general
introduction to the project and the components and fundamentals implemented to
develop the same. After that a detailed view of the remote control circuit and the
hardware developed follows.
INDEX
S.No. Chapter Page No.
1 Introduction
1.1 Electric Motor
1.2 Principle
1.3 Comparison Of DC Motor
2 Motor Speed Control
2.1 Speed Control
2.2 Basic Principle
2.3 PWM Speed Control
2.4 Speed Encoders
2.5 Inverted Pulse Width Modulation
3 Basic Circuit Component
3.1 Capacitor
3.1.1 Energy Storage
3.1.2 Current-voltage relation
3.1.3 DC circuits
3.1.4 AC circuits
3.1.5 Capacitor types
3.1.6 Dielectric Materials
3.1.7 Electrolytic capacitors
3.2 Resistor
3.2.1 Resistor marking
3.2.2 Four-Band resistors
3.3 Voltage Regulator IC 7805
3.4 Terminal Box
3.5 Power Switch
3.6 Reset Switch
3.7 Liquid Crystal Display
3.7.1 LCD Connector
3.8 Motor Driver IC L293D
3.9 Microcontroller(AT Mega32)
3.9.1 PIN Description
4 Designing of PCB
5 Circuit Description
6 Circuit Operation
7 Errors and Precaution
8 Conclusion and future expansion
9 Appendix- coding
10 References and Bibliography
CHAPTER-1
INTRODUCTION
1.1 Electric Motor
An electric motor uses electrical energy to produce mechanical energy, very typically through
the interaction of magnetic fields and current-carrying conductors. The reverse process,
producing electrical energy from mechanical energy, is accomplished by a generator or dynamo.
Many types of electric motors can be run as generators, and vice versa. For example a
starter/generator for a gas turbine or Traction motors used on vehicles often perform both tasks.
Electric motors are found in applications as diverse as industrial fans, blowers and pumps,
machine tools, household appliances, power tools, and disk drives. They may be powered by
direct current (e.g., a battery powered portable device or motor vehicle), or by alternating current
from a central electrical distribution grid. The smallest motors may be found in electric
wristwatches. Medium-size motors of highly standardized dimensions and characteristics provide
convenient mechanical power for industrial uses. The very largest electric motors are used for
propulsion of large ships, and for such purposes as pipeline compressors, with ratings in the
millions of watts. Electric motors may be classified by the source of electric power, by their
internal construction, by their application, or by the type of motion they give.
The brushed Dc motor generates torque directly from Dc power supplied to the motor by using
internal commutation, stationary permanent magnets and rotating electrical magnets. It works on
the principle of Lorentz force , which states that any current carrying conductor placed within an
external magnetic field experiences a torque or force known as Lorentz force. Advantages of a
brushed DC motor include low initial cost ,high reliability and simple control of motor speed.
CHAPTER-2
MOTOR SPEED CONTROL
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.
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. 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.
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 won’t 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.
By controlling analog circuits digitally, system costs and power consumption can be drastically
reduced. What’s more , many microcontrollers and DSP’s already include on-chip PWM
controllers , making implementation easy.
In a nutshell, PWM is a way of digitally encoding analog signal levels. Through the use of high
resolution counters , the duty cycle of a square wave is modulated to encode a specific analog
signal level. The PWM signal is either fully on or fully off. The voltage or current source is
supplied to the analog load by means of a repeating series of on and off pulses. The on-off time
during within DC supply is applied to the load, and the off-time is period during which that
supply is switched off. Given a sufficient bandwidth , any analog value can be encoded with
PWM.
One of the advantages of PWM is that the signal remains digital all the way from the processor
to the controlled system; no digital-to –analog conversion is necessary. By keeping the signal
digital, noise effects are minimized. Noise can only affect a digital signal if it is strong enough to
change a logic-1 to a logic-0 or vice versa.
To control the speed of a d.c. motor we need a variable voltage d.c. power source. However if
you take a 12V motor and switch on the power to ot, the motor will start to speed up: motors do
not respond so it will take small time to reach full speed. If we switch the power off sometime
before the motor reaches full speed, then the motor will start to slow down.If we switch the
power on and off quickly enough , the motor will run at some speed part way between zero and
full speed. This is exactly what a PWM Controller does: it switches the motor on in a series of
pulses. To control the motor speed it varies the width of the pulses – hence Pulse Width
Modulation.
To perform the same function as described above in software requires that the software has
digital representation of the speed of each wheel, and can finely control the width of the PWM
signal sent to a wheel .To get the speed of each wheel , an optical encoder must be used as in the
analogue method, but the output of t must be sent to the microcontroller. This is achieved using a
counter, clocked by the speed controller , which the microcontroller can read and can clear. At
regular intervals, the microcontroller must read the counter then clear it. The interval depends on
the maximum speed of the robot , the diameter of the wheel ,the number of slots in the speed
encoders disc and the number of bits of the counter.
In fast PWM mode, the compare unit allows generation of PWM waveforms on the CO pin.
Setting the COM2:0 bits to 2 will produce a non – inverted PWM and an inverted PWM output
can be generated by setting the COM21:0to 3 .The actual OC2 value will only be visible on the
port pin if the data direction for the port is set asoutput.The PWM waveform is generated by
setting (or clearing) the OC2 Register at the compare match between OCR2 and TCNT, and (or
setting) the OC2 Register at the timer clock cycle the counter (changes from MAX to BOTTO).
The extreme value for the OCR2 Register represent special cases when generating a PWM
waveform output in the fast PWM mode. If the OCR2 is set equal to BOTTOM, the output will
be a narrow spike for each MAX+1 timer clock cycle. Setting the ORC2 equal to MAX will
result in a constantly high or low output (depending on the polarity of the output set by the
COM21:0 bits.)
A Frequency (with 50% duty cycle) waveform output in fast PWM mode can be achieved by
setting OC2 o toggle its logical level on each compare match (COM21:0=1). The waveform
generated will have maximum frequency of foc2 = fclk_I/O/2 when OVR2 is set to zero.This
feature is similar to the OC2 toggle in CTC mode, expect the double buffer feature of the output
compare unit is enable in the fast PWM mode.
CHAPTER-3
BASIC CIRCUIT COMPONENT
3.1 Capacitor
Capacitors are widely used in electronic circuits to block direct current while allowing
alternating current to pass, to filter out interference, to smooth the output of power supplies, and
for many other purposes. They are used in resonant circuits in radio frequency equipment to
select particular frequencies from a signal with many frequencies.
Sometimes charge buildup affects the mechanics of the capacitor, causing the capacitance to
vary. In this case, capacitance is defined in terms of incremental changes:
In SI units, a capacitance of one farad means that one coulomb of charge on each conductor
causes a voltage of one volt across the device.[10]
Work must be done by an external influence to move charge between the conductors in a
capacitor. When the external influence is removed, the charge separation persists and energy is
stored in the electric field. If charge is later allowed to return to its equilibrium position, the
energy is released. The work done in establishing the electric field, and hence the amount of
energy stored, is given by:[11]
The current i(t) through a component in an electric circuit is defined as the rate of flow of the
charge q(t) that has passed through it. Physical charges cannot pass through the dielectric layer of
a capacitor, but rather build up in equal and opposite quantities on the electrodes: as each
electron accumulates on the negative plate, one leaves the positive plate. Thus the accumulated
charge on the electrodes is equal to the integral of the current, as well as being proportional to
the voltage (as discussed above). As with any antiderivative, a constant of integration is added to
represent the initial voltage v (t0). This is the integral form of the capacitor equation,[12]
Taking the derivative of this, and multiplying by C, yields the derivative form,[13]
The dual of the capacitor is the inductor, which stores energy in the magnetic field rather than the
electric field. Its current-voltage relation is obtained by exchanging current and voltage in the
capacitor equations and replacing C with the inductance L.
3.1.3 DC circuits
A series circuit containing only a resistor, a capacitor, a switch and a constant DC source of
voltage V0 is known as a charging circuit.[14] If the capacitor is initially uncharged while the
switch is open, and the switch is closed at t = 0, it follows from Kirchhoff's voltage law that
At t = 0, the voltage across the capacitor is zero and the voltage across the resistor is V0. The
initial current is then i (0) =V0 /R. With this assumption, the differential equation yields
3.1.4 AC circuits
Impedance, the vector sum of reactance and resistance, describes the phase difference and the
ratio of amplitudes between sinusoidally varying voltage and sinusoidally varying current at a
given frequency. Fourier analysis allows any signal to be constructed from a spectrum of
frequencies, whence the circuit's reaction to the various frequencies may be found. The reactance
and impedance of a capacitor are respectively
where j is the imaginary unit and ω is the angular velocity of the sinusoidal signal. The - j phase
indicates that the AC voltage V = Z I lags the AC current by 90°: the positive current phase
corresponds to increasing voltage as the capacitor charges; zero current corresponds to
instantaneous constant voltage, etc.
Note that impedance decreases with increasing capacitance and increasing frequency. This
implies that a higher-frequency signal or a larger capacitor results in a lower voltage amplitude
per current amplitude—an AC "short circuit" or AC coupling. Conversely, for very low
frequencies, the reactance will be high, so that a capacitor is nearly an open circuit in AC
analysis—those frequencies have been "filtered out".
Practical capacitors are available commercially in many different forms. The type of internal
dielectric, the structure of the plates and the device packaging all strongly affect the
characteristics of the capacitor, and its applications.
Most types of capacitor include a dielectric spacer, which increases their capacitance. These
dielectrics are most often insulators. However, low capacitance devices are available with a
vacuum between their plates, which allows extremely high voltage operation and low losses.
Variable capacitors with their plates open to the atmosphere were commonly used in radio tuning
circuits. Later designs use polymer foil dielectric between the moving and stationary plates, with
no significant air space between them.
In order to maximize the charge that a capacitor can hold, the dialectric material needs to have as
high a permittivity as possible, while also having as high a breakdown voltage as possible.
Several solid dielectrics are available, including paper, plastic, glass, mica and ceramic materials.
Paper was used extensively in older devices and offers relatively high voltage performance.
However, it is susceptible to water absorption, and has been largely replaced by plastic film
capacitors. Plastics offer better stability and aging performance, which makes them useful in
timer circuits, although they may be limited to low operating temperatures and frequencies.
Ceramic capacitors are generally small, cheap and useful for high frequency applications,
although their capacitance varies strongly with voltage and they age poorly. They are broadly
categorized as class 1 dielectrics, which have predictable variation of capacitance with
temperature or class 2 dielectrics, which can operate at higher voltage. Glass and mica capacitors
are extremely reliable, stable and tolerant to high temperatures and voltages, but are too
expensive for most mainstream applications. Electrolytic capacitors and super capacitors are
used to store small and larger amounts of energy, respectively, ceramic capacitors are often used
in resonators, and parasitic capacitance occurs in circuits wherever the simple conductor-
insulator-conductor structure is formed unintentionally by the configuration of the circuit layout.
Capacitor materials. From left: multilayer ceramic, ceramic disc, multilayer polyester film,
tubular ceramic, polystyrene, metalized polyester film, aluminum electrolytic. Major scale
divisions are in centimeters.
3.1.7 Electrolytic capacitors
Electrolytic capacitors are use an a aluminum or tantalum plate with an oxide dielectric layer.
The second electrode is a liquid electrolyte, connected to the circuit by another foil plate.
Electrolytic capacitors offer very high capacitance but suffer from poor tolerances, high
instability, gradual loss of capacitance especially when subjected to heat, and high leakage
current. Poor quality capacitors may leak electrolyte, which is harmful to printed circuit boards.
The conductivity of the electrolyte drops at low temperatures, which increases equivalent series
resistance. While widely used for power-supply conditioning, poor high-frequency
characteristics make them unsuitable for many applications. Electrolytic capacitors will self-
degrade if unused for a period (around a year), and when full power is applied may short circuit,
permanently damaging the capacitor and usually blowing a fuse or causing arcing in rectifier
tubes. They can be restored before use (and damage) by gradually applying the operating
voltage, often done on antique [[vacuum tube] equipment over a period of 30 minutes by using a
variable transformer to supply AC power. Unfortunately, the use of this technique may be less
satisfactory for some solid state equipment, which may be damaged by operation below its
normal power range, requiring that the power supply first be isolated from the consuming
circuits. Such remedies may not be applicable to modern high-frequency power supplies as these
produce full output voltage even with reduced input.
Tantalum capacitors offer better frequency and temperature characteristics than aluminum, but
higher dielectric absorption and leakage.[21] OS-CON (or OC-CON) capacitors are a polymerized
organic semiconductor solid-electrolyte type that offer longer life at higher cost than standard
electrolytic capacitors.
3.2 Resistor
A resistor is a two-terminal electronic component that produces a voltage across its terminals
that is proportional to the electric current passing through it in accordance with Ohm's law:
V = IR
Resistors are elements of electrical networks and electronic circuits and are ubiquitous in most
electronic equipment. Practical resistors can be made of various compounds and films, as well as
resistance wire (wire made of a high-resistivity alloy, such as nickel/chrome).
The primary characteristics of a resistor are the resistance, the tolerance, maximum working
voltage and the power rating. Other characteristics include temperature coefficient, noise, and
inductance. Less well-known is critical resistance, the value below which power dissipation
limits the maximum permitted current flow, and above which the limit is applied voltage. Critical
resistance is determined by the design, materials and dimensions of the resistor.
Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits. Size,
and position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.
Fig.3.2 Resistors
Most axial resistors use a pattern of colored stripes to indicate resistance. Surface-mount resistors
are marked numerically, if they are big enough to permit marking; more-recent small sizes are
impractical to mark. Cases are usually tan, brown, blue, or green, though other colors are
occasionally found such as dark red or dark gray.
Early 20th century resistors, essentially uninsulated, were dipped in paint to cover their entire
body for color coding. A second color of paint was applied to one end of the element, and a color
dot (or band) in the middle provided the third digit. The rule was "body, tip, dot", providing two
significant digits for value and the decimal multiplier, in that sequence. Default tolerance was
±20%. Closer-tolerance resistors had silver (±10%) or gold-colored (±5%) paint on the other end.
Four-band identification is the most commonly used color-coding scheme on resistors. It consists
of four colored bands that are painted around the body of the resistor. The first two bands encode
the first two significant digits of the resistance value, the third is a power-of-ten multiplier or
number-of-zeroes, and the fourth is the tolerance accuracy, or acceptable error, of the value. The
first three bands are equally spaced along the resistor; the spacing to the fourth band is wider.
Sometimes a fifth band identifies the thermal coefficient, but this must be distinguished from the
true 5-color system, with 3 significant digits.
The voltage regulators employ built-in the current limiting, thermal shutdown and safe operating
area protection which makes them virtually immune to damage from output overload.7805 is a
three terminal positive voltage regulator.With adequate heat sinking , it can deliver an excess of
0.5 A output current. Typical application would include local(on-card)regulators which can
eliminated the noise and degraded performance associated with single point regulation.
7805 Regulator come from the 78xx family of self-contained fixed linear voltage regulator
integrated circuit.The 78xx family is a very popular choice for many electronic circuits which
require a regulated power supply, due to their ease of use and relative cheapness.When
specifying individual ICs within this family , the xx is replaced with two digit number , which
indicate the output voltage the particular device is designed to provide (for example, the 7805
voltage regulator has a 5 volt output, while the 7812 produce the 12 volts).The 78xx line are
positive voltage regulator, meaning that they are designed to produce a voltage that is positive
relative to a common ground.There is a related line of 79xx device which are complementary
negative voltage regulators.78xx and 79xx ICs can be used in combination to provide supply
voltage in the same circuit if necessary.
An enclosure which includes, mounts, and protects one or more terminals or terminal boards; it
may include a cover and such accessories as mounting hardware, brackets, locks, and conduit
fittings. Terminal Box(2 Pin) is used here to connect the 12V supply (battery/battery eliminator)
to provide to the circuit.
Power switch used here is a push to ON PCB mount switch to switch ON and OFF
the power supply for microcontroller.
Reset Switch is used to reset the microcontroller switch. It is a PCB mount switch.
A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light
modulating properties of liquid crystals (LCs). LCs do not emit light directly.
They are used in a wide range of applications including: computer monitors, television,
instrument panels, aircraft cockpit displays, signage, etc. They are common in consumer devices
such as video players, gaming devices, clocks, watches, calculators, and telephones. LCDs have
displaced cathode ray tube(CRT) displays in most applications. They are usually more compact,
lightweight, portable, and less expensive. They are available in a wider range of screen sizes than
CRT and other flat panel displays.
LCDs are more energy efficient and offer safer disposal than CRTs. Its low electrical power
consumption enables it to be used in battery-powered electronic equipment. It is an
electronically-modulated optical device made up of any number of pixels filled with liquid
crystals and arrayed in front of a light source (backlight) or reflector to produce images in colour
or monochrome. The earliest discovery leading to the development of LCD technology, the
discovery of liquid crystals, dates from 1888. By 2008, worldwide sales of televisions with LCD
screens had surpassed the sale of CRT units.
LCDs with a small number of segments, such as those used in digital watches and pocket
calculators, have individual electrical contacts 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 super-twisted nematic (STN) or double-layer STN
(DSTN) technology—the latter of which addresses a colour-shifting problem with the former—
and colour-STN (CSTN)—wherein colour is added by using an internal filter. Each row or
column of the display has a single electrical circuit. The pixels are addressed one at a time by
row and column addresses. This type of display is called passive-matrix addressed 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 less feasible. Very slow response times and poor contrast are typical of passive-matrix
addressed LCDs.
High-resolution color displays such as modern LCD computer monitors and televisions use an
active matrix structure. A matrix of thin-film transistors (TFTs) is added to the polarizing and
color filters. Each pixel has its own dedicated transistor, allowing 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 addressed displays look "brighter" and "sharper" than passive-matrix
addressed displays of the same size, and generally have quicker response times, producing much
better images.
The 16 pin male header at left top is standard HD44780LCD module compatible connector.Just
fix any standard HD44780LCD module to control it through AVR.The connections to the
microcontroller and LCD are as below
a) RS-PB.0.
b) RW-PB.1
c) EN-PB.3
d) D0-PB.4
e) D1-PB.5
f) D2-PB.6
g) D3-PB.7
h) Brightness control potentiometer is also provided to adjust brightness of LCD.
i) Module
j) Remove the LCD to use there pins as normal I/O pins.
Motor Drivers
GND Ground.
Port A (PA7..PA0) Port A serves as the analog inputs to the A/D Converter. Port A also serves
as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide internal
pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive
characteristics with both high sink and source capability. When pins PA0 to PA7 are used as
inputs and are externally pulled low, they will source current if the internal pull-up resistors are
activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock
is not running.
Port B (PB7..PB0) PortB is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port B output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port B pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
• SS – Port B, Bit 4
SS: Slave Select input. When the SPI is enabled as a Slave, this pin is configured as an input
regardless of the setting of DDB4. As a Slave, the SPI is activated when this pin is driven low.
When the SPI is enabled as a Master, the data direction of this pin is controlled by DDB4. When
the pin is forced by the SPI to be an input, the pull-up can still be controlled by the PORTB4 bit.
Port C (PC7..PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port C output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port C pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the
pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be activated even if a reset
occurs. The TD0 pin is tri-stated unless TAP states that shift out data are entered.
Port D (PD7..PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
RESET Reset Input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a
reset.
XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock operating
circuit.
AVCC A VCC is the supply voltage pin for Port A and the A/D Converter. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter.
AREF AREF is the analog reference pin for the A/D Converter.
Configuring the Pin Each port pin consists of three register bits: DDxn, PORTxn, and PINxn.
the DDxn bits are accessed at the DDRx I/O address, the PORTxn bits at the PORTx I/O
address, and the PINxn bits at the PINx I/O address. The DDxn bit in the DDRx Register selects
the direction of this pin. If DDxn is written logic one, Pxn is configured as an output pin. If
DDxn is written logic zero, Pxn is configured as an input pin. If PORTxn is written logic one
when the pin is configured as an input pin, the pull-up resistor is activated. To switch the pull-up
resistor off, PORTxn has to be written logic zero or the pin has to be configured as an output pin.
The port pins are tri-stated when a reset condition becomes active, even if no clocks are running.
If PORTxn is written logic one when the pin is configured as an output pin, the port pin is driven
high (one). If PORTxn is written logic zero when the pin is configured as an output pin, the port
pin is driven low (zero). When switching between tri-state ({DDxn, PORTxn} = 0b00) and
output high ({DDxn, PORTxn} = 0b11), an intermediate state with either pull-up enabled
({DDxn, PORTxn} = 0b01) or output low ({DDxn, PORTxn} = 0b10) must occur. Normally, the
pull-up enabled state is fully acceptable, as a high-impudent environment will not notice the
difference between a strong high driver and a pull-up. If this is not the case, the PUD bit in the
SFIOR Register can be set to disable all pull-ups in all ports.
Pin Description
1 (XCK/T0) PB0
2 (T1) PB1
3 (INT2/AIN0) PB2
4 (OC0/AIN1) PB3
5 (SS) PB4
6 (MOSI) PB5
7 (MISO) PB6
8 (SCK) PB7
9 RESET
10 VCC
11 GND
12 XTAL2
13 XTAL1
14 (RXD) PD0
15 (TXD) PD1
16 (INT0) PD2
17 (INT1) PD3
18 (OC1B) PD4
19 (OC1A) PD5
20 (ICP1) PD6
21 (OC2) PD7
22 (SCL) PC0
23 (SDA) PC1
24 (TCK) PC2
25 (TMS) PC3
26 (TDO) PC4
27 PC5 (TDI)
28 PC6 (TOSC1)
29 PC7 (TOSC2)
30 AVCC
31 GND
32 AREF
33 PA7 (ADC7)
34 PA6 (ADC6)
35 PA5 (ADC5)
36 PA4 (ADC4)
37 PA3 (ADC3)
38 PA2 (ADC2)
39 PA1 (ADC1)
40 PA0 (ADC0)
CHAPTER-4
DESIGNING OF PCB
Steps of circuit Design
Stage-1:Initial Stage
In this stage a rough sketch is prepared deciding the components and their connection.
This rough sketch is further modified and a final layout is decided which is to be implemented
using Eagle Software, Commonly used for designing the circuit . In eagle software first the
schematics layout is prepared selecting the desired component. The Schematic Editor without
Layout Editor is applicable for drawing electrical wiring diagrams(connection scheme, contact
plans….).The Schematic editor comes , as well as the layout editor ,with the full library editor
for designing. The Schematic layout is switched to board with a option “Switch to Board”
provided in the File Menu. The next step is to arrange the component on the board according to
the circuit. Then we use the option of DRC for setting the wire width and other connection. The
circuit is optimized accordingly then by removing the jumpers and replacing the components by
its leg size dot plus space for soldering. Thus the figure-4.2 shows the PCB layout with all the
component, connection and jumpers.
CHAPTER – 5
5.1 CIRCUIT DESCRIPTION
The circuit is given 12v supply with the help of terminal box. To reduce the spikes and to filter
the incoming 12V de Voltage the it is passed through a filter circuit which comprises of one
Electrolytic Capacitor (1000, µF, 25V) and two ceramic capacitor (104). A switch is provided at
the input which when pressed indicate the supply by glowing a LED in series with a resistance.
The Micro Controller (AT mega 32), used in this project works at a particular voltage of 5V.To
provide this voltage to Micro controller we use a voltage regulator IC 7805.It has there terminals
which are input, output and ground .12V input DC voltage is provided at the input terminals of
the IC 7805 and this IC regulates the voltage of 5v which is required for the operation of the
Micro Controller. This 5V is provided is the Vcc terminal of the microcontroller and the Ground
is provided at GND terminal as show in the circuit diagram .A reset switch is provided to reset
the microcontroller to the initial state. A 16x2LCD display is connected at the PORT B of the
Micro Controller to display the speed and the direction of the motor with the help of the program
burn into Micro Controller .The program is fed into the Micro Controller with the help of
Robotic USB Burner and software AVR studio. A 2x5 Key Pad is provided at the Port C for
controlling the speed and direction of motor. The output of the key pad is provided to the motor
driver IC L293D which is used to drive the motor this L293D gets the input signal in from 0 and
1 from the controller and drive the motor in either direction i.e. Forward or Reverse. The speed
of the motor is controller with the principle of pulse Width Modulation Using Optical Encoder
and Decoder. The operating voltage of motor is 12 V DC which is provided directly from the
input to the motor through a switch. From this circuit we can simultaneously drive two motors if
required.
The figure below show the circuit diagram depicting various components of the project and their
inter Connections.
5.2 CIRCUIT OPERATION
The 12V input DC supply used for staring the circuit is provided through the terminal box and is
filtered through the filter circuit comprising capacitors. The input is indicated through LED in
series with the resistance .As the micro Controller works on 5V, the voltage is lowered down
with the help of 7805 voltage regulator IC.The Micro controller provides digital signals for the
operations of LCD and the motor .The LCD and the LED in the LCD are provided with their
respective VCC and GND .Program is burn in to the Micro controller with the help of AVR
Studio Software and Robotic USB Programmer .The respective programs for LCD Display,
Direction and Speed Control of Motor are fed in to the Micro controller .Firstly the LCD is
initialize and a string is displayed on the LCD panel. The next step is to register the data
direction with the help data direction register which is done in Hexa-Decimal Code. This is used
to register 1 for output port and 0 for output port. Initially the LCD screen is cleared and it
display a string “LCD IS READY” and with a delay of 2000ms it display a string “PRESS ANY
KEY” and further it again clear the LCD screen and display “???KEY” with a delay of
2000ms.The Enable pin of the motor driver IC is set to 1(Enable) or 0(Disable)for different
duration of the time through the pin 5 of the port D(OC1A).This procedure of varying the on
time of decoders is known as Pulse Width Modulation. When the Enable Pin of the motor driver
IC is set to 1 i.e. enabled its check either Pin of Controller (PC0 or PC1) which key is pressed. It
display a string “MOTOR IN REVERSE DIRECTION” if the first key is pressed and set to the
pin 6 of the Port D to 1 and Pin 7 to 0.When other key is pressed LCD display “MOTOR IN
FORWARD DIRECTION” by setting pin 7 of Port D to 1 and pin 6 of Port D to 0.When the
digital signal 00 or 11 is passed to pin 6 and 7 of Port D Motor will stop and LCD displays a
message “MOTOR IS STOPPED”.
1. Sufficient amount of darkening should be done while drawing the PCB layout over the
copper plate
3. The DC supply of the battery should be connected by taken care of the polarities
otherwise the voltage regulator IC 7805 blows off..
4. While providing supply AC adaptor red wire should go to V DD terminal and while wire
should go to the GND terminal.
5. In case the polarities are not correct the regulator IC 7805 may blow causing direct
supply to the micro Controller (ATmega32) and damage it also.
6. Also the incorrect connection would result in burning of motor driver IC L239D
7. The on boars connection of ISP should be correct otherwise no detection of device will
be related by Win AVR and hence the program will not get executed.
CHAPTER – 7
CONCLUSION & FUTURE EXPANSION
7.1 Conclusion
From this project “Microcontroller based Elevator System” we conclude that an effective speed
control can be achieved by varying the width of the pulse efficiently. The reason why this
method is more effective than other method is that the regulation achieved in this method is
sharp, accurate and we can get variety of range of speed above and below the rated speed.
We successfully achieved the objective of the project with the effective speed control and
displaying the speed on the motor on RPM along with the direction of rotation on LCD panel.
The Future expansion of the project could be that, now in this project the speed is
control is done by the keypad by using keys .In future we are planning to control
the speed using a wireless device (Remote) and a wireless module. The range
speed can be indicated by the LED. Thus many motor can be controlled from the
one location with the help of Remote.
CHAPTER-8
APPENDIX
CODING
#include<avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
#include<compat/deprecated.h> // HEADER FILE FOR FUNCTIONS LIKE SBI AND CBI
#include<avr/pgmspace.h>
#include<stdlib.h>
#include “lcd.h”
#define OC1A_PIN PD5 //OC1A pin
#define OC1B_PIN PD 6 //OC1B pin
#define OC1_DDR DDRD //OC1 DDR
Void lcd_putint(int i);
Void motor_speed(void );
Void lcd_putint(int i) //print integer on lcd(no auto linefeed)
{
char buffer[7];
itoa(i,buffer,10); //convert integer into string(decimal format)
lcd_puts(buffer); //and transmit string to LCD
} // lcd_putint
int i=0,j=0;
void motor_speed()
{
for(int k=0;k==0;)
{
if(bit_is_clear(PINC,0)) //if INT0 switch is passed to increase
{
i=i+10;
if(i>255)
i=255;
lcd_clrscr(); //clear display and home cursor
lcd_puts(“0 pressed”);
lcd_putint(i);
j=255-I;
if(i<=10)
j=255;
OCR1AL=j;
OCR1BL=j;
_delay_ms(250);
_delay_ms(250);
}
else
if(bit_is_clear(PINC,1)) //if INT1 switch is pressed to decrease speed
{
i=i-10;
if(i<=0)
i=1;
lcd_clrscr(); //clear display and home cursor
lcd_puts(“1 pressed”);
lcd_putint(i);
j=255-i;
if(i<=10)
j=255;
OCR1AL=j;
OCR1BL=j;
_delay_ms(250);
_delay_ms(250);
}
}
}
int main(void)
{
DDRB=0XFB; //Set Data Direction Register
//Set 1 for Output Port
//Set 0 for Input Port
DDRD=0XFF; //Set Data Direction Register
//Set 1 for Output Port
//Set 0 for Input Port
DDRC=0x00;
DDRA=0x00;
sbi(PORTD,5); //Motor1 Enable
sbi(PORTC,0); //Motor1 Enable
sbi(PORTC,1); //Motor1 Enable
OC1_DDR|=_BV(OC1A_PIN)+_BV(OC1B_PIN);
//Set OC1A and OC1B pin as output,required for output toggling
TCCR1A=_BV(WGM10) |_BV(COM1A1)|_BV(COM1A0) | _BV(COM1B1) |_BV(COM1B0);
//enable 8 bit PWM,select inverted PWM
//timer1 running on 1/8MCU clock with clear timer/counter1 on Compare Match
//PWM frequency will be MCU clock /8/512,e.g. with 1 MHz Crystal 244 Hz.
TCCR1B=_BV(CS11) |_BV(WGM12);
lcd_init(LCD_DISP_ON); //initialize display,cursor off
lcd_clrscr()(); //clear display and home cursor
lcd_puts(“LCD is Ready\n”); //put string to display (line1) with line feed
_delay_ms(2000);
lcd_clrscr(); //clear display and home cursor
lcd_puts(“???Key”); //cursor is now on second line , write second line
_delay_ms(2000);
for(;;)
{
lcd_puts(“SELECT DIRECTION\n”);
lcd_puts(“1:-UP 2:- DOWN ”);
if(bit_is_clear(PINC,0))
{
lcd_clrscr(); //clear display and home cursor
lcd_puts(“Motor in Forward\n”);
lcd_puts(“Direction\n”);
_delay_ms(2000);
sbi(PORTD,6);
cbi(PORTD,7);
motor_speed();
}
else
{
if(bit_is_clear(PINC,1))
{
lcd_clrscr(); //clear display and home cursor
lcd_puts(“Motor in Reverse\n”);
lcd_puts(“Direction\n”);
_delay_ms(2000);
sbi(PORTD,7);
cbi(PORTD,6);
motor_speed();
}
else
{
cbi(PORTD,7);
cbi(PORTD,7);
}
}
}
Return 0;
}
CHAPTER-9
REFERENCES AND BIBLOGRAPHY
1. Working with win AVR
2. Robotics trainer Manual
3. let us C-By-Yashwant Kanetkar
4. www.wikipedia.com
5. www.google.com
6. http://en.wikipedia.org/wiki/Resistor
7. http://personal.ee.surrey.ac.uk/Personal/H.M/UGLabs/images/resistor_packages.jpg
8. http://en.wikipedia.org/wiki/Capacitor
9. http://en.wikipedia.org/wiki/Linear_regulator
10. http://en.wikipedia.org/wiki/Liquid_crystal_display
11. http://en.wikipedia.org/wiki/Electric_motor
12. http://www.futurlec.com/Atmel/ATMEGA32.shtml