+ All Categories
Home > Documents > Gesture Controlled Robot

Gesture Controlled Robot

Date post: 14-May-2017
Category:
Upload: nitesh-arora
View: 223 times
Download: 2 times
Share this document with a friend
64
GESTURE CONTROLLED ROBOT A SUMMER TRAINING PROJECT REPORT Submitted by NITESH KUMAR ARORA Roll No. 01370102810 in partial fulfillment of the requirements for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
Transcript
Page 1: Gesture Controlled Robot

GESTURE CONTROLLED ROBOT

A SUMMER TRAINING PROJECT REPORT

Submitted by

NITESH KUMAR ARORA

Roll No. 01370102810

in partial fulfillment of the requirements for the award of the degree

of

BACHELOR OF TECHNOLOGY

IN

ELECTRONICS AND COMMUNICATION ENGINEERING

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

ANSAL INSTITUTE OF TECHNOLOGY, GURGAON, HARYANA

AFFILIATED TO GGSIP UNIVERSITY, NEW DELHI

Session- 2012- 2013

Page 2: Gesture Controlled Robot

ACKNOWLEDGEMENT

A formal statement of acknowledgment is hardly sufficient to express my gratitude towards the personalities who have helped me to undertake and complete this project.

Training in an organization like which is fuelled by the individuals with so much zest and energy, “teaming” up to form a formidable force, was in itself a true learning experience which is going to help me immensely in my career. I hereby convey my thanks to all those who have rendered their valuable help, support and guidance.

Firstly I would thank Director of Appin Technology Lab, Noida for granting me the permission to work as a Trainee in this esteemed company and for providing me all the facilities.

I am highly thankful to Mr. Vikas Sharma (Trainer and Guider) for helping me to undertake a project in Embedded Systems at this esteem corporate and providing highly valuable technical acumen, constructive criticism and moral support. Lastly, I bow before the almighty with folded hands.

Nitesh Kumar Arora

1

Page 3: Gesture Controlled Robot

ABSTRACT

We are living in the Embedded World. We are surrounded with many embedded products and our daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD player, Washing Machine or Microwave Oven in our kitchen, Card readers, Access Controllers, Palm devices of our work space enable us to do many of our tasks very effectively. Apart from all these, many controllers embedded in our car take care of car operations between the bumpers. All kinds of magazines and journals regularly dish out details about latest technologies, new devices; fast applications which make us believe that our basic survival is controlled by these embedded products. Now we can agree to the fact that these embedded products have successfully invaded into our world. What is this Embedded System?

Theoretically, an embedded controller is a combination of piece of microprocessor based hardware and the suitable software to undertake a specific task.

I have made a Project based on Microcontroller that is GESTURE CONTROLLED ROBOT. Inspired from Dr. Pranav Mistry’s Sixth sense technology, this project makes use of the hand gestures to control the movement of a simple robot. It actually is a small demonstration of the scope of this technology to control the digital devices around us using the natural gestures and help bridge the gap between digital and physical world.

Although the miniaturization of computer devices allows us to carry computers in our pockets, keeping us continually connected to the digital world, there is no link between our digital devices and interactions with physical world.There is a need to come over the monotonous digital routines and this project is a small application of such physical world interaction.

This training report covers all about the microcontroller and project description.

Nitesh Kumar Arora

2

Page 4: Gesture Controlled Robot

CONTENTS

1. Overview of Embedded Systems1.1 Introduction1.2 Characteristics of Embedded Products1.3 Common Embedded Systems in today’s world

2. 8051 MICROCONTROLLER2.1 Introduction2.2 Definition of a Microcontroller2.3 Difference between Microprocessor and Microcontroller2.4 8051 Architecture2.5 Pin Configuration of 80512.6 Reset and Oscillator Clock Circuit2.7 RAM Architecture2.8 Central Processing Unit 2.9 Bus2.10 Input-output unit

3. Interfacing components with 8051 3.1 LIQUID CRYSTAL DISPLAY INTERFACING 3.1.1 Pin Configuration

3.1.2 DDRAM - Display Data RAM3.1.3 BF - Busy Flag3.1.4 Instruction Register (IR) and Data Register (DR) 3.1.5 Interfacing LCD to 80513.1.6 LCD Commands

3.2 7- SEGMENT DISPLAY3.2.1 Introduction3.2.2 Creating Digit Pattern3.2.3 Multi 7 Segment interfacing

3.3 KEYPAD3.3.1 Introduction3.3.2 Constructing a Matrix keypad3.3.3 Scanning a Matrix Keypad3.3.4 Interfacing Matrix keypad

4. PROJECT DESCRIPTION4.1 Introduction

4.1.1 Problem Statement4.1.2 Basic Idea and Principle of The System

4.2 Block Diagram4.3 Flow Chart4.4 Components Description

3

Page 5: Gesture Controlled Robot

4.5 Circuit Diagram4.6 Working of the Circuit4.7 C Coding of the project

5. Conclusion

6. References

4

Page 6: Gesture Controlled Robot

1. EMBEDDED SYSTEMS

