pc remote nil

96
VISWAJYOTHI COLLEGE OF ENGINEERING AND TECHNOLOGY VAZHAKULAM, MUVATTUPUZHA – 686 670 MINI PROJECT REPORT ON PC REMOTE CONTROL ANIL PIUS BINS ABRAHAM NITHIN JOY

Upload: piusanil

Post on 28-Nov-2014

148 views

Category:

Documents


9 download

TRANSCRIPT

Page 1: Pc Remote nil

VISWAJYOTHI COLLEGE OF ENGINEERINGAND TECHNOLOGY

VAZHAKULAM, MUVATTUPUZHA – 686 670

MINI PROJECT REPORT

ON

PC REMOTE CONTROL

ANIL PIUS

BINS ABRAHAM

NITHIN JOY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING (2008-2012)

Page 2: Pc Remote nil

PC REMOTE

CONTROL

2

Page 3: Pc Remote nil

VISWAJYOTHI COLLEGE OF ENGINEERING AND TECHNOLOGY

VAZHAKULAM, MUVATTUPUZHA – 686 670

PC REMOTE CONTROL

MINI PROJECT

Submitted in partial fulfillment for the requirement of the

Award of Degree of Bachelor of Technology in

Electronics and Communication Engineering of

Mahatma Gandhi University.

BY

ANIL PIUS

BINS ABRAHAM

NITHIN JOY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

BATCH 2008-2012

3

Page 4: Pc Remote nil

VISWAJYOTHI COLLEGE OF ENGINEERINGAND TECHNOLOGY

VAZHAKULAM, MUVATTUPUZHA – 686 670

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CERTIFICATE

This is to certify that this mini project report entitled “PC REMOTE CONTROL’’is the bonafide report of mini project work done by Anil Pius,Bins Abraham and Nithin Joy of sixth semester Electronics and Communication Engineering in partial fulfillment for the requirement of the award of Bachelor of Technology in Electronics and Communication Engineering of Mahatma Gandhi University.

REG NO:

Mini Project Coordinator Head of Dept.

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

Mr. Melvin C Jose Prof. Jose P Varghese.ECE Dept, VJCET ECE Dept., VJCET

4

Page 5: Pc Remote nil

5

Page 6: Pc Remote nil

ACKNOWLEDGEMENT

We are bounded to thank GOD ALMIGHTY for his grace and blessings

he showered on us throughout this Endeavour.

We express our sincere thanks to our Principal Dr. M.G. GRASIUS for

his kind cooperation in all aspects of our project.

We are very much grateful to Prof. JOSE P VARGHESE, Head of

Department, Electronics and Communication Engineering, for helping

me to take up this venture and for fostering the excellent academic

climate in the Department.

It is with pleasure and a deep sense of gratitude that we acknowledge

here the invaluable guidance and constant encouragement given by

our guide Mr.MELVIN C JOSE & Ms.CUCKOO ANITHA JOSEPH,

Lecturers, Electronics and communication Engineering.

We are thankful to all staffs of Electronics Department Laboratories

for all their help and support.

We are indebted to all others, who were constantly suggesting better

way to process our work.

Our project would not have been a success without the prayers and

blessings of our parents.

ANIL PIUS

BINS ABRAHAM

NITHIN JOY

6

Page 7: Pc Remote nil

ABSTRACT

The convenience of selecting TV channels using your remote and then pointing the same remote to your Computer so that you can control the whole system using the single remote control. The 8 bit Microcontroller AT89C2051 is used to control all the system. An integrated Infrared Receiver is used to receive the infrared signal from the remote control handset.The received infrared signal was decoded by using the program, which was written on the ROM of the Microcontroller. The programs are flashed on the ROM area of the Microcontroller. The Flash memory is a type of EEPROM. The Details of the switch pressed was sent to the PC through its serial port. In the PC, Visual Basic was used to control the PC through the API functions.

The Following functions can be done with PC Remote control. * All Numerical Keys (0 - 9) * Arithmetic Keys (+, -, /, *) * Enter, Escape, Help, Refresh, Caps lock, Tab, Back space, delete, Left, Right, Up, down arrows, Page up, Page down, Window keys. * Calculator, Notepad * CD drive Open/Close * Control panel * Computer log off, reboot or shutdown * Volume Up, down, Mute * 5 User defined Programs

7

Page 8: Pc Remote nil

CONTENTS

8

Page 9: Pc Remote nil

INTRODUCTION

The project aims to development of a PC remote

control. This device helps to have better control of computer without mouse and

keyboard. As a result they can be avoided and their functions are incorporated in the

PC remote control. The commands made by the user through the PC remote control is

read and interpreted by the AT89C51 microcontroller. The button pressed in PC

remote control by the user will be detected by microcontroller based circuit and these

details are sent to PC via RS232.

PC remote control is basically an alternative for a mouse. PC remote control offers

a wireless means of communication between the computer and the user. PC remote

control helps to overcome the disadvantages of wired and wireless mouse. Such

devices can be easily attached to computers. PC remote control has become an

indispensible component of modern desktops and laptops.

The Following functions can be done with PC Remote control. * All Numerical Keys (0 - 9) * Arithmetic Keys (+, -, /, *) * Enter, Escape, Help, Refresh, Caps lock, Tab, Back space, delete, Left, Right, Up, down arrows, Page up, Page down, Window keys. * Calculator, Notepad * CD drive Open/Close * Control panel * Computer log off, reboot or shutdown * Volume Up, down, Mute * 5 User defined Programs

9

Page 10: Pc Remote nil

PROJECT DESCRIPTION

The Main Part of the system is designed by using the Microcontroller AT89c2051. The infrared receiver have three pins in which two pins are for +5v supply and ground while the third pin is for data output. The Infrared Receiver is designed for demodulating the frequency of 30khz to 40khz, for example, TSOP1838 is designed for demodulating frequency of 38khz which is used in our project.

