Major project report

72
A Major Project ON TV REMOTE AS A CORDLESS MOUSE Submitted in partial fulfillment of the requirements for the Degree of Bachelor of Engineering in Electronics & Communication Submitted to: RAJIV GANDHI PROUDYOGIKI VISHWAVIDHYALAYA, BHOPAL (M.P.) Submitted by PRAVEEN SINGH (0191EC101070) PRASHANT SONI(0191EC101069) TUSHAR SAHU(0191EC101113) PRAFUL TAJNE(0191EC101067) Under the Guidance of Prof. Archana Sharma Prof. Hema Singh EC Department Head of EC Department DEPARTMENT OF ELECTRONICS & COMMUNICATION TECHNOCRATS INSTITUTE OF TECHNOLOGY (EXCELLENCE), BHOPAL SESSION: 2013-2014

Transcript of Major project report

Page 1: Major project report

A

Major Project

ON

TV REMOTE AS A CORDLESS MOUSE

Submitted in partial fulfillment of the requirements for the

Degree of

Bachelor of Engineering in Electronics & Communication

Submitted to:

RAJIV GANDHI PROUDYOGIKI VISHWAVIDHYALAYA,

BHOPAL (M.P.)

Submitted by

PRAVEEN SINGH (0191EC101070)

PRASHANT SONI(0191EC101069)

TUSHAR SAHU(0191EC101113)

PRAFUL TAJNE(0191EC101067)

Under the Guidance of

Prof. Archana Sharma Prof. Hema Singh

EC Department Head of EC Department

DEPARTMENT OF ELECTRONICS & COMMUNICATION

TECHNOCRATS INSTITUTE OF TECHNOLOGY (EXCELLENCE),

BHOPAL

SESSION: 2013-2014

Page 2: Major project report

TECHNOCRATS INSTITUTE OF TECHNOLOGY

(EXCELLENCE), BHOPAL

CERTIFICATE

This is to certify that the work embodies in this major project work entitled “TV

REMOTE AS A CORDLESS MOUSE” being submitted by PRAVEEN SINGH

(0191EC101070), PRASHANT SONI (0191EC101069), TUSHAR

SAHU(0191EC101113), PRAFUL TAJNE (0191EC101067) in partial fulfillment

of the requirement for the award of Bachelor of Engineering in Electronics &

Communication Engineering to Rajiv Gandhi Proudyogiki Vishwavidyalaya, Bhopal

( M.P.) during the academic year 2013-14 is a record of bonafide piece of work,

carried out by Prof. Archana Sharma under my supervision and guidance in the

Electronics And Communication Engineering, Technocrats Institute of

Technology(Excellence), Bhopal.

Prof. Archana Sharma Prof. Hema Singh

EC Department Head of Department

Electronics & Communication

Page 3: Major project report

TECHNOCRATS INSTITUTE OF TECHNOLOGY

(EXCELLENCE), BHOPAL

ELECTRONICS AND COMMUNICATION DEPARTMENT

DECLARATION

We, PRAVEEN SINGH, PRASHANT SONI, TUSHAR SAHU, PRAFUL

TAJNE students of BACHELOR of ENGINEERING in (ELECTRONICS &

COMMUNICATION), Session 2013-14 Technocrats Institute of Technology

(Excellence), Bhopal M.P., here by declare that the work presented in this project

Report entitled “TV REMOTE AS CORDLESS MOUSE” is the outcome of our

own work, is bonafide and correct to the best of our knowledge and this work has

been carried out taking care of Engineering Ethics.

PRAVEEN SINGH (0191EC101070)

PRASHANT SONI (0191EC101069)

TUSHAR SAHU (0191EC101113)

PRAFUL TAJNE (0191EC101067)

Date :

Page 4: Major project report

ACKNOWLEDGEMENT

I deem it’s my privilege to extent my profound gratitude and appreciation towards all

those who have directly or indirectly involved themselves in making this project a

great success, It gives me immense pleasure to express my deepest sense of gratitude

and sincere thanks to my respected guide Prof. Archana Sharma, for their valuable

guidance encouragement and help for this work.

I express my deep sense of gratitude to Prof. Archana Sharma, for his keen intrest,

continued encouragement and support.

I would also like to express my sincere thanks to Dr Asif Ullah Khan Director of

Technocrats Institute of Technology (Excellence),Bhopal, Prof. Hema Singh Head of

Department Electronics & Communication for providing me with all the moral

support and necessary help. My sincere appreciation and thanks to all for keen

interest, continued encouragement and support my family members and friends.

PRAVEEN SINGH (0191EC101070)

PRASHANT SONI (0191EC101069)

TUSHAR SAHU (0191EC101113)

PRAFUL TAJNE (0191EC101067)

Page 5: Major project report

TABLE OF CONTENTS

CONTENTS PAGE NO.

ABSTRACT I

LIST OF FIGURES II

LIST OF TABLES IV

1. INTRODUCTION TO EMBEDDED SYSTEMS

1.1 WHAT IS EMBEDDED SYSTEM ? 1

1.2 SYSTEM DESIGN CALLS 1

1.3 EMBEDDED SYSTEM DESIGN CYCLE 2

1.4 CHARACTERISTICS OF EMBEDDED SYSTEM 2

1.5 APPLICATIONS 3

1.6 CLASSIFICATION 3

1.7 HARD REAL TIME RESPONSE 3

2. BLOCK DIAGRAM EXPLANATION

2.1 EXPLANATION 4

3. HARDWARE REQUIREMENTS

3.1 HARDWARE COMPONENTS 5

3.2 TRANSFORMER 6

3.3 VOLTAGE REGULATOR (LM7805) 8

3.4 FILTER 10

3.5 RECTIFIER 11

3.6 PIC MICROCONTROLLER (16F877A) 12

3.7 TSOP1738 15

3.8 MAX232 17

3.9 DB9 CONNECTOR 19

3.10 LED 21

3.11 IN4007 DIODE 23

3.12 RESISTOR 25

3.13 CAPACITOR 27

Page 6: Major project report

4. SOFTWARE REQUIREMENTS

4.1 WHAT IS MPLAB IDE? 35

4.2 DESCRIPTION OF EMBEDDED SYSTEM 35

4.3 COMPONENTS OF MICROCONTROLLER 35

4.4 THE DEVELOPMENT CYCLE 38

4.5 PROJECT MANAGER 38

4.6 DEVICE PROGRAMMING 39

4.7 COMPONENTS OF MPLAB IDE 40

4.8 MPLAB IDE FEATURES AND INSTALLATION 42

4.9 EMBEDDED C 49

5. SCHEMATIC DIAGRAM

5.1 DESCRIPTION 50

5.2 OPERATION 51

6. LAYOUT

6.1 LAYOUT DIAGRAM 53

7. MICROCONTROLLER PROGRAMMING

7.1 CODING 54

8. HARDWARE TESTING

8.1 CONTINUITY TEST 58

8.2 POWER ON TEST 59

9. RESULT AND CONCLUSION

9.1 RESULT 60

9.2 CONCLUSION 60

10. ADVANTAGES AND FUTURE SCOPE

10.1 ADVANTAGES 61

10.2 FUTURE SCOPE 61

REFERENCES 62

Page 7: Major project report

ABSTRACT

The project is designed to use a TV remote as a cordless mouse for the computer. A

conventional PC/laptop uses a mouse to operate and control all its applications. As a

PC mouse is wired to the system, one has to sit near the PC to operate it. This

becomes very tedious when the PC is used for presentation purposes (when using a

projector). In this proposed system TV remote can be used as a cordless mouse, and

the user need not operate the PC sitting near it.

A typical TV remote sends coded infrared data that is read by an IR sensor interfaced

to an 8051 family microcontroller. This data so received by the microcontroller sends

it to the COM port of a PC through a level shifter IC. This IR code is traditionally

RC5 code as followed by some manufacturers. Mouse Driver is used on the PC that

recognizes data received from the microcontroller through the COM port and

performs the required operation. Designated numbers on the TV remote are used to

perform up - down, right - left cursor movement. Features like left click and right

click of the mouse can also be performed with of the TV remote.

Further this project can be enhanced using Bluetooth/ RF technology to overcome the

traditional line of sight communication drawbacks of the infrared type.

I

Page 8: Major project report

LIST OF FIGURES

CONTENTS PAGE NO.

1. System design calls 1

2. V Diagram 2

3. Block Diagram 4

4. A Typical Transformer 6

5. Ideal Transformer as a Circuit Element 7

