Wireless Spy Robot With Bject Detection

117
WIRELESS SPY ROBOT WITH OBJECT DETECTION B SACHIN VINAY REDDY CH CHANDRAMOULI VINJAM Department of Electronics and Communication Engineering MAHATMA GANDHI INSTITUTE OF TECHNOLOGY (Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Transcript of Wireless Spy Robot With Bject Detection

Page 1: Wireless Spy Robot With Bject Detection

WIRELESS SPY ROBOT WITH OBJECT DETECTION

B SACHINVINAY REDDY CH

CHANDRAMOULI VINJAM

Department of Electronics and Communication Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY (Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad – 500 075

2010

Page 2: Wireless Spy Robot With Bject Detection

WIRELESS SPY ROBOT WITH OBJECT DETECTION

PROJECT REPORT

SUBMITTED IN PARTIAL FULFILLMENT

OF THE REQUIREMENTS FOR THE DEGREE OF

BACHELOR OF TECHNOLOGYIN

ELECTRONICS AND COMMUNICATION ENGINEERING

BY

B SACHIN (06261A0468) VINAY REDDY CH (06261A04B8)

CHANDRAMOULI VINJAM (06N61A0411)

Department of Electronics and Communication Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad – 500 075

2010

Page 3: Wireless Spy Robot With Bject Detection

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad-500 075

Department of Electronics and Communication Engineering

CERTIFICATE

Date: 24 April 2007 Date: 7 May 2010

This is to certify that the project work entitled “Wireless Spy Robot with Object Detection” is a bonafide work carried out by

B SACHIN (06261A0468)VINAY REDDY CH (06261A04B8) CHANDRAMOULI VINJAM (06N61A0411)

in partial fulfillment of the requirements for the degree of BACHELOR OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING by the Jawaharlal Nehru Technological University, Hyderabad during the academic year 2009-10.

The results embodied in this report have not been submitted to any other University or Institution for the award of any degree or diploma.

Page 4: Wireless Spy Robot With Bject Detection

-------------------------- --------------------------

Mrs. P Nalini Dr. E Nagbhooshanam Assistant Professor Professor & Head

ACKNOWLEDGEMENTS

The satisfaction that accompanies the successful completion of task would be but

incomplete without mention of the people, who made it possible, whose constant guidance and

encouragement crown all efforts with success.

We are highly indebted to our Faculty Liaison Mrs.P Nalini, Assistant Professor,

Electronics and Communication Engineering Department, who has given us all the necessary

technical guidance in carrying out this Project.

We wish to express our sincere thanks to Dr.E.Nagabhooshanam, Head of the

Department of Electronics and Communication Engineering, M.G.I.T., for permitting us to

pursue our Project in college and encouraging us throughout the Project.

Finally, we thank all the people who have directly or indirectly help us through the

course of our Project.

Page 5: Wireless Spy Robot With Bject Detection

B SACHIN VINAY REDDY CH CHANDRAMOULI VINJAM

Abstract

The main aim of the project is to detect an object with the help of an IR camera

even in the night

Now-a-days spying the enemies is very difficult for the soldiers because it is life

risky process. So for that we have to use the present technology in spying enemies without loss

of soldier’s lives.

The project is basically used to detect an object by using a wireless robot with a

night vision camera. This project uses a RF AV camera as a image sensing device. The video

from camera is taken by the pc via TV tuner card. The AV camera can be converted which is

converted into an IR camera by removing the IR filter, which has a wide range of applications

such as detecting the object in darkness with the help of IR illumination. The AV camera is

mounted on the wireless robot. The robot is controlled through PC. The video sent by the AV

camera is can be viewed on the monitor. The video sent by the AV camera is sampled and the

sampled image is processed through a MATLAB program to detect a object with gray levels in a

certain range. If an Object with the gray levels in the range will be detected.

The entire robot is constructed using the P89V51RD2BN Microcontroller, RF

transmitter and receiver, wireless AV camera, four DC gear motors, HT640 and HT648L

encoder decoder pair. Software programming for object detection is done in Matlab, while

microcontroller programming and dumping is done in Keil, Flash Magic software respectively.

Page 6: Wireless Spy Robot With Bject Detection

Table of Contents

Page No

CERTIFICATE FROM ECE DEPARTMENT i

ACKNOWLEDGEMENTS ii

ABSTRACT iii

LIST OF FIGURES vi

LIST OF TABLES viii

1. OVERVIEW

1.1 Introduction 1

1.2 Aim of the project 1

1.3 Methodology 1

1.4 Significance of the work 2

1.5 Organization of the Report 3

2. MICROCONTROLLER AND OTHER HARDWARE

2.1 Introduction 4

2.2 P89V51RD2BN MICROCONTROLLER

2.2.1 General description 5

2.2.2 Features 6

2.2.3 Block diagram 7

2.2.4 Pin description 8

2.2.5 Memory organization 12

2.3 ENCODER AND DECODER

2. 3.1 HT640 Encoder 19

2. 3.2 HT648L Decoder 22

Page 7: Wireless Spy Robot With Bject Detection

2.4 RF MODULES

2.4.1 ST-TX01-A434 Transmitter 26

2.4.2 ST-RX04-A434 Receiver 28

2.5. MAX232 29

2.6 ULN2803 32

2.7 RELAYS 34

2.8 DC MOTOR 38

2.9 REGULATOR 41

2.10 WIRELESS CAMERA 44

3. SOFTWARE DETAILS

3.1 Keil Software 48

3.2 Flash Magic 51

3.3 MATLAB 57

4. IMAGE PROCESSING USING MATLAB

4.1 Image Processing Toolbox 59

4.2 Image Acquisition with Wireless Camera 59

5. SOURCE CODE

5.1Microcontroller Code for Bot Control 70

5.2 MATLAB code 70

6. CONCLUSIONS AND FUTURE SCOPE 73

BIBLIOGRAPHY 74

Page 8: Wireless Spy Robot With Bject Detection

LIST OF FIGURES

2.1 Circuit Diagram of Transmitter Section 4

2.2 Circuit Diagram of Receiver Section 5

2.3 Block diagram of 89V51RD2BN 7

2.4 Pin diagram of 89V51RD2BN 8

2.5 Internal and external data memory Structure 16

2.6 Dual data pointer organization 17

2.7 Pin Diagram of HT640 Encoder 20

2.8 Flow Chart of Encoder 22

2.9 Pin Diagram of HT648L Decoder 24

2.10 Flow Chart of Decoder 26

2.11 Image and Block Diagram of ST-TX01-ASK Transmitter 27

2.12 Image and Block Diagram of ST-RX04-ASK Receiver 29

2.13 MAX 232 PIN DIAGRAM 30

2.14 Connection of Max232 to Pc 32

2.15 ULN pin connection and block diagram 33

2.16 Relay diagram 35

2.17 SPDT & DPDT Relay diagram 36

2.18 DC motor 39

2.19 Conceptual 3-pole dc motor 40

2.20 Pin Diagram of Regulator 42

Page 9: Wireless Spy Robot With Bject Detection

2.21 Pin connection of IC regulator 43

2.22 AV Transmitter circuit diagram 45

2.23 AV Receiver circuit diagram 46

Page 10: Wireless Spy Robot With Bject Detection

LIST OF TABLES

2.1 Pin Description of HT640…………………………………………………….. 21

2.2 Pin Description of HT648L………………………………………………….. 24

2.3 Positive Voltage Regulators in 7800 series………………………………….. 44

2.4 Specifications of RF-AV wireless cam ……………………………………... 47

Page 11: Wireless Spy Robot With Bject Detection

CHAPTER 1

OVERVIEW

1.1 Introduction:

Now-a-days tracing and attacking enemies at different areas are very much

difficult for the soldiers. There may be a chance for lost of lives of the soldiers during war and

emergency situations.

We have implemented a solution for the problem of replacing a soldier with a

Robo Soldier completely controlled with a wireless network. The project is to detect an object

that is located at some distance with a night vision camera. As the life of a soldier is very

valuable, a real soldier can be replaced by an artificial robotic soldier and perform few activities

that can be achievable by an artificial robot. In this way instead of risking the life of a soldier for

everything we can avoid few situations where an activity can be performed without a real soldier.

So this is something like automation in the war field with maximum usage of present

technological aspects with minimum loss.

1.2 Aim of the project:

The project is basically used to detect an object by using a wireless robot with a night

vision camera. This project uses a RF webcam which is converted into an IR camera, which has

a wide range of applications such as detecting the object in darkness with the help of IR

illumination. The IR camera is mounted on the wireless robot. The robot is controlled through

PC. The video sent by the IR camera can be viewed on the monitor. The video sent by the IR

camera is sampled and the sampled image is processed through a MATLAB program. This

program helps in object detection.

1.3 Methodology:

The project begins by programming the microcontroller for serial communication

with pc using RS232 interface. The data sent to the microcontroller through the terminal window

Page 12: Wireless Spy Robot With Bject Detection

of Flash Magic software. This data present in the ASCII format is specifically sent to port-2 of

the controller. Port-2 is connected to HT640 encoder whose purpose is to convert parallel data

from the controller into serial data of the RF transmitter. The antenna in the transmitter section

transmits the data to the receiver using ASK modulation technique operating at 434MHz

frequency.

The receiver receives the data and decodes the information received using

HT648L decoder. The decoded data is sent to the ULN2803 which is an 18 pin chip of eight

Darlington arrays which is used to drive the relays. DPDT relays are used to control the dc motor

which controls the motion of bot.

Wireless camera used for object detection is mounted on the bot. It is a wireless

audio and video (AV) camera using 1.2GHz RF communication range. Camera receiver is

connected to the pc by a TV tuner card. The video stream is imported into the Matlab using

“winvideo” command. The acquired video is sampled and further processed for object detection.

The Matlab code uses the RGB thresholds for detecting the object.

1.4 Significance of the work:

The word robot can refer to both physical robots and virtual software agents, but the latter

are usually referred to as bots. There is no consensus on which machines qualify as robots, but

there is general agreement among experts and the public that robots tend to do some or all of the

following: move around, operate a mechanical limb, sense and manipulate their environment,

and exhibit intelligent behavior, especially behavior which mimics humans or other animals.

Controlled by computer locally, the owner can move the robot to various locations within

range of the RF transmitter, take pictures and video, and listen to surroundings with the on-board

microphone.

Page 13: Wireless Spy Robot With Bject Detection

1.5 Organization of the Report:

The chapters are arranged in the following manner

Chapter 1 deals with introduction, aim of the project, methodology, significance of work,

organization of the project.

Chapter 2 discusses about the introduction to Microcontroller and other hardware units along

with their features that have been used in the project with complete circuit description and

necessary block diagrams and pin diagrams.

Chapter 3 explains in detail about the software used like Keil, Flash Magic and Matlab.

Chapter 4 shows the experimental results of image acquisition that is done in Matlab with

necessary functions that have been used for object detection.

Chapter 5 gives the source code of assembly code for bot control and Matlab code for object

detection.

Chapter 6 concludes the project by showing the results obtained from the execution of the

above code and implementation of wireless spy robot along with its future scope and the

references used are listed.

Page 14: Wireless Spy Robot With Bject Detection

CHAPTER 2

MICROCONTROLLER AND OTHER HARDWARE

2.1 INTRODUCTION:

The microcontroller generic part number actually includes a whole family of

microcontrollers that have numbers ranging from 8031 to 8751, where P89V51RD2 is one

among the above family used in the project. The other hardware components utilized are as

follows:

Hardware components:

1. HT 640 encoder and HT648 decoder

2. ULN 2803

3. MAX 232

4. LM7805 Voltage Regulator

5. Relays

6. RF module

7. Wireless webcam

Circuit Diagram:

Fig2.1: Block Diagram of Transmission Section

Page 15: Wireless Spy Robot With Bject Detection

Fig2.2: Block diagram of Receiver Section

2.2 P89V51RD2BN Microcontroller

2.2.1 General description

The P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1024 bytes of data RAM.

A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run

the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select

the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock

frequency. Another way to benefit from this feature is to keep the same performance by reducing

the clock frequency by half, thus dramatically reducing the EMI. The Flash program memory

supports both parallel programming and in serial In-System Programming (ISP). Parallel

programming mode offers gang-programming at high speed, reducing programming costs and

time to market. ISP allows a device to be reprogrammed in the end product under software

control. The capability to field/update the application firmware makes a wide range of

applications possible. The P89V51RD2 is also In-Application Programmable (IAP), allowing the

Flash program memory to be reconfigured even while the application is running.

Page 16: Wireless Spy Robot With Bject Detection

Basic difference between microcontroller and microprocessor:

A microprocessor system consists of a microprocessor with memory, input ports and

output ports connected to it externally. A microcontroller is a single chip containing a

microprocessor, memory, input ports and output ports. Since all four blocks reside on the one

chip, a microcontroller is much faster than a microprocessor system.

2.2.2 Features

80C51 Central Processing Unit

5 V Operating voltage from 0 to 40 MHz

64 kB of on-chip Flash program memory with ISP (In-System Programming) and

AP (In-Application Programming)

Supports 12-clock (default) or 6-clock mode selection via software or ISP

SPI (Serial Peripheral Interface) and enhanced UART

PCA (Programmable Counter Array) with PWM and Capture/Compare functions

Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)

Three 16-bit timers/counters

Programmable Watchdog timer (WDT)

Eight interrupt sources with four priority levels

Second DPTR register

Low EMI mode (ALE inhibit)

TTL- and CMOS-compatible logic levels

Brown-out detection

Low power modes

Power-down mode with external interrupt wake-up Idle mode

PDIP40, PLCC44 and TQFP44 packages

Page 17: Wireless Spy Robot With Bject Detection

MEMORY:

We can split memory into two types. RAM and ROM. RAM stands for random access

memory. They are two features of RAM which distinguish it from ROM. RAM is read/write

- data can be written to and read from RAM. RAM is volatile - data is lost once the power to

a RAM chip is lost.

Random access refers to the fact that data from any location in the memory chip is

accessible at any time (you simply put the desired address on the address bus). ROM stands

for read only memory. As with RAM, it is random access but it differs from RAM in two

ways. ROM, as the name suggests, is read only. You cannot write to a ROM chip. A ROM

chip must be programmed, but once programmed, it cannot be (easily) changed ROM is non-

volatile - when power is removed from the chip data is not lost. There are many types of

ROM available; PROM, EPROM, EEPROM and Flash are the most common.

2.2.3 BLOCK DIAGRAM:

Fig 2.3 Block diagram of P89V51RD2BN

Page 18: Wireless Spy Robot With Bject Detection

2.2.4 PIN DESCRIPTION:

Fig 2.4 Pin diagram of P89V51RD2BN

Page 19: Wireless Spy Robot With Bject Detection

Port0:

P0.0 to P0.7- Pins 39-32

Port 0 is an 8-bit open drain bi-directional I/O port. Port 0 pins that have ‘1’s

written to them float and in this state can be used as high-impedance inputs. Port 0 is also the

multiplexed low-order address and data bus during accesses to external code and data memory.

In this application, it uses strong internal pull-ups when transitioning to ‘1’s. Port 0 also receives

the code bytes during the external host mode programming, and outputs the code bytes during

the external host mode verification. External pull-ups are required during program verification or

as a general purpose I/O port.

Port 1:

P1.0 to P1.7-Pins 1-8

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 pins

are pulled high by the internal pull-ups when ‘1’s are written to them and can be used as inputs

in this state. As inputs, Port 1 pins that are externally pulled LOW will source current (IIL)

because of the internal pull-ups. P1.5, P1.6, P1.7 have high current drive of 16 mA. Port 1 also

receives the low-order address bytes during the external host mode programming and

verification.

P1.0 T2: External count input to Timer/Counter 2 or Clock-out from

Timer/Counter 2

P1.1 T2EX: Timer/Counter 2 capture/reload trigger and direction control P1.2 3 42

4 I ECI: External clock input. This signal is the external clock input for the PCA.

P1.3 CEX0: Capture/compare external I/O for PCA Module 0. Each

capture/compare module connects to a Port 1 pin for external I/O. When not used by the PCA,

this pin can handle standard I/O.

P1.4 SS: Slave port select input for SPI

CEX1: Capture/compare external I/O for PCA Module 1

P1.5 MOSI: Master Output Slave Input for SPI

CEX2: Capture/compare external I/O for PCA Module 2

P1.6 MISO: Master Input Slave Output for SPI

CEX3: Capture/compare external I/O for PCA Module 3

Page 20: Wireless Spy Robot With Bject Detection

P1.7 SCK: Master Output Slave Input for SPI

CEX4: Capture/compare external I/O for PCA Module 4

Port 2:

P2.0 to P2.7 pin 21-28

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 pins are pulled

HIGH by the internal pull-ups when ‘1’s are written to them and can be used as inputs in this

state. As inputs, Port 2 pins that are externally pulled LOW will source current (IIL) because of

the internal pull-ups. Port 2 sends the high-order address byte during fetches from external

program memory and during accesses to external Data Memory that use 16-bit address

(MOVX@DPTR). In this application, it uses strong internal pull-ups when transitioning to ‘1’s.

Port 2 also receives some control signals and a partial of high-order address bits during

the external host mode programming and verification.

Port 3:

P3.0 to P3.7 pin10-17

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. Port 3 pins are

pulled HIGH by the internal pull-ups when ‘1’s are written to them and can be used as inputs in

this state. As inputs, Port 3 pins that are externally pulled LOW will source current (IIL)

because of the internal pull-ups. Port 3 also receives some control signals and a partial of high-

order address bits during the external host mode programming and verification.

P3.0 RXD: serial input port

P3.1 TXD: serial output port

P3.2 INT0: external interrupt 0 input

P3.3 INT1: external interrupt 1 input

P3.4 T0: external count input to Timer/Counter 0

P3.5 T1: external count input to Timer/Counter 1

P3.6 WR: external data memory write strobe

P3.7 RD: external data memory read strobe

Page 21: Wireless Spy Robot With Bject Detection

PSEN Program Store Enable: PSEN is the read strobe for external program memory. When

the device is executing from internal program memory, PSEN is inactive (HIGH). When the

device 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. A forced HIGH-to-LOW input transition on the PSEN pin while the RST input is

continually held HIGH for more than 10 machine cycles will cause the device to enter

external host mode programming.

RST Reset: While the oscillator is running, a HIGH logic state on this pin for two machine

cycles will reset the device. If the PSEN pin is driven by a HIGH-to-LOW input transition while

the RST input pin is held HIGH, the device will enter the external host mode, otherwise the

device will enter the normal operation mode

EA External Access Enable: EA must be connected to VSS in order to enable the device to fetch

code from the external program memory. EA must be strapped to VDD for internal program

execution. However, Security lock level 4 will disable EA, and program execution is only

possible from internal program memory. The EA pin can tolerate a high voltage of 12 V.

ALE/PROG I/O Address Latch Enable: ALE is the output signal for latching the low byte of the

address during an access to external memory. This pin is also the programming pulse input

(PROG) for flash programming. Normally the ALE is emitted at a constant rate of 1¤6 the

crystal frequency and can be used for external timing and clocking. One ALE pulse is skipped

during each access to external data memory. However, if AO is set to ‘1’, ALE is disabled.

NC - No Connect

XTAL1 Crystal 1: Input to the inverting oscillator amplifier and input to the internal clock

generator circuits.

XTAL2 Crystal 2: Output from the inverting oscillator amplifier.

Page 22: Wireless Spy Robot With Bject Detection

VDD Power supply

VSS Ground

2.2.5 Memory organization:

The device has separate address spaces for program and data memory.

Flash program memory:

There are two internal flash memory blocks in the device. Block 0 has 64 kbytes and contains the

user’s code. Block 1 contains the Philips-provided ISP/IAP routines and may be enabled such

that it overlays the first 8 kbytes of the user code memory. The 64 kB Block 0 is organized as

512 sectors, each sector consists of 128 bytes. Access to the IAP routines may be enabled by

clearing the BSEL bit in the FCF register. However, caution must be taken when dynamically

changing the BSEL bit. Since this will cause different physical memory to be mapped to the

logical program address space, the user must avoid clearing the BSEL bit when executing user

code within the address range 0000H to 1FFFH.

Data RAM memory:

The data RAM has 1024 bytes of internal memory. The device can also address up to 64 kB for

external data memory.

Expanded data RAM addressing:

The P89V51RD2 has 1 kB of RAM

The device has four sections of internal data memory:

1. The lower 128 bytes of RAM (00H to 7FH) are directly and indirectly addressable.

2. The higher 128 bytes of RAM (80H to FFH) are indirectly addressable.

3. The special function registers (80H to FFH) are directly addressable only.

4. The expanded RAM of 768 bytes (00H to 2FFH) is indirectly addressable by the move

external instruction (MOVX) and clearing the EXTRAM bit.

Page 23: Wireless Spy Robot With Bject Detection

AUXR - Auxiliary register (address 8EH) bit allocation

Since the upper 128 bytes occupy the same addresses as the SFRs, the RAM must be accessed

indirectly. The RAM and SFRs space are physically separate even though they have the same

addresses. When instructions access addresses in the upper 128 bytes (above 7FH), the MCU

determines whether to access the SFRs or RAM by the type of instruction given. If it is indirect,

then RAM is accessed. If it is direct, then an SFR is accessed.

See the examples below.

Indirect Access:

MOV@R0, #data; R0 contains 90H

Register R0 points to 90H which is located in the upper address range. Data in ‘#data’ is written

to RAM location 90H rather than port 1.

Direct Access:

MOV90H, #data; write data to P1 Data in ‘#data’ is written to port 1. Instructions that write

directly to the address write to the SFRs. To access the expanded RAM, the EXTRAM bit must

be cleared and MOVX instructions must be used. The extra 768 bytes of memory is physically

located on the chip and logically occupies the first 768 bytes of external memory (addresses

000H to 2FFH). When EXTRAM = 0, the expanded RAM is indirectly addressed using the

MOVX instruction in combination with any of the registers R0, R1 of the selected bank or

DPTR. Accessing the expanded RAM does not affect ports P0, P3.6 (WR), P3.7 (RD), or P2.

With EXTRAM = 0, the expanded RAM can be accessed as in the following example.

Expanded RAM Access (Indirect Addressing only):

MOVX@DPTR, A DPTR contains 0A0H

DPTR points to 0A0H and data in ‘A’ is written to address 0A0H of the expanded RAM rather

than external memory. Access to external memory higher than 2FFH using the MOVX

instruction will access external memory (0300H to FFFFH) and will perform in the same way as

the standard 8051, with P0 and P2 as data/address bus, and P3.6 and P3.7 as write and read

timing signals.

Page 24: Wireless Spy Robot With Bject Detection

AUXR - Auxiliary register (address 8EH) bit description

EXTRAM Internal/External RAM access using MOVX @Ri/@DPTR. When ‘0’, core attempts

to access internal XRAM with address specified in MOVX instruction. If address supplied with

this instruction exceeds on-chip available XRAM, off-chip XRAM is going to be selected and

accessed. When ‘1’, every MOVX @Ri/@DPTR instruction targets external data memory by

default. AO ALE off: disables/enables ALE. AO = 0 results in ALE emitted at a constant rate of

1¤2 the oscillator frequency. In case of AO = 1, ALE is active only during a MOVX or MOVC.

When EXTRAM = 1, MOVX @Ri and MOVX @DPTR will be similar to the standard

8051. Using MOVX @Ri provides an 8-bit address with multiplexed data on Port 0. Other

output port pins can be used to output higher order address bits. This provides external paging

capabilities. Using MOVX @DPTR generates a 16-bit address. This allows external addressing

up the 64 kB. Port 2 provides the high-order eight address bits (DPH), and Port 0 multiplexes the

low order eight address bits (DPL) with data. Both MOVX @Ri and MOVX @DPTR generates

the necessary read and write signals (P3.6 - WR and P3.7 - RD) for external memory use. Below

shows external data memory RD, WR operation with EXTRAM bit. The stack pointer (SP) can

be located anywhere within the 256 bytes of internal RAM (lower 128 bytes and upper 128

bytes). The stack pointer may not be located in any part of the expanded RAM.Access limited to

ERAM ad

Page 25: Wireless Spy Robot With Bject Detection
Page 26: Wireless Spy Robot With Bject Detection

External data memory RD, WR with EXTRAM bit

Fig 2.5 Internal and external data memory structure.

Dual data pointers:

The device has two 16-bit data pointers. The DPTR Select (DPS) bit in AUXR1 determines

which of the two data pointers is accessed. When DPS = 0, DPTR0 is selected; when DPS = 1,

DPTR1 is selected. Quickly switching between the two data pointers can be accomplished by a

single INC instruction on AUXR1

Page 27: Wireless Spy Robot With Bject Detection

Fig 2.6 Dual data pointer organization.

AUXR1 - Auxiliary register 1 (address A2H) bit allocation

AUXR1 - Auxiliary register 1 (address A2H) bit description

Flash memory In-Application Programming

Flash organization

The P89V51RD2 program memory consists of a 64 kB block. An In-System Programming (ISP)

capability, in a second 8 kB block, is provided to allow the user code to be programmed in-

circuit through the serial port. There are three methods of erasing or programming of the Flash

memory that may be used. First, the Flash may be programmed or erased in the end-user

application by calling low-level routines through a common entry point (IAP). Second, the on-

chip ISP boot loader may be invoked. This ISP boot loader will, in turn, call low-level routines

through the same common entry point that can be used by the end-user application. Third, the

Flash may be programmed or erased using the parallel method by using a commercially available

EPROM programmer which supports this device.

Boot block

Page 28: Wireless Spy Robot With Bject Detection

When the microcontroller programs its own Flash memory, all of the low level details are

handled by code that is contained in a Boot block that is separate from the user Flash memory. A

user program calls the common entry point in the Boot block with appropriate parameters to

accomplish the desired operation. Boot block operations include erase user code, program user

code, program security bits, etc. A Chip-Erase operation can be performed using a commercially

available parallel programmer. This operation will erase the contents of this Boot Block and it

will be necessary for the user to reprogram this Boot Block (Block 1) with the Philips-provided

ISP/IAP code in order to use the ISP or IAP capabilities of this device.

Power-On reset code execution

Following reset, the P89V51RD2 will either enter the SoftICE mode (if previously enabled via

ISP command) or attempt to autobaud to the ISP boot loader. If this autobaud is not successful

within about 400 ms, the device will begin execution of the user code.

In-System Programming (ISP)

In-System Programming is performed without removing the microcontroller from the system.

The In-System Programming facility consists of a series of internal hardware resources coupled

with internal firmware to facilitate remote programming of the P89V51RD2 through the serial

port. This firmware is provided by Philips and embedded within each P89V51RD2 device. The

Philips In-System Programming facility has made in-circuit programming in an embedded

application possible with a minimum of additional expense in components and circuit board area.

The ISP function uses five pins (VDD, VSS, TxD, RxD, and RST). Only a small connector

needs to be available to interface your application to an external circuit in order to use this

Feature

.

Using the In-System Programming

The ISP feature allows for a wide range of baud rates to be used in your

application, independent of the oscillator frequency. It is also adaptable to a wide range of

oscillator frequencies. This is accomplished by measuring the bit-time of a single bit in a

received character. This information is then used to program the baud rate in terms of timer

counts based on the oscillator frequency. The ISP feature requires that an initial character (an

uppercase U) be sent to the P89V51RD2 to establish the baud rate. The ISP firmware provides

Page 29: Wireless Spy Robot With Bject Detection

auto-echo of received characters. Once baud rate initialization has been performed, the ISP

firmware will only accept Intel Hex-type records. Intel Hex records consist of ASCII characters

used to represent hexadecimal values and are summarized below:

:NNAAAARRDD..DDCC<crlf>

In the Intel Hex record, the ‘NN’ represents the number of data bytes in the record. The

P89V51RD2 will accept up to 32 data bytes. The ‘AAAA’ string represents the address of the

first byte in the record. If there are zero bytes in the record, this field is often set to 0000. The

‘RR’ string indicates the record type. A record type of ‘00’ is a data record. A record type of ‘01’

indicates the end-of-file mark. In this application, additional record types will be added to

indicate either commands or data for the ISP facility The maximum number of data bytes in a

record is limited to 32 (decimal). ISP commands are summarized in Table 10. As a record is

received by the P89V51RD2, the information in the record is stored internally and a checksum

calculation is performed. The operation indicated by the record type is not performed until the

entire record has been received. Should an error occur in the checksum, the P89V51RD2 will

send an ‘X’ out the serial port indicating a checksum error. If the checksum calculation is found

to match the checksum in the record, then the command will be executed. In most cases,

successful reception of the record will be indicated by transmitting a ‘.’ character out the serial

port.

Page 30: Wireless Spy Robot With Bject Detection

2.3 ENCODER AND DECODER:

2.3.1 HT640 ENCODER:

General Description

The HT640 encoder is a CMOS LSI for remote control system applications. It is capable of

encoding 18 bits of information which consists of 10 address bits and 8 data bits. Each

address/data input is externally trinary programmable if bonded out. It is otherwise set floating

internally. The programmable address/data is transmitted together with the header bits via an RF

or an infrared transmission medium upon receipt of a trigger signal.

Features

Operating voltage: 2.4V~12V

Low power and high noise immunity CMOS technology

Low standby current

Three words transmission

Built-in oscillator needs only 5% resistor

Easy interface with an RF or infrared transmission media

Minimal external components

Applications

Burglar alarm system

Smoke and fire alarm system

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control systems

Page 31: Wireless Spy Robot With Bject Detection

Fig 2.7 Pin Diagram of HT640 Encoder

Table 2.1: Pin Description of HT640

Functional Description

Operation

The HT640 encoder begins a three-word transmission cycle upon receipt of a transmission

enable

This cycle will repeat itself as long as the transmission enable (TE) is held high. Once the

transmission enable falls low, the encoder output completes its final cycle and then stops as

shown below.

Page 32: Wireless Spy Robot With Bject Detection

Information word

An information word consists of 4 periods as shown:

Fig 2.8 Flow Chart of Encoder

Page 33: Wireless Spy Robot With Bject Detection

2.3.2 HT648L DECODER:

General Description

The HT648L decoder is a CMOS LSIs for remote control system applications. It is

paired with the HT640 encoders. For proper operation a pair of encoder/decoder pair with the

same number of address and data format should be selected. The HT648L decoder receives serial

address and data from that series of encoders that are transmitted by a carrier using an RF or an

IR transmission medium. It then compares the serial input data twice continuously with its local

address. If no errors or unmatched codes are encountered, the input data codes are decoded and

then transferred to the output pins. The VT pin also goes high to indicate a valid transmission.

The HT648L is capable of decoding 18 bits of information that consists of 10 bits of address and

8 bits of data.

Features

Operating voltage: 2.4V~12V

Low power and high noise immunity CMOS technology

Low standby current

Capable of decoding 18 bits of information

Pairs with HOLTEK’s 318 series of encoders

8~18 address pins

0~8 data pins

Trinary address setting

Two times of receiving check

Built-in oscillator needs only a 5% resistor

Valid transmission indictor

Easily interface with an RF or an infrared transmission medium

Minimal external components

Applications

Burglar alarm system

Smoke and fire alarm system

Page 34: Wireless Spy Robot With Bject Detection

Garage door controllers

Car door controllers

Car alarm system

Security system

Cordless telephones

Other remote control systems

Pin diagram:-

Fig 2.9 Pin Diagram of HT648L Decoder

Pin description

Table 2.2: Pin Description of HT648L

Page 35: Wireless Spy Robot With Bject Detection

Functional Description

Operation

The HT648L decoder is paired with HT640 encoder. The decoder receives data

transmitted by the encoder and interprets the first 10 bits of the code period as address and the

last 8 bits as data. A signal on the DIN pin then activates the oscillator which in turns decodes

the incoming address and data. The decoder will check the received address twice continuously.

If all the received address codes match the contents of the decoder’s local address, the 8 bits of

data are decoded to activate the output pins, and the VT pin is set high to indicate a valid

transmission. That will last until the address code is incorrect or no signal has been received. The

output of the VT pin is high only when the transmission is valid. Otherwise it is low always.

Page 36: Wireless Spy Robot With Bject Detection

Decoder timing

Fig 2.10 Flow Chart of Decoder

Page 37: Wireless Spy Robot With Bject Detection

2. 4. RF MODULE:

2.4.1 ST-TX01-ASK Transmitter:

General Description:

This transmitter works based up on the ASK modulation. Amplitude-shift keying (ASK) is a

form of modulation that represents digital data as variations in the amplitude of a carrier wave.

The amplitude of an analog carrier signal varies in accordance with the bit stream (modulating

signal), keeping frequency and phase constant. The level of amplitude can be used to

represent binary logic 0s and 1s. We can think of a carrier signal as an ON or OFF switch. In the

modulated signal, logic 0 is represented by the absence of a carrier, thus giving OFF/ON keying

operation and hence the name given.

The ST-TX01-ASK is an ASK Hybrid transmitter module. ST-TX01-ASK is designed by the

Saw Resonator, with an effective low cost, small size, and simple-to-use for Frequency

Range: 315 / 433.92 MHZ.

Supply Voltage: 3~12V.

Output Power: 4~16dBm

Circuit Shape: Saw

Fig 2.11 Image and Block Diagram of ST-TX01-ASK Transmitter

Page 38: Wireless Spy Robot With Bject Detection

RF ASK Transmitter pin numbers

o Pin1. Antenna

o Pin2. Vcc

o Pin3. Data

o Pin4. GND

Applications

Wireless security systems

Car Alarm systems

Remote controls.

Sensor reporting

Automation systems

2.4.2 ST-RX04-ASK Receiver:

General Description:

The ST- RX04-ASK is an ASK super heterodyne receiver module with PLL synthesizer

and crystal oscillator. The circuit shape is PLL.

Receiver Frequency: 315 / 433.92 MHZ

Operation Voltage: 5V

IF Frequency: 500k

Typical sensitivity: -105dBm

Supply Current: 2.3mA

Features

Low power consumption.

Easy for application.

On-Chip VCO with integrated PLL using crystal oscillator reference.

Integrated IF and data filters.

Operation temperature range: -400C ~ -800C

Page 39: Wireless Spy Robot With Bject Detection

Operation voltage: 5 Volts.

Available frequency at: 315/434 MHz

The RX – ASK is an ASK Hybrid receiver module. It is a effective low cost solution for using

433 MHz. The TX-ASK is an ASK hybrid transmitter module. TX-ASK is designed by the saw

resonator, with an effective low cost, small size and simple to use for designing.

Fig 2.12 Image and Block Diagram of ST-RX04-ASK Receiver

Applications:

Car security system

Wireless security systems

Sensor reporting

Automation system

Remote Keyless entry

2.5MAX232:

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to

supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232 inputs

to 5-V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V and a typical

Page 40: Wireless Spy Robot With Bject Detection

hysteresis of 0.5 V, and can accept ±30-V inputs. Each driver converts TTL/CMOS input levels

into EIA-232 levels.

Fig 2.13 MAX 232 PIN DIAGRAM

The MAX232 contains four sections: dual charge-pump DC-DC voltage converters, RS-232

drivers, RS-232 receivers, and receiver and transmitter enable control inputs.

Dual Charge-Pump Voltage Converter

The MAX232 has two internal charge-pumps that convert +5V to ±10V (unloaded)

for RS-232 driver operation. The first converter uses capacitor C1 to double the +5V input to

+10V on C3 at the V+ output. The second converter uses capacitor C2 to invert +10V to -10V on

C4 at the V- output.

A small amount of power may be drawn from the +10V (V+) and -10V (V-) outputs to power

external circuitry, except on the MAX225 and MAX232, where these pins are not available. V+

and V- are not regulated, so the output voltage drops with increasing load current.

Page 41: Wireless Spy Robot With Bject Detection

MAX241, and MAX245–MAX249, avoid using V+ and Vto power external circuitry. When

these parts are shut down, V- falls to 0V, and V+ falls to +5V. For applications where a +10V

external supply is applied to the V+ pin (instead of using the internal charge pump to generate

+10V), the C1 capacitor must not be installed and the SHDN pin must be tied to VCC. This is

because V+ is internally connected to VCC in shutdown mode.

RS-232 Drivers

typical driver output voltage swing is ±8V when loaded with a nominal 5kΩ

RS-232 receiver and VCC = +5V. Output swing is guaranteed to meet the EIA/TIA- 232E and

V.28 specification, which calls for ±5V minimum driver output levels under worst-case

conditions. These include a minimum 3kΩ load, VCC = +4.5V, and maximum operating

temperature. Unloaded driver output voltage ranges from (V+ -1.3V) to (V- +0.5V).

Input thresholds are both TTL and CMOS compatible. The inputs of unused drivers can be left

unconnected since 400kΩ input pull-up resistors to VCC are built in (except for the MAX220).

The pull-up resistors force the outputs of unused drivers low because all drivers invert.

The internal input pull-up resistors typically source 12μA, except in shutdown mode where the

pull-ups are disabled.

Driver outputs turn off and enter a high-impedance state—where leakage current is

typically microamperes (maximum 25μA)—when in shutdown mode, in three-state mode, or

when device power is removed. Outputs can be driven to ±15V. The power supply current

typically drops to 8μA in shutdown mode. The receiver TTL/CMOS outputs are in a high-

impedance, three-state mode whenever the three-state enable line is high, and are also high-

impedance whenever the shutdown control line is high. When in low-power shutdown mode, the

driver outputs are turned off and their leakage current is less than 1μA with the driver output

pulled to ground. The driver output leakage remains less than 1μA, even if the transmitter output

is backdriven between 0V and (VCC + 6V). Below -0.5V, the transmitter is diode clamped to

ground with 1kΩ series impedance. The transmitter is also zener clamped to approximately VCC

+ 6V, with a series impedance of 1kΩ. The driver output slew rate is limited to less than 30V/μs

as required by the EIA/TIA-232E and V.28 specifications. Typical slew rates are 24V/μs

unloaded and 10V/μs loaded with 3Ω and 2500pF.

Page 42: Wireless Spy Robot With Bject Detection

RS-232 Receivers

EIA/TIA-232E and V.28 specifications define a voltage level greater than 3V as

a logic 0, so all receivers invert Input thresholds are set at 0.8V and 2.4V, so receivers respond to

TTL level inputs as well as EIA/TIA-232E and V.28 levels. The receiver inputs withstand an

input overvoltage up to ±25V and provide input terminating resistors withnominal 5kΩ values.

The receiver input hysteresis is typically 0.5V with a guaranteed minimum of 0.2V. This

produces clear output transitions with slow-moving input signals, even with moderate amounts

of noise and ringing. The receiver propagation delay is typically 600ns and is independent of

input swing direction.

Fig 2.14 CONNECTION OF MAX232 TO PC

2.6 ULN2803:

The driver makes use of the ULN2803 driver IC, which contains an array of 8

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.

Page 43: Wireless Spy Robot With Bject Detection

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.

Fig 2.15 ULN pin connection and block diagram

Page 44: Wireless Spy Robot With Bject Detection

The main features of ULN2803 are as follows:

Seven Darlington per package

Output current 500ma per driver (600ma peak)

Output voltage 50v

Integrated suppression diodes for inductive loads

Outputs can be paralleled for high current TTL/CMOS/DTL compatible inputs

Inputs pinned opposite outputs to simplify layout.

Transient protected outputs

Dual In-Line plastic package or small-Outline IC package

2.7 RELAY:

2.7.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 relay.

Page 45: Wireless Spy Robot With Bject Detection

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.

Fig 2.16 Relay diagram

The relay’s switch connections are usually contains 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 changeover" (SPCO)

Or "double pole changeover"(DPCO).

Page 46: Wireless Spy Robot With Bject Detection

Fig 2.17 SPDT Relay

D 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..

Fig 2.17 DPDT Relay

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.

2.7.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

Page 47: Wireless Spy Robot With Bject Detection

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:

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)

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.   