The IR receiver module receives the data sent by remote handset, amplifies, demodulates and converts it to MCU compatible voltage format and outputs it on its data output pin. The microcontroller decodes the infrared signal data and the microcontroller will sent the infrared Key code to the PC through the Serial port.

We use Microsoft Visual Basic 6.0 to receive the Key code through the Component called MSCOMM which is an component for the Com port control. Through this component we get the key code and do the appropriate functions.

After getting this key code of the Remote control the program compare the keycode with the code present in the program and if they are equal then the corresponding function was done.

10

Page 11: Pc Remote nil

SYSTEM REQUIREMENTS

SOFTWARE SPECIFICATIONS

1. Platform : Windows XP

2. Technology : Visual basic 2006(VB 6)

HARDWARE SPECIFICATIONS

1. AT89C51 Microcontroller

2. RS- 232/Serial Port Interfacing

3. Max 232 (level translator)

4. Philips RC5 remote control

5. Pentium IV or above Processor

6. Minimum of 512MB RAM

11

Page 12: Pc Remote nil

HARDWARE DESCRIPTION

BLOCK DIAGRAM

12

Page 13: Pc Remote nil

PERSONAL COMPUTER

BLOCK DIAGRAM DESCRIPTION

The figure above shows block diagram the PC remote

control using microcontroller.

Remote control:

The remote control is an input device. The remote control is an infra-red

device. The cheapest way to remotely control a device within a visible range is via

Infra-Red light. Infra-Red actually is normal light with a particular colour. Its wave

length of 950nm is below the visible spectrum. That's one of the reasons why IR is

chosen for remote control purposes. Another reason is because IR LEDs are quite easy

to make, and therefore can be very cheap. The important constituents of Infra-Red

remote control are transmitter and receiver.

The transmitter is a battery powered handset. It should consume as

little power as possible, and the IR signal should be as strong as possible to achieve an

acceptable control distance. Preferably it should be shock proof as well. Quartz crystals

13

MICROCONTROLLER BASED EMBEDDED

SYSTEM

REMOTE CONTROL

Page 14: Pc Remote nil

are seldom used in handsets. They are very fragile and tend to break easily when the

handset is dropped. Ceramic resonators are much more suitable here, because they can

withstand larger physical shocks. The fact that they are a little less accurate is not

important.

The received IR signal is picked up by the IR detection diode. The most important

selection criteria are the modulation frequency used and the availability in region. The

important constituents of receiver are amplifier, limiter, band pass filter, demodulator,

integrator and comparator. The limiter acts as an AGC circuit to get a constant pulse

level, regardless of the distance to the handset. Only the AC signal is sent to the Band

Pass Filter. The Band Pass Filter is tuned to the modulation frequency of the handset

unit. The purpose of detector, integrator and comparator is to detect the presence of the

modulation frequency. If this modulation frequency is present the output of the

comparator will be pulled low.

14

Page 15: Pc Remote nil

MICROCONTROLLER

A microcontroller is a computer-on-a-chip, containing a processor,memory, and input/output functions. It is a microprocessor emphasizing high integration, in contrast to a general-purpose microprocessor (the kind used in a PC).In addition to the usual arithmetic and logic element of a general purpose microprocessor, the microcontroller integrates additional elements such as read-write memory for data storage, read-only memory for program storage, peripheral devices, and input/output interfaces. At clock speeds of as little as a few MHz or even lower, microcontrollers often operate at very low speed compared to modern day microprocessors, but this is adequate for typical applications. They consume relatively little power (milliwatts), and will generally have the ability to sleep while waiting for an interesting peripheral event such as a button press to wake up again to do something. Power consumption while sleeping may be just nano watts, making them ideal for low power and long lasting battery applications. The microcontroller we used is the AT89C2051 manufactured by ATMEL Corporation. It is a 20 pin flash based 8bit CMOS microcontroller. The embedded software of themicrocontroller decodes the RC5 signal from the remote, which isthe major function in this project. This chip includes highperformance RISC CPU with plenty of features. Besides it is alow priced and easily available.

AT89C2051 Features

Some of the special features of this microcontroller aregiven below.

Compatible with MCS®-51Products 2K Bytes of Reprogrammable Flash Memory –Endurance: 10,000 Write/Erase Cycles 2.7V to 6V Operating Range Fully Static Operation: 0 Hz to 24 MHz Two-level Program Memory Lock

128x8-bit Internal RAM

15

Page 16: Pc Remote nil

15 Programmable I/O LinesTwo 16-bit Timer/CountersSix Interrupt SourcesProgrammable Serial UART ChannelDirect LED Drive OutputsOn-chip Analog ComparatorLow-power Idle and Power-down ModesGreen (Pb/Halide-free) Packaging Option

PIN Diagram

Microcontroller communicates input/output devices throughit’s ports. In AT89C2051 there are 15 I/O ports available for theuser. They can be use as general digital input or output pins.Some I/O pins occupy other functions as interrupts, counter,serial input/output ports, timers etc. they are selected in softwareroutines according to the logic of the program. A description ofthe I/O ports of the AT89C2051 is given below.

PORT 1 The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2to P1.7 provide internal pull-ups. P1.0 and P1.1 require externalpull-ups. P1.0 and P1.1 also serve as the positive input (AIN0)

and the negative input (AIN1), respectively, of the on-chip

16

Page 17: Pc Remote nil

precision analog comparator. The Port 1 out-put buffers can sink20 mA and can drive LED displays directly. When 1s are writtento Port 1 pins, they can be used as inputs. When pins P1.2 toP1.7 are used as inputs and are externally pulled low, they willsource current (IIL) because of the internal pull-ups. Port 1 alsoreceives code data during Flash programming and verification.

PORT 3

Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/Opins with internal pull-ups. P3.6 is hard-wired as an input to theoutput of the on-chip comparator and is not accessible as a general-purpose I/O pin. The Port 3 output buffers can sink 20 mA.When 1s are written to Port 3 pins they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 3pins that are externally being pulled low will source current (IIL)because of the pull-ups.

