152
BHOPAL (M.P) Session-2011 -2012 A “MAJOR PROJECT REPORT” ON “INTELLIGENT SPEED ADAPTATION” Submitted in fulfillment for requirement of B.E. in Electronics & communication engg.

Intelligent Speed Adaptation

Embed Size (px)

Citation preview

Page 1: Intelligent Speed Adaptation

BHOPAL (M.P)

Session-2011 -2012

A

“MAJOR PROJECT REPORT”

ON

“INTELLIGENT SPEED ADAPTATION”

Submitted in fulfillment for requirement of

B.E. in Electronics & communication engg.

GUIDED BY SUBMITTED BY

Page 2: Intelligent Speed Adaptation

Mr. VISHAL THAKUR ALOK KUMAR SINGH

(0126EC083D03)

AMIT SINGH CHAUHAN

(0126EC083D04)

JITENDRA S.

SISODIA (0126EC083D06)

ROUNAK DIWAKAR

(0126EC083D07)

RUCHI MAHOR

(0126EC083D09)

BHOPAL (M.P.)

CERTIFICATESESSION 2010

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

“INTELLIGENT SPEED ADAPTATION” being submitted by Jitendra

Singh Sisodia (0126EC083D06) in partial fulfillment of the requirement

for the award of “BACHELOR OF ENGINEERING (Electronics

Communication & Engineering)” to Rajiv Gandhi Proudyogiki

Vishwavidyalaya, Bhopal( M.P) during the academic year 2011 is a record

Page 3: Intelligent Speed Adaptation

of bonafide piece of work, carried out by him under our/my supervision and

guidance in the “Department of Electronics Communication &

Engineering”, Thakral Collage Of Technology, Bhopal(M.P.).

Guided & Approved by:

Mr. VISHAL THAKURHOD, Department of

Electronics Communications and Engineering

Forwarded by:

HOD DirectorDEPTT OF ECE TCT, Bhopal TCT, Bhopal

ACKNOWLEDGMENT

It is our profound privilege and pleasure to express overwhelming

sense of gratitude devotion and regard to out esteemed and learned teacher

Mr. VISHAL THAKUR. Whose initiation and timely guidance and

valuable suggestions helped us to carry out this project.

We do not have words to express our heartily gratitude to

Mr. VISHAL THAKUR HOD of electronics & communication for

unhearing continuous and expert guidance and valuable work which has to

be undertaken during the forth year of bachelor of engineering in Electronics

and communication Engineering as required by the academic curriculum.

Page 4: Intelligent Speed Adaptation

This project INTELLIGENT SPEED ADAPTATION has bee submitted as report work which has to be undertaken during the forth year of bachelor of engineering in Electronics and communication Engineering as required by the academic curriculum.

Table of contents

1. INTRODUCTION 01

2. BLOCK DAIGRAM

2.1 Block diagram of working model transmitter

2.2 Block diagram of working model reiever

2.3 Block diagram of practical system implementation

02

03

04

3. CIRCUIT DIAGRAM

3.1 Circuit diagram of transmitter card

3.2 Circuit diagram of receiver card

05

06

4. CONSTRUCTION AND WORKING

4.1 Description of working model 07

4.2 Construction of working model 10

4.3 Operating principle and working of model transmiter 10

4.4 Parameters of transmission 11

4.5 Frame format of transmitting frame 12

4.6 Construction of working model receiver 13

4.7 Operating principle and working of working model

receiver

14

4.8 Present design of practical vehicle system 15

4.9 Required design of practical vehicle system 17

Page 5: Intelligent Speed Adaptation

4.10 Overall design of Practical system 18

5. FLOW CHART

5.1 Flow Chart of transmitter 20

5.2 Flow chart of receiver 21

6. PCB LAYOUT

6.1 PCB Layout of transmitter

6.2 PCB Layout of receiver

22

23

7. LIST OF COMPONENTS 24

8. SPECIFICATIONS OF COMPONENTS 27

8.1 Specification of resistor

8.2 Specification of switch

8.3 Specification of rectifiers

8.4 Specification of didoe

31

32

34

35

9. PCB MANUFACTURING PROCESS 38

10. ADVANTAGES 42

11. FUTURE ENHANCEMENT 45

12. SOFTWARE CODING OF MICROCONTROLLER 46

13. PRECAUTIONS 130

14. BIBLIOGRAPHY 131

15. DATA SHEET

15.1 Data sheet of Microcontroller

15.2 Data sheet of LCD

15.3 Data sheet of RF module

15.4 Data Sheet of DC Motor

15.5 Data sheet of optocoupler

15.6 Data sheet of uln 2003

Page 6: Intelligent Speed Adaptation

1. INTRODUCTION-

Excessive or inappropriate speed is a significant factor in serious road accidents.

Road safety authorities around the world devote considerable resources to

addressing the speeding problem particularly compliance with speed limits. One

countermeasure that is gaining increasing attention is the use in vehicle technology

to assist drivers keep to speed limits or even prevent the vehicle from exceeding

speed limits on all roads at all times. This is known as Intelligent speed

Adaptation.

Intelligent speed Adaptation (ISA) is the generic name for advanced system in

which the vehicle knows the speed limit for the road currently being travelled on.

Page 7: Intelligent Speed Adaptation

That Information can be used to display the current speed limit inside the vehicle

and warn the driver when he or she is speeding. The technology is of interest

because of the known relationship between speed and risk of an accident and also

because of the relationship between speed and injury severity in an accident.

Page 8: Intelligent Speed Adaptation

2. Block Diagram

2.1 Block Diagram of Working model transmitter

Page 9: Intelligent Speed Adaptation

2.2 Block Diagram of Working model Receiver

Page 10: Intelligent Speed Adaptation

2.2 Block Diagram of overall system design of practical system

Page 11: Intelligent Speed Adaptation

3.1 Circuit Diagram3.1 Circuit Diagram of Transmitter Card

Page 12: Intelligent Speed Adaptation

3.2 Circuit Diagram of Receiver Card

Page 13: Intelligent Speed Adaptation

4. CONSTRUCTION AND WORKING 4.1 Description of Working ModelFor showing the implementation of our concept of project, we construct of working

model in which we use one transmitter card, a receiver card and a toy car. The transmitter

and receiver card is same as for practical system implementation. The only difference lies

between the practical vehicle system and our used toy car the toy car we use here is a

gear car which uses dc motor for its movement. For transferring of signals of information

between transmitter and receiver, we use RF communication through RF module. So the

whole system is designed around two parts –

1. Transmitter.

2. Receiver

4.2 Construction of working model Transmitter

Major Component of the Transmitter is 1. LCD display 2. 4 x 4 keyboards3. RF Module 4. Microcontroller 5. Power Supply Section

1. Lcd. Display: - It has 16x2 LCD display to see the status of the transmitter.

2. 4x4 keyboard: - it has 16 switch key board to set the varios parameter. Such as:-

Switch1:- To set the speed limit of speed zone. When this switch is press

Speed setting screen is shown. As follows Speed=10%.

Switch2:- To increase the speed limit, for e.g. If this press Speed=12%.

Switch3:- To decrease the speed limit, for e.g. If this press Speed=10%.

Switch4:- To save the speed limit and exit the screen, for e.g. If this press.

Return to home screen. RKDFCE BHOPAL

Switch5:- When this switch is press system then you set the sending

message. Shows you a previous message. Message=Rtn(Right

Page 14: Intelligent Speed Adaptation

turn)

Switch6 and 7:- by using this u can change the message.

Message=Rtn(Right turn)

Message=Ltn(left turn)

Message=Brd(Bridge)

Message=nhn(no horn)

Message=wip (work in progress)

Switch8 :- by using this u can save the message for transmission and exit

you home screen.

Switch9:- by using this u can select the mode of system.By default it will

shows the previous save mode. And remain in this.

Switch10:- by using this U are in transmiiter mode.

Switch11:- by using this U are in Remote mode.

Switch12:- by using this U are in save the state if power is off.

Switch13:- Only work in remote mode By using this increase the speed of car

remotely.

Switch14:- Only work in remote mode By using this decrease the speed of car

remotely.

Switch15:- Only work in remote mode By using stop the car.

Switch16:- Exit without saving in any mode.

3).Rf module:- This module is used to transfer data in rf. Form.

This module is working on a 433 mhz. and Ask modulation is

used. And support the data below the 1200 bps.

Page 15: Intelligent Speed Adaptation

4. Microcontroler. :- In this system we are using mc of microchip company which is

PIC16f877a. which is RISC based controller. Only has 35 set of

commands set. Has various paripherel inbuilt such as

USART,TIMER,ADC,SPI,I2C,EEPROM and has 8k of program

memory and also has various features.

5). Power Supply: - In the whole system we are using +5v regulated power supply. It is

obtained by the 230v ac.

This section is covered by these parts:-

12 v step down transformer (500m amp)

Full wave rectifier.

Filter.

linear regulator.

a. 12 v step down transformer(500m amp):- Step down transformer is used to

convert 230v ac to 12v ac. With current rating of 500 mump.

b. Full wave rectifier: - The full wave Bridge rectifier is used to convert 12 ac to the

pulsating dc which is equal to average value.

c. Filter: - Filter is a used to convert pulsating dc to constant dc. It may me

capacitor, RC network, inductance. depends upon the current following in the

circuit or impedance of circuit. But in this system we use capacitor.

d. Linear regulator:- regulator are used the system is used to convert high

voltage to +5v constant dc.

4.3 Operating Principle and working of working model transmitter

Basic function of a transmitter is to control the speed of the moving vehicle also send a

message to the drive if any for road. For e.g. on a road there is left turn, right turn, work

in progressed. When the system is in the transmitter mode it controls the speed of car. It

Page 16: Intelligent Speed Adaptation

continuously transmit the Transmitting frame and the contains following informations's

Message.

Format.

{ ?} First byte is opening bracket and last is closing is used to synchronies the reciver

and this 3 also check for errors .If message is in not this format then reciver

discard it.

T second byte is use to tell the receiver come in Transmiter is in control mode.

-- Third byte is use to tell the reciver for speed if speed is greater than permited then

decrease speed to the set value which has been recived

-- fourth byte is to give the message.

When the system is in Remote mode it controls the speed of car. Its sends first and last

byte as usual. Second byte is R which tells the reciver it also contol by remote Third forth

and fifth are if its

UP. then receiver increase the speed

DW. then receiver decrease the speed

St. Then receiver decrease to zero the speed.

4.4 Parameters of transmission:-

Transmission is done on 1200 baud rate , 8 data bits ,no parity.

Page 17: Intelligent Speed Adaptation

4.5 Frame Format of Transmitting Frame

Page 18: Intelligent Speed Adaptation

4.5 CONSTRUCTION OF WORKING MODEL RECEIVER

1. Lcd. Display: - It has 16x2 LCD display to see the status of the speed and

message send by the transmitter.

2. Swithes:- first switch is use to increase the speed of car Second switch is use to

decrease the speed of car.

3. Microcontroler. :- In this system we are using mc of microchip company

which is PIC16f877a. which is RISC based controller. Only has 35 set of

commands set. Has various paripherel inbuilt such as USART, TIMER, ADC,

SPI, I2C, EEPROM and has 8k of program memory and also has various

features.

4. RF Module :- This module is used to receive the data in RF form. This module is

working on a 433 MHz frequency. ASK demodulation is used in this module. it

support the data below the 1200 bps.

5. Power Supply :- The receiver section has a two power supplies. One for

microcontroller and other for motor driving section. Micro-controller power

supply section is same as in transmitter. For dc motor supply we use a 12v

regulator which is used to give 12v power supply to the motor.

6. DC Motor :- For the movement of toy car in our working model and also fopr

movement of carburetor plate in practical system, we use a DC motor. Motor

driving section has following more circuitry as –

1. Leds :- change the bridge ness as the duty cycle change.

2. Optocoupler: - isolate the high voltage to the micocontroler. Has four

optocupler used to increase the current for motor

3. ULN2003:- It has seven transistor which are in parallel. Also for increasing

the current.

Page 19: Intelligent Speed Adaptation

4.6 OPERATING PRINCIPLE AND WORKING OF WORKING

MODEL RECEIVER

The receiver program works in two section. The motor driving section.

The control section driving section.

1. The motor driving section:-Speed of the motor of the car is increase and decrease by

the pulse width modulation whose frequency is 1khz.when we want to increase the

speed of car we increase the duty cycle and it is shown on screen in a form of

percentage. When we decrease the speed of the car we decrease the duty cycle.

2. The control section driving section.:-This system is active any valid frame is

received. For eg Its receive a transmitting frame it extract speed and message and first

shows the message check the current speed with received speed. If it is greater the it

decrease the amout of duty cycle. If it is lesser or equal it takes no decision.

Page 20: Intelligent Speed Adaptation

4.7 DESCRIPTION OF PRACTICAL SYSTEM IMPLIMENTATION

In our system our carburetor is designed in such a way that a new slide is introduced

below the older slide of the carburetor which was fully controlled by the driver section

and ECU. Our new slide is now controlled by the receiver circuitry of the receiver of

speed adaptation system. The movement of this new slide is done by the high resolution

DC or stepper motor whose speed is controlled according to the received signal, which is

transmitted by transmitter section.

A digital Speedometer is also used in this system. This digital speedometer measures the

running speed of the vehicle for PID LOOP. At first receiver section takes the transmitted

