You are on page 1of 84
ACKNOWLEDGEMENT We owe a great many thanks to a great many people who helped and supported me during the making of this project report. Our deepest thanks to Prof. Mehul C. Patel,(Guide of our project) for providing proper guidance. He has taken pain to go through the project and make necessary suggestions as and when needed. We also express our thanks to Dr. Suprvava Patnaik, Head of the Electronics Engineering Department, SVNIT Surat , for extending her support. We would also thank other faculty members without whom this project would have been a distant reality. We also extend our heartfelt thanks to my family and well wishers. Avinash Kumar U08EC347 Mitendra Kumar U08EC350 Alok Kumar U08EC351 ABSTRACT If navigational data of a remote object can be sent over the air, then very powerful monitoring systems of immense utility can be designed. Our project work aims to achieve this by bringing together technologies like GPS and GSM. These modules are interfaced using high performance ARM9 application domain processor. The data sent by remote object include current location in terms of coordinates, height, and speed each with chosen time interval. SMS Service is used to send the data automatically to control centre. The control center can be where. The final system will consist of a remote object having U-Blox GPS modem, SAMSUNG S3C2440 ARM920T running Embedded Linux and SIM300 GSM modem while the monitoring station will be having GSM terminal. This system is of immense utitility in many fields like surveying, spying, tracking etc. Table of Contents  List of Figures iii  List of Tables iv 1. Introduction 01 1.1 Motivation 01 1.2 Overview of Project 02 1.3 Implementation Scheme 03 2. ARM9 MCU 04 2.1 Registers 04 2.2 Processor Modes 05 2.3 ARM Instruction Set 06 3. Embedded Linux 10 3.1 Introduction 10 3.2 Generic architecture 10 3.3 System Start up 13 3.4 System Memory Layout 15 3.5 Configuring and Compiling The Bootloader 17 3.6 Configuring and Compiling The Kernel 18 3.7 Configuring and Compiling The Rootfile system 20 3.8 Hardware Description of ARM9 Board 21 3.9 ARM9 Board Module Detail 21 4. GSM Receiver 24 4.1 Introduction 27 4.2 GSM Modem 28 4.3 GSM Kit 32 4.4 Power Supply 32 4.5 Dual Serial Interface 34 4.6 Indicator 37 4.7 Antenna Interface 38 5. GPS System 40 5.1 Why GPS 40 5.2 Generating GPS Signal Transit Time 41 5.3 Determining The Position in 3-D 42 5.4 Description of The entire System 43 i 5.5 The GPS navigation Message 49 5.6 Information Contained in The subframe 50 5.7 Calculating Position 51 5.8 GPS Receiver 55 5.9 Basic Design of GPS Module 58 5.10 NMEA Data Interface 59 6. Algorithm and Results 65 6.1Algorithm 66 6.2Results 66 6.3Application 71 7. Conclusion 73  List of References 74  List of Acronyms 76 ii List of Figures 1. Fig. 1.1 The Remote Object 02 2. Fig. 1.2 The Monitoring Station 03 3. Fig. 2.1 CPSR 04 4. Fig. 2.2 Processor Modes and registers 05 5. Fig. 2.3 ARM Instruction Format 06 6. Fig. 3.1 Architecture of generic Linux system 11 7. Fig. 3.2 System start up scenario 13 8. Fig. 3.3 Physical and virtual memory map for Compaq iPAQ 17 9. Fig. 3.4 Configuring and compiling the kernel 19 10. Fig. 3.5 Configuring and compiling the rootfile system using ptxdist 21 11. Fig. 3.6 ARM9 board 22 12. Fig. 3.7 ARM9 block diagram 23 13. Fig. 3.8 Circuit diagram of system reset 24 14. Fig. 3.9 Block diagram of serial ports of UART 25 15. Fig. 3.10 Circuit diagram of LCD interface 26 16. Fig. 4.1 GSM modem 30 17. Fig .4.2 Block diagram of GSM modem 31 18. Fig. 4.3 VBAT input 33 19. Fig. 4.4 Interfacing of serial port 35 20. Fig. 4.5 SIM interface circuit 37 21. Fig. 5.1 GPS satellite orbit to earth on 6 orbit plane 41 22. Fig. 5.2 Four satellites are required to determine a position in 3-D 42 23. Fig. 5.3 GPS segments 43 24. Fig. 5.4 Simplified satellite block diagram 46 25. Fig 5.5 Data structure of GPS satellite 46 26. Fig. 5.6 Measuring signal transit time 48 27. Fig. 5.7 Structure of entire navigation message 51 iii 28. Fig. 5.8 Four satellite signal must be received 52 29. Fig. 5.9 3-D coordinate system 53 30. Fig. 5.10 Smart GPS receiver 55 31. Fig. 5.11 Simplified block diagram of GPS receiver 56 32. Fig. 5.12 Typical block diagram of GPS 57 33. Fig. 6.1 Algorithm 65 34. Fig. 6.2 Snapshots of Location A 66 35. Fig. 6.3 Snapshots of Location B 67 36. Fig. 6.4 Message received at GSM Terminal 68 37. Fig. 6.5 Messages received at GSM Terminal when connected to pc 69 38. Fig. 6.6 Raw NMEA Data on minicom 70 39. Fig. 6.7 AVL Application 71 40. Fig. 6.8 Applicatoin in Science and Research 72 iv List of Tables 1. Table 2.1 Vector Table 07 2. Table 2.2 ARM Instructions 08 3. Table 4.1 GSM Technical Specifications 22 4. Table 4.2 AT Commands 24 5. Table 4.3 Logic Level of Port pins 34 6. Table 4.4 Signal of SIM Interface 36 7. Table 4.5 Working State of Network Status indicator 38 8. Table 5.1 Carrier Link Budget Analysis 44 9. Table 5.2 Causes of Error 52 10. Table 5.3 NMEA Data 61 11. Table 5.4 GGA Data 62 12. Table 5.5 GLL Data 63 13. Table 5.6 GSA Data 64 v Introduction Chapter-1 1.1 Motivation With the advent of satellite navigation systems like GPS (Global Position System), GLONASS and Galileo etc., it has become possible to track the position of any object having such systems. Concept of localizing or determining position of an object has been popular since ancient times. Earlier voyagers used magnetic compass for navigation purposes. It gave information about the directions with certain accuracy but localizing the position of object was still a distant reality. Now the navigations systems are used at many places for example in cars, military, engineering surveys and the list goes on. The advent use of navigation can be combined with modern day wireless communication services to yield a very useful application. It can be used to send the position of an object to a distant location. So it becomes possible to monitor the position of a remote object. This opens a wide door of possibilities for new and exciting applications. Surveillance, Vehicle Location Information, Location Based Services can be provided with considerable ease. The remote monitoring systems become all the more useful if we use brute computing capabilities of monitoring stations to calculate various other parameters related to remote object. For example it is possible to record the path taken by a remote object (call it path tracing), or for calculating speed of the object over long period of time, or for sounding a alarm when the object approaches restricted regions. Hence it depends on monitoring stations what kind of services they want to implement. So there can be innumerous applications for a tracking system, that the reason for implement the AVL. Throughout the thesis the AVL system has been explained. 1 1.2 Overview of Project The Automatic Vehicle Locating System can be broadly divided into two parts  The remote object  The monitoring station The remote object is the object whose location is to be monitored. In this thesis considered it to be a vehicle. The remote object should consist of some kind of navigation system, which would help to localize the position of the object. Further it should also contain some form of communication equipment, preferably wireless. And at last there must be some kind of controller which co-ordinates the operation of the navigation systems and communication equipment. Navigation Controller Communication System Equipment Fig. 1.1 The Remote Object Similarly the monitoring station should be equipped with a communication equipment to receive the location data from the remote object. Further the station must contain a computing device which can calculate and interpret the location data and provide it to the user in a comprehensive manner. For example if the user wants the output on map then co-ordinates obtained or calculated must be represented on map. Also note that monitoring station need not be 'fixed'. There is no reason to place such a restriction, after all as long as communicating equipment of the remote object and the monitoring stations are connected it doesn't matter where a monitoring station is located. This opens a new possibility of a portable monitoring station. 2 Communication Computing OUTPUT Equipment Device Fig. 1.2 The Monitoring Station 1.3 Implementation Scheme Until now showing the blocks of AVL conceptually. But real physical implementation requires far more complexity. How this functionality achieve that is shown conceptually in the previous section. We start with the remote object. To localize the position of the object we have decided to use GPS (Global Positioning System). Further GPS provides many advantages over other navigation systems [1].We have used a GPS modem with a RS-232 interface provided by MikroElektronika™. Since wireless communication between the remote object and monitoring station is desirable we need to ensure a robust and secure connection mechanism. Hence GSM becomes an obvious candidate. So a GSM modem with RS-232 interface provided by SciTech has been employed in this project. Finally we need a high performance microcontroller to perform the control operations. Since a we have to complex tasks of handling GPS calculations and GSM modem control, ARM9 MCU provide by SAMSUNG is used. At the monitoring station, a GSM modem. The computing device for interpreting the received data can be either a computer or another ARM9 MCU. It depends on whether we want portable or fixed monitoring stations. Finally we have used LCD display to display the final result in a comprehensive format. Although there is possibility to use either SMS or GPRS to transfer the remote object data, we have decided to implement the system initially using the SMS. This is mainly because of bulk SMS service is available at a low cost. Now that we have shown the role of various modules in our project, we will see a detailed description of each of the modules. 3 ARM9 MCU Chapter-2 ARM also known as Advanced RISC Machine was setup in 1990 as a joint venture of Apple Computer, VLSI Technology and Ascorn Computer. ARM develops the ARM processor cores and debug systems. But the complete microcontroller includes a number of other components like memory, peripherals, I/O subsystems other features. ARM provides licenses to chip manufacturers like NXP, Atmel, Sharp, ST Microelectronics. These silicon vendors design the complete SOC-MCU. In this chapter summarized ARM9 MCU from a programmer's point of view only [2],[3]. 2.1 Registers ARM is a load and store architecture, so all data processing instructions can only work on register file. There are 16 user registers: R0-R15. All of them are 32-bit registers. R0- R12 are used as general purpose registers. R13 is Stack Pointer and R14 is link register. Link registers are used to store return address during branching instructions. R15 is the program counter. CPSR is the current program status register. Its bits are shown in the "Figure 2.1". Fig. 2.1 CPSR Current program status register [2] N,Z,C,V are negative, zero, carry, overflow flags. They are updated only for certain type of instructions. I and F bit have the capability to mask the interrupts and fast interrupts respectively. If T bit is set then processor has entered Thumb mode and hence can only 4 executed 16-bit thumb instructions. Last 5 bits are used to indicate the current mode of the processor [3]. 2.2 Processor Modes There 7 processor modes supported in ARM. These are System mode, User mode, Supervisor mode, Interrupt mode, Fast interrupt mode, Abort mode and Undefined mode. Except the user mode all other modes are privileged modes and hence can change CPSR. Supervisor mode is generally employed for RTOS and user mode for application programs. Rest of the modes are used for exception handling. Each mode is having its own stack pointer (SP), SPSR, and link register (LR). In FIQ additionally R7-R12 are banked. Fig. 2.2 Processor Modes and registers [4] When an exception occurs than a processor is forced to change mode and PC loaded with vector table address as shown in "Figure 2.3". 5 Table 2.1 Vector Table [4] EXCEPTION MODE ADDRESS Reset Supervisor 0x00000000 Undefined instruction undefined 0x00000004 Software interrupt Supervisor 0x00000008 Prefetch about (instruction fetch Abort 0x0000000C memory about ) Data Abort(data access memory abort) Abort 0x000000010 IRQ (Interrupt) IRQ 0x00000018 FIQ (fast interrupt) 0x0000001C Out of the given exceptions, Software interrupt is of special interest because it is used to change the mode from user mode to supervisor mode and hence can be used to implement RTOS services. Interrupt and Fast interrupt are used to handle asynchronous events like peripheral interrupts [3]. 2.3 ARM Instruction Sets In ARM mode, all the instructions can be executed conditionally. Also CPSR flag is optionally updated with instructions. This not only helps to reduce un-necessary branching (which causes pipeline flush) but also helps to implement complex logic. Fig. 2.3 ARM Instruction Format [4] List of ARM Instructions are given categorically in "Table 2.1". For details of syntax [2]. 6 Table 2.2 ARM Instructions [5] Instruction Functions Instruction Type Move MOV Move NOT MVN Move SPSR to register MRS Move CPSR to register MRS Move Move register to SPSR MSR Move register to CPSR MSR Move immediate to SPSR flags MSR Move immediate to CPSR flags MSR Add ADD Add with carry ADC Subtract SUB Subtract with carry SBC Subtract reverse subtract RSB Subtract reverse subtract with carry RSC Arithmetic Multiply MUL Multiply accumulate MLA Multiply unsigned long UMULL Multiply unsigned accumulate long UMLAL Multiply signed long SMULL Multiply signed accumulate long SMLAL Compare CMP 7 Compare negative CMN Test TST Test equivalence TEQ AND AND Logical EOR EOR ORR ORR Bit clear BIC Branch B Branch Branch with link BL Branch and exchange instruction set BX Word LDR Word with user-mode privilege LDR Byte LDR Byte with user-mode privilege LDR Byte signed LDR Halfword LDR Halfword signed LDR Load Multiple block data operations -  Increment before LDMIB  Increment after LDMIA  Decrement before LDMDB  Decrement after LDMDA  Stack operation full LDMFD(A) 8  Stack operation empty LDMED(A) Word STR Word with user-mode privilege STRT Byte STRB Byte with user-mode privilege STRBT Halfword STRH Multiple block data operations - Store  Increment before STMIB  Increment after STMIA  Decrement before STMDB  Decrement after STMDA  Stack operation full STMFD(A)  Stack operation empty STMED(A) Word SWP Swap Byte SWPB Software Interrupt SWI interrupt 9 EMBEDDED LINUX CHAPTER-3 3.1 INTRODUCTION Linux is interchangeably used in reference to the Linux kernel, a Linux system, or a Linux distribution. Strictly speaking, Linux refers to the kernel maintained by Linus Torvalds and distributed under the same name through the main repository and various mirror sites. This codebase includes only the kernel and no utilities whatsoever. The kernel provides the core system facilities. It may not be the first software to run on the system, as a bootloader may have preceded it, but once it is running, it is never swapped out or removed from control until the system is shut down. In effect, it controls all hardware and provides higher-level abstractions such as processes, sockets, and files to the different software running on the system. An embedded Linux system simply designates an embedded system based on the Linux kernel and does not imply the use of any specific library or user tools with this kernel. An embedded Linux distribution may include: a development framework for embedded linux systems, various software applications tailored for usage in an embedded system, or both. Development framework distributions include various development tools that facilitate the development of embedded systems. This may include special source browsers, cross- compilers, debuggers, project management software, boot image builders, and so on. These distributions are meant to be installed on the development host. Tailored embedded distributions provide a set of applications to be used within the target embedded system. This might include special libraries, executables, and configuration files to be used on the target. A method may also be provided to simplify the generation of root file systems for the target system. 3.2 Generic Architecture of Embedded Linux Systems Immediately above the hardware sits the kernel. The kernel is the core component of the operating system. Its purpose is to manage the hardware in a coherent manner while 10 providing familiar high-level abstractions to user-level software. As with other Unix-like kernels, Linux drives devices, manages I/O accesses, controls process scheduling, enforces memory sharing, handles the distribution of signals, and tends to other administrative tasks. It is expected that applications using the APIs provided by a kernel will be portable among the various architectures supported by this kernel with little or no changes. This is usually the case with Linux, as can be seen by the body of applications uniformly available on all architectures supported by Linux. Fig. 3.1 Architecture of a generic Linux system[19] Within the kernel, two broad categories of layered services provide the functionality required by applications. The low-level interfaces are specific to the hardware configuration on which the kernel runs and provide for the direct control of hardware resources using a hardware-independent API. That is, handling registers or memory pages will be done differently on a PowerPC system and on an ARM system, but will be accessible using a common API to higher-level components of the kernel, albeit with some rare exceptions. Typically, low-level services will handle CPU-specific operations, architecture specific memory operations, and basic interfaces to devices Above the low-level services provided by the kernel, higher-level components provide the abstractions common to all Unix systems, including processes, files, sockets, and signals. Since the low-level APIs provided by the kernel are common among different 11 architectures, the code implementing the higher-level abstractions is almost constant regardless of the underlying architecture. There are some rare exceptions, as stated above, where the higher-level kernel code will include special cases or different functions for certain architectures. Between these two levels of abstraction, the kernel sometimes needs what could be called interpretation components to understand and interact with structured data coming from or going to certain devices. Filesystem types and networking protocols are prime examples of sources of structured data the kernel needs to understand and interact with to provide access to data going to and coming from these sources. During its normal operation, the kernel requires at least one properly structured filesystem, the root filesystem. It is from this filesystem that the kernel loads the first application to run on the system. It also relies on this filesystem for future operations such as module loading and providing each process with a working directory. The root filesystem may either be stored and operated on from a real hardware storage device or loaded into RAM during system startup and operated on from there. As we'll see later, the former is becoming much more popular than the latter with the advent of facilities such as the JFFS2 filesystem. Services exported by the kernel are often unfit to be used directly by applications. Instead, applications rely on libraries to provide familiar APIs and abstract services that interact with the kernel on the application's behalf to obtain the desired functionality. The main library used by most Linux applications is the GNU C library. For embedded Linux systems, substitutes to this library can be used, as we'll see later, to compensate for the GNU C library's main deficiency, its size. Other than the C library, libraries such as Qt, XML, or MD5 provide various utility and functionality APIs serving all sorts of purposes. Libraries are typically linked dynamically with applications. That is, they are not part of the application's binary, but are rather loaded into the application's memory space during application startup. This allows many applications to use the same instance of a library instead of each having its own copy. The C library found on a the system's filesystem, for instance, is loaded only once in the system RAM, and this same copy is shared among all applications using this library. But note that in some situations in embedded systems, 12 static linking, whereby libraries are part of the application's binary, is preferred to dynamic linking. When only part of a library is used by one or two applications, for example, static linking will help avoid having to store the entire library on the embedded system's storage device. 3.3 System Start-up Three main software components participate in system startup: the bootloader, the kernel, and the init process. The bootloader is the first software to run upon startup and is highly dependent on the target's hardware. The bootloader will conduct low-level hardware initialization and thereafter jump to the kernel's startup code. Fig. 3.2 System Start-up Scenario[20] Embedded Linux systems are as diverse as their non-Linux counterparts. Embedded Linux systems are characterized, nevertheless, by the requirement to load a Linux kernel and its designated root filesystem. How these are loaded and operated, largely depends on the system's requirements and, sometimes, on the state of its development. There are three different setups used to bootstrap an embedded Linux system: the solid state storage media setup, the disk setup, and the network setup. Each setup has its own typical configurations and uses. 13 When power is applied to the ARM9 board, Bootlaoder (U-Boot in our case) performs some low level hardware initialization, which includes configuring a serial port. It then prints a banner line. Next the CPU and core are displayed, followed by some configuration data describing clocks and cache configuration. This is followed by a text string describing the board. When the initial hardware configuration is complete, U-Boot configures any hardware subsystems as directed by its static configuration. Here we see I2C, DRAM, FLASH, L2 cache, PCI, and network subsystems being configured by U-Boot. Finally, U-Boot waits for input from the console over the serial port, as indicated by the MINI2440# prompt. Now U-Boot can load the kernel image into RAM from either persistent storage medium like NAND, SD-CARD or even USB-Stick or network like Ethernet over tftp. After bootm command can be given to U-Boot. This will pass on kernel parameters to kernel and give control to kernel. This marks the end of the bootloader. This is an important concept. Unlike the BIOS in a desktop PC, most embedded systems are architected in such a way that when the Linux kernel takes control, the bootloader ceases to exist. The kernel claims any memory and system resources that the bootloader previously used. The only way to pass control back to the bootloader is to reboot the board. When the Linux kernel begins execution, it spews out numerous status messages during its rather comprehensive boot process. During this step Kernel loads the device drivers and other daemons required for system managements. Shortly before issuing a login prompt on the serial terminal, Linux mounts a rootfile system. The root file system contains the application programs, system libraries, and utilities that make up a Linux system. Note that Linux can mount a root file system from other devices. The most common, of course, is to mount a partition from a hard drive as the root file system, as is done on your Linux laptop or workstation. But in our resource limited system kernel loads the filesystem from SD-Card. However note that even non persistent storage like network file system (NFS) could be used. It is common during development phase but not employed in final systems. 14 Until this point, the kernel itself was executing code, performing the numerous initialization steps in a context known as kernel context. In this operational state, the kernel owns all system memory and operates with full authority over all system resources. The kernel has access to all physical memory and to all I/O subsystems. It executes code in kernel virtual address space, using a stack created and owned by the kernel itself. When the Linux kernel has completed its internal initialization and mounted its root file system, the default behavior is to spawn an application program called init. When the kernel starts init, it is said to be running in user space or user space context. In this operational mode, the user space process has restricted access to the system and must use kernel system calls to request kernel services such as device and file I/O. These user space processes, or programs, operate in a virtual memory space picked at random6 and managed by the kernel. The kernel, in cooperation with specialized memory management hardware in the processor, performs virtual-to-physical address translation for the user space process. The single biggest benefit of this architecture is that an 6 It’s. error in one process can’t trash the memory space of another. This is a common pitfall in legacy embedded OSs that can lead to bugs that are some of the most difficult to track down. 3.4 System memory layout An embedded system designer has many options in the layout and use of Flash memory. In the simplest of systems, in which resources are not overly constrained, raw binary data (perhaps compressed) can be stored on the Flash device. When booted, a file system image stored in Flash is read into a Linux ram disk block device, mounted as a file system, and accessed only from RAM. This is often a good design choice when the data in Flash rarely needs to be updated. Any data that does need to be updated is relatively small compared to the size of the ramdisk. It is important to realize that any changes to files in the ramdisk are lost upon reboot or power cycle. However we decided to go with lesser popular but arguably better option. Bootloader is in first partition of NAND but Kernel and filesystems is placed in SD-card’s first and second partitions respectively so that they can be updated from laptops. 15 To best use the available resources, it is important to understand the system's memory layout, and the differences between the physical address space and the kernel's virtual address space. Most importantly, many hardware peripherals are accessible within the system's physical address space, but have restricted access or are completely "invisible" in the virtual address space. The physical map is important, because it provides us with information on how to configure the kernel and how to develop custom drivers. During the kernel's configuration, for instance, we may need to specify the location of the flash devices in our system. During development, we may also need to write a driver for a memory-mapped peripheral. We will also need to provide our bootloader with information regarding the components it has to load. Upon startup, the bootloader reads the kernel from the root filesystem into the system's RAM and jumps to the kernel's start routines. From there on, the rest of the system startup is carried out by Linux. Once Linux is running, the programs use virtual addresses. In contrast to the physical memory map, the layout of the virtual memory map is of secondary importance for kernel configuration or device driver development. For device driver development, for instance, it is sufficient to know that some information is located in kernel space and some other information is located in user space, and that appropriate functions must be used to properly exchange data between the two. The virtual memory layout is mostly important to understand and debug applications. The kernel occupies a quarter of the virtual address space starting from address 0xC0000000. This region is also known as "kernel space." The rest of the address space is occupied by application-specific text, data, and library mappings. This is also known as "user space." Whereas the kernel is always located above the 0xC0000000 mark for all applications, applications' memory maps may differ even on the same system. An example of the embedded linux system is shown in figure below. 16 Fig. 3.3 Physical and virtual memory maps for the Compaq iPAQ[19] 3.5 Configuring and Compiling the Bootloader Though the bootloader runs for a very short time during the system's startup and is mainly responsible for loading the kernel, it is a very important system component. Setting up a bootloader is, to some extent, a task common to all Linux systems. It is a special task, nevertheless, for embedded Linux systems, because the bootloaders used in such systems are either completely different from those used in common systems or, even when they are the same, are configured and operated in very different ways. 17 U-Boot is used in this project. U-boot provides options of booting kernel bfrom Flash,SD- Card,USB or network. U-boot can be configured and compiled on a development host according to the development board used. The steps are $cd {PROJECT_ROOT}/uboot $make mini2440_config $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- 3.6 Configuring and Compiling the Kernel The kernel is the central software component of all Linux systems. Its capabilities very much dictate the capabilities of the entire system. If the kernel you use fails to support one of your target's hardware components, for instance, this component will be useless as long as this specific kernel runs on your target. First of all the complete Kernel source must be downloaded from the appropriate repositories available on internet. Then required features of kernel must be selected according to the project. For example in this project SD-Card Support, USB-Support, LCD Support, TS support and CDC-ACM drivers (for GPS) must be selected. In general following options can be customized according to the needs.  Code maturity level options  Loadable module support  General setup  Memory technology devices  Block devices  Networking options  ATA/IDE/MFM/RLL support  SCSI support  Network device support  Input core support  Character devices 18  Filesystems  Console drivers  Sound  Kernel hacking Following commands are used for above steps $cd {PROJECT_ROOT}/linux-2.6.38 $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage This will take around 20-30 minutes to compile depending on the host computer. Also the cross toolchain must be installed on the host for above process to complete successfully. A snapshot of the above process is shown in the figure on the next page. Fig. 3.4 Configuring and Compiling the Kernel 19 3.7 Configuring and Compiling the rootfile system system is very important component of the Embedded Linux System from user point of view. User is generally unaware of the kernel features. Rootfile systems contains the components which make embedded linux useful for a particular application. It consists of following very important components:  Libraries: Required libraries like glibc (for C programs), Qt (for GUI) , libnss (for networking) must be selected for proper operation.  Kernel Modules: Certain hardware modules can be loaded on the fly from rootfile system as and when required.  Kernel Image: Although it is not necessary but modern day implementations include compressed kernel image on the rootfs itself.  Device Files: In Embedded Linux Systems hardware access is easier because of device files. These device files can be created on the fly as well by utilities like udev. In this project we make extensive use of device files like /dev/ttyUSB0 (for usb to serial converter cable used with GSM modem) and /dev/ttyACM0 (for GPS modem), /dev/fb0 (for graphics).  System Applications: These contain utilities like cd (file browsing) , grep (parsing utility), minicom (serial communication software equivalent to hyperterminal in windows), nano (text editor), lsusb (list usb devices), dmesg (kernel message) etc.  Customised Applications: These contain user developed applications which could compiled C programs or interpreted perl scripts or even a java program (provided jvm exists).  System Initialization: It consists of scripts written to run just after kernel passes control to user domain. It may consist of mounting virtual filesystems like /proc, /dev etc. Networking daemons and other servers may also be spawned at this point. It may also set certain environment variables required for system operations. At the end it will spawn and pass the control to vital processes required to carry out Embedded tasks. We have used busybox based system initialization. PTXDist is used to create complete filesystem for this project. Once ptxdist is installed on the host system, following commands can be executed to configure and compile the 20 complete filesystem. This is a very lengthy process 2 to 2.30 hours to compile depending on the host. $cd {PROJECT_ROOT}/{BSP} $ptxdist ARCH=arm menuconfig $ptxdist –ji1 –je1 go Fig. 3.5 Configuring and Compiling the rootfile system using ptxdist. 3.8 Hardware description ARM9 Board The Friendly ARM Mini2440 is a single board computer based on a Samsung S3C24xx family of ARM9 microprocessor. S3C24xx is designed to provide hand-held devices and general applications with cost-effective, low-power, and high-performance micro- 21 controller solution in small die size. To reduce total system cost, the S3C2410A includes the following components separate 16KB Instruction and 16KB Data Cache, MMU to handle virtual memory management, LCD Controller (STN & TFT), NAND Flash Boot Loader, System Manager (chip select logic and SDRAM Controller), 3-ch UART, 4-ch DMA, 4-ch Timers with PWM, I/O Ports, RTC, 8-ch 10-bit ADC and Touch Screen Interface, IIC-BUS Interface, IIS-BUS Interface, USB Host, USB Device, SD Host & Multi-Media Card Interface, 2-ch SPI and PLL for clock generation. Fig. 3.6 The ARM9 board (FriendlyARM mini2440)[20] 22 Fig. 3.7 ARM9 Block Diagram (FriendlyARM mini2440)[19] 23 3.9 ARM9 board Module Details  Power Supply The board needs an external 5V power supply. The other reqiuired voltages are generated on the board: 3.3V, 1.8V and 1.25V. The reset circuit uses a MAX811 reset IC and there is an additional reset switch on the board. Fig 3.8 circuit diagram of system reset[20]  NAND Flash Boot Loader 1. Supports booting from NAND flash memory 2. 4KB internal buffer for booting 3. Supports storage memory for NAND flash memory after booting  UART The three serial ports are led out on CON1 (UART0), CON2 (UART1) and CON3 (UART2). UART0 is also connected to a RS232 level converter and led out on COM0 (DB9 connector).  USB The USB Host is a USB type A connector and the USB Device is a USB type B connector. For communication control the USB Device has got an additional pin: USB_EN (GPC5). 24 Fig. 3.9 circuit diagram of serial ports on CON1 (UART0), CON2 (UART1) and CON3 (UART2[20]).  LCD Interface The board has got a 41 pin display connector (0.5mm pitch). All signals + a four- wire touch screen interface are on the connector. The jumper J2 is used for the LCD driver board power supply select signal, either 5V or 3.3V supply.  GPIO GPIO is on CON4, a 34 pin 2.0mm pitch connector. 25 Fig. 3.10 circuit diagram of LCD interface[20] 26 GSM RECEIVER Chapter-4 4.1 Introduction Communication over wireless channel is particularly challenging. Wireless channel provides a dynamic environment because of factors like large scale path loss, small scale fading effects, and multipath propagation. This all leads to high (and variable) bit error rates. So many important signal processing techniques like modulation, equalization, diversity and channel coding are used to improve bit error rate. Also to make wireless communication secure, we need to employ some form of encryption at some communication layer [8]. GSM (Global System for Mobile Communication) are the standards given by ETSI (European Telecommunication Standard Institute) for digital cellular networks. GSM provides a robust set of protocols for communications. It has some very desirable features: o Encryption algorithms for communication over air o Mobility management for providing high roaming capabilities o FEC (Forward Error Control) at lower layers of radio interface for combating and correcting error o Transparent set of user-plane protocols provide freedom to user. So he can implement vivid variety of applications using GSM Network without worrying of wireless communication woes. We intend to use either SMS or GPRS for transparent transfer of navigation data. The technical specifications of GSM has been shown in the "Table 6.1" 27 Table 4.1 GSM Technical Specifications[21] Parameter Specifications Reverse Channel Frequency 890-915 MHz Forward Channel Frequency 935-960 MHz ARFCN Number 0-124 and 975-1023 Tx/Rx Freq spacing 45 MHz Tx/Rx Time slot spacing 3 Time slots Modulation Data Rate 270.83 Kbps Frame Period 4.615 ms User per frame (Full rate) 8 Time Slot Per Period 576.9 us Bit Period 3.692 us Modulation 0.3 GMSK ARFCN Channel Spacing 200 KHz Interleaving (max. delay) 40 ms GPRS Data Rate Max 114 Kbps 4.2 GSM Modems GSM modems act as an access point for GSM networks. Many complexities of accessing a GSM network are hidden by GSM modem. GSM modem provides a set of commands called AT commands (AT stands for Attention) for accessing GSM service. The supported AT commands and their format depends on the manufacturer of the modem. Another important point to note is that GSM Modems provide a number of interfaces to access its capabilities like RS-232, Bluetooth, USB or even wirelessLAN. We have decided to use a GSM modem with RS-232 interface at the remote object because RS-232 is de-facto standard available on almost all microcontrollers. RS-232 is not one of the most robust protocols when compared to newer protocols like SPI, I2C but its simplicity makes it desirable for local interfaces. However at the monitoring station which may have a PC, we may go for modem with Bluetooth or USB interface, because RS-232 is no longer available on modern PC. 28 We have already tested Nokia Bluetooth modem at the receiving station. At the transmitting station we plan to use ScienTech GSM modem with RS-232 interface. As mentioned earlier the AT commands supported by those modems may vary but GSM services will remain same, so it makes no difference which modem we chose. AT commands are shown in "Table 4.2". These are the commands which are normally found in all GSM modems (hopefully!) [10]. Table 4.2 AT Commands Command Description AT Check serial interface and GSM modem working ATE0 Turn echo off, less traffic on serial line. AT+CGMI Manufacturer identification AT+CGMM Model identification AT+CGSN Product Serial Number AT+CIMI Request IMSI AT+CCID Card Identification AT+CREG Network Registration Status AT+CNMI Display of new incoming SMS. AT+CPMS Selection of SMS memory. ATA Answer a Call ATD Dial a Number ATD+VTD, AT+VTS Send DTMF AT+CMGR Read new message from a given memory location. AT+CMGS Send message to a given recipient. AT+CMGD Delete message AT+CMSS Send a message from a SIM card storage AT+CMGW To write a message to a SIM card 29 4.3 GSM KIT GSM receiver is used to receive the data from any user via the BTS. Today mainlySIM300 module is used for GSM system. This chapter describes the hardware interface of the SIMCOM SIM300 module that connects to the specific application and the air interface. As SIM300 can be integrated with a wide range of applications, all functional components of SIM300 are described in great detail as. . Fig 4.1 GSM modem SIM300 30 Fig. 4.2 Block diagram of SIM300 GSM modem 31 4.3.1 Product detail SIM300 is a Tri-band GSM/GPRS engine that works on frequencies EGSM (Enhanced GSM )900 MHz, DCS 1800 MHz and PCS1900 MHz. SIM300 provides GPRS multi-slot class 10 capability and support the GPRS coding schemes CS-1, CS-2, CS-3 and CS-4. The physical interface to the mobile application is made through a 60 pins board-to-board connector, which provides all hardware interfaces between the module and customers’ boards except the RF antenna interface.  The keypad and SPI LCD interface will give you the flexibility to develop customized applications.  Two serial ports can help you easily develop your applications.  Two audio channels include two microphones inputs and two speaker outputs. This can be easily configured by AT command. .4.3.2 Application Interface All hardware interfaces except RF interface that connects SIM300 to the customers’ cellular application platform is through a 60-pin 0.5mm pitch board-to-board connector. Sub-interfaces included in this board-to-board connector are described in detail in following chapters: -  Power supply  Dual serial interface  Two analog audio interfaces  SIM interface  Indicators (Buzzer, LED) 4.4 Power supply The power supply of SIM300 is from a single voltage source of VBAT= 3.4V...4.5V. In some case, the ripple in a transmit burst may cause voltage drops when current consumption rises to typical peaks of 2A, So the power supply must be able to provide sufficient current up to 2A. For the VBAT input, a local bypass capacitor is 32 recommended. A capacitor (about 100μF, low ESR) is recommended. Multi-layer ceramic chip (MLCC) capacitors can provide the best combination of low ESR and small size but may not be cost effective. A lower cost choice may be a 100 μF tantalum capacitor (low ESR) with a small (1 μF to 10μF) ceramic in parallel, which is illustrated as following figure. And the capacitors should put as closer as possible to the SIM300 VBAT pins. The following figure is the recommended circuit:- Fig 4.3 VBAT input[21] VBAT Eight BAT pins of the board-to-board connector are dedicated to connect the supply voltage. The power supply of SIM300 has to be a single voltage source of VBAT= 3.4V...4.5V. It must be able to provide sufficient current in a transmit burst which typically rises to 2A.mostly, these 8 pins are voltage input. Vmax= 4.5V Vmin=3.4V Vnorm=4.0V 33 Eight VBAT pins of the board-to-board connector are dedicated to connect the supply voltage; four GND pins are recommended for grounding. BACKUP can be used to back up the RTC. 4.5 Dual Serial interface SIM300 provides two unbalanced asynchronous serial ports. The GSM module is designed as a DCE (Data Communication Equipment), following the traditional DCE- DTE (Data Terminal Equipment) connection, the module and the client (DTE) are connected through the following signal (as following figure shows). Autobauding supports baud rate from 1200 bps to 115200bps. Serial port 1:-  Port/TXD - Client sends data to the RXD signal line of module  Port/RXD - Client receives data from the TXD signal line of module Serial port 2:-  Port/TXD - Client sends data to the DGBRXD signal line of module  Port/RXD - Client receives data from the DGBTXD signal line of module All pins of two serial ports have 8mA driver, the logic levels are described in following table Table 4.3 Logic levels of serial ports pin Parameter Min Max Unit Logic low input 0 0.3*VDD_EXT V Logic high input 0.7 *VDD_EXT VDD_EXT +0.3 V Logic low output GND 0.2 V Logic high output VDD_EXT -0.2 VDD_EXT V 34 Function of Serial Port 1 & 2 supporting Serial port 1:-  Seven lines on Serial Port Interface.  Contains Data lines /TXD and /RXD, State lines /RTS and /CTS, Control lines /DTR, /DCD and RING;  Serial Port 1 can be used for CSD FAX, GPRS service and send AT command of controlling module. Serial Port 1 can use multiplexing function, but you cannot use the Serial Port 2 at the same time;  Serial Port 1 supports the communication rate as following: 1200, 2400, 4800, 9600, 19200,38400, 57600, 115200 Default as 115200bps.  Autobauding supports the communication rate as following: 1200, 2400, 4800, 9600, 19200, 38400, 57600, and 115200bps. Serial port 2:-  Two lines on Serial Port Interface .  Only contains Data lines /TXD and /RXD  Serial Port 2 only used for transmitting AT command. It cannot be used for CSD call, FAX call.And the Serial port 2 can not use multiplexing function;  Serial port 2 supports the communication rate as following: 9600, 19200, 38400, 57600, 115200 Fig 4.4 interface of serial ports[22] 35 4.5.1 Two audio interface The module provides two Analogy input channels, AIN1 and AIN2, which may be used for both microphone and line inputs. The AIN1 and AIN2 channels are identical. One of the two channels is typically used with a microphone built into a handset. The other channel is typically used with an external microphone or external line input. The Module Analogy input configuration is determined by control register settings and established using Analogy multiplexes .4.5.2 SIM interface There is facility of inserting SIM card on the GSM modem. The information stored in the SIM card can be read by using the AT Command. The SIM interface supports the functionality of the GSM Phase 1 specification and also supports the functionality of the new GSM Phase 2+ specification for FAST 64 kbps SIM .Both 1.8V and 3.0V SIM Cards are supported. The SIM interface is powered from an internal regulator in the module having nominal voltage 2.8V. All pins reset as outputs driving low. Logic levels are as described in table. Table 4.4 Signal of SIM interface (board-to-board connector) PIN SIGNAL DISCRIPTION 19 SIM_VDD SIM Card Power output automatic output on SIM mode, one is 3.0V±10%, another is 1.8V±10%. Current is about 10mA. 21 SIM_I/O SIM Card data I/O 23 SIM_CLK SIM Card Clock 25 SIM_RST SIM Card Reset 16 SIM_PRESENCE SIM Card Presence 36 Fig 4.5 SIM interface reference circuit with 6 pins SIM card[22] If you don’t use the SIM card detection function, you can let the SIM_PRESENCE pin NC or connect to the GND. 4.6 Indicator There are mainly three indicators used in SIM300 GSM modem:-  BUZZER  POWER LED  NETWORK LED 37 BUZZER The PIN 36 on the board-to-board connector can be used to drive a buzzer to indicate incoming call. The output volume of buzzer can be set by “AT+CRSL”. POWER LED Power led is used to indicate the available power on the GSM module. NETWORK STATUS INDICATION LED The PIN 30 on the board-to-board connector can be used to drive a network status indication LED lamp. The working state of this pin is listed in following table Table 4.5 Working state of network status indication LED pin State SIM300 function Off SIM300 is not running 64ms On/ 800ms Off SIM300 does not find the network 64ms On/ 3000ms Off SIM300 find the network 64ms On/ 300ms Off GPRS communication 4.7 ANTENNA INTERFACE The RF interface has an impedance of 50Ω. To suit the physical design of individual applications SIM300 offers two alternatives.  Recommended approach: antenna connector on the component side of the PCB  Antenna pad and grounding plane placed on the bottom side 38 To minimize the loss on the RF cable, it need be very careful to choose RF cable. The value of insertion loss for SIM300 should be less then 1db. 4.7.1 Antenna connector SIM300 use MURATA’s MM9329-2700 RF connector on the module side, here you can use MURATA’s MXTK92XXXXX as matching connector on the application side. 4.7.2 Antenna pad The antenna can be soldered to the pad, or attached via contact springs. To help to ground the antenna, SIM300 comes with a grounding plane located close to the antenna pad. SIM300 material properties: SIM300 PCB Material: FR4 Antenna pad: Gold plated pad Antenna pad soldering temperature (fewer 10 seconds): 260°C 39 GPS SYSTEM CHAPTER 5 5.1 Why GPS (GPS-X-02007_UBLOX Model)? Basically, A GPS (Global positioning system) receiver determine just four variables, i.e longitude, latitude, height and time. Additional information (e.g speed ,direction etc) can be derived from these four components. Using GPS the following value can be determine anywhere on the earth :-  One’s exact location , accurate to within a range of 20m to 1 mm.  The precise time (UTC) accurate to within a range of 60ns to 5ns. GPS (The full description is:- Navigation System with Timing and Ranging Global Positioning System, NAVSTAR-GPS) was developed by the U.S. department of defense (DoD) and can be used both by civilians and military personal. There are currently 28 operational satellites orbiting the earth at a height of 20,180km on 6 different orbital planes. Their orbits are inclined at 55 degree to equator, ensuring that a least 4 satellites are in radio communication with any point on the planet. During the development of the GPS system, particular emphasis was placed on the following three aspects:- 1. It had to provide users with the capability of determining position, speed and time, whether in motion or at rest. 2. It had to have a continuous, global, 3 dimensional positioning capability with a high degree of accuracy, Irrespective of the weather. 3. It had to offer potential for civilian use. In order to calculate one’s exact position, all that needs to be measured is the signal transit time between the point of observation and four different satellites whose positions are known. 40 Fig 5.1 GPS satellites orbit the Earth on 6 orbital planes[21]  distance = transit time • the speed of signal (speed of signal is generally = light speed) 5.2 Generating GPS signal transit time 28 satellites inclined at 55° to the equator orbit the earth every 11 hrs and 58 minutes at a height of 20180 km on 6 different orbital planes. Each one of these satellites has a four atomic clocks on board. Atomic clocks on board. Atomic clocks are currently the most precise instrument known, losing a maximum of one second every 30,000 to 1,000,000 years. In order to make them even more accurate, they are regularly adjusted so synchronized from various control point on the Earth (i.e earth segment.) Signals are transmitted at the speed of light (300,000km/s) and therefore require approx. 67.3 ms to reach a position on the Earth’s surface located directly below the satellite. If you wish to establish your position on land (or at sea or in the air), all you require is an accurate clock. By comparing the arrival time of the satellite .Signal with the on board clock time the moment the signal was emitted, it is possible to determine the transit time of that signal.  distance =transit time • the speed of light , S= *C 41 Measuring signal transit time and knowing the distance to a satellite is still not enough to calculate one’s own position in 3-D space. To achieve this, four independent transit time measurements are required. It is for this reason that signal communication with four different satellites is needed to calculate one’s exact position. If the distance to the three satellites is known, all possible positions are located on the surface of three spheres whose radii correspond to the distance calculated. The position sought is at the point where all three surfaces of the spheres intersect. 5.3 Determining a position in 3-D space In order to determine these four unknown variables, four independent equations are needed. The four transit times required are supplied by the four different satellites (sat. 1 to sat. 4). The 28 GPS satellites are distributed around the globe in such a way that at least 4 of them are always “visible” from any point on Earth. Fig. 5.2 Four satellites are required to determine a position in 3-D space.[21] 42 5.4 Description of the entire system The Global Positioning System (GPS) comprises three segments:-  The space segment (all functional satellites)  The control segment (all ground stations involved in the monitoring of the system: master control station, monitor stations, and ground control stations).  The user segment (all civil and military GPS users). Fig 5.3 The three GPS segments[21] 43 5.4.1 space segment - The GPS satellites (Construction of a satellites) All 28 satellites transmit time signal and data synchronized by on board atomic clocks at the same frequency 1575.42 MHz. The minimum signal strength received on earth is approx -158dBw to -160dBw. In accordance with the specification, the maximum strength is approx -153dBw. Table 5.1 L1 carrier link budget analysis modulated with the C/A code[21] Gain (+) /loss (-) Absolute value Power at the satellite transmitter 13.4dBW (43.4dBm=21.9W) Satellite antenna gain (due to +13.4dB concentration of the signal at 14.3°) Radiate power EIRP 26.8dBW (56.8dBm) (Effective Integrated Radiate Power) Loss due to polarisation -3.4dB mismatch Signal attenuation in space -184.4dB Signal attenuation in the -2.0dB atmosphere Gain from the reception antenna +3.0dB Power at receiver input 160dBW (130dBm=100.0*10-18W) . The received power of –160dBW is unimaginably small. The maximum power density is 14.9 dB below receiver background noise. 44 Satellite signals The following information (navigation message) is transmitted by the satellite at a rate of 50 bits per second:-  Satellite time and synchronization signals.  Precise orbital data (ephemeris).  Time correction information to determine the exact satellite time.  Approximate orbital data for all satellites (almanac).  Correction signals to calculate signal transit time  Data on the ionosphere.  Information on satellite health. The time required to transmit all this information is 12.5 minutes. By using the navigation message the receiver is able to determine the transmission time of each satellite signal and the exact position of the satellite at the time of transmission. Each of the 28 satellites transmits a unique signature assigned to it. This signature consists of an apparent random sequence (Pseudo Random Noise Code,PRN) of 1023 zeros and ones. Generating the satellite signal Simplified block diagram On board the satellites are four highly accurate atomic clocks. The following time pulses and frequencies. Required for day-to-day operation are derived from the resonant frequency of one of the four atomic clocks.  The 50Hz data pulse.  The C/A code pulse (Coarse/Acquisition code, PRN-Code, coarse reception code at a frequency of 1023 MHz), which modulates the data using an exclusive-or operation (this spreads the data over a 1MHz bandwidth).  The frequency of the civil L1carrier (1575.42 MHz). The data modulated by the C/A code modulates the L1 carrier in turn by using Bi-Phase- Shift-Keying (BPSK). With every change in the modulated data there is a180°change in the L1 carrier phase. 45 Fig 5.4 Simplified satellite block diagram[21] Fig 5.5 Data structure of a GPS satellite[21] 5.4.2 Control segment The control segment (Operational Control System OCS) consists of a Master Control Station located in the state of Colorado, five monitor stations equipped with atomic clocks 46 that are spread around the globe in the vicinity of the equator, and three ground control stations that transmit information to the satellites. The most important tasks of the control segment are:-  Observing the movement of the satellites and computing orbital data (ephemeris)  Monitoring the satellite clocks and predicting their behavior  Synchronizing on board satellite time  Relaying precise orbital data received from satellites in communication  Relaying the approximate orbital data of all satellites (almanac)  Relaying further information, including satellite health, clock errors etc. The control segment also oversees the artificial distortion of signals (SA, Selective Availability), in order to degrade the system’s positional accuracy for civil use. System accuracy had been intentionally degraded up until May 2000 for political and tactical reasons by the U.S. Department of Defense (DoD), the satellite operators. It was shut down in May 2000, but it can be started up again, if necessary, either on a global or regional basis . 5.4.3 User segment The signals transmitted by the satellites take approx.67 milliseconds to reach a receiver. As the signals travel at the speed of light, their transit time depends on the distance between the satellites and the user. Four different signals are generated in the receiver having the same structure as those received from the 4 satellites. By synchronizing the signals generated in the receiver with those from the satellites, the four satellite. Signal time shifts Δt are measured as a timing mark. The measured time shifts Δt of all 4 satellite. Signals are used to determine signal transit time. In order to determine the position of a user, radio communication with four different satellites is required. The relevant distance to the satellites is determined by the transit time of the signals. The receiver then calculates the user’s latitude ϕ, longitude λ, height h and time t from the range and known position of the four satellites. 47 Signal recovery and the identification of the satellites takes place by means of correlation. As the receiver is able to recognize all C/A codes currently in use, By systematically shifting and comparing every code with all incoming satellite signals, a complete match will eventually occur (that is to say that the correlation factor CF is one), and a correlation point will be attained. The correlation point is used to measure the actual signal transit time and, as previously mentioned, to identify the satellite . Fig.5.6 Measuring signal transit time[21] Fig 5.7 Demonstration of the correction process across 30 bits[21] 48 The quality of the correlation is expressed here as CF (correlation factor).The value range of CF lies between Minus one and plus one and is only plus one when both signals completely match (bit sequence and phase). 1 = ∗ [( )−( )] mB : number of all matched bits uB : number of all unmatched bits N : number of observed bits. 5.5 THE GPS NAVIGATION MESSAGE The navigation message is a continuous stream of data transmitted at 50 bits per second. Each satellite relays the following information to Earth:-  System time and clock correction values.  Its own highly accurate orbital data (ephemeris).  Approximate orbital data for all other satellites (almanac).  System health etc. The navigation message is needed to calculate the current position of the satellites and to determine signal transit times. Structure of the navigation message A frame is 1500 bits long and takes 30 seconds to transmit. The 1500 bits are divided into five subframes each of 300 bits (duration of transmission 6 seconds).Each subframe is in turn divided into10 words each containing 30bits. Each subframe begins with a telemetry word and a handover word (HOW). A complete navigation message consists of 25 frames (pages).The structure of the navigation message is illustrated in diagrammatic format in above figure 49 Fig 5.8 Structure of the entire navigation message[21] .5.6 Information contained in the subframes A frame is divided into five subframes, each subframe transmitting different information:-  Subframe 1 contains the time values of the transmitting satellite, including the parameters for correcting signal transit delay and on board clock time, as well as information on satellite health and an estimation of the positional accuracy of the satellite. Subframe 1 also transmits the so-called 10-bit week number (a range of values from 0 to 1023 can be represented by 10 bits). GPS time began on Sunday, 6th January 1980 at 00:00:00 hours. Every 1024 weeks the week number restarts at 0.  Subframes 2 and 3 contain the ephemeris data of the transmitting satellite. This data provides extremely accurate information on the satellite’s orbit. 50  Subframe 4 contains the almanac data on satellite numbers 25 to 32 (N.B. each subframe can transmit data from one satellite only), the difference between GPS and UTC time and information regarding any measurement errors caused by the ionosphere.  Subframe 5 contains the almanac data on satellite numbers 1 to 24 (N.B. each subframe can transmit data from one satellite only).All 25 pages are transmitted together with information on the health satellite numbers 1 to 24. 5.7 CALCULATING POSITION Although originally intended for purely military purposes, the GPS system is used today primarily for civil applications, such as surveying, navigation (air, sea and land), positioning, measuring velocity, determining time, monitoring stationary and moving objects, etc. The system operator guarantees the standard civilian user of the service that the following accuracy (Table 4.1) will be attained for 95% of the time (2drms value ): Table 5.3 Accuracy of the standard civilian service Horizontal accuracy Vertical accuracy Time accuracy ≤13 m ≤22 m ~40ns With additional effort and expenditure, e.g. several linked receivers (DGPS), longer measuring time, and special measuring techniques (phase measurement) positional accuracy can be increased to within a centimeter. 5.7.1 Calculating a position The principle of measuring signal transit time (evaluation of pseudo-range.In order for a GPS receiver to determine its position, it has to receive time signals from four different satellites (Sat 1 ... Sat 4), to enable it to calculate signal transit time ∆t1 ... ∆t4 (Figure 5.8). 51 Fig. 5.9 Four satellite signals must be received[21] Calculations are effected in a Cartesian, three-dimensional co-ordinate system with a geocentric origin (Figure4.1). The range of the user from the four satellites R1, R2, R3 and R4 can be determined with the help of signal transit times ∆t1, ∆t2, ∆t3 and ∆t4 between the four satellites and the user. As the locations XSat, YSat and ZSat of the four satellites are known, the user co-ordinates can be calculated. Due to the atomic clocks on board the satellites, the time at which the satellite signal is transmitted is known very precisely. All satellite clocks are adjusted or synchronised with each another and universal time co-ordinated. In contrast, the receiver clock is not synchronised to UTC and is therefore slow or fast by ∆t0. The sign ∆t0 is positive when the user clock is fast. The resultant time error ∆t0 causes inaccuracies in the measurement of signal transit time and the distance R. As a result, an incorrect distance is measured that is known as pseudo distance or pseudo-range PSR 52 Fig. 5.10 Three dimensional co-ordinate system[22] ∆ = ∆t + ∆t PSR=∆ . C =(Δt + ∆t )⋅C PSR =R + ∆t ⋅c ……………………………. eqn.-1 R: True range of the satellite from the user C: Speed of light ∆t: signal transit time from the satellite to the user ∆t : difference between the satellite clock and the user clock PSR: pseudo-range The distance R from the satellite to the user can be calculated in a Cartesian system as follows: 53 R= ( − ) −( − ) −( − ) …………….eqn.-2 Thus eqn.(2) into eqn. (3) PSR= ( − ) −( − ) −( − ) + C. ∆t In order to determine the four unknown variables (∆t , , and ), four independent equations are necessary. XAnw: means unknown value of X The following is valid for the four satellites (i = 1 ... 4): PSR = _ − − _ − − _ − + C. ∆t 5.7.2 Error consideration and satellite signal Error components in calculations have so far not been taken into account. In the case of the GPS system, several causes may contribute to the overall error:  Satellite clocks although each satellite has four atomic clocks on board, a time error of just 10 ns creates an error in the order of 3 m.  Satellite orbits The position of a satellite is generally known only to within approx. 1 to 5 m.  Speed of light The signals from the satellite to the user travel at the speed of light. This slows down when traversing the ionosphere and troposphere and can therefore no longer be taken as a constant.  Measuring signal transit time The user can only determine the point in time at which an incoming satellite signal is received to within a period of approx. 10-20 ns, which corresponds to a positional error of 3-6 m. The error component is increased further still as a result of terrestrial reflection (multipath). 54  Satellite geometry The ability to determine a position deteriorates if the four satellites used to take measurements are close together. The effect of satellite geometry on accuracy of measurement. The errors are caused by various factors that are detailed in Table 5.4, which includes information on horizontal errors. 1 sigma (68.3%) and 2 sigma (95.5%) are also given. Accuracy is, for the most part, better than specified, the values applying to an average satellite constellation. Table 5.2 Cause of errors Cause of error Error Effects of the ionosphere 4m Satellite clocks 2.1 m Receiver measurements 0.5 m Ephemeris data 2.1 m Effects of the troposphere 0.7 m Multipath 1.4 m 5.8 GPS RECEVIER 55 Fig. 5.11 Smart GPS receiver Fig 5.12 Simplified block diagram of a GPS receiver[21]  Antenna The antenna receives extremely weak satellite signals on a frequency of 56 1572.42MHz. Signal output is around –163dBW. Some antenna have a 3dB gain  .LNA 1 This low noise amplifier (LNA) amplifies the signal by approx. 15 ... 20dB.  HF filter The GPS signal bandwidth is approx. 2MHZ. The HF filter reduces the affects of signal interference. The HF stage and signal processor actually represent the special circuits in a GPS receiver and are adjusted to each other.  HF Stage The amplified GPS signal is mixed with the frequency of the local oscillator. The filtered IF signal is maintained at a constant level in respect of its amplitude and digitalised via Amplitude Gain Control (AGC).  IF Filter The intermediate frequency is filtered out using a bandwidth of 2MHz. The image frequencies arising at the mixing stage are reduced to a permissible level.  Signal processor Up to 16 different satellite signals can be correlated and decoded at the same time. Correlation takes place by constant comparison with the C/A code. The HF stage and signal processor are simultaneously switched to synchronize with the signal. The signal processor has its own time base (Real Time Clock, RTC). All the data ascertained is broadcast (particularly signal transit time to the relevant satellites determined by the correlator), and this is referred to as source data. The signal processor can be offset by the controller via the control line to function in various operating mode.  Controller 57 Using the source data ,the controller calculates position ,time ,speed and course etc .It controls the signal processor and relays the calculated values to the display. Important information (such as ephemeris ,the most recent position etc.)are decoded and saved in RAM .The program and the calculation algorithms are saved in ROM.  Current supply The power supply delivers the necessary operational voltage to all levels of electronic component. 5.9 Basic design of a GPS module  Fig 5.13 Typical block diagram of a GPS module[21] 58 GPS modules have to evaluate weak antenna signals from at least four satellites ,in order to determine a correct three-dimensional position. A time signal is also often emitted in addition to longitude ,latitude and height .This time signal is synchronised with UTC (Universal Time Coordinated) .From the position determined and the exact time ,additional physical variables ,such as speed and acceleration can also be calculated .The GPS module issues Information on the constellation ,satellite health ,and the number of visible satellites etc. Figure shows a typical block diagram of a GPS module. The signals received (1575.42 MHz) are pre-amplified and transformed to a lower intermediate frequency. The reference oscillator provides the necessary carrier wave for frequency conversion, along with the necessary clock frequency for the processor and correlator. The analogue intermediate frequency is converted into a digital Signal by means of a 2-bit ADC. Signal transit time from the satellites to the GPS receiver is ascertained by correlating PRN pulse sequences .The Satellite PRN sequence must be used to determine this time, otherwise there is no correlation maximum. Data is recovered by mixing it with the correct PRN sequence. At the same time,the useful signal is amplified above the Interference level upto 16 satellite signals are processed simultaneously. The control and generation of PRN sequences and the recovery of data is carried out by a signal processor .Calculating and saving the position, including the variables derived from this ,is carried out by a processor with a memory facility. 5.10 The NMEA Data interface In order to relay computed GPS variables such as position, velocity, course etc. To a peripheral for example computer, screen, transceiver GPS modules have a serial interface (TTL or RS-232 level). The most important elements of receiver information are broadcast via this interface in a special data format. This format is\ standardised by the National Marine Electronics Association (NMEA) to ensure that data exchange takes place without any problems. Nowadays, data is relayed according to the NMEA- 0183 specification. NMEA has specified data sets for various Applications. For Example 59 GNSS (Global Navigation Satellite System), GPS, Loran, Omega, Transit and also for various manufacturers. The following seven data sets are widely used with GPS modules to relay GP information 1. GGA (GPS Fix Data, fixed data for the Global Positioning System) 2. GLL (Geographic Position – Latitude/Longitude) 3. GSA(GNSS DOP and Active Satellites, degradation of accuracy and the number of active satellites in the Global Satellite Navigation System) 4. GSV (GNSS Satellites in View, satellites in view in the Global Satellite Navigation System) 5. RMC (Recommended Minimum Specific GNSS Data) 6. VTG (Course over Ground and Ground Speed, horizontal course and horizontal velocity) 7. ZDA (Time & Date) 5.10.1 NMEA Protocol Frame Following is the frame format of NMEA Protocol $
<,value> *  $ - This is the start character .In NMEA Protocol the starting character is always dollar($)  Second field is address .This field is subdivided into 2 field .First field indicate the information originating from a GPS appliance. It is always GP for a GPS receiver. The second field is indicate the data set type .for example GGA, GLL, GSA, GSV etc.  Third field is Data field .This content the information of data like Latitude, Longitude, Altitude, Time. Comma used as a separator for different items of information  Four field is for check sum Asterisk ( *) used as a separator for the checksum. This field start with a ‘*’ and consists of two characters representing a hex number. The checksum is the exclusive OR of all characters between ‘$’ and ‘*’ Check is for checking the entire data. 60  Last field indicate the end of the data set: carriage return () and line feed, (). Following NMEA Protocol is found in the GPS receiver Table 5.3 NMEA Data $GPRMC,130303.0,A,4717.115,N,00833.912,E,000.03,043.4,200601,01.3,W*7D $GPZDA,130304.2,20,06,2001,,*56 $GPGGA,130304.0,4717.115,N,00833.912,E,1,08,0.94,00499,M,047,M,,*59 $GPGLL,4717.115,N,00833.912,E,130304.0,A*33 $GPVTG,205.5,T,206.8,M,000.04,N,000.08,K*4C $GPGSA,A,3,13,20,11,29,01,25,07,04,,,,,1.63,0.94,1.33*04 $GPGSV,2,1,8,13,15,208,36,20,80,358,39,11,52,139,43,29,13,044,36*42 $GPGSV,2,2,8,01,52,187,43,25,25,074,39,07,37,286,40,04,09,306,33*44 $GPRMC,130304.0,A,4717.115,N,00833.912,E,000.04,205.5,200601,01.3,W*7C $GPZDA,130305.2,20,06,2001,,*57 $GPGGA,130305.0,4717.115,N,00833.912,E,1,08,0.94,00499,M,047,M,,*58 $GPGLL,4717.115,N,00833.912,E,130305.0,A*32 $GPVTG,014.2,T,015.4,M,000.03,N,000.05,K*4F $GPGSA,A,3,13,20,11,29,01,25,07,04,,,,,1.63,0.94,1.33*04 $GPGSV,2,1,8,13,15,208,36,20,80,358,39,11,52,139,43,29,13,044,36*42 $GPGSV,2,2,8,01,52,187,43,25,25,074,39,07,37,286,40,04,09,306,33*44 . 5.10.2 GGA data set 61 The GGA data set (GPS Fix Data) contains information on time , longitude and latitude, the quality of the system, the number of satellites used and the height. $GPGGA,130305.0,4717.115,N,00833.912,E,1,08,0.94,00499,M,047,M,,*58 Following are the function of the individual characters or character sets. Table 5.4 GGA Data Field Description $ Start of the data set GP information originating from a GPS appliance GGA Data set identifier 130305.0 UTC positional time: 13h 03min 05.0sec 4717.115 Latitude: 47° 17.115 min N Northerly latitude (N=north, S= south) 00833.912 Latitude: 8° 33.912min E Easterly longitude (E= east, W=west) 1 GPS quality details (0= no GPS, 1= GPS, 2=DGPS) 08 Number of satellites used in the calculation 0.94 Horizontal Dilution of Precision (HDOP) 00499 Antenna height data (geoid height) M Unit of height (M= meter) 047 Height differential between an ellipsoid and geoid M Unit of differential height (M= meter) ,, Age of the DGPS data (in this case no DGPS is used) 0000 identification of the DGPS reference station * Separator for the checksum 62 58 Checksum for verifying the entire data set End of the data set 5.10.3 GLL data set The GLL data set (geographic position latitude/longitude) contains information on latitude and longitude, time and health. Example of a GLL data set:- $GPGLL, l4717.115 ,N, 00833.912, E ,130305.0 ,A*32 Following is meaning of each character Table 5.5 GPGLL Data $ Start of data set GP Information originating from a GPS appliance GLL Data set identifier 4717.115 Latitude: 47° 17.115 min N Northerly latitude (N=north, S= south) 833.912 Longitude: 8° 33.912min E Easterly longitude (E=east, W=west) 130305.0 UTC positional time: 13h 03min 05.0sec A Data set quality: A means valid (V= invalid) * Separator for the checksum 32 Checksum for verifying the entire data set End of the data set 5.10.4 GSA data set 63 The GSA data set (GNSS DOP and Active Satellites) contains information on the measuring mode (2D or 3D), the number of satellites used to determine the position and the accuracy of the measurements (DOP: Dilution of Precision) An example of a GSA data set: $GPGSA, A, 3, 13, 20, 11, 29, 01, 25, 07 ,04,,,,,1.63, 0.94, 1.33*04 Following are the description of each character Table 5.6 GSA Data $ Start of the data set GP Information originating from a GPS appliance GSA Data set identifier A Calculating mode (A= automatic selection between 2D/3D mode, M= manual selection Between 2D/3D mode) 3 Calculating mode_(1=_none,_2=2D,_3=3D)_ 13 ID number of the satellites used to calculate position 20 ID number of the satellites used to calculate position 11 ID number of the satellites used to calculate position 29 ID number of the satellites used to calculate position 01 ID number of the satellites used to calculate position 25 ID number of the satellites used to calculate position 07 ID number of the satellites used to calculate position 04 ID number of the satellites used to calculate position ,,,, Dummy for additional ID numbers (currently not used) 1.63 PDOP (Position Dilution of Precision) .94 HDOP (Horizontal Dilution of Precision) 1.33 VDOP (Vertical Dilution of Precision) * Separator for the checksum 04 Checksum for verifying the entire data set End of the data set 64 ALGORITHM AND RESULTS CHAPTER-6 65 Fig. 6.1 Algorithm 6.1 Algorithm 66 First of all GSM Modem must be registered to Network. Command ‘AT+CREG?’ is sent to the SIM300 module to check the status. If registration step is not successful then the above command should be again sent. If the registration is successful then signal quality is checked using ‘AT+CSQ?’. The obtained values are displayed on console itself. A counter is initialized with value 10 (this is because gps data is sent to control station at interval of 10 seconds). But note that data obtained is shown on local console at normal rate of 1 sample per second. Once counter is set, data packets from GPS receiver is received via USB driver interface ‘/dev/ttyACM0’. From these packets like GPGLL, GPRMC, GPGSA are extracted. From GPGLL packet longitude, latitude and time stamp are saved into buffer. From GPGGA packet height is extracted and saved to buffer. Similarly from GPGSV the number of satellites in view and from GPRMC speed is saved. This data from buffer is sent to local console ‘/dev/tty1’ which is lcd at the rate of 1 sample per second. Once the data is sent the counter is counter is decremented. If 10 seconds has elapsed then message is sent via GSM Modem using command ‘AT+CMGS’. After this counter is reset to initial value and the process is repeated. This is the simplified description of the operation of Automatic Vehicle Locator developed in this project. For demonstration and measurement purposes, a similar program was run but the data was sampled continuously and extracted data was continuously dumped to a file and displayed on local console. Here for demonstration purpose the screenshot is shown next section. 6.2 Results Figure 6.2 and Figure 6.3 shows the output data at two locations in SVNIT Campus. Validity of this data was checked using Google Maps. Also while testing the project it was observed that GPS data is accurate when used in outdoors. This fact could be explained because in crowded places and indoors there could be multiple path components causing problem. The longitude and latitude are shown in degree and minutes multiplied by 100. Another point to note here is that number of satellites in view generally depends on time of the day, and the location at which the remote object is. But user should not worry about the number of satellites because 4 satellites are enough to calculate the exact coordinates. Speed is shown in Nautical Miles per hour because this is defacto in GPS receivers. Height shown in the data are the measured from geodetic datum which could be approximated as mean sea level for simple applications. 67 Fig 6.4 shows the data obtained on a GSM terminal (control station). The format of the message is self explanatory. However point to note is that there is time stamp with each message and message are at interval of 10 seconds. Fig.6.2 Snapshot at Location A (SVNIT Campus, Hostel-6 Block B) 68 Fig. 6.3 Snapshot at location B (SVNIT CAMPUS Hostel-6 Block D) Fig. 6.4 Message Received on GSM Terminal 69 Fig 6.5 Messages received when GSM Terminal is Connected to PC via PC Suite Packets received from GPS receiver via NMEA protocol can be seen in raw format on ‘minicom’ or ‘microcom’. This is particularly useful to study the data formats used in NMEA protocols. This is shown in figure 6.6. However note that when reception is weak the packets would be empty. This condition was taken care of in programs. All the packets contain the checksum at the end (after *). This is useful to see if there was any error in received packet. No checksum problems were found during the project phase. This could be because USB uses differential signalling which is much more reliable and immune to error than RS-232 interface. 70 Fig 6.6 Raw NMEA data shown on minicom 71 6.3 APPLICATION Using the Global Positioning System (GPS) ,a process used to establish apposition at any point on the globe) the following two values can be determined anywhere on Earth .  One’s exact location (longitude, latitude and height co-ordinates) accurate to within a range of 20 m to approx.1mm.  The precise time (world time, Universal Time Coordinated, UTC) accurate to within a range of 60ns to approx.1ns. Various additional variables can be derived from the three-dimensional position and the exact time, such as  Speed  Acceleration  Course  Local time  Range instrument AVL (Automatic vehicle locator) we can track the exact position of any vehicle or moving object. Fig 6.7 AVL application[27] 72 Other application 1. Transport companies, logistics in general (aircraft, water-borne craft and road vehicle) 2. Railways 3. Geographical tachographs 4. Fleet management 5. Navigation systems 6. Military Science and Research GPS has readily found itself a place in archaeology ever since this branch of science began to use aerial and satellite imaging. In land surveying, GPS has virtually become an exclusive method for pinpointing sites in basic networks. Everywhere around the world, continental and national GPS networks are emerging that, in conjunction with the global ITRF, provide homogenous and highly accurate networks of points for density and point to point measurements. At a regional level, the number of tenders to set up GPS networks as a basis for geo-information systems and cadastral land surveys is growing. Fig 6.8 Application in Science and Research[27] 73 Conclusion Chapter-7 For physical implementation of this system, there could be a number of design alternatives. In earlier phase of project RTOS and ARM7 was employed along with U- Blox GPS modem and SIM300 GSM modem. But later on Embedded linux was chosen over RTOS and ARM9 was chosen over ARM7 because of performance reasons. This time same GPS receiver is used as navigation system. NMEA is used as communication protocol between controller and GPS receiver over a USB interface. GSM is used to provide communication link between remote object and monitoring system. GSM modem is interfaced to controller using AT protocols over a RS232 interface. controller in this case is high performance application domain processor SAMSUNG S3C2440 (ARM9). It runs self compiled Embedded linux. Performance of GPS and GSM receivers is limited by signal reception. So antenna plays an important role. Also Embedded linux provides a lot of flexibility in terms of available libraries and device drivers. Libraries like glibc, Qt were used. Device drivers like CDC- ACM (for GPS modem) and PL2303 (for GSM modem) were used. The data is extracted by controller from NMEA packets sent by GPS receiver. From these packets controller calculates useful data like longitude, latitude, height, speed, timestamp. These data are saved in a specific format and sent over GSM modem every 10s. The time is hardcoded but can be easily changed. This time will depend on the application for example a speed measuring or height profiling applications would require frequent data but normal tracking applications could work with lesser frequent data. The results have been attached in appendix. 74 List of References [1]. French G.T., An Introduction to GPS systems, GeoResearch Inc., 1996 [2]. Sloss, Symes, Wright, ARM System Developer's Guide, Morgan Kaufman Publishers, 2005 [3]. Furber S., ARM System on Chip Architecture, Pearson Education, 2000 [4]. LPC2138 User Manual, Rev.3, http://www.nxp.com/documents/user_manual/UM10120.pdf [5]. ARM7TDMI Technical Reference Manual, http://infocenter.arm.com/help/topic/com.arm.doc.ddi0210c/DDI0210B.pdf [6]. Noergard T., Embedded System Architecture, Newnes Publishers, 2005 [7]. Labrosse J.J., MicroC/OS-II: The Real Time Kernel, Viva Publishers, 2002 [8]. Rappaport T., Wireless Communications, Prentice Hall Inc., 2002 [9]. Eberspacher, Vogel, Bettstetter, Hartmann, GSM Architecture Protocol and Services, John Wiley & Sons Ltd., 2009 [10]. AT Commands Interface Guide, http://www.coster.info/costerit/teleges/doc/gsm822w.pdf [11]. Rabbany A.E., The Global Positioning Systems, Artech House, 2006 [12]. Y. Lv, X. Li, X, Peng, and J. Sun, "Design of the navigation system of UAV in high dynamic circumstance based on GPS," Proceedings of 6th International Symposium on Test and Measurement, Vol. 7, 2005 [13]. Tsui Y., Bao J., Fundamentals of Global Positioning System Receivers: A Software Approach, John Wiley & Sons, 2000 [14]. Takamura J., Shimizu K., Tanaka T., The Improvement of the Shift Error in GPS Standard Positioning Service, SICE Annual Conference in Fukui, August 4-6, 2003 [15]. Joong-hee Han; Kwon, J.H.; Impyeong Lee; Kyoungah Choi; , "Position and Attitude Determination for UAV-Based GPS, IMU and AT without GCPs," Multi- Platform/Multi-Sensor Remote Sensing and Mapping (M2RSM), 2011 International Workshop on , vol., no., pp.1-5, 10-12 Jan. 2011 75 [16]. Michael S. Braach and A.J. Van Dierendonck,"GPS receiver architectures and measurements" in proceedings of the IEEE vol81, no.1, january 1999 [17]. Karim Yaghmour, ”Building Embedded Linux Systems”, O’Reilly & Associates, 2003 [18]. Cristopher Hallinan, ”Embedded Linux Primer”, Prentice Hall, 2010 [19]. “User Manual S3C2410A Revision 1.0”, Samsung Electronics, 2004 [20]. “S3C2410-III v2.0 Linux User Manual Revision 1.0”, Embest Info, 2008 [21]. Jean Marie“GPS Basics Introduction to the system Application overview”, Ublox, 2002 [22]. “SIM300 Hardware Specifications Version 1.06”, SIMCOM Ltd., 2005 76 List of Acronyms AVL Automatic Vehicle System BPSK Binary phase Shift keying CDC ACM Communication Device Class Abstract Control Model CF Correlated Function DGPS Differential Global Positioning System ETSI European Telecommunications Standards Institute FCC Federal Communications Commission GLONASS Global Navigation Satellite System GPRS General Packet Radio Service GPS Global Positioning System GGSN Gateway GPRS Support Node GSM Global System for Mobile communication OCS Operational Control System NMEA National Marine Electronics Association MCU Microcontroller unit MSC Mobile Switching Centre MCS Micro-controller Unit PRN Pseudo Random Noise PPS Precise Positioning Service RTCM Radio Technical Commission for Maritime Services SGSN Serving GPRS Support Node SMS Short Message Service SP Stack Pointer SPS Standard Positioning Service 77