Advantages of Relay:

Page 48: Wireless Spy Robot With Bject Detection

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.

2.8 DC MOTOR:

DC motors are configured in many types and sizes, including brush less,

servo, and gear motor types. A motor consists of a rotor and a permanent magnetic field stator. The

magnetic field is maintained using either permanent magnets or electromagnetic windings. DC

motors are most commonly used in variable speed and torque.

Motion and controls cover a wide range of components that in some way are used to generate

and/or control motion. Areas within this category include bearings and bushings, clutches and

brakes, controls and drives, drive components, encoders and resolves, Integrated motion control,

limit switches, linear actuators, linear and rotary motion components, linear position sensing,

motors (both AC and DC motors), orientation position sensing, pneumatics and pneumatic

components, positioning stages, slides and guides, power transmission (mechanical), seals, slip

rings, solenoids, springs.

Motors are the devices that provide the actual speed and torque in a drive system.  This

family includes AC motor types (single and multiphase motors, universal, servo motors, induction,

synchronous, and gear motor) and DC motors (brush less, servo motor, and gear motor) as well as

linear, stepper and air motors, and motor contactors and starters.

In any electric motor, operation is based on simple electromagnetism. A current-

carrying conductor generates a magnetic field; when this is then placed in an external magnetic

field, it will experience a force proportional to the current in the conductor, and to the strength of

