You are on page 1of 81




Embedded systems are designed to do some specific task, rather than be a generalpurpose computer for multiple tasks. Some also have real time performance constraints that must
be met, for reason such as safety and usability; others may have low or no performance
requirements, allowing the system hardware to be simplified to reduce costs.
An embedded system is not always a separate block - very often it is physically built-in
to the device it is controlling. The software written for embedded systems is often called
firmware, and is stored in read-only memory or flash convector chips rather than a disk drive. It
often runs with limited computer hardware resources: small or no keyboard, screen, and little
Wireless communication has become an important feature for commercial products and
a popular research topic within the last ten years. There are now more mobile phone
subscriptions than wired-line subscriptions. Lately, one area of commercial interest has been
low-cost, low-power, and short-distance wireless communication used for \personal wireless
networks." Technology advancements are providing smaller and more cost effective devices for
integrating computational processing, wireless communication, and a host of other
functionalities. These embedded communications devices will be integrated into applications
ranging from homeland security to industry automation and monitoring. They will also enable
custom tailored engineering solutions, creating a revolutionary way of disseminating and
processing information. With new technologies and devices come new business activities, and
the need for employees in these technological areas. Engineers who have knowledge of
embedded systems and wireless communications will be in high demand. Unfortunately, there
are few adorable environments available for development and classroom use, so students often


do not learn about these technologies during hands-on lab exercises. The communication
mediums were twisted pair, optical fiber, infrared, and generally wireless radio.


Our new Combat robot is pc operated , it has got two barrel turret through bullet can be
fired, pc camera in synchronization with the turret can rotate up and down ,left and right up to a
safe firing limit. turret and camera mechanism has been installed on my spy robot vehicle, which
has all the function like tank, Turing to any angle on its axis, moving forward and reverse turning
left and right, running instantly into reverse direction.
This robot is mobile operated self powered, and has all the controls like a normal car. A
pair of laser gun has been installed on it, so that it can fire on enemy remotely when required.
This is not possible until a wireless camera is installed. Wireless camera will send real time
video and audio signals which could be seen on a remote monitor and action can be taken
accordingly. It can silently enter into enemy area and send us all the information through its tiny
camera eyes. It is designed for, fighting as well as suicide attack.


















2.1 AT89S52
In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. This
microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial port, and
four ports all on a single chip. At the time it was also referred as A SYSTEM ON A CHIP
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of
in-system programmable Flash memory. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction
set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or
by a conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit CPU with
in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller, which provides a highly flexible and cost-effective solution to many, embedded
control applications. The AT89S52 provides the following standard features: 8K bytes of Flash,
256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters,
a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode stops the
CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue
functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling
all other chip functions until the next interrupt


8031 has 128 bytes of RAM, two timers and 6 interrupts.

8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts.

8052 has 8K ROM, 256 bytes of RAM, three timers and 8 interrupts.
Of the three microcontrollers, 8051 is the most preferable. Microcontroller supports both

serial and parallel communication.

In the concerned project 8052 microcontroller is used. Here microcontroller used is
AT89S52, which is manufactured by ATMEL laboratories.


The 8051 is the name of a big family of microcontrollers. The device which we are going
to use along this tutorial is the 'AT89S52' which is a typical 8051 microcontroller manufactured
by Atmel. Note that this part doesn't aim to explain the functioning of the different
components of a 89S52 microcontroller, but rather to give you a general idea of the organization
of the chip and the available features, which shall be explained in detail along this tutorial.
The block diagram provided by Atmel in their datasheet showing the architecture the 89S52
device can seem very complicated, and since we are going to use the C high level language to











This figures shows the main features and components that the designer can interact with.
You can notice that the 89S52 has 4 different ports, each one having 8 Input/output lines
providing a total of 32 I/O lines. Those ports can be used to output DATA and orders do other
devices, or to read the state of a sensor, or a switch. Most of the ports of the 89S52 have 'dual
function' meaning that they can be used for two different functions: the fist one is to perform
input/output operations and the second one is used to implement special features of the
microcontroller like counting external pulses, interrupting the execution of the program
according to external events, performing serial data transfer or connecting the chip to a computer
to update the software.
Microprocessors brought the concept of programmable devices and made many
applications of intelligent equipment. Most applications, which do not need large amount of data
and program memory, tended to be costly.
The microprocessor system had to satisfy the data and program requirements so,
sufficient RAM and ROM are used to satisfy most applications .The peripheral control
equipment also had to be satisfied. Therefore, almost all-peripheral chips were used in the
design. Because of these additional peripherals cost will be comparatively high.


An example:
8085 chip needs:
An Address latch for separating address from multiplex address and data.32-KB RAM and
32-KB ROM to be able to satisfy most applications. As also Timer / Counter, Parallel
programmable port, Serial port, and Interrupt controller are needed for its efficient applications.
In comparison a typical Micro controller 8051 chip has all that the 8051 board has except
a reduced memory as follows.
4K bytes of ROM as compared to 32-KB, 128 Bytes of RAM as compared to 32-KB.
On comparing a board full of chips (Microprocessors) with one chip with all components
in it (Microcontroller).
Lots of Microprocessor circuitry and program to debug. In Micro controller there is no
Microprocessor circuitry to debug.
Slower Development time: As we have observed Microprocessors need a lot of debugging at
board level and at program level, where as, Micro controller do not have the excessive circuitry
and the built-in peripheral chips are easier to program for operation.
So peripheral devices like Timer/Counter, Parallel programmable port, Serial
Communication Port, Interrupt controller and so on, which were most often used were integrated
with the Microprocessor to present the Micro controller .RAM and ROM also were integrated in
the same chip. The ROM size was anything from 256 bytes to 32Kb or more. RAM was
optimized to minimum of 64 bytes to 256 bytes or more.
Microprocessor has following instructions to perform:
1. Reading instructions or data from program memory ROM.


2. Interpreting the instruction and executing it.

3. Microprocessor Program is a collection of instructions stored in a Nonvolatile memory.
4. Read Data from I/O device
5. Process the input read, as per the instructions read in program memory.
6. Read or write data to Data memory.
7. Write data to I/O device and output the result of processing to O/P device.

2.1.1 Introduction to AT89S52

The system requirements and control specifications clearly rule out the use of 16, 32 or
64 bit micro controllers or microprocessors. Systems using these may be earlier to implement
due to large number of internal features. They are also faster and more reliable but, the above
application is satisfactorily served by 8-bit micro controller. Using an inexpensive 8-bit
Microcontroller will doom the 32-bit product failure in any competitive market place. Coming to
the question of why to use 89S52 of all the 8-bit Microcontroller available in the market the main
answer would be because it has 8kB Flash and 256 bytes of data RAM32 I/O lines, three 16-bit
timer/counters, a Eight-vector two-level interrupt architecture, a full duplex serial port, on-chip
oscillator, and clock circuitry.
In addition, the AT89S52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode stops the
CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue
functioning. The Power Down Mode saves the RAM contents but freezes the oscillator, disabling
all other chip functions until the next hardware reset. The Flash program memory supports both
parallel programming and in Serial In-System Programming (ISP). The 89S52 is also InApplication Programmable (IAP), allowing the Flash program memory to be reconfigured even
while the application is running.


By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is
a powerful microcomputer which provides a highly flexible and cost effective solution to many
embedded control applications.
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
4.0V to 5.5V Operating Range
Full Duplex UART Serial Channel
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)


2.1.3 Architecture Overview



Pin Description
Supply voltage.

