1.pc controlled bomb displacing and detection.doc
TRANSCRIPT
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
1/169
INDEX
TOPICS
•
Certificates………………………………………………………………………………………
• Acknowledgement…………………………………………………………………………........
CHAPTE !" INTOD#CTION
!.! Introd$ction of t%e &ro'ect …………………………………………………………………………………
!.( Pro'ect o)er)iew……………………………………………………………………………………………...
!.* T%esis…………………………………………………………………………………………………………
CHAPTE (" E+,EDDED S-STE+S
(.! Introd$ction to emedded s/stems…………………………………………………………………………
(.( Need of emedded s/stems…………………………………………………………………………………...
(.* E0&lanation of emedded s/stems…………………………………………………………………………...
(.1 A&&lications of emedded s/stems…………………………………………………………………………
CHAPTE *" HAD2AE DESCIPTION
*.! Introd$ction wit% lock diagram……………………………………………………………………………
*.( +icrocontroller……………………………………………………………………………………………….
*.* eg$lated &ower s$&&l/……………………………………………………………………………………...
*.1 3ED……………………………………………………………………………………………………………
*.4 S(*( cale……………………………………………………………………………………………………
*.5 6igee mod$le………………………………………………………………………………………………...
*.7 +etal Detection sensor……….………………………………………………………………………………
1
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
2/169
*.8 ,$99er…………………………….…….………………………………………………….............................
*.!: ela/s………………………………………………………………………………………………………
*.!! DC motors……………………………………………………………………………………………………
*.!( DC motor dri)er……………………………………………………………………………………………..
CHAPTE 1" SO;T2AE DESCIPTION
1.! E0&ress PC,…………………………………………………………………………………………………
1.( PIC C Com&iler……………………………………………………………………………………………….
1.* Prote$s software………………………………………………………………………………………………
1.1 Proced$ral ste&s for com&ilation< sim$lation and d$m&ing……………………………………..
CHAPTE 4" PO=ECT DESCIPTION
CHAPTE 5" AD>ANTA?ES< DISAD>ANTA?ES AND APP3ICATIONS
CHAPTE 7" ES#3TS< CONC3#SION< ;#T#E POSPECTS
E;EENCES
2
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
3/169
CHAPTE !" INTOD#CTION
!.! Introd$ction"
The advent of new high-speed technology and the growing computer
Capacity provided realistic opportunity for new robot controls and realization of new methods of
control theory. This technical improvement together with the need for high performance robots
created faster, more accurate and more intelligent robots using new robots control devices, new drives
and advanced control algorithms. This project describes a new economical solution of robot control
systems. The presented robot control system can be used for different sophisticated robot applications.
The project aims in designing a Bomb Detecting and diffusion wireless controlled ar field
!obot through "C which is capable of detecting human beings and land mines in its path and which is
wirelessly controlled through "C using #igbee technology. $t is a very low cost robot used to monitor
the arfield. The robot can be moved in all the directions using the "C wirelessly. The robot system is
also used for bomb detection and diffusion using robotic arm.
#igbee is a "%& technology based on the $''' ()*.+. standard. nli/e Bluetooth or
wireless 0B devices, #igbee devices have the ability to form a mesh networ/ between nodes.1eshing is a type of daisy chaining from one device to another. This techni2ue allows the short range
of an individual node to be e3panded and multiplied, covering a much larger area.
The controlling device of the whole system is a 1icrocontroller. henever the user presses a
button in the "C, the data related to that button is sent through #igbee module interfaced to "C. This
data will be received by the #igbee module in the robot system and feds this to 1icrocontroller which
judges the relevant tas/ to the information received and acts accordingly. henever, land mines are
detected, it alerts through buzzer alarm system and also using diffuses using robotic arm. The
1icrocontrollers used in the project are programmed using 'mbedded C language.
This project utilizes two DC 1otors respectively. T%e DC motor generates tor@$e directl/
from DC &ower s$&&lied to t%e motor / $sing internal comm$tation< stationar/ &ermanent3
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
4/169
magnets< and rotating electrical magnets. It works on t%e &rinci&le of 3orent9 force< w%ic%
states t%at an/ c$rrent carr/ing cond$ctor &laced wit%in an e0ternal magnetic field e0&eriences
a tor@$e or force known as 3orent9 force. Ad)antages of a r$s%ed DC motor incl$de low initial
cost< %ig% reliailit/< and sim&le control of motor s&eed. Disad)antages are %ig% maintenance
and low lifes&an for %ig% intensit/ $ses.
+aintenance in)ol)es reg$larl/ re&lacing t%e r$s%es and s&rings w%ic% carr/ t%e
electric c$rrent< as well as cleaning or re&lacing t%e commutator . T%ese com&onents are
necessar/ for transferring electrical &ower from o$tside t%e motor to t%e s&inning wire windings
of t%e rotor inside t%e motor.
The driver used for DC 1otors is 4*56D. The Device is a monolithic integrated high
voltage, high current four channel driver designed to accept standard DT4 or TT4 logic levels and
drive inductive loads 7such as relays solenoids, DC and stepping motors8 and switching power
transistors. This project ma/es use of a micro controller, which is programmed, with the help of
embedded C instructions. This 1icrocontroller is capable of communicating with input and output
modules. The controller is interfaced with dc motors, which are fi3ed to the !obot to control the
direction of the !obot.
!.( Pro'ect O)er)iew"
%n embedded system is a combination of software and hardware to perform a
dedicated tas/ . 0ome of the main devices used in embedded products are 1icroprocessors and
1icrocontrollers.
1icroprocessors are commonly referred to as general purpose processors as they
simply accept the inputs, process it and give the output. $n contrast, a microcontroller not only accepts
the data as inputs but also manipulates it, interfaces the data with various devices, controls the data
and thus finally gives the result.
The project Bomb Detecting and diffusion wireless controlled ar field !obot
through "C using +9:;* 1icrocontroller is an e3clusive project that can move the robot according to
the instructions given by Computer and also alerts through buzzer when any metal is being detected
by it. $t also alerts when any human beings are near by using "$! sensor.
4
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
5/169
!.* T%esis O)er)iew"
The thesis e3plains the implementation of < Bomb Detecting and diffusion
wireless controlled ar field !obot through "C= using +9:;* microcontroller. The organization of the
thesis is e3plained here with>
C%a&ter ! "resents introduction to the overall thesis and the overview of the project. $n the project
overview a brief introduction of metal detection, "$! sensors, DC motors with driver, buzzer, and
using of robot and its applications are discussed.
C%a&ter ( "resents the topic embedded systems. $t e3plains the about what is embedded systems,
need for embedded systems, e3planation of it along with its applications.
C%a&ter * "resents the hardware description. $t deals with the bloc/ diagram of the project and
e3plains the purpose of each bloc/. $n the same chapter the e3planation of microcontrollers, power
supplies, metal detection sensors, DC motors with driver, buzzer, relay and #igbee modules are
considered.
C%a&ter 1 "resents the software description. $t e3plains the implementation of the project using "$C
C Compiler software.
C%a&ter 4 Presents the project description along with metal detection, #igbee module, buzzer, relay,
DC motors with driver interfacing to microcontroller.
C%a&ter 5 "resents the advantages, disadvantages and applications of the project.
C%a&ter 7 "resents the results, conclusion and future scope of the project.
5
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
6/169
CHAPTE (" E+,EDDED S-STE+S
(.! Emedded S/stems"
%n embedded system is a computer system designed to perform one or a few dedicated
functions often with real-time computing constraints. $t is embedded as part of a complete device
often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a
personal computer 7"C8, is designed to be fle3ible and to meet a wide range of end-user needs.
'mbedded systems control many devices in common use today.
'mbedded systems are controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processors 7D0"8. The /ey characteristic, however, is
being dedicated to handle a particular tas/, which may re2uire very powerful processors. :or e3ample,
air traffic control systems may usefully be viewed as embedded, even though they involve mainframe
computers and dedicated regional and national networ/s between airports and radar sites. 7'ach radar
probably includes one or more embedded systems of its own.8
0ince the embedded system is dedicated to specific tas/s, design engineers can
optimize it to reduce the size and cost of the product and increase the reliability and performance.
0ome embedded systems are mass-produced, benefiting from economies of scale.
"hysically embedded systems range from portable devices such as digital watches and
1"6 players, to large stationary installations li/e traffic lights, factory controllers, or the systems
controlling nuclear power plants. Comple3ity varies from low, with a single microcontroller chip, to
very high with multiple units, peripherals and networ/s mounted inside a large chassis or enclosure.
$n general, ?embedded system? is not a strictly definable term, as most systems have
some element of e3tensibility or programmability. :or e3ample, handheld computers share some
elements with embedded systems such as the operating systems and microprocessors which power
them, but they allow different applications to be loaded and peripherals to be connected. 1oreover,
even systems which don@t e3pose programmability as a primary feature generally need to support
software updates. An a continuum from ?general purpose? to ?embedded?, large application systems
will have subcomponents at most points even if the system as a whole is ?designed to perform one or
6
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
7/169
a few dedicated functions?, and is thus appropriate to call ?embedded?. % modern e3ample of
embedded system is shown in fig> *.+.
;ig (.!"A modern e0am&le of emedded s/stem
4abeled parts include microprocessor 78, !%1 798, flash memory 7;8.'mbedded
systems programming is not li/e normal "C programming. $n many ways, programming for an
embedded system is li/e programming "C + years ago. The hardware for the system is usually
chosen to ma/e the device as cheap as possible. 0pending an e3tra dollar a unit in order to ma/ethings easier to program can cost millions. iring a programmer for an e3tra month is cheap in
comparison. This means the programmer must ma/e do with slow processors and low memory, while
at the same time battling a need for efficiency not seen in most "C applications. Below is a list of
issues specific to the embedded field.
(.!.! Histor/"
$n the earliest years of computers in the +56))s, computers were sometimes
dedicated to a single tas/, but were far too large and e3pensive for most /inds of tas/s performed by
embedded computers of today. Aver time however, the concept of programmable controllers evolved
from traditional electromechanical se2uencers, via solid state devices, to the use of computer
technology.
7
http://en.wikipedia.org/wiki/Programmable_controllershttp://en.wikipedia.org/wiki/Electromechanicalhttp://en.wikipedia.org/wiki/Programmable_controllershttp://en.wikipedia.org/wiki/Electromechanical
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
8/169
Ane of the first recognizably modern embedded systems was the %pollo uidance
Computer , developed by Charles 0tar/ Draper at the 1$T $nstrumentation 4aboratory. %t the project@s
inception, the %pollo guidance computer was considered the ris/iest item in the %pollo project as it
employed the then newly developed monolithic integrated circuits to reduce the size and weight. %n
early mass-produced embedded system was the %utonetics D-+; guidance computer for
the 1inuteman missile, released in +59+. $t was built from transistor logic and had a hard dis/ for
main memory. hen the 1inuteman $$ went into production in +599, the D-+; was replaced with a
new computer that was the first high-volume use of integrated circuits.
(.!.( Tools"
'mbedded development ma/es up a small fraction of total programming. There@s also a
large number of embedded architectures, unli/e the "C world where + instruction set rules, and the
&$E world where there@s only 6 or major ones. This means that the tools are more e3pensive. $t
also means that they@re lowering featured, and less developed. An a major embedded project, at some
point you will almost always find a compiler bug of some sort.
Debugging tools are another issue. 0ince you can@t always run general programs on
your embedded processor, you can@t always run a debugger on it. This ma/es fi3ing your program
difficult. 0pecial hardware such as FT% ports can overcome this issue in part. owever, if you stop
on a brea/point when your system is controlling real world hardware 7such as a motor8, permanent
e2uipment damage can occur. %s a result, people doing embedded programming 2uic/ly become
masters at using serial $A channels and error message style debugging.
(.!.* eso$rces"
To save costs, embedded systems fre2uently have the cheapest processors that can do
the job. This means your programs need to be written as efficiently as possible. hen dealing with
large data sets, issues li/e memory cache misses that never matter in "C programming can hurt you.
4uc/ily, this won@t happen too often- use reasonably efficient algorithms to start, and optimize only
when necessary. Af course, normal profilers won@t wor/ well, due to the same reason debuggers don@t
wor/ well.
1emory is also an issue. :or the same cost savings reasons, embedded systems usually
have the least memory they can get away with. That means their algorithms must be memory efficient
7unli/e in "C programs, you will fre2uently sacrifice processor time for memory, rather than the
8
http://en.wikipedia.org/wiki/Apollo_Guidance_Computerhttp://en.wikipedia.org/wiki/Apollo_Guidance_Computerhttp://en.wikipedia.org/wiki/Charles_Stark_Draperhttp://en.wikipedia.org/wiki/Minuteman_(missile)http://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Digital_circuithttp://en.wikipedia.org/wiki/Digital_circuithttp://en.wikipedia.org/wiki/Hard_diskhttp://en.wikipedia.org/wiki/Hard_diskhttp://en.wikipedia.org/wiki/Apollo_Guidance_Computerhttp://en.wikipedia.org/wiki/Apollo_Guidance_Computerhttp://en.wikipedia.org/wiki/Charles_Stark_Draperhttp://en.wikipedia.org/wiki/Minuteman_(missile)http://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Digital_circuithttp://en.wikipedia.org/wiki/Hard_disk
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
9/169
reverse8. $t also means you can@t afford to lea/ memory. 'mbedded applications generally use
deterministic memory techni2ues and avoid the default ?new? and ?malloc? functions, so that lea/s
can be found and eliminated more easily. Ather resources programmers e3pect may not even e3ist.
:or e3ample, most embedded processors do not have hardware :"s 7:loating-"oint "rocessing
nit8. These resources either need to be emulated in software, or avoided altogether.
(.!.1 eal Time Iss$es"
'mbedded systems fre2uently control hardware, and must be able to respond to them
in real time. :ailure to do so could cause inaccuracy in measurements, or even damage hardware such
as motors. This is made even more difficult by the lac/ of resources available. %lmost all embedded
systems need to be able to prioritize some tas/s over others, and to be able to put offGs/ip low priority
tas/s such as $ in favor of high priority tas/s li/e hardware control.
(.( Need ;or Emedded S/stems"
The uses of embedded systems are virtually limitless, because every day new products
are introduced to the mar/et that utilizes embedded computers in novel ways. $n recent years,
hardware such as microprocessors, microcontrollers, and :"% chips have become much cheaper. 0o
when implementing a new form of control, it@s wiser to just buy the generic chip and write your own
custom software for it. "roducing a custom-made chip to handle a particular tas/ or set of tas/s costs
far more time and money. 1any embedded computers even come with e3tensive libraries, so that
?writing your own software? becomes a very trivial tas/ indeed. :rom an implementation viewpoint,
there is a major difference between a computer and an embedded system. 'mbedded systems are often
re2uired to provide !eal-Time response. The main elements that ma/e embedded systems uni2ue are
its reliability and ease in debugging.
(.(.! De$gging"
'mbedded debugging may be performed at different levels, depending on the facilities
available. :rom simplest to most sophisticate they can be roughly grouped into the following areas>
• $nteractive resident debugging, using the simple shell provided by the embedded operating
system 7e.g. :orth and Basic8
9
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
10/169
• '3ternal debugging using logging or serial port output to trace operation using either a
monitor in flash or using a debug server li/e the !emedy Debugger which even wor/s for
heterogeneous multi core systems.
• %n in-circuit debugger 7$CD8, a hardware device that connects to the microprocessor via a
FT% or &e3us interface. This allows the operation of the microprocessor to be controlled
e3ternally, but is typically restricted to specific debugging capabilities in the processor.
• %n in-circuit emulator replaces the microprocessor with a simulated e2uivalent, providing full
control over all aspects of the microprocessor.
• % complete emulator provides a simulation of all aspects of the hardware, allowing all of it to
be controlled and modified and allowing debugging on a normal "C.
• nless restricted to e3ternal debugging, the programmer can typically load and run software
through the tools, view the code running in the processor, and start or stop its operation. The
view of the code may be as assembly code or source-code.
Because an embedded system is often composed of a wide variety of elements, the
debugging strategy may vary. :or instance, debugging a software7and microprocessor8 centric
embedded system is different from debugging an embedded system where most of the processing is
performed by peripherals 7D0", :"%, co-processor8. %n increasing number of embedded systems
today use more than one single processor core. % common problem with multi-core development is
the proper synchronization of software e3ecution. $n such a case, the embedded system design may
wish to chec/ the data traffic on the busses between the processor cores, which re2uires very low-
level debugging, at signalGbus level, with a logic analyzer, for instance.
(.(.( eliailit/"
'mbedded systems often reside in machines that are e3pected to run continuously for
years without errors and in some cases recover by them if an error occurs. Therefore the software is
usually developed and tested more carefully than that for personal computers, and unreliable
mechanical moving parts such as dis/ drives, switches or buttons are avoided.
0pecific reliability issues may include>
• The system cannot safely be shut down for repair, or it is too inaccessible to repair. '3amples
include space systems, undersea cables, navigational beacons, bore-hole systems, and
automobiles.
10
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
11/169
• The system must be /ept running for safety reasons. ?4imp modes? are less tolerable. Aften
bac/ups are selected by an operator. '3amples include aircraft navigation, reactor control
systems, safety-critical chemical factory controls, train signals, engines on single-engine
aircraft.
• The system will lose large amounts of money when shut down> Telephone switches, factory
controls, bridge and elevator controls, funds transfer and mar/et ma/ing, automated sales and
service.
% variety of techni2ues are used, sometimes in combination, to recover from errorsH
both software bugs such as memory lea/s, and also soft errors in the hardware>
• atchdog timer that resets the computer unless the software periodically notifies the watchdog
• 0ubsystems with redundant spares that can be switched over to
• software ?limp modes? that provide partial function
• Designing with a Trusted Computing Base 7TCB8 architectureI9J ensures a highly secure K
reliable system environment
• %n 'mbedded ypervisor is able to provide secure encapsulation for any subsystem
component, so that a compromised software component cannot interfere with other
subsystems, or privileged-level system software. This encapsulation /eeps faults from
propagating from one subsystem to another, improving reliability. This may also allow a
subsystem to be automatically shut down and restarted on fault detection.
• $mmunity %ware "rogramming
(.* E0&lanation of Emedded S/stems"
(.*.! Software Arc%itect$re"
There are several different types of software architecture in common use.
• 0imple Control 4oop>
$n this design, the software simply has a loop. The loop calls subroutines, each of which
manages a part of the hardware or software.
• $nterrupt Controlled 0ystem>
11
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
12/169
0ome embedded systems are predominantly interrupt controlled. This means that tas/s
performed by the system are triggered by different /inds of events. %n interrupt could be generated
for e3ample by a timer in a predefined fre2uency, or by a serial port controller receiving a byte. These
/inds of systems are used if event handlers need low latency and the event handlers are short and
simple.
sually these /inds of systems run a simple tas/ in a main loop also, but this tas/ is not
very sensitive to une3pected delays. 0ometimes the interrupt handler will add longer tas/s to a 2ueue
structure. 4ater, after the interrupt handler has finished, these tas/s are e3ecuted by the main loop.
This method brings the system close to a multitas/ing /ernel with discrete processes.
• Cooperative 1ultitas/ing>
% non-preemptive multitas/ing system is very similar to the simple control loop
scheme, e3cept that the loop is hidden in an %"$. The programmer defines a series of tas/s, and each
tas/ gets its own environment to
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
13/169
overhead associated with a generic real time system, due to limitations regarding memory size,
performance, andGor battery life.
• 1icro/ernels %nd '3o/ernels>
% micro/ernel is a logical step up from a real-time A0. The usual arrangement is that
the operating system /ernel allocates memory and switches the C" to different threads of e3ecution.
ser mode processes implement major functions such as file systems, networ/ interfaces, etc.
$n general, micro/ernels succeed when the tas/ switching and intertas/ communication
is fast, and fail when they are slow. '3o/ernels communicate efficiently by normal subroutine calls.
The hardware and all the software in the system are available to, and e3tensible by application
programmers. Based on performance, functionality, re2uirement the embedded systems are divided
into three categories>
(.*.( Stand Alone Emedded S/stem"
These systems ta/es the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc.., process them and produces desired
output. This entire process of ta/ing input, processing it and giving output is done in standalone mode.
0uch embedded systems comes under stand alone embedded systems
'g> microwave oven, air conditioner etc..
(.*.* ealtime emedded s/stems"
'mbedded systems which are used to perform a specific tas/ or operation in a specific
time period those systems are called as real-time embedded systems. There are two types of real-time
embedded systems.
• ard !eal-time embedded systems>
These embedded systems follow an absolute dead line time period i.e.., if the tas/ing is
not done in a particular time period then there is a cause of damage to the entire e2uipment.
'g> consider a system in which we have to open a valve within 6) milliseconds. $f this valve is
not opened in 6) ms this may cause damage to the entire e2uipment. 0o in such cases we use
embedded systems for doing automatic operations.
13
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
14/169
• 0oft !eal Time embedded systems>
'g> Consider a TM remote control system, if the remote control ta/es a few milliseconds delay it will
not cause damage either to the TM or to the remote control. These systems which will not cause damage when
they are not operated at considerable time period those systems comes under soft real-time embedded systems.
(.*.1 Network comm$nication emedded s/stems"
% wide range networ/ interfacing communication is provided by using embedded
systems.
'g>
• Consider a web camera that is connected to the computer with internet can be used to
spread communication li/e sending pictures, images, videos etc.., to another computer
with internet connection throughout anywhere in the world.
• Consider a web camera that is connected at the door loc/.
henever a person comes near the door, it captures the image of a person and sends to
the des/top of your computer which is connected to internet. This gives an alerting message with
image on to the des/top of your computer, and then you can open the door loc/ just by clic/ing the
mouse. :ig> *.* show the networ/ communications in embedded systems.
;ig (.(" Network comm$nication emedded s/stems
14
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
15/169
(.*.4 Different t/&es of &rocessing $nits"
The central processing unit 7c.p.u8 can be any one of the following microprocessor,
microcontroller, digital signal processing.
• %mong these 1icrocontroller is of low cost processor and one of the main advantage of
microcontrollers is, the components such as memory, serial communication interfaces, analog
to digital converters etc.., all these are built on a single chip. The numbers of e3ternal
components that are connected to it are very less according to the application.
• 1icroprocessors are more powerful than microcontrollers. They are used in major applications
with a number of tas/ing re2uirements. But the microprocessor re2uires many e3ternal
components li/e memory, serial communication, hard dis/, input output ports etc.., so the
power consumption is also very high when compared to microcontrollers.
• Digital signal processing is used mainly for the applications that particularly involved with
processing of signals
(.1 APP3ICATIONS O; E+,EDDED S-STE+S"
(.1.! Cons$mer a&&lications"
%t home we use a number of embedded systems which include microwave oven,
remote control, vcd players, dvd players, camera etcN.
;ig(.*" A$tomatic coffee makes e@$i&ment
15
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
16/169
(.1.( Office a$tomation"
e use systems li/e fa3 machine, modem, printer etcN
;ig(.1" ;a0 mac%ine ;ig(.4" Printing mac%ine
(.1.*. Ind$strial a$tomation"
Today a lot of industries are using embedded systems for process control. $n industries
we design the embedded systems to perform a specific operation li/e monitoring temperature,
pressure, humidity ,voltage, current etc.., and basing on these monitored levels we do control other
devices, we can send information to a centralized monitoring station.
;ig(.5" oot
$n critical industries where human presence is avoided there we can use robots which
are programmed to do a specific operation.
16
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
17/169
(.1.4 Com&$ter networking"
'mbedded systems are used as bridges routers etc..
;ig(.7" Com&$ter networking
(.1.5 Tele comm$nications"
Cell phones, web cameras etc.
;ig(.8" Cell P%one ;ig(.B" 2e camera
CHAPTE *" HAD2AE DESCIPTION17
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
18/169
*.! Introd$ction>
$n this chapter the bloc/ diagram of the project and design aspect of independent
modules are considered. Bloc/ diagram is shown in fig> 6.+>
;I? *.!i" ,lock diagram of ,om Detecting and diff$sion wireless controlled 2ar field oot
t%ro$g% PC
18
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
19/169
;I? *.!ii" ,lock diagram of ,om Detecting and diff$sion wireless controlled 2ar field
oot t%ro$g% PC
T%e main locks of t%is &ro'ect are>
• 1icro controller 7+9:;*8
• . !eset button
• Crystal oscillator
19
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
20/169
• !egulated power supply 7!"08
• 4ed indicator
• !0*6* cable
• #igbee module
• 1etal detection sensor
• Buzzer
• !elay
• DC 1otors
• DC motors drivers
*.( +icro controller"
MICROCONTROLLER
A Microcontroller is a programmable digital processor with necessary peripherals
!oth microcontrollers and microprocessors are comple" se#$ential digital circ$its meant
to carry o$t %ob according to the program & instr$ctions 'ometimes analog inp$t&o$tp$t
inter(ace ma)es a part o( microcontroller circ$it o( mi"ed mode *both analog and digital
nat$re+
1 A smaller comp$ter
2 ,n-chip .AM/ .,M/ &, ports
"ample Motorolas 6811/ ntels 8051/ ilogs 8 and 16
General-purpose microprocessor
1 (or omp$ters
2 o .AM/ .,M/ &, on chip itsel(
3 "ample ntels "86/ Motorolas 680"0
20
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
21/169
Microprocessor vs. Microcontroller
Microprocessor
O is stand-alone/ .AM/ .,M/ &,/ timer are separate
O :esigner can decide on the amo$nt o( .,M/ .AM and &, ports
O e"pansi;e
O ;ersatility
O general-p$rpose
Microcontroller
O / .AM/ .,M/ &, and timer are all on a single chip
O =$ad >lat ac)age+
O ower ons$mption
O Amo$nt o( .AM/.,M
O &, ins
O >inal ost o( ?he prod$ct
O @ow easy it is pgraded
Memory types
$n a microcontroller, two types of memory are found. They are, program memory and data memory
respectively. "rogram memory is also /nown as @control store@ and @firm ware@. $t is non-volatile i.e, the
21
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
22/169
memory content is not lost when the power goes off. &on-volatile memory is also called !ead Anly
1emory 7!A18. There are various types of !A1.
1 Mask ROM 'ome microcontrollers with .,M are programmed while they are still
in the (actory ?his .,M is called Mas) .,M 'ince the microcontrollers with Mas)
.,M are $sed (or speci? b$t with a control and Coat
semicond$ctor as shown in the ? becomes , ?he charge in the Coat remains (or a long time *typically
o;er 30 years+ ?he charge can be remo;ed by e"posing the Coat to B radiation >or
B erasable ;ersion/ the pac)aging is done in a ceramic enclos$re with a glass
window
22
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
23/169
s$ally/ these ;ersions o( micro controllers are e"pensi;e
&. OT% E%ROM ,ne time programmable *,?+ .,M based microcontrollers do
not ha;e any glass window (or B erasing ?hese can be programmed only once
?his type o( pac)aging res$lts in microcontroller that ha;e the cost 10D o( themicrocontrollers with B erase (acility *ie/ 1&10th cost+
4 EE%ROM *lectrically rasable rogrammable .,M+ ?his is similar to .,M b$t
the Coat charge can be remo;ed electrically
5 'L()* #EE%ROM Memory$ >EA'@ memory was introd$ced by ?E in late
1980s
?his memory is similar to .,M b$t the cells in a >EA'@ memory are b$ssed so
that they can be erased in a (ew cloc) cycles @ence the reprogramming is (aster
+i,erent +ata memory types
1 .andom access memory *.AM+
2 .ead only memory *.,M+
Ranom access memory #R(M$ ata ill isappear a/ter poer on.
'tatic .AM *'.AM+ each bit is a Cip-Cop/ (ast b$t e"pensi;e
:ynamic .AM *:.AM+ each bit is a small capacitor/ and is needed to be
recharged reg$larly/ slower b$t cheap ?o be $sed as primary memory in a
comp$ter
:ata memory can be classi
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
24/169
• !its
• .egisters
• Bariable .AM
• rogram co$nter stac)
1icrocontroller can have ability to perform manipulation of individual bits in certain registers 7bit
manipulation8. This is a uni2ue feature of a microcontroller, not available in a microprocessor.
'ight bits ma/e a byte. 1emory bytes are /nown as file registers.
.egisters are some special .AM locations that can be accessed by the processor ;ery
easily
)tatic R(M #)R(M$ memory cell
This consists of two C1A0 inverters connected bac/ to front, so as to form a latch. "rocessor stac/s
storeGsave the data in a simple way during program e3ecution. "rocessor stac/ is a part of !%1 area
where the data is saved in a 4ast in :irst out 74$:A8 fashion just li/e a stac/ of paper on a table. Data
is stored by e3ecuting a @push@ instruction and data is read out using a @pop@ instruction
24
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
25/169
)R(M memory cell e0uivalent
Internal )tructure o/ a Microcontroller
25
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
26/169
At times/ a microcontroller can ha;e e"ternal memory also *i( there is no internal
memory or e"tra memory inter(ace is re#$ired+ arly microcontrollers were
man$(act$red $sing bipolar or M,' technologies Most modern microcontrollers are
man$(act$red with M,' technology/ which leads to red$ction in siFe and power
loss $rrent drawn by the is also red$ced considerably (rom 10mA to a (ew micro
Amperes in sleep mode *(or a microcontroller r$nning typically at a cloc) speed o(
20M@F+
*arvar vs. %rinceton (rchitecture
Many years ago/ in the late 1940s/ the ' Go;ernment as)ed @ar;ard and
rinceton $ni;ersities to come $p with a comp$ter architect$re to be $sed in
26
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
27/169
comp$ting distances o( a;al artillery shell (or de(ense applications rinceton
s$ggested comp$ter architect$re with a single memory inter(ace t is also )nown as
Bon e$mann architect$re a(ter the name o( the chie( scientist o( the pro%ect in
rinceton ni;ersity Hohn Bon e$mann *1903 - 1957 !orn in !$dapest/ @$ngary+
@ar;ard s$ggested a comp$ter with two diIerent memory inter(aces/ one (or the
data & ;ariables and the other (or program & instr$ctions Altho$gh rinceton
architect$re was accepted (or simplicity and ease o( implementation/ @ar;ard
architect$re became pop$lar later/ d$e to the parallelism o( instr$ction e"ec$tion
%rinceton (rchitecture #)ingle memory inter/ace$
rogram memory and data memory are inter(aced to thro$gh common b$ses
%n instruction ?!ead a data byte from memory and store it in the accumulator? is e3ecuted as follows>
-
ycle 1 - .ead nstr$ction
ycle 2 - .ead :ata o$t o( .AM and p$t into Acc$m$lator
t will ta)e more time to e"ec$te instr$ctions
27
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
28/169
*arvar (rchitecture #)eparate %rogram an +ata Memory inter/aces$
@ence each instr$ction is eIecti;ely e"ec$ted in one instr$ction cycle/ e"cept (or the
ones that modi(y the content o( the program co$nter >or e"ample/ the J%$mpJ *or
call+ instr$ctions ta)es 2 cycles ?h$s/ d$e to parallelism/ @ar;ard architect$ree"ec$tes more instr$ctions in a gi;en time compared to rinceton Architect$re
%IC Microcontrollers
stands (or eripheral nter(ace ontroller gi;en by Microchip ?echnology to
identi(y its single-chip microcontrollers ?hese de;ices ha;e been ;ery s$ccess($l in
8-bit microcontrollers ?he main reason is that Microchip ?echnology has contin$o$sly
$pgraded the de;ice architect$re and added needed peripherals to the
microcontroller to s$it c$stomers re#$irements ?he de;elopment tools s$ch asassembler and sim$lator are (reely a;ailable on the internet at wwwmicrochipcom
Lo - en %IC (rchitectures
Microchip microcontrollers are a;ailable in ;ario$s types Khen
microcontroller M was
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
29/169
with basic &, ($nctions ?hese de;ices are )nown as low-end architect$res ?hey
ha;e limited program memory and are meant (or applications re#$iring simple
inter(ace ($nctions and small program L data memories 'ome o( the low-end de;ice
n$mbers are
125
165
16505
Mi range %IC (rchitectures
Mid range architect$res are b$ilt by $pgrading low-end architect$res with more
n$mber o( peripherals/ more n$mber o( registers and more data&program memory
'ome o( the mid-range de;ices are
166
167
16>87
rogram memory type is indicated by an alphabet
.,M
> >lash
. Mas) .,M
op$larity o( the microcontrollers is d$e to the (ollowing (actors
1 'peed @ar;ard Architect$re/ .' architect$re/ 1 instr$ction cycle 4 cloc)
cycles
2 nstr$ction set simplicity ?he instr$ction set consists o( %$st 35 instr$ctions *as
opposed to 111 instr$ctions (or 8051+
3 ower-on-reset and brown-o$t reset !rown-o$t-reset means when the power
s$pply goes below a speci
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
30/169
4 microcontroller has (o$r optional cloc) so$rces
Eow power crystal
Mid range crystal
@igh range crystal
. oscillator *low cost+
5 rogrammable timers and on-chip A:
6 p to 12 independent interr$pt so$rces
7 ower($l o$tp$t pin control *25 mA *ma"+ c$rrent so$rcing capability per pin+
8 .,M&,?&.,M&>lash memory option
9 &, port e"pansion capability
>ree assembler and sim$lator s$pport (rom Microchip at wwwmicrochipcom
C%1 (rchitecture
?he $ses @ar;ard architect$re with separate rogram and Bariable *data+
memory inter(ace ?his (acilitates instr$ction (etch and the operation on
data&accessing o( ;ariables sim$ltaneo$sly
Architect$re o( microcontroller
%IC Microcontroller Clock
30
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
31/169
Most o( the microcontrollers can operate $p to 20M@F ,ne instr$ctions cycle
*machine cycle+ consists o( (o$r cloc) cycles
.elation between instr$ction cycles and cloc) cycles (or microcontrollers
nstr$ctions that do not re#$ire modi
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
32/169
1emory components are e3actly li/e that. :or a certain input we get the contents of a certain
addressed memory location and that@s all. Two new concepts are brought to us> addressing and
memory location. 1emory consists of all memory locations, and addressing is nothing but selecting
one of them. This means that we need to select the desired memory location on one hand, and on the
other hand we need to wait for the contents of that location. Besides reading from a memory location,
memory must also provide for writing onto it. This is done by supplying an additional line called
control line. e will designate this line as !G 7readGwrite8. Control line is used in the following way>
if rGwP+, reading is done, and if opposite is true then writing is done on the memory location.
1emory is the first element, and we need a few operation of our microcontroller.
Central Processing #nit
4et add 6 more memory locations to a specific bloc/ that will have a built in capability to multiply,
divide, subtract, and move its contents from one memory location onto another. The part we just
added in is called ?central processing unit? 7C"8. $ts memory locations are called registers.
32
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
33/169
!egisters are therefore memory locations whose role is to help with performing various mathematical
operations or any other operations with data wherever data can be found. 4oo/ at the current situation.
e have two independent entities 7memory and C"8 which are interconnected, and thus any
e3change of data is hindered, as well as its functionality. $f, for e3ample, we wish to add the contents
of two memory locations and return the result again bac/ to memory, we would need a connection
between memory and C". 0imply stated, we must have some ?way? through data goes from one
bloc/ to another.
,$s
That ?way? is called ?bus?. "hysically, it represents a group of (, +9, or more wires
there are two types of buses> address and data bus. The first one consists of as many lines as the
amount of memory we wish to address and the other one is as wide as data, in our case ( bits or the
connection line. :irst one serves to transmit address from C" memory, and the second to connect all
bloc/s inside the microcontroller.
33
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
34/169
%s far as functionality, the situation has improved, but a new problem has also appeared> we have a
unit that@s capable of wor/ing by itself, but which does not have any contact with the outside world, or
with usQ $n order to remove this deficiency, let@s add a bloc/ which contains several memory locations
whose one end is connected to the data bus, and the other has connection with the output lines on the
microcontroller which can be seen as pins on the electronic component.
In&$to$t&$t $nit
Those locations we@ve just added are called ?ports?. There are several types of ports > input, output or
bidirectional ports. hen wor/ing with ports, first of all it is necessary to choose which port we need
to wor/ with, and then to send data to, or ta/e it from the port.
hen wor/ing with it the port acts li/e a memory location. 0omething is simply being written into or
read from it, and it could be noticed on the pins of the microcontroller.
34
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
35/169
Serial comm$nication
Beside stated above we@ve added to the already e3isting unit the possibility of communication with an
outside world. owever, this way of communicating has its drawbac/s. Ane of the basic drawbac/s is
the number of lines which need to be used in order to transfer data. hat if it is being transferred to a
distance of several /ilometersR The number of lines timesS number of /ilometers doesn@t promise theeconomy of the project. $t leaves us having to reduce the number of lines in such a way that we don@t
lessen its functionality. 0uppose we are wor/ing with three lines only, and that one line is used for
sending data, other for receiving, and the third one is used as a reference line for both the input and
the output side. $n order for this to wor/, we need to set the rules of e3change of data. These rules are
called protocol. "rotocol is therefore defined in advance so there wouldn@t be any misunderstanding
between the sides that are communicating with each other. :or e3ample, if one man is spea/ing in
:rench, and the other in 'nglish, it is highly unli/ely that they will 2uic/ly and effectively understand
each other. 4et@s suppose we have the following protocol. The logical unit ?+? is set up on the
transmitting line until transfer begins. Ance the transfer starts, we lower the transmission line to
logical ?)? for a period of time 7which we will designate as T8, so the receiving side will /now that it
is receiving data, and so it will activate its mechanism for reception. 4et@s go bac/ now to the
transmission side and start putting logic zeros and ones onto the transmitter line in the order from a bit
of the lowest value to a bit of the highest value. 4et each bit stay on line for a time period which is
e2ual to T, and in the end, or after the (th bit, let us bring the logical unit ?+? bac/ on the line which
will mar/ the end of the transmission of one data. The protocol we@ve just described is called in
professional literature &!# 7&on-!eturn to #ero8.
%s we have separate lines for receiving and sending, it is possible to receive and send data 7info.8 at
the same time. 0o called full-duple3 mode bloc/ which enables this way of communication is called a
serial communication bloc/. nli/e the parallel transmission, data moves here bit by bit, or in a series
35
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
36/169
of bits what defines the term serial communication comes from. %fter the reception of data we need to
read it from the receiving location and store it in memory as opposed to sending where the process is
reversed. Data goes from memory through the bus to the sending location, and then to the receiving
unit according to the protocol.
Timer $nit
0ince we have the serial communication e3plained, we can receive, send and process data.
owever, in order to utilize it in industry we need a few additionally bloc/s. Ane of those is the timer
bloc/ which is significant to us because it can give us information about time, duration, protocol etc.
The basic unit of the timer is a free-run counter which is in fact a register whose numeric value
increments by one in even intervals, so that by ta/ing its value during periods T+ and T* and on the
basis of their difference we can determine how much time has elapsed. This is a very important part of
the microcontroller whose understanding re2uires most of our time.
2atc%dog
Ane more thing is re2uiring our attention is a flawless functioning of the microcontroller
during its run-time. 0uppose that as a result of some interference 7which often does occur in industry8
our microcontroller stops e3ecuting the program, or worse, it starts wor/ing incorrectly.
Af course, when this happens with a computer, we simply reset it and it will /eep wor/ing. owever,
there is no reset button we can push on the microcontroller and thus solve our problem. To overcome
this obstacle, we need to introduce one more bloc/ called watchdog. This bloc/ is in fact another free-
run counter where our program needs to write a zero in every time it e3ecutes correctly.
36
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
37/169
$n case that program gets ?stuc/?, zero will not be written in, and counter alone will reset the
microcontroller upon achieving its ma3imum value this will result in e3ecuting the program again,
and correctly this time around. That is an important element of every program to be reliable without
man@s supervision.
Analog to Digital Con)erter
%s the peripheral signals usually are substantially different from the ones that microcontroller can
understand 7zero and one8, they have to be converted into a pattern which can be comprehended by a
microcontroller. This tas/ is performed by a bloc/ for analog to digital conversion or by an %DC. This
bloc/ is responsible for converting an information about some analog value to a binary number and
for follow it through to a C" bloc/ so that C" bloc/ can further process it.
:inally, the microcontroller is now completed, and all we need to do now is to assemble it into an
electronic component where it will access inner bloc/s through the outside pins. The picture below
shows what a microcontroller loo/s li/e inside.
P%/sical config$ration of t%e interior of a microcontroller
Thin lines which lead from the center towards the sides of the microcontroller represent wires
connecting inner bloc/s with the pins on the housing of the microcontroller so called bonding lines.
Chart on the following page represents the center section of a microcontroller.
37
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
38/169
+icrocontroller o$tline wit% its asic elements and internal connections
:or a real application, a microcontroller alone is not enough. Beside a microcontroller, we
need a program that would be e3ecuted, and a few more elements which ma/e up a interface logic
towards the elements of regulation 7which will be discussed in later chapters8.
The program adds the contents of two memory locations, and views their sum on port %. The
first line of the program stands for moving the contents of memory location ?%? into one of the
registers of central processing unit. %s we need the other data as well, we will also move it into the
other register of the central processing unit. The ne3t instruction instructs the central processing unit
to add the contents of those two registers and send a result to port %, so that sum of that addition
would be visible to the outside world. :or a more comple3 problem, program that wor/s on its
38
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
39/169
solution will be bigger.
"rogramming can be done in several languages such as %ssembler, C and Basic which are most
commonly used languages. %ssembler belongs to lower level languages that are programmed slowly,
but ta/e up the least amount of space in memory and gives the best results where the speed of
program e3ecution is concerned. %s it is the most commonly used language in programming
microcontrollers it will be discussed in a later chapter. "rograms in C language are easier to be
written, easier to be understood, but are slower in e3ecuting from assembler programs. Basic is the
easiest one to learn, and its instructions are nearest a man@s way of reasoning, but li/e C programming
language it is also slower than assembler. $n any case, before you ma/e up your mind about one of
these languages you need to consider carefully the demands for e3ecution speed, for the size of
memory and for the amount of time available for its assembly.
%fter the program is written, we would install the microcontroller into a device and run
it. $n order to do this we need to add a few more e3ternal components necessary for its wor/. :irst we
must give life to a microcontroller by connecting it to a power supply 7power needed for operation of
all electronic instruments8 and oscillator whose role is similar to the role that heart plays in a human
body. Based on its cloc/s microcontroller e3ecutes instructions of a program. %s it receives supply
microcontroller will perform a small chec/ up on itself, loo/ up the beginning of the program and
start e3ecuting it. ow the device will wor/ depends on many parameters, the most important of
which is the s/illfulness of the developer of hardware, and on programmer@s e3pertise in getting the
ma3imum out of the device with his program.
Introd$ction
PIC!5; belongs to a class of (-bit microcontrollers of !$0C architecture.
$ts general structure is shown on the following map representing basic bloc/s.
Program memor/ 7:4%08-
$t is used for storing a written program. 0ince memory made in :4%0 technology can be
programmed and cleared more than once, it ma/es this microcontroller suitable for device
development.
EEPO+ - data memory that needs to be saved when there is no supply.
$t is usually used for storing important data that must not be lost if power supply suddenly stops. :or
39
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
40/169
instance, one such data is an assigned temperature in temperature regulators. $f during a loss of power
supply this data was lost, we would have to ma/e the adjustment once again upon return of supply.
Thus our device looses on self-reliance.
A+- Data memory used by a program during its e3ecution. $n !%1 are stored all inter-results or
temporary data during run-time.
POTA and POT, are physical connections between the microcontroller and the outside world.
"ort % has five, and port B has eight pins.
;EE#N TI+E is an (-bit register inside a microcontroller that wor/s independently of the
program. An every fourth cloc/ of the oscillator it increments its value until it reaches the ma3imum
7*8, and then it starts counting over again from zero. %s we /now the e3act timing between each
two increments of the timer contents, timer can be used for measuring time which is very useful with
some devices.
CENTA3 POCESSIN? #NIT has a role of connective element between other bloc/s in the
microcontroller. $t coordinates the wor/ of other bloc/s and e3ecutes the user program.
40
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
41/169
A&&lications
"$C+9: perfectly fits many uses, from automotive industries and controlling home appliances to
industrial instruments, remote sensors, electrical door loc/s and safety devices. $t is also ideal for
smart cards as well as for battery supplied devices because of its low consumption.
''"!A1 memory ma/es it easier to apply microcontrollers to devices where permanent storage of
various parameters is needed 7codes for transmitters, motor speed, receiver fre2uencies, etc.8. 4ow
cost, low consumption, easy handling and fle3ibility ma/e "$C+9: applicable even in areas where
microcontrollers had not previously been considered 7e3ample> timer functions, interface replacement
in larger systems, coprocessor applications, etc.8.
$n 0ystem "rogrammability of this chip 7along with using only two pins in data transfer8 ma/es
possible the fle3ibility of a product, after assembling and testing have been completed. This capability
can be used to create assembly-line production, to store calibration data available only after final
testing, or it can be used to improve programs on finished products.
Clock instr$ction c/cle
Cloc/ is microcontroller@s main starter, and is obtained from an e3ternal component called an
?oscillator?. $f we want to compare a microcontroller with a time cloc/, our ?cloc/? would then be a
tic/ing sound we hear from the time cloc/. $n that case, oscillator could be compared to a spring thatis wound so time cloc/ can run. %lso, force used to wind the time cloc/ can be compared to an
electrical supply.
Cloc/ from the oscillator enters a microcontroller via A0C+ pin where internal circuit of a
microcontroller divides the cloc/ into four even cloc/s +, *, 6, and which do not overlap.
41
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
42/169
These four cloc/s ma/e up one instruction cycle 7also called machine cycle8 during which one
instruction is e3ecuted.
'3ecution of instruction starts by calling an instruction that is ne3t in string. $nstruction is called from
program memory on every + and is written in instruction register on . Decoding and e3ecution of
instruction are done between the ne3t + and cycles. An the following diagram we can see therelationship between instruction cycle and cloc/ of the oscillator 7A0C+8 as well as that of internal
cloc/s +-. "rogram counter 7"C8 holds information about the address of the ne3t instruction.
Pi&elining
$nstruction cycle consists of cycles +, *, 6 and . Cycles of calling and e3ecuting instructions
are connected in such a way that in order to ma/e a call, one instruction cycle is needed, and one more
is needed for decoding and e3ecution. owever, due to pipelining, each instruction is effectively
e3ecuted in one cycle. $f instruction causes a change on program counter, and "C doesn@t point to the
following but to some other address 7which can be the case with jumps or with calling subprograms8,
two cycles are needed for e3ecuting an instruction. This is so because instruction must be processed
again, but this time from the right address. Cycle of calling begins with + cloc/, by writing into
instruction register 7$!8. Decoding and e3ecuting begins with *, 6 and cloc/s.
42
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
43/169
TC-: reads in instruction 1AM4 h 7it doesn@t matter to us what instruction was e3ecuted,
because there is no rectangle pictured on the bottom8.
TC-! e3ecutes instruction 1AM4 h and reads in 1AM: "A!TB.
TC-( e3ecutes 1AM: "A!TB and reads in C%44 0BU+.
TC-* e3ecutes a call of a subprogram C%44 0BU+, and reads in instruction B0: "A!T%, B$T6. %s
this instruction is not the one we need, or is not the first instruction of a subprogram 0BU+ whose
e3ecution is ne3t in order, instruction must be read in again. This is a good e3ample of an instruction
needing more than one cycle.
TC-1 instruction cycle is totally used up for reading in the first instruction from a subprogram at
address 0BU+.
TC-4 e3ecutes the first instruction from a subprogram 0BU+ and reads in the ne3t one.
Pin descri&tion
Clock generator oscillator
Ascillator circuit is used for providing a microcontroller with a cloc/. Cloc/ is needed so that
microcontroller could e3ecute a program or program instructions.
T/&es of oscillators
"$C+9:can wor/ with four different configurations of an oscillator
43
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
44/169
0ince configurations with crystal oscillator and resistor-capacitor 7!C8 are the ones that are used most
fre2uently, these are the only ones we will mention here. 1icrocontroller type with a crystal oscillator
has in its designation ET, and a microcontroller with resistor-capacitor pair has a designation !C.
This is important because you need to mention the type of oscillator when buying a microcontroller.
ET Ascillator
rystal oscillator is )ept in metal
ho$sing with two pins where yo$
ha;e written down the (re#$ency at
which crystal oscillates ,ne ceramic
capacitor o( 30p> whose other end is
connected to the gro$nd needs to be
connected with each pin
Ascillator and capacitors can be pac/ed in
joint case with three pins. 0uch element is
called ceramic resonator and is represented
in charts li/e the one below.
Center pins of the element is the ground,
while end pins are connected with A0C+
and A0C* pins on the microcontroller.
hen designing a device, the rule is to
place an oscillator nearer a
microcontroller, so as to avoid any
interference on lines on which
microcontroller is receiving a cloc/.
C Oscillator
$n applications where great time precision is not necessary, !C oscillator offers additional
savings during purchase. !esonant fre2uency of !C oscillator depends on supply voltage rate,
resistance !, capacity C and wor/ing temperature. $t should be mentioned here that resonant
fre2uency is also influenced by normal variations in process parameters, by tolerance of e3ternal !
and C components, etc.
44
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
45/169
%bove diagram shows how !C oscillator is connected with "$C+9:(. ith value of resistor ! being
below *.*/, oscillator can become unstable, or it can even stop the oscillation. ith very high value of
! 7e3.+18 oscillator becomes very sensitive to noise and humidity. $t is recommended that value of
resistor ! should be between 6 and +))/. 'ven though oscillator will wor/ without an e3ternal
capacitor 7CP)p:8, capacitor above *)p: should still be used for noise and stability. &o matter whichoscillator is being used, in order to get a cloc/ that microcontroller wor/s up on, a cloc/ of the
oscillator must be divided by . Ascillator cloc/ divided by can also be obtained on
A0C*GC4VAT pin, and can be used for testing or synchronizing other logical circuits.
:ollowing a supply, oscillator starts oscillating. Ascillation at first has an unstable period and
amplitude, but after some period of time it becomes stabilized.
45
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
46/169
To prevent such inaccurate cloc/ from influencing microcontroller@s performance, we need to /eep the
microcontroller in reset state during stabilization of oscillator@s cloc/. Diagram above shows a typical
shape of a signal which microcontroller gets from the 2uartz oscillator.
eset
!eset is used for putting the microcontroller into a @/nown@ condition. That practically means that
microcontroller can behave rather inaccurately under certain undesirable conditions. $n order to
continue its proper functioning it has to be reset, meaning all registers would be placed in a starting
position. !eset is not only used when microcontroller doesn@t behave the way we want it to, but can
also be used when trying out a device as an interrupt in program e3ecution, or to get a microcontroller
ready when loading a program.
n order to pre;ent (rom bringing a logical Fero
to ME. pin accidentally *line abo;e it means
that reset is acti;ated by a logical Fero+/ ME.
has to be connected ;ia resistor to the positi;e
s$pply pole .esistor sho$ld be between 5 and
10O ?his )ind o( resistor whose ($nction is to
)eep a certain line on a logical one as a
pre;enti;e/ is called a p$ll $p
1icrocontroller "$C+9:( /nows several sources of resets>
a8 !eset during power on, "A! 7"ower-An !eset8
b8 !eset during regular wor/ by bringing logical zero to 1C4! microcontroller@s pin.
c8 !eset during 04''" regime
d8 !eset at watchdog timer 7DT8 overflow
e8 !eset during at DT overflow during 04''" wor/ regime.
The most important reset sources are a8 and b8. The first one occurs each time a power supply is
brought to the microcontroller and serves to bring all registers to a starting position initial state.
The second one is a product of purposeful bringing in of a logical zero to 1C4! pin during normal
operation of the microcontroller. This second one is often used in program development.
46
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
47/169
During a reset, !%1 memory locations are not being reset. They are un/nown during a power up and
are not changed at any reset. nli/e these, 0:! registers are reset to a starting position initial state.
Ane of the most important effects of a reset is setting a program counter 7"C8 to zero 7))))h8 , which
enables the program to start e3ecuting from the first written instruction.
!eset at supply voltage drop below the permissible 7Brown-out !eset8. $mpulse for resetting duringvoltage voltage-up is generated by microcontroller itself when it detects an increase in supply Mdd 7in
a range from +.*M to +.(M8. That impulse lasts ;*ms which is enough time for an oscillator to get
stabilized. These ;*ms are provided by an internal "!T timer which has its own !C oscillator.
1icrocontroller is in a reset mode as long as "!T is active. owever, as device is wor/ing, problem
arises when supply doesn@t drop to zero but falls below the limit that guarantees microcontroller@s
proper functioning. This is a li/ely case in practice, especially in industrial environment where
disturbances and instability of supply are an everyday occurrence. To solve this problem we need to
ma/e sure that microcontroller is in a reset state each time supply falls below the approved limit.
$f, according to electrical specification, internal reset circuit of a microcontroller can not satisfy the
needs, special electronic components can be used which are capable of generating the desired reset
signal. Beside this function, they can also function in watching over supply voltage. $f voltage drops
below specified level, a logical zero would appear on 1C4! pin which holds the microcontroller in
reset state until voltage is not within limits that guarantee accurate performance.
+emor/ organi9ation
"$C+9:( has two separate memory bloc/s, one for data and the other for program. ''"!A1
memory with "! and 0:! registers in !%1 memory ma/e up the data bloc/, while :4%0
memory ma/es up the program bloc/.
S; registers
!egisters which ta/e up first +* locations in ban/s ) and + are registers of specialized function
assigned with certain bloc/s of the microcontroller. These are called 0pecial :unction !egisters.
Introd$ction"
The "$C+9:;* C1A0 :4%0-based (-bit microcontroller is upward compatible
with "$C+9C;*G;*% and "$C+9:(;*devices. $t features *)) ns instruction e3ecution,
47
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
48/169
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
49/169
- apt$re is 16-bit/ ma" resol$tion is 125 ns
- ompare is 16-bit/ ma" resol$tion is 200 ns
- KM ma" resol$tion is 10-bit
P 8-bit/ 5-channel Analog-to-:igital con;erter
P 'ynchrono$s 'erial ort *''+ with ' *Master mode+ and 2 *'la;e+
P @eat sin)&'o$rce $rrent 25 mA
P !rown-o$t detection circ$itry (or !rown-o$t .eset *!,.+
CMO) Technology
P Eow power/ high speed M,' >EA'@ technology
P >$lly static design
P Kide operating ;oltage range 20B to 55B
P nd$strial temperat$re range
P Eow power cons$mption
- Q 06 mA typical R 3B/ 4 M@F
- 20 SA typical R 3B/ 32 )@F
- W + X% typical standby current
:ollowing are the major bloc/s of "$C 1icrocontroller.
Program memor/ 7:4%08 is used for storing a written program.
0ince memory made in :4%0 technology can be programmed and cleared more than
once, it ma/es this microcontroller suitable for device development.
EEPO+ - data memory that needs to be saved when there is no supply.
49
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
50/169
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
51/169
Clock instr$ction c/cle
Cloc/ is microcontroller@s main starter, and is obtained from an e3ternal component
called an ?oscillator?. $f we want to compare a microcontroller with a time cloc/, our
?cloc/? would then be a tic/ing sound we hear from the time cloc/. $n that case,
oscillator could be compared to a spring that is wound so time cloc/ can run. %lso,
force used to wind the time cloc/ can be compared to an electrical supply.
Cloc/ from the oscillator enters a microcontroller via A0C+ pin where internal circuit
of a microcontroller divides the cloc/ into four even cloc/s +, *, 6, and which
do not overlap. These four cloc/s ma/e up one instruction cycle 7also called machine
cycle8 during which one instruction is e3ecuted.
'3ecution of instruction starts by calling an instruction that is ne3t in string. $nstruction
is called from program memory on every + and is written in instruction register on
. Decoding and e3ecution of instruction are done between the ne3t + and
cycles. An the following diagram we can see the relationship between instruction cycle
and cloc/ of the oscillator 7A0C+8 as well as that of internal cloc/s +-. "rogram
counter 7"C8 holds information about the address of the ne3t instruction.
Pi&elining
$nstruction cycle
consists of cycles +,
*, 6 and . Cycles
of calling and e3ecuting
instructions are
connected in such a way that in order to ma/e a call, one instruction cycle is needed,
51
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
52/169
and one more is needed for decoding and e3ecution. owever, due to pipelining, each
instruction is effectively e3ecuted in one cycle. $f instruction causes a change on
program counter, and "C doesn@t point to the following but to some other address
7which can be the case with jumps or with calling subprograms8, two cycles are needed
for e3ecuting an instruction. This is so because instruction must be processed again, but
this time from the right address. Cycle of calling begins with + cloc/, by writing into
instruction register 7$!8. Decoding and e3ecuting begins with *, 6 and cloc/s.
Pin descri&tion
"$C+9:;* has a total of *( pins. $t is most fre2uently found in a D$"*( type of case but
can also be found in 01D case which is smaller from a D$". D$" is an abbreviation for
Dual $n "ac/age. 01D is an abbreviation for 0urface 1ount Devices suggesting that
holes for pins to go through when mounting aren@t necessary in soldering this type of a
component.
52
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
53/169
"ins on "$C+9:;* microcontroller have the following meaning>
There are *( pins on "$C+9:;*. 1ost of them can be used as an $A pin. Athers are
already for specific functions. These are the pin functions.
+. 1C4! to reset the "$C
*. !%) port % pin )
6. !%+ port % pin +
. !%* port % pin *
. !%6 port % pin 6
9. !% port % pin
;. !% port % pin
(. M00 ground
5. A0C+ connect to oscillator
+). A0C* connect to oscillator
++. !C) port C pin ) MDD power supply53
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
54/169
+*. !C+ port C pin +
+6. !C* port C pin *
+. !C6 port C pin 6
+. !C - port C pin
+9. !C - port C pin
+;. !C9 - port C pin 9
+(. !C; - port C pin ;
+5. M00 - ground
*). MDD power supply
*+. !B) - port B pin )
**. !B+ - port B pin +
*6. !B* - port B pin *
*. !B6 - port B pin 6
*. !B - port B pin
*9. !B - port B pin
*;. !B9 - port B pin 9
*(. !B; - port B pin ;
By utilizing all of this pin so many application can be done such as>
+. 4CD connect to "ort B pin.
*. 4'D connect to any pin declared as output.
6. !elay and 1otor - connect to any pin declared as output.
. '3ternal ''"!A1 connect to $*C interface pin !C6 and !C 70C4 and 0D%8
. 4D!, "otentiometer and sensor connect to analogue input pin such as !%).
9. 01 modem dial up modem connect to !C9 and !C; the serial communication
interface using !0*6* protocol.
:or more detail function for each specific pin please refer to the device datasheet from
1icrochip.54
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
55/169
Ports
Term ?port? refers to a group of pins on a microcontroller which can be accessed simultaneously, or
on which we can set the desired combination of zeros and ones, or read from them an e3isting status.
"hysically, port is a register inside a microcontroller which is connected by wires to the pins of a
microcontroller. "orts represent physical connection of Central "rocessing nit with an outside world.
1icrocontroller uses them in order to monitor or control other components or devices. Due to
functionality, some pins have twofold roles li/e "%GTACV$ for instance, which is in the same time
the fourth bit of port % and an e3ternal input for free-run counter. 0election of one of these two pin
functions is done in one of the configuration registers. %n illustration of this is the fifth bit T)C0 in
A"T$A& register. By selecting one of the functions the other one is disabled.
%ll port pins can be designated as input or output, according to the needs of a device that@s being
developed. $n order to define a pin as input or output pin, the right combination of zeros and ones
must be written in T!$0 register. $f the appropriate bit of T!$0 register contains logical ?+?, then that
pin is an input pin, and if the opposite is true, it@s an output pin. 'very port has its proper T!$0
register. Thus, port % has T!$0%, and port B has T!$0B. "in direction can be changed during the
course of wor/ which is particularly fitting for one-line communication where data flow constantly
changes direction. "A!T% and "A!TB state registers are located in ban/ ), while T!$0% and T!$0B
pin direction registers are located in ban/ +.
POT, and TIS,
"A!TB have adjoined ( pins. The appropriate register for data direction is T!$0B. 0etting a bit in
T!$0B register defines the corresponding port pin as input, and resetting a bit in T!$0B register
defines the corresponding port pin as output.
55
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
56/169
'ach "A!TB pin has a wea/ internal pull-up resistor 7resistor which defines a line to logic one8 which
can be activated by resetting the seventh bit !B" in A"T$A& register. These @pull-up@ resistors are
automatically being turned off when port pin is configured as an output. hen a microcontroller is
started, pull-ups are disabled.
:our pins "A!TB, !B;>!B can cause an interrupt which occurs when their status changes from
logical one into logical zero and opposite. Anly pins configured as input can cause this interrupt to
occur 7if any !B;>!B pin is configured as an output, an interrupt won@t be generated at the change of
status.8 This interrupt option along with internal pull-up resistors ma/es it easier to solve common
problems we find in practice li/e for instance that of matri3 /eyboard. $f rows on the /eyboard are
connected to these pins, each push on a /ey will then cause an interrupt. % microcontroller will
determine which /ey is at hand while processing an interrupt $t is not recommended to refer to port B
at the same time that interrupt is being processed.
POTA and TISA
56
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
57/169
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
58/169
memory ma/es up the program bloc/.
Program memor/
"rogram memory has been carried out in :4%0 technology which ma/es it possible to program a
microcontroller many times before it@s installed into a device, and even after its installment if eventual
changes in program or process parameters should occur. The size of program memory is +)*
locations with + bits width where locations zero and four are reserved for reset and interrupt vector.
Data memor/
Data memory consists of ''"!A1 and !%1 memories. ''"!A1 memory consists of *9 eight bit
locations whose contents are not lost during loosing of power supply. ''"!A1 is not directly
addressable, but is accessed indirectly through ''%D! and ''D%T% registers. %s ''"!A1 memory
usually serves for storing important parameters 7for e3ample, of a given temperature in temperature
regulators8 , there is a strict procedure for writing in ''"!A1 which must be followed in order to
avoid accidental writing. !%1 memory for data occupies space on a memory map from location
)3)C to )3: which comes to 9( locations. 4ocations of !%1 memory are also called "! registers
which is an abbreviation for General Purpose Registers. "! registers can be accessed regardless of
which ban/ is selected at the moment.
A&&lications
"$C+9:;* perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door loc/s and safety
devices. $t is also ideal for smart cards as well as for battery supplied devices because
of its low consumption.
''"!A1 memory ma/es it easier to apply microcontrollers to devices where
permanent storage of various parameters is needed 7codes for transmitters, motor
speed, receiver fre2uencies, etc.8. 4ow cost, low consumption, easy handling and
fle3ibility ma/e "$C+9:;* applicable even in areas where microcontrollers had not
previously been considered 7e3ample> timer functions, interface replacement in larger
systems, coprocessor applications, etc.8.
58
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
59/169
$n 0ystem "rogrammability of this chip 7along with using only two pins in data
transfer8 ma/es possible the fle3ibility of a product, after assembling and testing have
been completed. This capability can be used to create assembly-line production, to
store calibration data available only after final testing, or it can be used to improve
programs on finished products.
*.* E?#3ATED PO2E S#PP3-"
*.*.! Introd$ction"
"ower supply is a supply of electrical power. % device or system that supplies electrical
or other types of energy to an output load or group of loads is called a power supply unit or "0. The
term is most commonly applied to electrical energy supplies, less often to mechanical ones, and rarelyto others.
% power supply may include a power distribution system as well as primary or
secondary sources of energy such as
• Conversion of one form of electrical power to another desired form and voltage, typically
involving converting %C line voltage to a well-regulated lower-voltage DC for electronic devices.
4ow voltage, low power DC power supply units are commonly integrated with the devices theysupply, such as computers and household electronics.
• Batteries.
• Chemical f uel cells and other forms of energy storage systems.
• 0olar power.
• enerators or alternators.
*.*.( ,lock Diagram"
59
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
60/169
;ig *.*.( eg$lated Power S$&&l/
The basic circuit diagram of a regulated power supply 7DC AG"8 with led connected as
load is shown in fig> 6.6.6.
;ig *.*.* Circ$it diagram of eg$lated Power S$&&l/ wit% 3ed connection
The components mainly used in above figure are
60
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
61/169
• *6)M %C 1%$&0
• T!%&0:A!1'!
• B!$D' !'CT$:$'!7D$AD'08
• C%"%C$TA!
•MA4T%' !'4%TA!7$C ;()8
• !'0$0TA!
• 4'D74$T '1$TT$& D$AD'8
The detailed e3planation of each and every component mentioned above is as follows>
Transformation" The process of transforming energy from one device to another is called
transformation. :or transforming energy we use transformers.
Transformers"
% transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its fre2uency. % varying current in the first
or primary winding creates a varying magnetic flu3 in the transformer@s core, and thus a
varying magnetic field through the secondary winding. This varying magnetic field induces a
varying electromotive force 7'1:8 or ?voltage? in the secondary winding. This effect is called mutual
induction.
$f a load is connected to the secondary, an electric current will flow in the secondary
winding and electrical energy will be transferred from the primary circuit through the transformer to
the load. This field is made up from lines of force and has the same shape as a bar magnet.
$f the current is increased, the lines of force move outwards from the coil. $f the current
is reduced, the lines of force move inwards.
$f another coil is placed adjacent to the first coil then, as the field moves out or in, the
moving lines of force will ?cut? the turns of the second coil. %s it does this, a voltage is induced in the
second coil. ith the ) z %C mains supply, this will happen ) times a second. This is called
1T%4 $&DCT$A& and forms the basis of the transformer.
61
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
62/169
The input coil is called the "!$1%!Y $&D$&L the output coil is the
0'CA&D%!Y $&D$&. :ig> 6.6. shows step-down transformer.
;ig *.*.1" Ste&Down Transformer
The voltage induced in the secondary is determined by the T!&0 !%T$A.
:or e3ample, if the secondary has half the primary turnsL the secondary will have half
the primary voltage.
%nother e3ample is if the primary has ))) turns and the secondary has )) turns, then
the turnSs ratio is +)>+.
$f the primary voltage is *) volts then the secondary voltage will be 3 +) smaller P *
volts. %ssuming a perfect transformer, the power provided by the primary must e2ual the power ta/en
by a load on the secondary. $f a *-watt lamp is connected across a * volt secondary, then the
primary must supply * watts.
To aid magnetic coupling between primary and secondary, the coils are wound on a
metal CA!'. 0ince the primary would induce power, called 'DDY C!!'&T0, into this core, the
core is 4%1$&%T'D. This means that it is made up from metal sheets insulated from each other.
Transformers to wor/ at higher fre2uencies have an iron dust core or no core at all.
&ote that the transformer only wor/s on %C, which has a constantly changing current
and moving field. DC has a steady current and therefore a steady field and there would be no
induction.
62
-
8/18/2019 1.PC CONTROLLED BOMB DISPLACING AND DETECTION.doc
63/169
0ome transformers have an electrostatic screen between primary and secondary. This is
to prevent some types of interference being fed from the e2uipment down into the mains supply, or in
the other direction. Transformers are sometimes used for $1"'D%&C' 1%TC$&.
e can use the transformers as step up or step down.
Ste& #& transformer"
$n case of step up transformer, primary windings are every l