the external magnetic field. The internal configuration of a DC motor is designed to harness the

magnetic interaction between a current-carrying conductor and an external magnetic field to

generate rotational motion.

Page 49: Wireless Spy Robot With Bject Detection

Look at a simple 2-pole DC electric motor (here red represents a magnet or winding with a

"North" polarization, while green represents a magnet or winding with a "South" polarization).

Fig 2.18 DC motor

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, commutator, field

magnet(s), and brushes. In most common DC motors (and all that Beamers will see), the external

magnetic field is produced by high-strength permanent magnets. The stator is the stationary part of

the motor. This includes the motor casing, as well as two or more permanent magnet pole pieces.

The rotor (together with the axle and attached commutator) rotates with respect to the stator. The

rotor consists of windings (generally on a core), the windings being electrically connected to the

commutator. The above diagram shows a common motor layout -- with the rotor inside the stator

(field) magnets.

The geometry of the brushes, commutator contacts, and rotor windings are such that

when power is applied, the polarities of the energized winding and the stator magnet(s) are

misaligned, and the rotor will rotate until it is almost aligned with the stator's field magnets. As the

rotor reaches alignment, the brushes move to the next commutator contacts, and energize the next

winding. Given our example two-pole motor, the rotation reverses the direction of current through

the rotor winding, leading to a "flip" of the rotor's magnetic field, and driving it to continue rotating.