~ 10 ~

Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
highimpedance inputs.Port 0 can also be configured to be the multiplexed loworder
address/data bus during accesses to external program and data memory. In this mode, P0
has internal pullups. Port 0 also receives the code bytes during Flash programming and
outputs the code bytes during program verification. External pull-ups are required during
program verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that
are externally being pulled low will source current (IIL) because of the internal pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.

~ 11 ~

Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pullups.The Port 2 output
buffers can sink/source four TTL inputs.When 1s are written to Port 2 pins, they are
pulled high by
the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally
being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the
high-order address byte during fetches from external program memory and during
accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this
application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents
of the P2 Special Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pullups.The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (IIL) because of the pullups. Port 3
also serves the functions of various special features of the AT89S52, as shown in the
following table. Port 3 also receives some control signals for Flash programming and

~ 12 ~

Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device. This pin drives High for 96 oscillator periods after the
Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to
disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is
enabled. ALE/PROG Address Latch Enable (ALE) is an output pulse for latching the low
byte of the address during accesses to external memory. This pin is also the program
pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a
constant rate of 1/6 the oscillator frequency and may be used for external timing or
clocking purposes. Note, however, that one ALE pulse is skipped during each access to
external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode
Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is activated
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.

~ 13 ~

External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on
reset. EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming.
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

Output from the inverting oscillator amplifier.

~ 14 ~

FIG-3 Functional block diagram of micro controller

The 8052 Oscillator and Clock:
The heart of the 8051 circuitry that generates the clock pulses by which all the
internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided for
connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are
employed. The crystal frequency is the basic internal clock frequency of the microcontroller. The
manufacturers make 8051 designs that run at specific minimum and maximum frequencies
typically 1 to 16 MHz.

~ 15 ~

Fig-4 Oscillator and timing circuit

Types of memory:
The 8052 have three general types of memory. They are on-chip memory, external Code
memory and external Ram. On-Chip memory refers to physically existing memory on the micro
controller itself. External code memory is the code memory that resides off chip. This is often in
the form of an external EPROM. External RAM is the Ram that resides off chip. This often is in
the form of standard static RAM or flash RAM.

a) Code memory

~ 16 ~

Code memory is the memory that holds the actual 8052 programs that is to be run. This
memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have
8K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory
is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

b) Internal RAM
The 8052 have a bank of 256 bytes of internal RAM. The internal RAM is found on-chip.
So it is the fastest Ram available. And also it is most flexible in terms of reading and writing.
Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 256 bytes of internal
memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains
8 registers. Internal RAM also contains 256 bits, which are addressed from 20h to 2Fh. These
bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are
numbered 00h to FFh. The user may make use of these variables with commands such as SETB
and CLR.
Special Function registered memory:
Special function registers are the areas of memory that control specific functionality of
the 8052 micro controller.
a) Accumulator (0E0h)
As its name suggests, it is used to accumulate the results of large no of instructions. It can
hold 8 bit values.
b) B registers (0F0h)
The B register is very similar to accumulator. It may hold 8-bit value. The b register is
only used by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets
stored in B register. In div AB the quotient gets stored in B with the remainder in A.
c) Stack pointer (81h)

~ 17 ~

The stack pointer holds 8-bit value. This is used to indicate where the
next value to be removed from the stack should be taken from. When a value is to be pushed
onto the stack, the 8052 first store the value of SP and then store the value at the resulting
memory location. When a value is to be popped from the stack, the 8052 returns the value from
the memory location indicated by SP and then decrements the value of SP.
d) Data pointer
The SFRs DPL and DPH work together work together to represent a 16-bit value called
the data pointer. The data pointer is used in operations regarding external RAM and some
instructions code memory. It is a 16-bit SFR and also an addressable SFR.
e) Program counter
The program counter is a 16 bit register, which contains the 2 byte address, which tells
the 8052 where the next instruction to execute to be found in memory. When the 8052 is
initialized PC starts at 0000h. And is incremented each time an instruction is executes. It is not
addressable SFR.
f) PCON (power control, 87h)
The power control SFR is used to control the 8051s power control modes. Certain
operation modes of the 8051 allow the 8051 to go into a type of sleep mode which consumes
much lee power.

g) TCON (timer control, 88h)

The timer control SFR is used to configure and modify the way in which the 8051s two
timers operate. This SFR controls whether each of the two timers is running or stopped and
contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related

~ 18 ~

bits are located in TCON SFR. These bits are used to configure the way in which the external
interrupt flags are activated, which are set when an external interrupt occurs.

h) TMOD (Timer Mode, 89h)

The timer mode SFR is used to configure the mode of operation of each of the two
timers. Using this SFR your program may configure each timer to be a 16-bit timer, or 13 bit
timer, 8-bit auto reload timer, or two separate timers. Additionally you may configure the timers
to only count when an external pin is activated or to count events that are indicated on an
external pin.

i) TO (Timer 0 low/high, address 8A/8C h)

These two SFRs taken together represent timer 0. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up. What is
configurable is how and when they increment in value.

j) T1 (Timer 1 Low/High, address 8B/ 8D h)

These two SFRs, taken together, represent timer 1. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up..
k) P0 (Port 0, address 90h, bit addressable)

~ 19 ~

This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level.
l) P1 (port 1, address 90h, bit addressable)
This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level m) P2 (port 2, address
0A0h, bit addressable):
This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0
is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on the
corresponding I/O pin whereas a value of 0 will bring it to low level.
n) P3 (port 3, address B0h, bit addressable)

This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0
is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a high level on the
corresponding I/O pin whereas a value of 0 will bring it to low level.
o) IE (interrupt enable, 0A8h):
The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits
of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable
or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of
whether an individual interrupt is enabled by setting a lower bit.

~ 20 ~

p) IP (Interrupt Priority, 0B8h)

The interrupt priority SFR is used to specify the relative priority of each interrupt. On
8051, an interrupt maybe either low or high priority. An interrupt may interrupt interrupts. For
e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt
always interrupts the system, even if another interrupt is currently executing. However, if a serial
interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since
the serial interrupt routine has the highest priority.

q) PSW (Program Status Word, 0D0h)

The program Status Word is used to store a number of important bits that are set and
cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the
parity flag and the overflow flag. Additionally, it also contains the register bank select flags,
which are used to select, which of the R register banks currently in use.

r) SBUF (Serial Buffer, 99h)

SBUF is used to hold data in serial communication. It is physically two registers. One is
writing only and is used to hold data to be transmitted out of 8052 via TXD. The other is read
only and holds received data from external sources via RXD. Both mutually exclusive registers
use address 99h.


~ 21 ~

All digital circuits require regulated power supply. In this article we are going to learn
how to get a regulated positive supply from the mains supply.

Figure 1 shows the basic block diagram of a fixed regulated power supply. Let us go through
each block.


A transformer consists of two coils also called as WINDINGS namely PRIMARY &
SECONDARY. They are linked together through inductively coupled electrical conductors also
called as CORE. A changing current in the primary causes a change in the Magnetic Field in the
core & this in turn induces an alternating voltage in the secondary coil. If load is applied to the
secondary then an alternating current will flow through the load. If we consider an ideal
condition then all the energy from the primary circuit will be transferred to the secondary circuit
through the magnetic field.

~ 22 ~


The secondary voltage of the transformer depends on the number of turns in the Primary as well as in the

2.2.4 Rectifier
A rectifier is a device that converts an AC signal into DC signal. For rectification purpose
we use a diode, a diode is a device that allows current to pass only in one direction i.e. when the
anode of the diode is positive with respect to the cathode also called as forward biased condition
& blocks current in the reversed biased condition.

Rectifier can be classified as follows:


Half Wave rectifier.

~ 23 ~

This is the simplest type of rectifier as you can see in the diagram a half wave rectifier consists
of only one diode. When an AC signal is applied to it during the positive half cycle the diode is
forward biased & current flows through it. But during the negative half cycle diode is reverse
biased & no current flows through it. Since only one half of the input reaches the output, it is
very inefficient to be used in power supplies.

Full wave rectifier.

Half wave rectifier is quite simple but it is very inefficient, for greater efficiency we would like
to use both the half cycles of the AC signal. This can be achieved by using a center tapped
transformer i.e. we would have to double the size of secondary winding & provide connection to
the center. So during the positive half cycle diode D1 conducts & D2 is in reverse biased

~ 24 ~

condition. During the negative half cycle diode D2 conducts & D1 is reverse biased. Thus we get
both the half cycles across the load.
One of the disadvantages of Full Wave Rectifier design is the necessity of using a center tapped
transformer, thus increasing the size & cost of the circuit. This can be avoided by using the Full
Wave Bridge Rectifier.

Bridge Rectifier

As the name suggests it converts the full wave i.e. both the positive & the negative half cycle
into DC thus it is much more efficient than Half Wave Rectifier & that too without using a center
tapped transformer thus much more cost effective than Full Wave Rectifier.
Full Bridge Wave Rectifier consists of four diodes namely D1, D2, D3 and D4. During the
positive half cycle diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3
conduct thus the diodes keep switching the transformer connections so we get positive half
cycles in the output.

~ 25 ~

If we use a center tapped transformer for a bridge rectifier we can get both positive & negative
half cycles which can thus be used for generating fixed positive & fixed negative voltages.

Even though half wave & full wave rectifier give DC output, none of them provides a
constant output voltage. For this we require to smoothen the waveform received from the
rectifier. This can be done by using a capacitor at the output of the rectifier this capacitor is also
CAPACITOR. Even after using this capacitor a small amount of ripple will remain.
We place the Filter Capacitor at the output of the rectifier the capacitor will charge to the peak voltage during
each half cycle then will discharge its stored energy slowly through the load while the rectified voltage drops
to zero, thus trying to keep the voltage as constant as possible.

~ 26 ~

If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the costing will
increase. The value of the Filter capacitor depends on the current consumed by the circuit, the frequency of
the waveform & the accepted ripple.

Vr= accepted ripple voltage.( should not be more than 10% of the voltage)
I= current consumed by the circuit in Amperes.
F= frequency of the waveform. A half wave rectifier has only one peak in one cycle so F=25hz
Whereas a full wave rectifier has Two peaks in one cycle so F=100hz.


A Voltage regulator is a device which converts varying input voltage into a constant
regulated output voltage. Voltage regulator can be of two types

~ 27 ~


Linear Voltage Regulator

Also called as Resistive Voltage regulator because they dissipate the excessive voltage

resistively as heat.

Switching Regulators.
They regulate the output voltage by switching the Current ON/OFF very rapidly. Since their

output is either ON or OFF it dissipates very low power thus achieving higher efficiency as
compared to linear voltage regulators. But they are more complex & generate high noise due to
their switching action. For low level of output power switching regulators tend to be costly but
for higher output wattage they are much cheaper than linear regulators.
The most commonly available Linear Positive Voltage Regulators are the 78XX series where the
XX indicates the output voltage. And 79XX series is for Negative Voltage Regulators.

After filtering the rectifier output the signal is given to a voltage regulator. The
maximum input voltage that can be applied at the input is 35V.Normally there is a 2-3 Volts drop
across the regulator so the input voltage should be at least 2-3 Volts higher than the output
voltage. If the input voltage gets below the Vmin of the regulator due to the ripple voltage or due
to any other reason the voltage regulator will not be able to produce the correct regulated

~ 28 ~

(i) Circuit diagram:

Fig 2.3. Circuit Diagram of power supply


IC 7805:
7805 is an integrated three-terminal positive fixed linear voltage regulator. It supports an

input voltage of 10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp
although lower current models are available. Its output voltage is fixed at 5.0V. The 7805 also
has a built-in current limiter as a safety feature. 7805 is manufactured by many companies,
including National Semiconductors and Fairchild Semiconductors.
The 7805 will automatically reduce output current if it gets too hot.The last two digits
represent the voltage; for instance, the 7812 is a 12-volt regulator. The 78xx series of regulators
is designed to work in complement with the 79xx series of negative voltage regulators in systems
that provide both positive and negative regulated voltages, since the 78xx series can't regulate
negative voltages in such a system.
The 7805 & 78 is one of the most common and well-known of the 78xx series regulators,
as it's small component count and medium-power regulated 5V make it useful for powering TTL

~ 29 ~

Table 2.1. Specifications of IC7805


IC 7805



Vein - Vout Difference

5V - 20V

Operation Ambient Temp

0 - 125C

Output Imax


2.3 HT9170B
The HT9170B/D are Dual Tone Multi Frequency (DTMF) receivers integrated with digital decoder
and band split filter functions as well as power-down mode and inhibit mode operations. Such devices use
digital counting techniques to detect and decode all the 16 DTMF tone pairs into a 4-bit code output.
Highly accurate switched capacitor filters are implemented to divide tone signals into low and high group
signals. A built-in dial tone rejection circuit is provided to eliminate the need for pre-filtering.
The DTMF (Dual Tone Multiple Frequency) application is associated with digital telephony, and provides
two selected output frequencies (one high band, one low band) for a duration of 100 ms. A benchmark
subroutine has been written for the COP820C/840C microcontrollers, and is outlined in detail in this
application note. This DTMF subroutine takes 110 bytes of COP820C/840C code, consisting of 78 bytes
of program code and 32 bytes of ROM table. The timings in this DTMF subroutine are based on a 20 MHz

~ 30 ~

COP820C/840C clock, giving an instruction cycle time of 1 ms.The matrix for selecting the high and low
band frequencies associated with each key is shown in Figure 1 . Each key is uniquely referenced by
selecting one of the four low band frequencies associated with the matrix rows, coupled with selecting one
of the four high band frequencies associated with the matrix columns. The low band frequencies are 697,
770, 852, and 941 Hz, while the high band frequencies are 1209, 1336, 1477, and 1633 Hz. The DTMF
subroutine assumes that the key decoding is supplied as a low order hex digit in the accumulator. The
COP820C/840C DTMF subroutine will then generate the selected high band and low
band frequencies on port G output pins G3 and G2 respectively for a duration of 100 ms. The
COP820C/840C each contain only one timer. The problem is that three different times must be generated
to satisfy the DTMF application. These three times are the periods of the two selected frequencies and the
100 ms duration period. Obviously the single timer can be used to generate any one (or possibly two) of
the required times, with the program having to generate the other two (or one) times. The solution to the
DTMF problem lies in dividing the 100 ms time duration by the half periods (rounded to the nearest
micro second) for each of the eight frequencies, and then examining the respective high band and low
band quotients and remainders. The results of these divisions are detailed in Table I. The low band
frequency quotients range from 139 to 188, while the high band quotients range from 241 to 326.
The observation that only the low band quotients will each fit in a single byte dictates that the high band
frequency be produced by the 16 bit (2 byte) COP820C/840C timer running in PWM (Pulse Width
Modulation) Mode. TL/
Operating voltage: 2.5V~5.5V
Minimal external components
No external filter is required
Low standby current (on power down mode)
Excellent performance
Tristate data output for MCU interface
3.58MHz crystal or ceramic resonator
1633Hz can be inhibited by the INH pin and HT9170B: 18-pin DIP

~ 31 ~

