Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 50

CHAPTER1: OVERVIEW

1.1 Introduction:

Now a day's every system is automated in order to face new challenges.


In the present days Automated systems have less manual operations, flexibility,
reliability and accurate. Due to this demand every field prefers automated control
systems. Especially in the field of electronics automated systems are giving good
performance. In the present scenario of war situations, unmanned systems plays very
important role to minimize human losses. So this robot is very useful to do operations
like mine detection.

In this project we are controlling a robot with wire. In this system, a robot
is fitted with motors. A micro controller is used to control all the operations.
According to the motor operations the ROBOT will operate as specified in program.
Whenever a mine is detected, the Buzzer is turned ON and the ROBOT stops.

In this system we have one metal detector sensor. A 12V battery is provided to
power the robot to perform all functions.

Metal detectors use electromagnetic induction to detect metal. The simplest


form of a metal detector consists of an oscillator producing an alternating current that
passes through a coil producing an alternating magnetic field. If a piece of electrically
conductive metal is close to the coil, eddy currents will be induced in the metal, and
this produces an alternating magnetic field of its own. If another coil is used to
measure the magnetic field (acting as a magnetometer), the change in the magnetic
field due to the metallic object can be detected.

1.2 Applications

• Used in Military applications


• Used in Industrial applications.

Uses include de-mining (the detection of land mines), the detection of weapons such
as knives and guns, especially at airports, geophysical prospecting, archaeology and
treasure hunting. Metal detectors are also used to detect foreign bodies in food, and in

1 MGIT
the construction industry to detect steel reinforcing bars in concrete and pipes and
wires buried in walls and floors.

1.3 Hardware components:

• AT 89S52 Micro controllers


• METAL DETECTOR SENSOR
• DC Gear MOTOR
• DPDT RELAYS
• ULN2003
1.4 Software tools:

• Kiel Micro vision.


• Embedded ‘C’
• Micro flash.

1.5 Block Diagram:

POWER SUPPLY

MOTORS
METAL
DETECTOR
SENSOR MICRO
CONTROLLER
UNIT

BUZZER

Fig 1.1: Block Diagram of Metal Detecting Robot

2 MGIT
CHAPTER 2: MICROCONTROLLER

2.1 Description:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller
with 8Kbytes of in-system programmable Flash memory. The device is manufactured
using Atmel’s high-density nonvolatile memory technology and is compatible with
the industry standard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. 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 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 interrupt or
hardware reset.

2.1.1 Features of Microcontroller (AT89S52):

• Compatible with MCS-51 Products


• 8 Kbytes of In-System Reprogrammable Flash Memory
• Endurance: 1,000 Write/Erase Cycles
• 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
• Full duplex UART serial channel
• Low Power Idle and Power-down modes
• Dual data pointer
• Power-off flag

3 MGIT
• On chip Oscillator

2.2 Block Diagram of Microcontroller

Figure 2.1 Block Diagram of AT89S52

4 MGIT
2.3 Pin Configurations:

A
T
8
9
S
5
2

Figure 2.2 Pin Diagram of AT89S52

2.3.1 Pin Description:

• VCC
Pin 40 provides Supply voltage to the chip. The voltage source is +5v

• GND.
Pin 20 is the grounded

5 MGIT
• Port 0

Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. 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 high-impedance inputs. Port 0 may also be configured to be the
multiplexed low-order address/data bus during accesses to external program and data
memory. In this mode P0 has internal pull-ups.

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 from pin 1 to 8.
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 following table.

Port 1 also receives the low-order address bytes during Flash programming
and program verification.

• Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to
28. The Port 2 output buffers can sink / source four TTL inputs. When 1s are written

6 MGIT
to Port 2 pins they are pulled high by the internal pull-ups 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 pull-ups.

Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application it uses strong internal pull-ups when emitting
1s. During accesses to external data memory that uses 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 pull-ups from pin 10 to
17. 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 pull-ups and can be used
as inputs. As inputs, Port 3 pins that are externally being pulled low will source
current (IIL) because of the pull-ups.

Port 3 also serves the functions of various special features of the AT89S52 as
listed below:

Table 2.1 Special Features of port3

Port 3 also receives some control signals for Flash programming and
programming verification.

7 MGIT
• RST
Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all activities. A high on this pin for two
machine cycles while the oscillator is running resets the device.