data and check the running speed of the vehicle through PID LOOP. if the running speed

is greater then received speed limit then an optimal target opening degree of the throttle

valve is calculated by the ECU and PID LOOP of the driving section of vehicle and

hence calculated opening degree of the throttle valve is done by the new introduced

slide below the older slide by the dc motor. As the speed of the vehicle increases beyond

the speed limit then our receiver system decreases the opening of the new slide and adjust

the amount of intake air fuel supplied to the engine and hence the speed is maintained at

safe optimal speed level.

If driver want to move above the speed limit of a particular zone then he/she can not

increases the speed above the safe limit .the reason is that when he/she want to increases

the speed of the vehicle system then he/she increases the opening of slide of throttle

through accelerator .now even he/she fully open the throttle slide to increases the speed,

our new introduced slide which is located below the older slide maintained the safe speed

of the vehicle according to the received signal. Hence our vehicle is within the safe limit.

4.8 TRANSMISSION LINK OF THE PRACTICAL SYSTEM

In our practical system implementation, remote mode of working is excluded from the

transmitter card. Error detection system is also excluded. The transmission link in the

practical implementation will be GSM or satellite link.

Page 21: Intelligent Speed Adaptation
Page 22: Intelligent Speed Adaptation

4.9 Present Designing of Practical Vehicle Systems

Page 23: Intelligent Speed Adaptation

4.10 Required Design of Practical Vehicle System

Page 24: Intelligent Speed Adaptation

4.11 Overall Design of practical system

Page 25: Intelligent Speed Adaptation

5. FLOW CHART

5.1 Flow Chart of Transmitter

Page 26: Intelligent Speed Adaptation

6. PCB LAYOUT

6.1 PCB Layout of Transmitter Receiver

Page 27: Intelligent Speed Adaptation
Page 28: Intelligent Speed Adaptation
Page 29: Intelligent Speed Adaptation

7. LIST OF COMPONENTSSemiconductors :

IC (7805 5V regulator) =1

IC (PIC16f876amicrocontroller) =1

D ( 1N4148 ) =4

D (4007 rectifier diode) =4

LED1 (3mm LED) =2

IC Base (14 pin ) =2

Resistors (all ¼ watt +% carbon):

R (1-kilo-ohm) = 1

R (10-kilo-ohm) =5

R (4.7- kilo-ohm) =1

R (50 E ohm) =1

Capacitor :

C (1000uf ,25V electrolytic) =1

C2,C3,(100/25) =2

Miscellaneous :

X( 230VAC primary to 12V/500mA ) =1

S (Puch-to on switch) =17

XTal (16 MHZ ) =1

16*2LCD =1

Mains Cable =1

Barg strip (16 pin ) =1

Ferric Cloride -100gms.

Soldering Wire - 20gms.

Connecting wires - 2mtrs.

Soldering Paste -10gms.

PCB 4”x6” =1

RF module (433 MHz)Tx =1

Page 30: Intelligent Speed Adaptation

RECEIVER COMPONENTS

Semiconductors :IC (7805 5V regulator) =1IC (78012 12V regulator) =1IC (PIC16f876amicrocontroller) =1D (4007 rectifier diode) =8LED1 (3mm LED ) =7Optocupler (pc817) =4IC Base (14 pin ) 3IC Base (16 pin ) 1

Resistors (all ¼ watt +% carbon):

R (1-kilo-ohm) = 7R (10-kilo-ohm) =5R (50 E ohm) =1R (4.7-kilo-ohm) =4

Capacitor :C (1000uf ,25V electrolytic) =1C2,C3,(100/25) =2C3 104 Ceramic =2

Miscellaneous :

X( 230VAC primary to 12V/1A ) =1S (Push-to on switch) =5XTal (16 MHZ ) =116*2LCD =1Mains Cable =1Barg strip (16 pin ) =1DC motor = 2Wire (5 m ) =1Connector ( 2pin ) =4Ferric Cloride -100gms. Soldering Wire - 20gms.Connecting wires - 2mtrs. Soldering Paste -10gms.

PCB 4”x6” =1RF module (433 MHz)reciver =1

Page 31: Intelligent Speed Adaptation

8. SPECIFICATION OF COMPONENTS Resistors

A resistor is an electrical component, which has been manufacture with a

specified amount of resistance. The resistors can conduct current in both the directions.

The resistors may be connected in an electric circuit without concern for lead

polarization. The resistors are used mainly for two purposes, namely controlling the flow

of electric current and providing desired amounts of voltage in electric in electric or

electronic circuits.

Resistor specifications

The resistors are specified in terms of their resistance values, tolerance power rating and

thermal stability. By tolerance, we mean the allowed variation permitted in the normal or

marred value or the resistor. It means that the actual value of the resistor may be either

greater or smaller than that of the indicated value, by a factor given by the specified

tolerance. Thus resistors are manufactured with a specified tolerance. For example, a

5000 resistor with a tolerance of + 10% will have an actual resistance value anywhere

between 4500 and 5500 or in other words 500 greater or smaller them the rated

value.

The power rating of a resistor is given by the maximum wattage it can dissipate, without

excessive heating. Since the power rating is proportional to the square of a current, there

fore current must not be higher than its safe value. If the current exceeds the safe value,

the resistance will burn out. Usually, carbon composition resistors will fail, if operated at

near the rated power values. In this case, the resistor will not burn out. But the failure is

gradual, which takes many months. It changes gradually to a much lower amount of

resistance. This causes an improper operation of an electronic of an electronic circuit

particularly in amplifier. Thus in order to increase the life of use a power dissipation of

about half of the rating of the resistor.

Page 32: Intelligent Speed Adaptation

The thermal stability of a resistor is indicated by the temperature coefficient

specification, which is usually expressed in parts per million per degree centigrade (+

ppm/C). The smaller value of temperature coefficient will have less variation in the

resistance value. Therefore, smaller value of temperature coefficient means a higher

thermal stability of a resistor.

CLASSIFICATION OF RESISTORS

Shows the classification of resistors in the from of a family tree. The resistors are

basically of two types, namely linear resistors and non- linear resistors. Each type is

further subdivided into many types as shown in the figure.

Linear resistors. The resistors through which the current is directly proportional to the

applied voltage, are called linear resistors. Such resistors have a property that their

resistance value do not change with the variation in applied voltage, temperature or light

intensity. The linear resistors are of two types namely fixed resistors and variable

resistors. Non-linear. The resistors through which the current is not directly proportional

to the applied voltage, are called non-linear resistors. Such resistors have a property that

their resistance values change with variation in applied voltage, temperature of light

intensity. The non-linear resistors are of three namely thermostat, photo resistor and

varistor.

Fixed Resistors

The fixed resistors are those whose do not change with the variation in applied voltage,

temperature and light intensity. Such resistors are available in various shapes and sizes,

with both axial and radial leads as shown in Fig.7.2. In addition to this, the fixed resistors

are available with sugs for installation by soldering or mounting with screws and rivets.

Page 33: Intelligent Speed Adaptation

8.1 RESISTOR COLOUR CODE CALCULATOR

The Resistor Colour Code Calculator can be used to identify resistors. It consists of three card discs showing the colours and values, these are fastened together so you can simply turn the discs to select the value or colour code required. Simple but effective!

There are two versions to download and print on A4 white card (two per sheet):

Coloured (for a colour printer) B/Wfor a black only printer)

This version must be coloured manually, it is easiest to do this before cutting out.

To make the calculator, carefully cut out the three discs and fasten them together with a small brass paper fastener.

The calculator design is copyright but it may be freely copied for educational purposes.

The Resistor Colour Code Calculator is supplied as a PDF file. To view and print PDF files you need an Acrobat Reader which may be downloaded free for Windows Mac,RISE OS, or Unix Linex computers. If you are not sure which type of computer you have it is probably Windows.

The ResistorColour Code

Colour Number

Black 0

Brown 1

Red 2

Orange 3

Yellow 4

Green 5

Blue 6

Violet 7

Grey 8

White 9

Page 34: Intelligent Speed Adaptation

8.2 SPECIFICATION OF SWITCHES

An electrical switch is a device usually used to open or close an electrical circuit. Mostly

switches are manually operated devices. Switches play important role in electronics, to

stop the flow of current or send the current.

TYPES OF SWITCHES

Push Button Switches :

Both locking a latching (contacts remaining operated after the button is pressed) and non

locking (contacts release after removal of the finger) designs are available. Other design

variations have multiple contacts, snap action and wiper action. In most design, state of

the switch (operated or not) is determined by visual observation only. Some designs have

an indication light either self-contained or separate.

Keyboards :

A wide variety of keyboards or key pads are used for providing manual input to

electronic instrument such as telephone sets and adding machines. The most commonly

available keyboard has a 12 button (4 rows and 3 columns) arrangement identical to the

telephone instruments although keyboards with 16 and 20 button arrangement are also

available.

Page 35: Intelligent Speed Adaptation

8.3 SPECIFICATIONS OF RECTIFIER

A rectifier is a circuit that converts the ac supply voltage to the pulsating dc voltage,

There are mainly 3 types of rectifier circuits

1. Half wave rectifier

2. Full wave rectifier

3. Full wave bridge rectifier

Half-wave rectifier circuit.

For most power applications, half-wave rectification is insufficient for the task. The

harmonic content of the rectifier's output waveform is very large and consequently

difficult to filter. Furthermore, the AC power source only supplies power to the load once

every half-cycle, meaning that much of its capacity is unused. Half-wave rectification is,

however, a very simple way to reduce power to a resistive load. Some two-position lamp

dimmer switches apply full AC power to the lamp filament for “full” brightness and then

half-wave rectify it for a lesser light output.

Full-wave rectifier, center-tapped design.

Page 36: Intelligent Speed Adaptation

This circuit's operation is easily understood one half-cycle at a time. Consider the first

half-cycle, when the source voltage polarity is positive (+) on top and negative (-) on

bottom. At this time, only the top diode is conducting; the bottom diode is blocking

current, and the load “sees” the first half of the sine wave, positive on top and negative on

bottom. Only the top half of the transformer's secondary winding carries current during

this half-cycle as in Figure below.

Full-wave center-tap rectifier: Top half of secondary winding conducts during positive

half-cycle of input, delivering positive half-cycle to load..

During the next half-cycle, the AC polarity reverses. Now, the other diode and the other

half of the transformer's secondary winding carry current while the portions of the circuit

formerly carrying current during the last half-cycle sit idle. The load still “sees” half of a

Page 37: Intelligent Speed Adaptation

sine wave, of the same polarity as before: positive on top and negative on bottom.

Full-wave center-tap rectifier: During negative input half-cycle, bottom half of secondary

winding conducts, delivering a positive half-cycle to the load.

Page 38: Intelligent Speed Adaptation

8.4 SPECIFICATION OF DIODES

It is s two terminal device consisting of a P-N junction formed either in GE or SI crystal. The P and N type regions are referred to as anode and cathode respectively. Commercially available diodes usually have some means to indicate which lead is P and which lead is N. Standard notations consists the number proceeded by IN such as In 240 & 250. Here 240 and 250 correspond to color band. Diodes are polarized, which means that they must be inserted into the PCB the correct way round. This is because an electric current will only flow through them in one direction (like air will only flow one way through a tyre valve).Diodes have two connections, an anode and a cathode. The cathode is always identified by a dot, ring or some other mark.

The pcb is often marked with a + sign for the cathode end. Diodes come in all shapes and sizes. They are often marked with a type number. Detailed characteristics of a diode can be found by looking up the type number in a data book. If you know how to measure resistance with a meter then test some diodes. A good one has low resistance in one direction and high in the other. There are specialized types of diode available such as the zener and light emitting diode (LED).

Page 39: Intelligent Speed Adaptation

9. PCB MANUFACTURING PROCESS :

9.1 PCB LAYOUTLay out of the desired circuit is the most important in any circuit board manufacturing process. The following points are to be observed while performing the layout of the PCBSufficient space should be maintained between two components. High heat dissipation components like high voltage resistors should be mounted at a sufficient distance from the semiconductors and electrolytic capacitors. Components layout should make proper combination with copper side circuit layout. Circuit copper line thickness should be decided taking into account the current drain in the circuit.

9.2 PREPARATION OF SCREEN:Nylon bolting cloth (Silk screen cloth) is stretched and attached to a wooden frame. Photosensitive chemical (silcot-6) and ammonium bicarbonate is spread on cloth and dried in total darkness. The screen is exposed to UV light and is developed in water.

9.3 PRINTING:The screen is placed on suitable copper laminated sheet on copper side and circuit black printing ink (acid resistant paint) is spread on it. After printing the PCB should be allowed to dry for at least 10 hrs. in a dust proof chamber.

9.4 ETCHING:The removal of excess copper on the copper laminated PCB apart from the printed circuit is known as etching. Generally PCB is placed in F3C13 solution and kept for one hour.

9.5 DRILLING:Under this operation drilling should be done as per circuit lay with the suitable drill and high speed machine. Drilling should always be done from copper side to avoid possibility of coming out of copper circuit and chipping out of Bakelite.

9.6 THINNING:It is an electroplating process (tin plating) done to increases the conductivity of the conducting medium and to avoid oxidizing effect.

9.7 COMPONENT MOUNTING:All components are mounted at their respective position as per the components layout. Proper precautions should be taken during mounting process.

