Anda di halaman 1dari 111

MAIN PROJECT REPORT ON DESIGN & DEVELOPMENT OF GSM & GPS BASED VEHICLE THEFT CONTROL SYSTEM By K. T. H. B.

Venkateswar Rao(07AG1A0461) Sai Sampath (07AG1A0456) Pramod Kumar (07AG1A0417) Abhilash (07AG1A0404) Internal guide U.Appalraju H.O.D S.Suryanarayana 1

INDEX CONTENTS 1. 2. 3. 4. 5. 6. 7. 8. Abbreviations Figure Locations Introduction to the project Block Diagram Block Diagram Description Schematic Schematic Descript ion Hardware Components Micro controller About GPS Technology About GSM Technology LCD Display Power Supply Max232 Ignition switch Dc motor Pc 9. Circuit Description 10.Software components a. About Keil b. Embedded C 11. Sour ce Code 12.Conclusion (or) Synopsis 13.Future Aspects 14.Bibliography Abbreviations: 2

ACC B PSW SP DPTR DPL DPH P0 P1 P2 P3 IE IP TMOD TCON T2CON T2MOD TH0 TL0 TH1 TL 1 TH2 TL2 RCAP2H RCAP2L SCON SBUF PCON GSM GPS PCB SFR WAAS LCD - Accumulator - B Register - Program Status Word - Stack Pointer - Data pointer - Low byte - High byte - Port 0 - Port 1 - Port 2 - Port 3 - Interrupt Enable co ntrol - Interrupt Priority control - Timer/Counter Mode control - Timer/Counter control - Timer/counter 2 control - Timer/counter mode2 control - Timer/counter 0high byte - Timer/counter 0 low byte - Timer/counter 1 high byte - Timer/counte r 1 low byte - Timer/counter 2 high byte - Timer/counter 2 low byte - T/C 2 capt ure register high byte - T/C 2 capture register low byte - Serial control - Seri al data buffer - Power control -Global System for Mobile Communications - Global positioning system - Printed circuit Board - Special function registers - Wide Area Augmentation System - Liquid Crystal Display Figure Locations: Fig 1 Fig 2 Fig 3 Fig 4 : Block Diagram : Schematic Diagram : Functional block d iagram of micro controller : Oscillator and timing circuit 3

Fig 5 : Pin diagram of AT89C51 Fig 6.1 : Oscillator Connections Fig 6.2 : External Clock Drive Configuration Fi g 7 Fig 8 Fig 9 : Memory organization of RAM : RAM Allocation in the 8051 : 8051 Register Banks and their RAM Addresses Fig 10 : DB-9 pin connector Fig 11 : Interfacing of MAX-232 to controller Fig 12 : GPS MODEM Fig 13 : GPS sample module (GARMIN) Fig 14 : GPS 3A pin assignment Fig 15 : structure of a GSM network Fig 16 : GSM smart modem Fig 17 : Block diag ram of modem with key connections Fig 18 : Internal diagram of GSM modem Fig 19 : Inserting/Removing the sim card into the modem Fig 20 : General architecture o f a GSM network Fig 21 : Interfacing of LCD to a micro controller Fig 22 : Funct ional Block Diagram of Power supply Fig 23 : An Electrical Transformer Fig 24 : Direction of current flow in a circuit Fig 25 : A Three Terminal Voltage Regulat or ABSTRACT 4

It deals with the design & development of a theft control system for an automobi le, which is being used to prevent / control the theft of a vehicle. the develop ed system makes use of an embedded system based on gsm technology. the designed & developed system is installed in the vehicle. an interfacing mobile is also co nnected to the microcontroller, which is in turn,connected to the engine. once, the vehicle is being stolen, the information is being used by the vehicle owner for further processing. the information is passed onto the central processing in surance system, where by sitting at a remote place, a particular number is diale d by them to the interfacing mobile that is with the hardware kit which is insta lled in the vehicle. by reading the signals received by the mobile, one can cont rol the ignition of the engine;say to lock it or to stop the engine immediately. again it will come to the normal condition only after entering a secured passwo rd. the owner of the vehicle & the central processing system will know this secu red password. the main concept in this design is introducing the mobile communic ations into the embedded system. the designed unit is very simple & low cost. th e entire designed unit is on a single chip. when the vehicle is stolen, owner of vehicle may inform to the central processing system, then they will stop the ve hicle by just giving a ring to that secret number and with the help of sim track ing knows the location of vehicle and informs to the local police or stops it fr om further movement. INTRODUCTION 5

The position of the vehicle will be traced with the help of the GPS and GSM tech nology. This project is aimed to track the vehicles giving the position of the v ehicle. The location of the vehicle is indicated using GPS (Global Positioning S ystem) technology. Communication link is made possible through a GPS transceiver . GPS will give the information of parameters like longitude, latitude and altit ude and that can be sent towards viewing system where we can showthe location of vehicle where it is passing wit paramerters . With this system we can easily id entify vehicle thefts. GSM is used for receiving and sending messages according to the software program written to perform the task. Global system for mobile co mmunication (GSM) is a globally accepted standard for digital cellular communica tion. GSM is the name of a standardization group established in 1982 to create a common European mobile telephone standard that would formulate specifications f or a pan-European mobile cellular radio system operating at 900 MHz. It is estim ated that many countries outside of Europe will join the GSM partnership.The Glo bal Positioning System (GPS) is a satellite-based navigation system that sends a nd receives radio signals. A GPS receiver acquires these signals and provides yo u with information. Using GPS technology, you can determine location, velocity, and time, 24 hours a day, in any weather conditions anywhere in the worldfor free . BLOCK DIAGRAM: 6

VEHICLE TRACKING SYSTEM GPS POWER SUPPLY GPS M A X 2 3 2 DC MOTOR DRIVERS LCD MICRO CONTROLLER (AT89c51) Ignition Switch L A T C H GSM MODEM DC MOTOR BLOCK DIAGRAM DESCRIPTION: 7

Here we have mainly two different blocks,those are tracking and location viewing blocks in this first we going to know about tracking systemIn this project we w ill place this vehicle trcking system in vehicle. The Block diagram consists of a GPS modem, a GSM modem, a Micro controller, an ignition switch, DC motor,a LCD Display and power supply. These hardware components will be discussed briefly a s follows: A GPS modem is used to get the signals and receive the signals from t he satellites. In this project, GPS modem get the signals from the satellites an d those are given to the microcontroller. The signals may be in the form of the coordinates; these are represented in form of the latitudes, longitudes and alti tudes. A GSM modem is used to get the messages from the mobile and as well as re ading the message also. Thereafter sending the acknowledgement will be done. Bef ore operating this GSM modem first we have to insert the SIM card in this modem. Then the total receiving and sending the messages will be done based on this nu mber. First the concerned person has to register for that number. And second one is viewing and controlling section the vehicle like tracking and bloking. In th is system mainly we have microcontroller, powersupply, LCD, GSM, Pc, keypad .by that particular keypad of keys only we are sending request for track and block i ng of vehicle.here we two switches one for sending request for tracking the vehi cle location and another for blocking the vehicle .A Micro controller is a heart of this project. The total controlling action will be done through this micro c ontroller. Based on the signals given to the micro controller that will be total ly controlled at the output section. If we send the message like TRACK to the GSM modem at viewing and controlling section it will get recieved by trcking section which is placed in the vehicle, it will send signals to the micro controller to trcke the vehicle and if sening message by view and control section isBLOCK means the system get blocked by microcontoller of controlling operation Upon receivin g the signals, the micro controller will switched-off the ignition part of that vehicle. Then the vehicle does not move at any inch. An ignition switch plays th e key role in the vehicle, for moving. If it is in off condition, the vehicle do es not move at an inch. In this project, for completely stopping the vehicle we are just switched-off the ignition switch with the help of the micro controller. 8

A LCD display is used at the output section. To display the status of the GSM an d GPS. The maximum power supply required to operate the hardware circuitry is +5 V DC voltage. SCHEMATIC DIAGRAM: Fig2: Schematic Diagram Schematic Explanation: GPS connections: Pins 1 2 3 4 connections VCC (+5v) This pin is connected to the 3rd (TXD) of the MAX -232 IC This pin is connected to the 2nd (RXD) of the MAX -232 IC GND 9

5 GND MAX-232 connections to microcontroller: Pins 11 12 13 14 15 16 connections This pin is connected to P3.1 (TXD) of the Mi cro controller This pin is connected to P3.0 (RXD) of the Micro controller This pin is connected to 3rd pin (TXD) of DB-9 connector This pin is connected to 2nd pin (RXD) of DB-9 connector Ground vcc (+5v) LCD connections to Micro controller: Pins 1 2 3 4 5 6 7-14 controller Connections VSS (ground) VCC (+5V) 10k pot RS, this pin is connected to P2.7 of the micro controller R/w, this pin is connected to P2.6 of the micro controller EN, this pin is connected to P2.5 of the micro controller (D0-D7) these pins are connected to the port (P0) of the micro Latch Connections to Micro controller: Pins Connections 9, 16 P3.0 2, 13 P3.1 19 P3.6 1 P3.7 10 GND 20 VCC Ignition switch P2.0 10

Schematic Explanation: pc connections: Pins 1 2 3 connections VCC (+5v) This pin is connected to the 2nd (RXD) of the M AX -232 IC GND MAX-232 connections to microcontroller: Pins 11 connections This pin is connected to P3.1 (TXD) of the Micro controller 11

12 13 15 16 This pin is connected to P3.0 (RXD) of the Micro controller This pin is connecte d to 3rd pin (TXD) of DB-9 connector Ground vcc (+5v) LCD connections to Micro controller: Pins 1 2 3 4 5 6 7-14 controller Connections VSS (ground) VCC (+5V) 10k pot RS, this pin is connected to P2.7 of the micro controller R/w, this pin is connected to P2.6 of the micro controller EN, this pin is connected to P2.5 of the micro controller (D0-D7) these pins are connected to the port (P0) of the micro Latch Connections to Micro controller: Pins Connections 9, 16 P3.0 2, 13 P3.1 19 P3.6 1 P3.7 10 GND 20 VCC Keypad switches: Switch 1 for tracking request is con nected to P3.4 Switch 1 for blocking request is connected to P3.4 12

HARDWARE COMPONENTS: MICRO CONTROLLER 89C51 INTRODUCTION A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O interfaces such as serial port, parallel port timer or count er, interrupt controller, data acquisition interfaces-Analog to Digital converte r, Digital to Analog converter, integrated on to a single silicon chip. If a sys tem is developed with a microprocessor, the designer has to go for external memo ry such as RAM, ROM, EPROM and peripherals. But controller is provided all these facilities on a single chip. Development of a Micro controller reduces PCB size and cost of design. One of the major differences between a Microprocessor and a Micro controller is that a controller often deals with bits not bytes as in the real world application. Intel has introduced a family of Micro controllers call ed the MCS-51. The Major Features: Compatible with MCS-51 products 4k Bytes n-system Reprogrammable flash memory Fully static operation: 0HZ to 24MHZ Three level programmable clock 128 * 8 bit timer/counters Six interrupt sources Program mable serial channel Low power idle power-down modes AT89C51 is 8-bit micro cont roller, which has 4 KB on chip flash memory, which is just sufficient for our ap plication. The on-chip Flash ROM allows the program memory to be reprogrammed in system or by conventional non-volatile memory Programmer. Moreover ATMEL is the leader in flash technology in todays market place and hence using AT 89C51 is th e optimal solution. 13

AT89C51 MICROCONTROLLER ARCHITECTURE The 89C51 architecture consists of these sp ecific features: Eight bit CPU with registers A (the accumulator) it program counter (PC) and data pointer (DPTR) Eight- bit stack pointer (PSW) E ight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51 ) Internal RAM of 128 bytes: Thirty two input/output pins arranged as four 8-bit ports:p0-p3 Two 16-bit timer/counters: T0 and T1 Full duplex serial data receive r/transmitter: SBUF Control registers: TCON, TMOD, SCON, PCON, IP, and IE Two ex ternal and three internal interrupts sources. Oscillator and clock circuits. Fig 3: Functional block diagram of micro controller 14

Types of memory: The 89C51 have three general types of memory. They are on-chip memory, external Code memory and external Ram. On-Chip memory refers to physical ly existing memory on the micro controller itself. External code memory is the c ode memory that resides off chip. This is often in the form of an external EPROM . External RAM is the Ram that resides off chip. This often is in the form of st andard static RAM or flash RAM. a) Code memory Code memory is the memory that ho lds the actual 89C51 programs that is to be run. This memory is limited to 64K. Code memory may be found on-chip or offchip. It is possible to have 4K of code m emory on-chip and 60K off chip memory simultaneously. If only off-chip memory is available then there can be 64K of off chip ROM. This is controlled by pin prov ided as EA. b) Internal RAM The 89C51 have a bank of 128 of internal RAM. The in ternal RAM is found on-chip. So it is the fastest Ram available. And also it is most flexible in terms of reading and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128 bytes of internal memory are subdiv ided. The first 32 bytes are divided into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte can be add ressed by the user. They are numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB and CLR. Flash memory is a nonvolatile mem ory using NOR technology, which allows the user to electrically program and eras e information. Flash memory is used in digital cellular phones, digital cameras, LAN switches, PC Cards for notebook computers, digital set-up boxes, embedded c ontrollers, and other devices. 15