• ALE/PROG
Address Latch is an output pin and is active high. Address Latch Enable 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 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.

• 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
when 12-volt programming is selected.

8 MGIT
• XTAL1

Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.

• XTAL2

Output from the inverting oscillator amplifier.

2.3.2 Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on chip oscillator, as shown in Figure
5.3. Either a quartz crystal or ceramic resonator may be used. To drive the device
from an external clock source, XTAL2 should be left unconnected while XTAL1 is
driven as shown in Figure 5.4.

Figure 2.3a crystal connections Figure 2.4b External Clock Drive


Configuration

There are no requirements on the duty cycle of the external clock signal, since
the input to the internal clocking circuitry is through a divide-by two flip-flop, but
minimum and maximum voltage high and low time specifications must be observed.

2.3.3 Idle Mode

In idle mode, the CPU puts itself to sleep while all the on-chip peripherals
remain active. The mode is invoked by software. The content of the on-chip RAM and
all the special functions registers remain unchanged during this mode. The idle mode
can be terminated by any enabled interrupt or by a hardware reset. It should be noted
that when idle is terminated by a hardware reset, the device normally resumes
9 MGIT
program execution, from where it left off, up to two machine cycles before the
internal reset algorithm takes control.

On-chip hardware inhibits access to internal RAM in this event, but access to
the port pins is not inhibited. To eliminate the possibility of an unexpected write to a
port pin when Idle is terminated by reset, the instruction following the one that
invokes Idle should not be one that writes to a port pin or to external memory.

2.3.4 Power down Mode

In the power down mode the oscillator is stopped, and the instruction that
invokes power down is the last instruction executed. The on-chip RAM and Special
Function Registers retain their values until the power down mode is terminated. The
only exit from power down is a hardware reset. Reset redefines the SFRs but does not
change the on-chip RAM. The reset should not be activated before VCC is restored to
its normal operating level and must be held active long enough to allow the oscillator
to restart and stabilize.

Table 2.2 Status of External Pins During Idle and Power Down Mode

2.3.5 Program Memory Lock Bits

On the chip are three lock bits which can be left unprogrammed (U) or can be
programmed (P) to obtain the additional features listed in the table 5.4. When lock bit
1 is programmed, the logic level at the EA pin is sampled and latched during reset. If
the device is powered up without a reset, the latch initializes to a random value, and
holds that value until reset is activated. It is necessary that the latched value of EA be
in agreement with the current logic level at that pin in order for the device to function
properly.

10 MGIT
Table 2.3 Lock Bit Protection Modes

2.4 TIMERS

• Timer 0 and 1

Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and
Timer 1 in the AT89C51.

Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit counter registers for
timer/counters 0 and 1.

• Timer 2

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event


counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2
has three operating modes: capture, auto-reload (up or down counting), and baud rate
generator. The modes are selected by bits in T2CON, as shown in Table 5.2. Timer 2
consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register
is incremented every machine cycle. Since a machine cycle consists of 12 oscillator
periods, the count rate is 1/12 of the oscillator frequency.

Table 2.4 Timer 2 Operating Modes

In the Counter function, the register is incremented in response to a 1-to-0


transition at its corresponding external input pin, T2. In this function, the external
input is sampled during S5P2 of every machine cycle. When the samples show a high
in one cycle and a low in the next cycle, the count is incremented. The new count

11 MGIT
value appears in the register during S3P1 of the cycle following the one in which the
transition was detected. Since two machine cycles (24 oscillator periods) are required
to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator
frequency. To ensure that a given level is sampled at least once before it changes, the
level should be held for at least one full machine cycle.

There are no restrictions on the duty cycle of external input signal, but it
should for at least one full machine to ensure that a given level is sampled at least
once before it changes.

2.4.1 Capture Mode


In the capture mode, two options are selected by bit EXEN2 in T2CON. If
EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in
T2CON.This bit can then be used to generate an interrupt. IfEXEN2 = 1, Timer 2
performs the same operation, but a 1-to-0 transition at external input T2EX also
causes the current value in TH2 and TL2 to be captured into RCAP2H andRCAP2L,
respectively. In addition, the transition at T2EXcauses bit EXF2 in T2CON to be set.
The EXF2 bit, likeTF2, can generate an interrupt.

2.4.2 Auto-reload (Up or Down Counter)