ETCHING PROCESS : Etching process requires the use of chemicals acid resistant dishes and running water supply Ferric chloride is maximum used solution but other enchants such as ammonium per sulfate can be used. Nitric acid can be used but in general it is not used due to poisonous fumes. The pattern prepared is glued to the copper surface of the board using a latex type of adhesive that can be cubed after use. The pattern is laid firmly on the copper use a very sharp knife to cut round the pattern carefully a remove the paper

Page 40: Intelligent Speed Adaptation

corresponding to the required copper pattern areas. Then apply the resist solutions, which can be kind of ink proportion fort the purpose maintaining smoothing clean outlines as far as possible. While the board is drying test all the components.Before going to next stage, check the whole gotten and cross cheek against the circuit diagram check for any freeing matte on the copper. The etching bath should be in a galls or enamels disc. If using crystal of ferric-chloride these should be thoroughly dissolved in water to the proportional suggested. There should be 0.5 Lt. Of water for 125 Gm. of crystal.Water liquid should be thoroughly deflated and druid in water land; never pour down the drain. To prevent particles of copper hindering further etching, agitate the solutions carefully be gently twisting or rocking the tray.The board should not be left in the bath a moment longer than is needed to remove just the right amount of copper. In spite of there being a resist coating there is no protection against etching away through exposed copper edges; this leads to over etching. Have running water ready so that etched board can be removed properly and rinsed; this will hall etching immediately.Drilling is one of those operations that call for great care because most of the holes will be made a very small drill. For most purposes a 1 mm drill is used Drill all holes with this size first those that need to be larger can be easily drilled again with the appropriate lager size.

COMPONENT ASSEMBLES:From the greatest variety of electronic components available today, which runs into tent of thousands of different types it is often a perplexing task to know which the right task for a given job is. There should be damage such as hair line crack intuit opera on PCB that could age a seriousfiec on the operational ability to the completed assemble. If there are than they can and should be repaired fiesta bye soldering a short link of bare copper wire over the affected part. The most popular method of holding all the items is to been the wires future apart after they even been indebted in the appropriate holes. This will hold the component in position ready for soldering.Some components will be considerably larger than other occupying and possible partially obscuring neighboring components. Because of this best to start by mounting the smallest first and progressing through to the largest. Before starting make certain that no further drilling I likely to be necessary because access may be impossible later.Next will probably be the resistor small signal diodes of other similar size components some capacitor are very small but it would be best to fit these after words when fitting each group of components marks of each one on the components its as it is fitted and if we have to leave the job we know where to recommence. Although transistor & integrated circuit are small items there are good reasons for leaving the soldering of these until the last step the main pint is that these components are sensitive to heart and is subjected to prolonged application to the soldering iron they could be internally damaged.All the components before mounting are rubbed with sandpaper so that oxide layer is removed from their tips. Now they are mounted according to the components layout.SOLDERING TECHNIQUES:

Page 41: Intelligent Speed Adaptation

A soldered connection ensures metal continuity. The soldering process involves: Melting of the flux which in turn removes the oxide films on the metal to be soldered. Melting the solder which removes the impurities. The solder partially dissolve of the metal in the connection. The solder cools and fuses wit the metal.The soldering techniques involves knowledge of :

Soldering iron

Soldering wire

Soldering procedure

Replacing components

10. ADVANTAGES

Road Accident Savings – with the help of ISA, there is a decrement in

road accidents due to unlimited and uncontrolled speed of the vehicles. By

using ISA, all the vehicles will be run in the maximum speed limit of

respective areas.

Environmental benefits – As it is clear from the description of ISA, it

reduces the consumption of fuels. This ultimately results in reduced

harmful emission. There are also noise and amenity benefits with the

implementation of ISA.

Displaying traffic related information inside the Vehicle – in the ISA

implemented vehicles, we can display any useful information inside the

vehicle which will helpful to the driver during the travelling periods. as an

example if there is any blind curve ahead the traveling path or there is any

construction is going on in a highway then these useful information's can be

displayed in the display section inside the vehicle before reaching to that

particular zone.

Increment or decrement in the speed limit according to the traffic

requirement – with the implementation of ISA, we can change in the

Page 42: Intelligent Speed Adaptation

speed limit of a particular are by changing the speed limit at the

transmitting section. So according to traffic conditions we can increase or

decrease the speed limit of vehicles.

Simpler and reliable technology – ISA technology do work, are robust

and reliable. This is technically simple, much simpler than other automatic

devices such as collision avoidance system.

11 DISADVANTAGES

There are following disadvantages of the ISA system.

Increases the traveling time – the implementation of the ISA system

directly and indirect increase the traveling time of the person, because due

to restriction in the speed, one can not drive its vehicle above a safe speed

as can drive in the absence of the ISA.

Causing problem of overtaking – ISA system could potentially cause a

problem if speed will limited in mid-overtaking. There will be overtaking

problem between the ISA – ISA and ISA – NONISA systems.

Risky for high speed moving light vehicles – ISA system is risky for

those light vehicles which are move at a very high speed the reason is that

when ISA implemented vehicle which are moving at a very high speed in

non ISA implemented zone, entering in a new zone where the required

speed is very low compared to speed of moving vehicle then ISA system of

the vehicle tries to reduce the speed of the vehicle immediately which will

causing an unbalancing problem to drivers.

Page 43: Intelligent Speed Adaptation

12 LIMITATIONS

There are some limitations of the ISA system such as

Not working when more number of vehicles are passing from a

particular zone – ISA system will not work in such type of zones from

where more number of vehicles are passing every time or at any particular

instant such as after any gathering etc. this is because of jamming of GSM

network. The jamming condition will occurred because there will be only

one tramsitter for controlling of all the vehicles i.e. for transmitting the

signals and receiver i.e. vehicles are more in numbers and hence will

causing jamming of network.

Page 44: Intelligent Speed Adaptation

13. FUTURE ENHANCEMENTS

There are following future Enhancement of the ISA System.

Find the route of a particular vehicle – in the future if we will transfer

the data bidirectionally i.e. from transmitter to vehicle and also from

vehicle to transmitter then we can find the route of a particular vehicle

which will very helpful in some special cases such as in case of stolling of

a vehicle.

Predict the speed limit through digital map – if we will uses the GPS

system in the vehicle then we can predict the upcoming speed ahead the

way as well as of the any other path / zone through a digital map.

Displaying other traffic and whether related information's – we will

also display some traffic condition related information's as well as some

whether related information's to the driver through the GPS System

implementation which will helpful to driver during traveling.

Page 45: Intelligent Speed Adaptation

;*******************************************LCD ********************************************************************************; IST LINE HOME ADDRESS ;80H 81H _ _ 8F; 2ND LINE HOME ADDRESS ;C0H C1H _ _ CF; 00- SAVING SPEED; 01- SAVING MESSAGE; 02- CONTROLER AND REMOTE SELECTION

cblock 0x20READBACKCOUNTERLCD_CMDLCD_DATALCD_READBACKPRCOUNTERREVDATACOUNTTEMPH_BYTEM_BYTEL_BYTER0 R1 R2 FLAG0FLAG1FLAG2FLAG3SWT1SWT2SPEEDTIME1FIRST_WORDSECOND_WORDTHIRD_WORDMESS_COUNTTX_COUNTERCONT_REMOTEendc

BAUD_CONSTANT EQU D'207'; BAUDRATE= 1200EE_ADD EQU H'120';****************************************************PINS DECLARATION****************************************************************

Page 46: Intelligent Speed Adaptation

#DEFINE EN PORTA,0 ; FOR LCD#DEFINE RW PORTA,1 ; FOR LCD#DEFINE RS PORTA,2 ; FOR LCD#DEFINE CL1 PORTA,3 ; INPUT#DEFINE CL2 PORTA,4 ; INPUT#DEFINE CL3 PORTA,5 ; INPUT#DEFINE CL4 PORTC,0 ; INPUT#DEFINE RL1 PORTC,1 ; OUTPUT#DEFINE RL2 PORTC,2 ; OUTPUT#DEFINE RL3 PORTC,3 ; OUTPUT#DEFINE RL4 PORTC,4 ; OUTPUT#DEFINE LED PORTC,5 ; OUTPUT#DEFINE FSW1 FLAG0,0#DEFINE FSW2 FLAG0,1#DEFINE FSW3 FLAG0,2#DEFINE FSW4 FLAG0,3#DEFINE FSW5 FLAG0,4#DEFINE FSW6 FLAG0,5#DEFINE FSW7 FLAG0,6#DEFINE FSW8 FLAG0,7#DEFINE FSW9 FLAG1,0#DEFINE FSW10 FLAG1,1#DEFINE FSW11 FLAG1,2#DEFINE FSW12 FLAG1,3#DEFINE FSW13 FLAG1,4#DEFINE FSW14 FLAG1,5#DEFINE FSW15 FLAG1,6#DEFINE FSW16 FLAG1,7#DEFINE PR_SPEED FLAG2,0#DEFINE TIME_ER FLAG2,1#DEFINE TIME_ON FLAG2,2#DEFINE PR_MESSAGE FLAG2,3#DEFINE SCR FLAG2,4#DEFINE UP FLAG2,5#DEFINE DWN FLAG2,6#DEFINE PR_TRANS_REMO FLAG2,7#DEFINE STOP FLAG3,0#DEFINE REMOTE CONT_REMOTE,0 ; NOT USE THIS CONT_REMOTE ANY WHERE ELSE BECAUSE SAVE IN EEPROM#DEFINE TRANS CONT_REMOTE,1 ; NOT USE THIS CONT_REMOTE ANY WHERE ELSE BECAUSE SAVE IN EEPROM

;****************************************INTRUPT ROUTINE REGISTERS**************************************************************

Page 47: Intelligent Speed Adaptation

TEMPW EQU H'7B'TEMPSTATUS EQU H'7C'TEMPPCLATH EQU H'7D';****************************************RAM CLEANING ROUTINE REGISTERS*******************************************************************COUNT_REG1 EQU H'7E'TMP_COUNT EQU H'7F';************************************************************************************************************************************

ERRORLEVEL-302BANK0 MACRO

BCF STATUS,RP0BCF STATUS,RP1ENDM

BANK1 MACROBSF STATUS,RP0BCF STATUS,RP1ENDM

BANK2 MACROBCF STATUS,RP0BSF STATUS,RP1ENDM

BANK3 MACROBSF STATUS,RP0BSF STATUS,RP1ENDM

include "P16F877.inc" org 0

GOTO INITIALIZE org 4 GOTO INTERRUPT

ASCII ANDLW B'00001111' ADDWF PCL,F RETLW H'30';0 RETLW H'31';1 RETLW H'32';2

Page 48: Intelligent Speed Adaptation

RETLW H'33';3 RETLW H'34';4 RETLW H'35';5 RETLW H'36';6 RETLW H'37';7 RETLW H'38';8 RETLW H'39';9 RETLW H'41';A RETLW H'42';B RETLW H'43';C RETLW H'44';D RETLW H'45';E RETLW H'46';F

;***********************************************I S

R****************************************************************************INTERRUPT

MOVWF TEMPWSWAPF STATUS, WCLRF STATUSMOVWF TEMPSTATUSMOVF PCLATH, WMOVWF TEMPPCLATHCLRF PCLATHCLRWDTBTFSC PIR1,CCP1IF GOTO TIMER_1BTFSC PIR1,RCIFGOTO RX_INTERRUPT BTFSC PIR1,CCP1IFGOTO TIMER_1

DATA_RETURNMOVF TEMPPCLATH, WMOVWF PCLATHSWAPF TEMPSTATUS, WMOVWF STATUSMOVF TEMPW, WRETFIE

RX_INTERRUPTBCF PIR1,RCIFMOVFW RCREGGOTO DATA_RETURN

Page 49: Intelligent Speed Adaptation

TIMER_1BCF T1CON,TMR1ONBCF PIR1,CCP1IFBTFSC TIME_ERCALL TIMER1_INITIALIZATIONINCF TIME1,FXORLW H'05'BTFSC STATUS,ZGOTO CLEAR_FLAGBCF TIME_ONCALL TIMER1_INITIALIZATIONGOTO DATA_RETURN

CLEAR_FLAGCLRF TIME1BCF TIME_ONCALL TIMER1_INITIALIZATIONCLRF FLAG0CLRF FLAG1GOTO DATA_RETURN

;*********************************************************PROGRAM STARTS*************************************************************INITIALIZE

CALL CHECK_RAM1 CALL PORT_INTITIALIZE

CALL LCD_INITIALIZATION

CLRWCALL EEPROM_READMOVFW READBACKMOVWF SPEED

MOVLW H'01'CALL EEPROM_READMOVFW READBACKMOVWF MESS_COUNT

MOVLW H'02'CALL EEPROM_READMOVFW READBACKMOVWF CONT_REMOTE

CALL TIMER1_INITIALIZATION

Page 50: Intelligent Speed Adaptation

CALL RS232_RECIEVE_INITIALIZATION

STARTCALL SCREENCALL SWITCHCALL TRANSFER_TRASMCALL TRANSFER_REMOTEGOTO START

;**************************************************************************************************************************************************

; REMOTE TRANSMING ROUTING;**************************************************************************************************************************************************TRANSFER_REMOTE

BTFSC PR_MESSAGERETURNBTFSC TRANSRETURNBTFSS REMOTERETURN

CLRF TX_COUNTER

BTFSC UPGOTO PRO1

BTFSC DWNGOTO PRO1