Fig 5: - Pin diagram of AT89C51 Pin Description: VCC: Supply voltage. GND: Groun d. Port 0: Port 0 is an 8-bit open-drain bi-directional I/O port. As an output p ort, each pin can sink eight TTL inputs. When 1sare written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be t he multiplexed low order address/data bus during accesses to external program an d data memory. In this mode P0 has internal pull-ups. Port 0 also receives the c ode bytes during Flash programming, and outputs the code bytes during program ve rification. External pullups are required during program verification. Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The P ort 1 output buffers can sink/source four TTL inputs. When 1s are written to Por t 1 pins 16

they are pulled high by the internal pull-ups and can be used as inputs. As inpu ts, Port 1 pins that are externally being pulled low will source current (IIL) b ecause of the internal pull-ups. Port 1 also receives the low-order address byte s during Flash programming and verification. Port 2: Port 2 is an 8-bit bi-direc tional I/O port with internal pull-ups. The Port 2 output buffers can sink/sourc e four TTL inputs. When 1s are written to Port 2 pins they are pulled high by th e internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are e xternally being pulled low will source current (IIL) because of the internal pul l-ups. Port 3: Port 3 is an 8-bit bi-directional I/O port with internal pull-ups . The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of vari ous special features of the AT89C51 as listed below: Tab 6.2.1 Port pins and their alternate functions RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. 17

ALE/PROG: Address Latch Enable output pulse for latching the low byte of the add ress during accesses to external memory. This pin is also the program pulse inpu t (PROG) during Flash programming. In normal operation ALE is emitted at a const ant rate of 1/6the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each acce ss to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX o r MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-di sable bit has no effect if the micro controller is in external execution mode. P SEN: Program Store Enable is the read strobe to external program memory. When th e AT89C51 is executing code from external program memory, PSEN is activated twic e each machine cycle, except that two PSEN activations are skipped during each a ccess to external data memory. EA/VPP: External Access Enable. EA must be strapp ed to GND in order to enable the device to fetch code from external program memo ry locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VC C for internal program executions. This pin also receives the 12-volt programmin g enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP. XTAL1: Input to the inverting oscillator amplifier and input to the interna l clock operating circuit. XTAL2: Output from the inverting oscillator amplifier. Oscillator Characteristic s: XTAL1 and XTAL2 are the input and output, respectively, of an inverting ampli fier, which can be configured for use as an on-chip oscillator, as shown in Figs 18

6.1 Either a quartz crystal or ceramic resonator may be used. To drive the devic e from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 6.2. There are no requirements on the duty cycle of t he external clock signal, since the input to the internal clocking circuitry is through a divide-bytwo flip-flop, but minimum and maximum voltage high and low t ime specifications must be observed. Fig 6.1 Oscillator Connections Fig 6.2 External Clock Drive Configuration REGISTERS: In the CPU, registers are used to store information temporarily. to be fetched. The vast majority of 8051 registers are 8bit registers. D7 D6 D5 D4 D3 D2 D1 D0 T he most widely used registers of the 8051 are A(accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR(data pointer), and PC(program counter). All of the above r egisters are 8-bits, except DPTR and the program counter. The accumulator, regis ter A, is used for all arithmetic and logic instructions. That information could be a byte of data to be processed, or an address pointing to the data SFRs (Special Function Registers) In the 8051, registers A, B, PSW and DPTR are part of the group of registers com monly referred to as SFR (special function registers). The SFR can be accessed b y the names (which is much easier) or by their addresses. For example, register A has address E0h, and register B has been ignited the address F0H, as shown in table. The following two points should note about the SFR addresses. 19

1. The Special function registers have addresses between 80H and FFH. These addr esses are above 80H, since the addresses 00 to 7FH are addresses of RAM memory i nside the 8051. 2. Not all the address space of 80H to FFH is used by the SFR. T he unused locations 80H to FFH are reserved and must not be used by the 8051 pro grammer. Symbol ACC B PSW SP DPTR DPL DPH P0 P1 P2 P3 IP IE TMOD TCON T2CON T2MO D TH0 TL0 TH1 TL1 TH2 TL2 RCAP2H RCAP2L SCON SBUF PCON Name Accumulator B regist er Program status word Stack pointer Data pointer 2 bytes Low byte High byte Por t0 Port1 Port2 Port3 Interrupt priority control Interrupt enable control Timer/c ounter mode control Timer/counter control Timer/counter 2 control Timer/counter mode2 control Timer/counter 0high byte Timer/counter 0 low byte Timer/counter 1 high byte Timer/counter 1 low byte Timer/counter 2 high byte Timer/counter 2 low byte T/C 2 capture register high byte T/C 2 capture register low byte Serial co ntrol Serial data buffer Power control Address 0E0H 0F0H 0D0H 81H 82H 83H 80H 90 H 0A0H 0B0H 0B8H 0A8H 89H 88H 0C8H 0C9H 8CH 8AH 8DH 8BH 0CDH 0CCH 0CBH 0CAH 98H 99H 87H Table: 8051 Special function register Address A Register (Accumulator): 20

This is a general-purpose register, which serves for storing intermediate result s during operating. A number (an operand) should be added to the accumulator pri or to execute an instruction upon it. Once an arithmetical operation is preforme d by the ALU, the result is placed into the accumulator B Register B register is used during multiply and divide operations which can be performed only upon num bers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A). Registers (R0-R7) Fig7: Memory organization of RAM This is a common name for the total 8 general p urpose registers (R0, R1, R2 ...R7). Even they are not true SFRs, they deserve t o be discussed here because of their purpose. The bank is active when the R regi sters it includes are in use. Similar to the accumulator, they are used for temp orary storing variables and intermediate results. Which of the banks will be act ive depends on two bits included in the PSW Register. These registers are stored in four banks in the scope of RAM. 8051 Register Banks and Stack RAM memory spa ce allocation in the 8051 There are 128 bytes of RAM in the 8051. The 128 bytes of RAM inside the 8051 are assigned addresses 00 to7FH. different groups as foll ows: 1. A total of 32 bytes from locations 00 to 1FH hex are set aside for regis ter banks and the stack. These 128 bytes are divided into three 21

2. A total of 16 bytes from locations 20 to 2FH hex are set aside for bitaddress able read/write memory. 3. A total of 80 bytes from locations 30H to 7FH are use d for read and write storage, or what is normally called Scratch pad. These 80 l ocations of RAM are widely used for the purpose of storing data and parameters n u 8051 programmers. Default register bank Register bank 0; that is, RAM location s 0, 1,2,3,4,5,6, and 7 are accessed with the names R0, R1, R2, R3, R4, R5, R6, and R7 when programming the 8051. FIG 8: RAM Allocation in the 8051 PSW Register (Program Status Word) This is one of the most important SFRs. The Program Status Word (PSW) contains s everal status bits that reflect the current state of the CPU. This register cont ains: Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit, and user-definable status flag. The ALU automatically changes some o f registers bits, which is usually used in regulation of the program performing. P - Parity bit. If a number in accumulator is even then this bit will be automat ically set (1), otherwise it will be cleared (0). It is mainly used during data transmission and receiving via serial communication. 22

OV Overflow occurs when the result of arithmetical operation is greater than 255 (decimal), so that it cannot be stored in one register. In that case, this bit will be set (1). If there is no overflow, this bit will be cleared (0). RS0, RS1 - Register bank select bits. These two bits are used to select one of the four register banks in RAM. By writing zeroes and ones to these bits, a group of regi sters R0-R7 is stored in one of four banks in RAM. RS1 0 0 1 1 RS2 0 1 0 1 Space in RAM Bank0 00h-07h Bank1 08h-0Fh Bank2 10h-17h Bank3 18h-1Fh F0 - Flag 0. This is a general-purpose bit available to the user. AC - Auxiliary Carry Flag is used for BCD operations only. CY - Carry Flag is the (ninth) auxi liary bit used for all arithmetical operations and shift instructions. DPTR Regi ster (Data Pointer) These registers are not true ones because they do not physic ally exist. They consist of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). Their 16 bits are used for external memory addressing. They may be handled as a 16-bit register or as two independent 8-bit registers. Besid es, the DPTR Register is usually used for storing data and intermediate results, which have nothing to do with memory locations. 23

SP Register (Stack Pointer) The stack is a section of RAM used by the CPU to store information temporily. Th is information could be data or an address. The CPU needs this storage area sinc e there are only a limited number of registers. How stacks are accessed in the 8 051 If the stack is a section of RAM, there must be registers inside the CPU to point to it. The register used to access the stack is called the SP (Stack point ) Register. The stack pointer in the 8051 is only 8 bits wide; which means that it can take values of 00 to FFH. When the 8051 is powered up, the SP register co ntains value 07. This means that RAM location 08 is the first location used for the stack by the 8051. The storing of a CPU register in the stack is called a PU SH, and pulling the contents off the stack back into a CPU register is called a POP. In other words, a register is pushed onto the stack to save it and popped o ff the stack to retrieve it. The job of the SP is very critical when push and po p actions are performed. Program counter: The important register in the 8051 is the PC (Program counter). The program counter points to the address of the next instruction to be execute d. As the CPU fetches the opcode from the program ROM, the program counter is in cremented to point to the next instruction. The program counter in the 8051 is 1 6bits wide. This means that the 8051 can access program addresses 0000 to FFFFH, a total of 64k 24

bytes of code. However, not all members of the 8051 have the entire 64K bytes of on-chip ROM installed, as we will see soon. TIMERS On-chip timing/counting facility has proved the capabilities of the micro contro ller for implementing the real time application. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation, etc,. Havi ng sufficient number of timer/counters may be a need in a certain design applica tion. The 8051 has two timers/counters. They can be used either as timers to gen erate a time delay or as counters to count events happening outside the micro co ntroller. TIMER 0 REGISTERS The 16-bit register of Timer 0 is accessed as low by te and high byte. the low byte register is called TL0(Timer 0 low byte)and the h igh byte register is referred to as TH0(Timer 0 high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc. TIMER 1 REGISTERS Timer 1 is also 16-bit register is split into two bytes, refer red to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte). These registers ar e accessible n the same way as the register of Timer 0. TMOD (timer mode) REGIST ER Both timers 0 and 1 use the same register, called TMOD, to set the various ti mer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bi ts are used to set the timer mode and the upper 2 bits to specify the operation. 25

GATE Gate control when set. The timer/counter is enabled only while the INTx pin is h igh and the TRx control pin is set. When cleared, the timer is enabled. C/T Timer or counter selected cleared for timer operation (Input from internal syste m clock).set for counter operation (input TX input pin). M1 0 M0 0 MODE 0 Operating Mode 13-bit timer mode 8-bit timer/counter THx with TLx as 5-bit presc aler. 0 1 1 16-bit timer mode 16-bit timer/counters THx with TLx are cascaded; there is no p rescaler 1 0 2 8-bit auto reload 8-bit auto reload timer/counter;THx Holds a value that is to b e reloaded into TLx each time it overflows. 1 1 3 Split timer mode. C/T (clock/timer): This bit in the TMOD register is used to decide whether the t imer is used as a delay generator or an event counter. If C/T=0, it is used as a timer for time delay generation. The clock source for the time delay is the cry stal frequency of the 8051.this section is concerned with this choice. The timers use as an event counter is discussed in the next section. Serial Communication: Serial data communication uses two methods, asynchronous and synchronous. The sy nchronous method transfers a block of data at a time, while the asynchronous met hod transfers a single byte at a time. 26

In data transmission if the data can be transmitted and received, it is a duplex transmission. This is in contrast to simplex transmissions such as with printer s, in which the computer only sends data. Duplex transmissions can be half or fu ll duplex, depending on whether or not the data transfer can be simultaneous. If data is transmitted one way at a time, it is referred to as half duplex. If the data can go both ways at the same time, it is full duplex. Of course, full dupl ex requires two wire conductors for the data lines, one for transmission and one for reception, in order to transfer and receive data simultaneously. Asynchrono us serial communication and data framing The data coming in at the receiving end of the data line in a serial data transfer is all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver agree on a set of rules, a protocol, on how the data is packed, how many bits constitute a character, and when the data begins and ends. Start and stop bits Asynchronous serial data com munication is widely used for character-oriented transmissions, while block-orie nted data transfers use the synchronous method. In the asynchronous method, each character is placed between start and stop bits. This is called framing. In the data framing for asynchronous communications, the data, such as ASCII character s, are packed between a start bit and a stop bit. The start bit is always one bi t, but the stop bit can be one or two bits. The start bit is always a 0 (low) an d the stop bit (s) is 1 (high). Data transfer rate The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely use d terminology for bps is baud rate. However, the baud and bps rates are not nece ssarily equal. This is due to the fact that baud rate is the modem terminology a nd is defined as the number of signal changes per second. In modems a single cha nge of signal, sometimes transfers several bits of data. As far as the conductor wire is concerned, the baud rate and bps are the same, and for this reason we u se the bps and baud interchangeably. RS232 Standards To allow compatibility amon g data communication equipment made by various manufacturers, an interfacing sta ndard called RS232 was set by the 27