Port Pin

Alternate Functions

P3.0 RXD (serial input port)P3.1 TXD (serial output port)P3.2 INT0 (external interrupt 0)P3.3 INT1 (external interrupt 1)P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

17

Page 18: Pc Remote nil

Microcontroller based embedded system:

The microcontroller based embedded system as an interpreter remote controller

commands. It takes information from the remote controller and translates it into

information that PC can understand. The microcontroller based embedded system

consist of 8051 microcontroller and Max 232 level translator IC. The 8051

microcontroller receives commands from remote control and translates it into

information that PC can understand. The RS232 is not compatible with

microcontrollers, we need a line driver to convert the RS232’s signals to TTL voltage

levels that will be acceptable to the microcontroller’s RxD pin. The MAX232 converts

from RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of the

MAX232 chip is that it uses a +5V power source which is the same as the source

voltage for the microcontroller.

Remote control as input device:

The remote control that we offer basically work like a

mouse. Once the software driver for the remote control is installed, the remote control

emulates mouse functions. Pressing the button on remote control is basically the same

as clicking your keyboard. When you press the button, it will carry out the intended

action of the button. The remote control uses Philips RC-5 protocol for communication

with the computer. So the remote control is called Philips RC-5 remote control.

18

Page 19: Pc Remote nil

Philips RC-5 protocol:

The RC-5 code from Philips is possibly the most used protocol because of the wide

availability of cheap remote controls. The important features of the protocol are

5 bit address and 6 bit command length

Bi-phase coding (aka Manchester coding)

Carrier frequency of 38kHz

Constant bit time of 1.778ms

The protocol uses bi-phase modulation of a 38 kHz IR

carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of

the bit time filled with a burst of the 38 kHz carrier and the other half being idle. A

logical zero is represented by a burst in the first half of the bit time. A logical one is

represented by a burst in the second half of the bit time. The pulse/pause ratio of the 38

kHz carrier frequency is 1/3 or 1/4 which reduces power consumption.

The first two pulses are the start pulses, and are both

logical "1". The 3rd bit is a toggle bit. This bit is inverted every time a key is released

and pressed again. This way the receiver can distinguish between a key that remains

down, or is pressed repeatedly. The next 5 bits represent the IR device address, which

is sent with MSB first. The address is followed by a 6 bit command, again sent with

MSB first. A message consists of a total of 14 bits, which adds up to a total duration of

25 ms. Sometimes a message may appear to be shorter because the first half of the start

bit S1 remains idle. And if the last bit of the message is logic "0" the last half bit of the

message is idle too. As long as a key remains down the message will be repeated every

114ms. The toggle bit will retain the same logical level during all of these repeated

messages. It is up to the receiver software to interpret this auto repeat feature.

19

Page 20: Pc Remote nil

CIRCUIT DIAGRAM

20

Page 21: Pc Remote nil

CIRCUIT DIAGRAM DESCRIPTION

The project aims to development of a PC remote control using 8051 microcontroller.

The commands made by the user through the pressing keys is read and interpreted by

the microcontroller. The key pressed by the user will be detected by microcontroller

based embedded system and these details are sent to PC via RS232.It can be used for

carrying the functions of mouse and media player in a systems. U4 is AT89C51 is an

8bit 8051 microcontroller. The regulated +5V supply for the microcontroller is derived

using MAX 232 IC. U2 is infra-red remote control receiver TSOP1736. U1 is level

translator MAX 232 IC.

COMPONENTS LIST

COMPONENT NAMESPECIFICATIONNUMBER

U3 7805 voltage regulator 1

U4 AT89C51 Microcontroller 1

U2 IR Receiver TSOP1738 1

U1 Level translator MAX 232 1

C1-C2 33 picofarad capacitor 2

C3-C7 10 microfarad capacitor 5

C8 0.1 microfarad capacitor 1

C9 4.7 microfarad capacitor 1

D1-D2 1N4148 diode 2

R1 56k resistor 1

P1 RS232 Female connector 1

X1 Crystal oscillator 1

21

Page 22: Pc Remote nil

COMPONENT SPECIFICTION

1.MAX232 IC

Applicability

This module is primary of interest for people building their own electronics with an RS-

232 interface. Off-the-shelf computers with RS-232 interfaces already contain the

necessary electronics, and there is no need to add the circuitry as described here.

MAX232(A) DIP Package

MAX232(A) DIP Package Pin Layout

Nbr Name Purpose Signal VoltageCapacitor Value MAX232

Capacitor Value MAX232A

1 C1++ connector for capacitor C1

capacitor should stand at least 16V

1µF 100nF

2 V+output of voltage pump

+10V, capacitor should stand at least 16V

1µF to VCC 100nF to VCC

3 C1-- connector for capacitor C1

capacitor should stand at least 16V

1µF 100nF

4 C2++ connector for capacitor C2

capacitor should stand at least 16V

1µF 100nF

5 C2-- connector for capacitor C2

capacitor should stand at least 16V

1µF 100nF

6 V- output of voltage -10V, capacitor 1µF to GND 100nF to GND

22

Page 23: Pc Remote nil

pump / invertershould stand at least 16V

7 T2out Driver 2 output RS-232

8 R2in Receiver 2 input RS-232

9 R2out Receiver 2 output TTL

10 T2in Driver 2 input TTL

11 T1in Driver 1 input TTL

12 R1out Receiver 1 output TTL

13 R1in Receiver 1 input RS-232

14 T1out Driver 1 output RS-232

15 GND Ground 0V 1µF to VCC 100nF to VCC

16 VCC Power supply +5V see above see above

V+(2) is also connected to VCC via a capacitor (C3). V-(6) is connected to GND via a

capacitor (C4). And GND(15) and VCC(16) are also connected by a capacitor (C5), as

close as possible to the pins.

23

Page 24: Pc Remote nil