1.1 Introduction

An embedded system is a computer system designed for specific control functions within a larger system, often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts.By contrast, a general-purpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems strictly follow a specific function.Whether we are at home or office or on the move, we are always surrounded by embedded systems. Starting from home appliances like TV, washing machine and systems like printer and elevator in workplace to the automobiles and automatic traffic control system are all examples of embedded systems.

“Embedded system is a combination of Hardware and Software Design to meet a specific need with performance in given time frame."Embedded systems contain processing cores that are typically either microcontrollers or digital signal processors (DSP).

Components in Embedded System are:

Hardware Input & Output Software

(Processing)

5

Page 7: Gesture Controlled Robot

1.2 Characteristics of Embedded Products

1. They perform a single set of functions.2. Work in a time constrained environment.3. Provide high performance and reliability.4. Mostly Embedded systems have low cost because they are mass produced in

millions.

1.3 Common Embedded Systems in today’s world

1. TelecomMobile phone systems, modem, routers.

2. Automotive applicationsBraking systems, traction systems, airbag release systems, engine-management units, steer-by-wire systems, cruise control applications.

3. Domestic appliancesDishwashers, televisions, washing machines microwave ovens, Video recorders, security systems, garage door controllers, calculators, digital watches, VCRs, Digital cameras, Remote controls, Treadmills.

4. Robotic Fire fighting robots, Automatic floor cleaner, robotic arm etc.

5. Aerospace applicationsFlight control systems, engine controllers, autopilots, passenger in-flight entertainment systems.

6. Medical equipment Anesthesia monitoring systems, ECG monitors, Pacemakers, Drug delivery systems, MRI scanners.

7. Defense systemsRadar systems, fighter aircraft flight control systems, radio systems, missile guidance systems.

8. Office automationLaser printers, fax machines, pagers, cash registers, gas pumps, credit/debit card readers, thermostats, grain analyzers.

6

Page 8: Gesture Controlled Robot

2. 8051 MICROCONTROLLER

2.1 IntroductionCircumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors, and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer, or what would later be known as a microcontroller came about.

The first microcontroller 8051 was developed by in the year 1981.It was called as a “System on a chip”. Intel refers to it as MCS-51 now.

2.2 Definition of a Microcontroller

A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.

Microcontroller, as the name suggests, are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys etc, where automation is needed.

The key features of microcontrollers include:

High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have on-

chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry.

Field Programmability, Flexibility

7

Page 9: Gesture Controlled Robot

Microcontrollers often use EEPROM or EPROM as their storage device to allow field programmability so they are flexible to use. Once the program is tested to be correct then large quantities of microcontrollers can be programmed to be used in embedded systems.

Easy to Use

Assembly language is often used in microcontrollers and since they usually follow RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:

A Timer module to allow the microcontroller to perform tasks for certain time periods.

A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller.

An ADC to allow the microcontroller to accept analogue input data for processing.

Fig 2.1: A block diagram of Microcontroller

8

Page 10: Gesture Controlled Robot

2.3 Difference between Microprocessor and Microcontroller

Fig 2.2:

A Microprocessor has many support devices like Read only memory, Read-Write memory, Serial interface, Timer, Input/output ports etc. All these support devices are interfaced to microprocessor via a system bus.All support devices in a microprocessor based system are external.  The system bus is composed of an address bus, data bus and control bus.

Fig 2.3:

In Microcontroller, all the support devices like Read only memory, Read – Write memory, Timer, Serial interface, I/O ports are internal. There is no need of interfacing these support devices and this saves a lot of time for the individual who creates the system .A microcontroller is nothing but a microprocessor system with all support devices integrated inside a single chip. There is no need of any external interfacing in a micro controller unless you desire to create something beyond the limit, like interfacing an external memory or DAC/ADC unit etc.

Support devices are external in a microprocessor based system where as support devices are internal for a micro controller. Microcontrollers offer software protection where as microprocessor base system fails to offer a protection system. This is made possible in microcontrollers by locking the on-chip program memory which makes it impossible to read using an external circuit.

9

Page 11: Gesture Controlled Robot

As we need to interface support devices externally in a microprocessor based system, time required to build the circuit will be more, the size will be more and power consumption will be more in a microprocessor based system compared to microcontroller.

2.4 8051 Architecture

Fig 2.4: Internal architecture of 8051 microcontroller

The Intel MCS-51 (commonly referred to as 8051) is a Harvard architecture, single chip microcontroller (µC) series which was developed by Intel in 1980 for use in embedded systems.It is a high performance single chip computer intended for use in sophisticated real time applications such as instrumentation, industrial control and computer peripherals. It provides extra features like interrupts, bit address ability and an enhanced set of instructions, which makes the chip very powerful and cost effective

The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a single package

10

Page 12: Gesture Controlled Robot

8-bit ALU, Accumulator and 8-bit Registers; hence it is an 8-bit microcontroller 8-bit data bus – It can access 8 bits of data in one operation 16-bit address bus – It can access 216 memory locations – 64 KB (65536 locations)