Electronics Industries Association (EIA) in 1960. In 1963 it was modified and ca lled RS232A. RS232B AND RS232C were issued in 1965 and 1969, respectively. Today , RS232 is the most widely used serial I/O interfacing standard. This standard i s used in PCs and numerous types of equipment. However, since the standard was s et long before the advert of the TTL logic family, its input and output voltage levels are not TTL compatible. In RS232, a 1 is represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3 undefined. For this reason, to connect a ny RS232 to a micro controller system we must use voltage converters such as MAX 232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa. MAX232 IC chips are commonly referred to as line drivers. RS232 pins RS232 cabl e, commonly referred to as the DB-25 connector. In labeling, DB25P refers to the plug connector (male) and DB-25S is for the socket connector (female). Since no t all the pins are used in PC cables, IBM introduced the DB-9 Version of the ser ial I/O standard, which uses 9 pins only, as shown in table. DB-9 pin connector 12345 6789 Fig 10: DB-9 pin connector (Out of computer and ex posed end of cable) Pin Functions: Pin 1 2 3 4 5 6 7 Description Data carrier detect (DCD) Received data (RXD) Transmitted data (TXD) Data terminal ready(DTR) Signal ground (GND) D ata set ready (DSR) Request to send (RTS) 28

8 9 Clear to send (CTS) Ring indicator (RI) Note: DCD, DSR, RTS and CTS are active low pins. The method ommunication allows for a simple connection of three lines: The three essential signals for 2-way RS-232 Communications ies data from DTE to the DCE. RXD: carries data from DCE to round used by RS-232 for c Tx, Rx, and Ground. are these: TXD: carr the DTE SG: signal g

8051 connection to RS232 The RS232 standard is not TTL compatible; therefore, it requires a line driver s uch as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice v ersa. The interfacing of 8051 with RS232 connectors via the MAX232 chip is the m ain topic. The 8051 has two pins that are used specifically for transferring and receiving data serially. These two pins are called TXD and RXD and a part of th e port 3 group (P3.0 and P3.1). pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD. These pins are TTL compatible; therefore, they require a line driver to make them RS232 compatible. One such line driver is the MAX232 ch ip. Since the RS232 is not compatible with todays microprocessors and microcontro llers, we need a line driver (voltage converter) to convert the RS232s signals to TTL voltage levels that will be acceptable to the 8051s TXD and RXD pins. One ex ample of such a converter is MAX232 from Maxim Corp. The MAX232 converts from RS 232 voltage levels to TTL voltage levels, and vice versa. 29

Fig 11: Interfacing of MAX-232 to controller INTERRUPTS A single micro controller can serve several devices. There are two ways to do th at: INTERRUPTS or POLLING. INTERRUPTS vs POLLING: The advantage of interrupts is that the micro controller can serve many devices (not all the same time, of cou rse); each device can get the attention of the micro controller based on the pri ority assigned to it. The polling method cannot assign priority since it checks all devices in round-robin fashion. More importantly, in the interrupt method th e micro controller can also ignore (mask) a device request for service. This is again not possible with the polling method. The most important reason that the i nterrupt method is preferable is that the polling method wastes much of the micr o controllers time by polling devices that do not need service. So, in order to a void tying down the micro controller, interrupts are used. INTERRUPT SERVICE ROU TINE For every interrupt, there must be an interrupt service routine (ISR), or i nterrupt handler. When an interrupt is invoked, the micro controller runs the in terrupts service routine. For every interrupt, there is a fixed location in memo ry that holds the address of its ISR. The group of memory location set aside to hold the addresses of ISRs is called the interrupt vector table. Shown below: In terrupt Vector Table for the 8051: INTERRUPT ROM LOCATION (HEX) Reset External h ardware Interrupt 0 Timers 0 interrupt (TF0) External hardware Interrupt 1(INT1) Timers 1 interrupt (TF1) 001B 30 Auto 0003 000B 0013 P3.3 (13) P3.2 (12) Auto A uto Auto 0000 PIN 9 FLAG CLEARING Auto

Serial COM (RI and TI) Six Interrupts in the 8051: 0023 Programmer Clears it In reality, only five interrupts are available to the user in the 8051, but many manufacturers data sheets state that there are six interrupts since they include reset .the six interrupts in the 8051 are allocated as above. 1. Reset. When th e reset pin is activated, the 8051 jumps to address location 0000.this is the po wer-up reset. 2. Two interrupts are set aside for the timers: one for Timer 0 an d one for Timer 1.Memory location 000BH and 001BH in the interrupt vector table belong to Timer 0 and Timer 1, respectively. 3. Two interrupts are set aside for hardware external harder interrupts. Pin number 12(P3.2) and 13(P3.3) in port 3 is for the external hardware interrupts INT0 and INT1, respectively. These exte rnal interrupts are also referred to as EX1 and EX2.Memory location 0003H and 00 13H in the interrupt vector table are assigned to INT0 and INT1, respectively. 4 . Serial communication has a single interrupt that belongs to both receive and t ransmit. The interrupt vector table location 0023H belongs to this interrupt. In terrupt Enable Register D7 EA D6 -D5 ET2 D4 ES D3 ET1 D2 EX1 D1 ET0 D0 EX0 EA IE.7 disables all interrupts. If EA=0, no interrupts is acknowledged. If EA=1, each i nterrupt source is individually enabled disabled By setting or clearing its enab le bit. -ET2 only). ES ET1 EX1 ET0 EX0 IE.6 Not implemented, reserved for future use.* IE.5 Enables or disables Timer 2 overflow or capture interrupt (8052 IE.4 IE.3 I E.2 IE.1 IE.0 Enables or disables the serial ports interrupt. Enables or disable s Timers 1 overflow interrupt Enables or disables external interrupt 1. Enables or disables Timer 0 overflow interrupt. Enables or disables external interrupt 0 . 31

GLOBAL POSITION SYSTEM About GPS Global Positioning System (GPS) technology is changing the way we work and play. You can use GPS technology when you are driving, flying, fishing, sailing, hiki ng, running, biking, working, or exploring. With a GPS receiver, you have an ama zing amount of information at your fingertips. Here are just a few examples of h ow you can use GPS technology. Know precisely how far you have run and at what p ace while tracking your path so you can find your way home. Pinpoint the perfect fishing spot on the water and easily relocate it. Get the closest location of y our favorite restaurant when you are out-of-town. Find the nearest airport or id entify the type of airspace in which you are flying What is GPS? The Global Positioning System (GPS) is a satellite-based navigation system that sends and receives radio signals. A GPS receiver acquires these signals and prov ides you with information. Using GPS technology, you can determine location, vel ocity, and time, 24 hours a day, in any weather conditions anywhere in the world for free. GPS, formally known as the NAVSTAR (Navigation Satellite Timing and Ra nging). Global Positioning System originally was developed for the military. Bec ause of its popular navigation capabilities and because you can access GPS techn ology using small, inexpensive equipment, the government made the system availab le for civilian use. The USA owns GPS technology and the Department of Defense m aintains it. 32

GPS technology requires the following three segments. Space segment. Control seg ment. User segment At least 24 GPS satellites orbit the earth twice a day in a s pecific pattern. They travel at approximately 7,000 miles per hour about 12,000 miles above the earths surface. These satellites are spaced so that a GPS receive r anywhere in the world can receive signals from at least four of them. Each GPS satellite constantly sends coded radio signals (pseudorandom code) to the earth . These GPS satellite signals contain the following information. The particular satellite that is sending the information. Where that satellite should be at any given time (the precise location of the satellite is. called ephemeris data). W hether or not the satellite is working properly. The date and time that the sate llite sent the signal. The signals can pass through clouds, glass, and plastic. Most solid objects such as buildings attenuate (decrease the power of) the signa ls. The signals cannot pass through objects that contain a lot of metal or objec ts that contain water (such as underwater locations). The GPS satellites are pow ered by solar energy. If solar energy is unavailable, for example, when the sate llite is in the earths shadow, satellites use backup batteries to continue runnin g. Each GPS satellite is built to last about 10 years. The Department of Defense monitors and the satellites to ensure that GPS technology continues to run smoo thly for years to come. Space Segment 33

Fig12: GPS MODEM Control Segment The control segment is responsible for constant ly monitoring satellite health, signal integrity, and orbital configuration from the ground control segment includes the following sections: Master control stat ion Monitor stations Ground antennas Monitor Stations At least six unmanned monitor stations are located around the w orld. Each station constantly monitors and receives information from the GPS sat ellites and then sends the orbital and clock information to the master control s tation (MCS). Master Control Station (MCS) The MCS) is located near Colorado Spr ings in Colorado. The MCS constantly receives GPS satellite orbital and clock in formation from monitor stations. The controllers in the MCS make precise correct ions to the data as necessary, and send the information (known as ephemeris data ) to the GPS satellites using the ground antennas. Ground Antennas Ground antenn as receive the corrected orbital and clock information from the MCS, and then se nd the corrected information to the appropriate satellites. User Segment The GPS user segment consists of your GPS receiver. Your receiver collects and processe s signals from the GPS satellites that are in view and then uses that informatio n to determine and display your location, speed, time, and so forth. Your GPS re ceiver does not transmit any information back to the satellites. 34

How Does GPS Technology Work? The following points provide a summary of the technology at work: view. Your GP receiver accounts for errors. For more information, refer to the Sources of Err ors. Your GPS receiver determines your current location, velocity, and time. You r GPS receiver can calculate other information, such as bearing, track, trip dis tance, and distance to destination, sunrise and sunset time so forth. Your GPS r eceiver displays the applicable information on the screen. The control segment c onstantly monitors the GPS constellation and uploads information to satellites t o provide maximum user accuracy Your GPS receiver collects information from the GPS satellites that are in Who Uses GPS? GPS technology has many amazing applications on land, at sea, and in the air. Yo u might be surprised to learn about the following examples of how people or prof essions are already using GPS technology Agriculture In precision farming, GPS t echnology helps monitor the application of fertilizer and pesticides. GPS techno logy also provides location information that helps farmers plow, harvest, map fi elds, and mark areas of disease or weed infestation. Aviation Aircraft pilots us e GPS technology for en route navigation and airport approaches. Satellite navig ation provides accurate aircraft location anywhere on or near the earth. Environ ment GPS technology helps survey disaster areas and maps the movement of environ mental phenomena (such as forest fires, oil spills, or hurricanes). It is even p ossible to find locations that have been submerged or altered by natural disaste rs. Ground Transportation GPS technology helps with automatic vehicle location a nd in-vehicle navigation systems. Many navigation systems show the vehicles locat ion on an 35

electronic street map, allowing drivers to keep track of where they are and to l ook up other destinations. Some systems automatically create a route and give tu rn-by-turn directions. GPS technology also helps monitor and plan routes for del ivery vans and emergency vehicles. Marine GPS technology helps with marine navig ation, traffic routing, underwater surveying, navigational hazard location, and mapping. Commercial fishing fleets use it to navigate to optimum fishing locatio ns and to track fish migrations. Military Military aircraft, ships, submarines, tanks, jeeps, and equipment use GPS technology for many purposes including basic navigation, target designation, close air support, weapon technology, and rende zvous. Public Safety Emergency and other specialty fleets use satellite navigati on for location and status information. Rail Precise knowledge of train location is essential to prevent collisions, maintain smooth traffic flow, and minimize costly delays. Digital maps and onboard inertial units allow fully-automated tra in control. Recreation Outdoor and exercise enthusiasts use GPS technology to st ay apprised of location, heading, bearing, speed, distance, and time. In additio n, they can accurately mark and record any location and return to that precise s pot. Space GPS technology helps track and control satellites in orbit. Future bo oster rockets and reusable launch vehicles will launch, orbit the earth. Return, and land, all under automatic control. Space shuttles also use GPS navigation. Surveying Surveyors use GPS technology for simple tasks (such as defining proper ty lines) or for complex tasks (such as building infrastructures in urban center s). Locating a precise point of reference used to be very time consuming. With G PS technology, two people can survey dozens of control points in an hour. Survey ing and mapping roads 36

and rail systems can also be accomplished from mobile platforms to save time and money. Timing Delivering precise time to any user is one of the most important functions of GPS technology. This technology helps synchronize clocks events aro und the world. Pager companies depend on GPS satellites to synchronize the trans mission of information throughout their systems. Investment banking firms rely o n this service every day to record international transactions simultaneously. How Accurate Is GPS? GPS technology depends on the accuracy of signals that travel from GPS satellite s to a GPS receiver. You can increase accuracy by ensuring that when you use (or at least when you turn on) your GPS receiver, you are in an area with few or no obstacles between you and the wide open sky. When you first turn on your GPS re ceiver, stand in an open area for a few moments to allow the unit to get a good fix on the satellites (especially if you are heading into an obstructed area). T his gives you better accuracy for a longer period of time (about 4-6 hours). It takes between 65 and 85 milliseconds for a signal to travel from GPS satellite t o a GPS receiver on the surface of the earth. FIG 13: GPS sample module (GARMIN) The signals are so accurate that time can be figured to much less than a millionth of a second, velocity can be figured to wi thin a fraction of a mile per hour, and location can be figured to within a few meters. 37

