Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
New Microsoft Office Word Document
1. pg. 1
In t er a c t iv e Ven d in g m a c h in e
Presented by:
D eb a h u t i Bh a t t a c h a r y a (ec /11/27)
Ah a n a d a s (ec /11/0 4)
An k it a sen (Ec /11/12)
An im esh m a n n a (ec /11/0 7)
2. pg. 2
CONTENTS:
1 INTRODUCTION (Pg. 3)
2 WORKING PRINCIPLE (Pg. 4 - 5)
3 COMPONENT LIST (Pg. 6)
4 DETAILS OF EACH AND EVERY PART WITH ITS EXPLANATION (Pg. 7 - 23)
5 SPECIAL MENTION OF FREEDUINO DATASHEET AND ALL ITS PARAMETERS (Pg. 23 - 25)
6 PIN CONFIGURATIONS (Pg. 26 - 27)
7 PIN DESCRIPTIONS (Pg. 28 - 30)
8 HARDWARE PROGRAMMING CODE (Pg. 31)
9 OVERVIEW (Pg. 32 - 39)
10 CONCLUSION (Pg. 39)
11 ACKNOWLEDGMENT (Pg. 40)
12 REFERENCES (Pg. 41)
3. pg. 3
INTRODUCTION:
The VENDING MACHINE,which disposes product like chocolate, soft
drinks, chips etc, is not a new topic.
Assemblingof all the parts to it is a complex process. Here we are trying to
make the machine more user friendly. Such that, blind people or visually
impaired persons will be able to operate the machine without others help
as well as operating this machine would be easy for common people too.
So here comes the concept of INTERACTIVEVENDINGMACHINE.
Where, every step of purchasing the product from vending machine will be
easier, communicative and technicallyinteresting.
It can be visualized as following:
Initially the machine is sleep mode, when a person stands in front of the
machine the machine starts to function. It asks for the required product,
then, it gets a user input. Machine functions as per the input then the
operations of coin collector and dispenser starts. The functionality stops
with the collecting the product by the customer. This part will be
discussed in the working principle section.
In order to do so, we have prepared a proximity sensor.
For the both way communication the voice logger is to be used.
Other components such as, piezoelectriccrystal, relay motor, load cell etc.
are to be interfaced with a microcontroller FreeduinoorArduino.
In our project, the full functionality of FREEDUINO has been checked and
with the help of LED, and hardware program ithas been used for detection
of any object coming in the zone of periphery.
4. pg. 4
WORKING PRINCIPLE:
We wanted to design the Interactive Vending Machine in such
a way, so that it will be convenient to each and every body. Apartfrom
that, keeping the cost estimation in mind and other factors under
consideration, here it is challengingto all of us.
Let us assume that the person has alreadyreached the base area
and he’s standing upon the position. The PiezzoElectricCrystals will then
be relaxed. An automaticHIGH voltage will be given as an impulse. Now,
the speaker will be ON. It will come up with all the details. The messages
and responses will be taking place via speaker and microphone
respectively. The conversation will be like this:
(MACHINE): Welcome! I have chocolates with price 5/- & 10/-.Coins are acceptable only.
You can get as manynumbersof chocolatesyou want, by sending the same amt of coin for those many
number of times.
“REPEATION OF THE SAME IN HINDI & BENGALI”
(MAN): Two 10/- ………..
~~~ COINS ARE TRANSACTED WITHIN A TIME INTIMATION OF 10 SECS OTHERWISE THE REQUEST
WONT BE GRANTED ~~~
5. pg. 5
Coins will be taken through coin collector, a container provided with a
nick/ groove. The box is attached with an electro mechanical drive. There
is a program running behind.The software and hardware partis
compounded.
The timing is alsoinstanced through a series of flip flop (with
clock) connected in series. When the timing pulse is generated HIGH, then
the response will be activated through product dispenser. It is in the form
of a tray, just similarto a drawer. When the motor rotates once then only
one chocolate will be disposed. If it is rotated twice, then accordinglytwo
and so on.
~~~ ALL THE ANSWERS WILL NOT ONLY BE SPEAKED RATHER BUZZER WILL ALSO BE SOUNDED IN
ORDER TO ALLERT THE CUSTOMER ~~~
The Interactive vending machine is not only accessible to the normal
persons but to the blind atthe same time by providing the Braille Buttons,
and to the physically challengedones too. Since the chair is at the average
person’s height along with the suitable wheel chair level. All these ideas
were one step towards the innovation. But due to limited time and lack of
application of all implemented technology intoa common platform we are
keeping those further technicalities for the next ones as future scope.
6. pg. 6
Now a briefdescription of each and every component is given below.
COMPONENT LIST:
PIC Microcontroller (PIC16f877A)
or
FREEDUINO or ARDUINO
Stepper Motor (5 volt)
Piezoelectric Cristal
Power supply (230 volt)
LED (LightEmitting Diode)
Microphone
Loud Speaker
Voice logger
Load Cell
Step Down Transformer (230-18volt)
Motor Driver (L293D)
Proximity Sensor
LCD Screen (Liquid Crystal Display)
Relay Driver(ULN2803APG)
7. pg. 7
DESCRIPTION:
All the components those are to be used are described here:
PIC MICROCONTROLLER:
PIC is a family of modified Harvard architecture microcontrollers made by
MicrochipTechnology, derived from the PIC 1650 originally developed by
General Instrument's Microelectronics Division. The name PIC initially
referred to "Peripheral Interface Controller", but now it is "PIC" only. The
first parts of the family were available in 1976;by 2013 the company had
shipped more than twelve billion individual parts, used in a wide variety
of embedded systems. Early models ofPIC had read-only memory (ROM)
or field-programmable EPROM for program storage, some with provision
for erasing memory. Later models used flash memory for program storage,
and some types have program-writeable non-volatile memory. Program
memory and data memory are separated. Data memory is 8 or (later
models)16 bits wide, and most models can only access on-chip data
memory. Program instructions varyin length by family of PIC, and may be
12, 14,16, or 24 bits long. The instruction set alsovaries by model, with
more powerful chips adding instructions for digital signalprocessing
functions. The hardware capabilities ofthe PIC range vary from 8-pin parts
with only a few I/O pins and on-chip clock oscillators up to multiple pin
surface mount packages with many discrete input/output bits, analog
inputs and outputs, and communications ports. Low-power and high-
speed variations existfor many types. The manufacturer supplies both
assemblers and a C compiler for most models. Third party and some open-
source tools are also made. Some parts have in-circuitprogramming
capability; low-costdevelopmentprogrammers are available as well has
8. pg. 8
high-production programmers. PICs are popular with both industrial
developers and hobbyists alike due to their low cost, wide availability,
large user base, extensive collection of application notes, availability oflow
cost or free developmenttools, and serial programming(and re-
programming with flash memory)capability.
The PIC architecture is characterized by its multiple
attributes:
Separate code and data spaces (Harvard architecture).
A small number of fixed-length instructions
Most instructions aresingle-cycle (2 clock cycles, or 4 clock cycles in 8-bit
models), with one delay cycle on branches and skips
One accumulator (W0), the use of which (as sourceoperand) is implied (i.e.
is not encoded in the op-code)
All RAM locations function as registers as both sourceand/or destination of
math and other functions
A hardwarestack for storing return addresses
A small amount of addressabledata space (32, 128, or 256 bytes,
depending on the family), extended through banking
Data-spacemapped CPU, port, and peripheral registers
ALU status flags are mapped into the data space
The programcounter is also mapped into the data space and writable (this
is used to implement indirect jumps).
9. pg. 9
The popular 16F877A that we have used:
The 16F877A is one of the most popular PIC microcontrollers and it's
easy to see why - it comes in a 40 pin DIP pin-out and it has many
internal peripherals. The only disadvantage thatyou could level at it is
that it does not have an internal clock source like most of the other more
modern PIC's. There is an alternativepart16F887/A thathas nearly the
same functionality as the 16F887Abutalso includes an internal clock
like the 16F88 and 18F4550 plus it has nano-watttechnology.
STEPPER MOTOR:
It is an electromechanical device which converts electrical pulses into
discrete mechanical movements. The shaft or spindle of a stepper motor
rotates in discrete step increments when electrical command pulses are
applied to it in the proper sequence. The motors rotation has several direct
relationships to these applied input pulses. The sequence of the applied
pulses is directly related to the direction of motor shafts rotation. The speed
of the motor shafts rotation is directly related tothe frequency of the input
pulses and the length of rotation is directly relatedto the number of input
pulses applied. One of the most significantadvantages of a stepper motor
10. pg. 10
is its ability tobe accurately controlled in an open loop system. Open loop
control means no feedback information aboutposition is needed. This type
of control eliminates the need for expensive sensing and feedback devices
such as optical encoders. Your position is known simply by keeping track
of the input step pulses.
Features:
The rotation angle of the motor is proportional to the input pulse.
The motor has full torque at standstill(ifthe windings are energized)
Precise positioning and repeatabilityof movementsince good stepper
motors have an accuracy of – 5% of a step and this error is non
cumulative from one step to the next.
Excellentresponse to starting/stopping/reversing.
Very reliable since there are no contact brushes in the motor.
Therefore the life of the motor is simply dependanton the life of the
bearing.
The motors response to digitalinput pulses provides open-loop
control, making the motor simpler and less costly to control.
It is possible to achieve very low speed synchronous rotation with a
load that is directly coupled to the shaft.
A wide range of rotational speeds can be realizedas the speed is
proportional to the frequency of the input pulses.
Stepper motor Parameters:
Model : 28BYJ-48
Rated voltage : 5VDC
Number of Phase : 4
11. pg. 11
Speed Variation Ratio : 1/64
Stride Angle : 5.625°/64
Frequency : 100Hz
DC resistance : 50Ω±7%(25℃)
Idle In-traction Frequency : > 600Hz
Idle Out-traction Frequency : > 1000Hz
In-traction Torque >34.3mN.m(120Hz)
Self-positioning Torque >34.3mN.m
Friction torque : 600-1200 gf.cm
Pull in torque : 300 gf.cm
Insulated resistance >10MΩ(500V)
Insulated electricity power :600VAC/1mA/1s
Insulation grade :A
Rise in Temperature <40K(120Hz)
Noise <35dB(120Hz,Noload,10cm)
The bipolar stepper motor
usually has four wires
coming out of it. Unlike
uni polar steppers, bipolar
steppers have no common
center connection. They
Stepper Motor
12. pg. 12
have two independentsets of coils instead. You can distinguish them from
uni polar steppers by measuring the resistance between the wires.). The
ULN2003Acontains seven Darlington transistordrivers and is somewhat
like having seven TIP120 transistors all in one package. The ULN2003A can
pass up to 500 mA per channel and has an internal voltage dropof about
1V when on. It alsocontains internal clampdiodes to dissipate voltage
spikes when driving inductive loads.Tocontrol the stepper, apply voltage
to each of the coils in a specific sequence.
LED:
1. Record indication: D1 (RED)
flashes 3 times within the
600ms, then off for400ms,and
then flashes quickly for 4 times
within 600ms. Now the
recording indication is over.
2. Begin to speak: D1 (RED)is
off for 400ms, and then is on.
Voice during the time while D1
(RED)is on will be recorded by
this module.
3. Recording a voice instruction successfully for the first time: D1 (RED)
off, D2 (ORANGE)on for 300ms.
4. Recording a voice instruction successfully for the first time: D1 (RED)
off, D2 (ORANGE)on for 700ms.
5. Recording failure: D2 (ORANGE)flashes 4 times within the 600ms. In
cases that voice instructions detected twice don’t match, or the sound is too
large, or there is no sound, recording will fail.You need to start over the
recording process for that instruction.
Waiting mode:
13. pg. 13
In waiting mode, D2 (ORANGE)is off, and D1 (RED) is on for 80ms every
other 200ms, fastflashing. In this mode, it doesn’t recognize voice
command, only waiting for serial commands.
Recognition stage:
In identification stage, D2 (ORANGE)is off, and D1 (RED)is on for 100ms
every other 1500ms,slow flashing. In this stage, this module is processing
received voice signal, and ifmatching, itwill send the result immediately
via serial port.
Recording :
Before using it, we have train it by recording voice instructions. Each voice
instruction has the maximum length of 1300ms,which ensures that most
words can be recorded. Once you startrecording, youcan’t stop the
recording process until you finish all the 5 voice instructions recording of
one group. Also, once you start recording, the previous voice instructions
in that group will be erased. In training state, this module doesn’t reply to
any other serial commands.
LED will flash to indicate state. Please refer to the LED part.
MICROPHONE:
A microphone, colloquially mice or mike (/ˈmark/), [1]is an acoustic-to-
electrictransducer or sensor that converts sound
in air into an electrical signal.Microphones are
used in many applications such as telephones,
hearing aids, publicaddress systems for concert
halls and public events, motion picture
production, live and recorded audioengineering,
two-way radios, megaphones, radioand television
broadcasting, and in computers for recording
voice, speech recognition, VoIP, and for non-
acoustic purposes such as ultrasonicchecking.
14. pg. 14
Most microphones today use electromagneticinduction
(dynamicmicrophones), capacitance change (condenser microphones)or
piezoelectricity (piezoelectricmicrophones)to produce an electrical signal
from air pressure variations. Microphones typicallyneed to be connected to
a preamplifierbefore the signal can be amplifiedwith an audiopower
amplifier or recorded.
1FEATURESDESCRIPTION:
• 500-mA-RatedCollectorCurrent The ULN2803A device is a high-
voltage, high-current
(Single Output) Darlington transistor array. The device consists of
eightnpn Darlington pairs thatfeature high-voltage
• High-VoltageOutputs: 50 V outputs
with common-cathode clamp diodes.
• OutputClamp Diodes switching inductive loads.
• Inputs CompatibleWith Various of each Darlington pair is 500 mA.
Typesof Logicpairs may be connected in parallelfor higher current
capability.
• Relay-DriverApplications
• Compatible with ULN2800A Series Applications include relaydrivers,
hammer drivers, lampdrivers, display drivers (LED and gas discharge),
line drivers, and logicbuffers.
LOAD CELL:
15. pg. 15
A load cell is
a transducer that is
used to create an
electrical signal whose
magnitude is directly
proportional to the
force being
measured. The various types of load cells include hydraulicload cells,
pneumatic load cells and strain gauge load cells.
Here we have used a Piezo-electric load cell:
Piezoelectricload cells work on the same principle of
deformation as the strain gauge load cells, but a voltage output is
generated by the basicpiezoelectricmaterial - proportional to the
deformation of load cell. Useful for dynamic/frequentmeasurements of
force. Most applications for piezo-based load cells are in the dynamic
loading conditions, where strain gauge load cells can fail with high
dynamicloadingcycles.
The load or force cell takes many forms to accommodate the
variety of uses throughout research and industrialapplications. The
majority of recent designs use strain gauges as the sensing element,
whether foil or semiconductor. Foil gauges offer the largestchoice of
differenttypes and in consequence tend to be the most used in load cell
designs. Strain gauge patterns offer measurementof tension, compression
and shear forces. Semiconductor strain gauges come in a smaller range of
patterns but offer the advantages of being extremely smalland have large
gauge factors, resulting in much larger outputs for the same given stress.
Due to these properties, they tend to be used for the
miniature load cell designs. Rings are used for load measurement, using a
calibratedmetal ring,the movementof which is measured with a precision
displacementtransducer. A vastnumber of load cell types have developed
over the years,the firstdesigns simply using a strain gauge to measure the
16. pg. 16
directstress which is introduced into a metal elementwhen it is subjected
to a tensile or compressive force. A bending beam type design uses strain
gauges to monitor the stress in the sensing element when subjected to a
bending force.
STEP DOWN TRANSFORMER:
It is one whose secondary voltage is less than its primary
voltage. It is designed to reduce the voltage from the primary windingto
the secondary winding. This kind oftransformer “steps down” the voltage
applied to it.
As a step-down unit, the
transformer converts high-voltage,
low-currentpower into low-voltage,
high-currentpower. The larger-gauge
wire used in the secondary windingis
necessary due to the increase in
current. The primary winding,which
doesn’t have to conduct as much
current, may be made of smaller-gauge
wire.
THE TRANSFORMER THAT IUSED IN THE PROJECT
Model: GPC-1005
230V primary to110V secondary
Power Rating: 300VA
o It steps down from 230-18volt.The 18v is dividedinto2 parts:
12v and 5v.
o 12v is given to the motor via the transistors. 5v supplied to MC.
17. pg. 17
MOTOR DRIVER:
It is a device or group of devices that serves to govern in some
predeterminedmanner the performance of an electric motor.
A motor controller mightinclude a manual or automaticmeans
for starting and stopping the motor, selecting forward or reverse rotation,
selecting and regulating the speed, regulatingor limiting the torque, and
protecting againstoverloads and faults.
Stepper motor drivers:
A stepper, or stepping, motor is a synchronous, brushless, high
pole count, poly phase motor. Control is usually, but not exclusively, done
open loop, i.e. the rotor position is assumed to follow a controlled rotating
field. Because of this, precise positioning with steppers is simpler and
cheaper than closed loop controls.
Modern stepper controllers drive the motor with much higher
voltages than the motor nameplate rated voltage, and limitcurrentthrough
chopping. The usual setup is to have a positioning controller, known as an
indexer, sending step and direction pulses to a separate higher voltage drive
circuit which is responsible for commutation and current limiting.
ProximitySensor:
A proximity sensor is a sensor able to detect the presence of
nearby objects without any physical contact. A proximity sensor often
emits an electromagneticfield or a beam of electromagneticradiation
18. pg. 18
(infrared, for instance), and looks for changes in the field or return signal.
The object being sensed is often referred to as the proximity sensor's target.
Differentproximity sensor targets demand differentsensors. For example,
a capacitive or photoelectric sensor mightbe suitable for a plastictarget; an
inductive proximity sensor always requires a metal target. The maximum
distance that this sensor can detect is defined "nominal range". Some
sensors have adjustments of the nominal range or means to reporta
graduated detection distance. Proximitysensors can have a high reliability
and long functional life because of the absence of mechanical parts and lack
of physical contact between sensor and the sensed object. Proximity sensors
are commonly used on smartphones to detect (and skip) accidental touch
screen taps when held to the ear during a call.[1]They are also used in
machine vibration monitoring tomeasure the variation in distance between
a shaft and its support bearing. This is common in large steam turbines,
compressors, and motors that use sleeve-type bearings. International
Electrotechnical Commission (IEC) 60947-5-2defines the technical details
of proximity sensors.
LCD:
A liquid-
crystal display (LCD)is
a flat panel display,
electronic visual
display, or video
display thatuses the
lightmodulating
properties of liquid
crystals. Liquidcrystals
do not emit light
directly. LCDs are
available to display
Proximity Sensors.
19. pg. 19
arbitraryimages (as in a general-purpose
computer display)or fixed images which can be
displayedor hidden, such as preset words, digits,
and 7-segmentdisplays as in a digitalclock.
They use the same basictechnology, except that
arbitraryimages are made up of a large number of
small pixels, while other displays have larger
elements.
LCDs are used in a wide range of applications
including computer monitors, televisions,
instrumentpanels, aircraftcockpit displays, and
signage.
They are common in consumer devices such as
DVD players, gamingdevices, clocks, watches,
calculators, and telephones, and have replaced
cathode ray tube (CRT) displays in most
applications. They are available in a wider range
of screen sizes than CRT and plasma displays,and
since they do not use phosphors, they do not
suffer image burn-in. LCDs are, however,
susceptible to image persistence.
The LCD screen is more energy efficient and can
be disposed of more safely than a CRT. Its low
electrical power consumption enables itto be used
in battery-poweredelectronicequipment.
It is an electronicallymodulated optical device
made up of any number of segments filled with
liquid crystals and arrayedin front of a light
source (backlight)or reflector to produce images
in color or monochrome.
Liquid crystals were firstdiscovered in 1888.[2]By
2008, annual sales of televisions with LCD screens
Seven segment LCD:
LCD :
The pin diagram:
Visual:
20. pg. 20
exceeded sales of CRT units worldwide, and the CRT became obsolete for
most purposes.
RELAY DRIVER(ULN2803APG):
A relay is an electro-magneticswitch which is useful if you want
to use a low voltage circuitto switch on and off a lightbulb (or anything
else) connected to the 220v main supply. The current needed to operate the
relay coil is more than can be supplied by
most chips (op. amps etc), so a transistor is
usually needed.
Relay Driverwith Flip-Flop
In many situations in which
you use a relay, you will alsoneed a bi-
stable flip flop. One useful integrated
circuit flip-flop is the 4013. (This IC actually
contains two flip-flops.) With the connections as shown in the circuit
below, when the voltage on pin 3 changes (rapidly)from 0v to the positive
supply voltage, the flip-flop changes state (it “flips”). The next time the
same thing happens, the flip-flop changes back to its originalstate again (it
“flops”).
ULN2803APG:
The ULN2803APG series are high−voltage, high−current
Darlington drivers comprised of eightNPN Darlington pairs.
All units feature integral clampdiodes for switching inductive
loads.
Applications include relay, hammer, lampand display(LED)drivers.
21. pg. 21
Features:
Output current (single output) 500 mA (max)
• High sustaining voltage output 50 V (min)
• Output clamp diodes
• Inputs compatible with various types of logic.
• Package Type−APG : DIP−18pin.
Piezoelectric sensors:
A piezoelectricsensor is a device
that uses the piezoelectric effect, to
measure changes in pressure, acceleration,
temperature, strain, or force by converting
them to an electrical charge. The
prefix piezo -is Greek for 'press' or
'squeeze'.
Piezoelectricsensors are versatile
tools for the measurementof various processes. They are used for quality
assurance, process control, and for research and developmentin many
industries. Pierre Curie discovered the piezoelectriceffect in 1880, butonly
in the 1950s did manufacturers begin touse the piezoelectriceffect in
industrial sensing applications. Since then, this measuring principle has
been increasinglyused, and has become a mature technology with
excellentinherentreliability.
It has been successfully used in various applications, such as
in medical, aerospace, nuclear instrumentation, and as a tiltsensor in
consumer electronicsor a pressure sensor in the touch pads of mobile
phones. In the automotive industry, piezoelectricelements are used to
monitor combustion when developing internalcombustion engines.
22. pg. 22
The sensors are either directly mounted into additional holes into the
cylinder head or the spark/glow plug is equipped with a built-in miniature
piezoelectricsensor.
One disadvantage of piezoelectricsensors is that they cannot be used for
truly static measurements.
Sensor Design:
Based on piezoelectrictechnology various physical quantities can be
measured; the most common are pressure and acceleration. For pressure
sensors, a thin membrane and a massive base is used, ensuring thatan
applied pressure specifically loads the elements in one direction. For
accelerometers, a seismicmass is attached to the crystal elements. When
the accelerometer experiences a motion, the invariantseismicmass loads
the elements according to Newton's second law of motion F=m a.
The main difference in working principle between these two cases
is the way they apply forces to the sensing elements. In a pressure sensor, a
thin membrane transfersthe force to the elements, while in accelerometers
an attached seismicmass applies the forces.
Sensors often tend to be sensitive to more than one physical
quantity. Pressure sensors show false signal when they are exposed to
vibrations.Sophisticated pressure sensors therefore use acceleration
compensation elements in addition to the pressure sensing elements.
23. pg. 23
By carefully matching those elements, the acceleration signal (released
from the compensation element) is subtracted from the combined signal of
pressure and acceleration to derive the true pressure information.
Vibration sensors can also harvestotherwise wasted energy from
mechanical vibrations.This is accomplished by using piezoelectric
materials to convert mechanical strain intousable electrical energy.
Now, let us explain the freeduinodata sheet.
FREEDUINO DATASHEET
ATMEGA 328P 8-BIT
MICROCONTROLLER WITH 32-K
BYTES IN SYSTEM
PROGRAMMABLE FLASH
24. pg. 24
DATASHEET
Features:
o High Performance, Microcontroller Family
o Advanced RISCArchitecture
o 131 Powerful Instructions – Most Single Clock Cycle Execution
o 32 x 8 General Purpose Working Registers
o Fully StaticOperation
o Up to 20 MIPS Throughput at 20MHz
o On-chip 2-cycle Multiplier
o High Endurance Non-volatile Memory Segments
o 4/8/16/32KBytes of In-System Self-Programmable Flash program
memory
o 256/512/512/1KBytes EEPROM
o 512/1K/1K/2KBytes Internal SRAM
o Write/EraseCycles: 10,000Flash/100,000 EEPROM
o Data retention: 20 years at 85 C/100years at25 C
o Optional Boot Code Section with IndependentLock Bits
o In-System Programmingby On-chipBoot Program
o True Read-While-Write Operation
o ProgrammingLock for Software Security
o Capacitive touch buttons, sliders and wheels
o QTouch and QMatrix®acquisition
o Up to 64 sense channels
o Peripheral Features
o Two 8-bitTimer/Counters with Separate Prescalerand Compare mode
o One 16-bitTimer/Counter with Separate Prescaler, Compare Mode,
and
o Capture Mode
o Real Time Counter with Separate Oscillator
25. pg. 25
o Six PWM Channels
o 8-channel 10-bitADCin TQFP
and QFN/MLF package
o Temperature Measurement
o 6-channel 10-bitADCin PDIP
Package
o Temperature Measurement
o Programmable Serial USART
o Master/Slave SPI Serial
Interface
o Byte-oriented 2-wire Serial
Interface (Philips I2C
compatible)
o Programmable Watchdog Timerwith Separate On-chipOscillator
o On-chip Analog Comparator
o Interrupt and Wake-up on Pin Change
o Special Microcontroller Features
o Power-on Reset and Programmable Brown-outDetection
o Internal CalibratedOscillator
o External and Internal InterruptSources
o Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-
down, Standby, and Extended Standby
o I/O and Packages
o 23 Programmable I/O Lines
o 28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLFand 32-pad QFN/MLF
o Operating Voltage:
o 1.8 - 5.5V
o Temperature Range:
o -40 Cto 85 C
o Speed Grade:
o 0 - 4MHz@1.8 -5.5V, 0 - 10MHz@2.7-5.5.V, 0 - 20MHz @ 4.5 - 5.5V
o Power Consumption at 1MHz, 1.8V, 25 C
o Active Mode: 0.2mA
o Power-down Mode: 0.1μA
28. pg. 28
Pin Descriptions:
VCC: Digital supply voltage
GND: Ground
Port B (PB7:0)XTAL1/XTAL2/TOSC1/TOSC2:
Port B is an 8-bitbi-directionalI/O port with internal pull-
up resistors (selected for each bit). The Port B output buffers have
symmetricaldrive 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 tristated when a
reset condition becomes active, even if the clock is not running.
Depending on the clock selection fuse settings, PB6 can be used as
input to the inverting Oscillator amplifier and input to the internal clock
operating circuit. Depending on the clock selection fuse settings, PB7 can
be used as output from the inverting Oscillator amplifier.
If the Internal CalibratedRCOscillator is used as chip clock source,
PB7...6 is used as TOSC2...1 inputfor the
Asynchronous Timer/Counter2 ifthe AS2 bitin ASSR is set.
The various special features of Port B are elaboratedin ”Alternate
Functions of Port B” on page 82 and ”System
Clock and Clock Options” on page 27.
Port C (PC5:0)
Port C is a 7-bitbi-directionalI/O port with internal pull-up
resistors (selected for each bit). The PC5...0 output buffers have
symmetricaldrive characteristics with both high sink and source capability.
29. pg. 29
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 tristated
when a reset condition becomes active, even if the clock is not running.
PC6/RESET:
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O
pin. Note that the electrical characteristics of PC6 differ from those of the
other pins of Port C.
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a
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. The minimum
pulse length is given in Table 29-11on page 305. Shorter pulses are not
guaranteed to generate a Reset.
The various special features of Port C are elaboratedin
”Alternate Functions of Port C” on page 85.
Port D (PD7:0):
Port D is an 8-bitbi-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 tristated when a reset condition
becomes active, even if the clock is not running.
The various special features of Port D are elaborated in
”Alternate Functions of Port D” on page 88.
30. pg. 30
AVCC:
AVCC is the supply voltage pin for the A/D Converter, PC3:0, and
ADC7:6. It should be externallyconnected to VCC, even if the ADCis not
used. If the ADC is used, it should be connected to VCC through a low-
pass filter.
Note that PC6...4 use digital supply voltage, VCC.
AREF: AREF is the analog reference pin for the A/D Converter.
ADC7:6 (TQFP andQFN/MLF Package Only):
In the TQFP and QFN/MLFpackage,ADC7:6 serve as
analog inputs to the A/D converter. These pins are powered from the
analog supply and serve as 10-bitADCchannels.
31. pg. 31
HARDWARE PROGRAMMINGLIST:
void set up()
{
pinMode(A2,INPUT);
}
void loop()
{
if (digitalRead(A2)==HIGH)
digitalWrite(13,HIGH);
else
digitalWrite(13,LOW);
}
32. pg. 32
Overview:
The ATmega328/Pis a low-power CMOS 8-bitmicrocontroller
based on the AVR enhanced RISC architecture. By executing powerful
instructions in a single clock cycle, the
ATmega48A/PA/88A/PA/168A/PA/328/Pachieves 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
ArithmeticLogicUnit(ALU), allowing twoindependentregisters to be
accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten
times faster than conventional CISC microcontrollers.
The ATmega48A/PA/88A/PA/168A/PA/328/Pprovides the
following features: 4K/8Kbytes ofIn-System Programmable Flash with
Read-While-Write capabilities, 256/512/512/1Kbytes EEPROM,
512/1K/1K/2Kbytes SRAM, 23 generalpurpose I/O lines, 32 general
purpose working registers, three flexible Timer/Counters with
compare modes, internal and external interrupts, a serial programmable
USART, a byte-oriented 2-wire Serial Interface, an SPI serial port, a 6-
channel 10-bitADC (8 channels in TQFPand QFN/MLFpackages),a
programmable Watchdog Timerwith internal Oscillator,and five software
selectable power saving modes. The Idle mode stops the CPU while
allowing the SRAM, Timer/Counters,USART,2-wire SerialInterface, SPI
port, and interruptsystem to continue functioning. The Power-down mode
saves the register contents but freezes the Oscillator, disablingall other
chip functions until the next interruptor hardware reset. In Power-save
mode, the asynchronous timer continues to run, allowing the user to
maintain a timer base while the rest of the device is sleeping.
The ADC Noise Reduction mode stops the CPU and all I/O
modules except asynchronous timer and ADC, to minimize switchingnoise
during ADCconversions. In Standby mode, the crystal/resonator
33. pg. 33
Oscillator is running while the rest of the device is sleeping. This allows
very fast start-up combined with low power consumption.
Atmel®offers the QTouch® libraryfor embedding capacitive
touch buttons, sliders and wheels functionality into AVR®
microcontrollers. The patented charge-transfersignalacquisition offers
robust sensing and includes fully denounced reporting of touch keys and
includes Adjacent Key Suppression® (AKS™)technology for unambiguous
detection of key events. The easy-to-use QTouch Suite toolchain allows you
to explore, develop and debug your own touch applications.
The device is manufactured using Atmel’s high density non-
volatile memory technology. The On-chip ISP Flash
allows the program memory to be reprogrammedIn-System through an
SPI serial interface, by a conventional non-volatile memory programmer, or
by an On-chip Boot program running on the AVR core.
The Boot program can use any interface to download the
application program in the Application Flash memory. Software in the
Boot Flash section will continue to run while the Application Flash section
is updated, providing true Read-While-Write operation. By combining an
8-bitRISC CPU with In-System Self-Programmable Flash on a monolithic
chip, the Atmel ATmega48A/PA/88A/PA/168A/PA/328/Pis a powerful
microcontroller thatprovides a highly flexible and cost effective solution to
many embedded control applications.
The ATmega48A/PA/88A/PA/168A/PA/328/PAVR is
supported with a full suite of program and system developmenttools
including: C Compilers, MacroAssemblers,Programebugger/Simulators,
In-Circuit Emulators, and Evaluation kits.
ATmega48A/PA/88A/PA/168A/PA/328/Psupport a real
Read-While-Write Self-Programmingmechanism.
There is a separate Boot Loader Section, and the SPM instruction
can only execute from there. In ATmega 48A/48PA there is no Read-While-
Write support and no separate Boot Loader Section. The SPM instruction
can execute from the entire Flash.
34. pg. 34
Resources
A comprehensive set of developmenttools, application notes and
datasheets are available for download on
http://www.atmel.com/avr.
1.
Data Retention
Reliability Qualification results show that the projected data retention
failure rate is much less than 1 PPM over
20 years at 85°Cor 100 years at 25°C.
About Code Examples
This documentation contains simple code examples thatbriefly show how
to use various parts of the device.
These code examples assume that the part specific header file is included
before compilation. Be aware thatnot
all C compiler vendors include bit definitions in the header files and
interrupthandling in C is compiler
dependent. Please confirm with the C compiler documentation for more
details.
For I/O Registers located in extended I/O map, “IN”, “OUT”, “SBIS”,
“SBIC”, “CBI”, and “SBI” instructions must
be replaced with instructions that allow access to extended I/O. Typically
“LDS” and “STS” combined with
“SBRS”, “SBRC”, “SBR”, and “CBR”.
CapacitiveTouch Sensing:
35. pg. 35
The Atmel®QTouch® Libraryprovides a simple to use solution to realize
touch sensitive interfaces on most
Atmel AVR®microcontrollers. The QTouch Library includes supportfor
the Atmel QTouch and Atmel QMatrix®
acquisition methods.
Touch sensing can be added to any application by linking the appropriate
Atmel QTouch Libraryfor the AVR
Microcontroller. This is done by using a simple set of APIs to define the
touch channels and sensors, and then
calling the touch sensing APIs to retrieve the channel information and
determine the touch sensor states.
The QTouch Libraryis FREE and downloadable from the Atmel website at
the following location:
www.atmel.com/qtouchlibrary. For implementation details and other
information, refer to the Atmel QTouch
Library User Guide - alsoavailable for download from Atmel website.
In order to maximize performance and parallelism, the AVR uses a
Harvardarchitecture – with separate
memories and buses for 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-fetched from the program memory.
This concept enables instructions to be executed in every clock cycle. The
program memory is In-System
Reprogrammable Flash memory.
The fast-access Register File contains 32 x 8-bitgeneral purpose working
registers with a single clock cycle
access time. This allows single-cycle ArithmeticLogicUnit(ALU)
operation. In a typical ALU operation there are --------
36. pg. 36
Program Memory
Instruction
Register
Decoder
Program Counter
Control Lines
(32 x 8) General Purpose Registers
ALU
Status and Control
I/O Lines
EEPROM
Data Bus 8-bit
Data SRAM
Direct Addressing
Indirect Addressing
Interrupt
Unit SPI
Unit Watchdog
37. pg. 37
Timer Analog
Comparator I/O Module 2I/O Module1 I/O Module n:
Register File – in one clock cycle.
Six of the 32 registers can be used as three 16-bitindirect
address registerpointers for Data Space addressing– enabling efficient
address calculations. One of the these address pointers can also be used as
an address pointer for look up tables in Flash program memory. These
added function registers are the 16-bitX-, Y-, and Zregister,
described later in this section.
The ALU supports arithmeticand logicoperations between
registers or between a constant and a register.
Single register operations can also be executed in the ALU.
After an arithmeticoperation, the Status Register is updated to reflect
information aboutthe resultof the operation.
Program flow is provided by conditional and unconditional
jump and call instructions, able to directly address the whole address
space. Most AVR instructions have a single 16-bitword format. Every
program memory address contains a 16- or 32-bitinstruction.
Program Flash memoryspace is divided in two sections, the
Boot Program section and the Application Program section. Both sections
have dedicated Lock bits for write and read/write protection. The SPM
instruction that writes into the Application Flash memory section must
reside in the Boot Program section.
During interrupts and subroutine calls, the return address
Program Counter (PC) is stored on the Stack. Stack is effectively allocated
in the general data SRAM,and consequently the Stack size is only limited
by the total SRAM size and the usage of the SRAM. All user programs
must initialize the SP in the Reset routine (before subroutines or interrupts
38. pg. 38
are executed). The Stack Pointer (SP) is read/write accessible in the I/O
space.
The data SRAM can easily be accessed through the five different
addressingmodes supported in the AVR
architecture.
The memory spaces in the AVR architecture are all linear and
regular memory maps.
A flexible interruptmodule has its control registers in the I/O
space with an additional Global InterruptEnable bit
in the Status Register. All interrupts have a separate Interrupt Vector in the
Interrupt Vector table. The interrupts have priority in accordance with their
Interrupt Vector position. The lower the Interrupt Vector address, the
higher the priority.
The I/O memory space contains 64 addresses for CPU peripheral
functions as Control Registers, SPI, and other I/O functions. The I/O
Memory can be accessed directly, or as the Data Space locations following
those of the Register File, 0x20 -0x5F. In addition, the
ATmega48A/PA/88A/PA/168A/PA/328/Phas Extended I/O space
from 0x60 - 0xFF in SRAM where only the ST/STS/STD and
LD/LDS/LDDinstructions can be used.
ALU – ArithmeticLogic Unit:
The high-performance AVR ALU operates in direct connection with all the
32 general purpose working registers.
Within a single clock cycle, arithmeticoperations between general
purpose registers or between a register and an immediate are executed.
The ALU operations are dividedintothree main categories – arithmetic,
logical, and bit-functions. Some implementations ofthe architecture also
provide a powerful multiplier supporting both signed/unsigned
multiplication and fractional format. See the “Instruction Set” section for a
detailed description.
39. pg. 39
Status Register:
The Status Register contains information aboutthe resultof the
most recently executed arithmeticinstruction.
This information can be used for altering programflow in order
to perform conditional operations. Note that the Status Register is updated
after all ALU operations, as specified in the Instruction Set Reference. This
will in many cases remove the need for using the dedicated compare
instructions, resulting in faster and more compact code.
The Status Register is not automaticallystored when entering an
interruptroutine and restored when returning from an interrupt. This must
be handled by software.
CONCLUSION:
Due to less time we have shorten the project. Design of the
detection of any object by FREEDUINO has been done, by perceiving the
electromagneticradiations (IR RADIATIONS)and keeping the LED ON.
Other parts, such as, voice logger and the casing, is kept for the
future group who will work on our project. The interfacing would be easier
as we have used FREEDUINO as the microcontroller. We wish the best to
the future groups to complete the project.
40. pg. 40
ACKNOWLEDGMENT
The entire project is done under the guidance of our most respected
Director Sir, Dr. DipankarSarkar and Miss. SukanyaRoy.
We are alsothankful to our E.C.E. faculty members, particularly
Mr. Abhishek Saha, Mr.Rajarshi Mukhopadhyay & Mrs. Sayani De Sarkar.