each of RAM and ROM On-chip RAM – 128 bytes (data memory) On-chip ROM – 4 kByte (program memory) Four byte bi-directional input/output port UART (serial port) Two 16-bit Counter/timers Two-level interrupt priority Power saving mode (on some derivatives)

2.5 Pin Configuration of 8051

Fig 2.5: 8051 pin configuration

11

Page 13: Gesture Controlled Robot

Pin Description

Port 0 (pin 32-39) Dual purpose I/O port. In min. component design, it is used as a general purpose I/O port. In larger designs with external memory, it becomes a multiplexed data bus: Low byte of address bus, strobed by ALE. 8-bit instruction bus, strobed by PSEN. 8-bit data bus, strobed by WR and RD.

Port 1 (pin 1-8) As an I/O port: Standard bi-directional port for interfacing to external devices as required for I/O.

Port 2 (pin 21-28) Dual purpose I/O port.As an I/O port: Standard bi-directional general purpose I/O port.Alternate functions: High byte of address bus for external program and data memory accesses

Port 3 (pin 10-17)It is an 8-bit bi-directional I/O port with internal pull-ups. It also serves the functions of various special features of the 80C51

Table of alternate uses of Port- 3 pins: PINS ALTERNATE USE SFR P3.0 RXD Serial data input SBUFP3.1 TXD Serial data output SBUFP3.2 INT0 External Interrupt 0 TCON.1 P3.3 INT1 External Interrupt 1 TCON.3P3.4 T0 External Timer 0 I/P TMODP3.5 T1 External Timer 1 I/P TMODP3.6 WR External Memory write pulse - P3.7 RD External Memory read pulse -

Reset (pin 9): It resets total 8051 micro controller.

XTAL1 & XTAL2 (pin 19 and 18): To connect the crystal oscillator. For 8051 oscillator of 11.0592 MHZ is connected between these pins.

ALE (pin 30):Address latch enable which is used to access the address locations from external memory.

12

Page 14: Gesture Controlled Robot

PSEN (pin 31): Program store enable which is used for storing programming code into the external memory.

EA (pin 29): External Access: 64 KB of ROM is the limit for external memory.If we are not connecting any external memory to micro controller, EA is connected to VCC in case of 8051.

Supply and Ground pins: Pin 40 is for +5V VCC and pin 20 is for GND.

2.6 Reset and Oscillator Clock Circuit

Reset circuit:

Fig 2.6.1: 8051 reset circuit

Reset circuit is employed at pin 9. In order for the RESET input to be effective, it must have a minimum duration of

two machine cycles.

Oscillator Clock circuit:

Fig 2.6.2: 8051 oscillator clock circuit

13

Page 15: Gesture Controlled Robot

Capacitor is storing charge permanently until we use it. Crystal Oscillator is used to generate a carrier signal with stable frequency. With the help of this oscillator we will deduce the execution speed in terms of bytes/ sec. It generates 12 clock pulses /machine cycle. Capacitors provide charge for crystal oscillator.

XTAL1 is at pin 19 and XTAL2 at pin 18. It uses a quartz crystal oscillator. We can observe the frequency on the XTAL2 pin. The crystal frequency is the basic internal frequency of the microcontroller. The internal counters must divide the basic clock rate to yield standard

communication bit per second (baud) rates. An 11.0592 megahertz crystal, although seemingly an odd value, yields a crystal

frequency of 921.6 kilohertz, which can be divided evenly by the standard communication baud rates of 19200, 9600, 4800, 2400, 1200, and 300 hertz.

2.7 RAM Architecture

Fig 2.7: RAM architecture

14

Page 16: Gesture Controlled Robot

The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAM available,

and it is also the most flexible in terms of reading, writing, and modifying its contents.

Internal RAM is volatile, so when the 8051 is reset this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". Three alternative register banks are located in internal RAM in addresses 08h

through 1Fh. Bit memory actually resides in internal RAM, from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be

used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack.

Register BanksThe 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7).These registers are generally used to assist in manipulating values and moving data from one memory location to another. The concept of register banks adds a great level of flexibility to the 8051.

Bit MemoryThe 8051, being a communication oriented microcontroller, gives user the ability to access a number of bit variables. These variables may be either 1 or 0. There are 128 bit variables available to the user, numbered 00h through 7Fh. The user may make use of these variables with commands such as SETB and CLR. It is important to note that Bit Memory is really a part of Internal RAM. In fact, the 128 bit variables occupy the 16 bytes of Internal RAM from 20h through 2Fh.

Special Function Register (SFR) MemorySpecial Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor. For example, four SFRs permit access to the 8051’s 32 input/output lines. Another SFR allows a program to read or write to the 8051’s serial port .SFR is a part of Internal Memory. This is not the case. When using this method of memory access (it’s called direct address), any instruction that has an address of 00h through 7Fh refers to an Internal RAM memory address; any instruction with an address of 80h through FFh refers to an SFR control register.

Special Function Registers

15

Page 17: Gesture Controlled Robot