Timer 2 can be programmed to count up or down when configured in its 16-bit
auto-reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit
located in the SFR T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that
timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down,
depending on the value of the T2EX pin.

12 MGIT
Table2.5: T2MOD-Timer 2 Mode Control Register

13 MGIT
Table2.6: T2CON-Timer/Counter2 Control Register

2.5 Interrupts

The AT89S52 has a total of six interrupt vectors: two external interrupts
(INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port
interrupt. These interrupts are all shown in fig 2.5

14 MGIT
Figure 2.4 Interrupts source

Each of these interrupt sources can be individually enabled or disabled by


setting or clearing a bit in Special Function Register IE. IE also contains a global
disable bit, EA, which disables all interrupts at once.

Note that Table 5.3 shows that bit position IE.6 is unimplemented. In the
AT89C51, bit position IE.5 is also unimplemented. User software should not write 1s
to these bit positions, since they may be used in future AT89 products.

Table 2.7 Interrupts Enable Register

15 MGIT
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in
register T2CON. Neither of these flags is cleared by hardware when the service
routine is vectored to. In fact, the service routine may have to determine whether it
was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in
software.

The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in
which the timers overflow. The values are then polled by the circuitry in the next
cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle
in which the timer overflows.

2.6 Special function registers:

Special function registers are the areas of memory that control specific
functionality of the 89S52 microcontroller.

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 register (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 products gets stored in B register. In DIV AB the quotient gets stored in B
with the remainder in A.

c) Stack pointer (081h)

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 stores the value of SP and then stores 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 (Data pointer low/high, address 82/83h)

16 MGIT
The SFRs DPL and DPH 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 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 8052’s power control modes.
Certain operation modes of the 8052 allow the 8052 to go into a type of “sleep mode”
which consumes low power.

SMOD ---- --- ---- GF1 GF0 PD IDL


g)TCON(Timer
control, 88h)

The timer mode control SFR is used to configure and modify the way in which
the 8052’s 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 bits are located in TCON SER. These bits are
used to configure the way in which the external interrupt flags are activated, which
are set when an external interrupt occur.

TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

17 MGIT
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 SR 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.

‌ ‌

Gate C/ T M1 M0 Gate C/ T M1 M0

TIMER1 TIMER0

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

These two SFRs 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 value.

j) T1 (Timer 1 low/ high, address 8B/ 8D h)

These two SFRs together represent timer 1. 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.

k) P0 (Port 0, address 80h, bit addressable)

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.

18 MGIT
l) P1(Port 1, address 90h, bit addressable)

This is port 1 latch. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 1 is first written on P1 register. For
e.g., bit 0 of port 1 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 port 2 latch. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 2 is first written on P2 register. For
e.g., bit 0 of port 2 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 0B0h, bit addressable)

This is port 3 latch. Each bit of this SFR corresponds to one of the pins on a
micro controller. Any data to be outputted to port 3 is first written on P3 register. For
e.g., bit 0 of port 3 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 0 all
interrupts are disabled regardless of whether an individual interrupt is enabled by
setting a lower bit.

___

EA ET2 ES ET1 EX1 ET0 EX0

p) IP (Interrupt Priority, 0B8h)

The interrupt priority SFR is used to specify the relative priority of each
interrupt. On 8052, an interrupt may be either low or high priority. An interrupt may
19 MGIT
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 no other interrupt will be able to interrupt the serial
interrupt routine since the serial interrupt routine has the highest priority.

___ ___

PT2 PS PT1 PX1 PT0 PX0

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.

CY AC F0 RS1 RS0 OV ---- P

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.

2.7 Memory Organization

The total memory of 89S52 system is logically divided in Program memory


and Data memory. Program memory stores the programs to be executed, while data
memory stores the data like intermediate results, variables and constants required for
the execution of the program. Program memory is invariably implemented using
EPROM, because it stores only program code which is to be executed and thus it need
not be written into. However, the data memory may be read from or written to and
thus it is implemented using RAM.

Further, the program memory and data memory both may be categorized as
on-chip (internal) and external memory, depending upon whether the memory
physically exists on the chip or it is externally interfaced. The 89S52 can address
20 MGIT
8Kbytes on-chip memory whose map starts from 0000H and ends at 1FFFH. It can
address 64Kbytes of external program memory under the control of PSEN (low)
signal.

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. That means the
upper 128bytes have the same addresses as the SFR space but are physically separate
from SFR space. When an instruction accesses an internal location above address
7FH, the address mode used in the instruction specifies whether the CPU accesses the
upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing
access SFR space. For example, the following direct addressing instruction accesses
the SFR at location 0A0H (which is P2).