6. 7805 Voltage Regulator 8

7. 7805 Internal Block Diagram 9

8. Rectifier Circuit 10

9. Filter Circuit 11

10. PIC16F877A PIN Diagram 12

11. TSOP 15

12. Block Diagram of TSOP 16

13. MAX232 PIN Diagram 18

14. DB9 Connector 19

15. Interfacing Between the Microcontroller and DB9 Connector 21

16. Symbol of LED 22

17. White LED Spectrum 23

18. IN4007 Diodes 24

19. PN Junction Diodes 24

20. Resistors 27

21. Capacitors 28

22. Capacitor - Theory of Operation 29

23. A simple demonstration of a parallel-plate capacitor 31

24. Parallel Plate Model 33

25. Several capacitors in parallel 34

26. Several capacitors in series 34

II

Page 9: Major project report

27. PICmicro MCU Data Sheet Instructions 37

28. MPLAB IDE Desktop 42

29. Selecting Device Dialog 43

30. Project Wizard Select Device 44

31. Project Wizard Select Language Tools 45

32. Project Wizard Name 45

33. Project Wizrd Select Template File 46

34. Project Wizard Select Linker Script 46

35. Project Wizard Summary 47

36. Project Window 47

37. Output Window 48

38. Project Context Menu 49

39. Schematic Diagram 50

40. Layout Diagram 53

III

Page 10: Major project report

LIST OF TABLES

CONTENTS PAGE NO.

1. Rating of Voltage Regulator 9

2. MAX232 Voltage Levels 17

3. MAX232 PIN Description 18

4. DB9 PIN Description 20

IV

Page 11: Major project report

1. INTRODUCTION TO EMBEDDED SYSTEMS

1.1 WHAT IS EMBEDDED SYSTEM ?

An Embedded System is a combination of computer hardware and software, and

perhaps additional mechanical or other parts, designed to perform a specific function.

An embedded system is a microcontroller-based, software driven, reliable, real-time

control system, autonomous, or human or network interactive, operating on diverse

physical variables and in diverse environments and sold into a competitive and cost

conscious market.

An embedded system is not a computer system that is used primarily for processing,

not a software system on PC or UNIX, not a traditional business or scientific

application. High-end embedded & lower end embedded systems. High-end

embedded system - Generally 32, 64 Bit Controllers used with OS. Examples

Personal Digital Assistant and Mobile phones etc . Lower end embedded systems -

Generally 8,16 Bit Controllers used with an minimal operating systems and hardware

layout designed for the specific purpose.

1.2 SYSTEM DESIGN CALLS

Fig. 1.2(a) System design calls

1

Page 12: Major project report

1.3 EMBEDDED SYSTEM DESIGN CYCLE

Fig. 1.3(b) V Diagram

1.4 CHARACTERISTICS OF EMBEDDED SYSTEM

An embedded system is any computer system hidden inside a product other than a

computer.

They will encounter a number of difficulties when writing embedded system

software in addition to those we encounter when we write applications

– Throughput – Our system may need to handle a lot of data in a short period of

time.

– Response–Our system may need to react to events quickly

– Testability–Setting up equipment to test embedded software can be difficult

– Debugability–Without a screen or a keyboard, finding out what the software is

doing wrong (other than not working) is a troublesome problem

– Reliability – embedded systems must be able to handle any situation without

human intervention

– Memory space – Memory is limited on embedded systems, and you must

make the software and the data fit into whatever memory exists

– Program installation – you will need special tools to get your software into

embedded systems

– Power consumption – Portable systems must run on battery power, and the

software in these systems must conserve power

2

Page 13: Major project report

– Processor hogs – computing that requires large amounts of CPU time can

complicate the response problem.

– Cost – Reducing the cost of the hardware is a concern in many embedded

system projects; software often operates on hardware that is barely adequate

for the job.

Embedded systems have a microprocessor/ microcontroller and a memory. Some

have a serial port or a network connection. They usually do not have keyboards,

screens or disk drives.

1.5 APPLICATIONS

1) Military and aerospace embedded software applications

2) Communicat ion Appl icat ions

3) Indus tr ial automation and process cont rol software

4) Mastering the complexity of applications.

5) Reduction of product design time.

6) Real time processing of ever increasing amounts of data.

7) Intelligent, autonomous sensors.

1.6 CLASSIFICATION

Real Time Systems.

RTS is one which has to respond to events within a specified deadline.

A right answer after the dead line is a wrong answer

1.6.1 RTS Classification

Hard Real Time System

Soft Real Time System

1.7 HARD REAL TIME SYSTEM

"Hard" real-time systems have very narrow response time.

Example: Nuclear power system, Cardiac pacemaker.

3

Page 14: Major project report

2. BLOCK DIAGRAM

Fig. 2 Block Diagram

2.1 EXPLANATION

Transformer step down the ac voltage and than passes to the rectifier circuit. Rectifier

Circuit convert ac voltage into dc voltage. 7805 Voltage Regulator provides a

constant dc supply to the IR receiver (TSOP1738), Microcontroller (PC16F877A), PC

Interface, LED. TV remote radiates Infrared signals which are captured by the IR

Receiver.Output of this receiver passes to the microcontroller. Now it provides a

specific instructions to the PC by using PC interface.

4

Page 15: Major project report

3. HARDWARE REQUIREMENTS

3.1 HARDWARE COMPONENTS:

1. TRANSFORMER (230 – 12 V AC)

2. VOLTAGE REGULATOR (LM 7805)

3. FILTER

4. RECTIFIER

5. PIC 16F877A

6. TSOP1738

7. MAX232

8. DB9 CONNECTOR

9. LED

10. 1N4007 DIODE

11. RESISTOR

12. CAPACITOR

5

Page 16: Major project report

3.2 TRANSFORMER

Transformers convert AC electricity from one voltage to another with a little loss of

power. Step-up transformers increase voltage, step-down transformers reduce voltage.

Most power supplies use a step-down transformer to reduce the dangerously high

voltage to a safer low voltage.

Fig. 3.2(a) A Typical Transformer

The input coil is called the primary and the output coil is called the secondary. There

is no electrical connection between the two coils; instead they are linked by an

alternating magnetic field created in the soft-iron core of the transformer. The two

lines in the middle of the circuit symbol represent the core. Transformers waste very

little power so the power out is (almost) equal to the power in. Note that as voltage is

stepped down and current is stepped up.

The ratio of the number of turns on each coil, called the turn’s ratio, determines the

ratio of the voltages. A step-down transformer has a large number of turns on its

primary (input) coil which is connected to the high voltage mains supply, and a small

number of turns on its secondary (output) coil to give a low output voltage.

Turns Ratio = (Vp / Vs) = ( Np / Ns )

Where,

Vp = primary (input) voltage.

Vs = secondary (output) voltage

Np = number of turns on primary coil

Ns = number of turns on secondary coil

Ip = primary (input) current

6

Page 17: Major project report

3.2.1 Ideal power equation :

Fig. 3.2(b) Ideal Transformer as a Circuit Element

If the secondary coil is attached to a load that allows current to flow, electrical power

is transmitted from the primary circuit to the secondary circuit. Ideally, the

transformer is perfectly efficient; all the incoming energy is transformed from the

primary circuit to the magnetic field and into the secondary circuit. If this condition is

met, the incoming electric power must equal the outgoing power:

Giving the ideal transformer equation

Transformers normally have high efficiency, so this formula is a reasonable

approximation.

If the voltage is increased, then the current is decreased by the same factor. The

impedance in one circuit is transformed by the square of the turns ratio. For example,

if an impedance Zs is attached across the terminals of the secondary coil, it appears to

the primary circuit to have an impedance of (Np/Ns)2Zs. This relationship is reciprocal,

so that the impedance Zp of the primary circuit appears to the secondary to be

(Ns/Np)2Zp.

7

Page 18: Major project report

3.3 VOLTAGE REGULATOR 7805

3.3.1 Features

• Output Current up to 1A.

• Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V.

• Thermal Overload Protection.

• Short Circuit Protection.

• Output Transistor Safe Operating Area Protection.

Fig. 3.3(a) 7805 Voltage Regulator

3.3.2 Description

The LM78XX/LM78XXA series of three-terminal positive regulators are available in

the TO-220/D-PAK package and with several fixed output voltages, making them

useful in a Wide range of applications. Each type employs internal current limiting,

thermal shutdown and safe operating area protection, making it essentially