2.CRYSTAL OSCILLATOR(11.0592 Mhz)

A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters and receivers. The most common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around them became known as "crystal oscillators."

Quartz crystals are manufactured for frequencies from a few tens of kilohertz to tens of megahertz. More than two billion (2×109) crystals are manufactured annually. Most are used for consumer devices such as wristwatches, clocks, radios, computers, and cellphones. Quartz crystals are also found inside test and measurement equipment, such as counters, signal generators, and oscilloscopes.

OPERATION

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly ordered, repeating pattern extending in all three spatial dimensions.

Almost any object made of an elastic material could be used like a crystal, with appropriate transducers, since all objects have natural resonant frequencies of vibration. For example, steel is very elastic and has a high speed of sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size, shape, elasticity, and the speed of sound in the material.High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork. For

24

Page 25: Pc Remote nil

applications not needing very precise timing, a low-cost ceramic resonator is often used in place of a quartz crystal.

When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency.

ELECTRICAL EQUILANT CIRCUIT

A quartz crystal can be modeled as an electrical network with a low impedance (series) and a high impedance (parallel) resonance point spaced closely together. Mathematically (using the Laplacetransform) the impedance of this network can be written as:

or,

where s is the complex frequency (s = jω), ωs is the series resonant frequency in radians per second and ωp is the parallel resonant frequency in radians per second.

3.TSOP 1738 based proximity sensor 25

Page 26: Pc Remote nil

Details

Received modulated infrared signal and converts into electrical signal.

Features

Photodetector and preamplifier circuit in the same casing. Receives and amplifies the infrared signal without any external component. 5 V output (active at level 0). 38 kHz integrated oscillator.

26

Page 27: Pc Remote nil

APPENDIX 1

27

Page 28: Pc Remote nil

PROGRAMINCLUDE reg_51.pdf

INPUT EQU P3.2; Port3,Bit2 is used as input. The demodulated

;signal with active low level is connected to this pin.RB0 EQU 000H ; Select Register Bank 0

RB1 EQU 008H ; Select Register Bank 1 ...poke to PSW to use

DSEG ; This is internal data memory

ORG 20H ; Bit adressable memory

FLAGS: DS 1

CONTROL BIT FLAGS.0 ; toggles with every new keystroke

NEW BIT FLAGS.1 ; Bit set when a new command has been received

COMMAND: DS 1 ; Received command byte

SUBAD: DS 1 ; Device subaddress

BUFFER: DS 30 ; Buffer to store length of transmitted pulses

TOGGLE: DS 1 ;Toggle every bit

ANS: DS 1 ;

ADDR: DS 1

STACK: DS 1 ; Stack begins here

CSEG ; Code begins here

;---------==========----------==========---------

PROCESSOR INTERRUPT AND RESET VECTORS

;---------==========----------==========---------

ORG 00H ; Reset28

Page 29: Pc Remote nil

JMP MAIN

ORG 0003H ; External Interrupt0

JMP RECEIVE

;---------==========----------==========---------

----------==========----------==========---------

Interrupt 0 routine

;---------==========----------==========----------

RECEIVE:

CPL P3.4

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$ ; Waste Time to sync second bit

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$ ; Waste Time to sync second bit

Mov 2,#134 ; Time Loop (3/4 bit time)

DJNZ 2,$ ; Waste Time to sync second bit

CLR a

MOV r6,#07h

pol1: MOV c,INPUT

RLC a

MOV 2,#235 ; Waste time for next BIT

DJNZ 2,$

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

29

Page 30: Pc Remote nil

MOV 2,#105 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

DJNZ r6,pol1

MOV SUBAD,A

MOV r6,#06h

pol2:

MOV c,Input

RLC a

Mov 2,#235 ; Waste time for next BIT

DJNZ 2,$

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

MOV 2,#235 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

MOV 2,#105 ; Time Loop (3/4 bit time)

DJNZ 2,$; Waste Time to sync second bit

DJNZ r6,pol2

MOV COMMAND,A; Save Command at IRData memory

30

Page 31: Pc Remote nil

MOV A,SUBAD

MOV ADDR,A

ANL A,#0FH

MOV SUBAD,A

CJNE A,#03H,ZXC1

MOV A,COMMAND

CPL A

MOV COMMAND,A

AJMP ASZ

ZXC1: MOV A,SUBAD

CJNE A,#00H,ANSS

AJMP ASZ

ASZ: MOV A,ADDR

ANL A,#20H

MOV TOGGLE,A

CJNE A,ANS,ANSS

AJMP WAR

ANSS: JMP ANS1

WAR:

MOV TMOD,#20H

MOV TH1,#0FDH

MOV SCON,#50H

SETB TR1

MOV A,COMMAND

31

Page 32: Pc Remote nil

MOV P0,A

MOV SBUF,A

JNB TI,$

CLR TI

CLR TR1

MOV ANS,TOGGLE

MOV A,ANS

CPL ACC.5

MOV ANS,A

SETB NEW ; Set flag to indicate the new command

;#######################################################

ANS1:

RETI

; ---------==========----------==========---------

32

Page 33: Pc Remote nil

; Main routine. Program execution starts here.

; ---------==========----------==========---------

MAIN:

MOV SP,#60H

SETB EX0 ; Enable external Interrupt0

CLR IT0 ; triggered by a high to low transition

SETB EA; /* Enable global interrupt */

MOV ANS,#00H ; clear temp toggle bit

CLR NEW

LOO:

JNB NEW,LOO

CLR NEW

AJMP LOO

END

*******___________________________________________________*******

PC REMOTE.exe

It is a windows application created in the visual basicprogramming language. For the working of this PC remote thisapplication should be installed in the computer.This program scans the serial port frequently when itstarted. Thus this application read the decoded serial BCD data

33

Page 34: Pc Remote nil

from the PC COM port. There is several actions are predefined inthis application for the TV remote buttons.

When this application closes the PC Remote working also stopsdown.

34

