Anda di halaman 1dari 41

1

CHAPTER-1
1.1 INTRODUCTION

,9 is , lig9 follower

It`s a 2icrocon9roller b,sed Lig9 follower. There is an easy switch ON/OFF button. The
sensors to detect the torch light which have been made using LIGHT DEPENDENT
RESISTORS (LDR). The sensor array contains 2 sensors.
The motors used to provide the movement to the bot are DC geared motors oI 200 rpm. One
castor wheel is used to support the bot. The bot is being driven by 9V battery connected in
series.

build , lig9 follower

Sensing a light and maneuvering the robot to stay on course, while constantly correcting wrong
moves using Ieedback mechanism Iorms a simple yet eIIective closed loop system. As a
programmer you get an opportunity to teach` the robot how to Iollow the light thus giving it a
human-like property oI responding to stimuli.

Prerequisi9es:
Knowledge oI basic digital and analog electronics.
C Programming Sheer interest, an innovative brain and perseverance!


1.2 DESIGN OF LIGHT DEPENDENT RESISTOR CIRCUIT

Principle of oper,9ion of 9e LDR:

A photoresistor or light dependent resistor or cadmium sulIide (CdS) cell is a resistor whose
resistance decreases with increasing incident light intensity. It can also be reIerred to as a
photoconductor.
A photoresistor is made oI a high resistance semiconductor. II light Ialling on the device is oI
high enough Irequency, photons absorbed by the semiconductor give bound electrons enough
energy to jump into the conduction band. The resulting Iree electron (and its hole partner)
conduct electricity, thereby lowering resistance.

A photoelectric device can be either intrinsic or extrinsic. An intrinsic semiconductor has its
own charge carriers and is not an eIIicient semiconductor, e.g. silicon. In intrinsic devices the
only available electrons are in the valence band, and hence the photon must have enough energy
to excite the electron across the entire bandgap. Extrinsic devices have impurities, also called
dopants, added whose ground state energy is closer to the conduction band.
2


Fig 1.1 : LDR sensors

1.2.1 POSITIONING OF SENSORS:-



The resistance oI the LDR sensor decreases when light Ialls on it. A good sensor will have near
zero resistance in presence oI light and a very large resistance in absence oI light. Whether the
sensors are Light Dependent Resistors, laser diode, InIrared Sensors, Ultrasonic Sensors or
anything else,the outputs oI the sensor modules are Ied to the Non-inverting input oI a
comparator . The reIerence voltage oI the comparator is Ied to the inverting input oI the
comparator by a trim pot or a tuning device connected between the supply lines. LM358 is a
comparator IC that digitizes the analog signal Irom the sensor array. Since the output oI LM358
is TTL compatible it can be directly Ied to the master microcontroller.


Fig 1.2: Working Principle oI LDR sensors

3

LDR Sensor Arr,




Fig 1.3: PCB oI LDR sensor Circuit


1.3 BIPOLAR MOTOR DRIVER:-

L293D is a bipolar motor driver IC. This is a high voltage, high current pushpull Iour channel
driver compatible to TTL logic levels and drive inductive loads. It has 600 mA output current
capability per channel and internal clamp diodes.

The L293 is designed to provide bidirectional drive currents oI upto 1 A at voltages Irom 4.5 V
to 36 V. The L293D is designed to provide bidirectional drive currents oI up to 600-mA at
voltages Irom 4.5 V to 36 V. Both devices are designed to drive inductive loads such as relays,
solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in
positive supply applications. All inputs are TTL compatible. Each output is a complete totem-
pole drive circuit, with a Darlington transistor sink and a pseudo-Darlington source. Drivers are
enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN.
When an enable input is high, the associated drivers are enabled, and their outputs are active and
in phase with their inputs. When the enable input is low, those drivers are disabled, and their
outputs are oII and in the high-impedance state. With the proper data inputs, each pair oI drivers
Iorms a Iull-H (or bridge) reversible drive suitable Ior solenoid or motor applications.

4

PIN DIAGRAM OF L293D:-

4 S 12 13
16 S
1
2
1S
9
?
10
3
14
6
11
VCC1- LOGIC
SUPPLY= SV
LM+
OUTPUT FOR
MOTOR1
OUTPUT FOR
MOTOR2
L_IN1
L_EN
GND
L293D
INPUT
LINES
R_EN
L_IN2
R_IN2
R_IN1
LM-
RM+
RM-

Fig 1.4:- PIN DIAGRAM OF L293D


The Device is a monolithic integrated high voltage, high current Iour channel driver designed to
accept standard DTL or TTL logic levels and drive inductive loads (such as relays solenoides,
DC and stepping motors) and switching power transistors. To simpliIy use as two bridges each
pair oI channels is equipped with an enable input. A separate supply input is provided Ior the
logic, allowing operation at a lower voltage and internal clamp diodes are included. This device
is suitable Ior use in switching applications at Irequencies up to 5 kHz.

5

The L293D is assembled in a 16 lead plastic packaage which has 4 center pins connected
together and used Ior heatsinking The L293DD is assembled in a 20 lead surIace mount which
has 8 center pins connected together and used Ior heatsinking.


Fig 1.5:- Circuit oI Bipolar motor driver





6

1.3.1 Mo9or driving

PC0 PC1 MOTOR


STATUS
X X STOPPED
0 0 STOPPED
1 1 FORWARD
1 0 LEFT
0 1 RIGHT

Table 1.1:- Working oI Motors


PICTURE OF BIPOLAR MOTOR DRIVER




Fig 1.6:- Bipolar Motor Driver


Pic9ure of 9e wole working projec9

Fig 1.:- Whole Project


8

CHAPTER-2
2.1 STEPS INVOLVED IN MAKING OF PCB:-