indestructible. If adequate heat sinking is provided, they can deliver over 1A output

Current. Although designed primarily as fixed voltage regulators, these devices can be

used with external components to obtain adjustable voltages and currents.

8

Page 19: Major project report

3.3.3 Internal Block Diagram

Fig. 3.3(b) 7805 Internal Block Diagram

3.3.4 Absolute Maximum Ratings

Table 3.3(a) Rating of Voltage Regulator

9

Page 20: Major project report

3.4 RECTIFIER

A rectifier is an electrical device that converts alternating current (AC), which

periodically reverses direction, to direct current (DC), current that flows in only one

direction, a process known as rectification. Rectifiers have many uses including as

components of power supplies and as detectors of radio signals. Rectifiers may be

made of solid state diodes, vacuum tube diodes, mercury arc valves, and other

components. The output from the transformer is fed to the rectifier. It converts A.C.

into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this

project, a bridge rectifier is used because of its merits like good stability and full wave

rectification. In positive half cycle only two diodes( 1 set of parallel diodes) will

conduct, in negative half cycle remaining two diodes will conduct and they will

conduct only in forward bias only.

Fig. 3.4(a) Rectifier Circuit

10

Page 21: Major project report

3.5 FILTER

Capacitive filter is used in this project. It removes the ripples from the output of

rectifier and smoothens the D.C. Output received from this filter is constant until the

mains voltage and load is maintained constant. However, if either of the two is varied,

D.C. voltage received at this point changes. Therefore a regulator is applied at the

output stage.

The simple capacitor filter is the most basic type of power supply filter. The use of

this filter is very limited. It is sometimes used on extremely high-voltage, low-current

power supplies for cathode-ray and similar electron tubes that require very little load

current from the supply. This filter is also used in circuits where the power-supply

ripple frequency is not critical and can be relatively high. Below figure can show how

the capacitor charges and discharges.

Fig. 3.5 Filter Circuit

11

Page 22: Major project report

3.6 MICRO CONTROLLER PIC16F877

3.6.1 Pin Diagram

Fig.3.6(a) PIC16F877A PIN Diagram

PIC16F873A/876A devices are available only in 28-pin packages, while

PIC16F874A/877A devices are avail- able in 40-pin and 44-pin packages. All

devices in the PIC16F87XA family share common architecture with the following

differences:

The PIC16F873A and PIC16F874A have one-half of the total on-chip memory of

the PIC16F876A and PIC16F877A.

The 28-pin devices have three I/O ports, while the 40/44-pin devices have five.

The 28-pin devices have fourteen interrupts, while the 40/44-pin devices have

fifteen.

The 28-pin devices have five A/D input channels, while the 40/44-pin devices

have eight.

12

Page 23: Major project report

3.6.2 High-Performance RISC CPU:

Only 35 single-word instructions.

All single-cycle instructions except for program branches, which are two cycle.

Operating speed: DC – 20 MHz clock input DC – 200 ns instruction cycle

Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data

Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory.

Pin out compatible to other 28-pin or 40/44-pin, PIC16CXXX and PIC16FXXX

microcontrollers.

3.6.3 Special Microcontroller Features:

100,000 erase/write cycle Enhanced Flash program memory typical.

1,000,000 erase/write cycle Data EEPROM memory typical.

Data EEPROM Retention > 40 years.

Self-reprogrammable under software control.

In-Circuit Serial Programming™ (ICSP™) via two pins.

Single-supply 5V In-Circuit Serial Programming.

Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation.

Programmable code protection.

Power saving Sleep mode.

Selectable oscillator options.

3.6.4 Peripheral Features:

Timer0: 8-bit timer/counter with 8-bit prescaler.

Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep via

external crystal/clock.

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler.

Two Capture, Compare, PWM modules

- Capture is 16-bit, max. resolution is 12.5 ns.

- Compare is 16-bit, max. resolution is 200 ns.

- PWM max resolution is 10-bit.

13

Page 24: Major project report

Synchronous Serial Port (SSP) with SPI™ (Master mode) and I2C (Master/Slave).

Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-

bit address detection.

Parallel Slave Port (PSP) – 8 bits wide with external RD, WR and CS Controls.

Brown-out detection circuitry for Brown-out Reset (BOR).

3.6.5 Analog Features:

10-bit, up to 8-channel Analog-to-Digital Converter (A/D)

Brown-out Reset (BOR)

Analog Comparator module with:

1. Two analog comparators.

2. Programmable on-chip voltage reference (VREF) module.

3. Programmable input multiplexing from device inputs and internal

voltage reference.

4. Comparator outputs are externally accessible.

3.6.6 CMOS Technology:

Low-power, high-speed Flash/EEPROM technology.

Fully static design.

Wide operating voltage range (2.0V to 5.5V).

Commercial and Industrial temperature ranges.

Low-power consumption.

3.6.7 Memory Organization

There are three memory blocks in each of the PIC16F87XA devices. The

program memory and data memory have separate buses so that concurrent

access can occur and is detailed in this section. The EEPROM data memory block is

detailed in Section 3.0 “Data EEPROM and Flash Program Memory”. Additional

information on device memory may be found in the PIC micro Mid-Range MCU

Family Reference Manual (DS33023).

14

Page 25: Major project report

3.6.8 Program Memory Organization

The PIC16F87XA devices have a 13-bit program counter capable of addressing

an 8K word x 14 bit program memory space. The PIC16F876A/877A devices

have 8K words x 14 bits of Flash program memory, while PIC16F873A/874A

devices have 4K words x 14 bits. Accessing a location above the physically

implemented address will cause a wraparound.The Reset vector is at 0000h and the

interrupt vector is at 0004h.

3.7 TSOP1738

3.7.1 Description

The TSOP17 – series are miniaturized receivers for infrared remote control systems.

PIN diode and preamplifier are assembled on lead frame, the epoxy package is

designed as IR filter.

The demodulated output signal can directly be decoded by a microprocessor.

TSOP1738 is the standard IR remote control receiver series, supporting all major

transmission codes.

3.7.2 Features

Photo detector and preamplifier in one package

Internal filter for PCM frequency

Improved shielding against electrical field disturbance

TTL and CMOS compatibility

Output active low

Low power consumption

High immunity against ambient light Fig.3.7(a) TSOP

1738

Continuous data transmission possible (up to 2400 bps)

Suitable burst length >= 10cycles/burst.

15

Page 26: Major project report

3.7.3 Block diagram of TSOP:

Fig.3.7(b) Block Diagram of TSOP

The circuit of the TSOP17 is designed in that way that unexpected output pulses due

to noise or disturbance signals are avoided. A band pass filter, an integrator stage and

an automatic gain control are used to suppress such disturbances. The distinguishing

mark between data signal and disturbance signal are carrier frequency, burst length

and duty cycle. The data signal should full fill the following condition:

Carrier frequency should be close to center frequency of the band pass (e.g.

38kHz).

Burst length should be 10 cycles/burst or longer.

After each burst which is between 10 cycles and 70 cycles a gap time of at least

14 cycles is necessary.

For each burst which is longer than 1.8ms a corresponding gap time is necessary

at some time in the data stream. This gap time should have at least same length as

the burst.

Up to 1400 short bursts per second can be received continuously. Some examples

for suitable data format are: NEC Code, Toshiba Micom Format, Sharp Code,

RC5 Code, RC6 Code, R–2000 Code, Sony Format (SIRCS). When a disturbance

signal is applied to the TSOP17.It can still receive the data signal. However the

sensitivity is reduced to that level that no unexpected pulses will occur. Some

examples for such disturbance signals which are suppressed by the TSOP17 series

are:

16

Page 27: Major project report

– DC light (e.g. from tungsten bulb or sunlight).

– Continuous signal at 38 kHz or at any other frequency.

3.8 MAX232

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port

to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a

dual driver/receiver and typically converts the RX, TX, CTS and RTS signals. The

drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from a single + 5 V

supply via on-chip charge pumps and external capacitors. This makes it useful for

implementing RS-232 in devices that otherwise do not need any voltages outside the

0 V to + 5 V range, as power supply design does not need to be made more

complicated just for driving the RS-232 in this case. The receivers reduce RS-232

inputs (which may be as high as ± 25 V), to standard 5 V TTL levels. These receivers

have a typical threshold of 1.3 V, and a typical hysteresis of 0.5 V.

3.8.1 Voltage levels

It is helpful to understand what occurs to the voltage levels. When a MAX232 IC

receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15V,