WAAS/EGNOS The Wide Area Augmentation System (WAAS) is a system of satellites an d ground stations that provides even better position accuracy than the already h ighly accurate GPS. Europes version of this system is the European Geostationary Navigation Overlay Service (EGNOS). The Federal Aviation Administration (FAA) de veloped the WAAS program. It makes more airspace usable to pilots, provides more direct end route paths, and provides new precision approach services to runways , resulting in safety and capacity improvements in all weather conditions at all locations throughout the U.S. National Airspace System (NAS). Although it was d esigned for aviation users, WAAS supports a wide variety of other uses, for exam ple, more precise marine navigation. To take advantage of WAAS technology, you m ust have a WAAS-capable GPS receiver in an area where WAAS satellite coverage is available such as North America. No additional equipment or fees are required t o take advantage of WAAS. Sources of Errors Errors can affect the accuracy of th e GPS signal. Take your GPS receiver to an area with a wide and unobstructed vie w of the sky to reduce the possibility and impact of some errors. Here are some of the most common GPS errors. Ionosphere and Troposphere Delays the satellite si gnal slows down as it passes through the atmosphere. The system uses a built-in model that calculates an average delay to partially correct this type of error. Orbital Errors this terminology refers to inaccuracies of the satellites reported location. Receiver Clock Errors the GPS receiver has a built-in clock that can ha ve small timing errors. Number of Satellites Visible obstructions can block signa l reception, causing position errors or no position reading. The more satellites that your GPS receiver can view, the better the fix is. Satellite Geometry/Shad ing refers to the relative position of the satellites at any given time. Ideal sa tellite geometry exists when the satellites are located at wide angles relative to each other. Poor geometry results when the satellites are located in a line o r in a tight grouping. Signal Multipath 38

the GPS signal bounces off of objects, such as tall buildings or large rock surfa ces, before it reaches the GPS receiver. This increases the travel time of the s ignal and, therefore, causes errors. Buying a GPS Receiver Deciding which GPS re ceiver to buy can be overwhelming. Think about how you want to use the unit, for example, traveling or running. Keep the following considerations in mind: Produ ct Level do you want the basics, or do you want all of the bells and whistles? Yo u can find a unit that fits your needs and budget. Power Source will you be using the unit away from an auxiliary power source? You might need to carry extra bat teries. With some you can use a vehicle adapter or AC power source. Portability d o you have a preference between a portable or a built-in unit? Some units mount directly in the dashboard of your boat or aircraft. Mapping Capability do you wan t to know the general direction or street-level details of your chosen path? Map data can include streets restaurants, tourist attractions, marine data, topogra phy, and so forth. Mounts a mount for your GPS can be useful to keep your hands f ree while navigating your bike, boat, car, or airplane. Many units with a mount, and several additional mounts are available. Ease of Use some receivers provide a tutorial or an easy-to-use touch screen interface. Some even have turn-by-turn voice instructions you are navigating your route. Antenna Configuration where ar e you going to use the unit? With some units, you use only the built-in antenna. With other units, you attach an external antenna to give you better reception P rice which units fit your price range? An inexpensive entry-level unit can be a g reat way to enter the GPS world. Software 39

whether you want to save your favorite locations or plan a trip, map software can help. You can use your PC or go directly your GPS receiver. Your preference for map detail and your specific activities determine which software is right for y ou. Complementary Navigation Aids Remember, a GPS receiver is a complement to na vigation and should not be the only navigational tool that you use. Using a pape r map, a simple compass, and having knowledge of manual navigation is a good, sa fe practice. AarLogic GPS 3A Pin assignment FIG 14: GPS 3A pin assignment 40

GLOBAL SYSTEM FOR MOBILE COMMUNICATIONS 41

Definition: Global system for mobile communication (GSM) is a globally accepted standard for digital cellular communication. GSM is the name of a standardizatio n group established in 1982 to create a common European mobile telephone standar d that would formulate specifications for a pan-European mobile cellular radio s ystem operating at 900 MHz. It is estimated that many countries outside of Europ e will join the GSM partnership. Description: GSM, the Global System for Mobile communications, is a digital cellular communications system, which has rapidly g ained acceptance and market share worldwide, although it was initially developed in a European context. In addition to digital transmission, GSM incorporates ma ny advanced services and features, including ISDN compatibility and worldwide ro aming in other GSM networks. The advanced services and architecture of GSM have made it a model for future thirdgeneration cellular systems, such as UMTS. This paper will give an overview of the services offered by GSM, the system architect ure, the radio transmission Fig 15: structure of a GSM network GSM Modems 42

A GSM modem can be an external modem device, such as the Wavecom FASTRACK Modem. Insert a GSM SIM card into this modem, and connect the modem to an available se rial port on your computer.A GSM modem can be a PC Card installed in a notebook computer, such as the Nokia Card Phone.A GSM modem could also be a standard GSM mobile phone with the appropriate cable and software driver to connect to a seri al port on your computer. Phones such as the Nokia 7110 with a DLR-3 cable, or v arious Ericsson phones, are often used for this purpose. A dedicated GSM modem ( external or PC Card) is usually preferable to a GSM mobile phone. This is becaus e of some compatibility issues that can exist with mobile phones. For example, i f you wish to be able to receive inbound MMS messages with your gateway, and you are using a mobile phone as your modem, you must utilize a mobile phone that do es not support WAP push or MMS. This is because the mobile phone automatically p rocesses these messages, without forwarding them via the modem interface. Simila rly some mobile phones will not allow you to correctly receive SMS text messages longer than 160 bytes (known as concatenated SMS or long SMS). This is because thes e long messages are actually sent as separate SMS messages, and the phone attemp ts to reassemble the message before forwarding via the modem interface. (Weve obs erved this latter problem utilizing the Ericsson R380, while it does not appear to be a problem with many other Ericsson models.) When you install your GSM mode m, or connect your GSM mobile phone to the computer, be sure to install the appr opriate Windows modem driver from the device manufacturer. To simplify configura tion, the Now SMS/MMS Gateway will communicate with the device via this driver. An additional benefit of utilizing this driver is that you can use Windows diagn ostics to ensure that the modem is communicating properly with the computer. The Now SMS/MMS gateway can simultaneously support multiple modems, provided that y our computer hardware has the available communications port resources. 43

Fig:16 GSM smart modem SMART MODEM (GSM/GPRS) INTRODUCTION: Analogics GSM Smart M odem is a multi-functional, ready to use, rugged and versatile modem that can be embedded or plugged into any application. The Smart Modem can be customized to various applications by using the standard AT commands. The modem is fully typeapproved and can directly be integrated into your projects with any or all the f eatures of Voice, Data, Fax, SMS, and Internet etc. Smart Modem kit contain the following items: Analogics GSM/GPRS Smart Modem SMPS based power supply adapter. 3 dBi antenna with cable (optional: other types) Data cable (RS232) User Manual PRODUCT DESCRIPTION: The connectors integrated to the body, guarantee the reliab le output and input connections. An extractible holder is used to insert the SIM card (Micro-SIM type). Status LED indicates the operating mode. 44

Fig 17: Block diagram of modem with key connections Physical Characteristics Dimensions Weight Housing 100 x 78 x 32 mm (excluding connectors) 125 grams Alum inum Profiled Temperature Range: Operating temperature: from -200C to +550C Storage temperatur e: from -250C to +700C Fig 18: Internal diagram of GSM modem Installing the modem: 45

To install the modem, plug the device on to the supplied SMPS Adapter. For Autom otive applications fix the modem permanently using the mounting slots (optional as per your requirement dimensions). Inserting/ Removing the SIM Card: To insert or Remove the SIM Card, it is necessary to press the SIM holder ejector button with Sharp edged object like a pen or a needle. With this, the SIM holder comes out a little, then pulls it out and insert or remove the SIM Card Fig 19: Inserting/Removing the sim card into the modem Make sure that the ejecto r is pushed out completely before accessing the SIM Card holder do not remove th e SIM card holder by force or tamper it (it may permanently damage). Place the S IM Card Properly as per the direction of the installation. It is very important that the SIM is placed in the right direction for its proper working condition C onnecting External Antenna: Connect GSM Smart Modem to the external antenna with cable end with SMA male. The Frequency of the antenna may be GSM 900/1800 MHz. The antenna may be ( 0 dbi, 3 dbi or short length L-type antenna) as per the fie ld conditions and signal conditions. DC Supply Connection The Modem will automat ically turn ON when connection is given to it. The following is the Power Supply Requirement: 46

Parameters Supply Voltage Peak Current at 5 V supply Average Current at 5 V supp ly in idle Mode Average Current at 5 V supply in idle Mode and RS232 Power Savin g Activated MIN 5V Avg 9V Max 12 V 1.8 A (during transmission) 35 mA 13 mA Connecting Modem to external devices: RS232 can be used to connect to the external device through the D-SUB/ USB (for USB model only) device that is provided in the modem. Connectors: Connector SMA 15 pin or 9 pin D-SUB USB (optional) Function RF Antenna connector RS232 link Audio link (only for 15 D-SUB) Reset (only for 15 D-SUB) USB communi cation port (optional) 2 pin Phoenix tm SIM Connector RJ11 (For 9 D-SUB and USB only) Power Supply Connector SIM Card Connection Audio link Simple hand set connection (4 wire) 2 wire desktop phone connection Description of the interfaces: The modem comprises several interfaces: LED Function including operating Status External antenna (via SMA) 47

Serial and control link Power Supply (Via 2 pin Phoenix tm contact) SIM card hol der LED Status Indicator: The LED will indicate different status of the modem: O FF ON Flashing Slowly Flashing rapidly Modem Switched off Modem is connecting to the network Modem is in idle mode Modem is in transmission/communication (GSM o nly) 9 - PIN D-SUB Female Connector PIN 1 2 3 4 5 6 7 8 9 NAME X None TX Rx DSR GND D TR CTS RTS X None Designation NC Transmit Data Receive Data Data Set Ready Groun d Data Terminal Ready Clear to send Request to send NC Type NC Input Output Outp ut Ground Input Output Input NC Protecting Modem: Do not expose to the modem to extreme conditions such as High temperatures, direct sunlight, High Humidity, Rain, Chemicals, Water, Dust etc. For these details see the specifications given. Do not drop, Shake or hit the Mo dem. (Warranty may void) The Modem should not be used in extreme vibrating condi tions 48

Handle the Antenna and cable with care. AT commands features: Line settings: A serial link handler is set with the following default values Au tobaud, 8 bits data, 1 stop bit, no parity, flow control. Command line Commands always start with AT (which means attention) and finish with a <CR> character. I nformation responses and result codes Responses start and end with <CR><LF>,. If command syntax is incorrect, an ERROR string is returned. If command syntax is correct but with some incorrect parameters, the +CME ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with different error codes. If the command line h as been performed successfully, an OK string is returned. In some cases, such as AT+CPIN? or (unsolicited) incoming events, the product does not return the OK str ing as a response. Services provided by GSM GSM was designed having interoperabi lity with ISDN in mind, and the services provided by GSM are a subset of the sta ndard ISDN services. Speech is the most basic, and most important, teleservice p rovided by GSM. In addition, various data services are supported, with user bit rates up to 9600 bps. Specially equipped GSM terminals can connect with PSTN, IS DN, Packet Switched and Circuit Switched Public Data Networks, through several p ossible methods, using synchronous or asynchronous transmission. Also supported are Group 3 facsimile 49

service, videotex, and teletex. Other GSM services include a cell broadcast serv ice, where messages such as traffic reports, are broadcast to users in particula r cells. A service unique to GSM, the Short Message Service, allows users to sen d and receive point-to-point alphanumeric messages up to a few tens of bytes. It is similar to paging services, but much more comprehensive, allowing bi-directi onal messages, store-and-forward delivery, and acknowledgement of successful del ivery. Supplementary services enhance the set of basic teleservices. In the Phas e I specifications, supplementary services include variations of call forwarding and call barring, such as Call Forward on Busy or Barring of Outgoing Internati onal Calls. Many more supplementary services, including multiparty calls, advice of charge, call waiting, and calling line identification presentation will be o ffered in the Phase 2 specifications. Architecture of the GSM network A GSM network is composed of several functional entities, whose functions and in terfaces are specified. Figure 1 shows the layout of a generic GSM network. The GSM network can be divided into three broad parts. The Mobile Station is carried by the subscriber. The Base Station Subsystem controls the radio link with the Mobile Station. The Network Subsystem, the main part of which is the Mobile serv ices Switching Center (MSC), performs the switching of calls between the mobile users, and between mobile and fixed network users. The MSC also handles the mobi lity management operations. Not shown are the Operations A GSM network is compos ed of several functional entities, whose functions and interfaces are specified. Figure 1 shows the layout of a generic GSM network. The GSM network can be divi ded into three broad parts. Subscriber carries the Mobile Station. The Base Stat ion Subsystem controls the radio link with the Mobile Station. The Network Subsy stem, the main part of which is the Mobile services Switching Center (MSC), perf orms the switching of calls between the mobile users, and between mobile and fix ed network users. The MSC also handles the mobility management operations. Not s hown is the Operations intendance Center, which oversees the proper operation an d setup of the network. The Mobile Station and the Base Station 50