2.1.1 Circui9 l,ou9:-
The connections on the PCB should be identical to the circuit
diagram, but while the circuit diagram is arranged to be readable, the PCB layout is arranged to
be Iunctional, so there is rarely any visible correlation between the circuit and the layout.
PCB layout can be perIormed manually (using CAD) or in combination with an Auto router.
The best results are usually still achieved using at least some manual routing - simply because
the design engineer has a Iar better judgement oI how to arrange circuitry. Surprisingly, many
auto routed boards are oIten completely illogical in their track routing - the program has
optimized the connections, and sacriIiced any small amount oI order that may have been put in
place by manual routing. Generally auto routed boards are slightly harder Ior a technician to
repair or debug, Ior this reason. Historically, PCBs used to be laid out by drawing or using stick
on paper shapes on Mylar Iilm, - that really WAS manual routing!
The CAD PCB layout consists oI several layers, Ior illustration purposes the holes, outline and
component identiIication layers can be combined into one diagram. When we produce PCBs Ior
clients, we use actual size check plots during the design process. A PCB will usually have
mounting holes and may possibly have cutouts, by cutting an actual size check plot and placing
it in the enclosure, you can see how it will be positioned in relation to other parts. We can also
place components up against the pad markings as a quick double check oI sizing.

2.1.2 L,ou9 on copper pl,9e:-

(i)Taking A Cu Plate For Layout Design:-


Fig 2.1: Cu Plate Ior PCB making
(ii) Drawing Circuit Layout on Cu Plate: - Cut the PCB drawing Irom the trace paper and place
on the copper plated board then Iix with adhesive tape.Mark the points to be drilled on the PCB
with a thick needle or any other sharp object
9


Fig 2.2:- Marking the points to be drilled
(iii) Remove the paper and draw the lines with a permanent waterprooI marker. Please note that
the Iinal quality oI etching depends on the ink used. You should try diIIerent brands or types oI
markers on a small piece beIore to Iind the best one. It does not matter iI it is black or blue etc.
but iI you leave the painted plate Ior over a Iew minutes the ink becomes too dry and it Ilakes in
the FeCl3. So Ireshly paint and etch your PCBs.
2.1.3 Drilling:-
Holes through a PCB are typically drilled with tiny drill bits made oI solid tungsten carbide. The
drilling is perIormed by automated drilling machines with placement controlled by a drill tape
or drill Iile. These computer-generated Iiles are also called numerically controlled drill (NCD)
Iiles or "Excellon Iiles". The drill Iile describes the location and size oI each drilled hole. These
holes are oIten Iilled with annular rings to create vias. Vias allow the electrical and thermal
connection oI conductors on opposite sides oI the PCB. When very small vias are required,
drilling with mechanical bits is costly because oI high rates oI wear and breakage. In this case,
the vias may be evaporated by lasers. Laser-drilled vias typically have an inIerior surIace Iinish
inside the hole. These holes are called micro vias. It is also possible with controlled-depth
drilling, laser drilling, or by pre-drilling the individual sheets oI the PCB beIore lamination, to
produce holes that connect only some oI the copper layers, rather than passing through the entire
board. These holes are called blind vias when they connect an internal copper layer to an outer
layer, or buried vias when they connect two or more internal copper layers and no outer layers.
The walls oI the holes, Ior boards with 2 or more layers, are plated with copper to Iorm plated-
through holes that electrically connect the conducting layers oI the PCB. For multilayer boards,
those with 4 layers or more, drilling typically produces a smear comprised oI the bonding agent
in the laminate system. BeIore the holes can be plated through, this smear must be removed by a
chemical de-smear process, or by plasma-etch.
10


Fig 2.3:-Drilling holes beIore etching
2.1.4 E9cing:-