The Special Function Registers (SFRs) contain memory locations that are used for special tasks.

Each SFR occupies internal RAM from 0x80 to 0xFF.They are 8-bits wide.

The A (accumulator) register or accumulator is used for most ALU operations and Boolean Bit manipulations.

Register B is used for multiplication & division and can also be used for general purpose storage.

PSW (Program Status Word) is a bit addressable register

PC or program counter is a special 16-bit register. It is not part of SFR. Program instruction bytes are fetched from locations in memory that are addressed by the PC.

Stack Pointer (SP) register is eight bits wide. It is incremented before data is stored during PUSH and CALL executions. While the stack may reside anywhere in on-chip RAM, the Stack Pointer is initialized to 07H after a reset. This causes the stack to begin at location 08H.

DPTR or data pointer is a special 16-bit register that is accessible as two 8- bit registers: DPL and DPH, which are used to used to furnish memory addresses for internal and external code access and external data access.

Control Registers: Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON contain control and status bits for the interrupt system.

Timer/Counters and the serial port.

Timer Registers: Register pairs (TH0, TL0) and (TH1, TL1) are the 16-bit registers

Counter registers for Timer/Counters 0 and 1, respectively.

Timers and Counters

Many microcontroller applications require the counting of external events such as the frequency of a pulse train, or the generation of precise internal time delays between computer actions. Both of these tasks can be accomplished using software techniques, but software loops for counting or timing keep the processor occupied so that, other perhaps more important, functions are not done. Hence the better option is to use interrupts & the

16

Page 18: Gesture Controlled Robot

two 16-bit count-up timers. The microcontroller can be programmed for either of the following:

1. Count internal - acting as timer2. Count external - acting as counter

All counter action is controlled by the TMOD (Timer Mode) and the TCON(Timer/Counter Control) registers. TCON Timer control SFR contains timer 1& 2 overflow flags, external interrupt flags, timer control bits, falling edge/low level selector bit etc. TMOD timer mode SFR comprises two four-bit registers (timer-1, timer-0) used to specify the timer/counter mode and operation. The timer may operate in any one of four modes that are determined by modes bits M1 and M0 in the TMOD register:

Timer mode-0: Setting timer mode bits to 00b in the TMOD register results in using the TH register as an 8-bit counter and TL as a 5-bit counter. Therefore mode0 is a 13- bit counter.

Timer mode-1: Mode-1 is similar to mode-0 except TL is configured as a full 8-bit counter when the mode bits are set to 01b in TMOD.

Timer mode-2: Setting the mode bits to 10b in TMOD configures the timer to use only the TL counter as an 8-bit counter. TH is used to hold a value that is loaded into TL every time TL overflows from FFh to 00h. The timer flag is also set when TL overflows.

Timer mode-3: In mode-3, timer-1 simply holds its count, where as timer 0 registersTL0 and TH0 are used as two separate 8-bit counters. TL0 uses the Timer-0 control bits. TH0 counts machine cycles and takes over the use of TR1 and TF1 from Timer-1.

Interrupts

A computer has only two ways to determine the conditions that exist in internal and external circuits. One method uses software instructions that jump to subroutines on the states of flags and port pins. The second method responds to hardware signals, called interrupts that force the program to call a subroutine. The Philips 8051 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in SpecialFunction Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once. Each interrupt forces the processor to jump at the interrupt location in the memory. The interrupted program must resume operation at the instruction where the

17

Page 19: Gesture Controlled Robot

interrupt took place. Program resumption is done by storing the interrupted PC address on to stack. RETI instruction at the end of ISR will restore the PC address.

“An interrupt is a special feature which allows the 8051 to provide the illusion of "multitasking," although in reality the 8051 is only doing one thing at a time.”

Addressing Modes

An "addressing mode" refers to how you are addressing a given memory location. The addressing modes are as follows,With an example of each:Immediate Addressing MOV A, #20hDirect Addressing MOV A, #30hIndirect Addressing MOV A, @R0External Direct MOVX A, @DPTRCode Indirect MOVC A, @A+DPTREach of these addressing modes provides important flexibility.

2.8 Central Processing Unit

Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

Fig 2.8: Simplified central processing unit with three registers

18

Page 20: Gesture Controlled Robot

Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another.

2.9Bus

That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires.There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

Fig 2.9: Showing connection between memory and central unit using buses

As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component.

19

Page 21: Gesture Controlled Robot

2.10 Input-output unit

. There are several types of ports: input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

Figure2.10: Simplified input-output unit communicating with external world

When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller.

8051 has bidirectional I/0 ports. To specify a port as input port set all the 8 bits of that port high. Eg: to make P1 as input port,

MOV P1, #11111111b or P1=0x0ff;

To specify a port as output port set all the 8 bits of that port as low.Eg: to make P2 as output port,

MOV P2, #00000000b or P2=0x00;

20

Page 22: Gesture Controlled Robot

3. INTERFACING COMPONENTS WITH 8051

3.1 LIQUID CRYSTAL DISPLAY INTERFACING

3.1.1 Pin Configuration