Page 35: Pc Remote nil

VISUAL BASIC

Visual Basic is a tool to develop Windows (Graphic UserInterface - GUI) applications. The applications have a familiarappearance to the user. Visual Basic is event-driven, meaningcode remains idle until called upon to respond to some event(button pressing, menu selection ...). Visual Basic is governed byan event processor. Nothing happens until an event is detected.Once an event is detected, the code corresponding to that event(event procedure) is executed. Program control is then returnedto the event processor. Some Features of Visual BasicFull set of objects - you 'draw' the applicationLots of icons and pictures for your useResponse to mouse and keyboard actionsClipboard and printer accessFull array of mathematical, string handling, and graphics functionsCan handle fixed and dynamic variable and control arraysSequential and random access file supportUseful debugger and error-handling facilitiesPowerful database access toolsActiveX supportPackage & Deployment Wizard makes distributing your applications simple.

From the development of Visual Basic there have been different versions of the software.We used the Visual Basic 6.0.somefeatures of the version is listed below.

Faster compilerNew ActiveX data control objectAllows database integration with wide variety ofapplicationsNew data report designerNew Package & Deployment WizardAdditional internet capabilities.

35

Page 36: Pc Remote nil

VISUAL BASIC PROGRAM

MAIN MODULE

Public Sub restart() Dim cExitWindows As New clsExitWindowsOn Error GoTo errHandle cExitWindows.ExitWindows WE_REBOOT Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to Restart your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub shutdown() Dim cExitWindows As New clsExitWindowsOn Error GoTo errHandle cExitWindows.ExitWindows WE_SHUTDOWNExit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to Shutdown your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd Sub

Public Sub start_menu()On Error GoTo errHandleIf frmmain.Command2.Caption = "Open Start Menu" Then Call keybd_event(VK_CONTROL, 0, 0, 0) Call keybd_event(VK_ESCAPE, 0, 0, 0) Call keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0) Call keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0) frmmain.Command2.Caption = "Close Start Menu"Else Call keybd_event(VK_ESCAPE, 0, 0, 0) Call keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0) frmmain.Command2.Caption = "Open Start Menu"End IfExit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to open the Start Menu of your computer" frmmsg.Label1.BackColor = vbBlue

36

Page 37: Pc Remote nil

Resume NextEnd SubPublic Sub notepad()On Error GoTo errHandleresult = Shell("notepad.exe", vbNormalFocus)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to open Notepad in your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd Sub

Public Sub cd_open()On Error GoTo errHandlemciSendString "set cdaudio door open", 0, 0, 0Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to open CD drive of your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub cd_close()On Error GoTo errHandlemciSendString "set cdaudio door closed", 0, 0, 0Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to Close CD drive of your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub calculator()On Error GoTo errHandleresult = Shell("calc", vbNormalFocus)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run Calculator Utility on your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub control_panel()On Error GoTo errHandleresult = Shell("rundll32.exe shell32.dll,Control_RunDLL", 5)Exit Sub

37

Page 38: Pc Remote nil

errHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg vbCrLf & "Unable to Show Control Panel of your computer" & vbCrLf frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub show_desktop()On Error GoTo errHandle ' 77 is the character code for the letter 'M' Call keybd_event(VK_LWIN, 0, 0, 0) Call keybd_event(77, 0, 0, 0) Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0) Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to Show Desktop of your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub prog1()On Error GoTo errHandleCall ShellExecute(hWnd, "Open", Form2.program1.Text, "", App.Path, 1)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run the Program on your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub prog2()On Error GoTo errHandleCall ShellExecute(hWnd, "Open", Form2.program2.Text, "", App.Path, 1)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run the Program on your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub prog3()On Error GoTo errHandleCall ShellExecute(hWnd, "Open", Form2.program3.Text, "", App.Path, 1)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run the Program on your computer"

38

Page 39: Pc Remote nil

frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub prog4()On Error GoTo errHandleCall ShellExecute(hWnd, "Open", Form2.program4.Text, "", App.Path, 1)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run the Program on your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd SubPublic Sub prog5()On Error GoTo errHandleCall ShellExecute(hWnd, "Open", Form2.program5.Text, "", App.Path, 1)Exit SuberrHandle: frmmsg.Label1.BackColor = vbRed prcShowMsg "Unable to run the Program on your computer" frmmsg.Label1.BackColor = vbBlue Resume NextEnd Sub

**********************************************************************

39

Page 40: Pc Remote nil

SYSTEM ANALYSIS

IDENTIFYING PROBLEMS OF EXISTING SYSTEM

Drawbacks of the mouse

1. Difficulties due to wire.

2. Easy damageable scrolling ball.

3. Reliability of optical sensors.

4. Cannot be operated from far distances.

ADVANTAGES OF PROPOSED SYSTEM

Merits of the Remote

1. Wirelessness.

2. Easy to use.

3. Efficient and reliable

4. Withstand larger physical shocks.

40

Page 41: Pc Remote nil

FUTURE FORECAST The ‘pc remote control’ can be made more useful by designing a special remote instead of ordinary tv remote, by including more buttons.Thereby we can control almost all keyboard functions by using this remote.

Hence we can use this while watching a movie or presenting a slideshow through laptops or pc, by using this remote control.

Wireless mouse controls can be eliminated by using this remote control.

CONCLUSION

The system has been tested in all ways and well executed to perform the

keyboard and mouse functions. The simplicity in the design and flexible operation will

be very helpful in using the device. The device is highly user friendly in nature. The

device developed has tried to avoid almost all disadvantages caused due wired, wireless

and optical mouse.

The usage of wired and optical mouse is limited by length of the wire connecting

to the PS2 port. The main disadvantage with the wireless mouse is the consumption of

power. The PC remote control allows the user to have better control over the computer

within a short range of distance.

41

Page 42: Pc Remote nil

BIBLIOGRAPHY

REFERENCES:

Electronic Communication Systems

