Professional Documents
Culture Documents
INTRODUCTION
~1~
do not learn about these technologies during hands-on lab exercises. The communication
mediums were twisted pair, optical fiber, infrared, and generally wireless radio.
~2~
BLOCK DIAGRAM:
U
L
N
2
0
0
3
A
POWER SUPPLY
T
8
9
MOBILE
HEAD
PHONE
DTMF
HT917
0
MOTOR1
MOTOR2
U
L
N
2
0
0
3
S
5
2
WIRELESS
WEBCAM
RELAY
~3~
LASER
GUN
MOTOR1
MOTOR2
CHAPTER 2
DESCRIPTION OF HARDWARE COMPONENTS
2.1 AT89S52
o A BRIEF HISTORY OF 8051
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
AT89S52:
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
~4~
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
~5~
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
program
it,
simpler
architecture
can
be
represented
as
the
figure
1.2.A.
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.
NECESSITY OF MICROCONTROLLERS:
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.
~6~
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.
Bulky:
On comparing a board full of chips (Microprocessors) with one chip with all components
in it (Microcontroller).
Debugging:
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.
~7~
~8~
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.
2.1.2 FEATURES
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)
~9~
Pin Description
VCC
Supply voltage.
GND
Ground.
~ 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
verification.
~ 12 ~
RST
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
.
PSEN
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 ~
EA/VPP
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.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
~ 14 ~
~ 15 ~
2.1.5 MEMORIES
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.
~ 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.
~ 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 ~
~ 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.
2.2.3 TRANSFORMER
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 ~
So
The secondary voltage of the transformer depends on the number of turns in the Primary as well as in the
secondary.
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.
~ 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.
2)
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.
3)
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.
FILTER CAPACITOR
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
called as FILTER CAPACITOR or SMOOTHING CAPACITOR or RESERVOIR
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.
Where,
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 ~
1)
resistively as heat.
2)
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
voltage.
~ 28 ~
(ii)
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
devices.
~ 29 ~
IC 7805
Vout
5V
5V - 20V
0 - 125C
Output Imax
1A
2.3 HT9170B
DTMF RECIEVER
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/
FEAUTURES:
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 ~
BLOCK DIAGRAM:
FUNCTIONAL DESCRIPTION:
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 ~
TIMING DIAGRAM
~ 34 ~
Applications:
PABX
Central office
Mobile radio
Remote control
Remote data entry
Call limiting
~ 35 ~
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 ~
Relays
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
installed.
General
purpose
double
pole,
double
throw
12V
relay
with
Specifications
Use this 12 volt relay to isolate float switches from spiking voltage
Auto top-off project? Read our top-off project suggested set-up page
~ 38 ~
magnetic
coil
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
heaters.
~ 39 ~
~ 40 ~
~ 41 ~
~ 42 ~
Description:
Features:
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.
Specification:
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
Specification:
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
Accessories:
1X Receiver
1X Camera
2X Adaptor
1X AV cable
1X Battu
1X Manual
~ 43 ~
LASER LIGHT
Terminology:
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.
Design
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
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).
~ 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
~ 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
technology).
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.
Design
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.
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.
Multiplayer
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 ~
CHAPTER 3
CIRCUITS AND THEIR OPERATION
3.1 CIRCUIT DIAGRAM:
Source code:-
~ 55 ~
#include<reg51.h>
delay(unsigned char);
sbit SMOTORUP=P2^0;
//S:SHAFT
sbit SMOTORDOWN=P2^1;
sbit AMOTORUP=P2^2;
sbit AMOTORDOWN=P2^3; //A:ANGLE
//sbit DMOTORCLK=P3^4;
//sbit DMOTORANTICLK=P3^5;
sbit BMOTOR_L_FORWARD=P1^4;
sbit BMOTOR_L_BACKWARD=P1^5; //B:BOTTOM MOTORS
sbit BMOTOR_R_FORWARD=P1^6;
sbit BMOTOR_R_BACKWARD=P1^7;
sbit GUN_LASER=P2^6;
//G:GRIP
sbit INTERUPT=P2^7;
main()
{
SMOTORUP=0;
SMOTORDOWN=0;
AMOTORUP=0;
AMOTORDOWN=0;
BMOTOR_L_FORWARD=0;
BMOTOR_L_BACKWARD=0;
BMOTOR_R_FORWARD=0;
BMOTOR_R_BACKWARD=0;
~ 56 ~
GUN_LASER=1;
P1=0X0F;
while(1)
{
////////////////////////shaft motor/////////////////////////////////////////
if(P1==0x07)
{
SMOTORUP=1;
delay(30);
SMOTORUP=0;
//1,2
}
if(P1==0x09)
{
SMOTORDOWN=1;
delay(30);
SMOTORDOWN=0;
}
////////////////////////////////////////////////////////////////////////////
/////////////////////angle motor////////////////////////////////////////////
if(P1==0x0B)
{
AMOTORUP=1;
delay(30);
AMOTORUP=0;
//3,4
~ 57 ~
}
if(P1==0x0C)
{
AMOTORDOWN=1;
delay(30);
AMOTORDOWN=0;
}
////////////////////////////////////////////////////////////////////////////
//////////////////////////////grip motor///////////////////////////////////////////////
if(P1==0x08)
{
GUN_LASER=~GUN_LASER;
}
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////OFF CONDITION///////////////////////////////////////////////
if(P1==0x0A)
{
SMOTORUP=0;
SMOTORDOWN=0;
AMOTORUP=0;
AMOTORDOWN=0;
// DMOTORCLK=0;
// DMOTORANTICLK=0;
BMOTOR_L_FORWARD=0;
~ 58 ~
BMOTOR_L_BACKWARD=0;
BMOTOR_R_FORWARD=0;
BMOTOR_R_BACKWARD=0;
GUN_LASER=0;
}
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////bottom motor///////////////////////////////////////////
if(P1==0x03)
{
BMOTOR_L_FORWARD=1;
BMOTOR_R_BACKWARD=1;
delay(150);
BMOTOR_L_FORWARD=0;
BMOTOR_R_BACKWARD=0;
BMOTOR_R_BACKWARD=0;
BMOTOR_L_BACKWARD=0;
BMOTOR_R_BACKWARD=0;
BMOTOR_R_FORWARD=0;
}
if(P1==0x01)
{
BMOTOR_R_FORWARD=1;
BMOTOR_L_BACKWARD=1;
~ 59 ~
delay(150);
BMOTOR_R_FORWARD=0;
BMOTOR_L_BACKWARD=0;
BMOTOR_L_BACKWARD=0;
BMOTOR_L_BACKWARD=0;
BMOTOR_R_BACKWARD=0;
BMOTOR_L_FORWARD=0;
if(P1==0x05)
{
BMOTOR_L_BACKWARD=1;
BMOTOR_R_BACKWARD=1;
delay(150);
BMOTOR_L_BACKWARD=0;
BMOTOR_R_BACKWARD=0;
}
if(P1==0x02)
{
BMOTOR_L_FORWARD=1;
BMOTOR_R_FORWARD=1;
delay(150);
~ 60 ~
BMOTOR_L_FORWARD=0;
BMOTOR_R_FORWARD=0;
// MOVING FORWARDS
}
}// interupt
}//while
}//main
delay(unsigned char time)
{
unsigned char i,j;
for(i=0;i<time;i++)
for(j=0;j<250;j++);
}
~ 61 ~
CHAPTER 4
4. SOFTWARE DEVELOPMENT
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.
~ 62 ~
Keil development tools for the 8051 Microcontroller Architecture support every level of
software developer from the professional applications
4.4 VISION
A project manager.
A make facility.
Tool configuration.
Editor.
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.
TRAFFIC is a traffic light controller with the RTX Tiny operating system.
~ 64 ~
the memory map of your target hardware. Default memory model settings are optimal for most
applications.
7. Select Project - Rebuild all target files or Build target.
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
Configuration
~ 65 ~
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
disabled.
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
debugging.
~ 67 ~
2.
3.
4.
~ 68 ~
5.
Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
6.
7.
~ 69 ~
8.
9.
10.
Then Click on OK
~ 70 ~
11.
12.
13.
14.
Now double click on the Target1, you would get another option Source group 1 as
shown in next page.
~ 71 ~
15.
Click on the file option from menu bar and select new
16.
The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
~ 72 ~
17.
18.
For a program written in Assembly, then save it with extension . asm and for C
based program save it with extension .C
~ 73 ~
19.
Now right click on Source group 1 and click on Add files to Group Source
20.
Now you will get another window, on which by default C files will appear.
~ 74 ~
21.
Now select as per your file extension given while saving the file
22.
23.
Now Press function key F7 to compile. Any error will appear if so happen.
24.
~ 75 ~
25.
26.
Then Click OK
27.
Now Click on the Peripherals from menu bar, and check your required port as shown
in fig below
~ 76 ~
28.
29.
30.
~ 77 ~
CHAPTER 5
5.1 CONCLUTION:
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.
5.2 RESULT:
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.
5.4 ADVANTAGES:
1.) With this method enemy can be identified clearly by ROBOT wireless camera and
5.5 DISADVANTAGES:
1.) OPERATOR should be perfect in monitoring ROBOT and sending action signals.
~ 78 ~
5.6 APPLICATIONS:
1.) This method can be implemented in OUR ARMY for attacking on enemies in
critical situations.
~ 79 ~
BIBILOGRAPHY
1.
WWW.MITEL.DATABOOK.COM
2.
WWW.ATMEL.DATABOOK.COM
3.
WWW.FRANKLIN.COM
4.
WWW.KEIL.COM
5.
6.
7.
8.
http://www.sunrom.com
http://www.rfsolutions.co.uk
http://en.wikipedia.org/wiki/ISight
www.laserhotshots.co.uk/gun2.gif
9.
www.laserhotshots.co.uk/garden.htm
REFERENCES
~ 80 ~
www.8051freeprojectsinfo.com
~ 81 ~