Etching is the process oI using strong acid or mordant to cut into the unprotected parts oI a
metal surIace to create a design in intaglio in the metal (the original processin modern
manuIacturing other chemicals may be used on other types oI material). As an intaglio method
oI printmaking it is, along with engraving, the most important technique Ior old master prints,
and remains widely used today.
Ferric Chloride (chemical name FeCl3). This is the acid that is used to etch away copper that
isn't protected by the remaining photo resist coating (it also stains things like crazy so wear old
clothes and plastic gloves when going anywhere near it!) FeCl3 oIten comes in bags in its
anhydrous Irom (dried orange-brown coloured crystals) but you can get ready made solution
too. Again, there are more expensive/Iriendlier/cleaner substitutes.II making up your own
solution, you need about 100 grams oI crystals per 200ml oI water - but it's not at all critical.
Place the crystals in a small plastic tray and slowly add some hot (40'c) water - you don`t need
more than 1cm's depth. Gently rock the tray to dissolve the crystals and only when they've
completely dissolved, place the PCB in. Etching should take less than 20 minutes, especially iI
the solution stays warm and you agitate the tray gently
The easy to Iind chemical which eats away the copper is FeCl3. It is sold both in solid and
dissolved states but solid one recommended. Prepare a solution which looks very dark. Also hot
solution works Iaster but it is not necessary iI you have enough time. Attach a thread to the plate
by a piece oI adhesive tape then immerse it in the FeCl3.

Fig 2.4:- Placing the plate in the FeCl3 solution
11

AIter a Iew minutes (it may take more iI your plate's copper layer is thick) the copper part oI the
plate which is not painted will be dissolved. When it is visible through the edges oI the painted
regions pay attention to the rest oI the process. Move the plate in the solution to help it dissolve
easier. When all unwanted copper parts are dissolved quickly take it out the solution and rinse
with plenty oI tap water. This is really important that FeCl3 residue leIt on the PCB will make it
rusty by the time. Be careIul: do not split FeCl3 on any part oI your home. It eats much oI the
metals and leaves ugly stains on surIaces.


Fig 2.5:- Stirring plate in Iecl3

AIter drying the rinsed PCB, remove painting with a solvent (such as acetone or thinner).

2.1.5 Co2ponen9 Asse2bling & Soldering:-
AIter the printed circuit board (PCB) is completed, electronic components must be attached
Iorm a Iunctional printed circuit assembly or PCA (sometimes called a "printed circuit board
assembly" PCBA). In through-hole construction, component leads are inserted in holes. In
surIace-mount construction, the components are placed on pads or lands on the outer surIaces oI
the PCB. In both kinds oI construction, component leads are electrically and mechanically Iixed
to the board with a molten metal solder.
There are a variety oI soldering techniques used to attach components to a PCB. High volume
production is usually done with machine placement and bulk wave soldering or reIlow ovens,
but skilled technicians are able to solder very tiny parts (Ior instance 0201 packages which are
0.02" by 0.01") by hand under a microscope, using tweezers and a Iine tip soldering iron Ior
small volume prototypes. Some parts are impossible to solder by hand, such as ball grid array
(BGA) packages.
OIten, through-hole and surIace-mount construction must be combined in a single PCA because
some required components are available only in surIace-mount packages, while others are
available only in through-hole packages. Another reason to use both methods is that through-
hole mounting can provide needed strength Ior components likely to endure physical stress,
while components that are expected to go untouched will take up less space using surIace-mount
techniques

12

2.1.6 How 9o Solder
Firs9 , few s,fe9 prec,u9ions:
1. Never 9ouc 9e ele2en9 or 9ip of 9e soldering iron.
They are very hot (about 400C) and will give you a nasty burn.
2. T,ke gre,9 c,re 9o ,void 9oucing 9e 2,ins flex wi9 9e 9ip of 9e iron.
The iron should have a heatprooI Ilex Ior extra protection. An ordinary plastic Ilex will
melt immediately iI touched by a hot iron and there is a serious risk oI burns and electric
shock.
3. Alw,s re9urn 9e soldering iron 9o i9s s9,nd wen no9 in use.
Never put it down on your workbench, even Ior a moment!
4. ork in , well-ven9il,9ed ,re,.
The smoke Iormed as you melt solder is mostly Irom the Ilux and quite irritating. Avoid
breathing it by keeping you head to the side oI, not above, your work.
Prep,ring 9e soldering iron:
1. Pl,ce 9e soldering iron in i9s s9,nd ,nd plug in.
The iron will take a Iew minutes to reach its operating temperature oI about 400C.
2. D,2pen 9e sponge in 9e s9,nd.
The best way to do this is to liIt it out the stand and hold it under a cold tap Ior a
moment, then squeeze to remove excess water. It should be damp, not dripping wet.
3. ,i9 , few 2inu9es for 9e soldering iron 9o w,r2 up.
You can check iI it is ready by trying to melt a little solder on the tip.
4. ipe 9e 9ip of 9e iron on 9e d,2p sponge.
This will clean the tip.
5. Mel9 , li99le solder on 9e 9ip of 9e iron.
This is called 'tinning' and it will help the heat to Ilow Irom the iron's tip to the joint. It
only needs to be done when you plug in the iron, and occasionally while soldering iI you
need to wipe the tip clean on the sponge.
ou ,re now re,d 9o s9,r9 soldering:
O Hold 9e soldering iron like , pen, ne,r 9e b,se of 9e ,ndle.
Imagine you are going to write your name! Remember to never touch the hot element or
tip.
O Touc 9e soldering iron on9o 9e join9 9o be 2,de.
Make sure it touches both the component lead and the track. Hold the tip there Ior a Iew
seconds and...
O Feed , li99le solder on9o 9e join9.
It should Ilow smoothly onto the lead and track to Iorm a volcano shape as shown in the
diagram. Apply the solder to the joint, not the iron.
O Re2ove 9e solder, 9en 9e iron, wile keeping 9e join9 s9ill.
Allow the joint a Iew seconds to cool beIore you move the circuit board.
O Inspec9 9e join9 closel.
It should look shiny and have a 'volcano' shape. II not, you will need to reheat it and Ieed
13

in a little more solder. This time ensure that bo9 the lead and track are heated Iully
beIore applying solder.
Using , e,9 sink:
Some components, such as transistors, can be damaged by heat when soldering so iI you are not
an expert it is wise to use a heat sink clipped to the lead between the joint and the component
body. You can buy a special tool, but a standard crocodile clip works just as well and is cheaper.













Fig 2.6:- Pictorial view oI soldered joint
Soldering Advice for Co2ponen9s
It is very tempting to start soldering components onto the circuit board straight away, but please
take time to identiIy all the parts Iirst. You are much less likely to make a mistake iI you do this!
1. Stick all the components onto a sheet oI paper using sticky tape.
2. IdentiIy each component and write its name or value beside it.
3. Add the code (R1, R2, C1 etc.) iI necessary.
Many projects Irom books and magazines label the components with codes (R1, R2, C1,
D1 etc.) and you should use the project's parts list to Iind these codes iI they are given.
4. Resistor values can be Iound using the resistor Colour code which is explained on our
Resistors page. You can print out and make your own Resistor Colour Code Calculator
to help you.
5. Capacitor values can be diIIicult to Iind because there are many types with diIIerent
labeling systems! The various systems are explained on our Capacitors page.
Some components require special care when soldering. Many must be placed the correct
way round and a Iew are easily damaged by the heat Irom soldering. Warnings are given in
the table below, together with other advice which may be useIul when soldering.
14

CHAPTER-3
3.1 COMPONENT LIST AND DESCRIPTION
The major components used in the project include the ATmega16 microcontroller,805
regulator, LM358N etc. The list oI the components along with their description is as Iollows.

LIST OF COMPONENTS:
1. IC ATmega16 Microcontroller
2. LM358N
3. L293D
4. Variable resistance
5. Electric Switch
6. LEDs
. Resistors
8. Capacitors
9. IC 805 Voltage regulator
10.9 v Power Supply
11.D.C Motors
12.Light Dependent Resistors











15



3.1.1 IC AT2eg,16 Microcon9roller:

1. High-perIormance, Low-power AVR 8-bit Microcontroller
2. Advanced RISC Architecture
i. 131 PowerIul Instructions Most Single-clock Cycle Execution
ii. 32 x 8 General Purpose Working Registers
iii. Fully Static Operation
iv. Up to 16 MIPS Throughput at 16 MHz
v. On-chip 2-cycle Multiplier
3. Nonvolatile Program and Data Memories
i. 16K Bytes oI In-System SelI-Programmable Flash
4. Endurance: 10,000 Write/Erase Cycles
i. Optional Boot Code Section with Independent Lock Bits
ii. In-System Programming by On-chip Boot Program
iii. True Read-While-Write Operation
iv. 512 Bytes EEPROM
5. Operating Voltages
i. 2. - 5.5V Ior ATmega16L
ii. 5.5V Ior ATmega16
6. Speed Grades
i. 0 - 8 MHz Ior ATmega16L
ii. 0 - 16 MHz Ior ATmega16





16

3.1.1.1 Pin Di,gr,2:


Fig 3.1:- Pin Diagram oI ATMEGA16


1

Pin Descrip9ion:

VCC : Digital supply voltage
GND : Digital ground
Por9 A (PA 9o PA0): Port A is an 8-bit bi-directional I/O port. Port pins can provide internal
pull-up resistors (selected Ior each bit). The Port A output buIIers can sink 20 mA and can drive
LED displays directly. When pins PA0 to PA are used as inputs and are externally pulled low,
they will source current iI the internal pull-up resistors are activated. Port A also serves as the
analog inputs to the A/D Converter.The Port A pins are tri-stated when a reset condition
becomes active, even iI the clock is not running.
Por9 B (PB7 9o PB0): Port B is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port B output buIIers can sink 20 mA. As inputs, Port B pins that are externally
pulled low will source current iI the pull-up resistors are activated. Port B also serves the
Iunctions oI various special Ieatures oI the AT90S8535. The Port B pins are tri-stated when a
reset condition becomes active, even iI the clock is not running.
Por9 C (PC7 9o PC0) : Port C is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port C output buIIers can sink 20 mA. As inputs, Port C pins that are externally
pulled low will source current iI the pull-up resistors are activated. Two Port C pins can
alternatively be used as oscillator Ior Timer/Counter2. The Port C pins are tri-stated when a
reset condition becomes active, even iI the clock is not running.
Por9 D (PD7 9o PD0):Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors. The Port D output buIIers can sink 20 mA. As inputs, Port D pins that are externally
pulled low will source current iI the pull-up resistors are activated. Port D also serves the
Iunctions oI various special Ieatures oI the AT90S8535. The Port D pins are tri-stated when a
reset condition becomes active, even iI the clock is not running.
RESET: Reset input. An external reset is generated by a low level on the RESET pin. Reset
pulses longer than 50 ns will generate a reset, even iI the clock is not running. Shorter pulses are
not guaranteed to generate a reset.
18

TAL1: Input to the inverting oscillator ampliIier and input to the internal clock operating
circuit.
TAL2: Output Irom the inverting oscillator ampliIier.
AVCC: AVCC is the supply voltage pin Ior Port A and the A/D Converter. II the ADC is not
used, this pin must be connected to VCC. II the ADC is used, this pin must be connected to
VCC via a low-pass Iilter.
AREF: AREF is the analog reIerence input Ior the A/D Converter. For ADC operations, a
voltage in the range 2V to AVCC must be applied to this pin.
AGND: Analog ground. II the board has a separate analog ground plane, this pin should be
connected to this ground plane. Otherwise, connect to GND.

3.1.1.2 BLOCK DIAGRAM:
The ATmega16 is a low-power CMOS 8-bit microcontroller based on the AVR RISC
architecture. By executing powerIul instructions in a single clock cycle, the ATmega16 achieves
throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power
consumption versus processing speed.The AVR core combines a rich instruction set with 32
general purpose working registers. All the 32 registers are directly connected to the Arithmetic
Logic Unit (ALU).
The ATmega16 provides the Iollowing Ieatures: 16K bytes oI In-System Programmable Flash
Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1Kbyte SRAM, 32
general purpose I/O lines, 32 general purpose working registers, a JTAG interIace Ior
Boundary-scan, On-chip Debugging support and programming, three Ilexible Timer/Counters
with compare modes, Internal and External Interrupts, a serial programmable USART, a byte
oriented Two-wire Serial InterIace, an 8-channel, 10-bitADC with optional diIIerential input
stage with programmable gain (TQFP package only),a programmable Watchdog Timer with
Internal Oscillator, an SPI serial port, and sixsoItware selectable power saving modes.
The Power-down mode saves the register contents but Ireezes the Oscillator, disabling all other
chip Iunctions until the next External Interrupt or Hardware Reset. In Power-save mode, the
Asynchronous Timer continues to run, allowing the user to maintain a timer base while the rest
oI the device is sleeping.
19

The ADC Noise Reduction mode stops the CPU and all I/O modules except Asynchronous
Timer and ADC, to minimize switching noise during ADC conversions.




Fig 3.2:- Architecture oI ATMEGA16

20

AVR CPU Core:
This section discusses the AVR core architecture in general. The main Iunction oI the CPU core
is to ensure correct program execution. The CPU must thereIore be able to access memories,
perIorm calculations, control peripherals, and handle interrupts.
Arci9ec9ur,l Overview: In order to maximize perIormance and parallelism, the AVR uses
a Harvard architecture with separate memories and buses Ior program and data. Instructions in
the program memory are executed with a single level pipelining. While one instruction is being
executed, the next instruction is pre-Ietched Irom the program memory. This concept enables
instructions to be executed in every clock cycle. The program memory is In System
Reprogrammable Flash memory.The Iast-access Register File contains 32 x 8-bit general
purpose working registers with a single clock cycle access time. This allows single-cycle
Arithmetic Logic Unit (ALU) operation. In a typical ALU operation, two operands are output
Irom the Register File, the operation is executed, and the result is stored back in the Register
File in one clock cycle.
.



Fig 3.3:- Block Diagram oI AVR MCU Architecture

21

ALU - Ari92e9ic Logic Uni9:

The high-perIormance AVR ALU operates in direct connection with all the 32 general purpose
working registers. Within a single clock cycle, arithmetic operations between
general purpose registers or between a register and an immediate are executed. The
ALU operations are divided into three main categories arithmetic, logical, and bit-Iunctions.

3.1.1.3 S9,9us Regis9er:

The Status Register contains inIormation about the result oI the most recently executed
arithmetic instruction. This inIormation can be used Ior altering program Ilow in order to
perIorm conditional operations. Note that the Status Register is updated aIter all ALU
operations, as speciIied in the Instruction Set ReIerence. This will in many cases remove the
need Ior using the dedicated compare instructions, resulting in Iaster and more compact code.



Fig 3.4:- ShiIt Register

Gener,l Purpose Regis9er File:

The Register File is optimized Ior the AVR Enhanced RISC instruction set. In order to achieve
the required perIormance and Ilexibility, the Iollowing input/output schemes are supported by
the Register File:
i. One 8-bit output operand and one 8-bit result input
ii. Two 8-bit output operands and one 8-bit result input
iii. Two 8-bit output operands and one 16-bit result input
iv. One 16-bit output operand and one 16-bit result input
22


Fig 3.5:- General Purpose Register

Te -regis9er, -regis9er ,nd Z-regis9er:

These registers are 16-bit address pointers Ior indirect addressing oI the Data Space.The
three indirect address registers X, Y, and Z.
S9,ck Poin9er :

The Stack is mainly used Ior storing temporary data, Ior storing local variables and Ior
storing return addresses aIter interrupts and subroutine calls. The Stack Pointer Register always
points to the top oI the Stack.
AVR AT2eg,16 Me2ories:
The AVR architecture has two main memory spaces, the Data Memory and the
Program Memory space. In addition, the ATmega16 Ieatures an EEPROM Memory Ior data
storage. All three memory spaces are linear and regular.

3.1.2 LM358N(COMPARATOR):
Utilizing the circuit designs perIected Ior recently introduced Quad Operational AmpliIiers,
these dual operational ampliIiers Ieature low power drain, a common mode input voltage range
extending to ground/VEE, single supply or split supply operation and pin outs compatible with
the popular MC1558 dual operational ampliIier. They can operate atsupply voltages as low as
3.0 V or as high as 32 V, with quiescent currents about oneIiIth oI those associated with the
MC141 (on a per ampliIier basis). The common mode input range includes the negative
23

supply, thereby eliminating the necessity Ior external biasing components in many applications.
The output voltage range also includes the negative power supply voltage.
These circuits consist oI two independent, high gain, internally Irequency compensated which
were designed speciIically to operate Irom a single powersupply overawide range oI voltages.
The low power supply drain is independent oI the magnitude oI the power supply voltage.

Fig 3.6:- Picture oI LM358N comparator
Pin connec9ions:

Fig 3.:- Internal Circuit oI LM358N comparator

24

3.1.3 L293D (H Bridge)

This is the H-Bridge IC which is used Ior the bidirectional motion oI motors. This IC contains
two H-Bridges.
A simple H-Bridge circuit is shown below.


Fig 3.8:- H Bridge circuit
Each H-Bridge in L293D is capable oI providing 600mA current to each motor
and that is suIIicient Ior us.

Te Pin di,gr,2 of L293D is sown below


Fig 3.9:- Pin diagram oI L293D
25

Te circui9 used in L293D is sown below


Fig 3.10:- circuit used in L293D

3.1.4 VARIABLE RESISTANCE:
Variable resistors consist oI a resistance track with connections at both ends and a wiper which
moves along the track as you turn the spindle. The track may be made Irom carbon, cermet
(ceramic and metal mixture) or a coil oI wire (Ior low resistances). The track is usually rotary
but straight track versions, usually called sliders, are also available.
Variable resistors may be used as a rheostat with two connections (the wiper and just one end
oI the track) or as a potentiometer with all three connections in use. Miniature versions called
presets are made Ior setting up circuits which will not require Iurther adjustment.
Variable resistors are oIten called potentiometers in books and catalogues. They are speciIied by
their maximum resistance, linear or logarithmic track, and their physical size. The standard
spindle diameter is 6mm
26

3.1.4.1 Reos9,9:
This is the simplest way oI using a variable resistor. Two
terminals are used: one connected to an end oI the track, the other
to the moveable wiper. Turning the spindle changes the resistance
between the two terminals Irom zero up to the maximum
resistance.
3.1.4.2 Po9en9io2e9er:
Variable resistors used as potentiometers have all three terminals
connected. This arrangement is normally used to vary voltage, Ior
example to set the switching point oI a circuit with a sensor, or
control the volume (loudness) in an ampliIier circuit.
3.1.4.3 Prese9s:
These are miniature versions oI the standard variable resistor. They are
designed to be mounted directly onto the circuit board and adjusted only
when the circuit is built. A small screwdriver or similar tool is required
to adjust presets. The screw must be turned many times (10) to move
the slider Irom one end oI the track to the other, giving very Iine control.


Fig 3.14:- Picture oI Presets

3.1.5 ELECTRIC SITCH:
Electric switches, electronic switches or electrical switches are devices used to connect or break
an electrical circuit. All switches consist oI an operator, contacts and a switch mechanism. The



Fig3.11:- Rheostat



Fig3.12:- Potentiometer



Fig 3.13:- Presets
2

operator actuates switch operation. The contacts are made oI low-resistance metal and are used
to make or break the electrical circuit. The switch mechanism is linked to the operator .
The two most basic switch devices, oI which other mechanisms are simply variations, are the
slow-make, slow-break (AC base) and the quick-make, quick-break (AC/DC base) mechanisms.
The Iirst device is basically a teeter-totter or seesaw design. It is spring-loaded, requiring a very
positive Iorce to close the contacts. The slowness oI a slow-make, slow-break device provides a
slight time delay. This delay allows the AC current wave to nearly instantaneously cycle to zero
beIore the spark is extinguished. Toggle switches, slide buttons, rocker switches or pushbutton
switches can operate the mechanism.
Although the circuit conIiguration possibilities Ior electronic switches are virtually endless,
typical circuits include single-throw, double-throw without center oII, double-throw with center
oII and double-throw momentary action with center oII. The single-throw switch is the most
basic circuit with only two positions: on and oII. Double-throw switches without an oII position
in the center are reIerred to as ON-ON switches. These manual electric switches are commonly
used in selector applications (e.g. 6V or 12V on a battery charger). Double-throw electric
switches with a center oII position are three-position switches with two independent ON
switches, an example oI which is the HI-OFF-LOW settings oI a kitchen range hood exhaust
Ian. Three-position double-throw electric switches with momentary action use a spring loading
action. As long as pressure is applied to the actuator, the position will be maintained, making
these electronic switches operator-dependent.



Fig 3.15:- Electric Switches


28



3.1.6 LED`S(Lig9 e2i99ing diode ):

LED Ialls within the Iamily oI P-N junction devices. The light emitting diode (LED) is a diode
that will give oII visible light when it is energized. In any Iorward biased P-N junction there is,
within the structure and primarily close to the junction, a recombination oI holes and electrons.
This recombination requires that the energy possessed by the unbound Iree electron be
transIerred to another state. The process oI giving oII light by applying an electrical source oI
energy is called electroluminescence.

S2bol of LED:

Fig 3.16:- Symbol oI LED
LED has two LEDs wired in 'inverse parallel' (one Iorwards, one backwards) combined in
one package with two leads. Only one oI the LEDs can be lit at one time and they are less useIul
than the tri-colour LEDs described above. LED emit light when an electric current passes
throughThem.







29

Fig 3.1:- Internal Circuit oI LED

Connec9ing ,nd soldering:
LEDs must be connected the correct way round, the diagram may be labelled a or Ior anode and
k or - Ior cathode (yes, it really is k, not c, Ior cathode!). The cathode is the short lead and there
may be a slight Ilat on the body oI round LEDs. II you can see inside the LED the cathode is
the larger electrode (but this is not an oIIicial identiIication method).
LEDS can be damaged by heat when soldering, but the risk is small unless you
are very slow. No special precautions are needed Ior soldering most LEDs.
3.1.6.1 Tes9ing ,n LED:
Never connect an LED directly to a battery or power supply!
It will be destroyed almost instantly because too much current will pass through
and burn it out. LEDs must have a resistor in series to limit the current to a saIe
value, Ior quick testing purposes a 1k resistor is suitable Ior most LEDs iI your
supply voltage is 12V or less. Remember to connect the LED the correct way
round!

3.1.6.2 Colours of LEDs: Fig 3.18:- Testing an
LED
LEDs are available in red, orange, amber, yellow, green, blue and white. Blue and white LEDs
are much more expensive than the other colours. The colour oI an LED is determined
by the semiconductor material, not by the colouring oI the 'package' (the plastic body).
LEDs oI all colours are available in uncoloured packages which may be diIIused (milky) or clear
(oIten described as 'water clear'). The coloured packages are also available as diIIused
(the standard type) or transparent.
3.1.6.3 Tri-colour LEDs:
The most popular type oI tri-colour LED has a red and a green LED combined in
one package with three leads. They are called tri-colour because mixed red and
green light appears to be yellow and this is produced when both
30

the red and green LEDs are on. The diagram
shows the construction oI a tri colour LED. Fig 3.19:- Tri color LED
3.1.7 RESISTANCE :
Resistance is the electronic component used to control the current passing through the circuit. They are
calibrated in ohms. In the other words resistance are circuit elements having the Iunction introducing
electrical resistance into the circuit. There are three basic types:

Fixed Resistance
Rheostat
Potentiometer


Fig 3.20:- Resistances

A Iixed Resistance is a two terminal resistance whose electrical resistance is constant. A rheostat is a
resistance that can be changed in resistance value without opening the circuit to make adjustment.
Potentiometer is an adjustable resistance with three terminals one each end oI the resistance element and
third movable along its length. The resistor is an electrical device whose primary Iunction is to introduce
resistance to the Ilow oI electric current. The magnitude oI opposition to the Ilow oI current is called the
resistance oI the resistor. A larger resistance value indicates a greater opposition to current Ilow. The
resistance is measured in ohms. An ohm is the resistance that arises when a current oI one ampere is
passed through a resistor subjected to one volt across its terminals. The Iollowing sections discuss
resistor characteristics and various resistor types
31






Resis9or V,lues- 9e resis9or color code:

Resistor Color Codes

Band Color 1st Band # 2
nd
Band # *3rd Band # Multiplier x Tolerances
Black 0 0 0 1
Brown 1 1 1 10 1
Red 2 2 2 100 2
Orange 3 3 3 1000
Yellow 4 4 4 10,000
Green 5 5 5 100,000 0.5
Blue 6 6 6 1,000,000 0.25
Violet 10,000,000 0.10
Grey 8 8 8 100,000,000 0.05
White 9 9 9 1,000,000,000
Gold 0.1 5
Silver 0.01 10
None 20



Table 3.1:- Color coding Ior Resistors





Fig 3.21:- Colouring oI Resistance
32


3.1.8 CAPACITOR:

A capacitor is a device capable oI storing an electric charge (static electricity). It consists oI
total plates separated by dielectric material. Capacitors are available in values ranging Irom less
than one Pico Iarad to thousands oI microIarad. While using a capacitor its ratings must be
careIully observed to make certain that the potential to be applied across the capacitor is not
greater than the rated value.
A capacitor or condenser is a passive electronic component consisting oI a pair oI conductors
separated by a dielectric. When a potential diIIerence exists across the conductors, an electric
Iield is present in the dielectric. This Iield stores energy and produces a mechanical Iorce
between the plates. The eIIect is greatest between wide, Ilat, parallel, narrowly separated
conductors.
An ideal capacitor is wholly characterized by a constant capacitance 'C', deIined as the ratio oI
charge 'Q' on each conductor to the voltage 'V' between them.

Sometimes charge buildup aIIects the mechanics oI the capacitor, causing the capacitance to
vary. In this case, capacitance is deIined in terms oI incremental changes:



Fig 3.22:- Capacitors
Tpes of C,p,ci9ors:
Depends upon the basis oI dielectric used:
1. Air insulated & vacuum capacitors
2. Paper insulated capacitors
33

3. Mica capacitors
4. Plastic Iilm capacitors
5. Ceramic capacitors
6. Electrolytic & tantalum capacitors

CERAMIC CAPACITOR:
In this project, 0.01 microIarad capacitor is a ceramic capacitor.
The basis oI the ceramic material is mainly barium titanate or a similar material, but other
ceramic substance including hydrous silicate oI magnesia or talc are also used. The electrodes
are applied in the Iorm oI silver which is either spread or plated on to the opposite Iaces oI a
thin tube, waIer or disc made Irom the ceramic material.Connecting wires are then soldered to
this deposit and the whole capacitor dipped in Ior a suitable coating. The two conducting places
separated by an insulating material (called dielectric) Iorms a capacitor. The basic purpose oI a
capacitor is to store the charge. The capacity oI a capacitor to store charge per unit potential
diIIerence is called capacitance which is measured in Farads but the practical units are
micro/nano/pico Iarads. The capacitor also oIIers low impedance to AC but very high
impedance to DC. The applications include coupling, bypassing and Iiltering Ior AC signal.
Capacitors are oI various types that include paper, Mica, Ceramic & Electrolytic. The capacitors
can also be oI either variable or Iixed type. The capacitors used in the project are Iixed: ceramic
or electrolytic type

Fig 3.23 :- Ceramic Capacitors
.
ELECTROLTIC CAPACITOR:
In this project, capacitor is an electrolytic capacitor. In this type oI capacitors, the dielectric
consists oI an extremely thin Iilm oI aluminum oxide Iormed on one oI its aluminum Ioil plates.
34

Intimate contact with the other plate is achieved by impregnating the paper between the Ioils
with an electrolyte in the Iorm oI viscous substance, such as ammonium borate. The sandwich is
then rolled into a cylindrical element and housed in either metallic cardboard, plastic or ceramic
protective tube.






Fig 3.24:- Electrolytic capacitor

3.1.9 IC 7805 Vol9,ge regul,9or:
8XX Series are three terminal ve Iixed voltage regulators these are available with seven
output options i.e. (5v, 6v, v, 12,15v & 24v) and 9xx series are terminal Iixed voltage
negative regulators. An assortment oI 8xx series ICs plus 3 V, and plus or minus 5 V, 9 V, 12
V, or 15 V when the load is less than 1.5 amperes.
The "8xx" series (805, 812, etc.) regulate positive voltages while the "9xx" series (905,
912, etc.) regulate negative voltages. OIten, the last two digits oI the device number are the
output voltage; eg, a 805 is a 5 V regulator, while a 915 is a -15 V regulator. The 8xx series
ICs can supply up to 1.5 Amperes depending on the model.
Features:
i. Output Current up to 1Aa
ii. Output Voltages oI 5, 6, 8, 9, 10, 12, 15, 18, 24V
iii. Thermal Overload Protection
iv. Short Circuit Protection
v. Output Transistor SaIe Operating Area Protection

35


Fig 3.25:- IC-805
3.1.9.1 C,r,c9eris9ics:
Vo: The regulated out put voltage is Iixed at a value which is speciIied by manuIactures and it
is indicated by the IC number.
Vin: The unregulated input must be at least 2v more than regulated out put voltage.
Io max: The out put current on the load may vary Irom zero to maximum out put current and to
protect it Irom thermal breakdown heat sinks are used

Fig 3.26:- Internal Circuit oI 805

36

Thermal Shut Down: There is internal temperature sensors which turn OFF the IC when it
becomes too hot. The IC again starts working when it is cooling up to given speciIied level.
Voltage Regulator (regulator), usually having three legs, converts varying input voltage and
produces a constant regulated output voltage. They are available in a variety oI outputs. It's a 3
terminal voltage regulator. It will take a DC voltage between 8 and 30 volts, about, and regulate
it to 5 volts. It is limited to about 1 amp, and thermal considerations may limit it to a lot lower
current. The most common part numbers start with the numbers 8 or 9 and Iinish with two
digits indicating the output voltage. The number 8 represents positive voltage and 9 negative
one. The 8XX series oI voltage regulators are designed Ior positive input. And the 9XX series
is designed Ior negative input.
Examples:
1. 5V DC Regulator Name: LM805 or MC805
2. -5V DC Regulator Name: LM905 or MC905
3. 6V DC Regulator Name: LM806 or MC806
4. -9V DC Regulator Name: LM909 or MC909
The LM8XX series typically has the ability to drive current up to 1A. For application
requirements up to 150mA, 8LXX can be used. As mentioned above, the component has three
legs: Input leg which can hold up to 36VDC Common leg (GND) and an output leg with the
regulator's voltage. For maximum voltage regulation, adding a capacitor in parallel between the
common leg and the output is usually recommended. Typically a 0.1MF capacitor is used. This
eliminates any high Irequency AC voltage that could otherwise combine with the output
voltage. See below circuit diagram which represents a typical use oI a voltage regulator.




3

3.1.10 9 v D.C. Power Suppl:


Fig 3.2:- DC Battery
Various batteries (top-leIt to bottom-right): two AA, one D, one handheld ham radio battery,
two 9-volt PP3, two AAA, one C, one camcorder battery, one cordless phone battery.
An electrical battery is a combination oI one or more electrochemical cells, used to convert
stored chemical energy into electrical energy. Since the invention oI the Iirst Voltaic pile in
1800 by Alessandro Volta, the battery has become a common power source Ior many household
and industrial applications, and is now a multi-billion dollar industry.Batteries may be used once
and discarded, or recharged Ior years as in standby power applications. Miniature cells are used
to power devices such as wristwatches and portable electronic devices; larger batteries provide
standby power Ior telephone exchanges or computer data
Batteries are classiIied into two broad categories, each type with advantages and disadvantages.
1. Primary batteries irreversibly (within limits oI practicality) transIorm chemical energy to
electrical energy. When the initial supply oI reactants is exhausted, energy cannot be
readily restored to the battery by electrical means.
2. Secondary batteries can be recharged; that is, they can have their chemical reactions
reversed by supplying electrical energy to the cell, restoring their original composition.

38

3.1.11 DC MOTORS:-
These are very commonly used in robotics. DC motors can rotate in both directions depending
upon the polarity oI current through the motor. These motors have Iree running torque and
current ideally zero. These motors have high speed which can be reduced with the help oI gears
and traded oII Ior torque. Speed Control oI DC motors is done through Pulse Width Modulation
techniques, i.e. sending the current in intermittent bursts. PWM can be generated by 555 timer
IC with adjusted duty cycle. Varying current through the motor varies the torque.






Fig 3.28:- PICTURE OF DC MOTOR USED




39

CHAPTER-4
SOURCE CODE

Project : Light Follower robot
Chip type : ATmega16
Program type : Application
Clock Irequency : 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/

#include mega16.h~

#deIine LEFTSENSOR PINC.0
#deIine RIGHTSENSOR PINC.1

#deIine FORWARD 0b00001001
#deIine LEFT 0b00000001
#deIine RIGHT 0b00001000
#deIine STOP 0b00000000

#deIine MOTORPORT PORTA

// Declare your global variables here

void main(void)

// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// FuncOut Func6Out Func5Out Func4Out Func3Out Func2Out Func1Out
Func0Out
// State0 State60 State50 State40 State30 State20 State10 State00
PORTA0x00;
DDRA0xFF;

// Port B initialization
// FuncIn Func6In Func5In Func4In Func3In Func2In Func1In Func0In
// StateT State6T State5T State4T State3T State2T State1T State0T
PORTB0x00;
DDRB0x00;
40


// Port C initialization
// FuncIn Func6In Func5In Func4In Func3In Func2In Func1In Func0In
// StateT State6T State5T State4T State3T State2T State1T State0T
PORTC0x00;
DDRC0x00;

// Port D initialization
// FuncIn Func6In Func5In Func4In Func3In Func2In Func1In Func0In
// StateT State6T State5T State4T State3T State2T State1T State0T
PORTD0x00;
DDRD0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal topFFh
// OC0 output: Disconnected
TCCR00x00;
TCNT00x00;
OCR00x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal topFFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: OII
// Input Capture on Falling Edge
// Timer 1 OverIlow Interrupt: OII
// Input Capture Interrupt: OII
// Compare A Match Interrupt: OII
// Compare B Match Interrupt: OII
TCCR1A0x00;
TCCR1B0x00;
TCNT1H0x00;
TCNT1L0x00;
ICR1H0x00;
ICR1L0x00;
OCR1AH0x00;
OCR1AL0x00;
OCR1BH0x00;
OCR1BL0x00;

// Timer/Counter 2 initialization
41

// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal topFFh
// OC2 output: Disconnected
ASSR0x00;
TCCR20x00;
TCNT20x00;
OCR20x00;

// External Interrupt(s) initialization
// INT0: OII
// INT1: OII
// INT2: OII
MCUCR0x00;
MCUCSR0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK0x00;

// Analog Comparator initialization
// Analog Comparator: OII
// Analog Comparator Input Capture by Timer/Counter 1: OII
ACSR0x80;
SFIOR0x00;

while (1)

// Place your code here
iI(LEFTSENSOR 1 && RIGHTSENSOR 1)
MOTORPORT FORWARD;
else iI(LEFTSENSOR 1 && RIGHTSENSOR 0)
MOTORPORT LEFT;
iI(LEFTSENSOR 0 && RIGHTSENSOR 1)
MOTORPORT RIGHT;
iI(LEFTSENSOR 0 && RIGHTSENSOR 0)
MOTORPORT STOP;


};
}

Anda mungkin juga menyukai