AUTOMATIC BOTTLE FILLING SYSTEM
Thesis submitfuil in partful fulJillment of the requiremen8 lor the degee
oI
Bachelor of TechnologSr
In Instrumentation E ngineering
by
Sandhan Jyoti Dutta (Gau4-l l/74)Pooja Bhattacharjee (Gau-C-tt ll-203)
Nirmal Basumatary (Gau-C-l l/89)
Under the guidance ofMr. Dipenkar Sutradhar
DEPARTMf, NT OF INSTRUMENTATION ENGINEERING
atdq fuftr|-+t "i-:en=T
els-{t-{rsCENTRAL INSTITUTE OF' TECHNOLOGY KOKRAJHAR
(A Centrally Funded Institute under Ministry of HRD, Govt. of India)BODOLAND TERRITORIAL AREAS DISTRICTS :: KOKRAJHAR
:: ASSAM::783370
Website: www.cit ac.in
MAY 2OI5
DECLARATION
WE hErEbY dECIATE thAt WOrK ENtitICd *ATITOMATIC BOTTLE FILLING SYSTEM',, iS AN
authentic record of our own work carried out at centrar Institute of rechnology, Kokrajhar, forthe award of degree of B Tech' in Instrumentation Engineering. project comprises of ouroriginal work pursued under the guidance of Mr. Dipankar sutradhar. The results embodiedin this report have not been submitted to any other Institute or University for any award. Theinformation provided is correct to the best ofour knowledge and belief
Date: I 8n May, 201 5
(SANDHAN JYOTI DUTTA)
University Roll: Gau-C-l | /74
University Registration No:
014612 of the year 201t-12
(POOJA BHATTACHARJEE)
University Roll: Gau_c_l I /l_203
University Registration No: 0gIgl5 ofthe year 201 2- | .3
(NIRMAL BASUMATARY)
Universiry Roll: Gau -C_l l/g9
University Registration No:
014654 ofthe year 201| _12
DEPARTMENT OF INSTRUMENTATION ENGINEERING
CENTRAL INSTITUTE OF TECHNOLOGY, KOKRAJHAR
May 2015
CERTIFICATE
This is to c€rtify that Sandhan Jyoti Dutta, Poojo Bhsttacharjee, Nirmel Basumatery have
uccessfully complaed their project entitled 'AUTOMATIC BOTTLE FILLING SYSTEM'which is a bonafide work carried out by themselves in partial fulfillment of Bachelor ofTechnology in Instrurnentation Engineering from Central lnstitute oftechnology, Kokajhar.
Sr"V"'(Ject Duttr)
HOD
Dept' of lnstrumentation Engineering
DEPARTMENT OF INSTRUMENTATION ENGINEARING
CENTRAL INSTITUTE OF TECIINOLOGY, KOKRAJHAR
Mav 2015
CERTIFICATE
This is to certiry that Sandhan Jyoti Dutta, Pooja Bhattscharjee and Nirmal Basumstary
have successfully completed theh project entitled "AUTOMATIC BOT'TLE FILLING
SYSTEM" which is a bonafide work carried out by tiemselves in panial fulfillment of
Bachelor of Technology in lnsfumentation Engineering from Central Institute of technology,
Kokrajhar. The work was carried out under my supervision during the academic session Aug
,2014-Mry, 2015.
Dept' of lnstrurnentation Engineering
(Dipankar Sutradhar)
DEPARTMENT OF INSTRUMENTATION ENGINEERING
CENTRAL INSTITUTE OF TECHNOLOGY, KOKRAJHAR
May 2015
CERTIFICATE BY THE BOARD OF EXAMINERS
This is to certifr that the project work entitled .AUTOMATIC BOTTLE FTLLING
SYSTEM" submitted by Sandhan Jyoti Dutt4 pooja Bhattacharjee, Nirmal Basumatary to the
Deparrnent of Instrumentation Enginecring of central Institute of rechnology, Kokajhar has
been examined and evaluated.
The project work has been prepared as per the regulations of central Institute of rechnology
and qualifies to be accepted in partial fulfilment of the requirement for the degree ofB. Tech.
Project Co.ordinator Board of Exrminers
Jr/A/Y- trJ-'
ACKNOWLEDGEMENT
On the very outset of this report, we would like to extend our sincere & heartfelt
obligation towards all the person who helped us in this project. Without their active guidance,
help, cooperation & encouragement, we could not have made these project work.
First and foremost, we would like to express our sincere gratitude to our guidg Mr.
Dpankar Sutradhar, we were privileged to experience a sustained help and involved interest
fiom his side. This bucked our enthusiasm even further and encouraged us to boldly step into
what was a totally dark and unexplored area before us. He always fuelled us to think out ofthe
box. I would like to thank the entire staff member for motivation guidance and support.
We are indebted to a number of friends and well-wishers who have extended their co-
opoation and help in the preparation of the project. Last but not the least; it goes incomplete
without saying that we are deeply indebted to our parents for their support and their patience.
g^'t\*IS &Sh^Sandhan Jvoti Dutta
Wj" 6fuu"t*Pooja Bhattacharjee
D*Min n al Satr>t't wttl latt/
Nirmal Basumatary
ABSTRACT
In this era of industrializatior\ the automation world is shrinking the need of humans to assist
machinery. Looking at the present scenario an automatic bottle filling system which uses
ultasonic sensors for the level m@surement and a solenoid valve in order to fill the liquid in the
bcde is desigrcd. Traditional methods of bottle filling involved placing bottles onto a conveyor
and filling only one bottle at a time in order to overcome this short come this project presents a
nodel filling bottles simultaneously. Microcontoller is used as the controller to control the
sutomatic functioning of this machine which consists of a conveyor belt and a filling station
.The successful implementation ofa proximity sensor using IR sensor for the bottles canied by
the conveyor belt can be depicted from the project, this IR sensor stops the gear motor to initiate
0re filling process. The frlling section is initiated with the help ofa nozzle and solenoid valve.
This project stands out of all the other filling system as it uses an ultrasonic sensor which gives
I great deal of accurary as it avoids human intervention and as a result enors are negligible. The
Butomatic filling machine is developed with the aim that it paves a new path to automation with
cost effectiveness. Thus, this project marks an effective and accruate process of bottle filling.
Keywords: Microconboller, Gear Motor, Nozzlq Ultrasonc sensor
vrl
Title page
Declaration
Certificate
Acknowledgement
Abstract
Comots
List of Figures
l.l In$odlction
t.2 Objective
2.1 Literatue Review
2. l. I Loading section
2. 1.2 Detection section
2.1.3 Solenoid control
2. 1.4 Filling section
2.2 Der;ign
2.2.1 Microcontrol ler
2.2.2 Water level sersor
2.2.3 DC gear motor
2.2.4 Conveyor belt
2.3 lludware Components
CONTENTS
CHAPTER I
INTRODUCTION
CHAPTER2
BACKGROUND THEORY
i
ii
iii
vi
vii
viii
x
vIl
CHAPTER-3
SYSTEM DESIGN
3.1Block Diagram
3.2 Flow chart
3.3 Circuit Diagram of Motor Driver
3.3. 1 Circuit Description
3.4 Circuit Diagram of Ultrasonic Sensor
3.4. I Circuit Description
3.5 Configuring 805 I microcontroller
3.6 Working
3.7 Algorithm
3.8 Application
7
8
9
9
t0
l0
l0
lll2
l3
4.1 Result
CHAPTER 4
RESULT AND DISCUSSIONS
CHAPTER-5
CONCLUSION AND FUTURE WORK
t4
5.1 Conclusion
5.2 Future Scope
5.3 Reference
APPENDIX
Appendix A: Source code of motor
Appendix B: Source code for ultrasonic sensor
Appendix c: Darasheet of AT89c52
Appendix D: Datasheet of LM293d
t5
l5
l6
tx
List of Figures
Fig 2. l: IR Detection
Fig 2.2: Microcontroller
Fig 2.3: Ulnasonic sansor
Fig 2.4: DC Gear motor
Fig 2.5: Conveyor Belt
Fig 3.1: Block diagram of the project
Fig 3.2: Flow Chart
Fig 3.3: Schematic circuit in proteus
Fig 3.4: Schematic circuit of ultrasoruc sensor
Page No
2
3
4
f
5
7
8
9
l0
CHAPTER I
INTRODUCTION
l.llntroduction
A plant has many sections like processing; rnanufacruring packing storage etc. In this project
we have concentrated on a specific part of plant, which is filling of bottles. The field ofautomation has had a notable impact in a wide range of industries beyond manufactunng.
Autornation is the use of control systems and information technologies to reduce the need forhuman work in the production of goods and services. In the scope of industrialization
sutomation is a step beyond mechanization. Automation greatly decreases the need for human
and meftal requirements as well. Automation plays an increasingly imponarr role in the world
economy. One of the important applications of automation is in the soft drink and other
bevoage industries, where a particular liquid has to be filled continuously. For these kinds ofapplication the rend is switching from the individual device or machine toward continuous
automation solutions. The aim of this project is to design an microcortroller based automatic
bctle filling system that sense the presence of bottle and level of liquid in it and then fills itaccordingly up to a fixed level. In this project we dweloped proximity sensor using infiared that
detects the presence of bottle and for detecting Ievel we have used ultrasonic sensors .Here we
used nozle to control tte f ling of liquid wfiich is dependent on the solenoid tap. There are
various process to measur€ liquid level counting frorn a droping of simple measuring scale to
complex capacitive liquid level sensor but, these processc require direct contact with the
container ard the liquid, which can again be a source of various errors. Therefore, we have
mrne up with an idea of using a difrerent source of measuring i.e., the ulbasonic distance
measurement apparahs is the untotrched measure and has the simple structue, inexpensive cost
, no electromagnetic interferences .
1.2 Objective
The project is aimed to meet dre following objectives:
. To design and implement automated liquid filling machine
o To learn the concept of electrical DC moto system
. To apply selector conveyor conc€pt
o To implonent hardware installatio4 wiring mechanical mounting
o To learn microconfoller progrsmming
CHAPTER 2
BACKGROUND THEORY
2.1 Literature Review
Tlrcre are a few reviews done
understanding on th" 0",","0,"11 "l'J
:il::::ilJ:H,:'"::*i::;., fi:ffi :T:gained from diffoent joumars, internet sources, books and previous proJects. The focus of thisproject is to anaryze principre and method on the usage of automatic fiting method and theultasonic technique of riquid lever m@surement. There are four basic operationar parts in thisproject namely roading sectioq detection of bottre, solenoid control and rever detection.
2.1.1 Loading Section
The loading section was designed to store the enpty boftre before the process was started.Microcontro'er sends the signal to the gear motor and it starts rotating and empty bottle comesin dre belt and moves till it reaches the nozzle opening where there is a IR sensor which detectsfte bottle and the filling starts.
2.1.2 D etection Secti on
IR Senson work by using a specific liglrt sensor to detect a select light wavelength in the Infia_Red (rR) spectrum By using an LED which produces right at the same waverength as what thesensor is rooking for' we can rook at the intensity of the received right. when an object is croseto the sensor' the right from the LED bounces off the object and into the right sensor. Thisresults in a large jump in the intensity, which we already know can
threshold.be detected usmg
.Jc .a,r.d p-Fn. _ no rR rgar. .r.oc-d b, orE.
Fig 2. l: IR Detection
2.1.3 Solenoid Control
The term refers to a variety of transducer devices that convert energy into linear motion. The
term is also often used to refer to a solenoid valvg which is an integrated device containing an
eleclromechanical solenoid which actuates either a pneumatic or hy&aulic valve, or a solenoid
switch, which is a specific type of relay that internally uses an electromechanical solenoid to
operate an electrical switch; for examplq an noz.z)e starter solenoid, which is an
elecromechanical solenoid used in our project
2.1.4 Filling Section.
The filling section comprises of the nozzle and the solenoid tapping .The solenoid taps the
nozzle to open and the filling starts .the nozzle is accompanied with a ulnasonic sensor module
HCSRO4 which keeps a vigil on the liquid level of the bottle. As the level is reached the nozzle
stops and the signal is received by the microcontroller which in turn sends the sigul to the gear
mdd which moves the bottle till the end
2.2 Design
The design of ttre project has an electronic and mechanical s€tup which contains certain
building blocks of the project which are discussed below.
2.2.1 Microcontroller
Microco roller is a computer or a chip that is programmed to perform almost any control
sequencing monitoring and display the function. Because of its relatively low cost, it becomes
the natural choice to the designer. Microcontroller is designed to be all of that in one. lts great
advantage is no other extonal components are needed for its application because all necessary
peripherals are already built into it. Thus, we can save the time' space and cost.
Fig 2.2:AT89C52 Chip
Featurcs
. 8K Byes of In-System Reprogrammable Flash Memory
. Endurance: 1.000 Writey'Erase Cycles
. Fully Static Operation: 0 Hz to 24 MHz
. Tlreelevel Program Memory Lock
. 256 x 8-bit Internal RAM
. 32 Programmable VO Lines
. Three 16-bit Timer/Counters
. Eight Interrupt Sources
. Programmable Soial Channel
. Low-power Idle and Power-down Modes
2.2.2 W ater Level Sensor
To make special water level sensor we have used ultrasonic sensor module. Ultrasonic sensors
(also known as ransceivers when they both send and receive) work on a principle similar tomdar or sonar which waluate atributes of a target by interpreting the echoes from radio orsound waves respectively. ultrasonic sensors generate high fiequency sound waves and
evaluate the echo which is received back by the sensor. Sensors calculate the time interval
between sending the signal and receiving the echo to determine the distance to an obiect.
Fig 2.3: Ultrasonic Sensor
2.2.3 DC Geared MotorMotor with metal gearbox
I. 12VDC
2. No load current 800mA (Max| Load current 9.5 A3. Rated Torque- l0Kg-cm
4. Rated speed -30 rpm
2.2.4 Conveyor Design
conveyor suppries a reliabre means when we need to transport burk of objects continuously.This machine can be divided into nvo categories: intermittent and continuous types. There arevsnous types of conveyor belt like wheel conveyor, roller conveyor, chain conveyor, screwconveyor.
l) Conveyor Belt length: 0.6m
2) Rollo diameter: 0.0350m
3) Speed ofConveyor Belt: 0.06m/ s (Considerinr
hertia of Bottle)
4) According to formula:
V=pirD*N/60 m/s
N= (60*vy (Pi*D)
N= (60,r0.06y (3. 1410.035)
N=32.74 RPM
From this Data standard Motor is selected having specification:N=30 Rpt\4 Torque: l0kg_c
Fig. 2.4: DC Motor
Fig 2.4:Conveyor Belt
2.3 Conponents Used
The components used in our project are:
l. Microcontroller: A1'89C52
2. Ulrasonic module: HCSRO4
3. L293D Motor Driver
4. IR Module
5. Gear Motor
6. Crysal: 11.0952 MLlz
7. Capacitors: l00uf, 33pf(coamic), IOuf (electrolytic)
8. Reset switch-l
9. Cormecting wires
10. LM 7805 voltage regulator
I l. JHD162A' Dsplay
12. Resistance
13. Diode lN4007
14. Transfonner
CHAPTER 3
SYSTEM DESTGN
3.l BlockDiagram
Fig.3.l Block diagram of the project
3.2 Flow of program
Valve on
Delay(Tsec)
Motor rotates conveyor
belt
Fig 3.2: Flow chart
33 Circuit Diagram
Fig 3 . 3 : Circuit diagram of motor driver
3.3.1 Circuit description of Motor Driver
Tlrc pin 2l of the microcontroll€r is connected to the input port of motor driver IC and the other
input of the motor driver is grounded with the EN pin connected to the EN of the
microcontroller. The pin 23 of the microcontroller is connected to the IR rnodrle and pin 22 is
connected to the solenoid section ofthe circuit. The pin 2 and 6 of the motor driver is the output
ptrt and are connected to the motor
R3 :-- O:
fGa a r^-l
'': '::i-
.r arfi1..
','.
3.4 Circuit Diagram of Ultrasonic sensor
Fig 3.4:Circuit Diagram Of Ultrasonic Level Measurement
.I
ll
3.4.1 Circuit Description of Ultrasonic Module:
A I l.0592MHz crystal is connected to the pin 18 and 19 of th€ microconfoller. The crystal
provides basic clock pulse to the microcontroller. Pin 39, 38 and 37 of the microcontroller are
connected to the RS, RW and EN pin of the JHDI62A display. Pin I to 7 of the microcontroller
is connected to the data port pins D0 to D7 of the LCD respectively. Preset lOk is used to
connolling the conhast and brightness of the LCD. Pin 12 and 15 of the microcontroller are
connected to the echo and trigger of the ultrasonic module.
10
3.4 Circuit Diagram of Ultrasonic sensor
Fig 3.4:Circuit Dagram Of Ultrasonic Level Measurement
3.4.1 Circuit Description of Ultrasonic Module:
A l l.0592MHz crystal is cormected to the pin l8 and 19 of the microcontroller. The crystal
provides basic clock pulse to the microcontroller. Pin 39, 38 and 37 of the microcontroller are
comected to the RS, RW and EN pin of dre JHDI62A display. Pin I to 7 of the microcontroller
is corurected to the data port piru D0 to D7 of the LCD respectively. preset lOk is used to
controltng the contrast and brightness of the LCD. Pin 12 and 15 of the microcontrolla are
connected to the echo and trigger ofthe ulfasonic module.
10
3.5 Configuring the 80Sl microcontroller:To inta face the sensor to AT89C52
aft€rnal interrupt pin(INT0 or INT|)other pin say P3.5 for fiigger.
STEPI. Connect the trigger pin ofsensor to p3.5 ofATggCSlSTEP2. Connect the echo pin ofthe sensor to INTO (p3.2) ofAT89C5lsrEH!. configure trre TII\'IERO of 80-5 r in I6 bit mode witrr.,GA]'E' bit e*bred. tf trre GATEpin is enabled and timer mn control bit TR' is set, the TIMER' wi be controlled by rNT, pin,when INT0 is high then the TIMER' starts counting. whenever INT' goes low TIMER0 hordsrts count.
3.6 WorkingThe aim of this project is to construct an automatic bottre fiting system using ATg9c52,ulbasonic module HCSRO4 .urtrasonic is one of the effective methods in the field of tiquidlevel measurement' rn the process of ultrasonic propagatio& reflectlon and refraction wi occruon the interface of the two different mediums between transmltted pulse and the received"echo" Normally empty boules will be kept in the conveyor beh and as the gear molor runs theconveyor belt, the bottre moves and wit stop when the bottle reaches the exact position beneaththe nozzle and it is detected by the IR sensor. The bottle starts filrin& the HCSRO4 startssensing the rever and if in case tre bottle is empty or not in a requ'ed rever the nozzle or thesolenoid valve w r opan untir it gets the required rever disprayed in the LCD. This mechanismwill sense the filled bottle at the end point and the microcontrolrer wi send a command to themotor &iver circuit to stop the conveyor belt. After that the conveyor bert will move until thenext bottle arrives. And the process repeats with every bottre that needs to be fi ed. In liquidfilling unit it corsists of overhead liquid tan( one IR sensor. and flow control (sorenoid) varveconnected to liquid tank. Aft"' inspection done by the inspection unit the container comes belowthe solenoid valve there one IR sensor placed below the valve and when it sense the container6e conveyor stops, then the solenoid varve get oN and filrs the liquid to the component basedon the instruction . Liquid filting starts a.!i soon as the conveyor stops. Solenoid contror varvesare electromagnetic pl'nger valves which control flow rates of liqurds or gases. The input tosolenoid valve is given by microconaolrer through a pull circuit. The fiming of sorenoid valveand conveyor stopping is sa by the timers used in program. we can change the timing based onthe requirement. The overhead liquid tank wifl suppry riquid to the bottres. The liquid revel issensed with the help of urtrasonic sensors i.e HCSRO4. After the standard liquid revel is reachedthe solenoid valve gets OFF and conveyor starts to run and automatically cycle repeats.
mrcrocontroller we need two I/O pins. One of them isfor measuring the pulse width at the echo pin. and any
11
L Solenoid valve to control the flow of liouid
2. Liquid filled tank
3. Pipe connected to solenoid valve
3.7 Algorithm:>Send a l0 micro second high pulse at tigger
Initially P3.5=0;
P3.5=l;
Delay (10 micro second);
P3.5{;:> 'WAIT" until the sensor aansmits the eight 40KHz pulses and signal reflection, Initially
the "ECHO" pin is low when the transmitter completes the pulse the pin goes high then our
TIMERO starts cumting .Whan input at INTO goes low timer holds count. Logic for waiting:
while (INTF:O); *trile(INT0:l );:>TIMER0 value = time taken by the signal to (go forward+ come back) It means the signal
taces the whole distance twice. So time taken by the signal to travel the distance = TIMERO
value/2 ULTRASONIC pulse travels with the speed of sound 133.97ir/s
Range of targeFvelocity *time
:> 13397 ' TIMER0/2
==> 6699 i TIMER0
At I l.0592MHz TIMERO gets incremented for lmicrosecond
MNGE = 6699 ir/seconds r TIMER0 micro seconds
= 6699 in/seconds I TIMER0 * (10^-6) seconds
as (lmicro second= 10^-6 seconds)
= 6699 inlseconds I TIMERO * (10^-6) seconds
= (6699 + TIMER0/ ( 1000000) in
= (TIMERO in/149.27
RANGE of targa =.(TIMER0 inyl49
By using the formula we can calculate the range of the target easily
3.8 Applications
This system is used in many applications where the filling of large numbo of bottles are
rquired maintaining catain liquid level. Typical industries include
r Food and Beverage
o Chemical
o Cosmetics
r Pharmaceutical
l5
Chapter 4
RESULTS AND DISCUSSIONS
4.1 Result
This project work has proposed an application of automation illustrating a microcontroller based
fully automatic liquid filling system. We have successfully carried out our project and
developed an automatic bottle filling system using the untouched level measuement method
.The system meets the demand of high-speed production using the least mechanism
requirement. The system has proved to work effectively avoiding unnecessary spill m wastage
of liquids. The system also provides high accuracy and precision in pro'portion of liquids.
Designing this system gave us interesting expoience in working with Microcontroller chip.
Also orn project is a combination of electronics and mechanical work. This provides us
knowledge and makes us aware of what all factors we need to consider while designing a
project based on automation.
t4
l'
Chapter 5
CONCLUSION
5.1 Conclusion
Thus we assembled a circuit which works on IR detection and ultrasonic liquid level .The
irylernenation of ultrasonic sensor was carried out effectively in the pro.ject which adds to the
uoique functioning of the project .This project as a journey where we acquired knowledge and
also gained some insights into the subject which we have shared in this report. The system can
perform the task of autonomous quality control system used in industrial production and it is
most suitable for small Scale industries as definite process is set by programming. Our aim of
fris work is to establish a flexiblg economical, easily configurablg reliable system which
nakc our project eco friendly.ln this project we successfully established a relation between the
ultrasonic sensor and the liquid level using the 8051 microcontroller. The liquid level is
successfirlly transmitted to the microcontroller via ultrasonic trans-receiver.
5.2 Future Scope
More features can be added to this system as follows: sealing and capping operations can be
fuplemented using achrators.
REFERENCES
1. Automatic Bottle Filling Using Microconnoller Volume Correr:tion" Ashwini p.
Somawa Supriya B. Asu&ar 2,Sachin A. International Jounal ofEngineering Research
& Technology (JERT)VoI. 2 Issue 3, March - 2013 ISSN: 22784181
Contactless Liquid-Level M€asurement through Opaque Container using Millimeter
Wave Sensor,Tatsuo Nakagawa, Akihiko Hyodq Kenichi Osada, Hideaki Kurata and
Shigeru OhoCentral Research Laboratory Hitachi Ltd., Tokyo, Japan
Development of a Ultasonic Instrun!€nt for the Sealed Container's Liquid Level
Measurement Lei Cherq Xinmin Dong and Jie Han Ping Yglnstitute of Vibration
Engineering College of Mechanical and Elecfical Engineering,Zhengzhou
University, Proceedings of the 6th World Congress on Intelligent control and
Automatioq June 2l -23,2006, Daliaq China.
Electonics for you, February 2008 edition ,EFY Group Publication (tndia), New Delhi
IEEE Transactions on Ultrasorics, Ferroelectrics, and Frequency Control, vol 6l,no 10.
October 2014 16270885-3010 c 2014 IEEE Bayesian Approximation Enor Approachin
Full-Wave Ultrasormd Tomography,Janne Koponen, Tomi Huttunerq Tanja Tarvainen
International Journal of Emerging Technology and Advanced Engineering Website: m
lnvw.ijetae.com (ISSN 2250-2459(Online),Volume 4, Special Issue l, February20l4)
lnternational Conferelce on Adlanced Developments in Engineuing and Technology
OCADET-I4), INDIA
7. Intemational Joumal of Emerging Technology and Advanced Engineoing Website:
www.ijetae.com (ISSN 2250-2459)Volume 2, Issue 8, August 20t2
4.
5.
TO
for motor driver
Ml=P2^0;
q=P2 l;
FP2"2;
dela(int 0
Ml=l;
sr--0;
Ml=0;
cr= l;
delay( I 000);
cr:O;
delay(300);
ENDIX B
for ultrasonic sensor
#includeceg52.l>
*{efine First_Line 0x80
lldefi ne Second_Line 0xc0
#define Curser_On OxOf
#define Curser_Off 0x0c
ttdefi ne Clear_Display 0x0 I
#tefine Data_Port Pl
sbit Lcd_rs = P0^0;
sbit Lcd_rw = P0^ I ;
sbit Lcd_en = P0^2;
sbit ItX= P3^2;
sbit TX= P3"5;
void Distance_MeasureQ;
void Lcd8_lni();
void LcdS_Comrnand(unsigned char);
void Lcd8_Write(unsigned char,unsigned char);
void Lcd8_Display(unsigned char,const unsigned charr,unsigned inQ;
void Lcd8_Decimal2(unsigned char,unsigned char);
void Lcd8_Decimal3(unsigned char,"ncigned char);
void Lcd8_Decimal4(unsigned char,unsigned int);
void Delay(unsigned int);
void delo;
unsigned
chari,inch I,incM,result,obj_distancgrept,secj,a=0,c:ekc,cu=Oxc0,Ie[20],num[20],n,v[20];
unsigned long int counf={,count I =0;
void maino
I
nA=l;
ETFI;
TMOD=0x01;
TH0=TLFOx00;
TRO-I;
rdty241'
LcdS_lnitQ ;Delay(65000);
Lcd8_Display(0x80,"LJltrasonic ",l6);Lcd8_Display(Oxc0," ",16);
Delay(65000); Delay(65000);
Lcd8_Display(0xC0,"Distance: ",16);
while(l )
{
Dstance_Measur{);
)
)
void Distance_Measur{
{
counFcount I =0;
THHxOO;TL0:Ox00;
TR0=0;
for(i=0;i< l0;it-r)
{
TX{;DelM1000);
TX=l;
Delay(10);
TX=O;
while(RX:0);
TRo=1;
while(Rx: I );
TR0={;
counFTHo<<8;
counFcountlTL0;
THFTLFOx00;
count I =count l+count;
Dela(s000);
)
counFcount l/ l0;
inch I =counto/o 10000/ 1000;
incM=counP/o I 000/ I 00;
r€sulF(inch I I l0Finch2;
obj_distance-result-2;
kd8_Decimal3 (0XCb,obj_distance);
)
void Lcd8 InitQ
{
LcdS_Command(0x38); //to select frrnction set
Lcd8_Command(ox06); //entry mode set
LcdS_Command(0x0c); //display on
kd8_Command(Ox0 I ); //clear display
]
void Lcd8_Command(unsigned char com)
{
Data_Port=com;
Lcd_en= l;Lcd_rs=Lcd_rw--0;
Delay(125);
Lcd_en=O;
Delay(125);
l
void Lcd8_Write(unsigned char conr,unsigned char lr)
tkd8_Command(com);
Data_PorFlr; // Data
Lcd_en=Lcd_n= l;Lcd_rw:0t
Delay(125);
Lcd_en=O;
Delay(125);
)
void Lcd8_Display(ursigned char corn const unsigned char tword,unsigned int n){
unsigned char Lcd_i;
for(Lcd_i=0;Lcd_i<n;Lcd_i++)
{
Lcd8_Write(com+Lcd_i, wordpcd_il ) ;
)
)
void Lcd8_DecimaD(unsigned char conr,unsigned char val)
{
unsigned int Lcd_hr,Lcd_Llcd_o:
Lcd_ln:val% 100;
Lcd_t=Lcd_hr/ l 0;
Lcd_elcd_M/ol0;
Lcd8_Write(corl! Lcd_t+0x30);Lcd8_Writ{com+ l, Lcd_o|0x3 0);
]void Lcd8_Decinal3(unsigned char conqunsigned char val)
tunsigned int Lcd_[Lcd_hr,Lcd_t,Lcd_o;
Lcd_h=vaU 100;
Lcd_tu=val% I 00;
Lcd_t=Lcd_h/ l0;
Lcd_rlcd_hrolo I 0;
LcdS_Writ{cor4 Lcd_h+Ox3 0);Lcd8_Write(com+ l, Lcd_t+Ox3 0);
Lcd8_Write(com+2. Lcd_o'-0x30);
void Delay(uruigned int del)
{
while(del--);
t
OFTEE PROTOTYPE
;
I
i
l.*Itt:
tiI
lI
tI
I
with MCS-s1" Productsot In-Systsm Roprogrammable Ftash M€mory
1,000 Writs/Eraso CyclesOp€ration: 0 Hz to 24 MHzProgram Memory Lock
lnternal RAltl/O Lines
Ti.ner/CountersSourcosSe.ial Channel
ldle and Powerdown Modas
Microcontroller
Flash allows the program memory to be raprogrammed in-system or by aI nonvolatile memory programmer. By combining a versatile g-bit CpU
on a monolithic chip, the Atmel ATB9C52 is a powerful microcomDurera highly-flexibl€ and cost-efiec1ive solution to many embedded control
POFP/TQFP
AT89C52
Not Recommended
m 7 (^07)
!l)P3sFSEN
,4,9SiSeFriIJ PLCC
i
6lr 6;6j-r_ r si i:
(rNm)P32
rt
8-bit
is a low-power, high-performance CMOS 8-bit microcomputer with gK with 8K BytesFlash programmable and erasable read only memory (pEROM). The device Flash:ured using Atmel's high-density nonvolatile memory lechnology and is
with the industry-standard 80C51 and 80C52 instruction set and Dinout.
fior New Designs.Use AT89S52.
Rev 0313H-O200
res' Compatible with MCS-51
- Products. 8K 8yt€s ol In-System Roprogrammabl€ Flash Memory
' Endurance:'l.000 Wrile/Erase Cycles, tult Static Operation: 0 Hz to 24 MHz, Ihr€slevel Program Memory Lock. 256 x 8+it Internal RAM. I Pogrammabl€ l/O Lines. Throe 16-bit Timer/Count€rs, Eight Intarrupt Sourcos, Pogrammable Serial Channel. low-oower ldle and Powerdown Modes
Descriptionlhe AT89C52 is a low-power, high-performance CN4OS 8-bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The deviceb manufactured using Atmel's high-density nonvolatile ntemory technology and iscompatible with the industry-standard 80C51 and 80C52 instructjon set and pinout.lle on-chip Flash allows the program memory to be reprogrammed in-system or by amnventional nonvolatile memory programmer. By combining a versatile 8-bit CPUwilh Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputerwhich provides a highly-flexible and cost-effective solution to many embedded controlapplications.
Pin ConfigurationsPOFP/TOFP
8-bitMicrocontrollerwith 8K Bytes
Not Recommendedfor New Designs.Use AT89S52.
PLCC
:,
Rcv 0313H-02/0".
-
flmEt
-Diagram
P0.0 - P0.7 PZO - F2.7
FSEF
FFG
RST
AT89C52
AT89C52 provides lhe following standard features: 8Kof Flash, 256 bytes o{ RAM, 32 l/O lines, three 16-bit
a six-vector two-level interrupt architecture,serial port, on-chip oscillator, and clock cir-
. In addition, the AT89C52 is designed with static logicoperation do\ryn to zero frequency and supports two
selectable powsr saving modes. The ldle Modethe CPU whila allowing the RAM, timer/counters,port, and interrupt system to continue functioning.
Powsr-down mode saves the RAM contents butthe oscillator, disabling all othsr chip tunctions until
nsxt hardware reset.
Description
vollage.
0 is an 8-bit oDen drain bi-directional l/O Dort. As anport, each pin can sink eight TTL inputs. When 1s
written to port 0 pins, the pins can be used as high-inputs.
0 can also be configured to be the multiplexed low-address/data bus during accesses to external pro-and data memory. In this mode, P0 has internal
0 also receives the code bytes during Flash program-and outpuls the code bytes during program
External pullups are required during program
1 is an 8-bit bi{irectional l/O port with intemal pullups.Port 1 outout buffers can sink/source four TTL inouts.
1s are written to Port 1 pins, they are pulled high byinternal pullups and can be used as inputs. As inputs,1 pins that are externally being pulled low will source
(lrL) because of the intemal pullups.
addition, P1.0 and P1.'l can be configured to be theter 2 external count input (P1.0/T2) and the
2 trigger input (P1 .1fizEx), respeclively, asin the following lable.
'l also receives the low-order address bytes duringprogramming and verification.
AT89C52
Port 2Port 2 is an 8-bit bi{irectional l/O port with intemal pullups.The Port 2 output buffers can sink/source four TTL inputs.When 'ls are written to Port 2 pins, they are pulled high bythe inlernal pullups and can be used as inputs. As inputs,Port 2 pins that are externally being pulled low will sourcecurrent (lrl) because of ihe internal pullups.
Port 2 emits the high-order address byte during fetchesfrom external program memory and during accesses toexternal dala memory that use lGbil addresses (MOVX @DPTR). In this application, Port 2 uses strong internal pul-lups when emitting 1s. During accesses to exlernal datamemory that use 8-bit addresses (Movx @ Rl), Port 2emits the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and somecontrol signals during Flash programming and verification.
Port 3Port 3 is an 8-bit bi.directional UO port with intemal pullups.The Port 3 output buffers can sink/source four TTL inputs.When 'ls are written to Port 3 pins, they are pulled high bythe intemal pullups and can be used as inputs. As inputs,Port 3 pins that are externally being pulled low will sourcecurrent (ltL) because of the pullups
Port 3 also serves the functions of various special featuresof the AT89C51, as shown in the following table.
Port 3 also receives some control signals for Flash pro-gramming and vsrification.
RSTReset input. A high on lhis pin for two machins cyclss whilethe oscillator is running resets the device.
ALE/PJOG-Address Latch Enabls is an oulput pulse for latching thelow byte of the address during accesses to extemal mem-ory. This pin is also the program puts€ input (FROG) duringFlash programming.
In normal operation, ALE is emitted al a constant rate of 1/6the oscillator frequency and may be used for external
Port Pin Alternaia Functions
P3.0 FiXD (serial input po.t)
P3.1 TXO (serial output port)
P3.2 lNT0 (external interrupt 0)
P3.3 iNfi (external intenupt 1)
P3.4 T0 (timer 0 external input)
P3.5 Tl (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 R-D (external data memory read strobe)
btbs of Flash, 256 bytes of RAM, 32 UO tines, three .16-bilftner/counters, a six-vector two-level interrupt architecture,
AT89C52 provides the following standard fealures:8K
AT89C52
Porl2Port 2 is an 8-bit bidirectional l/O port with intemal pullups.The Port 2 output buffers can sink/source four ffl inputs.yfll"_11" written to port 2 pins, they are purreo nigh Ltrne Internat pullups and can be used as inputs. As inputs.Port 2 pins that are externally being pulled low will souicecurrent (lrr) because of the internal pullups.Port 2 emits the high-order address byte during fetchesfrom external program memory and during acc.-esses to:{9rl'.at.data memory that use 16-bit addresses (MOVX @OPTR). In this application, port 2 uses strong internal pJ_lups when emitting 1s. During accesses to external datamemory that use 8-bit addresses (MOVX @ Rl), port 2emits the contents of the p2 Special Function RegLter.Port 2 also receives the high-order address bits and somecontrol signals during Flash programming and verification.Port 3
l:1 I1.."j 8-bil bi-direcrionat t/O pod w h inremat pu ups.I ne Hon J output buffers can sink/source four TTL inputs.
lfl^]-"_?:" y'*n to pon 3 pins, rhey are purreo rrigh otlne Intemal pullups and can be used as inputs. As inputs.Port 3 pins that are externally being pulled low will sourcecurrsnt (lL) because of the pu ups.Port 3 also serves the functions of various special featuresof the AT89CS1, as shown in the following t;bte.Port 3 also receives soms control signals for Flash pro_grammtng and verification.
a full-duplex serial port, on_chip oscillator, and clock cir_orlry. In addition. the ATg9C52 is designed with static logicbr.operation down lo zero frequency and supports twoSonware setectable power saving modes. The ldle Moderlops the CPU. while allowing the RAM, timer/counters,$nal port, and interrupt system to continue functioning.Ine power-down mode saves the RAM contents bJtli€szes.the oscillalor, disabling a other chip functions untilf|e next hardware reset.
Pin DescriptionvccSupply voltage.
GiIDGround.
Port 0
Porl 0 is an 8-bit open drain bi-directional l/O port. As anoutput.port. each pin can sink eight TTL inputs. When 1sare w-nlten
.to porl 0 pins, the pins can be used as high_
mpedance inputs.
Port Pin Altomata Functions
P1.0 T2 (external count input to Timer/Counter 2).cloc*out
T-2EX (Tim€r/Counter 2 capture/reload trigger anddirection control)
P1.1
Port 0 can also be configured to be lhe multiplexed low_order address/data bus during accesses to external pro-gram and data memory. In this mode, p0 has inteinalpullups.
Port 0 also receives the code bytes during Flash program_ming and outpuls the code bytes during pro!ramverification. External pullups are riquired Orri-ng pr6ra;verifica tio n.
Port 'l
l:n 1 ". "_" 8-bit bi{irectionat t/O port with internat pu[ups.
Ine pon 1 outpul buffers can sinusource four TTL inputs.
If".L]r "1" wrinen to port .l pins, they are pu ed high by
lhe rnternal pullups and can be used as inputs. As inputiPort 1 pins that are extsrnally being pulled low will sourcecunent (l[) because of the intemal pu ups.In addition, P1.0 and p1..t can be configured to be lhetimer/counter 2 external count input (pi.0/T2) and thelimer/counter_2 trigger Input (p1.1/T2EX), respectively, asshown in the following table.Port 1 also receives the low-order address bytes duringFlash programming and verification
Pon Pin Alt mate Functions
P3.0 RXD (serial input port)
_I9 (""tut olprt pott)
lNm (externat intenupt O)
iNTT (external intenupt 1)
T0 (timer 0 externat input)
T1 (timer 1 external input)
WR (external data memory write strobe)
m (external data memory read strobe)
P3.1
P3.2
P3.3
P3.4
P3.5
1qP3.7
RSTReset input. A high on this pin for two machine cycles whilethe osci alor is running resets the device.
ALE/PRGAddress Larch Enable is an output pulse for latching thelow byte of the address during accesses to external mem_ory. rhrs prn is atso the program putse inpul 1FR6G; OuringFrash programming.
In normal operation, ALE is emiftsd at a constant rate of 1/6the oscillator frequency and may be used for external
I 4EE-_| 0mrng or clocklng purposes. Note, however, that one ALE EefVpp1ffiil:
skipped durins each access to exrernat datl il"1l mi'#*i;*r"n',',r;:ii",:r."^y:.,,v set ns o, o or ;fi[*lrip!;li::"i'-Ti:;:il]itrt]1f,frl;
;3.1 , :,ruini"in""1,,:1i:i ,t,il:J:,::";: l,:i: ,TiJ:;"1,",T,""il ,n", n i".' L,i'r L ili',",,"; eo- *,,i i;, w_eaklv purled high. setrina ,,.'. eLE-ii.Jii"";ll''njj""j :I'rnarrv ratched on resel.
oflect if the microcontroller is'in exrernar execution mode. "r"""?:;l:
be strapped to vcc for internat program
!l]i[r s,or" Enabre is the rsac This Pin also,reeives.the.l2-volt programming enabre vo'-
sram memory. -r strobe to extarnar pro- irt"ir!ki"r'ijiX,?"5!X'n o."nr;;;ne wiren r z-voirWhen the AT89C52 is executino (
&l:il ffTiT;ffiH"::';,,,flii l::s'"*1fi:: ,ipil,::rrrrr,rreosci,,aror amp,irie, ano ,npu'o rhe€acn access to extemal data mero,lil. ". skipped during internat clock operating circuit. '
XrAL2
Table 1. AT89cs2 sFR Map and Reset values output from the inverting oscillator amplifier.
00000000
ACC00000000
PSW00000000
T2CON00000000
T2MODXXXXXXOO
RCAP2L00000000
RCAP2H00000000
rL200000000
fH2o0000000
IPxx000000
P311111111
IE0x000000
P211111111
scoN00000000
11111111
SAUFXXXXXXXX
TL100000000
TCON00000000
TMOO00000000
TLO00000000
THOo0000000
TH100000000
PO
11111111 00000111DPL
00000000DPH
00000000 PCON0xxx0000
OFSH
OFOH
OESH
80H
AT89C52
u93. L293DQUADRUPLE HALF.H DRIVERS
SLRSOOAC - SFPTEMBER 1986 - REVISED NOVEMBEB 2OO4
L293...NORNEPACKAGEL293D...NEPACKAGE
(roP vtEw)
Featuring Unitrode L293 and L293DProducts Now From Texas InstrumentsWide Supply-Voltage Range: 4.5 V to 36 VSeparate Input-Logic SupplyInternal ESD ProtectionThermal ShutdownHigh-Noiselmmunity InputgFunctionally Similar to SGS L293 andSGS 1293D
Output Current 1 A Per Channel(600 mA for 1293D)
a Peak Output Current 2 A Per Channel(1.2 A lor 1293o)
. Output Clamp Diodes tor InductiveTransient Suppression (L2930)
description/ordering information
The L293 and L293D are quadruple high-currenthalf-H drivers. The 1293 is designed to providebidirectional drive currents of up to I A at voltagesfrom 4.5 V to 36 V. The L293D is designed toprovide bidirectional drive currents of up to600-mA at voltages trom 4.5 V to 36 V Bothdevrces are designed to drive inductive loads suchas relays, solenoids, dc and bipolar steppingmotors, as well as other high-currenvhigh-voltageloads in positive-supply applicataons.
aaaaaa
1,2EN
1A
1Y
HEAT SINK AND /GFOUND \
2Y
2Avccz
1,2EN'1A.1Y
NCNCNCa
HEAT SINK AND JGFoUND )\NCNC2Y2A
Vccz
Vcc,4A
3,4EN
L293... DWP PACKAGE(TOP VtEW)
HEAT SINK ANDGFiOUND
Vccr4A4YNC
NC
NC')( HEAT SINK AND
r GROUND
NC
NC3Y3A
3,4EN
4Y
II
3Y
3A
All inputs are TTL compatjbte. Each output is acomplete totem-pole drive circuit, with aDarlington 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 4enabled by 3,4EN when an enable input is high, the associated drivers are enabled, and their outputs are activeand in phase with their inputs. When the enable input is low, those drivers are disabled, and their outputs areotf and in the high-impedance state. With the proper data inputs, each pair of drivers forms a tull-H (oibrioge.lreversible drive suitable tor solenoid or motor aoolications.
ORDERING INFORMATION
T4 PACKAGET ORDEBAALEPAFT NUiIBER
TOP.SIDEMARKING
0-C lo 70 C
HSOP (DWP) Tube ol20 L293DWP L293DWPPDIP (N) Tube ot 25 1293N L293N
POrP (NE) Tube ot 25 L293NE L293NE
Tube ot 25 L293DNE L293DNE' racKage orawrngs slanoard paching quanlties, thefihal data, syrnbolization, and PCB design guidelines are avaitabte at
wwwti.convsc/package
Please be aware that an imporiant notice conceming availabilrty, standard warranly. and use in cnlicat applicat ons olTexas Inslrumenrs semiconductor producrs and discraimers thereto appears al lhe end ol this data sheer.
pnOoUCTlO Drtr rtrmrrjoi it cs.nt .r or oudEttn orLP'odrir conrd m b rFonmod F $. r.fr 01 T.r4 t^.tru4.dr lr-r,*fi,$:i,i.ll*f;"_,*ru{6o..m,norsny,Etu,h If TEXAS
INSTRUMENTSPOST OFFTCE BOX 655303 a OATLAS TEXAS 7s26s
convlghr 2004 Ie.ds In\t ulrLnls t.c^,pn.i'cd
[293, 12930OUADRUPLE HALF-H DBIVEBS
NOVEMBER
description/ordering intormation (continued)
on the L293' external high-speed output clamp diodes should be used tor inductive transient suppressron.A V651 terminal, separate trom vcc2, is provided for the logic inputs to minimjze device power djssrpalon.The L293and L293D are characterized for operation lrom O"C to 70"C.
block diagram
vccro
--.t I16tsI
Jr-;
rlHl=13
12
lrltl
vccr
Outsut diodes are intremat in 12930.
irr
FU CTION TAALE(ech d.ivor)
H = high level, L = low level, X = ifielevant,z = high impedance (otf)r In the themal shuldown mode, tfie outsut,s
in lhe high-impedance slate, regardtess olthe input levels.
rNPurst oulPuTA EN
H
L
X
H
L
H
L
z
S r.ttINSTRUMENTS
POSTOFFTCE BOX 65s303. OAttA9. TEXAS 7s26s
t.zgg, L2E|DOUADRUPLE HAI-F"H DilVERS
aLASoCC - sEPtEllgEF |*8- REUAED O\iE ACn Sa
loglc dlagEm
tA
1,2!r
2A
JT
&.lx.A
IY
x
t\t
4Y
sch€madcs of Inpuls and ouFufs (I2ql)
EOIIYALET{T OF EACI{ IIPUT TYHCAL OF At|- OUTPUTS
S rs,n"INSTRI.JMENTS
F03t 6FO€ aor( dd[}. OA.llA, IEXAA 7ra.5
1293, L293DQUADRUPLE HALF.H DRIVEBS
SLRSOOAC - SEPTEMAFR I986 - REVISED NOVEMSER ?OO4
schematics ot inputs and outputs (L293D)
EOUIVALENT OF EACH INPUT TYPICAL OF ALL OUTPUTS
absolute maximum ratings over operating free,air temperature range (unless otherwlse noted)t1l
...... -3VtoV692+3V
rloi"" z ""j si owp p""k"g"
Maximum junction temperature, T; .....Storage temperature range, Tstg
I stresses beyond those listed under "absolute maximum €tings" may cause permanenl damage ro the device. These are slress ratingo onry, andtunctional operaticn ol the device at lhes€ or any other conditions beyond those indicaled uncier '?ecommended operating conditions" is notimpried. Erposure lo absorute-marimum-rated conditions lorextended periods may allect device reriabirity.NOTES: 1. Allvoltage values are with resp€ct to the net, ork ground terminal_
2 Maximum power dissipation is a lunclion ol TJ{max), dJA, and TA- The maxrrhum allowable F,ower dissipation at any a owableambient temperalure is Po = fiJ{ma() - Tr/gJA. Operating at the absotute maximum TJ ol tso.c can atfeci retiabitity.3. The package thermal impedance is calculated jn accorc,ance with JESD 5t -z_
Sn*tINSTRUMENTS
Pqsr oFFrc€ Box 0s5303 . oaLLAS, TEXAS /5?6s