BTFSC STOPGOTO PRO1

RETURNPRO1

MOVLW "{"CALL TX_COM

MOVLW "R"

Page 51: Intelligent Speed Adaptation

CALL TX_COM

BTFSS UPGOTO AN1

MOVLW "U"CALL TX_COMMOVLW "P"CALL TX_COMGOTO NEX1

AN1BTFSS DWNGOTO AN2

MOVLW "D"CALL TX_COMMOVLW "W"CALL TX_COMGOTO NEX1

AN2BTFSS STOPGOTO EN1

MOVLW "S"CALL TX_COMMOVLW "T"CALL TX_COMGOTO NEX1

NEX1MOVLW "?"CALL TX_COMMOVLW "}"CALL TX_COM

MOVLW H'20'CALL PR_DELAY

EN1BCF UPBCF DWNBCF STOP

RETURN

Page 52: Intelligent Speed Adaptation

;**************************************************************************************************************************************************

; TRANSMITER TRANSMING ROUTING ROUTINE;**************************************************************************************************************************************************TRANSFER_TRASM

BTFSC PR_MESSAGERETURNBTFSC PR_SPEEDRETURNBTFSC REMOTERETURNBTFSS TRANSRETURNDECFSZ TX_COUNTER,FRETURNMOVLW "{"CALL TX_COM

MOVLW "T"CALL TX_COM

MOVFW SPEEDCALL TX_COM

MOVFW MESS_COUNTCALL TX_COM

MOVLW "?"CALL TX_COM

MOVLW "}"CALL TX_COM

MOVLW H'20'CALL PR_DELAY

RETURN

Page 53: Intelligent Speed Adaptation

;**************************************************************************************************************************************************

; SWITCH CONDITION FETCHING AND DESION ROUTINE;**************************************************************************************************************************************************SWITCH

BSF RL1BCF RL2BCF RL3BCF RL4CALL DELAY255BTFSC CL1BSF SWT1,0BTFSS CL1BCF SWT1,0

BTFSC CL2BSF SWT1,1BTFSS CL2BCF SWT1,1

BTFSC CL3BSF SWT1,2BTFSS CL3BCF SWT1,2

BTFSC CL4BSF SWT1,3BTFSS CL4BCF SWT1,3

BCF RL1BSF RL2BCF RL3BCF RL4CALL DELAY255BTFSC CL1BSF SWT1,4BTFSS CL1

Page 54: Intelligent Speed Adaptation

BCF SWT1,4

BTFSC CL2BSF SWT1,5BTFSS CL2BCF SWT1,5

BTFSC CL3BSF SWT1,6BTFSS CL3BCF SWT1,6

BTFSC CL4BSF SWT1,7BTFSS CL4BCF SWT1,7

BCF RL1BCF RL2BSF RL3BCF RL4CALL DELAY255BTFSC CL1BSF SWT2,0BTFSS CL1BCF SWT2,0

BTFSC CL2BSF SWT2,1BTFSS CL2BCF SWT2,1

BTFSC CL3BSF SWT2,2BTFSS CL3BCF SWT2,2

BTFSC CL4BSF SWT2,3BTFSS CL4BCF SWT2,3

Page 55: Intelligent Speed Adaptation

BCF RL1BCF RL2BCF RL3BSF RL4CALL DELAY255BTFSC CL1BSF SWT2,4BTFSS CL1BCF SWT2,4

BTFSC CL2BSF SWT2,5BTFSS CL2BCF SWT2,5

BTFSC CL3BSF SWT2,6BTFSS CL3BCF SWT2,6

BTFSC CL4BSF SWT2,7BTFSS CL4BCF SWT2,7

MOVFW SWT1XORLW H'00'BTFSC STATUS,ZGOTO TEST1GOTO TEST2

TEST1MOVFW SWT2XORLW H'00'BTFSC STATUS,ZGOTO ONE_BUTTONGOTO OKTEST

TEST2MOVFW SWT2XORLW H'00'BTFSC STATUS,ZGOTO OKTEST

Page 56: Intelligent Speed Adaptation

RETURN

OKTESTMOVFW SWT1XORWF SWT2,WBTFSC STATUS,ZRETURN

MOVFW SWT1XORLW H'01'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'02'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'04'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'08'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'10'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'20'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT1XORLW H'40'BTFSC STATUS,ZGOTO ONE_BUTTON

Page 57: Intelligent Speed Adaptation

MOVFW SWT1XORLW H'80'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'01'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'02'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'04'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'08'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'10'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'20'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'40'BTFSC STATUS,ZGOTO ONE_BUTTON

MOVFW SWT2XORLW H'80'BTFSC STATUS,Z

Page 58: Intelligent Speed Adaptation

GOTO ONE_BUTTONRETURN

ONE_BUTTONBCF FSW1BTFSS SWT1,0GOTO N1BTFSC FSW1GOTO N1BSF FSW1BSF PR_SPEEDBCF PR_MESSAGEBCF PR_TRANS_REMOCLRWCALL EEPROM_READMOVFW READBACKMOVWF SPEEDCALL SPEED_DISPLAYRETURN

N1BTFSS SWT1,1BCF FSW2BTFSS SWT1,1GOTO N2BTFSC FSW2GOTO N2BSF FSW2BTFSS PR_SPEEDRETURNMOVLW H'02'ADDWF SPEED,FMOVFW SPEEDSUBLW H'64'GOTO DF1MOVLW H'64'MOVWF SPEED

DF1CALL SPEED_DISPLAYRETURN

N2BTFSS SWT1,2BCF FSW3

Page 59: Intelligent Speed Adaptation

BTFSS SWT1,2GOTO N3BTFSC FSW3GOTO N3BSF FSW3BTFSS PR_SPEEDRETURNMOVLW H'02'SUBWF SPEED,FBTFSC STATUS,CGOTO DF2CLRF SPEED

DF2CALL SPEED_DISPLAYRETURN

N3BTFSS SWT1,3BCF FSW4BTFSS SWT1,3GOTO N4BTFSC FSW4GOTO N4BSF FSW4BTFSS PR_SPEEDRETURNBCF PR_SPEEDBCF PR_MESSAGEBCF PR_TRANS_REMOBCF SCR

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

CLRW ;SELECTING EEPROM 00 ADDRESS T0 READ

CALL EEPROM_READMOVFW READBACKXORWF SPEED,WBTFSC STATUS,ZRETURNMOVFW SPEEDBANK2CLRF EE_ADDCALL EEPROM_WRITE

Page 60: Intelligent Speed Adaptation

RETURN

N4BTFSS SWT1,4BCF FSW5BTFSS SWT1,4GOTO N5BTFSC FSW5GOTO N5BSF FSW5BCF PR_SPEEDBSF PR_MESSAGEBCF PR_TRANS_REMO

MOVLW H'01'CALL EEPROM_READMOVFW READBACKMOVWF MESS_COUNT

CALL MESSAGE_DISPLAYRETURN

N5BTFSS SWT1,5BCF FSW6BTFSS SWT1,5GOTO N6BTFSC FSW6GOTO N6BSF FSW6BTFSS PR_MESSAGERETURNINCF MESS_COUNT,FMOVFW MESS_COUNTXORLW H'06'BTFSS STATUS,ZGOTO MSCLRF MESS_COUNT

MSCALL MESSAGE_DISPLAYRETURN

N6BTFSS SWT1,6BCF FSW7BTFSS SWT1,6

Page 61: Intelligent Speed Adaptation

GOTO N7BTFSC FSW7GOTO N7BSF FSW7BTFSS PR_MESSAGERETURNDECFSZ MESS_COUNT,FGOTO MS1MOVLW H'05'MOVWF MESS_COUNT

MS1CALL MESSAGE_DISPLAYRETURN

N7BTFSS SWT1,7BCF FSW8BTFSS SWT1,7GOTO N8BTFSC FSW8GOTO N8BSF FSW8BTFSS PR_MESSAGERETURNBCF PR_SPEEDBCF PR_MESSAGEBCF PR_TRANS_REMOBCF SCR

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'01'CALL EEPROM_READMOVFW READBACKXORWF MESS_COUNT,WBTFSC STATUS,ZRETURNBANK2MOVLW H'01'MOVWF EE_ADDBANK0MOVFW MESS_COUNTCALL EEPROM_WRITERETURN

Page 62: Intelligent Speed Adaptation

N8BTFSS SWT2,0BCF FSW9BTFSS SWT2,0GOTO N9BTFSC FSW9GOTO N9BSF FSW9BCF PR_SPEEDBCF PR_MESSAGEBSF PR_TRANS_REMOMOVLW H'02'CALL EEPROM_READMOVFW READBACKMOVWF CONT_REMOTECALL TRANS_REMOTERETURN

N9BTFSS SWT2,1BCF FSW10BTFSS SWT2,1GOTO N10BTFSC FSW10GOTO N10BSF FSW10BSF TRANSBCF REMOTECALL TRANS_REMOTERETURN

N10BTFSS SWT2,2BCF FSW11BTFSS SWT2,2GOTO N11BTFSC FSW11GOTO N11BSF FSW11BCF TRANSBSF REMOTECALL TRANS_REMOTERETURN

N11BTFSS SWT2,3BCF FSW12BTFSS SWT2,3

Page 63: Intelligent Speed Adaptation

GOTO N12BTFSC FSW12GOTO N12BSF FSW12BCF PR_SPEEDBCF PR_MESSAGEBCF PR_TRANS_REMOBCF SCR

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'02'CALL EEPROM_READMOVFW READBACKXORWF CONT_REMOTE,WBTFSC STATUS,ZRETURNBANK2MOVLW H'02'MOVWF EE_ADDBANK0MOVFW CONT_REMOTECALL EEPROM_WRITERETURN

RETURNN12

BTFSS SWT2,4BCF FSW13BTFSS SWT2,4GOTO N13BTFSC FSW13GOTO N13BSF FSW13BSF UPBCF DWNBCF STOPRETURN

N13BTFSS SWT2,5BCF FSW14BTFSS SWT2,5

Page 64: Intelligent Speed Adaptation

GOTO N14BTFSC FSW14GOTO N14BSF FSW14BCF UPBSF DWNBCF STOPRETURN

N14BTFSS SWT2,6BCF FSW15BTFSS SWT2,6GOTO N15BTFSC FSW15GOTO N15BSF FSW15BCF UPBCF DWNBSF STOPRETURN

N15BTFSS SWT2,7BCF FSW16BTFSS SWT2,7RETURNBTFSC FSW16RETURNBSF FSW16MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITEBCF PR_SPEEDBCF PR_MESSAGEBCF PR_TRANS_REMOBCF SCRRETURN

RETURN;***********************************************************************************************************

;SPEED DISPALY & CONVERSION ROUTINE;***********************************************************************************************************

Page 65: Intelligent Speed Adaptation

SPEED_DISPLAY

BTFSS PR_SPEED

MOVLW H'80' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

MOVLW "E"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "n"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "t"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "r"MOVWF LCD_DATACALL DATA_WRITE

MOVLW " "MOVWF LCD_DATACALL DATA_WRITE

MOVLW "S"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "p"MOVWF LCD_DATACALL DATA_WRITE

Page 66: Intelligent Speed Adaptation

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "d"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "-"MOVWF LCD_DATACALL DATA_WRITE

MOVFW SPEEDMOVWF L_BYTECLRF M_BYTECLRF H_BYTECALL B2_BCD

MOVFW R1XORLW H'00'BTFSC STATUS,ZGOTO S0

MOVFW R1ANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

S0

SWAPF R2,WANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

MOVFW R2

Page 67: Intelligent Speed Adaptation

ANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

MOVLW "%" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITERETURN

;***********************************************************************************************************

;TRANSMITER AND REMOTE SELECTION ROUTINE;***********************************************************************************************************

TRANS_REMOTEBTFSC PR_SPEEDRETURNBTFSC PR_MESSAGERETURNBTFSS PR_TRANS_REMORETURNMOVLW H'80' ;cursor HOME POSTION

positonMOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

BTFSC REMOTEGOTO RE1BTFSC TRANSGOTO TI1RETURN

RE1MOVLW "R"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATA

Page 68: Intelligent Speed Adaptation

CALL DATA_WRITE

MOVLW "m"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "o"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "t"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "-"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "M"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "o"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "d"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "."MOVWF LCD_DATACALL DATA_WRITERETURN

Page 69: Intelligent Speed Adaptation

TI1MOVLW "T"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "r"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "a"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "n"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "s"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "m"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "i"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "t"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "r"MOVWF LCD_DATACALL DATA_WRITE

Page 70: Intelligent Speed Adaptation

MOVLW "-"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "M"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "o"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "d"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "."MOVWF LCD_DATACALL DATA_WRITERETURN

;***********************************************************************************************************

;MESSAGE DISPLAY ROUTINE;***********************************************************************************************************

MESSAGE_DISPLAY

BTFSC PR_SPEEDRETURNBTFSS PR_MESSAGERETURN

MOVLW H'80' ;cursor HOME POSTION positon

MOVWF LCD_CMD

Page 71: Intelligent Speed Adaptation

CALL CMD_WRITE

MOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

MOVLW "M"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "s"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "s"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "a"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "g"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "-"MOVWF LCD_DATACALL DATA_WRITE

MOVFW MESS_COUNTXORLW H'00'BTFSS STATUS,ZGOTO MS2MOVLW " "MOVWF FIRST_WORD