Subsystem communicate across the Um interface, also known as the air interface o r radio link. The Base Station Subsystem communicates with the Mobile services S witching Center across the A interface. Fig 20: General architecture of a GSM network Mobile Station: The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card called th e Subscriber Identity Module (SIM). The SIM provides personal mobility, so that the user can have access to subscribed services irrespective of a specific termi nal. By inserting the SIM card into another GSM terminal, the user is able to re ceive calls at that terminal, make calls from that terminal, and receive other s ubscribed services. The mobile equipment is uniquely identified by the Internati onal Mobile Equipment Identity (IMEI). The SIM card contains the International M obile Subscriber Identity (IMSI) used to identify the subscriber to the system, a secret key for authentication, and other information. The IMEI and the IMSI ar e independent, thereby allowing personal mobility. The SIM card may be protected against unauthorized use by a password or personal identity number. Base Statio n Subsystem: 51

The Base Station Subsystem is composed of two parts, the Base Transceiver Statio n (BTS) and the Base Station Controller (BSC). These communicate across the stan dardized Abis interface, allowing (as in the rest of the system) operation betwe en components made by different suppliers. The Base Transceiver Station houses t he radio transceivers that define a cell and handles the radio-link protocols wi th the Mobile Station. In a large urban area, there will potentially be a large number of BTSs deployed, thus the requirements for a BTS are ruggedness, reliabi lity, portability, and minimum cost. The Base Station Controller manages the rad io resources for one or more BTSs. It handles radio-channel setup, frequency hop ping, and handovers, as described below. The BSC is the connection between the m obile station and the Mobile service Switching Center (MSC). Network Subsystem T he central component of the Network Subsystem is the Mobile services Switching C enter (MSC). It acts like a normal switching node of the PSTN or ISDN, and addit ionally provides all the functionality needed to handle a mobile subscriber, suc h as registration, authentication, location updating, handovers, and call routin g to a roaming subscriber. These services are provided in conjunction with sever al functional entities, which together form the Network Subsystem. The MSC provi des the connection to the fixed networks (such as the PSTN or ISDN). Signalling between functional entities in the Network Subsystem uses Signalling System Numb er 7 (SS7), used for trunk signalling in ISDN and widely used in current public networks. The Home Location Register (HLR) and Visitor Location Register (VLR), together with the MSC, provide the call-routing and roaming capabilities of GSM. The HLR contains all the administrative information of each subscriber register ed in the corresponding GSM network, along with the current location of the mobi le. The location of the mobile is typically in the form of the signalling addres s of the VLR associated with the mobile as a distributed database. station. The actual routing procedure will be described later. There is logically one HLR per GSM network, although it may be implemented 52

The Visitor Location Register (VLR) contains selected administrative information from the HLR, necessary for call control and provision of the subscribed servic es, for each mobile currently located in the geographical area controlled by the VLR. Although each functional entity can be implemented as an independent unit, all manufacturers of switching equipment to date implement the VLR together wit h the MSC, so that the geographical area controlled by the MSC corresponds to th at controlled by the VLR, thus simplifying the signalling required. Note that th e MSC contains no information about particular mobile stations --- this informat ion is stored in the location registers. The other two registers are used for au thentication and security purposes. The Equipment Identity Register (EIR) is a d atabase that contains a list of all valid mobile equipment on the network, where each mobile station is identified by its International Mobile Equipment Identit y (IMEI). An IMEI is marked as invalid if it has been reported stolen or is not type approved. The Authentication Center (AuC) is a protected database that stor es a copy of the secret key stored in each subscriber s SIM card, which is used for authentication and encryption over the radio channel. DM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver General Description These buffers/line drivers are designed to improve both the performance and PC b oard density of 3-STATE buffers/ drivers employed as memory-address drivers, clo ck drivers, and bus-oriented transmitters/receivers. Featuring 400 mV of hystere sis at each low current PNP data line input, they provide improved noise rejecti on and high fanout outputs and can be used to drive terminated lines down to 133 ohms. Features 3-STATE outputs drive bus lines directly PNP inputs reduce DC lo ading on bus lines Hysteresis at data inputs improves noise margins Typical IOL (sink current) 24 mA Typical IOH (source current) 15 mA 53

Typical propagation delay times Inverting 10.5 ns Noninverting 12 ns Typical ena ble/disable time 18 ns Typical power dissipation (enabled) Inverting 130 mW Noni nverting 135 mW 54

55

Liquid crystal display Liquid crystal displays (LCDs) have materials, which combine the properties of b oth liquids and crystals. Rather than having a melting point, they have a temper ature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped together in an ordered form similar to a crystal. An L CD consists of two glass panels, with the liquid crystal material sand witched i n between them. The inner surface of the glass plates are coated with transparen t electrodes which define the character, symbols or patterns to be displayed pol ymeric layers are present in between the electrodes and the liquid crystal, whic h makes the liquid crystal molecules to maintain a defined orientation angle. 56

One each polarisers are pasted outside the two glass panels. These polarisers wo uld rotate the light rays passing through them to a definite angle, in a particu lar direction. When the LCD is in the off state, light rays are rotated by the t wo polarisers and the liquid crystal, such that the light rays come out of the L CD without any orientation, and hence the LCD appears transparent. When sufficie nt voltage is applied to the electrodes, the liquid crystal molecules would be a ligned in a specific direction. The light rays passing through the LCD would be rotated by the polarisers, which would result in activating/ highlighting the de sired characters. The LCDs are lightweight with only a few millimeters thickness. Since the LCDs consume less power, they are compatible with low power electronic circuits, and can be powered for long durations. The LCDs dont generate light and so light is needed to read the display. By using backlighting, reading is possi ble in the dark. The LCDs have long life and a wide operating temperature range. Changing the display size or the layout size is relatively simple which makes th e LCDs more customers friendly. The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limit ed amount of numeric data. The recent advances in technology have resulted in be tter legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunicati ons and entertainment electronics. The LCDs have even started replacing the cath ode ray tubes (CRTs) used for the display of text and graphics, and also in smal l TV applications. This section describes the operation modes of LCDs then descri be how to program and interface an LCD to 8051 using Assembly and C. LCD operation In recent years the LCD is finding widespread use replacing LEDs(sevensegment LE Ds or other multisegment LEDs).This is due to the following reasons: 1. The decl ining prices of LCDs. 57

2. 3. The ability to display numbers, characters and graphics. This is in contract to LEDs, which are limited to numbers and a few characters. Incorporation of a refr eshing controller into the LCD, there by relieving the CPU of the task of refres hing the LCD. In the contrast, the LED must be refreshed by the CPU to keep disp laying the data. 4. Ease of programming for characters and graphics. LCD pin description The LCD discussed in this section has 14 pins. The function of each pins is give n in table. TABLE 1:Pin description for LCD: Pin 1 2 3 4 symbol Vss Vcc VEE RS I/O ---I Description Ground +5V power supply Power supply to control contrast RS=0 to select command register RS=1 to select data register R/W=0 for write R/W=1 for read Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bi t data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus 5 6 7 8 9 10 11 12 13 14 R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 I I/O I/O I/O I/O I/O I/O I/O I/O I/O TABLE 2: LCD Command Codes Code Command to LCD Instruction (hex) 1 2 Register Clear display screen Return home 58

4 6 5 7 8 A C E F 10 14 18 1C 80 C0 38 Decrement cursor Increment cursor Shift display right Shift display left Display off, cursor off Display off, cursor on Display on, cursor off Display on, curso r on Display on, cursor blinking Shift cursor position to left Shift cursor posi tion to right Shift the entire display to the left Shift the entire display to t he right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 2 lines and 5x7 matrix Uses: The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more informati on displaying capability and a wider temperature range. These have resulted in t he LCDs being extensively used in telecommunications and entertainment electroni cs. The LCDs have even started replacing the cathode ray tubes (CRTs) used for t he display of text and graphics, and also in small TV applications. LCD INTERFACING Sending commands and data to LCDs with a time delay: 59

Fig 21: Interfacing of LCD to a micro controller To send any command from table 2 to the LCD, make pin RS=0. for data, make RS=1. Then send a high to-low pulse to the E pin to enable the internal latch of the LC D. IGNITION SWITCH The term ignition switch is often used interchangeably to refer to two very diff erent parts: the lock cylinder into which the key is inserted, and the electroni c switch that sits just behind the lock cylinder. In some cars, these two parts are combined into one unit, but in other cars they remain separate. It is advisa ble to check your car s shop manual before attempting to purchase an ignition sw itch, to ensure that you buy the correct part. In order to start a car, the engi ne must be turning. Therefore, in the days before ignition switches, car engines had to be turned with a crank on the front of the car in order to start them. T he starter performs this same operation by turning the engine s flywheel, a larg e, flat disc with teeth on the outer edge. The starter has a gear that engages t hese teeth when it is powered, rapidly and briefly turning the flywheel, and thu s the engine. The ignition switch generally has four positions: off, accessories , on, and start. Some cars have two off positions, off and lock; one turns off t he car, and the other allows the key to be removed from the ignition. When the k ey is turned to the accessories 60