Fig 3.1: Pin configuration for 16 X 2 LCD

LCD stands for Liquid Crystal Display. The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters

8 data pins D7:D0Bi-directional data/command pins. Alphanumeric characters are sent in ASCII format.

 RS:  Register Select RS = 0 Command Register is selected RS = 1 Data Register is selected

R/W: Read or Write0 Write, 1 Read E: Enable (Latch data)Used to latch the data present on the data pins.A high-to-low edge is needed to latch the data. VEE: contrast control.

3.1.2 DDRAM - Display Data RAMDisplay data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM

21

Page 23: Gesture Controlled Robot

(DDRAM) that is not used for display can be used as general data RAM. So whatever you send on the DDRAM is actually displayed on the LCD.

3.1.3 BF - Busy FlagBusy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay for the LCD processing. To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process.

3.1.4 Instruction Register (IR) and Data Register (DR) There are two 8-bit registers controller, Instruction and Data register. Instruction register corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data which is to be displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the data register and data is then moved automatically to the DDRAM and hence is displayed on the LCD.

3.1.5 Interfacing LCD to 8051The LCD requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total of 11 data lines. The three control lines are  EN, RS, and RW. Note that the EN line must be raised/lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or write, text or instruction EN is the LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines.

3.1.6 LCD Commands

Commands and Instruction setOnly the instruction register (IR) and the data register (DR) of the LCD can be controlled by the MCU. Before starting the internal operation of the LCD, control information is temporarily stored into these registers to allow interfacing with various MCUs, which operate at different speeds, or various peripheral control devices. The internal operation of the LCD is determined by signals sent from the MCU.

Sending Commands to LCDTo send commands we simply need to select the command register. Everything is same as we have done in the initialization routine. But we will summarize the common steps and put them in a single subroutine.

22

Page 24: Gesture Controlled Robot

Following are the steps:1. Move data to LCD port2. Select command register3. Select write operation4. Send enable signal

5. Wait for LCD to process the command

Fig 3.2: LCD interfacing with 8051

3.2 7- SEGMENT DISPLAY

3.2.1 Introduction

The 7 segment display can also be used for displaying numbers. Each of the segments of the display is connected to a pin on the 8051.For active low, In order to light up a segment on the pin must be set to 0V. To turn a segment off the corresponding pin must be set to 5V. This is simply done by setting the pins on the 8051 to '1' or '0'. LED displays are Power-hungry (10mA per LED) and Pin-hungry (8 pins per 7-seg display). But they are cheaper than LCD display.

23

Page 25: Gesture Controlled Robot

Fig 3.3: 7 Segment Display

7-SEG Display is available in two types – Common anode & Common cathode,  but common anode display are most suitable for interfacing with 8051 since 8051 port pins can sink current better than sourcing it.

Fig 3.4: One 7 Segment Display interfacing with 8051

24

Page 26: Gesture Controlled Robot

3.2.2 Creating Digit PatternIn Common Anode display, the common Anode pin is tied to 5V .The cathode pins are connected to port 1 through 330 Ohm resistance (current limiting). For displaying Digit say 7 we need to light segments - a ,b, c. in Common anode display , to do so we have to provide  Logic0 (0V) at cathode of  these segments. So need to clear pins- P1.0, P1.1, P1.2.   that is 1 1 1 1 1 0 0 0 F8h

Digit Seg. h Seg. g Seg. f Seg. e Seg. d Seg. c Seg. b Seg. a HEX

0 1 1 0 0 0 0 0 0 C0

1 1 1 1 1 1 0 0 1 F9

2 1 0 1 0 0 1 0 0 A4

3 1 0 1 1 0 0 0 0 B0

4 1 0 0 1 1 0 0 1 99

Table 3.1: Hex code for displaying various digits

3.2.3 Multi 7 Segment interfacing Since we can enable only one 7-seg display at a time, we need to scan these display at fast rate .The data lines are common for all the 4 segments .The scanning frequency should be high enough to be flicker-free. At least 30HZ .Therefore: time one digit is ON is 1/30 seconds.

All the seven segments are connected in a parallel fashion with common data lines. So this can be realized with a single port of 8051. The enable pins of various seven-segments can be connected to the pins of other I/O port.

Due to constraint of the no. of I/O ports in the 8051 microcontroller this method is very effective.

The figure of such method is shown on the next page.

25

Page 27: Gesture Controlled Robot

Fig 3.5: Interfacing multi 7-segment display with 8051

3.3 KEYPAD

3.3.1 IntroductionKeypads are a part of HMI or Human Machine Interface and play really important role in a small embedded system where human interaction or human input is needed. Matrix keypads are well known for their simple architecture and ease of interfacing with any microcontroller.

3.3.2 Constructing a Matrix keypad

Construction of a keypad is really simple. As per the outline shown in the figure below we have four rows and four columns. In between each overlapping row and column line there is a key.

26

Page 28: Gesture Controlled Robot

Fig 3.6: A simple matrix keypad

So keeping this outline we can construct a keypad using simple SPST Switches as shown below:

3.3.3 Scanning a Matrix Keypad

There are many methods depending on how you connect your keypad with your controller, but the basic logic is same. We make the columns as i/p and we drive the rows making them o/p, this whole procedure of reading the keyboard is called scanning.

In order to detect which key is pressed from the matrix, we make row lines low one by one and read the coloums. Lets say we first make Row1 low, then read the columns. If any of the key in row1 is pressed will make the corresponding column as low i.e if second key is pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done.

So to scan the keypad completely, we need to make rows low one by one and read the columns. If any of the buttons is pressed in a row, it will take the corresponding column to a low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column 1 will become low, if button 2 then column2 and so on...

27

Page 29: Gesture Controlled Robot

3.3.4 Interfacing Matrix keypad

Fig 3.7: Matrix keypad interfacing with microcontroller

28

Page 30: Gesture Controlled Robot

4. PROJECT DESCRIPTION

4.1 INTRODUCTION

Currently the robot movements are usually controlled by buttoned remotes or by providing the signals through a computer.This project demonstrates how control the robot using hand gestures instead of old fashioned buttons.It actually shows the scope of this technology to control the digital devices around us using the natural gestures and help bridge the gap between digital and physical world.

4.1.1 Problem Statement

The control of the robot is intended in the following manner:

Pull down wrist movement: Forward movement of robot.

Pull up wrist movement: Backward movement of robot.

Right wrist movement: Movement of robot towards right.

Left wrist movement: Movement of robot towards left

4.1.2 Basic Idea and principle of the system

The Basic idea of the system is to convert the hand gestures into digital data which can then be used to do a certain task, mechanical or electrical. Here we are using the hand gestures to control the movement of a simple robot car.

The system is divided into two modules:1. Transmission module2. Receiver module

The transmission module consists of an accelerometer planted on the wrist of the person and the main circuit board consisting of the transmitter on the arm of the person. The transmission module will convert the hand gestures into digital data, encode it and transmit it to the receiving module.

The receiver module consists of a receiver, the controlling unit and the motors to drive the robot.

29

Page 31: Gesture Controlled Robot

The receiver module will receive the data, decode it and drive the robot accordingly.

Fig 4.1: The basic idea of the system

So ultimately the project transforms the hand gestures into movement of the robot.

30

Page 32: Gesture Controlled Robot

4.2 BLOCK DIAGRAM

Transmitter Section:

Fig 4.2: Transmitter section block diagram

Receiver Section:

Fig 4.3: Receiver section block diagram

31

Accelerometer

Comparator IC

LM 324

Encoder ICHT 12E

RF Transmitter

Decoder ICHT 12D

8051 Microcontrolle

r

Motor Driving IC -

L293D

RF Receiver Motors

Hand movements

Page 33: Gesture Controlled Robot

4.3 FLOW CHART

32

Convert the hand movement into 4 bit parallel data using Comparator IC

Start

Encode the 4 bit parallel data into serial using Encoder IC

Transmit the Serial Data using RF transmitter

Analog voltage across accelerometer proportional to the movement of hand

Receive the serial data using RF receiver

Serial data in accordance with hand movemements

Decode the serial data into 4 bit parallel data

Feed the data into microcontroller and take decision based on input.

Drive the motors

Stop

Page 34: Gesture Controlled Robot

4.4 COMPONENTS DESCRIPTION

In the Transmitter section, following major components are used:

1. Power Supply Circuit

2. Accelerometer

3. LM 324 - Comparator IC

4. HT12E – Encoder IC

5. RF Transmitter

Power Supply Circuit

The power supply section consists of step down transformers of 230V primary to 9V secondary voltages for the +5V power supply. The stepped down voltage is then rectified by 4 1N4007 diodes. The high value of capacitor 1000 μF charges at a slow rate as the time constant is low, and once the capacitor charges there is no resistor for capacitor to discharge. This gives a constant value of DC.

IC 7805 is used for regulated supply of +5 volts in order to prevent the circuit ahead from any fluctuations. The filter capacitors connected after this IC filters the high frequency spikes. These capacitors are connected in parallel with supply and common so that spikes filter to the common. These give stability to the power supply circuit. As can be seen from the circuit diagram, the rectified voltage from the 4 diodes is given to pin 1 of the 7805 regulators. Pin 2 of the regulator is connected to ground and pin 3 to Vcc. With adequate heat sinking the regulator can deliver 1A output current. If internal power dissipation becomes too high for the heat sinking provided, the thermal shutdown circuit takes over preventing the IC from overheating.

33

Page 35: Gesture Controlled Robot

Fig 4.4: +5V Power Supply Circuit

Accelerometer ADLX 335

It detects motion, vibration, and angle with respect to gravity. Inside this commonly available MEMS are tiny nano-structures that bend due to momentum and gravity. When these MEMS experiences any form of acceleration (gravity is a downward acceleration) the tiny structures bend by an amount which can be electrically detected. This means accelerometers can be used to detect and/or control for vibration of a device, acceleration of a robot actuator, or even the angle of the accelerometer with respect to gravity.