and changes TTL Logic 1 to between -3 to -15V, and vice versa for converting from

RS232 to TTL.

This can be confusing when you realize that the RS232 Data Transmission voltages at

a certain logic state are opposite from the RS232 Control Line voltages at the same

logic state. To clarify the matter, see the table below. For more information see RS-

232 Voltage Levels.

Table 3.8(a) MAX232 Voltage Levels

17

Page 28: Major project report

Fig.3.8(a) MAX232 PIN Diagram

Table 3.8(a) MAX232 PIN Description

18

Page 29: Major project report

3.8.2 Application:

The MAX232 has two receivers (converts from RS-232 to TTL voltage levels) and

two drivers (converts from TTL logic to RS-232 voltage levels). This means only two

of the RS-232 signals can be converted in each direction.

Typically a pair of a driver/receiver of the MAX232 is used for

TX and RX

And the second one for

CTS and RTS.

There are not enough drivers/receivers in the MAX232 to also connect the DTR,

DSR, and DCD signals. Usually these signals can be omitted when e.g.

communicating with a PC's serial interface. If the DTE really requires these signals

either a second MAX232 is needed, or some other IC from the MAX232 family can

be used.

3.9 DB9 CONNECTOR

The DB9 (originally DE-9) connector is an analog 9-pin plug of the D-Sub miniature

connector family (D-Sub or Sub-D). The DB9 connector is mainly used for serial

connections, allowing for the asynchronous transmission of data as provided for by

standard RS-232 (RS-232C).

Fig 3.9(a) DB9 Connector

19

Page 30: Major project report

3.9.1 Pin description:

Table 3.9(a) DB9 PIN Description

This is a common connector used in many computer, audio/video, and data

applications. The official name is D-sub miniature, but many people call it “D-sub” or

just “DB”. The connector gets its name from its trapezoidal shape that resembles the

letter “D”. Most DB connectors have two rows of pins. Common types of D-sub

connectors are DB9 and DB25, used on PCs for serial and parallel ports.

One special type of D-sub connectors is the High-Density DB style, which looks just

like a regular DB connector, only with pins that are slightly smaller and placed closer

together. This is typically referred to as an “HD” connector. HD connectors often

have three rows of pins instead of two. The most common HD connector is the HD15,

which is found on PC video cards and monitors. DB- and HD-connectors use

thumbscrews to secure the connector in place.

Another type of D-sub is the MD, or Micro DB connector. This connector is slimmer

than a standard D-sub, with pins even smaller than the ones used on HD connectors.

The MD is also commonly called a “half-pitch” DB connector. These are often used

in SCSI applications, and the most popular types are the MD50 and MD68

connections.

20

Page 31: Major project report

D-sub connectors are usually described by the total number of pins that they can hold.

In some cases, a DB25 connector may only have 4 or 5 pins loaded into it; however, it

is still called a “DB25” connector and not a “DB4” or “DB5”. Another example is the

HD15 connector used by monitors—most monitor cables only are loaded with 14

pins, but it is still called an HD15 connector.

3.9.2 Interfacing Between Microcontroller and DB9 Connector

Fig.3.9(b) Interfacing Between Microcontroller and DB9 Connector

3.10 LED

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as

indicator lamps in many devices, and are increasingly used for lighting. When a light-

emitting diode is forward biased (switched on), electrons are able to recombine with

holes within the device, releasing energy in the form of photons.

This effect is called electroluminescence and the color of the light (corresponding to

the energy of the photon) is determined by the energy gap of the semiconductor. An

LED is often small in area (less than 1 mm2), and integrated optical components may

be used to shape its radiation pattern.

21

Page 32: Major project report

Light-emitting diodes are used in applications as diverse as replacements for aviation

lighting, automotive lighting as well as in traffic signals. The compact size, the

possibility of narrow bandwidth, switching speed, and extreme reliability of LEDs has

allowed new text and video displays and sensors to be developed, while their high

switching rates are also useful in advanced communications technology.

3.10.1 Electronic Symbol:

Fig 3.10(a) Symbol of LED

3.10.2 Colors and materials of LED’S

Conventional LEDs are made from a variety of inorganic semiconductor materials,

the following table shows the available colors with wavelength range, voltage drop

and material.

3.10.3 White LED’S

Light Emitting Diodes (LED) have recently become available that are both white and

bright, so bright that they seriously compete with incandescent lamps in lighting

applications. They are still pretty expensive as compared to a GOW lamp but draw

much less current and project a fairly well focused beam.When run within their

ratings, they are more reliable than lamps as well. Red LEDs are now being used in

automotive and truck tail lights and in red traffic signal lights. You will be able to

detect them because they look like an array of point sources and they go on and off

instantly as compared to conventional incandescent lamps. LEDs are monochromatic

(one color) devices. The color is determined by the band gap of the semiconductor

used to make them. Red, green, yellow and blue LEDs are fairly common. White light

contains all colors and cannot be directly created by a single LED. The most common

form of "white" LED really isn't white. It is a Gallium Nitride blue LED coated with a

phosphor that, when excited by the blue LED light, emits a broad range spectrum that

in addition to the blue emission, makes a fairly white light.

22

Page 33: Major project report

There is a claim that these white LED's have a limited life. After 1000 hours or so of

operation, they tend to yellow and dim to some extent. Running the LEDs at more

than their rated current will certainly accelerate this process.

There are two primary ways of producing high intensity white-light using LEDs. One

is to use individual LEDs that emit three primary colors—red, green, and blue—and

then mix all the colors to form white light. The other is to use a phosphor material to

convert monochromatic light from a blue or UV LED to broad-spectrum white light,

much in the same way a fluorescent light bulb works. Due to metamerism, it is

possible to have quite different spectra that appear white.

Fig 3.10(b) White LED spectrum

3.11 IN4007 DIODE

Diodes are used to convert AC into DC these are used as half wave rectifier or full

wave rectifier. Three points must he kept in mind while using any type of diode.

Maximum forward current capacity

Maximum reverse voltage capacity

Maximum forward voltage capacity

23

Page 34: Major project report

Fig.3.11(a) IN4007 Diodes

The number and voltage capacity of some of the important diodes available in the

market are as follows:

Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and

IN4007 have maximum reverse bias voltage capacity of 50V and maximum

forward current capacity of 1 Amp.

Diode of same capacities can be used in place of one another. Besides this diode

of more capacity can be used in place of diode of low capacity but diode of low

capacity cannot be used in place of diode of high capacity. For example, in place

of IN4002; IN4001 or IN4007 can be used but IN4001 or IN4002 cannot be used

in place of IN4007.The diode BY125made by company BEL is equivalent of

diode from IN4001 to IN4003. BY 126 is equivalent to diodes IN4004 to 4006

and BY 127 is equivalent to diode IN4007.

Fig.3.11(c) PN Junction Diode

24

Page 35: Major project report

3.11.1 PN Junction Operation

Now that you are familiar with P- and N-type materials, how these materials are

joined together to form a diode, and the function of the diode, let us continue our

discussion with the operation of the PN junction. But before we can understand how

the PN junction works, we must first consider current flow in the materials that make

up the junction and what happens initially within the junction when these two

materials are joined together.

3.12 RESISTOR

A resistor is a two-terminal electronic component designed to oppose an electric

current by producing a voltage drop between its terminals in proportion to the current,

that is, in accordance with Ohm's law:

V = IR

Resistors are used as part of electrical networks and electronic circuits. They are

extremely commonplace in most electronic equipment. Practical resistors can be made

of various compounds and films, as well as resistance wire (wire made of a high-

resistivity alloy, such as nickel/chrome).

The primary characteristics of resistors are their resistance and the power they can

dissipate. Other characteristics include temperature coefficient, noise, and inductance.

Less well-known is critical resistance, the value below which power dissipation limits

the maximum permitted current flow, and above which the limit is applied voltage.

Critical resistance depends upon the materials constituting the resistor as well as its

physical dimensions; it's determined by design.

Resistors can be integrated into hybrid and printed circuits, as well as integrated

circuits. Size, and position of leads (or terminals) are relevant to equipment designers;

resistors must be physically large enough not to overheat when dissipating their

power.

A resistor is a two-terminal passive electronic component which implements electrical

resistance as a circuit element. When a voltage V is applied across the terminals of a

resistor, a current I will flow through the resistor in direct proportion to that voltage.

25

Page 36: Major project report

The reciprocal of the constant of proportionality is known as the resistance R, since,

with a given voltage V, a larger value of R further "resists" the flow of current I as