In real life, though, DC motors will always have more than two poles (three is a very

common number). In particular, this avoids "dead spots" in the commutator. You can imagine how

with our example two-pole motor, if the rotor is exactly at the middle of its rotation (perfectly

aligned with the field magnets), it will get "stuck" there. Meanwhile, with a two-pole motor, there is

a moment where the commutator shorts out the power supply (i.e., both brushes touch both

commutator contacts simultaneously). This would be bad for the power supply, waste energy, and

Page 50: Wireless Spy Robot With Bject Detection

damage motor components as well. Yet another disadvantage of such a simple motor is that it would

exhibit a high amount of torque” ripple" (the amount of torque it could produce is cyclic with the

position of the rotor).

Fig 2.19 working of DC motor

So since most small DC motors are of a three-pole design, let's tinker with the workings of one via an

interactive animation (JavaScript required):

Fig 2.19 conceptual 3-pole dc motor

One pole is fully energized at a time (but two others are "partially" energized). As each brush

transitions from one commutator contact to the next, one coil's field will rapidly collapse, as the next

coil's field will rapidly charge up (this occurs within a few microsecond). We'll see more about the

effects of this later, but in the meantime you can see that this is a direct result of the coil windings'

series wiring:

Page 51: Wireless Spy Robot With Bject Detection