position, certain accessories, such as the radio, are powered; however, accessor ies that use too much battery power, such as window motors, remain off in order to prevent the car s battery from being drained. The accessories position uses t he least amount of battery power when the engine is not running, which is why dr ive-in movie theaters recommend that the car be left in the accessories mode dur ing the movie. The on position turns on all of the car s systems, including syst ems such as the fuel pump, because this is the position the ignition switch rema ins in while the car s engine is running. The start position is spring loaded so that the ignition switch will not remain there when the key is released. When t he key is inserted into the ignition switch lock cylinder and turned to the star t position, the starter engages; when the key is released, it returns to the on position, cutting power to the starter. This is because the engine runs at speed s that the starter cannot match, meaning that the starter gear must be retracted once the engine is running on its own. Either the ignition switch or the lock c ylinder may fail in a car, but both circumstances have very different symptoms. When the ignition switch fails, generally the electrical wiring or the plastic h ousing develops problems. The car may not turn on and/or start when this happens . Also, the spring-loaded start position could malfunction, in which case the st arter will not engage unless the key is manually turned back to the on position. When the lock cylinder malfunctions, however, the operation of the key itself w ill become problematic. If the tumblers become stripped, the lock cylinder may b e able to turn with any key, or you may be able to remove the key when the car i s on. If the tumblers begin to shift, the lock cylinder may not turn. Sometimes the key can be wiggled until the lock cylinder turns, but it is important to rem ember that this is only a temporary fix MAX-232: The MAX232 from Maxim was the first IC which in one package contains the necessa ry drivers (two) and receivers (also two), to adapt the RS-232 signal voltage le vels to TTL logic. It became popular, because it just needs one voltage (+5V) an d generates the necessary RS-232 voltage levels (approx. -10V and +10V) internal ly. This greatly simplified the design of circuitry. Circuitry designers no long er need to design and build a power supply with three voltages (e.g. -12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a simple 78x05 voltage converter. The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the MAX232A is much more often used (and easier to get) than the original MAX232, and the MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232 needs. It should be noted that the MAX 232(A) is just a driver/receiver. It does not generate the necessary RS232 sequence of marks and spaces with the right timing, it does not decode the R S-232 signal, it does not provide a serial/parallel conversion. All it does is t o convert signal voltage levels. Generating serial data with the right timing an d decoding serial data has to be done by additional circuitry, e.g. by a 16550 U ART or 61

one of these small micro controllers (e.g. Atmel AVR, Microchip PIC) getting mor e and more popular. The MAX232 and MAX232A were once rather expensive ICs, but t oday they are cheap. It has also helped that many companies now produce clones ( ie. Sipex). These clones sometimes need different external circuitry, e.g. the c apacities of the external capacitors vary. It is recommended to check the data s heet of the particular manufacturer of an IC instead of relying on Maxim s origi nal data sheet. The original manufacturer (and now some clone manufacturers, too ) offers a large series of similar ICs, with different numbers of receivers and drivers, voltages, builtin or external capacitors, etc. E.g. The MAX232 and MAX2 32A need external capacitors for the internal voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between three and ten times more expensive in electronic shops than the MAX232A because of its internal capacitor s. It is also more difficult to get the MAX233 than the garden variety MAX232A. A Typical Application The MAX 232(A) has two receivers (converts from RS-232 to TTL voltage levels) and two drivers (converts from TTL logic to RS-232 voltage l evels). This means only two of the RS-232 signals can be converted in each direc tion. The old MC1488/1498 combo provided four drivers and receivers. Typically a pair of a driver/receiver of the MAX232 is used for TX and RX And the second one for CTS and RTS. There are not enough drivers/receivers in the MAX232 to also connect the DTR, DS R, and DCD signals. Usually these signals can be omitted when e.g. communicating with a PC s serial interface. If the DTE really requires these signals either a second MAX232 is needed, or some other IC from the MAX232 family can be used (i f it can be found in consumer electronic shops at all). An alternative for DTR/D SR is also given below. Maxim s data sheet explains the MAX232 family in great d etail, including the pin configuration and how to connect such an IC to external circuitry. This information can be used as-is in own design to get a working RS -232 interface. Maxim s data just misses one critical piece of information: How exactly to connect the RS-232 signals to the IC. So here is one possible example : MAX232 to RS232 DB9 Connection as a DCE 62

MAX232 Pin Nbr. MAX232 Pin Name Signal Voltage DB9 Pin 7 8 9 10 11 12 13 14 15 T 2out R2in R2out T2in T1in R1out R1in T1out GND CTS RTS RTS CTS TX RX TX RX GND R S-232 7 RS-232 8 TTL TTL TTL TTL n/a n/a n/a n/a RS-232 3 RS-232 2 0 5 In addition one can directly wire DTR (DB9 pin 4) to DSR (DB9 pin 6) without goi ng through any circuitry. This gives automatic (brain dead) DSR acknowledgment o f an incoming DTR signal. Sometimes pin 6 of the MAX232 is hard wired to DCD (DB 9 pin 1). This is not recommended. Pin 6 is the raw output of the voltage pump a nd inverter for the -10V voltage. Drawing currents from the pin leads to a rapid breakdown of the voltage, and as a consequence to a breakdown of the output vol tage of the two RS-232 drivers. It is better to use software which doesn t care about DCD, but does hardware-handshaking via CTS/RTS only. The circuitry is comp leted by connecting five capacitors to the IC as it follows. The MAX232 needs 1. 0F capacitors, the MAX232A needs 0.1F capacitors. MAX232 clones show similar diffe rences. It is recommended to consult the corresponding data sheet. At least 16V capacitor types should be used. If electrolytic or tantalic capacitors are used, the polarity has to be observed. The first pin as listed in the following table is always where the plus pole of the capacitor should be connected to. MAX232(A ) external Capacitors Capacitor + Pin - Pin Remark C1 C2 C3 C4 C5 1 4 2 3 5 16 T his looks non-intuitive, but because pin 6 is on -10V, GND gets the + connector, and not the GND 6 16 GND The 5V power supply is connected to 63

+5V: Pin 16 GND: Pin 15 Features Meet or Exceed TIA/EIA-232-F and ITU Recommendation V.28 Operate With Single 5-V Power Supply Operate Up to 120 kbit/s Two Drivers and Two Receivers 30-V Input Levels Low Supply Current . . . 8 mA Typical Designed to be Interchangeable With Maxim MAX232 ESD Protection Exceeds JESD 22 2000-V Human-Body Model (A114-A)

Applications TIA/EIA-232-F Battery-Powered Systems Terminals Modems Computers Description/ordering information The MAX232 is a dual driver/receiver that includes a capacitive voltage generato r to supply EIA-232 voltage levels from a single 5-V supply. Each receiver conve rts EIA-232 inputs to 5-V TTL/CMOS levels. These receivers have a typical thresh old of 1.3 V and a typical hysteresis of 0.5 V, and can accept 30-V inputs. Each driver converts TTL/CMOS input levels into EIA232 levels. The driver, receiver, and voltage-generator functions are available as cells in the Texas Instruments Lin ASIC library. 64

DC Motor DC motors are configured in many types and sizes, including brush less, servo, a nd gear motor types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is maintained using either permanent magnets or elect romagnetic windings. DC motors are most commonly used in variable speed and torq ue. Motion and controls cover a wide range of components that in some way are us ed to generate and/or control motion. Areas within this category include bearing s and bushings, clutches and brakes, controls and drives, drive components, enco ders and resolves, Integrated motion control, limit switches, linear actuators, linear and rotary motion components, linear position sensing, motors (both AC an d DC motors), orientation position sensing, pneumatics and pneumatic components, positioning stages, slides and guides, power transmission (mechanical), seals, slip rings, solenoids, springs. Motors are the devices that provide the actual speed and torque in a 65

drive system. This family includes AC motor types (single and multiphase motors, universal, servo motors, induction, synchronous, and gear motor) and DC motors (brush less, servo motor, and gear motor) as well as linear, stepper and air mot ors, and motor contactors and starters. In any electric motor, operation is base d on simple electromagnetism. A current-carrying conductor generates a magnetic field; when this is then placed in an external magnetic field, it will experienc e a force proportional to the current in the conductor, and to the strength of t he external magnetic field. As you are well aware of from playing with magnets a s a kid, opposite (North and South) polarities attract, while like polarities (N orth and North, South and South) repel. The internal configuration of a DC motor is designed to harness the magnetic interaction between a current-carrying cond uctor and an external magnetic field to generate rotational motion. Let s start by looking at a simple 2-pole DC electric motor (here red represents a magnet or winding with a "North" polarization, while green represents a magnet or winding with a "South" polarization). Fig 25: Block Diagram of the DC motor Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, co mmutator, field magnet(s), and brushes. In most common DC motors (and all that B eamers will see), the external magnetic field is produced by high-strength perma nent magnets1. The stator is the stationary part of the motor -- this includes t he motor casing, as well as two or more permanent magnet pole pieces. The rotor (together with the axle and attached commutator) rotates with respect to the sta tor. The rotor consists of windings (generally on a core), the windings being el ectrically connected to the commutator. The above diagram shows a common motor l ayout -- with the rotor inside the stator (field) magnets. 66

The geometry of the brushes, commutator contacts, and rotor windings are such th at when power is applied, the polarities of the energized winding and the stator magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the stator s field magnets. As the rotor reaches alignment, the brushes mov e to the next commutator contacts, and energize the next winding. Given our exam ple two-pole motor, the rotation reverses the direction of current through the r otor winding, leading to a "flip" of the rotor s magnetic field, and driving it to continue rotating. In real life, though, DC motors will always have more than two poles (three is a very common number). In particular, this avoids "dead spo ts" in the commutator. You can imagine how with our example two-pole motor, if t he rotor is exactly at the middle of its rotation (perfectly aligned with the fi eld magnets), it will get "stuck" there. Meanwhile, with a two-pole motor, there is a moment where the commutator shorts out the power supply (i.e., both brushe s touch both commutator contacts simultaneously). This would be bad for the powe r supply, waste energy, and damage motor components as well. Yet another disadva ntage of such a simple motor is that it would exhibit a high amount of torque rip ple" (the amount of torque it could produce is cyclic with the position of the r otor). Fig 26: Block Diagram of the DC motor having two poles only So since most small DC motors are of a three-pole design, let s tinker with the workings of one via an interactive animation (JavaScript required): Fig 27: Block Diagram of the DC motor having Three poles 67

You ll notice a few things from this -- namely, one pole is fully energized at a time (but two others are "partially" energized). As each brush transitions from one commutator contact to the next, one coil s field will rapidly collapse, as the next coil s field will rapidly charge up (this occurs within a few microseco nd). We ll see more about the effects of this later, but in the meantime you can see that this is a direct result of the coil windings series wiring: Fig 28: Internal Block Diagram of the Three pole DC motor There s probably no better way to see how an average dc motor is put together, t han by just opening one up. Unfortunately this is tedious work, as well as requi ring the destruction of a perfectly good motor. This is a basic 3-pole dc motor, with 2 brushes and three commutator contacts. H-BRIDGE: 68

DC motors are typically controlled by using a transistor configuration called an "H-bridge". This consists of a minimum of four mechanical or solid-state switch es, such as two NPN and two PNP transistors. One NPN and one PNP transistor are activated at a time. Both NPN and PNP transistors can be activated to cause a sh ort across the motor terminals, which can be useful for slowing down the motor f rom the back EMF it creates. 69

Basic Theory H-bridge. Sometimes called a "full bridge" the H-bridge is so named because it has four switching elements at the "corners" of the H and the motor forms the cross bar. The key fact to note is that there are, in theory, four swi tching elements within the bridge. These four elements are often called, high si de left, high side right, low side right, and low side left (when traversing in clockwise order). The switches are turned on in pairs, either high left and lowe r right, or lower left and high right, but never both switches on the same "side " of the bridge. If both switches on one side of a bridge are turned on it creat es a short circuit between the battery plus and battery minus terminals. If the bridge is sufficiently powerful it will absorb that load and your batteries will simply drain quickly. Usually however the switches in question melt. To power t he motor, you turn on two switches that are diagonally opposed. In the picture t o the right, imagine that the high side left and low side right switches are tur ned on. The current flows and the motor begins to turn in a "positive" direction . Turn on the high side right and low side left switches, then Current flows the other direction through the motor and the motor turns in the opposite direction . Actually it is just that simple, the tricky part comes in when you decide what to use for switches. Anything that can carry a current will work, from four SPS T switches, one DPDT switch, relays, transistors, to enhancement mode power MOSF ETs. One more topic in the basic theory section, quadrants. If each switch can b e controlled independently then you can do some interesting things with the brid ge, some folks call such a bridge a "four quadrant device" (4QD get it?). If you built it out of a single DPDT relay, you can really only control forward or rev erse. You can build a small truth table that tells you for each of the switch s states, what the bridge will do. As each switch has one of two states, and there are four switches, there are 16 possible states. However, since any state that turns both switches on one side on is "bad" 70

(smoke issues forth: P), there are in fact only four useful states (the four qua drants) where the transistors are turned on. High Side Left High Side Low Side Low Side Quadrant Right Left On Off Off Off On On On On Off Off Off On The last two rows describe a maneuver where Right Description On Forward Running Off Backward Running Off Braking On Braking you "short circuit" the motor which causes the motors generator effect to work against itself. The turning motor gen erates a voltage which tries to force the motor to turn the opposite direction. This causes the motor to rapidly stop spinning and is called "braking" on a lot of H-bridge designs. Of course there is also the state where all the transistors are turned off. In this case the motor coasts freely if it was spinning and doe s nothing if it was doing nothing. Implementation 1. Using Relays: A simple implementation of an H Bridge using fou r SPST relays is shown. Terminal A is High Side Left, Terminal B is High Side Ri ght, Terminal C is Low Side Left and Terminal D is Low Side Right. The logic fol lowed is according to the table above. Warning: Never turn on A and C or B and D at the same time. This will lead to a short circuit of the battery and will lea d to failure of the relays due to the large current. 71

72

2. Using Transistors: We can better control our motor by using transistors or Fi eld Effect Transistors (FETs). Most of what we have discussed about the relays H -Bridge is true of these circuits. See the diagram showing how they are connecte d. You should add diodes across the transistors to catch the back voltage that i s generated by the motor s coil when the power is switched on and off. This fly back voltage can be many times higher than the supply voltage! For information o n building an H-Bridge using Transistors, have a look here. Warning: If you don t use diodes, you could burn out your transistors. Also the same warning as in t he diode case. Don t turn on A and C or B and D at the same time.

Transistors, being a semiconductor device, will have some resistance, which caus es them to get hot when conducting much current. This is called not being able t o sink or source very much power, i.e.: Not able to provide much current from gr ound or from plus voltage. Mosfets are much more efficient, they can provide muc h more current and not get as hot. They usually have the fly back diodes built i n so you don t need the diodes anymore. This helps guard against fly back voltag e frying your ICs. To use Mosfets in an H-Bridge, you need P-Channel Mosfets on top because they can "source" power, and N-Channel Mosfets on the bottom because then can "sink" power. It is important that the four quadrants of the H-Bridge circuits be turned on and off properly. When there is a path between the positiv e and ground side of the H-Bridge, other than through the motor, a condition exi sts called "shoot through". This is basically a direct short of the power supply and can cause semiconductors to become ballistic, in circuits with large curren ts flowing. There are H-bridge chips available that are much easier, and safer, to use than designing your own H-Bridge circuit. 1. Using H-Bridge Devices The L 293 has 2 H-Bridges (actually 4 Half H-Bridges), can provide about 1 amp to each and occasional peak loads to 2 amps. The L298 has 2 h-bridges on board, can han dle 1amp and peak current draws to about 3amps. The LMD18200 has one h-bridge on board, can handle about 2 or 3 amps and can handle a peak of about 6 amps. Ther e are several more commercially designed H-Bridge chips as well. Once a Half H-b ridge is enabled, it truth table is as follows: OUTPU T Y L H 73 INPUT A L H

So you just give a High level when you want to turn the Half H-Bridge on and Low level when you want to turn it off. When the Half H-Bridge is on, the voltage a t the output is equal to Vcc2.If you want to make a Full H-Bridge, you connect t he motor (or the load) between the outputs of two Half HBridges and the inputs w ill be the two inputs of the Half H-Bridges. Suppose we have connected Half H-Br idges 1 and 2 to form a Full H-Bridge. Now the truth table is as follows: INPUT 1A INPUT 2A OUTPUT 1Y OUTPUT 2Y Description L L L L Braking (both terminals of motor are Gnd) Forward Running Backward Running Braki ng (both terminals of motor at Vcc2 L H H L L H H L H H H H 2) L293D Motor Driver IC: Since two motors are used to drive The back wheels of the robot independently, there is a need for Two H-bridges. Instead of implement ing the above H-bridge controlCircuit twice, an alternative is to use an integra ted circuit (IC), which Provides more than one H-bridges. One such IC is L293D, which has 2 H-Bridges in it. It can supply 600Ma continuous and 1.2A peak Curren ts. It is suitable for switching applications up to 5 kHz. These Features make i t ideal for our application. Another option is to use IC L298, which can drive 2 A continually and 3A peak currents. The Diagram of L293D 74

is shown in Figure 2It can be observed from the figure that L293D has a similar configuration to the circuit in Figure 1 3) Motor Driver Connections: The motor driver requires 2 control inputs for each motor. Since we drive 2 motors, we need 4 controls 75