~ 32 ~


The HT9170B/D tone decoders consist of three band pass filters and two digital decode circuits to
convert a tone (DTMF) signal into digital code output.
An operational amplifier is built-in to adjust the input signal. The pre-filter is a band rejection filter,
which reduces the dialing tone from 350Hz to 400Hz.
The low group filter filters low group frequency signal output whereas the high group filter
filters high group Frequency signal output. A zero-crossing detector with follows each filters output
hysteretic. When each signal amplitude at the output exceeds the specified level, it is transferred to full
swing logic signal.
When input signals are recognized to be effective, DV becomes high, and the correct tone code (DTMF)
digit is transferred.

~ 33 ~

Steering control circuit:

The steering control circuit is used for measuring the effective signal duration and for protecting
against drop out of valid signals. It employs the analog delay by external RC time-constant controlled by
EST. The EST pin is normally low and draws the RT/GT pin to keep low through discharge of external
RC. When a valid tone input is detected, EST goes high to charge RT/GT through RC. When the voltage
of RT/GT changes from 0 to VTRT (2.35V for 5V supply), the input signal is effective, and the code
detector will create the correct code.
After D0~D3 are completely latched, DV output becomes high. When the voltage of RT/GT
falls down from VDD to VTRT (i.e. when there is no input tone), DV output becomes Low, and D0~D3
keeps data until a next valid tone input is produced. By selecting adequate external RC value, the
minimum acceptable input tone duration (tACC) and the minimum acceptable inter-tone rejection (tIR)
can be set. External Components (R, C) are chosen by the formula.


~ 34 ~

Central office
Mobile radio
Remote control
Remote data entry
Call limiting

~ 35 ~


A relay is an electrically operated switch. Current flowing through the coil of the relay
creates a magnetic field which attracts a lever and changes the switch contacts. The coil current
can be on or off so relays have two switch positions and most have double throw (changeover)
switch contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be completely separate
from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC
mains circuit. There is no electrical connection inside the relay between the two circuits, the link
is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it
can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips)
cannot provide this current and a transistor is usually used to amplify the small IC current to the
larger value required for the relay coil. The maximum output current for the popular 555 timer IC
is 200mA so these devices can supply relay coils directly without amplification. Relays are
usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays
with 4 sets of changeover contacts are readily available. For further information about switch
contacts and the terms used to describe them please see the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to the pins
providing you take care to avoid melting the plastic case of the relay. The supplier's catalogue
should show you the relay's connections. The coil will be obvious and it may be connected either
way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this
can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection
diode across the relay coil.

~ 36 ~


All electrical relays have one thing in common--they control things where it is convenient
or impossible for a person to flip a switch. For example, electrical relays are used to turn on the
motor to open an automatic garage door, as well as to turn on a furnace. Many modern relays are
"solid state," meaning they use transistor-like devices to do their work. Electromechanical relays,
however, are still in use, and the working parts are easy to see and understand. They include an
electromagnet, which is turned on by a low-voltage control circuit, and a contact switch, which
in turn controls the load circuit. When the electromagnet is energized, it behaves just like
someone flipping a light switch, by pulling the switch up or down.
Poles and Throws

A simple electrical circuit requires two wires. Break one wire leading to a lamp, and it goes out.
That is exactly what most household switches do. Called a single pole switch, it opens one wire
in the circuit. Because it only turn the light on or off, it is also called single throw. This type of
switch is labeled SPST. For a "three-way" circuit, however, a different kind of switch is required;
it is never off, it just routes one side of the circuit over one of two wires. If both switches are set

~ 37 ~

on the same wire, the lamp goes on. If they are set on different wires, the lamp goes off. This
kind of switch is a single pole, double throw (because it has two "on" positions), or SPDT.
The main circuit breaker in any building is another type of switch. It positively disconnects all of
the power to the building, so it breaks both sides of the circuit. This is a double pole switch, and
because it is only on or off, it is a single throw, so it is a DPST switch.
The DPDT relay is the fourth kind of simple switch. The "DP" means that it is double pole, so it
switches both sides of the circuit, and the "DT" means that rather than just turning on and off, it
switches from one set of wires to another.
One Final Variable

A household wall switch will stay the way you leave it. Turn on the lights, and it stays on; turn it
off and it stays off. A relay, however, behaves in a different way. Since it is operated by an
electromagnet, when the magnet is de-energized, the switch will go back to its original position.
For a DPDT relay, that means that when the control circuit is off, the relay will turn on either
circuit A or circuit B. It is the user's choice, but it must be determined before the relay is










Use this 12 volt relay to isolate float switches from spiking voltage

Avert damage to float switches from pumps or solenoids

Works with our 12 Volt Wall Transformer

Connect wires simply and easily with our Relay Socket

Prongs accept our 3/16" Quick Connect Clips

Auto top-off project? Read our top-off project suggested set-up page

Also see our sister site

Coil voltage: 12VDC

~ 38 ~



Coil resistance: 160 Ohms

Contact rating: 10A at 250VAC or 30VDC

2.5 ULN2003

ULN is mainly suited for interfacing between low-level circuits and multiple peripheral power
loads. The series ULN20XX high voltage, high current Darlington arrays feature continuous load
current ratings. The driving circuitry in- turn decodes the coding and conveys the necessary data
to the stepper motor, this module aids in the movement of the arm through steppers.
The driver makes use of the ULN2003 driver IC, which contains an array of 7 power
Darlington arrays, each capable of driving 500mA of current. At an approximate duty
cycle, depending on ambient temperature and number of drivers turned on,
simultaneously typical power loads totaling over 230w can be controlled.
The device has base resistors, allowing direct connection to any common logic
family. All the emitters are tied together and brought out to a separate terminal.
Output protection diodes are included; hence the device can drive inductive loads
with minimum extra components. Typical loads include relays, solenoids, stepper
motors, magnetic print hammers, multiplexed LED, incandescent displays and

~ 39 ~

2.7.1 Darlington Pair

What is a Darlington Pair?

A Darlington pair is two transistors that act as a single transistor but with a much
higher current gain.
What is current gain?
Transistors have a characteristic called current gain. This is referred to as its hFE.
The amount of current that can pass through the load when connected to a
transistor that is turned on equals the input current x the gain of the transistor
(hFE) The current gain varies for different transistor and can be looked up in the
data sheet for the device. Typically it may be 100. This would mean that the
current available to drive the load would be 100 times larger than the input to the

~ 40 ~

2.7.2 Why use a Darlington Pair?

In some application the amount of input current available to switch on a transistor is very
low. This may mean that a single transistor may not be able to pass sufficient current required by
the load.
As stated earlier this equals the input current x the gain of the transistor (hFE). If it is not
be possible to increase the input current then we need to increase the gain of the transistor. This
can be achieved by using a Darlington Pair.
A Darlington Pair acts as one transistor but with a current gain that equals:
Total current gain (hFE total) = current gain of transistor 1 (hFE t1) x current gain of transistor 2
(hFE t2)
So for example if you had two transistors with a current gain (hFE) = 100:
(hFE total) = 100 x 100
(hFE total) = 10,000
You can see that this gives a vastly increased current gain when compared to a single transistor.
Therefore this will allow a very low input current to switch a much bigger load current.

~ 41 ~

Base Activation Voltage

Normally to turn on a transistor the base input voltage of the transistor will need to be
greater that 0.7V. As two transistors are used in a Darlington Pair this value is doubled. Therefore
the base voltage will need to be greater than 0.7V x 2 = 1.4V.
It is also worth noting that the voltage drop across collector and emitter pins of the
Darlington Pair when the turn on will be around 0.9V Therefore if the supply voltage is 5V (as
above) the voltage across the load will be will be around 4.1V (5V 0.9V)