Fig 2.19 working of 3-pole dc motor

There's probably no better way to see how an average dc motor is put

together, than by just opening one up. Unfortunately this is tedious work, as well as requiring the

destruction of a perfectly good motor. This is a basic 3-pole dc motor, with 2 brushes and three

commutator contacts

2.9 VOLTAGE REGULATOR:

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.

Fig 2.20 Pin Diagram of Regulator

Page 52: Wireless Spy Robot With Bject Detection

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

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.

Three-Terminal Voltage Regulators:

Fixed Positive Voltage Regulators:

Vin Vout

C1 C2

IN OUT

78XX

GND

Page 53: Wireless Spy Robot With Bject Detection

Fig 2.21 pin connection of IC regulator

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, Vi, 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 2.3 Positive Voltage Regulators in 7800 series

IC No. Output voltage(v) Maximum input voltage(v)

7805

7806

7808

7810

7812

7815

7818

+5

+6

+8

+10

+12

+15

+18

35V

Page 54: Wireless Spy Robot With Bject Detection

7824 +24 40V

2.10 WIRELESS CAMERA

Radio Frequency – AV Wireless Cam

A wireless audio and video signal transmitter and receiver system apparatus

capable of accepting both external baseband audio and video signal inputs and a modulated

external audio/video signal modulated at a particular TV channel. A transmitter transmits an

audio/video signal to one or more remote receivers which regenerate the original audio/video

signal providing both baseband audio /video signal output at the particular television channel.

The transmitter includes a modulated audio/video signal input section and baseband audio and

video signal input sections which provide audio subcarrier and video baseband signals to a

video/RF switch which permits the user to select between modulated and baseband inputs to the

transmitter. The audio/video signal is AM modulated and up converted before being transmitted

to the receiver. The receiver down converts the received audio/video signal and through which a

modulated audio/video signal output section connected to baseband audio and video signal

output sections serves to provide both modulated and baseband audio/video signal outputs.

Page 55: Wireless Spy Robot With Bject Detection

2.22 AV Transmitter circuit diagram

The transmitter is made up of 2 parts: audio and video unit. The audio signal form MIC1 is

amplified, then modulated by the audio carry frequency oscillator(6.5MHz), the modulated carry

frequency is added in the VT of voltage controlled oscillator VCO2 (2.4GHz,D1,Q1). The video

signal from CMOS camera passes through the sharp network (R4,R5,C11,R16),also is added in

the VT of VCO2,another signal is added in the VCO2 is the error voltage output of loop filter

(R1,R24,R25,R28,C17,C19,C25) of PLL(U2) which is programmed by CPU(U1), the channel

data is decided by the encode switch(SW1) of CPU’s VCO2 is compared with reference crystal

oscillator, the error frequency of oscillator VCO2 can be corrected. The carry frequency

modulated of audio and video has filter (c20,c18,c23,smicrostrip) to make the higher harmonica

of signal reduce to lower level. The purer signal is emitted by antenna (RFout )

AV Receiver:

Here in this we use RF receiver which worked at the frequencies of 900MHz to 1200MHz. The

receiver receives the signal from the transmitter when we tune the tuner circuit of the receiver.

The receiver circuit basically consists of a receiving antenna, RF amplifier, Demodulator, Tuner

and Display device.

Page 56: Wireless Spy Robot With Bject Detection

Fig 2.23 AV Receiver circuit diagram

The receiving antenna is used to pickup the Electro-magnetic signals and converts

these signals into Electrical signals. The antenna is fed to the RF amplifier which is used to

amplify the electric signals. The tuner is used to tune specific frequency for effective reception.

The demodulator is used to demodulate the modulated singles and produces baseband signal

which is used to demodulate the modulated signal and produces baseband signal which is similar

to the input of the transmitter. The output of the demodulator is given to the any type of displays

devices to see the audio and video of transmitted signals.

Features:

Wireless transmission and reception

Small size

Light weight

Low power consumption

High sensitivity

Easy installation and operation

Easy to construct

Table 2.4 Specifications of RF-AV Wireless Cam

Image pickup device ½ ¼ inch CMOS

TV system PAL/CCIR,NTSC/EIA

Definition 380 TV lines

Scan frequency Pal/CCIR:50Hz,NTSC/EIA:60Hz

Page 57: Wireless Spy Robot With Bject Detection

Min illumination 3 LUX

Output Power 5omW,200mW

Output frequency 900MHz,1200MHz

Power supply DC +6V to +12V

Page 58: Wireless Spy Robot With Bject Detection

CHAPTER 3

SOFTWARE DETAILS

3.1 KEIL SOFTWARE

Introduction to Micro vision Keil (IDE)

Keil is a cross compiler. So first we have to understand the concept of compilers and cross

compilers. After then we shall learn how to work with keil.

Concept of compiler: -

Compilers are programs used to convert a High Level Language to object code. Desktop

compilers produce an output object code for the underlying microprocessor, but not for other

microprocessors. I.E the programs written in one of the HLL like ‘C’ will compile the code to

run on the system for a particular processor like x86 (underlying microprocessor in the

computer). For example compilers for Dos platform is different from the Compilers for Unix

platform

So if one wants to define a compiler then compiler is a program that translates source code into

object code. The compiler derives its name from the way it works, looking at the entire piece of

source code and collecting and reorganizing the instruction. See there is a bit little difference

between compiler and an interpreter. Interpreter just interprets whole program at a time while

compiler analyzes and execute each line of source code in succession, without looking at the

entire program.

The advantage of interpreters is that they can execute a program immediately. Secondly

programs produced by compilers run much faster than the same programs executed by an

interpreter. However compilers require some time before an executable program emerges. Now

as compilers translate source code into object code, which is unique for each type of computer,

many compilers are available for the same language.

Page 59: Wireless Spy Robot With Bject Detection

Concept of cross compiler: -