MOV 0A0H, #data

Instructions that use indirect addressing access the upper128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H)

.MOV @R0, #data

Note that stack operations are examples of indirect addressing, so the upper 128 bytes
of data RAM are available as stack space.

21 MGIT
CHAPTER 3: REGULATED POWER SUPPLY

3.1 Description:

A variable regulated power supply, also called a variable bench power


supply, is one where you can continuously adjust the output voltage to your
requirements. Varying the output of the power supply is the recommended way to test
a project after having double checked parts placement against circuit drawings and the
parts placement guide. This type of regulation is ideal for having a simple variable
bench power supply. Actually this is quite important because one of the first projects
a hobbyist should undertake is the construction of a variable regulated power supply.
While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to have a
variable supply on hand, especially for testing. Most digital logic circuits and
processors need a 5 volt power supply. To use these parts we need to build ta
regulated 5 volt source. Usually you start with an unregulated power supply ranging
from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit
and the Microcontroller Beginner Kit.). To make a 5 volt power supply, we use a
LM7805 voltage regulator IC .

The LM7805 is simple to use. You simply connect the positive lead of your
unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin,
connect the negative lead to the Common pin and then when you turn on the power,
you get a 5 volt supply from the Output pin.

22 MGIT
3.1.1 Circuit Features:

• Brief description of operation: Gives out well regulated +5V output, output
current capability of 100 mA
• Circuit protection: Built-in overheating protection shuts down output when
regulator IC gets too hot
• Circuit complexity: Very simple and easy to build
• Circuit performance: Very stable +5V output voltage, reliable operation
• Availability of components: Easy to get, uses only very common basic
components
• Design testing: Based on datasheet example circuit, I have used this circuit
successfully as part of many electronics projects
• Applications: Part of electronics devices, small laboratory power supply
• Power supply voltage: Unregulated DC 8-18V power supply
• Power supply current: Needed output current + 5 mA
• Component costs: Few dollars for the electronics components + the input
transformer cost

3.2 Block Diagram:

Fig 3.1: components of a typical linear power supply

23 MGIT
Basic Power Supply Circuit Description:

Fig 3.2: Basic power supply circuit

Above is the circuit of a basic unregulated dc power supply. A bridge


rectifier D1 to D4 rectifies the ac from the transformer secondary, which may also be
a block rectifier such as WO4 or even four individual diodes such as 1N4004 types.
(See later re rectifier ratings).

The principal advantage of a bridge rectifier is you do not need a centre tap on
the secondary of the transformer. A further but significant advantage is that the ripple
frequency at the output is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes
filtering somewhat easier.

As a design example consider we wanted a small unregulated bench supply for


our projects. Here we will go for a voltage of about 12 - 13V at a maximum output
current (IL) of 500ma (0.5A). Maximum ripple will be 2.5% and load regulation is
5%.

Now the RMS secondary voltage (primary is whatever is consistent with your
area) for our power transformer T1 must be our desired output Vo PLUS the voltage
drops across D2 and D4 (2 * 0.7V) divided by 1.414.

This means that Vsec = [13V + 1.4V] / 1.414 which equals about 10.2V. Depending
on the VA rating of your transformer, the secondary voltage will vary considerably in
accordance with the applied load. The secondary voltage on a transformer advertised
as say 20VA will be much greater if the secondary is only lightly loaded.

24 MGIT
If we accept the 2.5% ripple as adequate for our purposes then at 13V this
becomes 13 * 0.025 = 0.325 Vrms. The peak to peak value is 2.828 times this value.
Vrip = 0.325V X 2.828 = 0.92 V and this value is required to calculate the value of
C1. Also required for this calculation is the time interval for charging pulses. If you
are on a 60Hz system it is 1/ (2 * 60) = 0.008333 which is 8.33 milliseconds. For a
50Hz system it is 0.01 sec or 10 milliseconds.