~ 42 ~

1) Classical design for family
2) 380 TV Line 1.2GHz;
3) Tiny size for portability and observation;
4) Built-in microphone for audio monitoring;
5) Min 100 meters transmission distance without block.
6) Including adjustable bracket, easy installation.

1) Imaging sensor: 1/3" CMOS
2) CMOS total pixels: Pal 628 x 582; NTSC 510 x 492
3) Horizontal resolution: 380 TV lines
4) View angle:62
5) Minimum illumination: 1.0 Lux / F2.0
6) Transmission power: 50mW
7) Modulation mode: FM
8) Unobstructed effective range: 100m
9) Frequency: 900~1230MHz
10)Scanning Frequency: PAL/CCIR: 50Hz NTSC/EIA: 60Hz
11)Camera Size:36x28x36mm;
12)Camera weight:60g
1) Frequency: 900~1230MHz
2) Scanning Frequency: PAL/CCIR: 50Hz NTSC/EIA: 60Hz
3) Receiving Sensitivity: -85dBm
4) Video Output:1Vp-p@75; S/N>38dB Audio; Output: 1Vpp@600
5) Modulation mode: FM
6) Receiver Size:
7) weight: 130g


1X Receiver
1X Camera
2X Adaptor
1X AV cable
1X Battu
1X Manual

~ 43 ~



Laser beams in fog and on a car windshield

Light amplification by stimulated emission of radiation (LASER) is a mechanism for

emitting electromagnetic radiation, typically light or visible light, via the process of
stimulated emission. The emitted laser light is (usually) a spatially coherent, narrow lowdivergence beam, that can be manipulated with lenses. In laser technology, "coherent
light" denotes a light source that produces (emits) light of in-step waves of identical
frequency and phase. [1] The lasers beam of coherent light differentiates it from light
sources that emit incoherent light beams, of random phase varying with time and position;
whereas the laser light is a narrow-wavelength electromagnetic spectrum monochromatic
light; yet, there are lasers that emit a broad spectrum light, or simultaneously, at different

The word laser originally was the upper-case LASER, the acronym from Light
Amplification by Stimulated Emission of Radiation, wherein light broadly denotes
electromagnetic radiation of any frequency, not only the visible spectrum; hence infrared laser,
ultraviolet laser, X-ray laser, et cetera. Because the microwave predecessor of the laser, the
maser, was developed first, devices that emit microwave and radio frequencies are denoted
masers. In the early technical literature, especially in that of the Bell Telephone Laboratories
researchers, the laser was also called optical maser, a currently uncommon term, moreover,

~ 44 ~

since 1998, Bell Laboratories adopted the laser usage.[2] Linguistically, the back-formation verb
to lase means to produce laser light and to apply laser light to. The word laser sometimes is
inaccurately used to describe a non-laser-light technology, e.g. a coherent-state atom source is an
atom laser.

gamma rays, X-rays, ultraviolet rays, visible spectrum, infrared, microwaves, radio waves.


Principal components:
1. Gain medium
2. Laser pumping energy
3. High reflector
4. Output coupler
5. Laser beam
A laser consists of a gain medium inside a highly reflective optical cavity, as well as a
means to supply energy to the gain medium. The gain medium is a material with properties that
allow it to amplify light by stimulated emission. In its simplest form, a cavity consists of two
mirrors arranged such that light bounces back and forth, each time passing through the gain
medium. Typically one of the two mirrors, the output coupler, is partially transparent. The output
laser beam is emitted through this mirror.

~ 45 ~

Light of a specific wavelength that passes through the gain medium is amplified
(increases in power); the surrounding mirrors ensure that most of the light makes many passes
through the gain medium, being amplified repeatedly. Part of the light that is between the mirrors
(that is, within the cavity) passes through the partially transparent mirror and escapes as a beam
of light.
The process of supplying the energy required for the amplification is called pumping. The
energy is typically supplied as an electrical current or as light at a different wavelength. Such
light may be provided by a flash lamp or perhaps another laser. Most practical lasers contain
additional elements that affect properties such as the wavelength of the emitted light and the
shape of the beam.

Laser physics

A helium-neon laser demonstration at the Kastler-Brossel Laboratory at Univ. Paris 6.

The glowing ray in the middle is an electric discharge producing light in much the same way as a
neon light. It is the gain medium through which the laser passes, not the laser beam itself, which
is visible there. The laser beam crosses the air and marks a red point on the screen to the right.

Spectrum of a helium neon laser showing the very high spectral purity intrinsic to nearly
all lasers. Compare with the relatively broad spectral remittance of a light emitting diode.
The gain medium of a laser is a material of controlled purity, size, concentration, and
shape, which amplifies the beam by the process of stimulated emission. It can be of any state:

~ 46 ~

gas, liquid, solid or plasma. The gain medium absorbs pump energy, which raises some electrons
into higher-energy ("excited") quantum states. Particles can interact with light both by absorbing
photons or by emitting photons. Emission can be spontaneous or stimulated. In the latter case,
the photon is emitted in the same direction as the light that is passing by. When the number of
particles in one excited state exceeds the number of particles in some lower-energy state,
population inversion is achieved and the amount of stimulated emission due to light that passes
through is larger than the amount of absorption. Hence, the light is amplified. By itself, this
makes an optical amplifier. When an optical amplifier is placed inside a resonant optical cavity,
one obtains a laser.
The light generated by stimulated emission is very similar to the input signal in terms of
wavelength, phase, and polarization. This gives laser light its characteristic coherence, and
allows it to maintain the uniform polarization and often monochromaticity established by the
optical cavity design.
The optical cavity, a type of cavity resonator, contains a coherent beam of light between
reflective surfaces so that the light passes through the gain medium more than once before it is
emitted from the output aperture or lost to diffraction or absorption. As light circulates through
the cavity, passing through the gain medium, if the gain (amplification) in the medium is stronger
than the resonator losses, the power of the circulating light can rise exponentially. But each
stimulated emission event returns a particle from its excited state to the ground state, reducing
the capacity of the gain medium for further amplification. When this effect becomes strong, the
gain is said to be saturated. The balance of pump power against gain saturation and cavity losses
produces an equilibrium value of the laser power inside the cavity; this equilibrium determines
the operating point of the laser. If the chosen pump power is too small, the gain is not sufficient
to overcome the resonator losses, and the laser will emit only very small light powers. The
minimum pump power needed to begin laser action is called the lasing threshold. The gain
medium will amplify any photons passing through it, regardless of direction; but only the
photons aligned with the cavity manage to pass more than once through the medium and so have
significant amplification.
The beam in the cavity and the output beam of the laser, if they occur in free space rather
than waveguides (as in an optical fiber laser), are, at best, low order Gaussian beams. However
this is rarely the case with powerful lasers. If the beam is not a low-order Gaussian shape, the
transverse modes of the beam can be described as a superposition of Hermite-Gaussian or
Laguerre-Gaussian beams (for stable-cavity lasers). Unstable laser resonators on the other hand,
have been shown to produce fractal shaped beams.[4] The beam may be highly collimated, that is
being parallel without diverging. However, a perfectly collimated beam cannot be created, due to
diffraction. The beam remains collimated over a distance which varies with the square of the
beam diameter, and eventually diverges at an angle which varies inversely with the beam
diameter. Thus, a beam generated by a small laboratory laser such as a helium-neon laser spreads
to about 1.6 kilometers (1 mile) diameter if shone from the Earth to the Moon. By comparison,
the output of a typical semiconductor laser, due to its small diameter, diverges almost as soon as
it leaves the aperture, at an angle of anything up to 50. However, such a divergent beam can be