A cross compiler is similar to the compilers but we write a program for the target processor (like

8051 and its derivatives) on the host processors (like computer of x86)

It means being in one environment you are writing a code for another environment is called cross

development. And the compiler used for cross development is called cross compiler

So the definition of cross compiler is a compiler that runs on one computer but produces object

code for a different type of computer. Cross compilers are used to generate software that can run

on computers with a new architecture or on special-purpose devices that cannot host their own

compilers. Cross compilers are very popular for embedded development, where the target

probably couldn't run a compiler. Typically an embedded platform has restricted RAM, no hard

disk, and limited I/O capability. Code can be edited and compiled on a fast host machine (such as

a PC or Unix workstation) and the resulting executable code can then be downloaded to the

target to be tested. Cross compilers are beneficial whenever the host machine has more resources

(memory, disk, I/O etc) than the target. Keil C Compiler is one such compiler that supports a

huge number of host and target combinations. It supports as a target to 8 bit microcontrollers like

Atmel and Motorola etc.

Why do we need cross compiler?

There are several advantages of using cross compiler. Some of them are described as follows

By using this compilers not only can development of complex embedded systems be

completed in a fraction of the time, but reliability is improved, and maintenance is easy.

Knowledge of the processor instruction set is not required.

A rudimentary knowledge of the 8051’s memory architecture is desirable but not

necessary.

Register allocation and addressing mode details are managed by the compiler.

The ability to combine variable selection with specific operations improves program

readability.

Keywords and operational functions that more nearly resemble the human thought

process can be used.

Page 60: Wireless Spy Robot With Bject Detection

Program development and debugging times are dramatically reduced when compared to

assembly language programming.

The library files that are supplied provide many standard routines (such as formatted

output, data conversions, and floating-point arithmetic) that may be incorporated into your

application.

Existing routine can be reused in new programs by utilizing the modular programming

techniques available with C.

The C language is very portable and very popular. C compilers are available for almost

all target systems. Existing software investments can be quickly and easily converted from or

adapted to other processors or environments. 

Now after going through the concept of compiler and cross compilers lets we start with

Keil C cross compiler.

Keil C cross compiler:

Keil is a German based Software development company. It provides several development tools

like

•         IDE (Integrated Development environment)

•         Project Manager

•         Simulator

•         Debugger

•         C Cross Compiler, Cross Assembler, Locator/Linker

Keil Software provides you with software development tools for the ARM microcontrollers.

With these tools, you can generate embedded applications for the multitude of ARM derivatives.

Keil provides following tools for ARM development

1.     ARM Optimizing C Cross Compiler,

2.     Macro Assembler,

Page 61: Wireless Spy Robot With Bject Detection

3.    ARM Utilities (linker, object file converter, library manager),

4.     Source-Level Debugger/Simulator,

5.     µVision for Windows Integrated Development Environment.

The keil ARM tool kit includes three main tools, assembler, compiler and linker.

An assembler is used to assemble your ARM assembly program

A compiler is used to compile your C source code into an object file

A linker is used to create an absolute object module suitable for your in-circuit emulator.

8051 project development cycle: -

These are the steps to develop ARM project using keil

1. Create source files in C or assembly.

2. Compile or assemble source files.

3. Correct errors in source files.

4. Link object files from compiler and assembler.

5. Test linked application.

3.2 Flash Magic

NXP Semiconductors produce a range of Microcontrollers that feature both

on-chip Flash memory and the ability to be reprogrammed using In-System Programming

technology. Flash Magic is Windows software from the Embedded Systems Academy that

allows easy access to all the ISP features provided by the devices. These features include:

Erasing the Flash memory (individual blocks or the whole device)

Programming the Flash memory

Modifying the Boot Vector and Status Byte

Reading Flash memory

Performing a blank check on a section of Flash memory

Reading the signature bytes

Page 62: Wireless Spy Robot With Bject Detection

Reading and writing the security bits

Direct load of a new baud rate (high speed communications)

Sending commands to place device in Boot loader mode

Flash Magic provides a clear and simple user interface to these features and more as described in

the following sections. Under Windows, only one application may have access the COM Port at

any one time, preventing other applications from using the COM Port. Flash Magic only obtains

access to the selected COM Port when ISP operations are being performed. This means that other

applications that need to use the COM Port, such as debugging tools, may be used while Flash

Magic is loaded. Note that in this manual third party Compilers are listed alphabetically. No

preferences are indicated or implied.

3.2.1Five Step ProgrammingFor each step there is a corresponding section in the main window as described in the User

Interface Tour.

Step 1 – Connection Settings

Before the device can be used the settings required to make a connection must be specified

.

COM Port Settings

Select the desired COM port from the drop down list or type the desired COM port directly into

the box. If you enter the COM port yourself then you must enter it in one of the following

formats:

COM n

n

Page 63: Wireless Spy Robot With Bject Detection

Any other format will generate an error. So if you want to use COM 5 (which is not present on

the drop down list) you can directly type in either “COM 5” or “5”.

Select the baud rate to connect at. Try a low speed first. The maximum speed that can be

used depends on the crystal frequency on your hardware. You can try connecting at higher and

higher speeds until connections fail. Then you have found the highest baud rate to connect at.

Alternatively, some devices support high speed communications. Please refer to the High Speed

Communications section for information. Select the device being used from the drop down list.

Ensure you select the correct one as different devices have different feature sets and different

methods of setting up the serial communications.

Select the interface being used, if any. An interface is a device that connects between your PC

and the target hardware. If you simply have a serial cable or USB to serial cable

Connecting your COM port to the target hardware, then choose "None (ISP)". Choosing the

correct interface will automatically configure Flash Magic for that interface, along with enabling

and disabling the relevant features.

Enter the oscillator frequency used on the hardware. Do not round the frequency, instead

enter it as precisely as possible. Some devices do not require the oscillator frequency to be

entered, so this field will not be displayed. Once the options are set ensure the device is running

the on-chip Boot loader if you are using a manual ISP entry method. Note that the connection

settings affect all ISP features provided by Flash Magic.

Ethernet Settings

Selecting a device with "Ethernet" at the end of the name indicates that the Ethernet

boot loader should be used. The Ethernet options will be displayed.

Enter an IP address for the boot loader. This must be an address on the same subnet as the

PC running Flash Magic and it must not be already in use. The boot loader will be assigned this

IP address while Flash Magic is accessing the device.

The IP address must have the format "a.b.c.d" where a, b, c and d are decimal values from zero

to 255.

Page 64: Wireless Spy Robot With Bject Detection

Enter the MAC address of the boot loader. Typically the MAC address is hard-coded in the

bootloader.The MAC address must have the format "aa-bb-cc-dd-ee-ff" where aa, bb, cc, dd, ee

and ff are two digit hexadecimal values.

Note that the connection settings affect all ISP features provided by Flash Magic.

4.2 Step 2 – Erasing

This step is optional, however if you attempt to program the device without first erasing at least

one Flash block, then Flash Magic will warn you and ask you if you are sure you want to

program the device.

Select each Flash block that you wish to erase by clicking on its name. If you wish to erase all

the Flash then check that option. If you check to erase a Flash block and all the Flash then the

Flash block will not be individually erased. If you wish to erase only the Flash blocks used by

the hex file you are going to select, then check that option. For most devices erasing all the Flash

also results in the Boot Vector and Status Byte being set to default values, which ensure that the

Boot loader will be executed on reset, regardless of the state of the PSEN pin or other hardware

requirements. Only when programming a Hex File has been completed will the Status Byte be

set to 00H to allow the code to execute.

This is a safeguard against accidentally attempting to execute when the Flash is erased. On some

devices erasing all the Flash will also erase the security bits. This will be indicated by the text

next to the Erase all Flash option. On some devices erasing all the Flash will also erase the speed

setting of the device (the number of clocks per cycle) setting it back to the default. This will be

indicated by the text next to the Erase all Flash option.

Page 65: Wireless Spy Robot With Bject Detection

4.3 Step 3 – Selecting the Hex File

This step is optional. If you do not wish to program a Hex File then do not select one.

You can either enter a path name in the text box or click on the Browse button to select a

Hex File by browsing to it. Also you can choose Open… from the File menu. Note that the Hex

file is not loaded or cached in any way. This means that if the Hex File is modified, you do not

have to reselect it in Flash Magic. Every time the Hex File is programmed it is first re-read from

the location specified in the main window. The date the Hex file was last modified is shown in

this section. This information is updated whenever the hex file is modified. The hex file does not

need to be reselected. Clicking on more info or choosing Information… from the File menu will

display additional information about the Hex file. The information includes the range of Flash

memory used by the Hex file, the number of bytes of Flash memory used and the percentage of

the currently selected device that will be filled by programming the Hex file. If the device

supports programming and execution from RAM, for example the ARM devices, then the hex

file may contain records for the RAM. First the flash will be programmed followed by the RAM.

Programs loaded into RAM via a hex file may be executed using such features as the Go option.

4.4 Step 4 – Options

Flash Magic provides various options that may be used after the Hex File has been programmed.

Page 66: Wireless Spy Robot With Bject Detection

This section is optional, however Verify After Programming, Fill Unused Flash and Gen Block

Checksums may only be used if a Hex File is selected (and therefore being programmed), as they

all need to know either the Hex File contents or memory locations used by the Hex File.

Checking the Verify After Programming option will result in the data contained in the Hex File

being read back from Flash and compared with the Hex File after programming. This helps to

ensure that the Hex File was correctly programmed. If the device does not support verifying then

this item will be disabled. Checking the Fill Unused Flash option will result in every memory

location not used by the Hex File being programmed with the value that sets all the bits to a

programmed state. Once a location has been programmed with this feature it cannot be

reprogrammed with any other value, preventing someone from programming the device with a

small program to read out the contents of Flash or altering the application’s operation. Checking

the Gen Block Checksums option will instruct Flash Magic to program the highest location in

every Flash block used by the Hex File with a special “checksum adjuster value”.

This value ensures that when a checksum is calculated for the whole Flash Block it will equal