This accelerometer gives us analog voltage proportional to all angle of accelerometer in all the three axis, X,Y and Z axis.

The Accelerometer is having 6 pins1- VDD- We will give the +5volt to this pin2- GND- We will simply connect this pin to the ground for biasing.3- X- On this pin we will receive the analog data for x direction movement.4- Y- On this pin we will receive the analog data for y direction movement.5- Z- On this pin we will receive the analog data for z direction movement.6- ST- this pin is use to set the sensitivity of the accelerometer 1.5g/2g/3g/4g.

34

Page 36: Gesture Controlled Robot

LM 324 – Comparator IC

Comparator is a device which compares two input voltages and gives output as high or low.

Properties of comparator:

If V+ > V- , thenVo= Vsat (Digital High 1 output)

If V+ < V- , thenVo=0 (Digital Low 0 output)

Fig 4.5: A Comparator

Examples:

35

Page 37: Gesture Controlled Robot

LM 324 is a Four Comparator IC.

Fig 4.6: LM 324 Pin Diagram

HT12E – Encoder IC

HT 12E is an encoder which encodes the data applied on it

It has 8 address and 4 data /address pins

36

Page 38: Gesture Controlled Robot

Fig 4.7: HT12E Pin Diagram

Pin Number Pin Name Description

1-8 A0-A7 Address bits

9 GND Supply Ground

18 VCC +5V supply for IC

14 ~TE Transmission enable, active low

10-13 AD8- AD11 The 4 bit input is applied here

15-16 OSC2 and OSC1 Connected by an oscillator resistor 1.1 M ohm

17 DOUT The encoded output.

Table 4.1: Pin description of HT12E IC

RF Transmitter

An RF transmitter receives serial data and transmits it wirelessly through RF through its antenna connected at pin4.

The transmission occurs at the rate of 1Kbps - 10Kbps. It operates at a frequency of 434 MHz.

Pin Number

Pin Name Description

1 GND Supply ground

2 Data Serial Data Input

3 VCC +5V supply

4 Antenna o/p Antenna for transmission

37

Page 39: Gesture Controlled Robot

Table 4.2: Pin description of RF transmitter.

Fig 4.8: RF transmitter pin diagram

In the Receiver section, following major components are used:

1. Power Supply Circuit

2. RF Receiver

3. HT12D – Decoder IC

4. 8051 Microcontroller (P89v51RD2)

5. L293D – Motor Driver IC

RF Receiver

It receives the data transmitted by the RF transmitter.

Fig 4.9: RF Receiver pin diagram

38

Page 40: Gesture Controlled Robot

Pin Number

Pin Name Description

1,6,7 GND Supply ground

2 Data Serial Data Output.Data is received here.

4,5 VCC +5V supply

8 Antenna o/p

Antenna for reception

Table 4.3: Pin description of RF receiver.

HT12D – Decoder IC

HT12D converts serial data received to parallel data. The input data is decoded when no error or unmatched codes are found. A valid

transmission in indicated by a high signal at VT (pin 17).

39

Page 41: Gesture Controlled Robot

Fig 4.10: HT12D Pin diagram

Pin

Number

Pin Name Description

1-8 A0-A7 Address bits

9 GND Supply Ground

18 VCC +5V supply for IC

14 DIN Data IN. Serial Input pin

10-13 D8- D11 The 4 bit output data is received here.

15-16 OSC2 and

OSC1

Connected by an oscillator resistor 51K ohm

17 VT It is the valid transmission pin. It will high when the transmission is error-free.

Table 4.4: Pin description of HT12D IC

8051 Microcontroller (P89V51RD2)

40

Page 42: Gesture Controlled Robot

Criteria for choosing a microcontroller:

The basic criteria for choosing a microcontroller suitable for the application are:

1) The first and foremost criterion is that it must meet the task at hand efficiently andcost effectively. In analyzing the needs of a microcontroller-based project, it is seenwhether an 8- bit, 16-bit or 32-bit microcontroller can best handle the computingneeds of the task most effectively. Among the other considerations in this categoryare:a) Speed: The highest speed that the microcontroller supports.b) Packaging: It may be a 40-pin DIP (dual inline package) or a QFP (quad flat package), or some other packaging format. This is important in terms of space, assembling, and prototyping the end product.c) Power consumption: This is especially critical for battery-powered products.d) The number of I/O pins and the timer on the chip.e) How easy it is to upgrade to higher –performance or lower consumption versions.f) Cost per unit: This is important in terms of the final cost of the product in which a microcontroller is used.

2) The second criterion in choosing a microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, compiler, technical support.

3) The third criterion in choosing a microcontroller is its ready availability in needed quantities both now and in the future. Currently of the leading 8-bit microcontrollers, the 8051 family has the largest number of diversified suppliers. By supplier is meant a producer besides the originator of the microcontroller. In the case of the 8051, this has originated by Intel several companies also currently producing the 8051. Thus the microcontroller P89V51RD2, satisfying the criterion necessary for the proposed application is chosen for the task.