– Wayne Tomasi

The 8051 Microcontroller and Embedded Systems

– Muhammad Ali Mazidi

Programming in ANSI C

– E Balagurusamy

WEBSITES:

www.edaboard.com

www.datasheet4u.com

www.datasheetarchive.com

42

Page 43: Pc Remote nil

APPENDIX 2

43

Page 44: Pc Remote nil

Appendix A. DATA SHEET AT89C51

THE MICROCONTROLLER (AT89C51)

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer

with 4K bytes of Flash programmable and erasable read only memory (PEROM). The

device is manufactured using Atmel’s high-density nonvolatile memory technology

and is compatible with the industry-standard MCS-51 instruction set and pinout. The

on-chip Flash allows the program memory to be reprogrammed in-system or by a

conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU

with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer

which provides a highly-flexible and cost-effective solution to many embedded control

applications.

Harvard architecture has the program and data

memory as separate memories and is accessed from separate buses; this improves

speed over the traditional Von Neumann architecture in which the program and data

are fetched from the same memory using the same bus.

44

Page 45: Pc Remote nil

45

Page 46: Pc Remote nil

46

Page 47: Pc Remote nil

The AT89C51 provides the following standard

features: 4Kbytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters,

five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator

and clock circuitry. In addition, the AT89C51 is designed with static logic for operation

down to zero frequency and supports two software selectable power saving modes. The

Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and

interrupt system to continue functioning. The Power-down Mode saves the RAM

contents but freezes the oscillator disabling all other chip functions until the next

hardware reset.

Pin Description

VCC - Supply voltage.

GND - Ground.

Port 0

Port 0 is an 8-bit open-drain bi-directional I/O port. As an output

port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins

can be used as high impedance inputs. Port 0 may also be configured to be the

multiplexed low order address/data bus during accesses to external program and data

memory. In this mode P0 has internal pullups. Port 0 also receives the code bytes

during Flash programming, and outputs the code bytes during program verification.

External pullups are required during program verification.

Port 1

47

Page 48: Pc Remote nil

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

Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1

pins they are pulled high by the internal pullups and can be used as inputs. As inputs,

Port 1 pins that are externally being pulled low will source current (IIL) because of the

internal pullups. Port 1 also receives the low-order address bytes during Flash

programming and verification.

Port 2

Port 2 is an 8-bit bi-directional I/O port with internal pullups. The

Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2

pins they are pulled high by the internal pullups and can be used as inputs. As inputs,

Port 2 pins that are externally being pulled low will source current (IIL) because of the

internal pullups. Port 2 emits the high-order address byte during fetches from external

program memory and during accesses to external data memory that uses 16-bit

addresses (MOVX @ DPTR). In this application, it uses strong internal pullups when

emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX

@ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also

receives the high-order address bits and some control signals during Flash

programming and verification.

Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3

output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they

are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins

that are externally being pulled low will source current (IIL) because of the pullups.

Port 3 also serves the functions of various special features of the AT89C51 as listed

below:

48

Page 49: Pc Remote nil

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

RST

Reset input. A high on this pin for two machine cycles while the oscillator is running

resets the device.

ALE/PROG

Address Latch Enable output pulse for latching the low byte of the

address during accesses to external memory. This pin is also the program pulse input

(PROG) during Flash programming. In normal operation ALE is emitted at a constant

rate of 1/6 the oscillator frequency, and may be used for external timing or clocking

purposes. Note, however, that one ALE pulse is skipped during each access to external

Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR

location 8EH. With the bit set, ALE is active only during a MOVX or MOVC

instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has

no effect if the microcontroller is in external execution mode.

PSEN

49

Page 50: Pc Remote nil

Program Store Enable is the read strobe to external program

memory. When the AT89C51 is executing code from external program memory, PSEN

is activated twice each machine cycle, except that two PSEN activations are skipped

during each access to external data memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the device to

fetch code from external program memory locations starting at 0000H up to FFFFH.

Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.

EA should be strapped to VCC for internal program executions. This pin also receives

the 12-volt programming enable voltage (VPP) during Flash programming, for parts

that require 12-volt VPP.

XTAL1

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

circuit.

XTAL2

Output from the inverting oscillator amplifier.

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output,

respectively, of an inverting amplifier which can be configured for use as an on-chip

oscillator, as shown in Figure 1. Either a quartz crystal or ceramic resonator may be

used. To drive the device from an external clock source, XTAL2 should be left

unconnected while XTAL1 is driven as shown in Figure 2. There are no requirements

on the duty cycle of the external clock signal, since the input to the internal clocking

50

Page 51: Pc Remote nil

circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high

and low time specifications must be observed.

Special Function Registers

The 8051 operations that do not use the internal 128-byte RAM

addresses from 00h to 7Fh are done by a group of specific internal registers, each

called a special function register, which may be addressed like internal RAM, using

addresses from 80h to FFh. Some SFRs are bit addressable and this feature allows the

programmer to change only what needs to be altered, leaving the remaining bits in that

SFR unchanged. The SFR names and equivalent internal RAM addresses are given in

following table:

NAME FUNCTION INTERNAL RAM

ADDRESS

A Accumulator 0E0

B Arithmetic 0F0

51

Page 52: Pc Remote nil

DPH Addressing external memory 83

DPL Addressing external memory 82

IE Interrupt enable control 0A8

IP Interrupt priority 0B8

P0 Input/output port latch 80

P1 Input/output port latch 90

P2 Input/output port latch A0

P3 Input/output port latch 0B0

PCON Power control 87

PSW Program status word 0D0

SCON Serial port control 98

SBUF Serial port data buffer 99

Accumulator: A is the Accumulator register. The mnemonics for accumulator-specific

instructions, however, refer to the accumulator simply as A.

B Register: The B register is used during multiply and divide operations. For other

instructions it can be treated as another scratch pad register.

Program Status Word: The PSW register contains program status information.

52

Page 53: Pc Remote nil