55H, providing the contents of the Flash block have not be altered or corrupted. Please refer to

the Block Checksums section for more information. Checking the Execute option will cause the

downloaded firmware to be executed automatically after the programming is complete. Note that

this will not work if using the Hardware Reset option or a device that does not support this

feature.

4.5 Step 5 – Performing the Operations

Step 5 contains a Start button.

Clicking the Start button will result in all the selected operations in the main window taking

place. They will be in order:

Erasing Flash

Programming the Hex File

Page 67: Wireless Spy Robot With Bject Detection

Verifying the Hex File

Filling Unused Flash

Generating Checksums

Programming the clocks bit

Programming the Security Bits

Executing the firmware

Once started progress information and a progress bar will be displayed at the bottom of the main

window. In addition the Start button will change to a cancel button. Click on the cancel button to

cancel the operation. Note that if you cancel during erasing all the Flash, it may take a few

seconds before the operation is cancelled. Once the operations have finished the progress

information will briefly show the message “Finished…”. The Programmed Count shown next to

the progress bar will increment. This shows the total number of times the hex file has been

programmed. Modifying the hex file or selecting another hex file will reset the count.

Alternatively, right-clicking over the count provides a menu with the option to immediately reset

the count.

3.3 MATLAB

MATLAB is a high-performance language for technical computing. It

integrates computation, visualization, and programming in an easy-to-use environment where

problems and solutions are expressed in familiar mathematical notation. Typical uses include

Math and computation

Algorithm development

Data acquisition

Modeling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

Application development, including graphical user interface building

Page 68: Wireless Spy Robot With Bject Detection

MATLAB is an interactive system whose basic data element is an array that does not require

dimensioning. This allows you to solve many technical computing problems, especially those

with matrix and vector formulations, in a fraction of the time it would take to write a program in

a scalar non interactive language such as C or FORTRAN. The name MATLAB stands for

matrix laboratory. MATLAB was originally written to provide easy access to matrix software

developed by the LINPACK and EISPACK projects. Today, MATLAB engines incorporate the

LAPACK and BLAS libraries, embedding the state of the art in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In university

environments, it is the standard instructional tool for introductory and advanced courses in

mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-

productivity research, development, and analysis. MATLAB features a family of add-on

application-specific solutions called toolboxes. Very important to most users of MATLAB,

toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive

collections of MATLAB functions (M-files) that extend the MATLAB environment to solve

particular classes of problems. Areas in which toolboxes are available include signal processing,

control systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

Page 69: Wireless Spy Robot With Bject Detection

CHAPTER 4

IMAGE PROCESSING USING MATLAB

4.1 Image Processing Toolbox:

Image Processing Toolbox is a collection of functions that extend the capability of

the MATLAB numeric computing environment. The toolbox supports a wide range of image

processing operations, including Spatial image transformations Morphological operations

Neighborhood and block operations Linear filtering and filter design Transforms Image analysis

and enhancement image registration Deblurring Region of interest operations Many of the

toolbox functions are MATLAB M-files, a series of MATLAB statements that implement

specialized image processing algorithms. You can view the MATLAB code for these functions

using the statement type function name you can extend the capabilities of Image Processing

Toolbox by writing your own M-files, or by using the toolbox in combination with other

toolboxes, such as Signal Processing Toolbox and Wavelet Toolbox.

4.2 Image Acquisition with Wireless Camera

What Is Image Acquisition Toolbox?

Image Acquisition Toolbox is a collection of functions that extend the capability of

the MATLAB numeric computing environment. The toolbox supports a wide range of image

acquisition operations, including: Acquiring images through many types of image acquisition

devices, from professional grade frame grabbers to USB-based Webcams Viewing a preview of

the live video stream, Triggering acquisitions (includes external hardware triggers)Configuring

callback functions that execute when certain events occur, Bringing the image data into the

MATLAB workspace. Many of the toolbox functions are MATLAB M-files. You can view the

MATLAB code for these functions using the statement “type function name”.

Page 70: Wireless Spy Robot With Bject Detection

You can extend the capabilities of Image Acquisition Toolbox by writing your own M-files, or

by using the toolbox in combination with other toolboxes, such as Image Processing Toolbox

and Data Acquisition Toolbox.

Basic Image Procedure Acquisition

This section illustrates the basic steps required to create an image acquisition application by

implementing a simple motion detection application. The application detects movement in a

scene by performing a pixel-to-pixel comparison in pairs of incoming image frames. If nothing

moves in the scene, pixel values remain the same in each frame. When something moves in the

image, the application displays the pixels that have changed values.

To use Image Acquistion Toolbox to acquire image data,we must perform the following steps:

Step 1:

Install Your Image Acquisition Device. Follow the setup instructions that come with your image

acquisition device. Setup typically involves:

Installing the frame grabber board in your computer

Installing any software drivers required by the device. These are supplied by the device

vendor.

Connecting a camera to a connector on the frame grabber board.

Verifying that the camera is working properly by running the application software that

came with the camera and viewing a live video stream. Generic Windows image

acquisition devices, such as Webcams and digital video camcorders, typically do not

require the installation of a frame grabber board. You connect these devices directly to

your computer via a USB or FireWire port.

After installing and configuring your image acquisition hardware, start MATLAB on your

computer by double-clicking the icon on your desktop. You do not need to perform any special

configuration of MATLAB to perform image acquisition.

Step 2: Retrieve Hardware Information

Page 71: Wireless Spy Robot With Bject Detection

In this step, you get several pieces of information that the toolbox needs to uniquely identify the

image acquisition device you want to access. You use this information when you create an image

acquisition object, described in Step 3: Create a Video Input Object.

Determining the Adaptor Name

To determine the name of the adaptor, enter the imaqhwinfo function at the MATLAB prompt

without any arguments.

imaqhwinfo

ans =

InstalledAdaptors: {'dcam' 'winvideo'}

MATLABVersion: '7.4 (R2007a)'

ToolboxName: 'Image Acquisition Toolbox'

ToolboxVersion: '2.1 (R2007a)'

In the data returned by imaqhwinfo, the InstalledAdaptors field lists the adaptors that are

available on your computer. In this example, imaqhwinfo found two adaptors available on the

computer: 'dcam' and 'winvideo'. The listing on your computer might contain only one adaptor

name. Select the adaptor name that provides access to your image acquisition device.

Determining the Device ID

To find the device ID of a particular image acquisition device, enter the imaqhwinfo function at

the MATLAB prompt, specifying the name of the adaptor as the only argument. (You found the

adaptor name in the first call to imaqhwinfo) In the data returned, the DeviceIDs field is a cell

array containing the device IDs of all the devices accessible through the specified adaptor.

info = imaqhwinfo('dcam')

info =

Page 72: Wireless Spy Robot With Bject Detection

AdaptorDllName: [1x77 char]

AdaptorDllVersion: '2.1 (R2007a)'

AdaptorName: 'dcam'

DeviceIDs: {[1]}

DeviceInfo: [1x1 struct]

Determining the Supported Video Formats

To determine which video formats an image acquisition device supports, look in the DeviceInfo

field of the data returned by imaqhwinfo. The DeviceInfo field is a structure array where each

structure provides information about a particular device. To view the device information for a

particular device, you can use the device ID as a reference into the structure array. Alternatively,

you can view the information for a particular device by calling the imaqhwinfo function,

specifying the adaptor name and device ID as arguments. To get the list of the video formats

supported by a device, look at SupportedFormats field in the device information structure. The

SupportedFormats field is a cell array of strings where each string is the name of a video format

supported by the device. For more information, see Determining Supported Video

Formats.dev_info = imaqhwinfo('dcam',1)

dev_info =

DefaultFormat: 'F7_Y8_1024x768'

DeviceFileSupported: 0

DeviceName: 'XCD-X700 1.05'

DeviceID: 1

ObjectConstructor: 'videoinput('dcam', 1)'

SupportedFormats: {'F7_Y8_1024x768' 'Y8_1024x768'}

Page 73: Wireless Spy Robot With Bject Detection

Step 3: Create a Video Input Object

In this step you create the video input object that the toolbox uses to represent the connection

between MATLAB and an image acquisition device. Using the properties of a video input object,

you can control many aspects of the image acquisition process. To create a video input object,

use the videoinput function at the MATLAB prompt. The DeviceInfo structure returned by the

imaqhwinfo function contains the default videoinput function syntax for a device in the Object

Constructor field. The following example creates a video input object for the DCAM adaptor.

Substitute the adaptor name of the image acquisition device available on your system.

vid = videoinput('dcam',1,'Y8_1024x768')

The videoinput function accepts three arguments: the adaptor name, device ID, and video format.

You retrieved this information in step 2. The adaptor name is the only required argument; the

videoinput function can use defaults for the device ID and video format. To determine the default

video format, look at the DefaultFormat field in the device information structure. See

Determining the Supported Video Formats for more information.Instead of specifying the video

format, you can optionally specify the name of a device configuration file, also known as a

camera file. Device configuration files are typically supplied by frame grabber vendors. These

files contain all the required configuration settings to use a particular camera with the device.

Viewing the Video Input Object Summary

To view a summary of the video input object you just created, enter the variable name (vid) at

the MATLAB command prompt. The summary information displayed shows many of the

characteristics of the object, such as the number of frames that will be captured with each trigger,

the trigger type, and the current state of the object. You can use video input object properties to

control many of these characteristics. See Step 5: Configure Object Properties (Optional) for

more information.

vid

Summary of Video Input Object Using 'XCD-X700 1.05'.

Acquisition Source(s): input1 is available.

Page 74: Wireless Spy Robot With Bject Detection

Acquisition Parameters: 'input1' is the current selected source.

10 frames per trigger using the selected source.

'Y8_1024x768' video data to be logged upon START.

Grabbing first of every 1 frame(s).

Log data to 'memory' on trigger.

Trigger Parameters: 1 'immediate' trigger(s) on START.

Status: Waiting for START.

0 frames acquired since starting.

0 frames available for GETDATA.

Step 4: Preview the Video Stream (Optional)

After you create the video input object, MATLAB is able to access the image acquisition device