Remember the tolerance of the type of capacitor used here is very loose. The
important thing to be aware of is the voltage rating should be at least 13V X 1.414 or
18.33. Here you would use at least the standard 25V or higher (absolutely not
16V).With our rectifier diodes or bridge they should have a PIV rating of 2.828 times
the Vsec or at least 29V. Don't search for this rating because it doesn't exist. Use the
next highest standard or even higher. The current rating should be at least twice the
load current maximum i.e. 2 X 0.5A or 1A. A good type to use would be 1N4004,
1N4006 or 1N4008 types.

These are rated 1 Amp at 400PIV, 600PIV and 1000PIV respectively. Always
be on the lookout for the higher voltage ones when they are on special.

3.4 IC Voltage Regulators:

Voltage regulators comprise a class of widely used ICs. Regulator IC units


contain the circuitry for reference source, comparator amplifier, control device, and
overload protection all in a single IC. Although the internal construction of the IC is
somewhat different from that described for discrete voltage regulator circuits, the
external operation is much the same. IC units provide regulation of either a fixed
positive voltage, a fixed negative voltage, or an adjustably set voltage.

A power supply can be built using a transformer connected to the ac supply


line to step the ac voltage to desired amplitude, then rectifying that ac voltage,
filtering with a capacitor and RC filter, if desired, and finally regulating the dc voltage
using an IC regulator. The regulators can be selected for operation with load currents
from hundreds of mill amperes to tens of amperes, corresponding to power ratings
from mill watts to tens of watts.

25 MGIT
3.4.1 Three-Terminal Voltage Regulators:

Fixed Positive Voltage Regulators: IN


OUT
Vin Vout
78XX
C1 C2

GND

Fig shows the basic connection of a three-terminal voltage regulator IC to a


load. The fixed voltage regulator has an unregulated dc input voltage, Vin, applied to
one input terminal, a regulated output dc voltage, Vo, from a second terminal, with
the third terminal connected to ground. While the input voltage may vary over some
permissible voltage range, and the output load may vary over some acceptable range,
the output voltage remains constant within specified voltage variation limits. A table
of positive voltage regulated ICs is provided in table. For a selected regulator, IC
device specifications list a voltage range over which the input voltage can vary to
maintain a regulated output voltage over a range of load current. The specifications
also list the amount of output voltage change resulting from a change in load current
(load regulation) or in input voltage (line regulation).

Table 3.1: Positive Voltage Regulators in 7800 series

IC No. Output voltage(v) Maximum input


voltage(v)

7805 +5

7806 +6

7808 +8 35V

7810 +10

7812 +12

7815 +15 40V

7818 +18

7824 +24

26 MGIT
CHAPTER 4: RELAYS

4.1 Overview:

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 position and
they are double throw (changeover) switches.

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) can not 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 relay with 4 sets of changeover contacts are readily
available. 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

27 MGIT
relay.

The supplier's catalogue should show you the relay's connection. 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.

The relay’s switch connections usually contain COM, NC and NO.

COM = Common, always connect to this; it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

Connect to COM and NO if you want the switched circuit to be on when the relay
coil is on.

Connect to COM and NC if you want the switched circuit to be on when the relay coil
is off.

Most relays are SPDT or DPDT which are often described as "single pole change
over" (SPCO)

Or "double pole change over"(DPCO).

This is a Single Pole Double Throw relay. Current will flow between the
movable contact and one fixed contact when the coil is energized and between the
movable contact and the alternate fixed contact when the relay coil is energized. The
most commonly used relay in car audio, the Bosch relay, is a SPDT relay.

28 MGIT
This relay is a Double Pole Double Throw relay. It operates like the SPDT
relay but has twice as many contacts. There are two completely isolated sets of
contacts.

4.2 Relay Construction:

Relays are amazingly simple devices. There are four parts in every relay:

• Electromagnet
• Armature that can be attracted by the electromagnet
• Spring
• Set of electrical contacts

A relay consists of two separate and completely independent circuits. The


first is at the bottom and drives the electromagnet. In this circuit, a switch is
controlling power to the electromagnet. When the switch is on, the electromagnet is
on, and it attracts the armature. The armature is acting as a switch in the second
circuit. When the electromagnet is energized, the armature completes the second
circuit and the light is on. When the electromagnet is not energized, the spring pulls
the armature away and the circuit is not complete. In that case, the light is dark.

When you purchase relays, you generally have control over several variables:

29 MGIT
• The voltage and current that is needed to activate the armature
• The maximum voltage and current that can run through the armature and the
armature contacts
• The number of armatures (generally one or two)
• The number of contacts for the armature (generally one or two -- the relay
shown here has two, one of which is unused)
• Whether the contact (if only one contact is provided) is normally open (NO)
or normally closed (NC)

4.3 Relay Applications:

In general, the point of a relay is to use a small amount of power in the


electromagnet coming, say, from a small dashboard switch or a low-power electronic
circuit -- to move an armature that is able to switch a much larger amount of power.
For example, you might want the electromagnet to energize using 5 volts and 50
milliamps (250 mill watts), while the armature can support 120V AC at 2 amps (240
watts).

Relays are quite common in home appliances where there is an electronic


control turning on something like a motor or a light. They are also common in cars,
where the 12V supply voltage means that just about everything needs a large amount
of current. In later model cars, manufacturers have started combining relay panels into
the fuse box to make maintenance easier.

In places where a large amount of power needs to be switched, relays are often
cascaded. In this case, a small relay switches the power needed to drive a much larger
relay, and that second relay switches the power to drive the load.
Relays can also be used to implement Boolean logic.

30 MGIT
4.3.1 Advantages of Relay:

• Relays can switch AC and DC, transistors can only switch DC.
• Relays can switch high voltages, transistors cannot.
• Relays are a better choice for switching large currents (> 5A).
• Relays can switch many contacts at once.

CHAPTER 5: METAL DETECTOR


(Proximity Sensor)
A Proximity sensor can detect objects without physical contact. A proximity
sensor often emits an electromagnetic field or beam and look for changes in the field.
The object being sensed is often referred to as the proximity sensor's target. Different
proximity sensor targets demand different sensors. For example, a capacitive or
photoelectric sensor might be suitable for a plastic target; an inductive proximity
sensor requires a metal target.

In capacitive proximity sensors, the sensed object changes the dielectric


constant between two plates. A proximity sensor has a range, which is usually quoted
relative to water. Because changes in capacitance take a relatively long time to detect,
the upper switching range of a proximity sensor is about 50 Hz. The proximity sensor
is often found in bulk-handling machines, level detectors, and package detection. One
advantage of capacitive proximity sensors is that they are unaffected by dust or
opaque containers, allowing them to replace optical devices.

A typical capacitive proximity sensor has a 10-mm sensing range and is 30


mm in diameter. The proximity sensor incorporates a potentiometer to allow fine
tuning of the sensing range and can repetitively detect objects within 0.01 mm of the

31 MGIT
set point. Switching frequency is 10 Hz, and operating temperature range is -14 to
158°F. Conditioning the output of a proximity sensor has always been difficult.
Proximity sensor designers must confront linearity, hysteresis, excitation voltage
instability, and voltage offset.

A proximity sensor that measures current flow between the sensing electrode
and the target provides readouts in appropriate engineering units. Usually, one side of
the voltage source or oscillator connects to the sensing electrode, and the other side
connects through a current-measuring circuit to the target, which generally is a metal
part at earth or ground potential.

Probes used with a capacitive proximity sensor have either a flat disc or
rectangular sensing element surrounded by a guard electrode that provides electrical
isolation between the proximity sensor and its housing. The guard also ensures that
the lines of electrostatic field emanating from the probe are parallel and perpendicular
to the surface of the proximity sensor.

Capacitance proximity sensor systems can make measurements in 100 µsec


with resolutions to 10-7 in(0.001 micron). Probe diameters range from a few
thousandths of an inch to several feet for corresponding measurements ranging from
thousandths of an inch to several feet.

Proximity sensor selection depends on the material to be sensed. Proximity


sensor probes for sensing non-conducting surfaces or insulators vary slightly from
those for conducting surfaces. Non-conducting probe signals are also more difficult to
linearize.

As standoff distance decreases, required proximity sensor size decreases. But


if the ratio of sensor area to gap width is too small, signal current will be too weak to
measure accurately. A probe-to-target capacitance of about 0.25 pF corresponds to a
safe maximum standoff distance. This is the capacitance produced by a 1 sq-in. plate
spaced 1 in. from a large conducting surface. If plate area is 0.1 in 2 (0.33 in on a side),
then a 0.1-in. spacing produces the same capacitance, and so forth.

When measuring the distance to a conducting surface, proximity sensor tip