4) Also P89V51RD2 provides ease In-System programming.

The pin diagram and other specifications have been discussed earlier in Chapter 2.

41

Page 43: Gesture Controlled Robot

L293D – Motor Driver IC (Actuator)

Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors.

In L293D’s common mode of operation, two DC motors can be driven simultaneously, both in forward and reverse direction.

The motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15.

Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and anticlockwise directions, respectively.

Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating. When an enable input is high, the associated driver gets enabled. When the enable input is low, that driver is disabled.

Fig 4.11: L293D Pin diagram

42

Page 44: Gesture Controlled Robot

Pin

Number

Pin Name Description

1 Enable1,2 Enable pin for Motor 1; active high

2 Input 1 Input 1 for Motor 1

3 Output 1 Output 1 for Motor 1

4 GND Ground

5 GND Ground

6 Output2 Output2 for Motor 1

7 Input 2 Input 2 for Motor 1

8 Motor Supply(VCC2) Supply voltage for Motors; 12V

9 Enable 3,4 Enable pin for Motor 2; active high

10 Input 3 Input 3 for Motor 2

11 Output 3 Output 3 for Motor 2

12 GND Ground

13 GND Ground

14 Output 4 Output 4 for Motor 2

15 Input 4 Input 4 for Motor 2

16 VCC1 Supply voltage; +5V

Table 4.5: Pin description of L293D

43

Page 45: Gesture Controlled Robot

4.5 CIRCUIT DIAGRAM

Transmitter Section:

44

Page 46: Gesture Controlled Robot

2. Receiver Section:

45

Page 47: Gesture Controlled Robot

4.6 Working of the Circuit

46

Page 48: Gesture Controlled Robot

The Accelerometer gives analog voltage proportional to the movement related to the data.

This voltage is fed to LM 324IC.The X pin output is fed to pin 3 and 6 and Y output voltage to pin 12 and 9. Reference Voltages are set in such a way that only one comparator output is one during one hand movement. In stable position, outputs of both X and Y pins of ADLX335 are 1.6V.

Vref1 = 1.7 V , Vref2=1.5 V , Vref3= 1.7 V , Vref4=1.5 V.

The 4 bit data generated is fed to the Encoder IC HT12E at pins 10 to 13, 10 being the MSB. The serial output is obtained at pin 17.

This serial data from pin 17 of encoder is fed to DATA pin of the RF transmitter. The data at receiver side is received by RF receiver and fed to pin 14 of HT12D;

decoder IC. The parallel data from HT12D is obtained at pins 10 to 13, 13 being the MSB. The parallel data is sent to the controller P89v51RD2.

Port 1 of the controller is made the input port.Port 2 is made the output port.

The controller takes the input, and makes the decision accordingly, sending data to port2.

The port2 output is connected to actuator L293D IC which derives the motor accordingly.

4.7 C Coding of the project

47

Page 49: Gesture Controlled Robot

#include<reg51.h>

int main(){

P1=0x0ff; // P1 as input portP2=0x00; // P2 as output port

while(1){

if(P1==0xf8) //forwardP2=0x0a;

else if(P1==0xf4) //backwardP2=0x05;

else if(P1==0xf2) //leftP2=0x02;

else if(P1==0xf1) //rightP2=0x08;

elseP2=0x00; //stop

}}

5. Conclusion

48

Page 50: Gesture Controlled Robot

With the completion of this training, I am now aware of the Microcontroller 8051. I have worked for six complete weeks in the Embedded systems. I have worked almost as an engineer to the extent of my technical capabilities. Doing all these, I have acquired a lot of knowledge about the working of Microcontroller with Embedded C Programming and it’s Softwares (Keil and Flash Magic).I was the part of one of the most happening and demanding field of electronics i.e. 8051 Microcontroller started by Intel and spending six weeks into it really proved very useful to me and I have gained a lot out of it :

1 I got the knowledge of uC 8051 2 I worked practically on the softwares Keil Uvision, Flash Magic, Topview

Simulator. 3 I worked practically which helped me in being more familiar to the interfacing of

different display devices which I am supposed to do in the long run.4 I learned basic concepts of electronics which helped me to understand more.5 Training helped me increasing my working skills and the knowledge in this field

and also showed me the atmosphere that we have to join after completion of the degree program.

Finally, the main advantage of this training was that it has now enabled me to explore myself in the giant Robotic industry.

The project overtaken inspires me to research more in this technology and work on similar projects involving the use of gestures.Although the miniaturization of computer devices allows us to carry computers in our pockets, keeping us continually connected to the digital world, there is no link between our digital devices and interactions with physical world.There is a need to come over the monotonous digital routines and this project is a small application of such physical world interaction.

REFERENCES

49

Page 51: Gesture Controlled Robot

This report has been compiled with valuable contribution from:

Books:

Muhammed Ali Mazidi, Janice Gillispie Mazidi and Rolin D.McKinlay

Web resources:

www.8051projects.comwww.rickeysworld.comwww.electronics4u.comwww.projectsguide.com

50


Recommended