~ 47 ~

transformed into a collimated beam by means of a lens. In contrast, the light from non-laser light
sources cannot be collimated by optics as well.
Although the laser phenomenon was discovered with the help of quantum physics, it is
not essentially more quantum mechanical than other light sources. The operation of a free
electron laser can be explained without reference to quantum mechanics.

Modes of operation
The output of a laser may be a continuous constant-amplitude output (known as CW or
continuous wave); or pulsed, by using the techniques of Q-switching, modelocking, or gainswitching. In pulsed operation, much higher peak powers can be achieved.
Some types of lasers, such as dye lasers and vibronic solid-state lasers can produce light over a
broad range of wavelengths; this property makes them suitable for generating extremely short
pulses of light, on the order of a few femtoseconds (10-15 s).

Continuous wave operation

In the continuous wave (CW) mode of operation, the output of a laser is relatively
constant with respect to time. The population inversion required for lasing is continually
maintained by a steady pump source.
Pulsed operation
In the pulsed mode of operation, the output of a laser varies with respect to time, typically
taking the form of alternating 'on' and 'off' periods. In many applications one aims to deposit as
much energy as possible at a given place in as short time as possible. In laser ablation for
example, a small volume of material at the surface of a work piece might evaporate if it gets the
energy required to heat it up far enough in very short time. If, however, the same energy is spread
over a longer time, the heat may have time to disperse into the bulk of the piece, and less
material evaporates. There are a number of methods to achieve this.
In a Q-switched laser, the population inversion (usually produced in the same way as CW
operation) is allowed to build up by making the cavity conditions (the 'Q') unfavorable for lasing.
Then, when the pump energy stored in the laser medium is at the desired level, the 'Q' is adjusted
(electro- or acousto-optically) to favourable conditions, releasing the pulse. This results in high
peak powers as the average power of the laser (were it running in CW mode) is packed into a
shorter time frame.
Mode locking

~ 48 ~

A mode locked laser emits extremely short pulses on the order of tens of picoseconds
down to less than 10 femtoseconds. These pulses are typically separated by the time that a pulse
takes to complete one round trip in the resonator cavity. Due to the Fourier limit (also known as
energy-time uncertainty), a pulse of such short temporal length has a spectrum which contains a
wide range of wavelengths. Because of this, the laser medium must have a broad enough gain
profile to amplify them all. An example of a suitable material is titanium-doped, artificially
grown sapphire (Ti:sapphire).
The mode locked laser is a most versatile tool for researching processes happening at
extremely fast time scales also known as femtosecond physics, femtosecond chemistry and
ultrafast science, for maximizing the effect of nonlinearity in optical materials (e.g. in secondharmonic generation, parametric down-conversion, optical parametric oscillators and the like),
and in ablation applications. Again, because of the short timescales involved, these lasers can
achieve extremely high powers.
Pulsed pumping
Another method of achieving pulsed laser operation is to pump the laser material with a
source that is itself pulsed, either through electronic charging in the case of flashlamps, or
another laser which is already pulsed. Pulsed pumping was historically used with dye lasers
where the inverted population lifetime of a dye molecule was so short that a high energy, fast
pump was needed. The way to overcome this problem was to charge up large capacitors which
are then switched to discharge through flashlamps, producing a broad spectrum pump flash.
Pulsed pumping is also required for lasers which disrupt the gain medium so much during the
laser process that lasing has to cease for a short period. These lasers, such as the excimer laser
and the copper vapour laser, can never be operated in CW mode.

Light gun

The NES Zapper, Nintendo's early light gun

~ 49 ~

A light gun is a pointing device for c omputers and a control device for arcade and video
games. Modern screen-based light guns work by building a sensor into the gun itself, and the onscreen target(s) emit light rather than the gun. The first light gun of this type was used on the
MIT Whirlwind computer.
The light gun, and its descendant, the light pen, are now rarely used as computer pointing
devices, because of the popularity of the mouse and changes in monitor display technology traditional light guns can only work with standard CRT monitors.

Early history
The first light guns appeared in the 1930s, following the development of light-sensing
vacuum tubes. It was not long before the technology began appearing in arcade shooting games,
beginning with the Seaborg Ray-O-Lite in 1936. These early light gun games, like modern laser
tag, used small targets (usually moving) onto which a light-sensing tube was mounted; the player
used a gun (usually a rifle) that emitted a beam of light when the trigger was pulled. If the beam
struck the target, a "hit" was scored.
The video game light gun is typically modeled on a ballistic weapon (usually a pistol)
and is used for targeting objects on a video screen. With force feedback, the light gun can also
simulate the recoil of the weapon.
Light guns are very popular in arcade games, but had not caught on as well in the home
video game console market until after the Nintendo Entertainment System (NES), Sega Master
System (SMS), Mega Drive/Genesis, and Super Nintendo Entertainment System (SNES)
systems. Nevertheless, many home 'Pong' systems of the 70s included a pistol or gun for
shooting simple targets on screen.
Traditional light guns cannot be used on the newer LCD and plasma screens, and have problems
with projection screens.
The following are famous example of light guns:

Magnavox Odyssey Shooting Gallery the first gun for a home console was in fact a big
rifle, which looked very lifelike and even needed to be "cocked" after each shot
Nintendo's NES Zapper for the NES, arguably the most popular example of the light gun
XG-1 for Atari XE-GS
Action Max, a console that used VHS tapes for games, solely controlled by a light gun
Light Phaser for Sega Master System
Super Scope for Super Nintendo, shaped like a bazooka
Menacer for Sega Mega Drive
Peacekeeper Revolver for Philips CDi
Sega Lock-On, a stand-alone laser tag system

~ 50 ~