Inputs from the microcontroller. Since it has many pins which can be configured as outputs, there are many options for implementation.For example, in our robot the last 4 bits of Port B (RB4, RB5, RB6,RB7 - Pins 37 to 40) are used to contro l the rotation direction of the motors . The enable pins of the motor driver are connected to the PWM outputs of the microcontroller (Pins 16and 17). This is be cause, as was mentioned above, by changing the width of the pulse (implying chan ging the enable time of the driver) one can change the speed of the motor. The t ruth table for motor driver is as shown in Table II, where H = high, L = low, an d Z =high output impedance state. Since the motors are reverse aligned, in order to have the robot Move forward they must be configured such that one of them tu rns forward and the other one turns backward. In case of any requirement for the robot to move backward, it is sufficient to just reverse the TABLE II THE TRUTH TABLE OF THE MOTOR DRIVER input H L H L TABLE III DRIVER CONTROL INPUTS Directi on Forward Backward Input 1 H L Input 2 L H Input 3 L H Input 4 H L enable H H L L output H L z z Power supply 76

The power supply are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a part icular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D .C Power Supply For example a 5V regulated power supply system as shown below: Fig 22: Functional Block Diagram of Power supply Transformer: A transformer is an electrical device which is used to convert electrical power from one electrical circuit to another without change in frequency. Transformers convert AC electricity from one voltage to another with little loss of power. T ransformers work only with AC and this is one of the reasons why mains electrici ty is AC. Step-up transformers increase in output voltage, step-down transformer s decrease in output voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coi l is called the primary and the output coil is called the secondary. There is no 77

electrical connection between the two coils; instead they are linked by an alter nating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of tu rns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil w hich is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage. Fig 23: An Electrical Transformer Turns ratio = Vp/ VS = Np/NS Power Out= Power In VS X IS=VP X IP Vp = primary (input) voltage Np = number of turns on primary coi l Ip = primary (input) current RECTIFIER: A circuit, which is used to convert a.c to dc, is known as RECTIFIER. The proces s of conversion a.c to d.c is called rectification TYPES OF RECTIFIERS: Half wave Rectifier Full wave rectifier 1. Center tap full wave rectifier. 2. Bridge type full bridge rectifier. Comparison of rectifier circuits: 78

Type of Rectifier Parameter Number diodes PIV of diodes Vm D.C voltage Vdc, at n o-load Ripple factor Ripple frequency Rectification efficiency Transformer Utili zation Factor(TUF) RMS voltage Vrms output Vm/ 0.318Vm 1.21 f 0.406 0.287 Vm/2 2 Vm 2Vm/ 0.636Vm 0.482 2f 0.812 0.693 Vm/2 Vm 2Vm/ 0.636Vm 0.482 2f 0.812 0.812 Vm /2 of 1 2 3 Half wave Full wave Bridge Full-wave Rectifier: From the above comparisons we came to know that full wave bridge rectifier as mo re advantages than the other two rectifiers. So, in our project we are using ful l wave bridge rectifier circuit. Bridge Rectifier: A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and w ith single component bridges where the diode bridge is wired internally. A bridg e rectifier makes use of four diodes in a bridge arrangement as shown in fig(a) to achieve full-wave rectification. This is a widely used configuration, both wi th individual diodes wired as shown and with single component bridges where the diode bridge is wired internally. 79

Fig(24.A): Operation: During positive half cycle of secondary, the diodes D2 and D3 are in forward bia sed while D1 and D4 are in reverse biased as shown in the fig(b). The current fl ow direction is shown in the fig (b) with dotted arrows. Fig(24.B) During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward biased while D2 and D3 are in reverse biased as shown in the fig( c). The current flow direction is shown in the fig (c) with dotted arrows. Fig(24.C) 80

Filter: A Filter is a device, which removes the a.c component of rectifier output but al lows the d.c component to reach the load. Capacitor Filter: We have seen that the ripple content in the rectified output of half wave rectif ier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering: (a) A capa citor, in parallel to the load, provides an easier by pass for the ripples voltag e though it due to low impedance. At ripple frequency and leave the d.c.to appea rs the load. (b) An inductor, in series with the load, prevents the passage of t he ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c) (c) various combinations of capacitor and in ductor, such as L-section filter section filter, multiple section filter etc. wh ich make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier. Filtering is performed by a large value electrolytic capacitor conne cted across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charge s quickly near the peak of the varying DC, and then discharges as it supplies cu rrent to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = *3*f*r*Rl Where, f = supply frequency, r = ripple factor, 81

Rl = load resistance Note: In our circuit we are using 1000microfarads. Regulator: Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or varia ble output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulat ors include some automatic protection from excessive current ( overload protecti on ) and overheating ( thermal protection ). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regul ator shown on the right. The LM7805 is simple to use. You simply connect the pos itive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you tur n on the power, you get a 5 volt supply from the output pin. Fig 25: A Three Terminal Voltage Regulator 78XX: The Bay Linear LM78XX is integrated linear positive regulator with three termina ls. The LM78XX offer several fixed output voltages making them useful in wide ra nge of applications. When used as a zener diode/resistor combination replacement , the LM78XX usually results in an effective output impedance improvement of two orders of magnitude, lower quiescent current. The LM78XX is available in the TO -252, TO-220 & TO-263packages, Features: 82

Output Current of 1.5A Output Voltage Tolerance of 5% Internal thermal overload protection Internal Short-Circuit Limited No External Component Output Voltage 5 .0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V Offer in plastic TO-252, TO-220 & TO-26 3 Direct Replacement for LM78XX CIRCUIT DESCRIPTION: In this project, the GSM and GPS are connected to the micro controller. The GSM is used for sending, receiving and reading the messages. The GPS is used for get ting the location of the vehicle which sends the location name in the form of co ordinates ie., latitudes, longitudes and altitudes. These GSM and GPS are both m eant for serial communication. Both the GSM and GPS are RS voltage level compati ble but the Micro controller is TTL compatible. To match the voltage levels we u sing the MAX232 line driver to convert the RS voltage level to TTL voltage level s and vice versa. The controller is having one serial port. It is impossible to interface to two serial communication devices and access both at a time. So that , through Latch these devices are connected to the MAX. activated and vice versa . The ignition switch is used for starting/ stopping the engine i.e., nothing bu t a motor. This is operated through software, which is connected to one of the p ort pin. The LCD display will acts as an output source in this project that will be helpful to display the location name on this display. The RS, R/W. and EN pi ns are the control pins which are used for controlling purpose. The RS pin is us ed to select either data mode or command mode. The R/W is used to indicate that the LCD will acts as a either read or write mode. The EN pin is used to enable t he data. D0-D7 are data pins used to get the data from the micro controller. To operate the LCD display, which requires maximum of +5V DC power supply.The power supply is used drive all the hardware components, which are work at the maximum voltage of +5V DC. The 230V AC is a power supply which is used for operate our general home 83 The latch is acts to store the information temporarily. For acce ssing these devices, one is kept in sleep mode and the other

appliance. But our hardware components which requires just +5V DC voltage. A ste p-down transformer is used to step down the 230V AC to the required AC voltage a nd thereafter it is meant for filtering with the help of a capacitor. Thereby, t he circuit is meant for the regulation to get the constant +5V DC. This output + 5V DC power supply is getting at the load ie., may be a capacitor for rectificat ion purpose, ie., any AC ripples should be minimized with the help of this capac itor at the lo SOFTWARE USED Embedded C: Data Types: U people have already come across the word Data types in C- Language. Here also th e functionality and the meaning of the word is same except a small change in the prefix of their labels. Now we will discuss some of the widely used data types for embedded C- programming. Data Types unsigned char signed char unsigned int signed int sbit bit sfr Size in Bits 8-bit 8-bit 16-bit 16-bit 1-bit 1-bit 8-bit Data Range/Usage 0-255 -128 to +127 0 to 65535 -32,768 to +32,767 SFR bit addres sable only RAM bit addressable only RAM addresses 80-FFH only Unsigned char: The unsigned char is an 8-bit data type that takes a value in the range of 0255( 00-FFH). It is used in many situations, such as setting a counter value, where t here is no need for signed data we should use the unsigned char instead of the s igned char. Remember that C compilers use the signed char as the default if we d o not put the key word. 84

Signed char: The signed char is an 8-bit data type that uses the most significant bit (D7 of D7-D0) to represent the or + values. As a result, we have only 7 bits for the ma gnitude of the signed number, giving us values from -128 to +127. In situations where + and are needed to represent a given quantity such as temperature, the us e of the signed char data type is a must. Unsigned int: The unsigned int is a 16-bit data type that takes a value in the range of 0 to 6 5535 (0000-FFFFH).It is also used to set counter values of more than 256. We mus t use the int data type unless we have to. Since registers and memory are in 8-b it chunks, the misuse of int variables will result in a larger hex file. To over come this we can use the unsigned char in place of unsigned int. Signed int: Signed int is a 16-bit data type that uses the most significant bit (D15 of D15D 0) to represent the or + value. As a result we have only 15 bits for the magnitu de of the number or values from -32,768 to +32,767. Sbit (single bit): The sbit data type is widely used and designed specifically to access single bit addressable registers. It allows access to the single bits of the SFR registers . (II) I/O PROGRAMMING IN EMBEDDED C: In this topic we look at C- programming of the I/O ports and also both byte and bit I/O programming. 85

Byte size I/O As we know that ports P0-P3 are byte accessible, we use the P0-P3 labels as defined in the header file. Bit addressable I/O programming The I/O po rts of P0-P3 are bit- addressable, so we can access a single bit without disturb ing the rest of the port. We use the sbit data type to access a single bit of P0 -P3.the format is Px^y where x is the port and y is the bit. Accessing SFR addre sses 80-FFH Another way to access the SFR RAM space 80-FFH is to use the sfr dat a type. This is shown in the below example .Both the bit and byte addresses for the P0-P3 ports are given in the table. Notice in the given example that there i s no #include<reg51.h> statement which allows us to access any byte of the SFR R AM space 80-FFH. Single Bit Addresses of Ports P0 P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 Addr 80H 81H 82H 83H 84H 85H 86H 87H P1 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Addr 90H 91H 92H 93H 94H 95H 96H 97H P2 P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 P2.7 Addr A0H A1H A2H A3H A4H A5H A6H A7H P3 P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Addr B0H B1H B2H B3H B4H B5H B6H B7H Ports Bit D0 D1 D2 D3 D4 D5 D6 D7 (III) DATA CONVERTION PROGRAMS IN EMBEDDED C Many micro-controllers have a real time clock (RTC) where the time and date are kept even when the power is off. These time and date are often in packed BCD by 86

RTC. To display them they must be converted to ASCII. So, in this topic we are s howing application of logic and instructions in the conversion of BCD and ASCII. ASCII numbers On ASCII key boards, when the key 0 is activated, 0110000 (30h) is pr ovided to the system. Similarly 31h (0110001) is provided for the key 1, and so on as shown in the table Packed BCD to ASCII conversion The RTC provides the time of day (hour, minutes, seconds) and the date (year, month, day) continuously, re gardless of whether the power is ON or OFF. In the conversion procedure the pack ed BCD is first converted to unpacked BCD. Then it is tagged with 0110000 (30h). ASCII code for Digits 0-9 Key 0 1 2 3 4 5 6 7 8 9 ASCII (hex) 30 31 32 33 34 35 36 37 38 39 Binary 011 0000 011 0001 011 0010 011 0011 011 0100 011 0101 011 01 10 011 0111 011 1000 011 1001 BCD (unpacked) 0000 0000 0000 0001 0000 0010 0000 0011 0000 0100 0000 0101 0000 0110 0000 0111 0000 1000 0000 1001 ASCII to packed BCD conversion To convert ASCII to packed BCD it is first conver ted to unpacked and then combined to make packed BCD. For example 4 and 7 on the keyboard give 34h and 37h respectively the goal is to produce 47h or 0100 0111 wh ich is packed BCD. 87

Key 4 7 ASCII 34 37 unpacked BCD 00000100 00000111 packed BCD 01000111 or 47h Checksum byte in ROM To ensure the integrity of ROM contents, every system must perform the checksum calculation. The process of checksum will detect any corrup tion of the contents of ROM. One of the cause of the ROM corruption is current s urge either when the system is turned on or during operation. To ensure data int egrity in ROM the checksum process uses, what is a checksum byte. There is an ex tra byte that is tagged to the end of the series of data. To calculate the check sum byte of a series of bytes of data, the following steps can be used 1) Add th e bytes together and drop the carries. 2) Take the 2s complement of the total sum . This is the checksum byte , which becomes the last byte of the series Binary (hex) to decimal and ASCII conversion in embedded C In C-language we use a function call printf which is standard IO library function doing the conversions of data from binary to decimal, or vice versa. But here we are using our own functions for conversions because it occupies much of memory. One of the most commonly used is binary to decimal conversion. In devices such as ADC chips the data is provided to the controller in binary. In order to displ ay binary data we need to convert it to decimal and then to ASCII. Since the hex adecimal format is a convenient way of representing binary data we refer to bina ry data as hex. The binary data 00-FFH converted to decimal will give us 000 to 255. 88