and is ready to acquire data. However, before you begin, you might want to see a preview of the

video stream to make sure that the image is satisfactory. For example, you might want to change

the position of the camera, change the lighting, correct the focus, or make some other change to

your image acquisition setup.

To preview the video stream in this example, enter the preview function at the MATLAB

prompt, specifying the video input object created in step 3 as an argument.

preview(vid)

The preview function opens a Video Preview figure window on your screen containing the live

video stream. To stop the stream of live video, you can call the stoppreview function. To restart

the preview stream, call preview again on the same video input object.

Page 75: Wireless Spy Robot With Bject Detection

While a preview window is open, the video input object sets the value of the Previewing

property to 'on'. If you change characteristics of the image by setting image acquisition object

properties, the image displayed in the preview window reflects the change.

To close the Video Preview window, use the closepreview function, specifying the

video input object as an argument.

closepreview(vid)

Calling closepreview without any arguments closes all open Video Preview windows.

Step 5: Configure Object Properties (Optional)

After creating the video input object and previewing the video stream, you might want to modify

characteristics of the image or other aspects of the acquisition process. You accomplish this by

setting the values of image acquisition object properties. This section

Describes the types of image acquisition objects used by the toolbox

Describes how to view all the properties supported by these objects, with their current

values

Describes how to set the values of object properties

Types of Image Acquisition Objects

The toolbox uses two types of objects to represent the connection with an image acquisition

device:

Video input objects

Video source objects

A video input object represents the connection between MATLAB and a video acquisition

device at a high level. The properties supported by the video input object are the same for every

type of device. You created a video input object using the videoinput function in step 3.

Page 76: Wireless Spy Robot With Bject Detection

When you create a video input object, the toolbox automatically creates one or more video

source objects associated with the video input object. Each video source object represents a

collection of one or more physical data sources that are treated as a single entity. The number of

video source objects the toolbox creates depends on the device and the video format you specify.

At any one time, only one of the video source objects, called the selected source, can be active.

This is the source used for acquisition.

Viewing Object Properties

To view a complete list of all the properties supported by a video input object or a video source

object, use the get function. To list the properties of the video input object created in step 3, enter

this code at the MATLAB prompt.

get(vid)

The get function lists all the properties of the object with their current values.

General Settings:

DeviceID = 1

DiskLogger = []

DiskLoggerFrameCount = 0

EventLog = [1x0 struct]

FrameGrabInterval = 1

FramesAcquired = 0

FramesAvailable = 0

FramesPerTrigger = 10

Logging = off

LoggingMode = memory

Name = Y8_1024x768-dcam-1

NumberOfBands = 1

Previewing = on

ReturnedColorSpace = grayscale

Page 77: Wireless Spy Robot With Bject Detection

ROIPosition = [0 0 1024 768]

Running = off

Tag =

Timeout = 10

Type = videoinput

UserData = []

VideoFormat = Y8_1024x768

VideoResolution = [1024 768]

To view the properties of the currently selected video source object associated with this video

input object, use the getselectedsource function in conjunction with the get function. The

getselectedsource function returns the currently active video source. To list the properties of

the currently selected video source object associated with the video input object created in step 3,

enter this code at the MATLAB prompt.

get(getselectedsource(vid))

The get function lists all the properties of the object with their current values.

General Settings:

Parent = [1x1 videoinput]

Selected = on

SourceName = input1

Tag =

Type = videosource

Device Specific Properties:

FrameRate = 15

Page 78: Wireless Spy Robot With Bject Detection

Gain = 2048

Shutter = 2715

Setting Object Properties

To set the value of a video input object property or a video source object property, you

can use the set function or you can reference the object property as you would a field in a

structure, using dot notation. Some properties are read only; you cannot set their values. These

properties typically provide information about the state of the object. Other properties become

read only when the object is running. To view a list of all the properties you can set, use the set

function, specifying the object as the only argument. To implement continuous image

acquisition, the example sets the Trigger Repeat property to Inf. To set this property using the set

function, enter this code at the MATLAB prompt. set (vid,'TriggerRepeat',Inf);To help the

application keep up with the incoming video stream while processing data, the example sets the

FrameGrabInterval property to 5. This specifies that the object acquire every fifth frame in the

video stream. (You might need to experiment with the value of the FrameGrabInterval property

to find a value that provides the best response with your image acquisition setup.) This example

shows how you can set the value of an object property by referencing the property as you would

reference a field in a MATLAB structure.

vid.FrameGrabInterval = 5;

To set the value of a video source object property, you must first use the getselectedsource

function to retrieve the object.

(You can also get the selected source by searching the video input object Source property for the

video source object that has the Selected property set to 'on'.) To illustrate, the example assigns a

value to the Tag property.

Page 79: Wireless Spy Robot With Bject Detection

vid_src = getselectedsource(vid);

set(vid_src,'Tag','motion detection setup');

Step6: Acquire Image Data

After you create the video input object and configure its properties, you can acquire data. This is

typically the core of any image acquisition application, and it involves these steps: Starting the

video input object —

You start an object by calling the start function. Starting an object prepares the object for data

acquisition. For example, starting an object locks the values of certain object properties (they

become read only). Starting an object does not initiate the acquiring of image frames, however.

The initiation of data logging depends on the execution of a trigger.The following example calls

the start function to start the video input object. Objects stop when they have acquired the

requested number of frames. Because the example specifies a continuous acquisition, you must

call the stop function to stop the object. Triggering the acquisition —

To acquire data, a video input object must execute a trigger. Triggers can occur in several ways,

depending on how the TriggerType property is configured. For example, if you specify an

immediate trigger, the object executes a trigger automatically, immediately after it starts. If you

specify a manual trigger, the object waits for a call to the trigger function before it initiates data

acquisition. For more information, see Acquiring Image Data.In the example, because the

TriggerType property is set to 'immediate' (the default) and the TriggerRepeat property is set to

Inf, the object automatically begins executing triggers and acquiring frames of data,

continuously.

Bringing data into the MATLAB workspace —The toolbox stores acquired data in a memory

buffer, a disk file, or both, depending on the value of the video input object LoggingMode

property. To work with this data, you must bring it into the MATLAB workspace. To bring

multiple frames into the workspace, use the getdata function. Once the data is in the MATLAB

workspace, you can manipulate it as you would any other data.

Page 80: Wireless Spy Robot With Bject Detection

CHAPTER 5

SOURCE CODE

5.1 Microcontroller code for BOT control

org 00h

te equ p3.2

clr te

mov a,#00h

mov tmod,#20h

mov th1,#-3

mov scon,#50h

setb te

setb tr1

clr ri

next: jnb ri,next

mov a,sbuf

mov p1,a

end

5.2 MATLAB program for object detection:

clear all

clc

vid=videoinput('winvideo',1,'YUY2_640x480');

preview(vid)

set(vid,'FramesPerTrigger',1);

pause(10);

rgb_image=getsnapshot(vid);

Page 81: Wireless Spy Robot With Bject Detection

[a b c]=size('rgb_image');

y=a;

x=b;

x1=x/2-60;

x2=x/2+60;

y1=y/2-40;

y2=y/2+40;

while(1)

rgb_image=getsnapshot(vid);

flushdata(vid);

rbar=0;

cbar=0;

e=0;

z=wavread('Ipl_Trumpet.wav');

load handel

Fs=48000;

p = audioplayer(z, Fs);

fR=rgb_image(:,:,1);

fG=rgb_image(:,:,2);

fB=rgb_image(:,:,3);

I=((fR>=55)&(fG<=125)&(fB<=165)&(fR<=75)&(fG>=115)&(fB>=155));

se=strel('disk',10);

B=imopen(I,se);

final=imclose(B,se);

[L,n]=bwlabel(final);

for k=1:n

[r,c]=find(L==k);

rbar=mean(r);

cbar=mean(c);

e=(((rbar>=x1)*2*2*2)+((rbar<=x2)*2*2)+((cbar>=y1)*2)+(cbar<=y2))

end

Page 82: Wireless Spy Robot With Bject Detection

switch(e)

case 5

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 6

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 7

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 9

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 10

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 11

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 13

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 14

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

case 15

play(p, [1 (get(p, 'SampleRate') * 3)]);

pause(4);

otherwise

disp('Not detected');

end

Page 83: Wireless Spy Robot With Bject Detection

end

CHAPTER 6

CONCLUSIONS AND FUTURE SCOPE

6.1 CONCLUSION: The project “WIRELESS SPY ROBOT WITH OBJECT DETECTION”

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 IC’s and with

the help of growing technology the project has been successfully implemented.

6.2 Future work:

Inspired by colonies of insects such as ants and bees, researchers are modeling the

behavior of swarms of thousands of tiny robots which together perform a useful task, such as

finding something hidden, cleaning, or spying. Each robot is quite simple, but the emergent

behavior of the swarm is more complex. The whole set of robots can be considered as one single

distributed system, in the same way an ant colony can be considered a super organism, exhibiting

swarm intelligence. The largest swarms so far created include the iRobot swarm, the

SRI/MobileRobots CentiBots project and the Open-source Micro-robotic Project swarm, which

are being used to research collective behaviors.[65][66] Swarms are also more resistant to failure.

Whereas one large robot may fail and ruin a mission, a swarm can continue even if several robots

fail. This could make them attractive for space exploration missions, where failure can be

extremely costly.

Page 84: Wireless Spy Robot With Bject Detection

BIBLIOGRAPHY

TEXT BOOKS:

The 8051 Microcontroller and Embedded Systems ,2000

By Muhammad Ali Mazidi and Janice Gillispie Mazidi

Fundamentals of Embedded Software

By Daniel W. Lewis

The 8051/8052 Microcontroller: Architecture, Assembly Language, And Hardware Interfacing

 

By Craig Steiner

Electronics For You Magazine MATLAB Help By Mathworks

WEB SITES:

1. www.alldatasheets.com

2. www.8051 projects.info/projects.asp

3. www.wikipedia.com

4. www.project.spogels.com

Page 85: Wireless Spy Robot With Bject Detection

5. www.projectfreaks.com