Stack Pointer: The Stack Pointer register is 8 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.

Data Pointer: The Data Pointer (DPTR) consists of a high byte (DPH) and a low byte

(DPL). Its intended function is to hold a 16-bit address. It may be manipulated as a 16-

bit register or as two independent 8-bit registers.

53

Page 54: Pc Remote nil

Serial Data Buffer: The Serial Data Buffer is actually two separate registers, a

transmit buffer and a receive buffer register. When data is moved to SBUF, it goes to

the transmit buffer where it is held for serial transmission. (Moving a byte to SBUF is

what initiates the transmission.) When data is moved from SBUF, it comes from the

receive buffer.

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

registers for Timer/Counters 0 and 1 respectively.

Control Registers: Special Function Registers IP, IE, TMOD, TCON, T2CON,

SCON, and PCON contain control and status bits for the interrupt system, the

timer/counters, and the serial port.

54

Page 55: Pc Remote nil

55

Page 56: Pc Remote nil

56

Page 57: Pc Remote nil

57

Page 58: Pc Remote nil

Timer/Counters

The Atmel 80C51 Microcontrollers implement two general purpose, 16-bit

timers/counters. They are identified as Timer 0 and Timer 1, and can be independently

configured to operate in a variety of modes as a timer or as an event counter. When

operating as a timer, the timer/counter runs for a programmed length of time, then

issues an interrupt request. When operating as a counter, the timer/counter counts

negative transitions on an external pin. After a preset number of counts, the counter

issues an interrupt request. The various operating modes of each timer/counter are

described in the following sections.

58

Page 59: Pc Remote nil

A basic operation consists of timer registers THx and

TLx (x= 0, 1) connected in cascade to form a 16-bit timer. Setting the run control bit

(TRx) in TCON register turns the timer on by allowing the selected input to increment

TLx. When TLx overflows it increments THx; when THx overflows it sets the timer

overflow flag (TFx) in TCON register. Setting the TRx does not clear the THx and

TLx timer registers. Timer registers can be accessed to obtain the current count or to

enter preset values. They can be read at any time but TRx bit must be cleared to preset

their values, otherwise the behavior of the timer/counter is unpredictable. The C/Tx#

control bit (in TCON register) selects timer operation, or counter operation, by

selecting the divided-down peripheral clock or external pin Tx as the source for the

counted signal. TRx bit must be cleared when changing the mode of operation,

otherwise the behavior of the timer/counter is unpredictable. For timer operation