given by Ohm's law:

Resistors are common elements of electrical networks and electronic circuits and are

ubiquitous in most electronic equipment. Practical resistors can be made of various

compounds and films, as well as resistance wire (wire made of a high-resistivity alloy,

such as nickel-chrome). Resistors are also implemented within integrated circuits,

particularly analog devices, and can also be integrated into hybrid and printed circuits.

The electrical functionality of a resistor is specified by its resistance: common

commercial resistors are manufactured over a range of more than 9 orders of

magnitude. When specifying that resistance in an electronic design, the required

precision of the resistance may require attention to the manufacturing tolerance of the

chosen resistor, according to its specific application. The temperature coefficient of

the resistance may also be of concern in some precision applications. Practical

resistors are also specified as having a maximum power rating which must exceed the

anticipated power dissipation of that resistor in a particular circuit: this is mainly of

concern in power electronics applications. Resistors with higher power ratings are

physically larger and may require heat sinking. In a high voltage circuit, attention

must sometimes be paid to the rated maximum working voltage of the resistor.

The series inductance of a practical resistor causes its behavior to depart from ohms

law; this specification can be important in some high-frequency applications for

smaller values of resistance. In a low-noise amplifier or pre-amp the noise

characteristics of a resistor may be an issue. The unwanted inductance, excess noise,

and temperature coefficient are mainly dependent on the technology used in

manufacturing the resistor. They are not normally specified individually for a

particular family of resistors manufactured using a particular technology. A family of

discrete resistors is also characterized according to its form factor, that is, the size of

the device and position of its leads (or terminals) which is relevant in the practical

manufacturing of circuits using them.

26

Page 37: Major project report

Fig.3.12(a) Resistors

3.12.1 Units

The ohm (symbol: Ω) is the SI unit of electrical resistance, named after Georg Simon

Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and

manufactured over a very large range of values, the derived units of milliohm (1 mΩ

= 10−3

Ω), kilohm (1 kΩ = 103 Ω), and megohm (1 MΩ = 106

Ω) are also in common

usage.

The reciprocal of resistance R is called conductance G = 1/R and is measured in