One way to do this is to divide it by 10 and keep the remainder, for example 111 11101 or FDH is 253 in decimal. The following is one version of the algorithm fo r conversion of hex (binary) to decimal. Quotient FD/0A 19/0A 19 2 Remainder 3(l ow digit) LSD 5(middle digit) 2(high digit) (MSD) ABOUT SOFTWARE Softwares used a re: *Keil software for c programming *Express PCB for lay out design *Express SC H for schematic design What s New in Vision3? Vision3 adds many new features to th e Editor like Text Templates, Quick Function Navigation, and Syntax Coloring wit h brace high lighting Configuration Wizard for dialog based startup and debugger setup. Vision3 is fully compatible to Vision2 and can be used in parallel with Vis ion2. What is Vision3? Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the foll owing components: A project manager. A make facility. Tool configuration. Editor . A powerful debugger. To help you get started, several example programs (located in the \C51\Examples, \C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided. HELLO is a simple program that prints the string "Hello World" using the Serial Interface. MEASURE is a data acquisition system for analog and digital systems. 89

TRAFFIC is a traffic light controller with the RTX Tiny operating system. SIEVE is the SIEVE Benchmark. DHRY is the Dhrystone Benchmark. WHETS is the Single-Pre cision Whetstone Benchmark. Additional example programs not listed here are provided for each device archite cture. Building an Application in Vision2 To build (compile, assemble, and link) an application in Vision2, you must: 1. Select Project -(forexample,166\EXAMPLES\ HELLO\HELLO.UV2). 2. Select Project - Rebuild all target files or Build target. V ision2 compiles, assembles, and links the files in your project. Creating Your Own Application in Vision2 To create a new project in Vision2, you m ust: 1. Select Project - New Project. 2. Select a directory and enter the name o f the project file. 3. Select Project - Select Device and select an 8051, 251, o r C16x/ST10 device from the Device Database. 4. Create source files to add to the project. 5. Select Project - Targets, Groups, Files. Add/Files, select Source G roup1, and add the source files to the project. 6. Select Project - Options and set the tool options. Note when you select the target device from the Device Dat abase all special options are set automatically. You typically only need to confi gure the memory map of your target hardware. Default memory model settings are o ptimal for most applications. 7. Select Project - Rebuild all target files or Bu ild target. Debugging an Application in Vision2 To debug an application created u sing Vision2, you must: 1. Select Debug - Start/Stop Debug Session. 2. Use the St ep toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function. 90

3. Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using standard options like Step, Go, Break, and so on. Starting Vision2 and Creating a Project Vision2 is a standard Windows application and started by c licking on the program icon. To create a new project file select from the Vision2 menu. Project New Project. This opens a standard Windows dialog that asks you fo r the new project file name. We suggest that you use a separate folder for each project. You can simply use the icon Create New Folder in this dialog to get a n ew empty folder. Then select this folder and enter the file name for the new pro ject, i.e. Project1. Vision2 creates a new project file with the name PROJECT1.UV 2 which contains a default target and file group name. You can see these names i n the Project. Window Files. Now use from the menu Project Select Device for Tar get and select a CPU for your project. The Select Device dialog box shows the Vis ion2 device database. Just select the micro controller you use. We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary tool optio ns for the 80C51RD+ device and simplifies in this way the tool Configuration. Bu ilding Projects and Creating a HEX Files Typical, the tool settings under Option s Target are all you need to start a new application. You may translate all sour ce files and line the application with a click on the Build Target toolbar icon. When you build an application with syntax errors, Vision2 will display errors an d warning messages in the Output Window Build page. A double click on a message line opens the source file on the correct location in a Vision2 editor window. On ce you have successfully generated your application you can start debugging. Aft er you have tested your application, it is required to create an Intel HEX file to download the software into an EPROM programmer or simulator. Vision2 creates H EX files with each build process when Create HEX files under Options for Target Output is enabled. You may start your PROM programming utility after the make pr ocess when you specify the program under the option Run User Program #1. CPU Sim ulation 91

Vision2 simulates up to 16 Mbytes of memory from which areas can be mapped for re ad, write, or code execution access. The Vision2 simulator traps and reports ille gal memory access. In addition to memory mapping, the simulator also provides su pport for the integrated peripherals of the various 8051 derivatives. The on-chi p peripherals of the CPU you have selected are configured from the Device. Datab ase selection you have made when you create your project target. Refer to page 5 8 for more Information about selecting a device. You may select and display the on-chip peripheral components using the Debug menu. You can also change the aspe cts of each peripheral using the controls in the dialog boxes. Start Debugging Y ou start the debug mode of Vision2 with the Debug Start/Stop Debug Session comman d. Depending on the Options for Target Debug Configuration, Vision2 will load the application program and run the startup code Vision2 saves the editor screen lay out and restores the screen layout of the last debug session. If the program exe cution stops, Vision2 opens an editor window with the source text or shows CPU in structions in the disassembly window. The next executable statement is marked wi th a yellow arrow. During debugging, most editor features are still available. F or example, you can use the find command or correct program errors. Program sour ce text of your application is shown in the same windows. The Vision2 debug mode differs from the edit mode in the following aspects: _ The Debug Menu and Debug C ommands described on page 28 are Available. The additional debug windows are disc ussed in the following. _ The project structure or tool parameters cannot be mod ified. All build Commands are disabled. Disassembly Window The Disassembly windo w shows your target program as mixed source and assembly program or just assembl y code. A trace history of previously executed instructions may be displayed wit h Debug View Trace Records. To enable the trace history, set Debug Enable/Disabl e Trace Recording. 92

If you select the Disassembly Window as the active window all program step comma nds work on CPU instruction level rather than program source lines. You can sele ct a text line and set or modify code breakpoints using toolbar buttons or the c ontext menu commands. You may use the dialog Debug Inline Assembly to modify the CPU instructions. That allows you to correct mistakes or to make temporary chang es to the target program you are debugging. Steps for executing the Keil programs: 1. 2. Click on the Keil uVision Icon on Desktop The following fig will appear 3. 4. Click on the Project menu from the title bar Then Click on New Project 93

5. Save the Project by typing suitable project name with no extension in u r own fo lder sited in either C:\ or D:\ 6. 7. 8. Then Click on Save button above. Select the component for u r project. i.e. Atme l Click on the + Symbol beside of Atmel 94

9. Select AT89C51 as shown below 10. 11. Then Click on OK The Following fig will appear 95

12. 13. 14. Then Click either YES or NOmostly NO Now your project is ready to USE Now double clic k on the Target1, you would get another option Source group 1 as shown in next pag e. 15. Click on the file option from menu bar and select new 96

16. The next screen will be as shown in next page, and just maximize it by double cl icking on its blue boarder. 17. 18. Now start writing program in either in C or ASM For a program written in Assembly, t hen save it with extension . asm and for C based program save it with extension .C 97

19. Now right click on Source group 1 and click on Add files to Group Source 20. Now you will get another window, on which by default C files will appear. 98

21. 22. 23. Now select as per your file extension given while saving the file Click only one time on option ADD Now Press function key F7 to compile. Any error will appear if so happen. 24. 25. If the file contains no error, then press Control+F5 simultaneously. The new win dow is as follows 99

26. 27. Then Click OK Now Click on the Peripherals from menu bar, and check your required port as shown in fig below 28. Drag the port a side and click in the program file. 100

29. 30. Now keep Pressing function key F11 slowly and observe. You are running your progra m successfully Source Code 101

#include<reg51.h> #include<GSM_init.h> unsigned char L,Lg[12],key,x[4],Po,count, z; bit f2,f3,f4,f5; sbit IOE1=P3^7; sbit IOE2=P3^6; sbit m1=P1^0;sbit m2=P1^1;sb it m3=P1^2;sbit m4=P1^3; sbit as=P3^2;sbit cs=P1^7;sbit ent=P3^3; sbit inc=P3^4; sbit dec=P3^5; void main(void); void serial(void) interrupt 4 using 1 { if(RI) { a[i]=SBUF; RI=0; if(SBUF=='*') { f2=1; EA=0; } i++; if(SBUF=='$') { i=0; } } } void clear() { for(i=0;i<42;i++) { a[i]='\0'; } } GPS_track() { IOE1=1; IOE2=0; ES=1; cmd(0x80); 102

l1: sconf1(); EA=1; delay(50); EA=0; if(a[0]=='G' && a[1]=='P' && a[2]=='G' && a[3]= ='G' && a[4]=='A' && a[27]=='N') { goto l2; } else { clear(); EA=1; goto l1; } l 2: cmd(0x01); cmd(0x80); for(i=6;i<22;i++) { DT(a[i]); } cmd(0xc0); for(i=22;i<3 8;i++) { DT(a[i]); } Po=0; for(i=17;i<29;i++) { Lg[Po]=a[i];Po++; } IOE1=0; IOE2 =1; GSM_setup(); EA=0; serial_tx("AT+CMGS="); serial_tx1(0x22); serial_tx("+9191 77212213"); serial_tx1(0x22); serial_tx1(0x0d); delay(10); serial_tx("Logitude:" ); for(i=0;i<4;i++) { serial_tx1(Lg[i]); 103

} serial_tx(" Latitude:"); for(i=5;i<11;i++) { serial_tx1(Lg[i]); } serial_tx1(0 x1a); cmd(0x01); DTS("msg sent"); for(i=0;i<42;i++) { a[i]='\0'; } EA=1; cmd(0x0 1);cmd(0x80);DTS("welcome"); } void start() { m1=1;m2=0;m3=1;m4=0; } void stop() { m1=1;m2=1;m3=1;m4=1; } void main() { IOE1=0; IOE2=1; GSM_setup(); L=0;f2=0;f3 =0;f4=0;f5=0;key=0; while(1) { EA=1;count=0;cmd(0x01); key=0;Po=0; goto j2; j1: key=0;Po=0; cmd(0x80);DTS("Password :"); j2: if(ent==0) { while(ent==0); 104

while(count<2 && f4==1) { cmd(0x80); DTS("Password :"); cmd(0x8a+Po); DT(key+0x3 0); if(inc==0) { while(inc==0); if(key<9 && key>=0) { key++; } else { key=0; } } else if(dec==0) { while(dec==0); if(key<9 && key>0) { key--; } else { key=0; } } else if(ent==0) { while(ent==0); key=0; Po++; } x[Po]=key+0x30; if(Po>=4) { if (x[0]=='1' && x[1]=='2' && x[2]=='3' && x[3]=='4') { 105

cmd(0x01);cmd(0xc0);DTS("correct pass u can"); delay(100); cmd(0x01);delay(10);f 4=0;f3=0; count=0; } else { cmd(0x01);cmd(0xc0);DTS("incorrect pass pls try"); c ount++;a[4]="";key=0; delay(10);cmd(0x01); goto j1; } } } } if(count>=2) { cmd(0 x01);cmd(0x80);DTS("Due to wrong pass"); cmd(0xc0);DTS("Vehicle P blocked"); whi le(1) ; } if(cs==0 && as==1 && f3==0) { start(); cmd(0x01);cmd(0x80);DTS("vehicl e is going"); } else { stop(); if(as==0) { f3=1; cmd(0x01);cmd(0x80);DTS("vehicl e is crashed"); EA=0; serial_tx("AT+CMGS="); serial_tx1(0x22); serial_tx("+91917 7212213"); 106

serial_tx1(0x22); serial_tx1(0x0d); delay(10); serial_tx(" ur vehicle is crashed "); serial_tx1(0x1a); //clear(); i=0; delay(100); EA=1; f1=wait(); if(f1!=1) { g oto intim; } f1=0; clear();L=0;i=0; GPS_track(); } } while(f2==1) { i=0; cmd(0x0 1);cmd(0xC0); while(a[i]!='#') { i++ ; } z=i; for(i=z+1;a[i]!='*';i++) { DT(a[i] ); } delay(300); if(a[z+1]=='B' && a[z+2]=='L' && a[z+3]=='O' && a[z+4]=='C' && a[z+5]=='K' && a[z+6]=='*') { cmd(0x01);cmd(0x80);DTS("vehicle is blocked"); del ay(300); stop(); 107 // // // // // //

f3=1;f4=1; } else if(a[z+1]=='T' && a[z+2]=='R' && a[z+3]=='A' && a[z+4]=='C' && a[z+5]=='K' && a[z+6]=='*') { cmd(0x01);cmd(0x80);DTS("vehicle is Tracking"); d elay(200);cmd(0x01);clear(); GPS_track(); f1=0; } i=0;z=0; for(i=0;i<43;i++) { a [i]='\0'; } f2=0; EA=1; } cmd(0x01);cmd(0xc0);DTS("Waiting for mess"); } } 108

Conclusion The project DESIGN & DEVELOPMENT OF GSM & GPS BASED VEHICLE THEFT CONTROL SYSTEM h as been successfully designed and tested. Integrating features of all the hardwa re components used have developed it. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. Sec ondly, using highly advanced ICs and with the help of growing technology the proj ect has been successfully implemented. Future Aspects In this project, we are taking the action after the vehicle is thefting. If at a ll, we provide some of the authentication before operating the vehicle so that w e can prevent the vehicle thefting at the starting itself. The authentication ma y be either the RFID or smart card or a finger print module. By adding the authe ntication to this project, there we should provide more security to this project . 109

Bibliography The 8051 Micro controller and Embedded Systems -Muhammad Ali Mazidi Janice Gilli spie Mazidi The 8051 Micro controller Architecture, Programming & Applications Kenneth J.Ayala Fundamentals of Micro processors and Micro computers -B.Ram Micr o processor Architecture, Programming & Applications -Ramesh S.Gaonkar Electroni c Components -D.V.Prasad Wireless Communications - Theodore S. Rappaport Mobile Tele Communications - William C.Y. Lee References on the Web: www.national.com w ww.atmel.com www.microsoftsearch.com www.geocities.com http://tycho.usno.navy.mi l/gpscurr.html 110

Anda mungkin juga menyukai