size should be small when compared to the conducting surface for maximum linearity
and accuracy. If the proximity sensor tip is approximately the same size as the

32 MGIT
measured surface, capacitance changes caused by gap-width variations are not
distinguishable from those caused by target surface-area changes between samples.
Therefore, the distance between the target surface edges and proximity sensor edges
should be at least three times the gap length.

If the target surface cannot extend beyond the probe-tip edges, then probe tip
dimensions may exceed those of the target surface. However, the measurement will be
affected somewhat by variations in part size. In general, if the target surface is large
and stationary, the largest proximity sensor possible is used. However, little is gained
by increasing probe size once the proximity sensor capacitance exceeds 1 pF.

In addition to round and square probe shapes, a variety of configurations are


available for specific tasks. For example, if required resolution for a moving target
surface is finer in one direction of motion than that for a direction normal to the first,
then a rectangular probe can be used. Here, the narrow dimension is aligned in the
direction requiring the best resolution. This technique is used to measure radial wave
crests on a rotating disc, or radial and axial edge run-out of hollow cylindrical objects.

For measuring internal conical surfaces, a proximity sensor is often mounted


inside cone-shaped probes. This is useful for measuring valve-seat run-out. A probe
array can measure surface flatness. Here, each probe is electronically zeroed against a
known flat surface. A proximity sensor automatically scans the outputs of probes,
indicating average deviation from standard, the highest and lowest deviation from the
average, and the difference between them.

Capacitive proximity sensor AECO

33 MGIT
These are electronic transducers which provide an output signal when any type of
material (Wood, metal plastic, granular and powder product) comes into their sensing
area without coming into contact.

• Cylindrical series 18 - 30 - 40 mm dia.


• Totally screened and partially screened version
• Adjustable sensing distance
• Amplified 4 wire types NPN or PNP, NO+NC from 10 ÷ 55 Vdc
• Amplified 2 wire types from 20 ÷ 250 Vac/dc
• Relay output type with 1 pole changeover 1A ÷ 220 Vac
• Supply voltage 18 ÷ 50 Vdc / 18 ÷ 240 Vac
• Led incorporated
• Short circuit protection for D.C. and A.C. versions
• Maximum output current D.C. 200 mA, AC. 300 mA
• Types with connector output
• Types with instantaneous intervention or timing up to 15 min
• Protection housing in HOSTAFORM if used as level control

CHAPTER 6: SOFTWARE

6.1 KEIL SOFTWARE DESCRIPTION:

1. Click on the Keil uVision Icon on Desktop


2. The following fig will appear

34 MGIT
3. Click on the Project menu from the title bar
4. Then Click on New Project

5. Save the Project by typing suitable project name with no extension in u r


own folder sited in either C:\ or D:\

6. Then Click on save button above.


35 MGIT
7. Select the component for your project i.e. Atmel……
8. Click on the + Symbol beside of Atmel

9. Select AT89S52 as shown below

10. Then Click on “OK”


11. The Following fig will appear

36 MGIT
12. Then Click either YES or NO………mostly “NO”
13. Now your project is ready to USE

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

37 MGIT
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.

38 MGIT
17. Now start writing program in either in “C” or “ASM”
18. For a program written in Assembly, then save it with extension “. asm”
and for “C” based program save it with extension “ .C”

39 MGIT
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.

40 MGIT
21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error if so happens will
appear.

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


25. The new window is as follows and click “OK”.

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

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

42 MGIT
28. Now keep Pressing function key “F11” slowly and observe the running of
the program successfully

6.2 SOURCE CODING:

#include<reg51.h>
//PORT 2

sbit L_MOTORFORWARD=P1^0;

sbit L_MOTORBACKWARD=P1^1;

sbit R_MOTORFORWARD=P1^6;

sbit R_MOTORBACKWARD=P1^7;

sbit METAL=P2^0;

sbit buzzer=P0^7;

sbit start=P0^0;

sbit stop=P0^1;
43 MGIT
main()

L_MOTORFORWARD=0;

L_MOTORBACKWARD=0;

R_MOTORFORWARD=0;

R_MOTORBACKWARD=0;

while(1)

if(stop==1)

L_MOTORFORWARD=0;

L_MOTORBACKWARD=0;

R_MOTORFORWARD=0;

R_MOTORBACKWARD=0;

if(start==1)