Page 72: Intelligent Speed Adaptation

MOVLW " "MOVWF SECOND_WORDMOVLW " "MOVWF THIRD_WORDGOTO SHOW

MS2MOVFW MESS_COUNTXORLW H'01'BTFSS STATUS,ZGOTO MS3MOVLW "L"MOVWF FIRST_WORDMOVLW "T"MOVWF SECOND_WORDMOVLW "N"MOVWF THIRD_WORDGOTO SHOW

MS3MOVFW MESS_COUNTXORLW H'02'BTFSS STATUS,ZGOTO MS4MOVLW "B"MOVWF FIRST_WORDMOVLW "R"MOVWF SECOND_WORDMOVLW "D"MOVWF THIRD_WORDGOTO SHOW

MS4MOVFW MESS_COUNTXORLW H'03'BTFSS STATUS,ZGOTO MS5MOVLW "W"MOVWF FIRST_WORDMOVLW "I"MOVWF SECOND_WORDMOVLW "P"MOVWF THIRD_WORDGOTO SHOW

MS5MOVFW MESS_COUNTXORLW H'04'

Page 73: Intelligent Speed Adaptation

BTFSS STATUS,ZGOTO MS6MOVLW "N"MOVWF FIRST_WORDMOVLW "H"MOVWF SECOND_WORDMOVLW "R"MOVWF THIRD_WORDGOTO SHOW

MS6MOVFW MESS_COUNTXORLW H'05'BTFSS STATUS,ZGOTO SHOWMOVLW "R"MOVWF FIRST_WORDMOVLW "T"MOVWF SECOND_WORDMOVLW "N"MOVWF THIRD_WORD

SHOW

MOVFW FIRST_WORDMOVWF LCD_DATACALL DATA_WRITE

MOVFW SECOND_WORDMOVWF LCD_DATACALL DATA_WRITE

MOVFW THIRD_WORDMOVWF LCD_DATACALL DATA_WRITERETURN

;***********************************************************************************************************

;MESSAGE DISPLAY ROUTINE;***********************************************************************************************************

SCREENBTFSC PR_SPEED

Page 74: Intelligent Speed Adaptation

RETURNBTFSC PR_MESSAGERETURNBTFSC SCRRETURNBSF SCRMOVLW H'01' MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'84' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW "o"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "i"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "s"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "T"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "."MOVWF LCD_DATACALL DATA_WRITE

MOVLW H'C3' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW "B"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "H"

Page 75: Intelligent Speed Adaptation

MOVWF LCD_DATACALL DATA_WRITE

MOVLW "O"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "P"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "A"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "L"MOVWF LCD_DATACALL DATA_WRITE

RETURN

; ***********************************************READ ROUTINE********************************************************************** ; TAKE THE ADDRESS IN LCD_CMD GIVE U A DATAA IN

LCD_READBACK

DATA_READCALL CMD_WRITECALL READYCALL READBACK_LCD

RETURN;***********************************LCD CLEARING ROUTINE ROUTINE***************************************************************************; TAKE COMMAND IN LCD_CMDCMD_WRITE

CALL READYCALL CMDWRTRETURN

;***********************************LCD CLEARING ROUTINE ROUTINE***************************************************************************

Page 76: Intelligent Speed Adaptation

; TAKE COMMAND IN LCD_DATADATA_WRITE

CALL READYCALL DATAWRTRETURN

;***********************************LCD CLEARING ROUTINE ROUTINE***************************************************************************CLEAR_LCD

CALL READYMOVLW H'01' ;CLEAR DISPLAY MOVWF LCD_CMDCALL CMDWRTRETURN

;***********************************LCD DATA SEND ROUTINE ROUTINE***************************************************************************DATAWRT

BSF RS ;RS PULL TO HIGHBCF RW ;RW PULL TO HIGHBTFSC LCD_DATA,0BSF REVDATA,7BTFSS LCD_DATA,0BCF REVDATA,7

BTFSC LCD_DATA,1BSF REVDATA,6BTFSS LCD_DATA,1BCF REVDATA,6

BTFSC LCD_DATA,2BSF REVDATA,5BTFSS LCD_DATA,2BCF REVDATA,5

BTFSC LCD_DATA,3BSF REVDATA,4BTFSS LCD_DATA,3BCF REVDATA,4

BTFSC LCD_DATA,4

Page 77: Intelligent Speed Adaptation

BSF REVDATA,3BTFSS LCD_DATA,4BCF REVDATA,3

BTFSC LCD_DATA,5BSF REVDATA,2BTFSS LCD_DATA,5BCF REVDATA,2

BTFSC LCD_DATA,6BSF REVDATA,1BTFSS LCD_DATA,6BCF REVDATA,1

BTFSC LCD_DATA,7BSF REVDATA,0BTFSS LCD_DATA,7BCF REVDATA,0

MOVFW REVDATA ;LCD COMMAND TRANFER TO W MOVWF PORTB ;LCD DATA COMMAND TO LCD

PINS BSF EN ;EN THE TRANSFERNOP NOPBCF ENNOP NOPRETLW H'00'

;***********************************LCD COMMAND SEND ROUTINE ROUTINE***************************************************************************CMDWRT

BCF RS ;RS PULL TO LOWBCF RW ;RW PULL TO LOW

BTFSC LCD_CMD,0BSF REVDATA,7BTFSS LCD_CMD,0BCF REVDATA,7

BTFSC LCD_CMD,1

Page 78: Intelligent Speed Adaptation

BSF REVDATA,6BTFSS LCD_CMD,1BCF REVDATA,6

BTFSC LCD_CMD,2BSF REVDATA,5BTFSS LCD_CMD,2BCF REVDATA,5

BTFSC LCD_CMD,3BSF REVDATA,4BTFSS LCD_CMD,3BCF REVDATA,4

BTFSC LCD_CMD,4BSF REVDATA,3BTFSS LCD_CMD,4BCF REVDATA,3

BTFSC LCD_CMD,5BSF REVDATA,2BTFSS LCD_CMD,5BCF REVDATA,2

BTFSC LCD_CMD,6BSF REVDATA,1BTFSS LCD_CMD,6BCF REVDATA,1

BTFSC LCD_CMD,7BSF REVDATA,0BTFSS LCD_CMD,7BCF REVDATA,0

MOVFW REVDATA ;LCD COMMAND TRANFER TO W MOVWF PORTB ;LCD DATA COMMAND TO LCD

PINS BSF EN ;EN THE TRANSFERNOP NOP BCF ENNOP NOP

Page 79: Intelligent Speed Adaptation

RETLW H'00';**************************************DATAREAD FRM LCD***********************************************************************READBACK_LCD

BSF RSBSF RWBANK1

MOVLW H'FF'MOVWF TRISB ; MAKE ALL PINS INPUT TO

RECIVE DATABANK0BSF ENNOP NOP BTFSC PORTB,0BSF REVDATA,7BTFSS PORTB,0BCF REVDATA,7

BTFSC PORTB,1BSF REVDATA,6BTFSS PORTB,1BCF REVDATA,6

BTFSC PORTB,2BSF REVDATA,5BTFSS PORTB,2BCF REVDATA,5

BTFSC PORTB,3BSF REVDATA,4BTFSS PORTB,3BCF REVDATA,4

BTFSC PORTB,4BSF REVDATA,3BTFSS PORTB,4BCF REVDATA,3

BTFSC PORTB,5BSF REVDATA,2BTFSS PORTB,5

Page 80: Intelligent Speed Adaptation

BCF REVDATA,2

BTFSC PORTB,6BSF REVDATA,1BTFSS PORTB,6BCF REVDATA,1

BTFSC PORTB,7BSF REVDATA,0BTFSS PORTB,7BCF REVDATA,0

MOVFW REVDATA ;LCD COMMAND TRANFER TO W MOVWF LCD_READBACKBCF ENNOP NOPBANK1

CLRF TRISB ; MAKE ALL PINS OUTPUT BANK0RETLW H'00'

;***********************************LCD BUSY CHECK ROUTINE***************************************************************************

READYBCF PORTB,0BANK1BSF TRISB,0BANK0BCF RS ;FOR READING LCDBSF RW ;FOR READING LCDBCF ENNOP NOP BSF ENNOP NOPBTFSC PORTB,0GOTO READYBANK1BCF TRISB,0BANK0

Page 81: Intelligent Speed Adaptation

BCF RWRETURN

;**************************************************************************************************************************************************

; BINARY TO BCD CONVERION ROUTINE;**************************************************************************************************************************************************B2_BCD

BCF STATUS,0 ; clear the carry bitMOVLW .24MOVWF COUNTCLRF R0CLRF R1CLRF R2

LOOP16 RLF L_BYTE, FRLF M_BYTE , FRLF H_BYTE , FRLF R2, FRLF R1, FRLF R0, FDECFSZ COUNT, FGOTO ADJDEC RETLW 0

ADJDEC MOVLW R2MOVWF FSRCALL ADJBCDMOVLW R1MOVWF FSRCALL ADJBCDMOVLW R0MOVWF FSRCALL ADJBCDGOTO LOOP16

ADJBCD MOVLW 3ADDWF 0,WMOVWF TEMPBTFSC TEMP,3 ; test if result > 7MOVWF 0MOVLW 30ADDWF 0,W

Page 82: Intelligent Speed Adaptation

MOVWF TEMPBTFSC TEMP,7 ; test if result > 7MOVWF 0 ; save as MSDRETLW 0

;**************************************************************************************************************************************************

; EEPROM ROUTINES ROUTINE;**************************************************************************************************************************************************

EEPROM_WRITEBANK2MOVWF EEDATAMOVWF EEADRBANK3BCF EECON1,EEPGDBSF EECON1,WRENBCF INTCON,GIEMOVLW H'55'MOVWF EECON2MOVLW H'AA'MOVWF EECON2BSF EECON1,WR BSF INTCON,GIEBANK0CALL DELAY255BANK3BTFSC EECON1,WRGOTO $-1BCF EECON1,WRENBANK0RETURN

EEPROM_READBANK2MOVWF EEADRBANK3BCF EECON1,EEPGDBSF EECON1,RDBANK2MOVFW EEDATABANK0MOVWF READBACKRETURN

Page 83: Intelligent Speed Adaptation

;**************************************************************************************************************************************************

; COMPUTER TRANSMITTING ROUTINE;**************************************************************************************************************************************************

TX_COMMOVWF TXREGBANK1BTFSS TXSTA,TRMTGOTO $-1BANK0CALL DELAY255RETURN

;**************************************************************************************************************************************************

; LCD INTIALIZATION ROUTINE;**************************************************************************************************************************************************LCD_INITIALIZATION

CALL PR_DELAY ;30 MSEC START DELAY FOR LCD TO RISE POWER

CALL PR_DELAY ;30 MSEC START DELAY FOR LCD TO RISE POWER