Namco's GunCon and GunCon 2, first to read the video signal in the accessory (rather
than internally in the console) and said to be highly accurate; used for PlayStation and
PlayStation 2
Dreamcast light guns for Dreamcast
The XT-7 from Captain Power, an interactive television show
Magnum Light Phaser For Spectrum / Commodore 64
The Wii Zapper for the Wii console is designed to house the Wii Remote and Nunchuk,
giving a light gun feel (although the Wii Remote itself does not use traditional light gun

There are also light guns for Sega Saturn, Xbox and several other console and arcade systems.
Recent light gun video games include Resident Evil: The Umbrella Chronicles, Time Crisis 4,
Virtua Cop 3, and The House of the Dead: Overkill.
The Wii Remote can be seen as a successor to this technology, and it can be used relatively
accurately with CRT, LCD, plasma, and projection screens. Like the NES Zapper, it is "bundled"
with the system, but unlike traditional light guns, the Wii Remote serves as a primary controller.
If coupled with the Nunchuk attachment, the Wii Remote allows for a potentially seamless union
between first-person shooter gameplay and "light gun" implementation. Namco's GunCon 3 also
uses a system similar to the Wii Remote, using 2 infrared LEDs and sensors in the gun, as
opposed to the traditional light guns.

The "light gun" is named because it uses light as its method of detecting where on screen the user
is targeting. The name leads one to believe that the gun itself emits a beam of light, but in fact
most light guns actually receive light through a photodiode in the gun barrel.
There are two versions of this technique that are commonly used, but the concept is the same:
when the trigger of the gun is pulled, the screen is blanked out to black, and the diode begins
reception. All or part of the screen is painted white in a way that allows the computer to judge
where the gun is pointing, based on when the diode detects light. The user of the light gun
notices little or nothing, because the period in which the screen is blank is usually only a fraction
of a second (see persistence of vision).

Sequential targets
The first detection method, used by the Zapper, involves drawing each target sequentially in
white light after the screen blacks out. The computer knows that if the diode detects light as it is
drawing a square (or after the screen refreshes) then, that is the target at which the gun is pointed.
Essentially, the diode tells the computer whether or not you hit something, and for n objects, the
sequence of the drawing of the targets tell the computer which target you hit after 1 +

~ 51 ~

ceil(log2(n)) refreshes (one refresh to determine if any target at all was hit and ceil(log 2(n)) to do
a binary search for the object that was hit).
An interesting side effect of this is that on poorly designed games, often a player can point the
gun at a light bulb, pull the trigger and hit the first target every time. Better games account for
this either by detecting if all targets appear to match or by displaying a black screen and
verifying that no targets match.

Cathode ray timing

The GunCon (gray; top) and the GunCon 2 (orange; bottom) for the PlayStation and PlayStation
2, respectively

The blue (top) and pink (middle) Konami Justifiers made for the Super Nintendo
Entertainment System and the green (bottom) one made for the PlayStation
The second method, used by the Super Nintendo Entertainment System's Super Scope and
computer light pens, is more elaborate and more accurate.
The trick to this method lies in the nature of the cathode ray tube inside the video monitor
(CRTs were the only affordable TV monitors in the late 1980s and early 1990s, when this method
was popularized). The screen is drawn by a scanning electron beam that travels across the screen
starting at the top until it hits the end, and then moves down to update the next line. This is done
repeatedly until the entire screen is drawn, and appears instantaneous to the human eye as it is
done very quickly.
When the player pulls the trigger, the computer (often assisted by the display circuitry)
times how long it takes the electron beam to excite the phosphor at the location at which the gun
is pointed. The light gun sends a signal after sensing the sudden small change in brightness of a

~ 52 ~

point on the screen when the electron gun refreshes that spot. The computer then calculates the
targeted position based on the monitor's horizontal refresh rate (the fixed amount of time it takes
the beam to get from the left to right side of the screen). Either the computer provides a time base
for the horizontal refresh rate through the controller's connector (as in the Super Scope), or the
gun reads the composite video signal through a T-connector on the A/V cable (as in the GunCon
2). Once the computer knows where the gun is pointed, it can tell through collision detection if it
coincides with the target or not.
Many guns of this type (including the Super Scope) ignore red light, as red phosphors
have a much slower rate of decay than green or blue phosphors. As a result, some (but not all)
games brighten the entire screen somewhat when the trigger is pulled in order to get a more
reliable fix on the position.
Display timing is useless with plasma, LCD, and DLP, which refresh all pixels at the same time.

Combined method
Some light guns designed for sequential targeting are not timed precisely enough to get
an (X, Y) reading against the video signal, but they can use a combination of the two methods.
First the screen is brightened and the response time is measured as in cathode ray timing, but the
computer measures only which scanline was hit and not which horizontal pixel was hit. This
does not need nearly as fast a timer that pure cathode ray timing uses, on the order of 15 kHz for
Y vs. 5 MHz for (X, Y) on a standard resolution display. Then using sequential targets, the game
cycles among those targets on the line.

Infrared emitters
A new method was developed to compensate for display technologies other than CRT. It
relies on one or several infrared light emitters placed near the screen, and one IR sensor on the
muzzle of the gun. When the trigger is pressed, the gun sends the intensity of the IR beam it
detects. Since this intensity depends upon both distance and relative angle to the screen, angle
sensors are located in the gun. This way a trigonometric equation system is solved, and the
muzzle's 3D position relative to the screen is calculated. Then, by projecting the muzzle on the
screen with the measured angles the impact point is determined. An early example of this
technology (though not using IR) can be seen in the NES Power Glove Accessory, which used
three ultrasonic sensors serving the same function as the IR emitters used in some lightguns.
A simpler variant is commonly used in arcades, where there are no angle detectors but 4
IR sensors. However, this can prove inaccurate when shooting from certain distances and angles,
since the calculation of angles and 3D position has a larger margin of error.

~ 53 ~

Other variants include 3 or more emitters with different infrared wavelengths and the
same number of sensors. With this method and proper calibration three or more relative angles
are obtained, thus not needing angle detectors to position the gun.
Sometimes, the sensors are placed around the screen and the emitter on the gun, but
calculations are similar.
This family of methods are used for the Wii Remote, GunCon 3,[1] and modern arcade
light gun games.

Image capture
When the user pulls the trigger the screen is replaced for a split-second with a seemingly
random but non-repeating display of black and white pixels or groups of pixels (blocks). The
light gun contains a fine-resolution but low pixel count digital camera with a very narrow field of
view. With just a handful of the encrypted random dot image pixels captured the gun converts the
small image into a binary array which allows the computer to locate the exact position the gun
was pointed at and is compatible with any screen of any size. The size of the screen and distance
to shooter is entered into the gun driver software to determine the dimensions of the random
blocks/pixels to best allow rendering on the light gun CCD.

A game that uses more than one gun reads both triggers continuously and then, when one
player pulls a gun's trigger, the game reads that gun until it knows which object was hit.

Positional guns
Positional guns are fairly common in video arcades. A positional gun is a gun mounted to
the cabinet on a swivel that allows the player to aim the gun. These are often confused with light
guns but work quite differently. These guns may not be removed from the cabinet like the optical
counterparts, which are tethered and stored in a mounted holster. They are typically more
expensive initially but easier to maintain and repair. Games that use positional guns include
Operation Wolf, Silent Scope, the arcade version of Resident Evil: Survivor, Space Gun,
Revolution X and Terminator 2: Judgment Day. The console ports used light guns.
A positional gun is effectively an analog stick that records the position of the gun to
determine where the player is aiming. The gun must be calibrated, which usually happens after
powering up. Some games have mounted optical guns, such as Exidy's Crossbow.

~ 54 ~


Source code:-

~ 55 ~

delay(unsigned char);
sbit SMOTORUP=P2^0;


sbit AMOTORUP=P2^2;
//sbit DMOTORCLK=P3^4;
sbit GUN_LASER=P2^6;


sbit INTERUPT=P2^7;

~ 56 ~

////////////////////////shaft motor/////////////////////////////////////////


/////////////////////angle motor////////////////////////////////////////////


~ 57 ~

//////////////////////////////grip motor///////////////////////////////////////////////
//////////////////////////////OFF CONDITION///////////////////////////////////////////////

~ 58 ~


//////////////////////bottom motor///////////////////////////////////////////



~ 59 ~








~ 60 ~



}// interupt
delay(unsigned char time)
unsigned char i,j;

~ 61 ~


4.1 Introduction:
In this chapter the software used and the language in which the program code is defined
is mentioned and the program code dumping tools are explained. The chapter also documents the
development of the program for the application. This program has been termed as Source code.
Before we look at the source code we define the two header files that we have used in the code.

4.2 Tools Used:

Figure 4.1 Keil Software- internal stages

~ 62 ~

Keil development tools for the 8051 Microcontroller Architecture support every level of
software developer from the professional applications

4.3 C51 Compiler & A51 Macro Assembler:

Source files are created by the Vision IDE and are passed to the C51 Compiler or A51
Macro Assembler. The compiler and assembler process source files and create replaceable object
The Keil C51 Compiler is a full ANSI implementation of the C programming language
that supports all standard features of the C language. In addition, numerous features for direct
support of the 8051 architecture have been added.


What's New in Vision3?