(C/Tx# = 0), the timer register counts the divided-down peripheral clock. The timer

register is incremented once every peripheral cycle (6 peripheral clock periods). The

timer clock rate is FPER / 6, i.e. FOSC / 12 in standard mode or FOSC / 6 in X2 mode.

For counter operation (C/Tx# = 1), the timer register counts the negative transitions on

the Tx external input pin. The external input is sampled every peripheral cycle. When

the sample is high in one cycle and low in the next one, the counter is incremented.

Since it takes 2 cycles (12 peripheral clock periods) to recognize a negative transition,

the maximum count rate is FPER / 12, i.e. FOSC / 24 in standard mode or FOSC / 12

in X2 mode. There are no restrictions on the duty cycle of the external input signal, but

to ensure that a given level is sampled at least once before it changes, it should be held

for at least one full peripheral cycle. Timer 0 and Timer 1 have four operating modes

from which to select which are selected by bit-pairs (M1, M0) in TMOD. Modes 0, 1,

and 2 are the same for both timer/counters. Mode 3 is different. The four operating

modes are described below

59

Page 60: Pc Remote nil

Mode 0 (13-bit Timer)

Mode 0 configures timer 0 as a 13-bit timer which is set

up as an 8-bit timer (TH0 register) with a modulo 32 prescaler implemented with the

lower five bits of the TL0 register. The upper three bits of TL0 register are

indeterminate and should be ignored. Prescaler overflow increments the TH0 register.

As the count rolls over from all 1’s to all 0’s, it sets the timer interrupt flag TF0. The

counted input is enabled to the Timer when TR0 = 1 and either GATE = 0 or INT0 = 1.

(Setting GATE = 1 allows the Timer to be controlled by external input INT0, to

facilitate pulse width measurements). TR0 is a control bit in the Special Function

register TCON. GATE is in TMOD. The 13-bit register consists of all 8 bits of TH0

and the lower 5 bits of TL0. The upper 3 bits of TL0 are indeterminate and should be

ignored. Setting the run flag (TR0) does not clear the registers. Mode 0 operation is the

same for Timer 0 as for Timer 1. Substitute TR0, TF0 and INT0 for the corresponding

Timer 1 signals in Table 2-10. There are two different GATE bits, one for Timer 1

(TMOD.7) and one for Timer 0 (TMOD.3).

Mode 1 (16-bit Timer)

60

Page 61: Pc Remote nil

Mode 1 is the same as Mode 0, except that the Timer register is being run with all 16

bits. Mode 1 configures timer 0 as a 16-bit timer with the TH0 and TL0 registers

connected in cascade. The selected input increments the TL0 register.

Mode 2 (8-bit Timer with Auto-Reload)

Mode 2 configures timer 0 as an 8-bit timer (TL0 register) that automatically reloads

from the TH0 register. TL0 overflow sets TF0 flag in the TCON register and reloads

TL0 with the contents of TH0, which is preset by software. When the interrupt request

is serviced, hardware clears TF0. The reload leaves TH0 unchanged. The next reload

value may be changed at any time by writing it to the TH0 register. Mode 2 operation

is the same for Timer/Counter 1.

61

Page 62: Pc Remote nil

Mode 3 (Two 8-bit Timers)

Mode 3 configures timer 0 so that registers TL0 and TH0 operate as separate 8-bit

timers. This mode is provided for applications requiring an additional 8-bit timer or

counter. TL0 uses the timer 0 control bits C/T0# and GATE0 in the TMOD register,

and TR0 and TF0 in the TCON register in the normal manner. TH0 is locked into a

timer function (counting FPER /6) and takes over use of the timer 1 interrupt (TF1) and

run control (TR1) bits. Thus, operation of timer 1 is restricted when timer 0 is in mode

3. Timer 1 is identical to timer 0, except for mode 3, which is a hold-count mode.

Placing Timer 1 in mode 3 causes it to halt and hold its count. This can be used to halt

Timer 1 when TR1 run control bit is not available i.e., when Timer 0 is in mode 3.

Programming the Flash

The AT89C51 is normally shipped with the on-chip Flash memory array in the erased

state (that is, contents = FFH) and ready to be programmed. The programming

interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program

enable signal. The low-voltage programming mode provides a convenient way to

62

Page 63: Pc Remote nil

program the AT89C51 inside the user’s system, while the high-voltage programming

mode is compatible with conventional thirdparty Flash or EPROM programmers. The

AT89C51 is shipped with either the high-voltage or low-voltage programming mode

enabled. The AT89C51 code memory array is programmed byte-by byte in either

programming mode. To program any nonblank byte in the on-chip Flash Memory, the

entire memory must be erased using the Chip Erase Mode.

Programming Algorithm

Before programming the AT89C51, the address, data and control signals should be set

up. To program the AT89C51, take the following steps.

1. Input the desired memory location on the address lines.

2. Input the appropriate data byte on the data lines.

3. Activate the correct combination of control signals.

4. Raise EA/VPP to 12V for the high-voltage programming mode.

5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The

byte-write cycle is self-timed and typically takes no more than 1.5 ms.

Repeat steps 1 through 5, changing the address and data for the entire array or until the

end of the object file is reached.

Data Polling: The AT89C51 features Data Polling to indicate the end of a write cycle.

During a write cycle, an attempted read of the last byte written will result in the

complement of the written datum on PO.7. Once the write cycle has been completed,

true data are valid on all outputs, and the next cycle may begin. Data Polling may

begin any time after a write cycle has been initiated.

Ready/Busy: The progress of byte programming can also be monitored by the

RDY/BSY output signal. P3.4 is pulled low after ALE goes high during programming

63

Page 64: Pc Remote nil

to indicate BUSY. P3.4 is pulled high again when programming is done to indicate

READY.

Program Verify: If lock bits LB1 and LB2 have not been programmed, the

programmed code data can be read back via the address and data lines for verification.

The lock bits cannot be verified directly. Verification of the lock bits is achieved by

observing that their features are enabled.

Chip Erase: The entire Flash array is erased electrically by using the proper

combination of control signals and by holding ALE/PROG low for 10 ms. The code

array is written with all “1”s. The chip erase operation must be executed before the

code memory can be re-programmed.

Programming Interface

Every code byte in the Flash array can be written and the entire

array can be erased by using the appropriate combination of control signals. The write

operation cycle is selftimed and once initiated, will automatically time itself to

completion.

UART(Universal Asynchronous Receiver Transmitter )

A Universal Asynchronous Receiver Transmitter is a serial port

adapter that receives and transmits serial data with each data character preceded by a

start bit and followed by a stop bit. There is sometimes a parity bit included. These are

integrated circuits that convert data from parallel to serial transmission so instead of

having eight wires, each carrying a single bit at the same time, the serial transmission

passes the bits, one at a time along a single wire. It can also receive eight bits of serial

data then pass it into the microcontroller in a single byte. Parallel transmission is

obviously a lot faster since eight bits are moved at a time but it requires eight

64

Page 65: Pc Remote nil

connections. UARTS do a lot more than a shift register. They include parity checking

and buffers to enable it to handle about 16 bytes at a time. Most transmissions involve

the ASCII code to represent the characters to be transmitted. This is a seven-bit code to

represent each alphanumeric character and a variety of control instructions. The ASCII

code is used in both parallel and serial transmissions. Each letter and symbol has its

own seven-digit code. A further bit is added on the end to provide a parity bit. When

using ASCII signals in a serial transmission, we need to be able to tell the receiving

apparatus when a particular ASCII character has been sent. This is easily done in a

synchronous system that ensures that the transmitter and the receiver are locked

together running at the same speed. This is not the easiest way of operating the system

owing to the difficulties of ensuring the two devices remain synchronous. Therefore,

we tend to operate asynchronously. This means that we have to send a signal along

with each ASCII code to tell the receiver when the code has started and when it has

stopped. Otherwise the transmitter would send a continuous stream of data and if a bit

were lost, the receiver would get out of step and would misread all subsequent data.

To get round this problem, a 0 V ‘start’ bit is sent at the

beginning of the character and a positive ‘stop’ bit is sent at the end. This brings a

seven-bit ASCII code up to a total of 10 bits. The start and stop bits ensure that there is

at least one change of level for each character that can be used to keep the receiver

clock nearly synchronized to the transmitter for the time taken to receive that character.

For distances over a few metres, we need to use a slightly more sophisticated

transmission system to prevent random noise from interfering too much. There are

65

Page 66: Pc Remote nil

several systems in use, the most popular being those created by the EIA (Electrical

Industries Association). As with most transmission media, there is a trade off between

the speed and the maximum distance the system can be used for. If you intend pushing

the transmission distance to its maximum value, you will have to accept a reduced

speed. As a rule of thumb, halve the speed if you double the distance.

Appendix B. MAX232

Since the RS232 is not compatible with

microcontrollers, we need a line driver (voltage converter) to convert the RS232’s

signals to TTL voltage levels that will be acceptable to the microcontroller’s RxD pin.

Here we use the converter MAX232 from Maxim Corp. The MAX232 converts from

RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of the

MAX232 chip is that it uses a +5V power source which is the same as the source

voltage for the microcontroller. In other words, with a single +5 V power supply we

can power both the microcontroller and MAX232, with no need for the dual power

supplies.

66

Page 67: Pc Remote nil

67