MOVLW H'3B' ;FUNCTION SET[0,0,0,1(FOR LCD REQ.),1(DL, DATA LENGTH 8),1(N SET 2 LINES),1(F -FONT 5X10 DOTS,X,X)

MOVWF LCD_CMD ; NO READY HAS BEEN CHECKED

CALL CMDWRT

MOVLW H'0C' ;LCD SETTING(0,0,0,0,1(ALWAYS),1(D,TO INCREMENT ADDRESS AUTO),1(C-ON THE CURSOR),1(BTO BLINK THE CURSOR))

MOVWF LCD_CMDCALL CMD_WRITE

CALL CLEAR_LCD

Page 84: Intelligent Speed Adaptation

MOVLW H'80' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITERETURN

;;*****************************************************************************************************************************************************************

;TIMER INTIALIZING ROUITINE;*****************************************************************************************************************************************************************TIMER1_INITIALIZATION

BTFSC TIME_ONRETURNBSF TIME_ONCLRF TMR1L ; CLEAR LOW BYTE OF TIMER1CLRF TMR1H ; CLEAR HIGH BYTE OF TIMER1BANK1BCF PIE1,CCP1IE; ENABLE THE COMPARE MODE

FOR TIMER1BANK0MOVLW H'50' ;

TRANSFER THE DATA OF LOWER BYTE OF 10000 EQUIVALENT TO COMPARE DATA REG LOWER AT 16 MHZ

MOVLW H'C3'MOVWF CCPR1H ;

TRANSFER THE DATA OF HIGHER BYTE OF 10000 EQUIVALENT TO COMPARE DATA REG HIGHER AT 16 MHZ

BSF TIME_ERBANK1BSF PIE1,CCP1IE; ENABLE THE COMPARE MODE

FOR TIMER1BANK0BCF TIME_ERMOVLW B'00110101'; TRANSFER THE DATA FOR

ENABLEING TIMER1 CONTROL TO WMOVWF T1CON ; TRANSFER THE DATA FOR

ENABLEING TIMER1 CONTROL TO TIMER1 CONTROL REGMOVLW B'00001010'; TRANSFER THE DATA FOR

ENABLEING COMPARE MODE CONTROL TO W

Page 85: Intelligent Speed Adaptation

MOVWF CCP1CON ; TRANSFER THE DATA FOR ENABLEING COMPARE MODE CONTROL TO COMPARE MODE CONTROL REG

CLRF TMR1L ; CLEAR LOW BYTE OF TIMER1CLRF TMR1H ; CLEAR HIGH BYTE OF TIMER1RETURN

;;*****************************************************************************************************************************************************************

;PORTINTIALIZATION ROUTINE

;*****************************************************************************************************************************************************************PORT_INTITIALIZE

BANK1 MOVLW B'11111000'

MOVWF TRISA CLRF TRISB

MOVLW B'10000001' ;C6 TX IS O/P MOVWF TRISC ;TRANSFER TO PORTC

DIRECTION REGISTERMOVLW B'00000111'MOVWF ADCON1BANK0

CLRF PORTA CLRF PORTB

CLRF PORTC MOVLW B'11000000' ; TRANSFER THE DATA

FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO WMOVWF INTCON ; TRANSFER THE DATA

FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO INTERRUPT CONTROL REGISTER

RETURN;;*****************************************************************************************************************************************************************

;RS232 INTIALIZE ROUTINE;*****************************************************************************************************************************************************************RS232_RECIEVE_INITIALIZATION

CLRF STATUS

Page 86: Intelligent Speed Adaptation

MOVLW BAUD_CONSTANT

MOVWF SPBRGMOVLW B'10100000'MOVWF TXSTABSF PIE1,RCIECLRF STATUSMOVLW B'10010000'MOVWF RCSTAMOVLW B'11000000'; TRANSFER THE DATA FOR

ENABLEING GENERAL AND PERIPHERAL INTERPPT TO WMOVWF INTCON ; TRANSFER THE DATA FOR

ENABLEING GENERAL AND PERIPHERAL INTERPPT TO INTERRUPT CONTROL REGISTER

RETURN

;;*****************************************************************************************************************************************************************

;PROGRAMABLE DELAY ROUTINE;*****************************************************************************************************************************************************************PR_DELAY

MOVWF PRCOUNTEROO1

CALL DELAY255DECFSZ PRCOUNTER,FGOTO OO1RETURN

;;*****************************************************************************************************************************************************************

;255 CYCLE DELAY ROUTINE;*****************************************************************************************************************************************************************DELAY255

DECFSZ COUNTER,FGOTO DELAY255RETURN

Page 87: Intelligent Speed Adaptation

;;*****************************************************************************************************************************************************************

;RAM CLEANING ROUNTINE;*****************************************************************************************************************************************************************CHECK_RAM1

MOVLW D'20' ;THIS IS FOR INITIAL POWER UP DELAY

MOVWF COUNT_REG1 ;TRANSFER TO COUNT_REG1 REGISTERCHECK_RAM2

CALL CHECK_RAM ;CALL SUBROUTINE FOR CHECKING THE RAM

CLRWDT ;CLEAR WATCHDOG TIMER

DECFSZ COUNT_REG1,F ;DECREASE COUNT_REG1 AND AND CHECK IF ZERO THEN SKIP

GOTO CHECK_RAM2 ;GOTO CHECK_RAM2 LABEL

RETURN

CHECK_RAMCLRF STATUS ;GOTO BANK0MOVLW H'50' ;THIS IS FOR RAM

REGISTER COUNT TO BE CLEAREDMOVWF TMP_COUNT ;TRANSFER TO TMP_COUNT

REGISTERMOVLW H'70' ;THIS IS START RAM

REGISTER MOVWF FSR ;TRANSFER TO FSR

REGISTER FOR INDIRECT ADDRESSINGMOVLW H'FF' ;MAKE ALL BITS OF

THE REGISTER UNDER CONSIDERATION TO 1STEP1

MOVWF INDF ;TRANSFER TO FSR REGISTER DIRECTED REGISTER

DECF FSR,F ;DECREASE FSR FOR FOR NEXT REGISTER TO GO

DECFSZ TMP_COUNT,F ;DECREASE TMP_COUNT AND CHECH WHETHER ALL REGISTERED AS DESIRED MADE "FF"

GOTO STEP1 ;IF NOT GOTO 3 STEPS UP

Page 88: Intelligent Speed Adaptation

MOVLW H'50' ;THIS IS FOR RAM REGISTER COUNT TO BE CLEARED

MOVWF TMP_COUNT ;TRANSFER TO TMP_COUNT REGISTER

MOVLW H'70' ;THIS IS START RAM REGISTER

MOVWF FSR ;TRANSFER TO FSR REGISTER FOR INDIRECT ADDRESSINGSTEP2

MOVLW H'FF' ;FEED ALL BITS OF W 1

XORWF INDF,F ;XOR WITH THE INDIRECTLY ADDRESSED REGISTER

BTFSS STATUS,Z ;SKIP IF ALL BITS IN W ARE ZERO

GOTO CHECK_RAM ;ELSE GOTO CHECK_RAM LABEL

DECF FSR,F ;DECREASE FSR FOR FOR NEXT REGISTER TO GO

DECFSZ TMP_COUNT,F ;DECREASE TMP_COUNT AND CHECH WHETHER ALL REGISTERED AS DESIRED MADE "00"

GOTO STEP2 ;IF NOT GOTO 5 STEPS UP

RETURN ;RETURN FROM THE SUB ROUTINE

END

Page 89: Intelligent Speed Adaptation

;*******************************************LCD ********************************************************************************; IST LINE HOME ADDRESS ;80H 81H _ _ 8F; 2ND LINE HOME ADDRESS ;C0H C1H _ _ CF

cblock 0x20READBACKCOUNTERLCD_CMDLCD_DATALCD_READBACKPRCOUNTERREVDATASPEED_DISSPEED_DISPSEQUECETLONTHONTLOFFTHOFFFLAG0FLAG1TLTHCOUNTTEMPH_BYTEM_BYTEL_BYTER0 R1 R2 NUM RSDATARSDATA1RSDATA2RSDATA3RSDATA4BYTE_COUNTRX_SPEEDRX_MESSAGERX_MESSAGEPCOUNTER25COUNTER26

Page 90: Intelligent Speed Adaptation

FIRST_WORDSECOND_WORDTHIRD_WORDendc

BAUD_CONSTANT EQU D'207'; BAUDRATE= 1200EE_ADD EQU H'120';****************************************************PINS DECLARATION****************************************************************#DEFINE EN PORTA,0 ; FOR LCD#DEFINE RW PORTA,1 ; FOR LCD#DEFINE RS PORTA,2 ; FOR LCD#DEFINE NUMUP PORTA,4 ; FOR SPEED DW#DEFINE NUMDWN PORTA,3 ; FOR SPEED DW#DEFINE SPDWN PORTA,5 ; FOR SPEED DW#DEFINE SPUP PORTC,0 ; FOR SPEED DW#DEFINE OVERSP PORTC,1 ; FOR SPEED DW#DEFINE MT1 PORTC,5 ; FOR MOTOR#DEFINE MT2 PORTC,4 ; FOR MOTOR#DEFINE MT3 PORTC,3 ; FOR MOTOR#DEFINE MT4 PORTC,2 ; FOR MOTOR#DEFINE TIME_ER FLAG1,0#DEFINE TIMER_ON FLAG1,1#DEFINE TON FLAG1,2#DEFINE TOFF FLAG1,3#DEFINE SW FLAG0,0#DEFINE SW1 FLAG0,1#DEFINE SW2 FLAG0,2#DEFINE SW3 FLAG0,3#DEFINE STP FLAG0,4#DEFINE MS_SP FLAG0,5#DEFINE UP_RES FLAG0,6

;****************************************INTRUPT ROUTINE REGISTERS**************************************************************TEMPW EQU H'7B'TEMPSTATUS EQU H'7C'TEMPPCLATH EQU H'7D';****************************************RAM CLEANING ROUTINE REGISTERS*******************************************************************COUNT_REG1 EQU H'7E'TMP_COUNT EQU H'7F'

Page 91: Intelligent Speed Adaptation

;************************************************************************************************************************************

ERRORLEVEL-302BANK0 MACRO ;macro to select data RAM bank 0

BCF STATUS,RP0BCF STATUS,RP1ENDM

BANK1 MACRO ;macro to select data RAM bank 1

BSF STATUS,RP0BCF STATUS,RP1ENDM

BANK2 MACRO ;macro to select data RAM bank 2

BCF STATUS,RP0BSF STATUS,RP1ENDM

BANK3 MACRO ;macro to select data RAM bank 3

BSF STATUS,RP0BSF STATUS,RP1ENDM

include "P16F877.inc" org 0

GOTO INITIALIZE org 4 GOTO INTERRUPT

ASCII ANDLW B'00001111' ADDWF PCL,F RETLW H'30';0 RETLW H'31';1 RETLW H'32';2 RETLW H'33';3 RETLW H'34';4 RETLW H'35';5 RETLW H'36';6 RETLW H'37';7

Page 92: Intelligent Speed Adaptation

RETLW H'38';8 RETLW H'39';9 RETLW H'41';A RETLW H'42';B RETLW H'43';C RETLW H'44';D RETLW H'45';E RETLW H'46';F

;***********************************************I S

R****************************************************************************INTERRUPT

MOVWF TEMPW ; TRANSFER DATA OF W TO TEMPW

SWAPF STATUS, W ; SWAP AND TRANSFER DATA OF STATUS TO W

CLRF STATUS ; CLEAR STATUSMOVWF TEMPSTATUS ; TRANSFER DATA OF W TO

TEMPSTATUSMOVF PCLATH, W ; TRANSFER DATA OF PCLATH TO

WMOVWF TEMPPCLATH ; TRANSFER DATA OF W TO

TEMPPCLATHCLRF PCLATH ; CLEAR PCLATHCLRWDT ;CLEAR WATCH DOG TIMERBTFSC PIR1,CCP1IF ;GOTO TIMER1 INTERRUPT

PROCESSINGGOTO TIME_DOBTFSC RCSTA,FERRGOTO FERR_ERRBTFSC RCSTA,OERRGOTO OVER_ERRBTFSC PIR1,RCIF ;CHECK WHETHER INTERRUPT

GENERATED BY THE TIMER1 IF NO THEN SKIPGOTO RX_INTERRUPT ;GOTO TIMER1 INTERRUPT

PROCESSING

DATA_RETURNMOVF TEMPPCLATH, W ; TRANSFER DATA OF

TEMPPCLATH TO WMOVWF PCLATH ; TRANSFER DATA OF

W TO PCLATHSWAPF TEMPSTATUS, W ; TRANSFER DATA OF

TEMPSTATUS TO W

Page 93: Intelligent Speed Adaptation

MOVWF STATUS ; TRANSFER DATA OF W TO STATUS

MOVF TEMPW, W ; TRANSFER DATA OF TEMPW TO W

RETFIE ; RETURN FROM INTERRUPTFERR_ERR

MOVFW RCREGCLRWBCF RCSTA,FERRGOTO RESET_BYTE_COUNT

OVER_ERRBCF RCSTA,CRENMOVFW RCREGCLRWCALL DELAY255BSF RCSTA,CRENGOTO RESET_BYTE_COUNT

RX_INTERRUPTBCF PIR1,RCIFMOVFW RCREGMOVWF RSDATAMOVFW BYTE_COUNTXORLW H'01'BTFSC STATUS,ZGOTO CHECK_B1MOVFW BYTE_COUNTXORLW H'02'BTFSC STATUS,ZGOTO STORE_1BMOVFW BYTE_COUNTXORLW H'03'BTFSC STATUS,ZGOTO STORE_2BMOVFW BYTE_COUNTXORLW H'04'BTFSC STATUS,ZGOTO STORE_3BMOVFW BYTE_COUNTXORLW H'05'BTFSC STATUS,ZGOTO STORE_4BMOVFW BYTE_COUNTXORLW H'06'BTFSC STATUS,Z

Page 94: Intelligent Speed Adaptation

GOTO STORE_5BGOTO RESET_BYTE_COUNT

CHECK_B1MOVFW RSDATAXORLW "{"BTFSS STATUS,ZGOTO RESET_BYTE_COUNT

INC_BYTE_COUNTINCF BYTE_COUNT,FGOTO DATA_RETURN

RESET_BYTE_COUNTMOVLW H'01'MOVWF BYTE_COUNTGOTO DATA_RETURN

STORE_1BMOVFW RSDATAMOVWF RSDATA1GOTO INC_BYTE_COUNT

STORE_2BMOVFW RSDATAMOVWF RSDATA2GOTO INC_BYTE_COUNT

STORE_3BMOVFW RSDATAMOVWF RSDATA3GOTO INC_BYTE_COUNT

STORE_4BMOVFW RSDATAMOVWF RSDATA4GOTO INC_BYTE_COUNT

STORE_5BMOVFW RSDATAXORLW "}"BTFSC STATUS,ZGOTO RS232RECIVEGOTO RESET_BYTE_COUNT

RS232RECIVE

MOVFW RSDATA1XORLW "R"BTFSC STATUS,ZGOTO REM

Page 95: Intelligent Speed Adaptation

MOVFW RSDATA1XORLW "T"BTFSC STATUS,ZGOTO TRA

REM

MOVFW RSDATA4XORLW "?"BTFSS STATUS,ZGOTO RESET_BYTE_COUNT

MOVFW RSDATA2XORLW "U"BTFSS STATUS,ZGOTO CHD

MOVFW RSDATA3XORLW "P"BTFSS STATUS,ZGOTO ERCALL RUPGOTO ER

CHDMOVFW RSDATA2XORLW "D"BTFSS STATUS,ZGOTO CHS

MOVFW RSDATA3XORLW "W"BTFSS STATUS,ZGOTO ERCALL RDWGOTO ER

CHS

MOVFW RSDATA2XORLW "S"BTFSS STATUS,ZGOTO ERMOVFW RSDATA3XORLW "T"BTFSS STATUS,ZGOTO ER

Page 96: Intelligent Speed Adaptation

BSF STPER

CLRF RSDATA1CLRF RSDATA2CLRF RSDATA3CLRF RSDATA4GOTO RESET_BYTE_COUNT

TRAMOVFW RSDATA3ANDLW H'0F'MOVWF RX_MESSAGE

MOVFW RSDATA4XORLW "?"BTFSS STATUS,ZGOTO RESET_BYTE_COUNTBTFSC MS_SPGOTO RESET_BYTE_COUNTBSF MS_SPMOVFW RSDATA2MOVWF RX_SPEEDMOVFW RSDATA3ANDLW H'0F'CLRF RSDATA1CLRF RSDATA2CLRF RSDATA3CLRF RSDATA4GOTO RESET_BYTE_COUNT

TIME_DOBCF PIR1,CCP1IF ;GOTO TIMER1 INTERRUPT

PROCESSINGBCF TIMER_ONBTFSC TONGOTO ON_CYCLEBTFSC TOFFGOTO OFF_CYCLEGOTO DATA_RETURN

ON_CYCLEBSF TOFFBCF TON

Page 97: Intelligent Speed Adaptation

BSF MT1BSF MT2BSF MT3BSF MT4MOVFW TLONMOVWF TLMOVWF THCALL TIMER1_INITIALIZATIONGOTO DATA_RETURN

OFF_CYCLEBSF TONBCF TOFFBCF MT1BCF MT2BCF MT3BCF MT4MOVFW TLOFFMOVWF TLMOVFW THOFFMOVWF THCALL TIMER1_INITIALIZATIONGOTO DATA_RETURN

;*********************************************************PROGRAM STARTS*************************************************************INITIALIZE

CALL CHECK_RAM1CALL RS232_RECIEVE_INITIALIZATIONCALL LCD_INITIALIZATIONBSF TONMOVLW H'50'MOVWF TLONMOVWF TLMOVWF SPEED_DISPMOVLW H'00'MOVWF THONMOVWF THMOVLW H'7F'MOVWF COUNTER26

MOVLW H'F0'

Page 98: Intelligent Speed Adaptation

MOVWF TLOFFMOVLW H'0F'MOVWF THOFFCLRW ;SELECTING EEPROM 00 ADDRESS T0

READCALL EEPROM_READMOVFW READBACKMOVWF NUM

CALL TIMER1_INITIALIZATION

STARTBTFSC STPGOTO INITIALIZE BTFSC MS_SPCALL CONTROL

CALL SWITCHCALL DISPLAYGOTO START

;*****************************************************************************************************************************************************************

;SPEED CONTROL ROUTINE;*****************************************************************************************************************************************************************

CONTROL

MOVFW SPEED_DISSUBWF RX_SPEED,WBTFSC STATUS,CGOTO OK_SPEEDBSF UP_RESBSF OVERSPDECFSZ COUNTER25,FRETURNDECFSZ COUNTER26,FRETURNMOVLW H'7F'MOVWF COUNTER26CALL RDW

Page 99: Intelligent Speed Adaptation

RETURNOK_SPEED

BCF UP_RESBCF OVERSPBCF MS_SPCLRF RX_SPEEDRETURN

;*****************************************************************************************************************************************************************

;SPEED AND MESSAGE DISPALY ROUTINE ;*****************************************************************************************************************************************************************

DISPLAY

MOVFW RX_MESSAGEPXORWF RX_MESSAGE,WBTFSS STATUS,ZGOTO DIS_AS

MOVFW SPEED_DISXORWF SPEED_DISP,WBTFSC STATUS,ZRETURN

DIS_ASMOVFW RX_MESSAGEMOVWF RX_MESSAGEP

MOVLW H'01' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'80' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW "S" ;DISPLAY R AT 80

Page 100: Intelligent Speed Adaptation

MOVWF LCD_DATACALL DATA_WRITE

MOVLW "p" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "e" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "d" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "=" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVFW SPEED_DISMOVWF L_BYTECLRF M_BYTECLRF H_BYTECALL B2_BCD

MOVFW R1XORLW H'00'BTFSC STATUS,ZGOTO PO

MOVFW R1ANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

POSWAPF R2,WANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

Page 101: Intelligent Speed Adaptation

MOVFW R2ANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

MOVLW "%"MOVWF LCD_DATACALL DATA_WRITE

MOVLW " "MOVWF LCD_DATACALL DATA_WRITE

MOVFW RX_MESSAGEXORLW H'00'BTFSC STATUS,ZGOTO FR1

MOVLW "C"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "a"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "u"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "t"MOVWF LCD_DATACALL DATA_WRITE

MOVLW "."MOVWF LCD_DATACALL DATA_WRITE

FR1MOVLW H'C0' ;cursor HOME POSTION

positon

Page 102: Intelligent Speed Adaptation

CALL CMD_WRITE

MOVLW "M" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "P" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "0" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "4" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "-" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "N" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "-" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "9" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "6" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

MOVLW "4" ;DISPLAY R AT 80MOVWF LCD_DATACALL DATA_WRITE

Page 103: Intelligent Speed Adaptation

MOVFW NUMMOVWF L_BYTECLRF M_BYTECLRF H_BYTECALL B2_BCD

MOVFW R2ANDLW H'0F'CALL ASCIIMOVWF LCD_DATACALL DATA_WRITE

MOVLW " "MOVWF LCD_DATACALL DATA_WRITE

MOVLW " "MOVWF LCD_DATACALL DATA_WRITE

MOVFW RX_MESSAGEXORLW H'00'BTFSS STATUS,ZGOTO MS2MOVLW " "MOVWF FIRST_WORDMOVLW " "MOVWF SECOND_WORDMOVLW " "MOVWF THIRD_WORDGOTO SHOW

MS2MOVFW RX_MESSAGEXORLW H'01'BTFSS STATUS,ZGOTO MS3MOVLW "L"MOVWF FIRST_WORDMOVLW "T"MOVWF SECOND_WORD

Page 104: Intelligent Speed Adaptation

MOVLW "N"MOVWF THIRD_WORDGOTO SHOW

MS3MOVFW RX_MESSAGEXORLW H'02'BTFSS STATUS,ZGOTO MS4MOVLW "B"MOVWF FIRST_WORDMOVLW "R"MOVWF SECOND_WORDMOVLW "D"MOVWF THIRD_WORDGOTO SHOW

MS4MOVFW RX_MESSAGEXORLW H'03'BTFSS STATUS,ZGOTO MS5MOVLW "W"MOVWF FIRST_WORDMOVLW "I"MOVWF SECOND_WORDMOVLW "P"MOVWF THIRD_WORDGOTO SHOW

MS5MOVFW RX_MESSAGEXORLW H'04'BTFSS STATUS,ZGOTO MS6MOVLW "N"MOVWF FIRST_WORDMOVLW "H"MOVWF SECOND_WORDMOVLW "R"MOVWF THIRD_WORDGOTO SHOW

MS6MOVFW RX_MESSAGEXORLW H'05'BTFSS STATUS,ZGOTO SHOW

Page 105: Intelligent Speed Adaptation

MOVLW "R"MOVWF FIRST_WORDMOVLW "T"MOVWF SECOND_WORDMOVLW "N"MOVWF THIRD_WORD

SHOW

MOVFW FIRST_WORDMOVWF LCD_DATACALL DATA_WRITE

MOVFW SECOND_WORDMOVWF LCD_DATACALL DATA_WRITE

MOVFW THIRD_WORDMOVWF LCD_DATACALL DATA_WRITE

MOVFW SPEED_DISMOVWF SPEED_DISP

CLRW ;SELECTING EEPROM 00 ADDRESS T0 READ

CALL EEPROM_READMOVFW READBACKXORWF NUM,WBTFSC STATUS,ZRETURNMOVFW NUMBANK2CLRF EE_ADD ;SELECTING EEPROM 00

ADDRESS T0 WRITERETURN

;*****************************************************************************************************************************************************************

;SWITCH FETCHING AND DESION ROUTINE

Page 106: Intelligent Speed Adaptation

;*****************************************************************************************************************************************************************

SWITCHBTFSS SPUPBCF SWBTFSS SPUPGOTO NEXT1BTFSC SWGOTO NEXT1BSF SWBTFSC UP_RESRETURN

RUPMOVLW H'02'ADDWF SPEED_DIS,F

MOVFW SPEED_DISSUBLW H'64'BTFSC STATUS,CGOTO OP

MOVLW H'64'MOVWF SPEED_DIS

MOVLW H'F0'MOVWF TLONMOVLW H'0F'MOVWF THON

MOVLW H'50'MOVWF TLOFFMOVLW H'00'MOVWF THOFFRETURN

OPMOVLW H'50'ADDWF TLON,FBTFSC STATUS,CINCF THON,F

MOVLW H'50'SUBWF TLOFF,F

Page 107: Intelligent Speed Adaptation

BTFSS STATUS,CDECF THOFF,FRETURN

NEXT1

BTFSS SPDWNBCF SW1BTFSS SPDWNGOTO NEXT2BTFSC SW1GOTO NEXT2BSF SW1

RDW

MOVLW H'02'SUBWF SPEED_DIS,FBTFSC STATUS,CGOTO OP1

MOVLW H'00'MOVWF SPEED_DIS

MOVLW H'50'MOVWF TLONMOVLW H'00'MOVWF THON

MOVLW H'F0'MOVWF TLOFFMOVLW H'0F'MOVWF THOFFRETURN

OP1MOVLW H'50'ADDWF TLOFF,FBTFSC STATUS,CINCF THOFF,F

MOVLW H'50'SUBWF TLON,FBTFSS STATUS,CDECF THON,FRETURN

Page 108: Intelligent Speed Adaptation

NEXT2BTFSS NUMUPBCF SW2BTFSS NUMUPGOTO NEXT3BTFSC SW2GOTO NEXT3BSF SW2MOVLW H'0A'MOVWF SPEED_DISPINCF NUM,FMOVFW NUMSUBLW H'09'BTFSC STATUS,CRETURNMOVLW H'09'MOVWF NUMRETURN

NEXT3BTFSS NUMDWNBCF SW3BTFSS NUMDWNRETURNBTFSC SW3RETURNBSF SW3MOVLW H'0A'MOVWF SPEED_DISPMOVLW H'01'SUBWF NUM,FBTFSC STATUS,CRETURNMOVLW H'00'MOVWF NUMRETURN

;*****************************************************************************************************************************************************************

;MAIN LCD DATA_READ ROUTINE

Page 109: Intelligent Speed Adaptation

;*****************************************************************************************************************************************************************; TAKE THE ADDRESS IN LCD_CMD GIVE U A DATAA IN

LCD_READBACK

DATA_READCALL CMD_WRITECALL READYCALL READBACK_LCD

RETURN;*****************************************************************************************************************************************************************

;MAIN LCD CMD_WRITE SEND ROUTINE;*****************************************************************************************************************************************************************

; TAKE COMMAND IN LCD_CMDCMD_WRITE

CALL READYCALL CMDWRTRETURN

;*****************************************************************************************************************************************************************

;MAIN LCD DATA SEND ROUTINE;*****************************************************************************************************************************************************************; TAKE COMMAND IN LCD_DATADATA_WRITE

CALL READYCALL DATAWRTRETURN

;;*****************************************************************************************************************************************************************

;LCD DATA SEND ROUTINE

Page 110: Intelligent Speed Adaptation

;*****************************************************************************************************************************************************************DATAWRT

BSF RS ;RS PULL TO HIGHBCF RW ;RW PULL TO HIGHBTFSC LCD_DATA,0BSF REVDATA,7BTFSS LCD_DATA,0BCF REVDATA,7

BTFSC LCD_DATA,1BSF REVDATA,6BTFSS LCD_DATA,1BCF REVDATA,6

BTFSC LCD_DATA,2BSF REVDATA,5BTFSS LCD_DATA,2BCF REVDATA,5

BTFSC LCD_DATA,3BSF REVDATA,4BTFSS LCD_DATA,3BCF REVDATA,4

BTFSC LCD_DATA,4BSF REVDATA,3BTFSS LCD_DATA,4BCF REVDATA,3

BTFSC LCD_DATA,5BSF REVDATA,2BTFSS LCD_DATA,5BCF REVDATA,2

BTFSC LCD_DATA,6BSF REVDATA,1BTFSS LCD_DATA,6BCF REVDATA,1

BTFSC LCD_DATA,7

Page 111: Intelligent Speed Adaptation

BSF REVDATA,0BTFSS LCD_DATA,7BCF REVDATA,0MOVWF PORTB ;LCD DATA COMMAND TO LCD

PINS BSF EN ;EN THE TRANSFERNOP NOPBCF ENNOP NOPRETLW H'00'

;;*****************************************************************************************************************************************************************

;LCD COMMAND SEND ROUTINE;*****************************************************************************************************************************************************************CMDWRT

BCF RS ;RS PULL TO LOWBCF RW ;RW PULL TO LOW

BTFSC LCD_CMD,0BSF REVDATA,7BTFSS LCD_CMD,0BCF REVDATA,7

BTFSC LCD_CMD,1BSF REVDATA,6BTFSS LCD_CMD,1BCF REVDATA,6

BTFSC LCD_CMD,2BSF REVDATA,5BTFSS LCD_CMD,2BCF REVDATA,5

BTFSC LCD_CMD,3BSF REVDATA,4BTFSS LCD_CMD,3BCF REVDATA,4

Page 112: Intelligent Speed Adaptation

BTFSC LCD_CMD,4BSF REVDATA,3BTFSS LCD_CMD,4BCF REVDATA,3

BTFSC LCD_CMD,5BSF REVDATA,2BTFSS LCD_CMD,5BCF REVDATA,2

BTFSC LCD_CMD,6BSF REVDATA,1BTFSS LCD_CMD,6BCF REVDATA,1

BTFSC LCD_CMD,7BSF REVDATA,0BTFSS LCD_CMD,7BCF REVDATA,0

MOVFW REVDATA ;LCD COMMAND TRANFER TO W MOVWF PORTB ;LCD DATA COMMAND TO LCD

PINS BSF EN ;EN THE TRANSFERNOP NOP BCF ENNOP NOPRETLW H'00'

;;*****************************************************************************************************************************************************************

;DATAREAD FRM LCD ROUTINE;*****************************************************************************************************************************************************************READBACK_LCD

BSF RSBSF RWBANK1

MOVLW H'FF'

Page 113: Intelligent Speed Adaptation

MOVWF TRISB ; MAKE ALL PINS INPUT TO RECIVE DATA

BANK0BSF ENNOP NOP BTFSC PORTB,0BSF REVDATA,7BTFSS PORTB,0BCF REVDATA,7

BTFSC PORTB,1BSF REVDATA,6BTFSS PORTB,1BCF REVDATA,6

BTFSC PORTB,2BSF REVDATA,5BTFSS PORTB,2BCF REVDATA,5

BTFSC PORTB,3BSF REVDATA,4BTFSS PORTB,3BCF REVDATA,4

BTFSC PORTB,4BSF REVDATA,3BTFSS PORTB,4BCF REVDATA,3

BTFSC PORTB,5BSF REVDATA,2BTFSS PORTB,5BCF REVDATA,2

BTFSC PORTB,6BSF REVDATA,1BTFSS PORTB,6BCF REVDATA,1

BTFSC PORTB,7

Page 114: Intelligent Speed Adaptation

BSF REVDATA,0BTFSS PORTB,7BCF REVDATA,0

MOVFW REVDATA ;LCD COMMAND TRANFER TO W MOVWF LCD_READBACKBCF ENNOP NOPBANK1

CLRF TRISB ; MAKE ALL PINS OUTPUT BANK0RETLW H'00'

;;*****************************************************************************************************************************************************************

;LCD BUSY CHECK ROUTINE;*****************************************************************************************************************************************************************

READYBCF PORTB,0BANK1BSF TRISB,0BANK0BCF RS ;FOR READING LCDBSF RW ;FOR READING LCDBCF ENNOP NOP BSF ENNOP NOPBTFSC PORTB,0GOTO READYBANK1BCF TRISB,0BANK0BCF RWRETURN

Page 115: Intelligent Speed Adaptation

;;*****************************************************************************************************************************************************************

;BINARY TO BCD CONVERION;*****************************************************************************************************************************************************************B2_BCD

BCF STATUS,0 ; clear the carry bitMOVLW .24MOVWF COUNTCLRF R0CLRF R1CLRF R2

LOOP16 RLF L_BYTE, FRLF M_BYTE , FRLF H_BYTE , FRLF R2, FRLF R1, FRLF R0, FDECFSZ COUNT, FGOTO ADJDEC RETLW 0

ADJDEC MOVLW R2MOVWF FSRCALL ADJBCDMOVLW R1MOVWF FSRCALL ADJBCDMOVLW R0MOVWF FSRCALL ADJBCDGOTO LOOP16

ADJBCD MOVLW 3ADDWF 0,WMOVWF TEMPBTFSC TEMP,3 ; test if result > 7MOVWF 0MOVLW 30ADDWF 0,WMOVWF TEMP

Page 116: Intelligent Speed Adaptation

BTFSC TEMP,7 ; test if result > 7MOVWF 0 ; save as MSDRETLW 0

;;*****************************************************************************************************************************************************************

;EEPROM ROUTINES;*****************************************************************************************************************************************************************EEPROM_WRITE

BANK2MOVWF EEDATAMOVFW EE_ADDBANK3BCF EECON1,EEPGDBSF EECON1,WRENBCF INTCON,GIEMOVLW H'55'MOVWF EECON2MOVLW H'AA'MOVWF EECON2BSF EECON1,WR BSF INTCON,GIEBANK0CALL DELAY255BANK3BTFSC EECON1,WRGOTO $-1BCF EECON1,WRENBANK0RETURN

EEPROM_READBANK2MOVWF EEADRBANK3BCF EECON1,EEPGDBSF EECON1,RDBANK2MOVFW EEDATABANK0MOVWF READBACKRETURN

Page 117: Intelligent Speed Adaptation

;;*****************************************************************************************************************************************************************

;LCD INTIALIZATION;*****************************************************************************************************************************************************************LCD_INITIALIZATION

CALL PR_DELAY ;30 MSEC START DELAY FOR LCD TO RISE POWER

CALL PR_DELAY ;30 MSEC START DELAY FOR LCD TO RISE POWER

MOVLW H'3B' ;FUNCTION SET[0,0,0,1(FOR LCD REQ.),1(DL, DATA LENGTH 8),1(N SET 2 LINES),1(F -FONT 5X10 DOTS,X,X)

CALL CMDWRTCALL DELAY255

MOVLW H'0C' ;LCD SETTING(0,0,0,0,1(ALWAYS),1(D,TO INCREMENT ADDRESS AUTO),1(C-ON THE CURSOR),1(BTO BLINK THE CURSOR))

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'01' ;LCD SETTING(0,0,0,0,1(ALWAYS),1(D,TO INCREMENT ADDRESS AUTO),1(C-ON THE CURSOR),1(BTO BLINK THE CURSOR))

MOVWF LCD_CMDCALL CMD_WRITE

MOVLW H'80' ;cursor HOME POSTION positon

MOVWF LCD_CMDCALL CMD_WRITERETURN

;;*****************************************************************************************************************************************************************

;PORTINTIALIZATION ROUTINE

Page 118: Intelligent Speed Adaptation

;*****************************************************************************************************************************************************************PORT_INTITIALIZE

BANK1 MOVLW B'11111000'

MOVWF TRISA CLRF TRISB

MOVLW B'10000001' ;C6 TX IS O/P AND ALL ARE INPUT

MOVWF TRISC ;TRANSFER TO PORTC DIRECTION REGISTER

MOVLW B'00000111'MOVWF ADCON1BANK0

CLRF PORTA CLRF PORTB

CLRF PORTC MOVLW B'11000000' ; TRANSFER THE DATA

FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO WMOVWF INTCON ; TRANSFER THE DATA

FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO INTERRUPT CONTROL REGISTER

RETURN;;*****************************************************************************************************************************************************************

;RS232 INTIALIZE ROUTINE;*****************************************************************************************************************************************************************RS232_RECIEVE_INITIALIZATION

CLRF STATUSMOVLW BAUD_CONSTANTBANK1MOVWF SPBRGMOVLW B'10100000'MOVWF TXSTABSF PIE1,RCIEMOVLW B'10010000'MOVWF RCSTAMOVLW H'01'MOVWF BYTE_COUNT

Page 119: Intelligent Speed Adaptation

MOVLW B'11000000'; TRANSFER THE DATA FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO W

MOVWF INTCON ; TRANSFER THE DATA FOR ENABLEING GENERAL AND PERIPHERAL INTERPPT TO INTERRUPT CONTROL REGISTER

RETURN

;;*****************************************************************************************************************************************************************

;PROGRAMABLE DELAY ROUTINE;*****************************************************************************************************************************************************************PR_DELAY

MOVWF PRCOUNTEROO1

CALL DELAY255DECFSZ PRCOUNTER,FGOTO OO1RETURN

;;*****************************************************************************************************************************************************************

;255 CYCLE DELAY ROUTINE;*****************************************************************************************************************************************************************DELAY255

DECFSZ COUNTER,FGOTO DELAY255RETURN

;;*****************************************************************************************************************************************************************

;25 USEC TIMER INTILIZATION ROUTINE;*****************************************************************************************************************************************************************TIMER1_INITIALIZATION

BTFSC TIMER_ON

Page 120: Intelligent Speed Adaptation

RETURNBSF TIMER_ONBANK1BCF PIE1,CCP1IE; ENABLE THE COMPARE MODE

FOR TIMER1BANK0MOVFW TLMOVFW THMOVWF CCPR1HBSF TIME_ERBANK1BSF PIE1,CCP1IE; ENABLE THE COMPARE MODE

FOR TIMER1BANK0BCF TIME_ERMOVLW B'00000101'; TRANSFER THE DATA FOR

ENABLEING TIMER1 CONTROL TO WMOVWF T1CON ; TRANSFER THE DATA FOR

ENABLEING TIMER1 CONTROL TO TIMER1 CONTROL REGMOVLW B'00001010'; TRANSFER THE DATA FOR

ENABLEING COMPARE MODE CONTROL TO WMOVWF CCP1CON ; TRANSFER THE DATA FOR

ENABLEING COMPARE MODE CONTROL TO COMPARE MODE CONTROL REG

CLRF TMR1L ; CLEAR LOW BYTE OF TIMER1CLRF TMR1H ; CLEAR HIGH BYTE OF TIMER1RETURN

;;*****************************************************************************************************************************************************************

;RAM CLEANING ROUNTINE;*****************************************************************************************************************************************************************CHECK_RAM1

MOVLW D'20' ;THIS IS FOR INITIAL POWER UP DELAY

MOVWF COUNT_REG1 ;TRANSFER TO COUNT_REG1 REGISTERCHECK_RAM2

CALL CHECK_RAM ;CALL SUBROUTINE FOR CHECKING THE RAM

CLRWDT ;CLEAR WATCHDOG TIMER

Page 121: Intelligent Speed Adaptation

DECFSZ COUNT_REG1,F ;DECREASE COUNT_REG1 AND AND CHECK IF ZERO THEN SKIP

GOTO CHECK_RAM2 ;GOTO CHECK_RAM2 LABEL

RETURN

CHECK_RAMCLRF STATUS ;GOTO BANK0MOVLW H'50' ;THIS IS FOR RAM

REGISTER COUNT TO BE CLEAREDMOVWF TMP_COUNT ;TRANSFER TO TMP_COUNT

REGISTERMOVLW H'70' ;THIS IS START RAM

REGISTER MOVWF FSR ;TRANSFER TO FSR

REGISTER FOR INDIRECT ADDRESSINGMOVLW H'FF' ;MAKE ALL BITS OF

THE REGISTER UNDER CONSIDERATION TO 1STEP1

MOVWF INDF ;TRANSFER TO FSR REGISTER DIRECTED REGISTER

DECF FSR,F ;DECREASE FSR FOR FOR NEXT REGISTER TO GO

DECFSZ TMP_COUNT,F ;DECREASE TMP_COUNT AND CHECH WHETHER ALL REGISTERED AS DESIRED MADE "FF"

GOTO STEP1 ;IF NOT GOTO 3 STEPS UP

MOVLW H'50' ;THIS IS FOR RAM REGISTER COUNT TO BE CLEARED

MOVWF TMP_COUNT ;TRANSFER TO TMP_COUNT REGISTER

MOVLW H'70' ;THIS IS START RAM REGISTER

MOVWF FSR ;TRANSFER TO FSR REGISTER FOR INDIRECT ADDRESSINGSTEP2

MOVLW H'FF' ;FEED ALL BITS OF W 1

XORWF INDF,F ;XOR WITH THE INDIRECTLY ADDRESSED REGISTER

BTFSS STATUS,Z ;SKIP IF ALL BITS IN W ARE ZERO

GOTO CHECK_RAM ;ELSE GOTO CHECK_RAM LABEL

Page 122: Intelligent Speed Adaptation

DECF FSR,F ;DECREASE FSR FOR FOR NEXT REGISTER TO GO

DECFSZ TMP_COUNT,F ;DECREASE TMP_COUNT AND CHECH WHETHER ALL REGISTERED AS DESIRED MADE "00"

GOTO STEP2 ;IF NOT GOTO 5 STEPS UP

RETURN ;RETURN FROM THE SUB ROUTINE

END

Page 123: Intelligent Speed Adaptation

15. PRECAUTIONS

1) Frist check all component as per the circuit.

2) Check transistor.

3) Pay proper attention to the polarity of capacitors and diodes while

assembling.

4) While mounting transistor be sure that you have connected collector,

emitter and base properly.

5) Clean PCB after soldering so those components do not short.

6) Remember the anode and cathode of diode before fitting.

7) Remember to check dry soldering and short circuit.

8) IC should be mounted on IC base.

9) Take care in wiring the circuit to avid loose connection.

10) Check for print short after soldering.

11) Please use resistance of the exact value as given in the circuit.

12) Check primary and secondary winding of the transformer before

connecting.

13) The insulation of the wire inside the modes should be of good quality.

Page 124: Intelligent Speed Adaptation

16. BIBLIOGRAPHY

BOOKS :

1. Electronic devices and circuit theory

2. Electronic projects.

3. Microelectronic circuits

4. Electronic for you.

WEBSITES :

1. www.efy.com

2. www.nationalsemiconductor.com

3. www.icdiscription.com

4. www.electrosofts.com