Vision3 adds many new features to the Editor like Text Templates, Quick Function
Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based
startup and debugger setup. Vision3 is fully compatible to Vision2 and can be used in parallel
with Vision2.
What is Vision3?
Vision3 is an IDE (Integrated Development Environment) that helps you write, compile,
and debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.


A powerful debugger.

~ 63 ~

To help you get started, several example programs (located in the \C51\Examples,
\C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.

HELLO is a simple program that prints the string "Hello World" using the Serial Interface.

MEASURE is a data acquisition system for analog and digital systems.

TRAFFIC is a traffic light controller with the RTX Tiny operating system.

SIEVE is the SIEVE Benchmark.

DHRY is the Dhrystone Benchmark.

WHETS is the Single-Precision Whetstone Benchmark.

Additional example programs not listed here are provided for each device architecture.


To build (compile, assemble, and link) an application in Vision2, you must:
1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.
Vision2 compiles, assembles, and links the files in your project.
Creating Your Own Application in Vision2
To create a new project in Vision2, you must:
1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device
4. Create source files to add to the project.
5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add the source files
to the project.
6. Select Project - Options and set the tool options. Note when you select the target device from the
Device Database all special options are set automatically. You typically only need to configure

~ 64 ~

the memory map of your target hardware. Default memory model settings are optimal for most
7. Select Project - Rebuild all target files or Build target.

Debugging an Application in Vision2

To debug an application created using Vision2, you must:
1. Select Debug - Start/Stop Debug Session.
2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the
Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.

Starting Vision2 and Creating a Project

Vision2 is a standard Windows application and started by clicking on the program icon. To
create a new project file select from the Vision2 menu
Project New Project. This opens a standard Windows dialog that asks you for the new
project file name. We suggest that you use a separate folder for each project. You can simply use
the icon Create New Folder in this dialog to get a new empty folder. Then select this folder and
enter the file name for the new project, i.e. Project1. Vision2 creates a new project file with the
name PROJECT1.UV2 which contains a default target and file group name. You can see these
names in the Project

Window Files.
Now use from the menu Project Select Device for Target and select a CPU for your project.
The Select Device dialog box shows the Vision2 device database. Just select the
microcontroller you use. We are using for our examples the Philips 80C51RD+ CPU. This
selection sets necessary tool options for the 80C51RD+ device and simplifies in this way the tool

~ 65 ~

Building Projects and Creating a HEX Files

Typical, the tool settings under Options Target are all you need to start a new
application. You may translate all source files and line the application with a click on the Build
Target toolbar icon. When you build an application with syntax errors, Vision2 will display
errors and warning messages in the Output Window Build page. A double click on a message
line opens the source file on the correct location in a Vision2 editor window. Once you have
successfully generated your application you can start debugging.
After you have tested your application, it is required to create an Intel HEX file to
download the software into an EPROM programmer or simulator. Vision2 creates HEX files
with each build process when Create HEX files under Options for Target Output is enabled.
You may start your PROM programming utility after the make process when you specify the
program under the option Run User Program #1.

CPU Simulation
Vision2 simulates up to 16 Mbytes of memory from which areas can be mapped for
read, write, or code execution access. The Vision2 simulator traps and reports illegal memory
accesses. In addition to memory mapping, the simulator also provides support for the integrated
peripherals of the various 8051 derivatives. The on-chip peripherals of the CPU you have
selected are configured from the Device.

Database selection
You have made when you create your project target. Refer to page 58 for more
Information about selecting a device. You may select and display the on-chip peripheral
components using the Debug menu. You can also change the aspects of each peripheral using the
controls in the dialog boxes.
Start Debugging

~ 66 ~

You start the debug mode of Vision2 with the Debug Start/Stop Debug Session
command. Depending on the Options for Target Debug Configuration, Vision2 will load the
application program and run the startup code Vision2 saves the editor screen layout and restores
the screen layout of the last debug session. If the program execution stops, Vision2 opens an
editor window with the source text or shows CPU instructions in the disassembly window. The
next executable statement is marked with a yellow arrow. During debugging, most editor features
are still available.
For example, you can use the find command or correct program errors. Program source
text of your application is shown in the same windows. The Vision2 debug mode differs from
the edit mode in the following aspects:

The Debug Menu and Debug Commands described below are available. The additional
debug windows are discussed in the following.

The project structure or tool parameters cannot be modified. All build Commands are
Disassembly Window
The Disassembly window shows your target program as mixed source and assembly
program or just assembly code. A trace history of previously executed instructions may be
displayed with Debug View Trace Records. To enable the trace history, set Debug
Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step commands
work on CPU instruction level rather than program source lines. You can select a text line and set
or modify code breakpoints using toolbar buttons or the context menu commands.
You may use the dialog Debug Inline Assembly to modify the CPU instructions. That
allows you to correct mistakes or to make temporary changes to the target program you are

~ 67 ~



Click on the Keil uVision Icon on Desktop


The following fig will appear


Click on the Project menu from the title bar


Then Click on New Project

~ 68 ~


Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\


Then Click on Save button above.


Select the component for u r project. i.e. Atmel

~ 69 ~


Click on the + Symbol beside of Atmel


Select AT89C51 as shown below


Then Click on OK

~ 70 ~


The Following fig will appear


Then Click either YES or NOmostly NO


Now your project is ready to USE


Now double click on the Target1, you would get another option Source group 1 as
shown in next page.

~ 71 ~


Click on the file option from menu bar and select new


The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.

~ 72 ~


Now start writing program in either in C or ASM.


For a program written in Assembly, then save it with extension . asm and for C
based program save it with extension .C

~ 73 ~


Now right click on Source group 1 and click on Add files to Group Source


Now you will get another window, on which by default C files will appear.

~ 74 ~


Now select as per your file extension given while saving the file


Click only one time on option ADD


Now Press function key F7 to compile. Any error will appear if so happen.


If the file contains no error, then press Control+F5 simultaneously.

~ 75 ~


The new window is as follows


Then Click OK


Now Click on the Peripherals from menu bar, and check your required port as shown
in fig below

~ 76 ~


Drag the port a side and click in the program file.


Now keep Pressing function key F11 slowly and observe.


You are running your program successfully

~ 77 ~



To project can be successfully implemented in capturing enemy info and attacking.
ROBOT can silently enter into enemy area and send us all the information through its tiny
camera eyes. It is designed for, fighting.

The project MOBILE SPY ROBO has been successfully designed and tested.
Integrating features of all the hardware components used have developed it. Presence of every
module has been reasoned out and placed carefully thus contributing to the best working of the
unit. Secondly, using highly advanced ICs and with the help of growing technology the project
has been successfully implemented.


By using this method in our ARMY the system attacking enemies will be more sophisticated
And soldiers involvement is reduced.

1.) With this method enemy can be identified clearly by ROBOT wireless camera and

attack by remote signals.

2.) There is no need of person involvement in the attacking area.

1.) OPERATOR should be perfect in monitoring ROBOT and sending action signals.

~ 78 ~

1.) This method can be implemented in OUR ARMY for attacking on enemies in
critical situations.

~ 79 ~












~ 80 ~

1. "The 8051 Microcontroller Architecture, Programming & Applications"

By Kenneth J Ayala.
2. "The 8051 Microcontroller & Embedded Systems" by Mohammed Ali Mazidi and
Janice Gillispie Mazidi
3. "Power Electronics by M D Singh and K B Khanchandan
4. "Linear Integrated Circuits by D Roy Choudary & Shail Jain
5. "Electrical Machines by S K Bhattacharya
6. "Electrical Machines II by B L Thereja

8. ^ "Google exposes web surveillance cams" by Kevin Poulsen, The Register,

8th January 2005, retrieved 5th September 2006.

~ 81 ~