Siemens (SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of

an ohm: S = Ω − 1. Although the concept of conductance is often used in circuit

analysis, practical resistors are always specified in terms of their resistance (ohms)

rather than conductance.

3.13 CAPACITOR

A capacitor or condenser is a passive electronic component consisting of a pair of

conductors separated by a dielectric. When a voltage potential difference exists

between the conductors, an electric field is present in the dielectric. This field stores

energy and produces a mechanical force between the plates. The effect is greatest

between wide, flat, parallel, narrowly separated conductors.

An ideal capacitor is characterized by a single constant value, capacitance, which is

measured in farads. This is the ratio of the electric charge on each conductor to the

potential difference between them.

27

Page 38: Major project report

The conductors and leads introduce an equivalent series resistance and the dielectric

has an electric field strength limit resulting in a breakdown voltage.

Fig. 3.13(a) Capacitors

A capacitor (formerly known as condenser) is a device for storing electric charge. The

forms of practical capacitors vary widely, but all contain at least two conductors

separated by a non-conductor. Capacitors used as parts of electrical systems, for

example, consist of metal foils separated by a layer of insulating film.

Capacitors are widely used in electronic circuits for blocking direct current while

allowing alternating current to pass, in filter networks, for smoothing the output of

power supplies, in the resonant circuits that tune radios to particular frequencies and

for many other purposes.

A capacitor is a passive electronic component consisting of a pair of conductors

separated by a dielectric (insulator). When there is a potential difference (voltage)

across the conductors, a static electric field develops in the dielectric that stores

energy and produces a mechanical force between the conductors. An ideal capacitor is

characterized by a single constant value, capacitance, measured in farads. This is the

ratio of the electric charge on each conductor to the potential difference between

them.The capacitance is greatest when there is a narrow separation between large

areas of conductor.

28

Page 39: Major project report

In practice the dielectric between the plates passes a small amount of leakage current

and also has an electric field strength limit, resulting in a breakdown voltage, while

the conductors and leads introduce an undesired inductance and resistance.

3.13.1 Theory of operation

Fi.3.13(b) Capacitor - Theory of Operation

Charge separation in a parallel-plate capacitor causes an internal electric field. A

dielectric (orange) reduces the field and increases the capacitance.

Fig.3.13(c) A simple demonstration of a parallel-plate capacitor

A capacitor consists of two conductors separated by a non-conductive region. The

non-conductive region is called the dielectric or sometimes the dielectric medium. In

simpler terms, the dielectric is just an electrical insulator. Examples of dielectric

mediums are glass, air, paper, vacuum, and even a semiconductor depletion region

chemically identical to the conductors.

29

Page 40: Major project report

A capacitor is assumed to be self-contained and isolated, with no net electric charge

and no influence from any external electric field. The conductors thus hold equal and

opposite charges on their facing surfaces, and the dielectric develops an electric field.

In SI units, a capacitance of one farad means that one coulomb of charge on each

conductor causes a voltage of one volt across the device.

The capacitor is a reasonably general model for electric fields within electric circuits.

An ideal capacitor is wholly characterized by a constant capacitance C, defined as the

ratio of charge ±Q on each conductor to the voltage V between them:

Sometimes charge build-up affects the capacitor mechanically, causing its capacitance

to vary. In this case, capacitance is defined in terms of incremental changes:

3.13.2 Energy storage

Work must be done by an external influence to "move" charge between the

conductors in a capacitor. When the external influence is removed the charge

separation persists in the electric field and energy is stored to be released when the

charge is allowed to return to its equilibrium position. The work done in establishing

the electric field, and hence the amount of energy stored, is given by:

3.13.3 Current-voltage relation

The current i(t) through any component in an electric circuit is defined as the rate of

flow of a charge q(t) passing through it, but actual charges, electrons, cannot pass

through the dielectric layer of a capacitor, rather an electron accumulates on the

negative plate for each one that leaves the positive plate, resulting in an electron

depletion and consequent positive charge on one electrode that is equal and opposite

to the accumulated negative charge on the other.

30

Page 41: Major project report

As with any antiderivative, a constant of integration is added to represent the initial

voltage v (t0). This is the integral form of the capacitor equation,

.

Taking the derivative of this, and multiplying by C, yields the derivative form,

.

The dual of the capacitor is the inductor, which stores energy in the magnetic field

rather than the electric field. Its current-voltage relation is obtained by exchanging

current and voltage in the capacitor equations and replacing C with the inductance L.’

3.13.4 DC circuits

Fig.3.13(d) RC circuit

A simple resistor-capacitor circuit demonstrates charging of a capacitor.

A series circuit containing only a resistor, a capacitor, a switch and a constant DC

source of voltage V0 is known as a charging circuit. If the capacitor is initially

uncharged while the switch is open, and the switch is closed at t = 0, it follows from

Kirchhoff's voltage law that

Taking the derivative and multiplying by C, gives a first-order differential equation,

At t = 0, the voltage across the capacitor is zero and the voltage across the resistor is

V0. The initial current is then i (0) =V0 /R.

31

Page 42: Major project report

With this assumption, the differential equation yields

where τ0 = RC is the time constant of the system.

As the capacitor reaches equilibrium with the source voltage, the voltage across the

resistor and the current through the entire circuit decay exponentially. The case of

discharging a charged capacitor likewise demonstrates exponential decay, but with the

initial capacitor voltage replacing V0 and the final voltage being zero.

3.13.5 AC circuits

Impedance, the vector sum of reactance and resistance, describes the phase difference

and the ratio of amplitudes between sinusoidally varying voltage and sinusoidally

varying current at a given frequency. Fourier analysis allows any signal to be

constructed from a spectrum of frequencies, whence the circuit's reaction to the

various frequencies may be found. The reactance and impedance of a capacitor are

respectively

where j is the imaginary unit and ω is the angular velocity of the sinusoidal signal.

The - j phase indicates that the AC voltage V = Z I lags the AC current by 90°: the

positive current phase corresponds to increasing voltage as the capacitor charges; zero

current corresponds to instantaneous constant voltage, etc.

Note that impedance decreases with increasing capacitance and increasing frequency.

This implies that a higher-frequency signal or a larger capacitor results in a lower

voltage amplitude per current amplitude—an AC "short circuit" or AC coupling.

32

Page 43: Major project report

Conversely, for very low frequencies, the reactance will be high, so that a capacitor is

nearly an open circuit in AC analysis—those frequencies have been "filtered

out".Capacitors are different from resistors and inductors in that the impedance is

inversely proportional to the defining characteristic, i.e. capacitance.

3.13.6 Parallel plate model

Fig.3.13(e) Parallel Plate Model

Dielectric is placed between two conducting plates, each of area A and with a

separation of d.

The simplest capacitor consists of two parallel conductive plates separated by a

dielectric with permittivity ε (such as air). The model may also be used to make

qualitative predictions for other device geometries. The plates are considered to

extend uniformly over an area A and a charge density ±ρ = ±Q/A exists on their

surface. Assuming that the width of the plates is much greater than their separation d,

the electric field near the centre of the device will be uniform with the magnitude E =

ρ/ε. The voltage is defined as the line integral of the electric field between the plates

Solving this for C = Q/V reveals that capacitance increases with area and decreases

with separation

.

The capacitance is therefore greatest in devices made from materials with a high

permittivity.

33

Page 44: Major project report

3.13.7 Networks

A. For capacitors in parallel

Fig.3.13(f) Several capacitors in parallel.

Capacitors in a parallel configuration each have the same applied voltage. Their

capacitances add up. Charge is apportioned among them by size. Using the schematic

diagram to visualize parallel plates, it is apparent that each capacitor contributes to the

total surface area.

B. For capacitors in series

Fig.3.13(g) Several capacitors in series.

Connected in series, the schematic diagram reveals that the separation distance, not

the plate area, adds up. The capacitors each store instantaneous charge build-up equal

to that of every other capacitor in the series. The total voltage difference from end to

end is apportioned to each capacitor according to the inverse of its capacitance. The

entire series acts as a capacitor smaller than any of its components.

Capacitors are combined in series to achieve a higher working voltage, for example

for smoothing a high voltage power supply. The voltage ratings, which are based on

plate separation, add up.

34

Page 45: Major project report

4. SOFTWARE REQUIREMENTS

4.1 WHAT IS MPLAB IDE?

MPLAB IDE is a software program that runs on a PC to develop applications for

Microchip microcontrollers. It is called an Integrated Development Environment, or

IDE, because it provides a single integrated environment to develop code for

embedded microcontrollers.

4.2 DESCRIPTION OF EMBEDDED SYSTEM

An embedded system is typically a design making use of the power of a small

microcontroller, like the Microchip PIC micro MCU or PIC Digital Signal

Controller(DSCs). These microcontrollers combine a microprocessor unit (like the CPU

in a desk- top PC) with some additional circuits called peripherals, plus some additional

circuits on the same chip to make a small control module requiring few other external

devices. This single device can then be embedded into other electronic and mechanical

devices for low-cost digital control.

4.3 COMPONENTS OF MICROCONTROLLER

The PIC micro MCU has program memory for the firmware, or coded instructions, to

run a program. It also has file register memory for storage of variables that the

program will need for computation or temporary storage. It also has a number of

peripheral device circuits on the same chip. Some peripheral devices are called I/O

ports. I/O ports are pins on the microcontroller that can be driven high or low to send

signals, blink lights, drive speakers just about anything that can be sent through a wire.

Often these pins are bidirectional and can also be configured as inputs allowing the

program to respond to an external switch, sensor or to communicate with some

external device.

35

Page 46: Major project report

Serial communication peripherals allow you to stream communications over a few

wires to another microcontroller, to a local network or to the internet. Peripherals on

the PIC micro MCU called timers accurately measure signal events and generate and

capture communications signals, pro- duce precise waveforms, even automatically

reset the microcontroller if it gets hung or lost due to a power glitch or hardware

malfunction. Other peripherals detect if the external power is dipping below dangerous

levels so the microcontroller can store critical information and safely shut down before

power is completely lost.

The peripherals and the amount of memory an application needs to run a program

largely determines which PIC micro MCU to use. Other factors might include the

power consumed by the microcontroller and its form factor, i.e., the size and

characteristics of the physical package that must reside on the target design.

A development system for embedded controllers is a system of programs running on a

desktop PC to help write, edit, debug and program code ñ the intelligence of embedded

systems applications ñ into a microcontroller. MPLAB IDE runs on a PC and contains

all the components needed to design and deploy embedded systems applications. The

typical tasks for developing an embedded controller application are:

1. Create the high level design. From the features and performance desired, decide

which PIC micro MCU or PIC DSC device is best suited to the application, then design

the associated hardware circuitry. After determining which peripherals and pins

control the hardware, write the firmware ñ the software that will control the hardware

aspects of the embedded application. A language tool such as an assembler, which is

directly translatable into machine code, or a compiler that allows a more natural

language for creating programs, should be used to write and edit code. Assemblers and

compilers help make the code understandable, allowing function labels to identify

code routines with variables that have names associated with their use, and with

constructs that help organize the code in a maintainable structure.

36

Page 47: Major project report

Fig 4.3(a) PIC micro MCU Data Sheet Instructions

2. Compile, assemble and link the software using the assembler and/or compiler and

linker to convert your code into ones and zeroes machine code for the PIC micro

MCUs. This machine code will eventually become the firmware (the code

programmed into the microcontroller).

3.Test your code. Usually a complex program does not work exactly the way imagined,

and bugs need to be removed from the design to get proper results. The debugger

allows you to see the ones and zeroes execute, related to the source code you wrote,

with the symbols and function names from your program. Debugging allows you to

experiment with your code to see the value of variable sat various points in the program,

and to do what if check, changing variable values and stepping through routines.

4. Burn the code into a microcontroller and verify that it executes correctly in the

finished application. Of course, each of these steps can be quite complex.

37

Page 48: Major project report

4.4 THE DEVELOPMENT CYCLE

The process for writing an application is often described as a development cycle, since

it is rare that all the steps from design to implementation can be done flawlessly the first

time. More often code is written, tested and then modified in order to produce an

application that performs correctly. The Integrated Development Environment allows

the embedded systems design engineer to progress through this cycle without the

distraction of switching among an array of tools. By using MPLAB IDE, all the

functions are integrated, allowing the engineer to concentrate on completing the

application without the interruption of separate tools and different modes of operation.

MPLAB IDE is a wrapper that coordinates all the tools from a single graphical user

interface, usually automatically. For instance, once code is written, it can be converted

to executable instructions and downloaded into a microcontroller to see how it works.

In this process multiple tools are needed: an editor to write the code, a project manager

to organize files and settings, a compiler or assembler to convert the source code to

machine code and some sort of hardware or software that either connects to a target

microcontroller or simulates the operation of a microcontroller.

4.5 PROJECT MANAGER

The project manager organizes the files to be edited and other associated files so they

can be sent to the language tools for assembly or compilation, and ultimately to a linker.

The linker has the task of placing the object code fragments from the assembler,

compiler and libraries into the proper memory areas of the embedded controller, and

ensure that the modules function with each other. This entire operation from assembly

and compilation through the link process is called a project build.

From the MPLAB IDE project manager, properties of the language tools can be

invoked differently for each file, if desired, and a build process integrates all of the

language tools operations. The source files are text files that are written conforming to

the rules of the assembler or compiler.

38

Page 49: Major project report

The assembler and compiler convert them into intermediate modules of machine code

and placeholders for references to functions and data storage. The linker resolves these

placeholders and combines all the modules into a file of executable machine code. The

linker also produces a debug file which allows MPLAB IDE to relate the executing

machine codes back to the source files. A text editor is used to write the code. It is not a

normal text editor, but an editor specifically designed for writing code for Microchip

MCUs. It recognizes the constructs in the text and uses color coding to identify various

elements, such as instruction mnemonics, C language constructs and comments. The

editor supports operations commonly used in writing source code, such as finding

matching braces in C, commenting and un-commenting out blocks of code, finding text

in multiple files and adding special bookmarks. After the code is written, the editor

works with the other tools to display code execution in the debugger. Breakpoints can

be set in the editor, and the values of variables can be inspected by hovering the mouse

pointer over the variable name. Names of variables can be dragged from source text

windows and then dropped into a Watch window.

4.6 DEVICE PROGRAMMING

After the application has been debugged and is running in the development

environment, it needs to be tested on its own. A device can be programmed with the in-

circuit debugger or a device programmer. MPLAB IDE can be set to the programmer

function, and the part can be burned. The target application can now be observed in its

nearly final state. Engineering prototype programmers allow quick prototypes to be

made and evaluated. Some applications can be programmed after the device is

soldered on the target PC board. Using In-Circuit Serial Programming(ICSP)

programming capability, the firmware can be programmed into the application at the

time of manufacture, allowing updated revisions to be programmed into an embedded

application later in its life cycle. Devices that support in-circuit debugging can even be

plugged back into the MPLAB ICD 2 after manufacturing for quality tests and

development of next generation firmware.

39

Page 50: Major project report

4.7 COMPONENTS OF MPLAB IDE

The MPLAB IDE has both built-in components and plug-in modules to configure the

system for a variety of software and hardware tools.

4.7.1 MPLAB IDE Built-In Components

The built-in components consist of:

Project Manager

The project manager provides integration and communication between the IDE and the

language tools.

Editor

The editor is a full-featured programmer's text editor that also serves as a window into

the debugger.

Assembler/Linker and Language Tools

The assembler can be used stand-alone to assemble a single file, or can be used with the

linker to build a project from separate source files, libraries and recompiled objects. The

linker is responsible for positioning the compiled code into memory areas of the target

microcontroller.

Debugger

The Microchip debugger allows breakpoints, single stepping, watch windows and all

the features of a modern debugger for the MPLAB IDE. It works in conjunction with the

editor to reference information from the target being debugged back to the source code.

Execution Engines

There are software simulators in MPLAB IDE for all PIC micro MCU and dsPIC DSC

devices. These simulators use the PC to simulate the instructions and some peripheral

functions of the PIC micro MCU and PIC DSC devices.

40

Page 51: Major project report

Optional in-circuit emulators and in-circuit debuggers are also available to test code as

it runs in the applications hardware.

4.7.2 Additional Optional Components for MPLAB IDE

Optional components can be purchased and added to the MPLAB IDE:

Compiler Language Tools

MPLAB C18 and MPLAB C30 C compilers from Microchip provide fully integrated,

optimized code. Along with compilers from HI-TECH, IAR, micro Engineering Labs,

CCS and Byte Craft, they are invoked by the MPLAB IDE project manager to compile

code that is automatically loaded into the target debugger for instant testing and

verification.

Programmers

PICSTART Plus, PIC kit 1 and 2, PRO MATE II, MPLAB PM3 as well as MPLAB

ICD 2 can program code into target devices. MPLAB IDE offers full control over

programming both code and data, as well as the Configuration bits to set the various

operating modes of the target microcontrollers or digital signal controllers.

In-Circuit Emulators

MPLAB ICE 2000 and MPLAB ICE 4000 are full-featured emulators for the PIC

micro MCU and dsPIC DSC devices. They connect to the PC via I/O ports and allow

full control over the operation of microcontroller in the target applications.

In-Circuit Debugger

MPLAB ICD 2 provides an economic alternative to an emulator. By using some of the

on-chip resources, MPLAB ICD 2 can download code into a target microcontroller

inserted in the application, set breakpoints, single step and monitor registers and

variables.

41

Page 52: Major project report

4.8 MPLAB IDE FEATURES AND INSTALLATION

MPLAB IDE is a Windows Operating System (OS) based Integrated Development

Environment for the PIC micro MCU families and the dsPIC Digital Signal

Controllers. The MPLAB IDE provides the ability to:

Create and edit source code using the built-in editor.

Assemble, compile and link source code.

Debug the executable logic by watching program flow with the built-in simulator or

in real time with in-circuit emulators or in-circuit debuggers.

Make timing measurements with the simulator or emulator.

View variables in Watch windows.

4.8.1 Running MPLAB IDE

To start MPLAB IDE, double click on the icon installed on the desktop after installation

or select Start>Programs>Microchip>MPLAB IDE vx.xx>MPLAB IDE. A screen will

display the MPLAB IDE logo followed by the MPLAB IDE desktop.

Fig. 4.8(a) MPLAB IDE Desktop

4.8.2 SELECTING THE DEVICE

To show menu selections in this document, the menu item from the top row in

MPLAB IDE will be shown after the menu name like this MenuName>MenuItem.

42

Page 53: Major project report

To choose the Select Device entry in the Configure menu, it would be written as

Configure>Select Device. Choose Configure>Select Device. In the Device dialog,

select the PIC18F8722 from the list if itís not already selected.

Fig.4.8(b) Selecting Device Dialog

The lights indicate which MPLAB IDE components support this device.

A green light indicates full support.

A yellow light indicates preliminary support for an upcoming part by the particular

MPLAB IDE tool component. Components with a yellow light instead of a green

light are often intended for early adopters of new parts who need quick support and

understand that some operations or functions may not be available.

A red light indicates no support for this device. Support may be forthcoming or

inappropriate for the tool, e.g., PIC DSC devices cannot be supported on MPLAB

ICE 2000.

4.8.3 CREATING THE PROJECT

The next step is to create a project using the Project Wizard. A project is the way the

files are organized to be compiled and assembled.

We will use a single assembly file for this project and a linker script. Choose

Project>Project Wizard. From the Welcome dialog, click on Next> to advance.

43

Page 54: Major project report

The next dialog (Step One) allows you to select the device, which we have already

done. Make sure that it says PIC18F8722. If it does not, select the PIC18F8722 from the

drop down menu. Click Next>.

Fig.5.9(c) Project Wizard Select Device

4.8.4 SETTING UP LANGUAGE TOOLS

Step Two of the Project Wizard sets up the language tools that are used with this

project. Select Microchip MPASM Toolsuite in the Active Toolsuite list box. Then

MPASM and MPLINK should be visible in the Toolsuite Contents box. Click on each

one to see its location. If MPLAB IDE was installed into the default directory, the

MPASM assembler executable will be:

C:\Program Files\Microchip\MPASM Suite\mpasmwin.exe

the MPLINK linker executable will be:

C:\Program Files\Microchip\MPASM Suite\mplink.exe

and the MPLIB librarian executable will be:

C:\Program Files\Microchip\MPASM Suite\mplib.exe

If these do not show up correctly, use the browse button to set them to the proper files in

the MPLAB IDE subfolders.

44

Page 55: Major project report

Fig.4.8(d) Project Wizard Select Language Tools

4.8.5 NAMING THE PROJECT

Step Three of the wizard allows you to name the project and put it into a folder. This

sample project will be called MyProject. Using the Browse button, place the project in

a folder named Projects32.

Fig.4.8(e) Project Wizard Name

4.8.6 ADDING FILES TO THE PROJECT

Step Four of the Project Wizard allows file selection for the project. A source file has

not yet been selected, so we will use an MPLAB IDE template file. The template files

are simple files that can be used to start a project.

45

Page 56: Major project report

They have the essential sections for any source file, and contain information that will

help you write and organize your code.There is one template file for each Microchip

PIC micro MCU and PIC DSC device. Choose the file named 8722tmpo.asm. If

MPLAB IDE is installed in the default location, the full path to the file will be:

C:\ProgramFiles\Microchip\MPASM Suite\Template\Object\8722tmpo.asm

Fig.4.8(f) Project Wizard Select Template File

Press Add>> to move the file name to the right panel, and click on the checkbox at the

start of the line with the file name to enable this file to be copied to our project directory.

Next, add the second file for our project, the linker script. There is a linker script for each

device.

Fig.4.8(g) Project Wizard Select Linker Script

46

Page 57: Major project report

These files define the memory configuration and register names for the various parts. Use

the file named 18F8722.lkr. The full path is:

C:\Program Files\Microchip\MPASM Suite\LKR\18F8722.lkr

Make sure that your dialog looks like the picture above, with both checkboxes checked,

then press Next> to finish the Project Wizard. The final screen of the Project Wizard is

a summary showing the selected device, the tool suite and the new project file name.

Fig.4.8(h) Project Wizard Summary

After pressing the Finish button, review the Project Window on the MPLAB IDE

desktop. If the Project Window is not open, select View>Project.

Fig.4.8(i) Project Window

47

Page 58: Major project report

4.8.7 BUILDING THE PROJECT

From the Project menu, we can assemble and link the current files. They donít have

any of our code in them yet, but this ensures that the project is set up correctly.

To build the project, select either:

Project>Build All

Right click on the project name in the project window and select Build All

Click the Build All icon on the Project toolbar. Hover the mouse over icons to see

pop-up text of what they represent.

The Output window shows the result of the build process. There should be no

errors on any step. The warnings listed in Figure will not interfere with

theoperation of the tutorial pro- gram. They are merely identifying a directive that

has been deprecated, i.e., is being discontinued in favor of another. To turn off

thedisplay of warnings, do the following:

Select Project>Build Options>Project and click on the MPASM Assembler tab.

Select Output from the Categories drop-down list.

Select Errors onlyî from the Diagnostic level drop-down list.

Click OK.

Fig.4.9(a) Output Window

48

Page 59: Major project report

4.8.8 CREATING CODE

Open the template file in the project by double clicking on its name in the Project

Window, or by selecting it with the cursor and using the right mouse button to bring up

the context menu:

Fig.4.9(b) Project Context Menu

4.9 EMBEDDED C

Use of embedded processors in passenger cars, mobile phones, medical equipment,

aerospace systems and defense systems is widespread, and even everyday domestic

appliances such as dish washers, televisions, washing machines and video recorders

now include at least one such device.

Because most embedded projects have severe cost constraints, they tend to use low-

cost processors like the 8051 family of devices considered in this book. These popular

chips have very limited resources available most such devices have around 256 bytes

(not megabytes) of RAM, and the available processor power is around 1000 times less

than that of a desktop processor. As a result, developing embedded software presents

significant new challenges, even for experienced desktop programmers.

49

Page 60: Major project report

5. SCHEMATIC DIAGRAM

Fig.5 Schematic Diagram

5.1 DESCRIPTION

5.1.1 POWER SUPPLY

The circuit uses standard power supply comprising of a step-down transformer from

230Vto 12V and 4 diodes forming a Bridge Rectifier that delivers pulsating dc which

is then filtered by an electrolytic capacitor of about 470µF to 1000µF. The filtered dc

being unregulated, IC LM7805 is used to get 5V DC constant at its pin no 3

irrespective of input DC varying from 9V to 14V. The input dc shall be varying in the

event of input ac at 230volts section varies in the ratio of V1/V2=N1/N2.

The regulated 5V DC is further filtered by a small electrolytic capacitor of 10µF for

any noise so generated by the circuit. One LED is connected of this 5V point in series

with a resistor of 330Ω to the ground i.e., negative voltage to indicate 5V power

supply availability. The 12V point is used for other applications as on when required.

50

Page 61: Major project report

5.1.2 MAX232

The MAX232 used in the project is an integrated circuit that converts signals from an

RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits

like microcontroller. The MAX232 is a dual driver/receiver and typically converts the

RX, TX, CTS and RTS signals

5.1.3 BRIEF EXPLANATION OF TSOP 1738

The TSOP 1738 is a member of IR remote control receiver series. This IR sensor

module consists of a PIN diode and a pre amplifier which are embedded into a single

package. The output of TSOP is active low and it gives +5V in off state. When IR

waves, from a source, with a centre frequency of 38 kHz incident on it, its output goes

low.

TSOP module has an inbuilt control circuit for amplifying the coded pulses from the

IR transmitter. A signal is generated when PIN photodiode receives the signals. This

input signal is received by an automatic gain control (AGC). For a range of inputs, the

output is fed back to AGC in order to adjust the gain to a suitable level. The signal

from AGC is passed to a band pass filter to filter undesired frequencies. After this, the

signal goes to a demodulator and this demodulated output drives an npn transistor.

The collector output of the transistor is obtained at pin 3 of TSOP module.

5.2 OPERATION

5.2.1 Connections

The output of power supply which is 5v is connected to the 11&32 pin of pic

microcontroller & Gnd is connected to 12&31 pin of pic microcontroller. Pins 25, 26

of pic microcontroller are connected to pins 11 & 12 of Max232.

Pins 13 and 14 of Max232 are given to pins 2 and 3 of DB9 connector. Pin 33 of pic

microcontroller are given to 3rd

pin of TSOP1738.

51

Page 62: Major project report

5.2.2 Working

The project uses an IR receiver such as TSOP1738 that responds to only specific

frequency of 38 kHz, in order to avoid receiving false signal from normal

environmental infrared sources. The output of this receiver is interfaced to interrupt 1

i.e., pin 33 of the pic microcontroller. A standard TV remote that delivers infrared

codes at 38 kHz is thus received by the TSOP receiver feeding a 14 bit data so emitted

from the remote to the controller through receiver. The program is so returned that it

recognizes the 14 bit data relating to a particular number being pressed at the

remote.Here the channel ON & OFF buttons and volume low to volume high buttons

of the TV remote buttons are used for sending specific 14 bit data to pin – 33 of PIC

MC. Software used at the PC receives these commands the serial port being connected

to the MC through MAX232, RS232 interface. Thus the TV remote works like a

mouse from a distance.

52

Page 63: Major project report

6. LAYOUT DIAGRAM

6.1 LAYOUT DIAGRAM

Fig.6.1 Layout Diagram

53

Page 64: Major project report

7. MICROCONTROLLER PROGRAMMING

7.1 CODING

54

Page 65: Major project report

55

Page 66: Major project report

56

Page 67: Major project report

57

Page 68: Major project report

8. HARDWARE TESTING

8.1 CONTINUITY TEST

In electronics, a continuity test is the checking of an electric circuit to see if current

flows (that it is in fact a complete circuit). A continuity test is performed by placing a

small voltage (wired in series with an LED or noise-producing component such as a

piezoelectric speaker) across the chosen path. If electron flow is inhibited by broken

conductors, damaged components, or excessive resistance, the circuit is "open".

Devices that can be used to perform continuity tests include multi meters which

measure current and specialized continuity testers which are cheaper, more basic

devices, generally with a simple light bulb that lights up when current flows.

An important application is the continuity test of a bundle of wires so as to find the

two ends belonging to a particular one of these wires; there will be a negligible

resistance between the "right" ends, and only between the "right" ends.

This test is the performed just after the hardware soldering and configuration has been

completed. This test aims at finding any electrical open paths in the circuit after the

soldering. Many a times, the electrical continuity in the circuit is lost due to improper

soldering, wrong and rough handling of the PCB, improper usage of the soldering

iron, component failures and presence of bugs in the circuit diagram. We use a multi

meter to perform this test. We keep the multi meter in buzzer mode and connect the

ground terminal of the multi meter to the ground. We connect both the terminals

across the path that needs to be checked. If there is continuation then you will hear the

beep sound.

58

Page 69: Major project report

8.2 POWER ON TEST

This test is performed to check whether the voltage at different terminals is according

to the requirement or not. We take a multi meter and put it in voltage mode.

Remember that this test is performed without microcontroller. Firstly, we check the

output of the transformer, whether we get the required 12 V AC voltage.

Then we apply this voltage to the power supply circuit. Note that we do this test

without microcontroller because if there is any excessive voltage, this may lead to

damaging the controller.

We check for the input to the voltage regulator i.e., are we getting an input of 12v and

an output of 5v. This 5v output is given to the microcontrollers’ 40th pin. Hence we

check for the voltage level at 40th

pin. Similarly, we check for the other terminals for

the required voltage. In this way we can assure that the voltage at all the terminals is

as per the requirement.

59

Page 70: Major project report

9. RESULT AND CONCLUSION

9.1 RESULT

TV remote works like a mouse i.e. by pressing its button following operations are

performed :

2 = up arrow

5 = down arrow

4 = left arrow

6 = right arrow

1 = left click

3 = right click

Volume+ = to increase cursor speed

Volume- = to decrease cursor speed

9.2 CONCLUSION

Mouse Driver is used on the PC that recognizes data received from the

microcontroller through the COM port and performs the required operation.

Designated numbers on the TV remote are used to perform up - down, right - left

cursor movement. Features like left click and right click of the mouse can also be

performed with the TV remote. Further this project can be enhanced using Bluetooth/

RF technology to overcome the traditional line of sight communication drawbacks of

the infrared type.

60

Page 71: Major project report

10. ADVANTAGES AND FUTURE SCOPE

10.1 ADVANTAGES

Physically Being in Front of Computer.

Reduced Productivity Cost.

BT Connectivity.

Not Required Mouse Pad

Absence of BT Dongle

10.2 FUTURE SCOPE

Elimination of Specific Remote

Contolling Various Applications Viz

o For entertainment purpose,

o Browsers,

o Players like i-Tunes, etc.

61

Page 72: Major project report

REFERENCES

DATA SHEETS

PIC16F877A

7805 Regulator

IN4007 Diode (Bridge Rectifier)

LEDs

Philips TV Remote

RS232 DB9 Connector

TSOP 1738

WEBSITES

www.atmel.com

www.beyondlogic.org

www.wikipedia.org

www.howstuffworks.com

www.alldatasheets.com

62