if(METAL==1)

buzzer=0;

L_MOTORFORWARD=0;

L_MOTORBACKWARD=0;

R_MOTORFORWARD=0;

R_MOTORBACKWARD=0;

else

buzzer=1;

44 MGIT
L_MOTORFORWARD=0;

R_MOTORBACKWARD=0;

L_MOTORFORWARD=1;

R_MOTORFORWARD=1;

} //if (flag)

} //while

} //main

7. INTERFACING
7.1 Interfacing ULN2003* and relays:

Fig7.1: Interfacing ULN2003 and relays

7.2 Interfacing Metal detector and Microcontroller:


45 MGIT
P1.0,P1.1 & P1.6,P1.7 to
ULN
d
rivers

Fig 7.2: Interfacing Metal detector and Microcontroller

*See appendix for information about ULN2003.

7.3 Working:
• A +5V voltage is supplied to the microcontroller board and +12V to the
relays from the power supply unit.

CE Amp
• A reset switch is provided for the microcontroller connecting the 9th pin
which resets the ports.

• A crystal oscillator is connected between 18th and 19th pins of


microcontroller for the generation of clock signals.

• An ON/OFF switch is provided which sends a start signal (when pressed)


to P0.0 and stop signal (when pressed) to P0.1.

• The metal detector input pin is connected to variable resistor and from
variable resistor to the microcontroller port P2.0 through CE amplifier.

• The ports P1.0, P1.1 and P1.6, P1.7 are connected to the ULN driver s and the
output of ULN drivers to the relays.
46 MGIT
• The motors used are Helical Gear Motors providing 60RPM which are
fixed to the wooden board.

Whenever a metal is detected, the metal detector generates an input signal to


the microcontroller at P2.0 which in turn disables the ports P1.6 and P1.7 which connects
to ULN drivers. This results in the stopping of motors and a buzzer is turned ON.

CHAPTER 8: CONCLUSION AND FUTURE SCOPE

CONCLUSION:

Embedded systems are emerging as a technology with high potential. The last
decade witnessed the revolution of Microcontroller based embedded systems. This
project deals with the detection of mines with the help of Metal Detector and
Microcontroller. The risks involved in the manual detection of mines can be avoided
using this “Metal Detecting Robot”.

FUTURE SCOPE

This system is a rapidly growing field and there are new and improved
strategies popping up all the time. The range of the robot can be increased trough RF
or GSM operation. The robot can be fitted with a camera to monitor the operation,
and the location of the mine can be viewed from a distant place. It can also be used
for surveillance purposes.

47 MGIT
This system is best for detection in the warzones where the probability
of mines is high and the manual detection becomes risky. The number of sensors can
be increased and also multiple varieties of sensors such as smoke sensors etc can be
fitted to increase its versatility.

The addition of the above discussed advancements certainly builds this


project into a much flexible and reliable security system.

REFERENCES

BOOKS:

[1]. Mr. Mazidi, “The 8051 Microcontroller and Embedded Systems”, PHI, 2000

[2]. Mr. A.V. Deshmuk, “Microcontrollers (Theory & Applications)”, WTMH, 2005

[3]. Mr. Daniel W Lewis , “Fundamentals of Embedded Software.”

WEB SITES:

[1]. http://electronics.howstuffworks.com/gadgets/other-gadgets/metal-detector.htm

[2]. http://www.atmel.com/dyn/resources/prod_documents/doc1919.pdf

[3]. http://www.societyofrobots.com/microcontroller_tutorial.shtml

48 MGIT
APPENDIX A

ULN 2003

Description:

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 ULN2003 is a monolithic high voltage and high current Darlington


transistor arrays. It consists of seven NPN Darlington pairs that feature high-voltage
outputs with common-cathode clamp diode for switching inductive loads. The
collector-current rating of a single Darlington pair is 500mA. The Darlington pairs

49 MGIT
may be paralleled for higher current capability. Applications include relay drivers,
hammer drivers, lamp drivers, display drivers (LED gas discharge), line drivers, and
logic buffers. The ULN2003 has a 2.7kΩ series base resistor for each Darlington pair
for operation directly with TTL or 5V CMOS devices.

Features:

• 500mA rated collector current(Single output)

• High-voltage outputs: 50V

• Inputs compatible with various types of logic.

• Relay driver application

50 MGIT

You might also like