Escolar Documentos
Profissional Documentos
Cultura Documentos
INTRODUCTION
The project includes the development of the software and hardware for a Micro controller based tracking system based on the technique Dromography. Here dromos' means [way, street, route, corridor] + 'graphos' [to write], so Dromography is the study of geography and logistics of transportation, movement and communication routes. In this project we are adding digital dashboard which will display the speed, distance traveled, engine temperature, mileage and fuel level of the vehicle. All the parameters are displayed
Here the project comes under the embedded systems, which is the combination of software and hardware and perhaps some sensors, which are used to perform a specific tracing function. The project is done using Microchips Microcontroller PIC16F877. Micro controller programming is done using assembly language in Microchips integrated development environment MPLAB version 5.60.
The hardware part keeps on monitoring the speed and the direction of the vehicle. The hardware sends the data to computer via serial port and track is plotted with the help of interface software. Again the hardware section can be divided in to microcontroller, input unit, output unit, and the display unit .The software section have the microcontroller coding and the user interface window programming. Using Visual Basic language the window is developed. The route is traced on this window. Some additional push buttons such as SAVE, LOAD and CLEAR are also provided to perform some useful tasks.This project is very helpful to make a map to plot and retrace the route of a vehicle. And it takes care of displaying speed, distance, engine temperature, fuel level and mileage. This is very useful method for
Dept of ECE Maliankara 1 SNMIMT
town planning and road survey .Again these maps are also used to trace our position in the map. Being an independent gadget it works accurately with a high precision.
CHAPTER 1
SNMIMT
CHAPTER 2
The contrast between a Microprocessor and Microcontroller is best exemplified by the fact that most microprocessors have many opcodes for moving data from external memory to CPU; Microcontroller have one or two. Microprocessor may have one or two types of bit handling instructions; Microcontroller will have many. Microprocessors are concerned with rapid movement of code and data from external address to the chip. Microprocessor must have many additional parts to be optional. Micro controllers can function as a computer with addition of no external digital parts. Microprocessors are intended to be general-purpose digital computer where as Microcontroller are intended to be special purpose digital controllers. Microprocessors contain a CPU, memory, addressing circuits and interrupt handling data. Micro controllers have these features as well as timers, parallel and serial I\O, Internal RAM and ROM.
SNMIMT
Embedded system is any electronic equipment built in intelligence and dedicated software. All embedded systems use either a microprocessor or a microcontroller. The application of these micro controllers makes user-friendly cheaper solutions and enables to add features otherwise impossible to provide by other means. Embedded devices can be defined as any devices with a microprocessor or microcontroller embedded in it that has a relatively focused functionality. The software for the Embedded System is called firmware.
The firmware is written in Assembly language for time or resource critical operation or using higher-level languages like C or Embedded C. The software will be simultaneously micro code simulations for the largest processor. Since they are supported to perform only specific task, these programs are stored in Read Only Memories (ROMs). Moreover they may need no or minimal inputs from the user, hence the user interface like monitor, mouse & large keyboard etc. may be absent.Embedded system is also known as Real time Systems since they respond to an input or event and produce the result within the guaranteed time period. This time period can be a few microseconds to days or months.
The software program for real time system is written either in assembly or high-level language such as C. The assembly language is used in the case of some critical applications. Now days high-level languages replace most of the assembly language constructs.
Embedded technology is present in almost every electronic device we use today. There is embedded software inside the cellular phone, automobiles and thermostat in air conditioners, industrial control equipments and scientific & medical equipments, defense uses communication satellites etc. Embedded technology thus covers a broad range of products of which generalization is difficult.
The embedded intelligence can be found in five broad markets. The first is consumer segment, which includes home appliances and entertainment equipment. The second is automotive segment-where a modern car has nearly 50 micro controllers providing intelligence and control, like keyless entry, antilock braking and air bags. The third is office automation, which includes PCs, keyboards, machines. 2.4 ADVANTAGES OF EMBEDDED SYSTEM Higher Performance: The integration of various ICs shortens the copiers and printers. The fourth market, telecommunications, includes cellular phones, pagers and answering
traveling route and time of data to be transmitted resulting in higher performance. Lower Power Consumption: The integration of various ICs eliminates buffers and other interface circuits. As the number of components is reduced, less power will be consumed.
Dept of ECE Maliankara 5 SNMIMT
the chip is smaller in size and therefore occupies less space on the PCB. Hence products using embedded system are slimmer and more compact. Reduced design and development: The system on a chip provides all functionality required by the system. System designers need not worry about the basic function the system-right from the beginning of the basic phase, they can focus on the development features. As a result, the time spends on research and development is reduced and this in turn reduces the time to market of their products. Lower system costs: In the past, several chips in separate packages where required to configure a system. Now, just one system on-chip can replace all of these, dramatically reducing the packaging cost.There are many MCU manufacturers. To understand apply general concepts, it is necessary to study one type in detail. In our project, we use PIC series IC PIC16F873 from microchip.
CHAPTER 3
BLOCK DIAGRAM
SNMIMT
CHAPTER 4
BLOCK DESCRIPTION
A very simple logic is used to develop this device. The PIC we used here is 16F877A. Here the external interrupt is enabled for a high to low pulse and also initialized the ADC for the channel 0. The system is getting the analog voltage continuously from the high
Dept of ECE Maliankara 7 SNMIMT
precision potentiometer connected at the steering of the vehicle, and the ADC is kept continuously busy for converting the analog voltage from channel 0 in to hex equivalent. The system didnt use the hex value directly, but it uses some generated codes for the each specific range of hex values. These codes are transmitted for different steering positions. Serial port is used for transmissions. These codes are used to trace the route on the displaying device using the user interface window. The second transducer is an optical speed sensor which is connected at the wheel. This sensor keeps producing pulses on each rotation of the wheel, the pulses are sent to the RB0 pin as an external interrupt. On each external interrupt the ASCII code is produced with the help of the hex ADC value and is transmitted to MAX232 for serial communication. The mode of serial communication is asynchronous in nature. The transmitted codes are used to plot the map on the interface window. Here the switches are placed in order to mark the emergency destinations.
CHAPTER 5
HARDWARE DESCRIPTION
This is the section where sensing elements are used to sense various parameters for processing and keys to accept some instructions which are provided by the user. Here in this system mainly four sensors are used.
ROTATION SENSOR
An IR LED is placed somewhere in the wheel. In line with it, a photodiode is placed. As the wheel rotate, the IR LED cuts with the photodiode. This makes the photodiode to conduct. Thus every time when the IR LED cuts with photo diode current pulses occur at the output of the photo diode. These pulses are given to the 0-pin of PORTB (RB0). The interrupt register of PIC is configured in such a way that an interrupt is generated when a high to low transition takes place in RB0.
STEERING SENSOR
It is used to sense the steering position of the vehicle, which is a rotatory high precision potentiometer. The voltages provided by this are given to ADC of PIC16F877 microcontroller and ultimately the microcontroller will generate the codes for transmission. The transducer connected at the steering produces voltage which varies according to the rotation of the steering. For a specific angular position it produces a specific voltage level as output. The keys are the input medium to this device .Which are used to point out certain locations and our position on the ongoing way.
SNMIMT
TEMPERATURE SENSOR
A thermistor is used as the temperature sensor. It is a semiconducting device whose resistance varies with the absolute temperature. Also, it has a negative coefficient of resistance. That is, the resistance decreases as the temperature increases. Its resistance range is 100 to 100 K for a temperature range of 50 0Cto s s +150 0C. The thermistor used for temperature sensing gives current output, which is directly proportional to the absolute temperature variation. This temperature sensor works over a wide range of voltages starting from +4V to +40V, which adds to the versatility of its application in various temperature sensing circuits. Another feature of this device is that at any given temperature it acts as a constant current source (i.e. a source with infinite output impedance), which makes this sensor suitable for remote sensing. The temperature transducer can be used for temperature monitoring at far off places without a drop in signal level. For digital temperature display the current output of the transducer needs to be converted to suitable proportional voltage level. This is achieved by utilizing the resistor connected in series with thermistor will result in 1mV/ K drop across the resistor. This voltage drop is fed to the micro controller through analog input pin for further processing and display.
FUEL SENSOR
For fuel sensing we use a float. A float is a variable resistor, whose resistance varies with its arm position. The one end of arm is connected to the variable resistor and the other end is connected to a hollow cylinder, which is made of plastic. This will float over the floating surface. As the fuel level increases or decreases position of float also changes. The corresponding movement of arm is producing a variation in the variable resistor. This analog signal is given as the
Dept of ECE Maliankara 10 SNMIMT
input signal of PIC of the through its analog input. This analog C input is given into the ADC of the C to produce a digital signal. The digital signal is then converted into corresponding ASCII code for the LCD to display the output.
11
SNMIMT
The
system
is
controlled
by
the
PIC
microcontroller
PIC16F877A from microchip. This microcontroller is having a 10-bit ADC feature which is our prime requirement. This particular version of microcontroller is used because of its lower cost, easy availability and stability after several flash programming. PIC16F877 gets the voltage produced by the high precision potentiometer connected on the steering. Here the ADC gets the analog voltage on the channel 0 (RA0/AN0) PIN. The ADC produces the HEX output continuously according to the steering position. But we cant send the HEX codes as it is to the displaying unit. For that we are converting these codes to ASCII codes .The important thing to note here is that the steering is always changing the positions due to jerk or driving limitations. These deviations may also be traced on the displaying window .To avoid the tracing due to minor steering variation oversensitivity we are dividing the total steering movement in to 14 sectors of approximately 150 and for each sector an ASCII code is assigned. The total angular deviation of the steering is assigned as 1800 and the vehicle will move straightly when the steering is at 900. When the steering position is in a particular sector the assigned ASCII is being ready to send via serial port for displaying unit. As already said the single round of the wheel is detected by the optical sensor .which is generating a pulse on every rotation. Here on each pulse the steering position which is indicated by the ASCII value is send to the displaying unit, were according to these codes the tracing is performed. The keys are used to mark the places on the route and to find out the current position of the vehicle on the route map.
12
SNMIMT
Peripheral Features:
Dept of ECE Maliankara 13 SNMIMT
Low power, high speed CMOS FLASH technology Wide operating voltage range: 2.0V to 5.5V Industrial temperature
14
SNMIMT
15
SNMIMT
16
SNMIMT
PIC16F877A ARCHITECTURE
17
SNMIMT
MEMORY ORGANIZATIONS:
There are two memory blocks-program memory and data memory. Each block has its own bus, so that access to each block can occur during the same oscillator cycle. The data memory can further be broken down in to general purpose RAM and Special Function Registers (SFRs).
core functions. Banking requires the use of control bits for bank selection. These control bits are located in the status register.
To move values from one register to another register the value must pass through the working register (w). This means that for all register-to-register moves two instruction cycles are required. The entire data memory can be accessed either directly or indirectly. Direct addressing may require the use of RP0 and RP1 bits. Indirect addressing uses Indirect Register Pointer (IRP) bit if the STATUS registers for access in to Bank0/Bank1 or Bank2/Bank3 areas of data memory.
2k
2k
SFR
SFR
SFR
SFR
128
GPR GPR GPR GPR
BANK 0
BANK 1
BANK 2
BANK 3
REGISTERS:
Status register is used for checking status of working register. It is an 8-bit register. It is also used for bank selection.
STATUS REGISTER
Dept of ECE Maliankara 19 SNMIMT
IRP
RP1
RP0
T0
PD
DC
C/B
IRP: Register bank select bit is used for indirect addressing. 1: Bank 2, 3 0: Bank 0, 1 RP1: -Register pointer for group selection 1:Group2 0:Group1 RP0: -Register pointer for bank selection 1: Higher bank 0: Lower bank TO: -Time out bit 1: Watch dog timer set 0: Watch dog timer reset PD: -Power down bit 1: Normal mode of operation 0: System in low power mode Z: -Zero flag 1: Zero flag set 0: Zero flag clear DC: Digit carry C/B: Carry/Borrow
Dept of ECE Maliankara 20 SNMIMT
1: Carry 0: Borrow
21
SNMIMT
TRIS is data direction control register. TRIS register is used to configure port pins as input or output. Ports are in Bank 0 and corresponding TRIS are in Bank 1Setting TRIS register bit put corresponding output drive in high impedance mode. Clearing a bit in the TRIS register puts the content of the output latch on the selected pin. Microcontroller possess three internal timers-timer 0,timer 1 and timer 2.These timers are in Bank 0 and their control registers are in Bank 1.Timer 0 is 8 bit, timer 1 is 16 bit and timer 2 is 8 bit. OPTION register is the control register for timer 0.It is an 8-bit register. T1CON and T2CON are the control registers of timer 1 and timer 2 respectively.
RBP U 7 1
INTED G 0
TOCS 6
TOSE 5
PSA 4
PS2
PS1 3
PS0 2
PSA: -Pre scalar alignment 1: Applicable for watch dog timer 0: Applicable for timer PS2 PS1 PS0: - Pre scalar value assignment bits
0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1
Delay of the timer is calculated using the formula Delay = 1/(fosc/4) x pre scalar value x (255-x) Fosc: 4MHz X: value loaded to the timer ADC inside the microcontroller converts the analog value to
corresponding 8-bit digital value. ADCON0 and ADCON1 are the control registers for ADC.ADCON0 is in Bank 0 and ADCON1 is in Bank 1.ADRES which is in bank 0 is the result register. ADC uses PORT B as the channel. Both ADCON0 and ADCON1 are 8 bit registers. But ADRES is a 16-bit register.
ADC ADCS0 S1 7 1 0 6
CHS2
CHS1 5
CHS0
GO/DO NE 4 3
ADO N 2
Fig: ADCON0
Dept of ECE Maliankara 23 SNMIMT
ADCS1 ADCS0: -Analog to digital conversion clock select bits. 0 0: fosc/2 0 1: fosc/8 1 0: fosc/32 1 1: FRC CHS2 CHS1 CHS0: -Analog channel select bit 0 0 0: RA0 0 0 1: RA1 0 1 0: RA2 0 1 1: RA3 1 0 0: RA4 1 0 1: RA5 GO/DONE: -Analog to digital conversion status bit 1: Start/progress 0: Done ADON: -ADC module ON bit 1: ON 0: OFF 7 1 ADF M 0 PCFG 3 PCFG PCFG 2 1 CFG 0 6 5 4 3 2
Fig: ADCON1 ADFM: -AD result format select bit 1: ADRESH 000000xx ADRESL xxxxxxxx 0: ADRESH xxxxxxxx ADRESL xx000000
Dept of ECE Maliankara 24 SNMIMT
CSR C 7 1
TX9
TXEN 6 0
SYNC 5
BRGH 4
TRMT 3
TX9 D 2
Fig: TXSTA
CSRC: -It is clock source select bit. It is used in synchronous. TX9: -Transmission bit select. 1: It will send 9 bit data i.e. 8bit + 1 parity. 0: It will send 8 bit. TXEN: -Transmission enable. 1: Enable. 0: Disable. SYNC: -Mode select bit. 1: synchronous 0: asynchronous BRGH: -Baud rate high speed select. 1: high speed [fosc/16(x+1)]. 0: low speed [fosc/64(x+1)]. TMRT: -Transmit shift register status bit. 1: TSR empty. 0: TSR full. TX9D:- It is the parity used in 9 bit transmission.
Dept of ECE Maliankara 25 SNMIMT
SPEN RX9 7 1 0 6
SREN
CREN 5
FERR
OFRR 3
RX9 D 2
SPEN: -Serial port enable bit. RX9: -Reception bit select. 1: It will receive 9 bit data i.e. 8bit + 1 parity. 0: It will receive 8 bit. SREN: - Single reception enable. It is not used in asynchronous. CREN: -Continuous receive enable. It is mainly used in asynchronous. ADDEN: -Address detect enable. Not commonly used. FERR: -Faming error. Not commonly used. RX9D:- It is the 9 bit of received data.
GIE 7 1
PEIE E 6 0
TOI E
INT E 5
RBI F 4
TOI
INTF F 3
RBI 2
Fig: INTCON
Dept of ECE Maliankara 26 SNMIMT
GIE: -Global interrupt enable bit. 1: Enables all unmarked interrupts. 0: Disable all interrupt.
27
SNMIMT
PEIE: -Peripheral interrupt enable bit. 1: It will send 9 bit data i.e. 8bit + 1 parity. 0: It will send 8 bit. TOIE: -TIMER 0 enable. 1: Enable. 0: Disable. INTE: -INTERRUPT ENABLE 1: Enable. 0: Disable. RBIE: -RB0 INT ENABLE 1: Enable. 0: Disable. INTF: -INT TIMER FLAG 1: Enable. 0: Disable. RBIF:- RB0 INT FLAG 1: Enable. 0: Disable.
INPUT/OUTPUT PORTS:
Input/Output ports allow the PIC microcontroller to monitor and control other devices. To add flexibility and functionality to a device, some pins are multiplexed with alternate functions. These functions depend on which peripheral features are on the device. In general when a pin is functioning, that pin may not be used as a general-purpose I/O pin.
28
SNMIMT
For most ports I/O the data direction register called TRIS register controls pins directions. The TRIS<x> controls the direction of PORT <x> .A 1 in the TRIS bit corresponds to that pin being an input while a 0 corresponds to that pin being an output. The PORT register is the latch for the data to be output. When the PORT is read, the device reads the level present on the I/O pin.
INSTRUCTION SET:
There are 35 instructions. All operations are instructions can be classified in to three categories. Byte oriented instructions Bit oriented instructions Literal and control instructions through the
XORWF-Exclusive ORing of content of working register with file register RLF-Rotate left with carry RRF-Rotate right with carry DECF-Decrement the content of file register DECFSZ-Decrement the content of file register and skip the next instruction if zero INCF-Increment file register content
INCFSZ-Increment the content of file register and skip the next instruction if zero COMF-Ones complement SWAPF-Interchange the nibbles NOP-No operations
30
SNMIMT
check
the
data
transfer
using
the
windows
utility
called
HyperTerminal.
CHAPTER 6
CIRCUIT DIAGRAM
32
SNMIMT
CHAPTER 7
CIRCUIT DESCRIPTION
Here the clock source for this microcontroller is 4MHz.The MCLR/VPP is connected to the Vcc always because here no reset
Dept of ECE Maliankara 33 SNMIMT
feature is used. The on chip 10-Bit ADC is used to convert the analog voltage into the HEX value the result is 8-Bit in length. The voltage is applied to the channel 0 (RA0/AN0) of the PIC16f877.The external interrupt is provided by the clock pulse generated by the optical sensor connected at the RB0/INT pin. The input keys are used to send some messages to the microcontroller. The keys are connected to the 4, 5, 6and 7th pin of the PORT D .The program is always scanning the keys ,when a particular key is pressed the PORT pin get a high voltage and when this event happens the particular task will be performed. The communication between the device and the display unit is a serial mode of communication. Since RS232 is not compatible with the PIC here we are using MAX 232 to convert the TTL of the Microcontroller to RS232 voltage levels and vice versa. It uses a +5v power source which is the same as the source voltage for the PIC. Any invention of latest technology cannot be activated without the source of power. All the electronic components starting from diode to ICs only work with a DC supply ranging from +/-5v to +/-12v. The regulation is usually obtained using an IC voltage regulator unit, which takes a DC voltage and provides a somewhat lower DC voltage, which remains the same even if the input DC voltage varies or the output load connected to the DC voltage changes. There are extra 3 LEDs used in the circuit any future used such as low level indication, increased speed indication etc. Here we are connected fuel sensor to channel 1 which is a float sensor. It is a variable resistor whose resistance varies with its arm. One end of arm is connected to a hollow cylinder (plastic). Movement of float produces a corresponding movement in variable resistor. This output voltage is fed to microprocessor through analog input pin for further processing and display.
34
SNMIMT
Also we are connected a thermistor as a temperature sensor as it is connected to channel 2. Thermistor is a semiconducting device varies with absolute temperature. The resistance range is 100 ohm to 100 kilo ohm for the temperature range of -50 deg. to +150 deg Celsius. Temperature sensor we are using will give output current proportional to absolute temperature variation. For digital display output current is converted into suitable proportional voltage by connecting a series resistor connected with thermistor will result in 1mV/K drop across resistor. This voltage drop is fed to microcontroller through analog input pin for further processing and display. The rotation sensor we used is an opto coupler. It contains one IR LED for producing IR rays and it also contains one photodiode which will get triggered when the IR rays falls on the base of the phototransistor. This sensor is placed anywhere in the wheel and as the wheel rotates it will cuts the IR ray send from IR LED and this produces a pulse occurring at the collector output of phototransistor. These pulses are given to RB0 pin of PIC which is the interrupt enable bit. The interrupt register of PIC is so configured that, an interrupt is generated when a high to low transition takes place in RB0. The series 78 regulators provide fixed regulated voltages from 5 to 24v.Figure shows how one such IC, a LM 317 is connected to provide voltage
35
SNMIMT
CHAPTER 8
VB FRONTEND
36
SNMIMT
CHAPTER 9
37
SNMIMT
CHAPTER 10
PCB LAYOUT
CHAPTER 11
Dept of ECE Maliankara 38 SNMIMT
PCB FABRICATION
PRINTED CIRCUIT BOARD
ARES (Advanced Routing and Editing Software) forms the PCB lay out module of the PROTEUS system and offers net listed based PCB design complete with a suite of high performance design automation tools. The latest version is compatible with Windows 998/Me/2k/XP and later. It includes a brand new Auto-placer, improved auto-placing, automatic gate swap optimization and even more support for power plans
PCB FABRICATION
The various steps involved in the preparation of PCB are explained below: 1) PCB fabrication. 2) Soldering of components. 1) PCB fabrication. Materials required: Copper clad sheet, paint, ferric chloride solution, drilling machine. The steps involved in making PCB: a) Preparation of the lay out of the track: The track lay out of the circuit is drawn using pcb designing software. The layout should be made in such a way that the parts are in easy roots which will be done automatically by the use of the software. This enables PCB more economical and compact. The softwares commonly used are Or CAD, Proteus, PCB express etc. b) Transferring of layout to the copper clad: Plain, copper clad PC board can be purchased from many different retailers. If necessary, cut down the board to the approximate size. A table saw with a diamond blade or a shear are the best choices. In any case, be sure to wear googles and a breathing mask. Always clean the board with
Dept of ECE Maliankara 39 SNMIMT
water (perhaps some cleaning solution) and a scouring pad. The scrubbing removes grime and oxidation, thus preparing the surface for a crisp transfer and ultimately firm soldering. After drying the copper board, place the blue transfer paper with the image or toner side against the copper. Carefully position the image the clinging of the plastics to the clean copper helps. c) Etching: Ferric chloride solution is popularly used as the etching solution. The ferric chloride powder is made in to a solution using water and kept in a plastic tray. Now carefully immerse the marked copper clad sheet in the solution for a period of 1-2 hours. Due to reaction the solution becomes weak and it cant be used for further etching process. The copper in the unmarked area will be etched out. Take out the etched sheet from the tray containing the solution and wash it in clean water and dry out in sunlight for an hour. Later remove the paint over the tracks using turpentine. d)Drilling: The holes are made in the etched out copper clad sheet using a drilling machine with drill bits of size 0.5mm, 0.6mm, 0.9mm etc are depending on the leads of the components used in the circuit
SOLDERING OF COMPONENTS
Soldering is the process of joining two or dissimilar metals by melting another metal having low melting point. In order to make the surfaces accept the soldering readily the component terminals should be oxides and other obstructing films. Soldering flux cleans the oxides from the surfaces of the metal; the lead should be cleaned chemically or by scrapping using a blade or knife. Small amount of lead should be coated on the cleaned position of leads and the bits of soldering iron. This process is called tinning. Zinc chloride, ammonium chloride, rosin are commonly used fluxes. The solder is used for joining two metals at temperature below the melting point
Dept of ECE Maliankara 40 SNMIMT
.The popularly used alloys of tin and lead that melts at375degree F and solidifies when it cools. The most of the solder wires are flux core type. Soldering iron is the tool used to melt the solder and apply at the joint of the circuit. It operates at 230v main supply. The power ratings of the soldering iron are 10W, 25W, 35W, 65W, 125W. CHAPTER 12
SOFTWARE
In the software section two types of programming languages are considered. The first one is the assembly coding of the PIC microcontroller. A total of 35 instructions are used to code controller IC. The coding is performed on a MPLAB simulator version 5.60.00. The codes are programmed to the PIC microcontroller version PIC16F877 using a flash PIC programmer and a PIC ISP software. The source code for PIC16F877 is given in APPENDIX. 12.1 FLOWCHART (PROGRAM)
41
SNMIMT
42
SNMIMT
43
SNMIMT
44
SNMIMT
45
SNMIMT
46
SNMIMT
12.3 PROGRAM
LIST P=PIC16F877A #INCLUDE "P16F877A.INC" CBLOCK 0X20 HEXDATA DEC1 DEC2 DEC3 R3 R1 R0 ASCI0 ASCI1 ASCI2 ASCI3 ASCI4 DR1 DR2 DR3 COUNTER DIS1 DIS2 DIS3 DIS4 DIS5 SPEED DATAO DATAI NUM ADDRE TEMP VAL1,VAL2,VAL3,VAL4,VAL5 TEM,FUEL,CNT
Dept of ECE Maliankara 47 SNMIMT
R4,R5,R6 MIF MIF1 MIL SPEED1 ENDC LINIT MACRO INIT MOVLW INIT MOVWF DR1 BCF DR2,3 CALL SUB ENDM LCHAR MACRO CHAR MOVLW CHAR MOVWF DR1 BSF DR2,3 CALL SUB ENDM LINT MACRO INT MOVF INT,0 MOVWF DR1 BSF DR2,3 CALL SUB ENDM ORG 0 GOTO FIRST ORG 4 MOVWF TEMP GOTO INTR ADC1 CLRF DEC1 CLRF DEC2 CLRF DEC3 CLRF R3 MOVF HEXDATA,0 MOVWF R3 MOVLW D'100' INCF DEC1,1 SUBWF R3,1 ;LCD INIT MACRO
48
SNMIMT
BTFSC STATUS,0 GOTO $-3 DECF DEC1,1 ADDWF R3,1 MOVLW D'10' INCF DEC2,1 SUBWF R3,1 BTFSC STATUS,0 GOTO $-3 DECF DEC2,1 ADDWF R3,0 MOVWF DEC3 MOVLW 0X30 ADDWF DEC1,0 MOVWF ASCI1 MOVLW 0X30 ADDWF DEC2,0 MOVWF ASCI2 MOVLW 0X30 ADDWF DEC3,0 MOVWF ASCI3 RETURN FUNSET MOVLW B'00110000' MOVWF PORTB BSF PORTB,1 NOP NOP NOP BCF PORTB,1 RETURN SUB BCF STATUS,6 BSF STATUS,5 MOVLW B'11110001' MOVWF TRISB BCF STATUS,6 BCF STATUS,5 BSF PORTB,3 NOP NOP NOP BSF PORTB,1 ;FUNCTION SET FOR LCD
49
SNMIMT
NOP NOP NOP BTFSC PORTB,7 GOTO $-1 BCF STATUS,6 BSF STATUS,5 MOVLW B'00000001' MOVWF TRISB BCF STATUS,6 BCF STATUS,5 CLRF PORTB MOVLW 0XF0 ANDWF DR1,0 MOVWF PORTB BTFSC DR2,3 BSF PORTB,2 NOP NOP NEXT3 BSF PORTB,1 NOP NOP NOP BCF PORTB,1 SWAPF DR1,1 MOVLW 0XF0 ANDWF DR1,0 MOVWF PORTB BTFSC DR2,3 BSF PORTB,2 NOP NOP NEXT2 BSF PORTB,1 NOP NOP NOP BCF PORTB,1 CLRF DR2 BCF PORTB,2 RETURN DELAY BCF STATUS,5 BCF STATUS,6 MOVLW 0XEB MOVWF TMR0
;5M DELAY
50
SNMIMT
MOVF TMR0,0 BTFSS STATUS,2 GOTO $-2 NOP RETURN DELAY2 BCF STATUS,5 BCF STATUS,6 MOVLW D'254' MOVWF TMR0 MOVF TMR0,0 BTFSS STATUS,2 GOTO $-2 NOP RETURN TRANS: bcf STATUS,RP0 bcf STATUS,RP1 btfss PIR1,TXIF goto $-1 movf R0,0 movwf TXREG RETURN INTR BTFSS INTCON,1 RETFIE BCF INTCON,1 INCF SPEED,1 INCF SPEED1,1 INCF DIS5,1 MOVLW D'10' SUBWF DIS5,0 BTFSS STATUS,2 GOTO RET CLRF DIS5 INCF DIS4,1 MOVLW D'10' SUBWF DIS4,0 BTFSS STATUS,2 GOTO RET ;20uS DELAY
51
SNMIMT
CLRF DIS5 CLRF DIS4 INCF DIS3,1 MOVLW D'10' SUBWF DIS3,0 BTFSS STATUS,2 GOTO RET CLRF DIS5 CLRF DIS4 CLRF DIS3 INCF DIS2,1 MOVLW D'10' SUBWF DIS2,0 BTFSS STATUS,2 GOTO RET CLRF DIS5 CLRF DIS4 CLRF DIS3 CLRF DIS2 INCF DIS1,1 MOVLW D'10' SUBWF DIS1,0 BTFSS STATUS,2 GOTO RET CLRF CLRF CLRF CLRF CLRF DIS5 DIS4 DIS3 DIS2 DIS5
RET NOP MOVF R6,0 MOVWF R0 CALL TRANS MOVF TEMP,0 BCF INTCON,1 RETFIE FIRST CLRF DIS1 CLRF DIS2 CLRF DIS3 CLRF DIS4 CLRF DIS5
Dept of ECE Maliankara 52 SNMIMT
CLRF SPEED CLRF CLRF CLRF CLRF CLRF CLRF CLRF CLRF CLRF VAL1 VAL2 VAL3 VAL4 VAL5 PORTA PORTB PORTC PORTE
MOVLW B'11010000' MOVWF INTCON MOVLW 0X04 MOVWF DR3 DISPLAY BCF STATUS,6 BSF STATUS,5 MOVLW 0X00 MOVWF ADCON1 MOVLW B'10000111' MOVWF OPTION_REG MOVLW B'00000001' MOVWF TRISB BSF TRISD,0 BSF TRISD,1 BSF TRISD,2 BSF TRISD,3 BCF TRISC,2 BCF STATUS,6 BCF STATUS,5 CALL DELAY CALL DELAY CALL DELAY CALL FUNSET CALL DELAY CALL FUNSET MOVLW D'75' MOVWF COUNTER DECFSZ COUNTER,1 ;LCD ROUTINE
53
SNMIMT
GOTO $-1 CALL FUNSET LINIT 0X21 LINIT 0X0C LINIT 0X06 LINIT 0X02 LINIT 0X01 DECFSZ DR3,1 GOTO DISPLAY BCF STATUS,6 BSF STATUS,5 BSF TRISC,7 BCF TRISC,6 MOVLW 0X24 MOVWF TXSTA MOVLW D'25' MOVWF SPBRG BCF STATUS,6 BCF STATUS,5 CLRF PORTC MOVLW 0X80 MOVWF RCSTA LINIT 0X01 LINIT 0X80 LCHAR'D' LCHAR'R' LCHAR'O' LCHAR'M' LCHAR'O' LCHAR'G' LCHAR'R' LCHAR'A' LCHAR'P' LCHAR'H' LCHAR'Y' LINIT 0XC0 LCHAR's' LCHAR'm' LCHAR'a' LCHAR'r' LCHAR't' LCHAR' '
54
SNMIMT
LCHAR'v' LCHAR'e' LCHAR'h' LCHAR'i' LCHAR'c' LCHAR'l' LCHAR'e' CALL DEL1 START CALL SWITCH CALL STEER NOP DSP BCF STATUS,6 BSF STATUS,5 MOVLW 0X00 MOVWF ADCON1 MOVLW B'10000111' MOVWF OPTION_REG MOVLW B'11111111' MOVWF TRISA BCF STATUS,6 BCF STATUS,5 MOVLW B'10000001' MOVWF ADCON0 CALL DELAY2 BSF ADCON0,2 BTFSC ADCON0,2 GOTO $-1 MOVF ADRESH,0 MOVWF FUEL MOVWF MIF CLRF SPEED1 CLRF CNT MOVLW 0X02 INCF CNT,1 SUBWF FUEL,1 BTFSC STATUS,0 GOTO $-3 DECF CNT,1
55
SNMIMT
MOVF CNT,0 SUBLW D'100' BTFSC STATUS,0 GOTO LOP MOVLW D'100' MOVWF CNT LOP MOVF CNT,0 MOVWF HEXDATA CALL ADC1 DISP1 NOP LINIT 0X01 LINIT 0X80 LCHAR'F' LCHAR'U' LCHAR'E' LCHAR'L' LCHAR' ' LCHAR'L' LCHAR'E' LCHAR'V' LCHAR'E' LCHAR'L' LCHAR' ' LINT ASCI1 LINT ASCI2 LINT ASCI3 LCHAR'%' CALL DEL1 CALL SWITCH CALL STEER CALL DEL1 DISP2 MOVLW B'10010001' MOVWF ADCON0 CALL DELAY2 BSF ADCON0,2 BTFSC ADCON0,2 GOTO $-1 MOVF ADRESH,0 MOVWF TEM MOVLW D'113'
56
SNMIMT
SUBWF TEM,1 MOVF TEM,0 MOVWF HEXDATA CALL ADC1 LINIT 0X01 LINIT 0X80 LCHAR'T' LCHAR'E' LCHAR'M' LCHAR'P' LCHAR'E' LCHAR'R' LCHAR'A' LCHAR'T' LCHAR'U' LCHAR'R' LCHAR'E' LINIT 0XC5 LINT ASCI1 LINT ASCI2 LINT ASCI3 LCHAR' ' LCHAR' ' LCHAR'c' CALL DEL1 CALL SWITCH CALL STEER CALL DEL1 DISP3 MOVLW 0X30 ADDWF DIS5,0 MOVWF ASCI4 MOVLW 0X30 ADDWF DIS4,0 MOVWF ASCI3 MOVLW 0X30 ADDWF DIS3,0 MOVWF ASCI2 MOVLW 0X30 ADDWF DIS2,0 MOVWF ASCI1 MOVLW 0X30
57
SNMIMT
ADDWF DIS1,0 MOVWF ASCI0 LINIT 0X01 LINIT 0X80 LCHAR'D' LCHAR'I' LCHAR'S' LCHAR'T' LCHAR'A' LCHAR'N' LCHAR'C' LCHAR'E' LINIT 0XC0 LINT ASCI0 LINT ASCI1 LINT ASCI2 LINT ASCI3 LINT ASCI4 LCHAR' ' LCHAR' ' LCHAR'm' CALL DEL1 CALL SWITCH CALL STEER CLRF SPEED CALL DEL1 MOVF SPEED,0 MOVWF HEXDATA CALL ADC1 LINIT 0X01 LINIT 0X80 LCHAR'S' LCHAR'P' LCHAR'E' LCHAR'E' LCHAR'D' LCHAR' ' LINT ASCI1 LINT ASCI2 LINT ASCI3 LCHAR' ' LCHAR' '
58
SNMIMT
LCHAR'm' LCHAR'/' LCHAR's' CALL CALL CALL CALL DEL1 SWITCH STEER DEL1
MOVLW B'10000001' MOVWF ADCON0 CALL DELAY2 BSF ADCON0,2 BTFSC ADCON0,2 GOTO $-1 MOVF ADRESH,0 MOVWF MIF1 MOVF MIF1,0 SUBWF MIF,0 BTFSS STATUS,0 GOTO START BTFSC STATUS,2 GOTO START MOVWF MIF CLRF MIL MOVF MIF,0 INCF MIL,1 SUBWF SPEED1,1 BTFSC STATUS,0 GOTO $-3 DECF MIL,1 MOVF MIL,0 MOVWF HEXDATA CALL ADC1 LINIT 0X01 LINIT 0X80 LCHAR'M' LCHAR'I' LCHAR'L' LCHAR'E' LCHAR'A'
59
SNMIMT
LCHAR'G' LCHAR'E' LCHAR' ' LINT ASCI1 LINT ASCI2 LINT ASCI3 CALL DEL1 CALL SWITCH CALL STEER CALL DEL1 GOTO START STEER MOVLW B'10001001' MOVWF ADCON0 CALL DELAY2 BSF ADCON0,2 BTFSC ADCON0,2 GOTO $-1 MOVF ADRESH,0 MOVWF R4 MOVLW D'20' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO A1 MOVLW D'40' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO B1 MOVLW D'60' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO C1 MOVLW D'80' MOVWF R5 MOVF R4,0 SUBWF R5,0
60
SNMIMT
BTFSC STATUS,0 GOTO D1 MOVLW D'100' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO E1 MOVLW D'120' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO F1 MOVLW D'140' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO G1 MOVLW D'160' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO H1 MOVLW D'180' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO I1 MOVLW D'200' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO J1
61
SNMIMT
MOVLW D'220' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO K1 MOVLW D'240' MOVWF R5 MOVF R4,0 SUBWF R5,0 BTFSC STATUS,0 GOTO L1 GOTO M1 A1 MOVLW 'A' MOVWF R6 GOTO LAST B1 MOVLW 'B' MOVWF R6 GOTO LAST C1 MOVLW 'C' MOVWF R6 GOTO LAST D1 MOVLW 'D' MOVWF R6 GOTO LAST E1 MOVLW 'E' MOVWF R6 GOTO LAST F1 MOVLW 'F' MOVWF R6 GOTO LAST G1 MOVLW 'G' MOVWF R6 GOTO LAST H1 MOVLW 'H' MOVWF R6
62
SNMIMT
GOTO LAST I1 MOVLW 'I' MOVWF R6 GOTO LAST J1 MOVLW 'J' MOVWF R6 GOTO LAST K1 MOVLW 'K' MOVWF R6 GOTO LAST L1 MOVLW 'L' MOVWF R6 GOTO LAST M1 MOVLW 'M' MOVWF R6 GOTO LAST LAST NOP RETURN DEL65 MOVLW D'1' MOVWF NUM FSS MOVLW D'1' MOVWF TMR0 MOVF TMR0,0 BTFSS STATUS,2 GOTO $-2 DECFSZ NUM,1 GOTO FSS NOP RETURN DEL150 MOVLW D'150' MOVWF R1 NOP DECFSZ R1,1 GOTO $-2 RETURN DEL1 MOVLW D'10'
63
SNMIMT
MOVWF R1 MOVLW 0X01 MOVWF TMR0 MOVF TMR0,0 BTFSS STATUS,2 GOTO $-2 DECFSZ R1,1 GOTO $-6 NOP RETURN SWITCH BTFSC PORTD,4 CALL HOS BTFSC PORTD,5 CALL HOT BTFSC PORTD,6 CALL JUN BTFSC PORTD,7 CALL PET NOP RETURN HOS BTFSS PORTD,4 GOTO $-1 MOVLW '+' MOVWF R0 CALL TRANS NOP RETURN HOT BTFSS PORTD,5 GOTO $-1 MOVLW 'T' MOVWF R0 CALL TRANS NOP RETURN JUN BTFSS PORTD,6 GOTO $-1 MOVLW 'X' MOVWF R0 CALL TRANS NOP RETURN
64
SNMIMT
PET BTFSS PORTD,7 GOTO $-1 MOVLW 'P' MOVWF R0 CALL TRANS NOP RETURN END ;----------------------------------------------------;FUEL LEVEL --RA0 ;TEMPERATURE --RA1 ;SPPED IR --RB0 ;LCD --PORTB ;-----------------------------------------------------
65
SNMIMT
66
SNMIMT
DoEvents
68
SNMIMT
Wend MSComm1.PortOpen = False End Sub Private Sub stop_Click() running = 0 'stops running End Sub Private Sub form_load() MSComm1.CommPort = 1 'set initial port settings MSComm1.Settings = "9600,N,8,1" MSComm1.InBufferSize = 1 xmove = 0 'initial scrolling is 0 ymove = 0 End Sub Private Sub plot() Dim deg As Double ' the degree of rotation Dim plotData As String 'char to plot Dim xdiff, ydiff As Integer 'temp variable to calculate the new position i = 1 'initialise counter canvas.Cls 'clears canvas x1 = XSIZE / 2 + xmove 'setting initial position y1 = YSIZE / 2 + STEP + ymove x2 = XSIZE / 2 + xmove y2 = YSIZE / 2 + ymove While True ' infinite loop plotData = Mid(dataDelay, i, 1) 'takes each bit to plot If IsNull(plotData) Or IsEmpty(plotData) Or plotData = "" Then Exit Sub ' breaks when data finishes i=i+1 Select Case plotData ' plotting of the movements Case "A"
69
SNMIMT
deg = -75 '75d left Case "B" deg = -60 '60d left Case "C" deg = -45 '45d left Case "D" deg = -30 '30d left Case "E" deg = -15 '15d left Case "F" deg = -5 '5d left Case "G" deg = 0 Case "H" deg = 5 Case "I" deg = 15 '15d right Case "J" deg = 30 '30d right Case "K" deg = 45 '45d right Case "L" deg = 60 '60d right Case "M" deg = 75 '75d right Case Else GoTo MARK 'going to mark locations End Select xdiff = x2 - x1 'keys for translation ydiff = y2 - y1 x1 = x1 + xdiff 'translation of line y1 = y1 + ydiff
Dept of ECE Maliankara 70 SNMIMT
x2 = x2 + xdiff y2 = y2 + ydiff deg = (deg / 180) * 3.14 'convertion to radians x3 = x2 * Cos(deg) - y2 * Sin(deg) - x1 * Cos(deg) + y1 * Sin(deg) + x1 'rotaion y3 = x2 * Sin(deg) + y2 * Cos(deg) - x1 * Sin(deg) - y1 * Cos(deg) + y1 'x3 = (x2 - x1) * Cos(deg) - (y2 - y1) * Sin(deg) + x1 'y3 = (x2 - x1) * Sin(deg) + (y2 - y1) * Cos(deg) + y1 x2 = x3 y2 = y3 If x1 >= 0 And y1 >= 0 And x2 >= 0 And y2 >= 0 Then canvas.Line (x1, y1)-(x2, y2) GoTo REPEAT ' skipping the following part MARK: Dim location As String 'plotting different locations on map Select Case plotData Case "+" location = "Hospital" Case "P" location = "Petrol Bunk" Case "T" location = "Hotel" Case "X" location = "Junction" Case Else GoTo REPEAT ' invalid data input End Select canvas.CurrentX = x2 ' locating the point and printing data canvas.CurrentY = y2 canvas.Circle (x2, y2), 10 canvas.Circle (x2, y2), 20 canvas.Circle (x2, y2), 30
Dept of ECE Maliankara 71 SNMIMT
canvas.Print (location) REPEAT: Wend End Sub Private Sub HS_Change() 'scrolling xmove = HS.Value * -1 ' 'set motion in opposite of scrolling plot End Sub Private Sub VS_Change() ymove = VS.Value * -1 plot End Sub Private Sub load_Click() On Error GoTo LoadEnd dlgOpen.ShowOpen 'loads a pre saved file Open dlgOpen.FileName For Input As #1 Line Input #1, dataDelay Close #1 plot LoadEnd: End Sub Private Sub save_Click() On Error Resume Next dlgOpen.ShowSave 'save the current file Open dlgOpen.FileName For Output As #1 If dlgOpen.FileName = "" Then Exit Sub Print #1, dataDelay MsgBox "File saved..."
72
SNMIMT
The plotting is done according to the following data in the table below: ANGLE FROM THE REFERENCE POSITION 750 600 450 300 150 50 00 50 150 300 450 600 750 DIRECTIN FROM THE REFERENCE POSITION left left left left left left Straight right right right right right right
CODE SEND A B C D E F G H I J K L M
TO
73
SNMIMT
Also marking of locations using keys are made according to the data in the below table: PLACE TO MARK Hospital Petrol pump Here ( Present location) Junction CODE TO SEND + P T X
The software continuously checks the port for the availability of any data. When ever a data is available it will plot or locate on a picture box with name canvas. The plotting starts from the centre of the canvas with the assumption that the vehicle is parked in the vertically upward direction. The ports are initialized at the loading of the program. The plotting is done with the help of two 2D graphics transformations- Translation and rotation. Translation: The currently available line is translated in the forward direction of the vehicles path. Initially it is assumed that the vehicle is traveling through the vertical path upward. xdiff = x2 - x1 'keys for translation ydiff = y2 - y1 x1 = x1 + xdiff 'translation of line y1 = y1 + ydiff x2 = x2 + xdiff y2 = y2 + ydiff Rotation: The translated line is rotated with the degree measure obtained as data from the circuit. This is done in three steps. Translation to the origin and rotated and then translated back.
74
SNMIMT
x3 = x2 * Cos(deg) - y2 * Sin(deg) - x1 * Cos(deg) + y1 * Sin(deg) + x1 y3 = x2 * Sin(deg) + y2 * Cos(deg) - x1 * Sin(deg) - y1 * Cos(deg) + y1 Now this available new line is plotted as the representation of the received data. On the reception of a signal to locate corresponding text is decided and marked at the current position. Also some small circles are drawn in order to indicate it.
Actions of different buttons: i. Start: Starts the process of reading data from the port ii. Stop: Stops the process of reading data from the port iii. Clear: Clears the available data. iv. Save: Saves the available data to a file for future use. v. Load: Loads a file and plots the data available from that. The picture box will be redrawn on each and every change of the data or a scroll on the screen. The source code for the interface window is given in APPENDIX.
75
SNMIMT
CHAPTER 13
76
SNMIMT
CHAPTER 14
ADVANTAGES High accuracy of parameters displayed. Easy to read. Laptop or palmtop interface to view the route. The system works on 12 V power supply from the automobile battery.
Highly reliable, and compact in size.
77
SNMIMT
CHAPTER 15
FUTURE SCOPE
System can be modified by using wireless data transmission systems to pc which can be useful in monitoring of path and position of vehicles. This can be easily implemented in cars by using LCD screens and new generation microcontrollers. By modifyying t VB program we can make the system more user friendly. This system can also be used in ships with small modifications. It can able to replace the GPS system in future by further developing more accurate data transmission systems through air.
78
SNMIMT
CHAPTER 16
CONCLUSION
In this technological era many advanced tracking systems are available in market which is mostly based on Global Positioning System. But if anyone wants to enjoy these facilities, they have to pay a lot for the receiver and other service charges. Also there are many other limitations like geographical position of the place, satellite coverage etc. These factors determine the effectiveness of the service. But here this Dromography based traking system provides a cheap solution for traking a vehicle in a map .Also this system ease the tracing of a new route map of unknown places. We can create backup of the map as well in a short time. Being an independent gadget it works accurately with a high precision. Also this system is very much upgradable such as we can make this system as an assistant which can provide information about the current location, the distance from the target place, the speed etc. of the vehicle.
79
SNMIMT
CHAPTER 17
BIBLIOGRAPHY
o www.wikipedia.org/dromography.php o www.alldatasheet.com/pic/16F877a.html o Op amps and Linear Integrated Circuits by Ramakand A.Gayakwad. Vol 3
80
SNMIMT
81
SNMIMT