Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INTRODUCTION:
1.1. Overview
The algorithm of Flexible Bus System is devised in a way that this system replaces the scheduled bus lines systems and buses and dynamically changes their routes according to passengers demands. Passengers are informed about the real time location of the buses which makes it easy for the passengers to decide whether to ride a particular bus or not making this system passenger friendly. The main objective of this project is to do a research on the use of short range wireless technology called Zigbee in Demand Responsive Transit (DRT), making it much more efficient, reliable and less expensive. This research is not the only way to develop this kind of a system and by no means suggested the best solution but it can definitely be one of the better alternatives we have till date and can be used in the areas where there are no 3G, WiMax or other long range wireless technologies available. This research will also help us understand the potential of Zigbee. Till now Zigbee is being used as in-house or in-vehicle technology but this research brings an idea of using Zigbee as communication tool for InterVehicle and Vehicle to Infrastructure. Using Zigbee to communicate between Bus and the Bus Stop will also reduce the total cost of the system as Zigbee devices are far cheaper than WiFi, 3G and WiMax devices. Due to the fact that Zigbee is low power as compared to other short range wireless technologies like WiFi, this system can be deployed in mountainous areas where power is a major concern.
Installing the 3G modules on Bus Stop and Bus which are more than 1 in most of the cases will greatly increase the total installation cost of the system.
Fig 1.1 Existing FBS System Following are some drawbacks to this approach. 1. Installation cost is very high. 2. Maintenance cost is very high. 3. High power consumption. 4. Cannot be applied in areas where there are no long range wireless signals available (Rural or mountainous areas). To overcome these problems we propose a model which is less costly than the system discussed above. We call our proposed system The Flexible Bus System. This paper will only include the wireless communication part of this system.
instead of going to the Bus Stop9 by driving to all the Bus Stops from 2~9, the Bus will directly drive to Bus Stop9 to pick up the passenger. This way the wait time of the passenger waiting on Bus Stop9 will be less as compared to the case in which Bus has to drive from 2~9. The Flexible Bus System will not only decrease the wait time of the passengers but it will also decrease the drive time of the Buses which will greatly reduce the total cost of the System.
Bus stops and central station uses Zigbee as a communication medium. The complete information of all the passengers account details, Buses and Bus stops is stored in the External memory (EEPROM) interfaced to the station using I2C protocol. For example if a passenger wants to reserve a ticket from any bus/bus stop he will provided an RFID tag with some balance, the passenger has to punch his tag near to the RFID reader placed at Bus/Bus stop ,and he has to give his complete details about is travel . Then the controller placed in that bus stop sends the details of the passenger to the central station using Zigbe. The central station receives the data through Zigbee and stores in one memory for processing. It will compare the data received from bus or bus stop and the passenger Id, it will check the complete details of the travel like source, destination and number of persons travelling. The central station after comparing all the details according to the Bus root ,source and destination the equivalent amount for the travel are debited from his account. And after successful reservation of tickets the details of the reservation are sent to corresponding station by Zigbee. If there are any errors like tag detection, not enough balance then the central station will send the appropriate command data to corresponding station. In this central station we are providing choice to admin ,they can modify the data and update the balance of users whenever they needed.
the remaining seats after reservation and how many tickets reserved to this and displays them on LCD and sends the request signal to send GPS coordinates. In the bus a PIC18F452 microcontroller which is interfaced with GPS system is placed. And this PIC controller is inter connected to the LPC2148 . Whenever the Bus system wants to send the bus location to other stations then it will send the request signal to PIC there the required location information is sent through Zigbee to all the necessary stations. If Bus stop receives the data from central station about ticket confirmation at the bus stop then it will check whether that data belongs to that bus stop or not. It ignores if the data doesnt belongs to it otherwise first it will check for is there any error in the confirmation process if so it will check for what type of error and finds it then displays the error message on LCD. In the received data if there is no error information then it will check for remaining balance of the passenger in their account and remaining seats in that bus to which the passenger has reserved. In this same process the information between bus , bus stop and central station is processing through Zigbee. If any passenger reserves tickets for a bus that particular bus will send the location of it to that bus stop and we can also send the time to reach that stop if needed. Suppose if one bus is going , and there is no one passenger in next stop for this bus the stop will send that information to that bus and bus will not stop at that stop.
CHAPTER -2
EMBEDDED SYSTEM HARDWARE
2.1 Introduction to Microcontroller:
A microprocessor system consists of a microprocessor with memory, input ports and output ports connected to it externally. A microcontroller is a single chip containing a microprocessor, memory, input ports and output ports. Since all four blocks reside on the one chip, a microcontroller is much faster than a microprocessor system. We have several other basic microcontroller families such as PIC, M68HCXX, and AVR etc. All these basic microcontrollers are useful for implementing basic interfacing and control mechanisms for simple applications. There are several applications which require lot of computation and high speed data processing. In such applications advanced microcontrollers and microprocessors are used. One such advanced architecture is ARM.
This is due to the optimization of each instruction on the CPU. Each instruction is of a fixed length to allow the pipeline to fetch future instructions before decoding the current instruction. Pipelining: The processing of instructions is broken down into smaller units that can be executed in parallel by pipelines. Ideally the pipeline advances by one step on each cycle for maximum throughput. Instructions can be decoded in one pipeline stage. Large number of registers: The RISC design philosophy generally incorporates a larger number of registers to prevent large amount of interactions with memory. Any register can contain either data or an address. Registers act as the fast local memory store for all data processing operation. Load-store architecture: The processor operates on data held in registers. Separate load and store instructions transfer data between the register bank and external memory. These design rules allow a RISC processor to be simpler, and thus the core can operate at higher clock frequencies. CISC
1. Complex instructions taking multiple cycles 2. Any instruction may refer to memory 3. Not pipelined or less pipelined
RISC
Simple instructions taking one cycle Only LOAD/STORE refer to memory Highly pipelined
4. Instructions interpreted by the micro-program Instructions executed by the hardware 5. Variable format 6. Many instructions and modes 7. Complexity in the micro-program 8. Single register set Fixed format instructions Few instructions and modes Complexity in the compiler Multiple register sets
flow model. In which the ARM core as functional units connected by data buses,. And the arrows represent the flow of data, the lines represent the buses, and boxes represent either an operation unit or a storage area. The figure shows not only the flow of data but also the abstract components that make up an ARM core.
Figure 2.4.1: ARM core dataflow model In the above figure the Data enters the processor core through the Data bus. The data may be an instruction to execute or a data item. This ARM core represents the Von Neumann implementation of the ARM data items and instructions share the same bus. In contrast, Harvard implementations of the ARM use two different buses. The instruction decoder translates instructions before they are executed. Each instruction executed belongs to a particular instruction set. The ARM processors, like all RISC processors, use load-store architecture. This means it has two instruction types for transferring data in and out of the processor: load instructions copy data from memory to registers in the core, and conversely the store instructions copy data from registers to memory. There are no data processing instructions that directly manipulate data in memory. Thus, data processing is carried out solely in registers. Data items are placed in the register file a storage bank made up of 32-bit registers. Since the ARM core is a 32- bit processor, most instructions treat the registers as holding signed or
8
unsigned 32-bit values. The sign extend hardware converts signed 8-bit and 16-bit numbers to 32-bit values as they are read from memory and placed in a register. The ALU (arithmetic logic unit) or MAC (multiply accumulate unit) takes the register values Rn and Rm from the A and B buses and computes a result. Data processing instructions write the result in Rd directly to the register file. Load and store instructions use the ALU to generate an address to be held in the address register and broadcast on the Address bus. One important feature of the ARM is that register Rm alternatively can be preprocessed in the barrel shifter before it enters the ALU. Together the barrel shifter and ALU can calculate a wide range of expressions and addresses. After passing through the functional units, the result in Rd is written back to the register file using the Result bus. For load and store instructions the incrementer updates the address register before the core reads or writes the next register value from or to the next sequential memory location. The processor continues executing instructions until an exception or interrupt changes the normal execution flow.
There are two different types of devices connected to the bus 1. Bus Master 2. Bus Slave Bus Master: A logical device capable of initiating a data transfer with another device across the same bus (ARM processor core is a bus Master). Bus Slave: A logical device capable only of responding to a transfer request from a bus master device (Peripherals are bus slaves) Generally a Bus has two architecture levels
9
Physical lever: Which covers electrical characteristics a bus width (16, 32, 64 bus). Protocol level: which deals with protocol? NOTE: - ARM is primarily a design company. It seldom implements the electrical characteristics of the bus, but it routinely specifies the bus protocol
Later ARM introduced another bus design called the ARM High performance Bus (AHB). Using AMBA i. ii. Peripheral designers can reuse the same design on multiple projects A Peripheral can simply be bolted on the On Chip bus without having to redesign an
interface for different processor architecture. This plug-and-play interface for hardware developers improves availability and time to market. AHB provides higher data throughput than ASB because it is based on centralized multiplexed bus scheme rather than the ASB bidirectional bus design. This change allows the AHB bus to run at widths of 64 bits and 128 bits ARM introduced two variations on the AHB bus 1. 2. Multi-layer AHB AHB-Lite
In contrast to the original AHB , which allows a single bus master to be active on the bus at any time , the Multi-layer AHB bus allows multiple active bus masters. AHB-Lite is a subset of the AHB bus and it is limited to a single bus master. This bus was developed for designs that do not require the full features of the standard AHB bus. AHB and Multiple-layer AHB support the same protocol for master and slave but have different interconnects. The new interconnects in Multi-layer AHB are good for systems with
10
multiple processors. They permit operations to occur in parallel and allow for higher throughput rates.
2.4.4 NOMENCLATURE:
ARM uses the nomenclature shown below is to describe the processor implementations. The letters and numbers after the word ARM indicate the features a processor may have. ARM { x }{ y }{ z }{ T }{ D }{ M }{ I }{ E }{J }{ F }{ -S } x family y memory management / protection unit z cache T Thumb 16 bit decoder D JTAG debug M fast multiplier I Embedded ICE macro cell E enhanced instruction (assumes TDMI) J Jazelle F vector floating-point unit S synthesizable version All ARM cores after the ARM7TDMI include the TDMI features even though they may not include those letters after the ARM label The processor family is a group of processor implementations that share the same hardware characteristics. For example, the ARM7TDMI, ARM740T, and ARM720T all
11
share the same family characteristics and belong to the ARM7 family JTAG is described by IEEE 1149.1 standard Test Access Port and boundary scan architecture. It is a serial protocol used by ARM to send and receive debug information between the processor core and test equipment Embedded ICE macro cell is the debug hardware built into the processor that allows breakpoints and watch points to be set Synthesizable means that the processor core is supplied as source code that can be compiled into a form easily used by EDA tools.
32/16-bit RISC architecture (ARM v4T) 32-bit ARM instruction set for maximum performance and flexibility 16-bit Thumb instruction set for increased code density Unified bus interface, 32-bit data bus carries both instructions and data Three-stage pipeline 32-bit ALU Very small die size and low power consumption Fully static operation Coprocessor interface Extensive debug facilities (Embedded ICE debug unit accessible via JTAG interface unit)
2.4.7 Benefits:
Generic layout can be ported to specific process technologies Unified memory bus simplifies SoC integration process ARM and Thumb instructions sets can be mixed with minimal overhead to support application requirements for speed and code density
Code written for ARM7TDMI-S is binary-compatible with other members of the ARM7 Family and forwards compatible with ARM9, ARM9E and ARM10 families, thus it's
12
Static design and lower power consumption are essential for battery -powered devices Instruction set can be extended for specific requirements using coprocessors Embedded ICE-RT and optional ETM units enable extensive, real-time debug facilities
13
non-privileged mode which does not have write permissions to CPSR. The other six modes are privileged modes. Privileged: - Full read-write access to the CPSR. Under this we are having Abort, Fast interrupt request, Interrupt request, Supervisor, System and Undefined. Abort (10111): When there is a failed attempt to access memory Fast interrupt Request (FIQ (10001)) & interrupt request (10010) : Correspond to interrupt levels available on ARM Supervisor mode (10011): State after reset and generally the mode in which OS kernel executes System mode (11111): Special version of user mode that allows full read-write access of CPSR. Undefined (11011): When processor encounters an undefined instruction Non-privileged:- Only read access to the control filed of CPSR but read-write access to the condition flags. User (10000): User mode is user for programs and applications. And this is the normal mode
The above figure shows all 37 registers of register file. Out of these 37 registers, 20 registers are hidden from a program in different modes. These are called banked registers.
shows the type of instructions that ARM support. Data Processing Instructions Branch Instructions Load-store Instructions Software Interrupt Instruction Program Status Register Instructions
15
The LPC2148 microcontrollers are based on a 32 bit ARM7TDMI-S CPU with realtime emulation and embedded trace support, that combines the microcontroller with embedded high speed flash memory of 512 kB. A 128-bit wide memory interface and a
16
unique accelerator architecture enable 32-bit code execution at the maximum clock rate. For critical code size applications, the alternative 16-bit Thumb mode reduces the code by more than 30 % with minimal performance penalty. Due to their tiny size and low power consumption, LPC2148 microcontrollers are ideal for the applications where miniaturization is a key requirement, such as access control and point-of-sale. A blend of serial communications interfaces ranging from a USB 2.0 Full Speed device, multiple UARTS, SPI, SSP to I2Cs and on-chip SRAM of 8 kB up to 40 kB, make these devices very well suited for communication gateways and protocol converters, soft modems, voice recognition and low end imaging, providing both large buffer size and high processing power. Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC, PWM channels and 45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these microcontrollers particularly suitable for industrial control and medical systems.
3.2 Features of LPC2148 Microcontroller: 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package. 8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program memory. 128 bit wide interface/accelerator enables high speed 60 MHz operation. In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software. Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms. EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the on-chip RealMonitor software and high speed tracing of instruction execution. USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM. In addition, the LPC2146/8 provides 8 kB of on-chip RAM accessible to USB by DMA. One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total of 6/14 analog inputs, with conversion times as low as 2.44 s per channel. Single 10-bit D/A converter provide variable analog output. Two 32-bit timers/external event counters (with four capture and four compare Channels each), PWM unit (six outputs) and watchdog. Low power real-time clock with independent power and dedicated 32 kHz clock input.
17
Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 kbit/s), SPI and SSP with buffering and variable data length capabilities. Vectored interrupt controller with configurable priorities and vector addresses. Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package. Up to nine edge or level sensitive external interrupt pins available. 60 MHz maximum CPU clock available from programmable on-chip PLL with settling time of 100 s. On-chip integrated oscillator operates with an external crystal in range from 1 MHz to 30 MHz and with an external oscillator up to 50 MHz. Power saving modes include Idle and Power-down. Individual enable/disable of peripheral functions as well as peripheral clock scaling for additional power optimization. Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out Detect (BOD) or Real-Time Clock (RTC). Single power supply chip with Power-On Reset (POR) and BOD circuits: CPU operating voltage range of 3.0 V to 3.6 V (3.3 V 10 %) with 5 V tolerant I/O pads.
3.3 Description about the Block Diagram:3.3.1 On chip Flash Program Memory : LPC 2148 is having 512 kB Flash memory. This memory may be used for both code and data storage. Programming of the flash memory may be accomplished in several ways(ISP/IAP).
3.3.2
On-chip static RAM may be used for code and/or data storage. The SRAM may be accessed as 8-bit, 16-bit, and 32-bit. An 8 kB SRAM block intended to be utilized mainly by the USB
3.3.3
Interrupt Controller:-
The Vectored Interrupt Controller (VIC) accepts all of the interrupt request inputs and categorizes them as Fast Interrupt Request (FIQ), vectored Interrupt Request (IRQ), and nonvectored IRQ as defined by programmable settings.
3.3.4 Analog to Digital Converter :LPC2148 contains two analog to digital converters(ADC0 & ADC1 ). Total number of available ADC inputs is 14. These two ADCs are 10 bit successive approximation analog to
18
digital converters. Measurement range of 0 V to VREF. Global Start command for both converters.
3.3.5 Digital to Analog Converter :The DAC enables to generate a variable analog output. The maximum DAC output voltage is the VREF voltage. 10-bit DAC. Buffered output. Power-down mode available.
3.3.6 USB 2.0 Device Controller :The USB is a 4-wire serial bus that supports communication number between a host and a (127 max) of peripherals. Enables 12 Mbit/s data exchange with a USB host
controller. A DMA controller (available only in LPC2146/48) can transfer data between an endpoint buffer and the USB RAM.
3.3.7 UART :LPC2148 contains two UARTs( UART0 & UART1). In addition to standard transmit and receive data lines, the LPC2148 UART1 also provides a full modem control handshake interface. 16 byte Receive and Transmit FIFOs. It contains Built-in fractional baud rate generator covering wide range of baud rates without a need for external crystals of particular values.
3.3.8 I2C-bus serial I/O controller :I2C is a bidirectional. It is a multi-master bus, it can be controlled by more than one bus master connected to it. It supports bit rates up to 400 kbit/s. Bidirectional data transfer between masters and slaves. Serial clock synchronization allows devices with different bit rates to communicate via one serial bus. Serial clock synchronization can be used as a handshake mechanism to suspend and resume serial transfer.
3.3.9 SPI serial I/O control :It is s a full duplex serial interface, designed to handle multiple masters and slaves connected to a given bus. Synchronous, Serial, Full Duplex Communication.
3.3.10 SSP serial I/O control :Supports full duplex transfers. Data frames of 4 bits to 16 bits of data flowing from the master to the slave and from the slave to the master. Synchronous serial communication.
19
Master or slave operation. 8-frame FIFOs for both transmit and receive. Four bits to 16 bits per frame .
3.3.11 Timers :LPC 2148 has two 32-bit timer/counters with a programmable 32-bit prescaler. It also having external External event counter. Four 32-bit capture channels per timer/counter that can take a snapshot of the timer value when an input signal transitions. A capture event may also optionally generate an interrupt. It is also having Four 32-bit match registers that allow: Continuous operation with optional interrupt generation on match. Stop timer on match with optional interrupt generation. Reset timer on match with optional interrupt generation. Four external outputs per timer/counter corresponding to match registers, with the following capabilities: Set LOW on match. Set HIGH on match. Toggle on match. Do nothing on match.
3.3.12 Watchdog Timer :The purpose of the watchdog is to reset the microcontroller within a reasonable amount of time if it enters an erroneous state. When enabled, the watchdog will generate a system reset if the user program fails to feed (or reload) the watchdog within a predetermined amount of time.
3.3.13 Real Time Clock :The RTC is designed to provide a set of counters to measure time when normal or idle operating mode is selected. The RTC has been designed to use little power, making it suitable for battery powered systems where the CPU is not running continuously (Idle mode).
20
3.3.14 Crystal Oscillator :On-chip integrated oscillator operates with external crystal in range of 1 MHz to 25 MHz. The oscillator output frequency is called fosc and the ARM processor clock frequency is referred to as CCLK for purposes of rate equations, etc. fosc and CCLK are the same value unless the PLL is running and connected.
3.3.15 PLL :The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz. The input frequency is multiplied up into the range of 10 MHz to 60 MHz with a Current Controlled Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the multiplier value cannot be higher than 6 on this family of microcontrollers due to the upper frequency limit of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there is an additional divider in the loop to keep the CCO within its frequency range while the PLL is providing the desired output frequency. The output divider may be set to divide by 2, 4, 8, or 16 to produce the output clock. Since the minimum output divider value is 2, it is insured that the PLL output has a 50 % duty cycle. The PLL is turned off and bypassed following a chip reset and may be enabled by software. The program must configure and activate the PLL, wait for the PLL to Lock, then connect to the PLL as a clock source. The PLL settling time is 100 s
21
22
The main features of the pic 18f452 microcontroller are given below:
23
Peripheral Features:
High current sink/source 25 mA/25 mA Three external interrupt pins Timer0 module: 8-bit/16-bit timer/counter with 8-bit programmable prescaler Timer1 module: 16-bit timer/counter Timer2 module: 8-bit timer/counter with 8-bit period register (time-base for PWM) Timer3 module: 16-bit timer/counter Secondary oscillator clock option - Timer1/Timer3 Master Synchronous Serial Port (MSSP) module, Two modes of operation I2C Master and Slave mode Addressable USART module Supports RS-485 and RS-232. Parallel Slave Port (PSP) module.
24
25
LCD screen
LCD screen consists of two lines with 16 characters each. Each character consists of 5x8 or 5x11 dot matrix. This book covers 5x8 character display because it is commonly used.Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built in backlight (blue or green diodes). When used during operating, a resistor for current limitation should be used (like with any LE diode).
26
If there are no characters on display or all of them are dimmed upon the display is on, the first thing that should be done is to check the potentiometer for contrast regulation. Is it properly adjusted? Same applies in case the operation mode is changed (writing in one or two lines).
busy flag and can be read from line D7. When the bit BF is cleared (BF=0), display is ready to receive.
LCD Connection
Depending on how many lines are used for connection to the microcontroller, there are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the process in a phase called initialization. In the first case, the data are transferred through outputs D0-D7 as it has been already explained. In case of 4-bit LED mode, for the sake of saving valuable I/O pins of the microcontroller, there are only 4 higher bits (D4-D7) used for communication, while other may be left unconnected. Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that normally would be sent through lines D4-D7), four lowerbits are sent afterwards. With the help of initialization, LCD will correctly connect and interprete each data received. Besides, with regards to the fact that data are rarely read from LCD (data mainly are transferred from microcontroller to LCD) one more I/O pin may be saved by simpleconnecting R/W pin to the Ground. Such saving has its price. Even though message displaying will be normally performed, it will not be possible to read from busy flag since it is not possible to read from display.
Luckily, solution is simple. It is sufficient to give LCD enough time to perform its task upon sending every character or command. Since execution of the slowest command is approximately 1.64mS, it will be quite enough to wait for approximately 2mS.
28
The ZigBee standard provides network, security, and application support services operating on top of the IEEE 802.15.4 Medium Access Control (MAC) and Physical Layer (PHY) wireless standard. It employs a suite of technologies to enable scalable, self-organizing, selfhealing networks that can manage various data traffic patterns. The network layer supports various topologies such star, clustered tree topology and self healing mesh topology which is essential in Smartdust Apart from easy installation and easy implementation. ZigBee has a wide application area such as home networking, industrial networking, Smartdust, many more, having different profiles specified for each field. The upcoming of ZigBee will revolutionize the home networking and rest of the wireless world. The ZigBee Alliance is not pushing a technology; rather it is providing a standardized base set of solutions for sensor and control systems.
The physical layer was designed to accommodate the need for a low cost yet allowing for high levels of integration. The use of direct sequence allows the analog circuitry to be very simple and very tolerant towards inexpensive implementations. The media access control (MAC) layer was designed to allow multiple topologies without complexity. The power management operation doesn't require multiple modes of operation.
29
The MAC allows a reduced functionality device (RFD) that needn't have flash nor large amounts of ROM or RAM. The MAC was designed to handle large numbers of devices without requiring them to be "parked". The network layer has been designed to allow the network to spatially grow without requiring high power transmitters. The network layer also can handle large amounts of nodes with relatively low latencies. Low power consumption, simply implemented ,Users expect batteries to last many months to years! Consider that a typical single family house has about 6 smoke/CO detectors. If the batteries for each one only lasted six months, the home owner would be replacing batteries every month! In contrast to Bluetooth, which has many different modes and states depending upon your latency and power requirements, ZigBee/IEEE 802.15.4 has two major states: active (transmit/receive) or sleep. The application software needs to focus on the application, not on which power mode is optimum for each aspect of operation. Even mains powered equipment needs to be conscious of energy. ZigBee devices will be more ecological than their predecessors saving megawatts at it full deployment. Consider a future home that has 100 wireless control/sensor devices, Low cost to the users means low device cost, low installation cost and low maintenance. ZigBee devices allow batteries to last up to years using primary cells (low cost) without any chargers (low cost and easy installation). ZigBee's simplicity allows for inherent configuration and redundancy of network devices provides low maintenance. High density of nodes per network , ZigBee's use of the IEEE 802.15.4 PHY and MAC allows networks to handle any number of devices. This attribute is critical for massive sensor arrays and control networks. Simple protocol, global implementation, ZigBee's protocol code stack is estimated to be about 1/4th of Bluetooth's or 802.11's. Simplicity is essential to cost, interoperability, and maintenance. The IEEE 802.15.4 PHY adopted by ZigBee has been designed for the 868 MHz band in Europe, the 915 MHz band in N America, Australia, etc; and the 2.4 GHz band is now recognized to be a global band accepted in almost all countries.
30
Data rates of 250 kbps (@2.4 GHz), 40 kbps (@ 915 MHz), and 20 kbps (@868 MHz) Optimized for low duty-cycle applications (<0.1%) CSMA-CA channel access Yields high throughput and low latency for low duty cycle devices like sensors and controls Low power (battery life multi-month to years) Multiple topologies: star, peer-to-peer, mesh Addressing space of up to: 18,450,000,000,000,000,000 devices (64 bit IEEE address) 65,535 networks Optional guaranteed time slot for applications requiring low latency Fully hand-shaked protocol for transfer reliability Range: 50m typical (5-500m based on environment)
In the Zigbee architecture, the PHY layer and MAC layer are based on the IEEE 802.15.4 WPAN standard. Zigbee defines the NWK and APS layers. The software and hardware vendor will provide the software stack with appropriate tools to allow an OEM to create applications, which are added to the APL. The Physical (PHY) layer and Medium Access Control (MAC) layer are based on the IEEE802.15.4 PAN standard. This includes the actual radio hardware. Above the MAC and PHY are the Network (NWK) and application layers defined by Zigbee. The first two layers, the physical (PHY) and Medium Access Control (MAC) are defined in the IEEE standard. The other layers that build on the PHY and MAC layers are defined by the Zigbee alliance. The PHY layer contains the RF transceiver and access to the other hardware and control mechanisms. The function of the PHY is to activate and deactivate the radio transceiver and other hardware specific services such as access to the channels. The MAC layer is as described by the name a controlling device for radio medium. It controls access to the physical radio channel and other services defined by the PHY service. It is also responsible for a reliable transmission system through its services. The services are about channel access and transmission techniques and validation of data packets. The network (NWK) layer is responsible for the network controlling functions. It controls the mechanism for joining and leaving a network and for creating a network for those devices which have the capability to do so. The NWK layer applies also security to what is going to be data packets. The NWK layer is responsible for discovery and storing information about the neighbors in the network. Responsibility for routing between devices and routing of packets to their destination goes to this layer. The application layer (APL) consists of three different blocks which have different functionalities and responsibilitiesThe APS layer provides an interface between the NWK layer and the APL with its set of services. The Zigbee device object (ZDO) is responsible for managing Zigbee devices in the network. This could be discovering new device in the network and define its role in the network it also determines the services the new device provides. Possible device types are those defined in Zigbee standard and they are coordinators, routers and end devices. The
32
Application Frame (AF) contains application objects which can be manufacturer defined application objects. An example of an application object is a power switch. The security service provider (SSP) provides enhanced security options as encryption with 128-bit key transport.
5.2.3TRANSCEIVER
Pin Diagram
Fig: 5.2.3 Pin diagram of X-Bee Transceiver Zigbee modules feature a UART interface, which allows any microcontroller or microprocessor to immediately use the services of the Zigbee protocol. All a Zigbee hardware designer has to do in this ase is ensure that the hosts serial port logic levels are compatible with the XBees 2.8- to 3.4-V logic levels. The logic level conversion can be performed using either a standard RS-232 IC or logic level translators such as the 74LVTH125 when the host is directly connected to the XBee UART. The below table gives the pin description of transceiver.
Pin
Name
Directio n
Description
1 2 3 4
5 6 7 8 9
Module Reset PWM Output 0/RX Signal Strength Indicator PWM Output 1 Do not connect Pin Sleep Control Line or Digital Input 8
10 11 12 13 14 15
Ground Analog Input 4 or Digital I/O 4 Clear-to-Send Flow Control or Digital I/O 7 Module Status Indicator Voltage Reference for A/D Inputs Associated Indicator, Analog Input 5 or Digital I/O 5
Associate/AD5/DIO5 Either
16
RTS/AD6/DIO6
Either
17 18 19 20
Analog Input 3 or Digital I/O 3 Analog Input 2 or Digital I/O 2 Analog Input 1 or Digital I/O 1 Analog Input 0 or Digital I/O 0
FEATURES:
Table: 5.2 Performance characteristics
Parameters Indoor/Urban Range Outdoor RF (LOS) Transmit Power Output RF Data Rate Serial Interface Data Rate Receiver Sensitivity Value 30m 100m 1mW (0dBm) 250,000bps 1200-115200bps -92dBm
35
The X-Bee RF Modules interface to a host device through a logic-level asynchronous Serial port. Through its serial port, the module can communicate with any logic and voltage Compatible UART; or through a level translator to any serial device. Data is presented to the X-Bee module through its DIN pin, and it must be in the asynchronous serial format, which consists of a start bit, 8 data bits, and a stop bit. Because the input data goes directly into the input of a UART within the X-Bee module, no bit inversions are necessary within the asynchronous serial data stream. All of the required timing and parity checking is automatically taken care of by the X-Bees UART. Just in case you are producing data faster than the X-Bee can process and transmit it, both X-Bee modules incorporate a clear-to-send (CTS) function to throttle the data being presented to the X-Bee modules DIN pin. You can eliminate the need for the CTS signal by sending small data packets at slower data rates. If the microcontroller wants to send data to transceiver, it will send RTS (Request to Send) signal. If the transceiver is idle it sends CTS (Clear to Send) signal. The RTS and CTS signals are active low. When microcontroller receives CTS command it will send data to the transceiver through DIN pin. The transceiver will send the data to microcontroller through DOUT pin. The communication between transceiver and the microcontroller at the transmitter and receiver is similar. The communication between transmitter and receiver is through RF communication.
For example:
36
UART data packet 0x1F (decimal number is 31) as transmitted through the RF module. Data enters the module UART through the DI pin (pin 3) as an asynchronous serial signal. The signal should idle high when no data is being transmitted. Each data byte consists of a start bit (low), 8 data bits (least significant bit first) and a stop bit (high). The following figure illustrates the serial bit pattern of data passing through the module.
The module UART performs tasks, such as timing and parity checking, that are needed for data communications. Serial communications depend on the two UARTs to be configured with compatible settings (baud rate, parity, start bits, stop bits, data bits). X-Bee RF Modules operate in Transparent Mode. When operating in this mode, the modules act as a serial line replacement - all UART data received through the DI pin is queued up for RF transmission. When RF data is received, the data is sent out the DO pin.
5.3 EEPROM
EEPROM (also written E2PROM and pronounced "e-e-prom," "double-e prom," "esquared," or simply "e-prom") stands for Electrically Erasable Programmable Read-Only Memory and is a type of non-volatile memory used in computers and other electronic devices to store small amounts of data that must be saved when power is removed, e.g., calibration tables or device configuration.
When larger amounts of static data are to be stored (such as in USB flash drives) a specific type of EEPROM such as flash memory is more economical than traditional EEPROM devices. EEPROMs are realized as arrays of floating-gate transistors. EEPROM is user-modifiable read-only memory (ROM) that can be erased and reprogrammed (written to) repeatedly through the application of higher than normal electrical voltage generated externally or internally in the case of modern EEPROMs. EPROM usually must be removed from the device for erasing and programming, whereas EEPROMs can be programmed and
37
erased in circuit. Originally, EEPROMs were limited to single byte operations which made them slower, but modern EEPROMs allow multi-byte page operations. It also has a limited life - that is, the number of times it could be reprogrammed was limited to tens or hundreds of thousands of times. That limitation has been extended to a million write operations in modern EEPROMs. In an EEPROM that is frequently reprogrammed while the computer is in use, the life of the EEPROM can be an important design consideration. It is for this reason that EEPROMs were used for configuration information, rather than random access memory.
Components of the System: User segment GPS antennas & receiver/processors Position Velocity Precise timing Used by Aircraft Ground vehicles Ships and individuals
Satellite ranging Satellite locations Satellite to user distance Need four satellites to determine position
Distance measurement Radio signal traveling at speed of light Measure time from satellite to user
Low-tech simulation Distance to a satellite is determined by measuring how long a radio signal takes to reach us from that satellite. To make the measurement we assume that both the satellite and our receiver are generating the same pseudo-random codes at exactly the same time. By comparing how late the satellite's pseudo-random code appears compared to our receiver's code, we determine how long it took to reach us. Multiply that travel time by the speed of light and you've got distance. Accurate timing is the key to measuring distance to satellites. Satellites are accurate because they have four atomic clocks ($100,000 each) on board. Receiver clocks don't have to be too accurate because an extra satellite range measurement can remove errors. To use the satellites as references for range measurements we need to know exactly where they are. GPS satellites are so high up their orbits are very predictable.
All GPS receivers have an almanac programmed into their computers that tells them where in the sky each satellite is, moment by moment. Minor variations in their orbits are measured by the Department of Defense. The error information is sent to the satellites, to be transmitted along with the timing signals.
40
Features
The GPS smart receiver provides a host of features that make it easy for integration and use. Ultra low power design. High performance receiver tracks up to 16 satellites. Compact design ideal for applications with minimal space. A rechargeable battery sustains internal clock and memory. It is recharged during normal operation. User initialization is not required. One full duplex serial communication and user selectable baud rates allow maximum interface capability andflexibility. Water proof (1 meter) design for all weather. Built-in low noise, high gain active antenna.
keypad is very simple. Wires run in vertical columns (we call the m C0 to C3) and in horizontal rows (called R0 to R3). These 8 wires are available externally, and will be connected to the lower 8 bit s of t he port. Each key on the keypad is essentially a switch that connects a row wire to a column wire. When a key is pressed, it makes an electrical connection between the row and column
pressed. The hex keypad is connected to the DE2 Media Computer via the GPIO parallel ports. We need to remember a few things about the GPIO ports in order to read and interpret hex keypad input properly. Recall that each pin on JP1 or JP2 can be configured individually as input or output. Furthermore, the port direction can be reconfigured by your program, so that the inputs and outputs can be changed while your program is running. Finally, remember that each pin in the HEX keypad is connected to a pull-up resistor, so any input coming from the hex keypad will read a 1 by default (i.e. when a key is not being pressed).These facts, coupled with our knowledge of how the row and column wires of the hex keypad are wired
up to the DE2 board, will allow us to determine which key has been pressed. If we treat all the hex keypad wires as inputs, we will always read in a 0xFF, since there is nothing driving those wires they are unconnected. Even when a key is pressed, the effect is of connecting one input port to another, so the pull-up resistors will always output a 1.
42
5.6 RFID
Short for radio frequency identification, RFID is a dedicated short range communication (DSRC) technology. The term RFID is used to describe various technologies that use radio waves to automatically identify people or objects. RFID technology is similar to the bar code identification systems we see in retail stores everyday; however one big difference between RFID and bar code technology is that RFID does not rely on the line-of-sight reading that bar code scanning requires to work.
An antenna or coil
A transceiver (with decoder) A transponder (RF tag) electronically programmed with unique information
The antenna emits radio signals to activate the tag and to read and write data to it. The reader emits radio waves in ranges of anywhere from one inch to 100 feet or more, depending upon its power output and the radio frequency used. When an RFID tag passes through the electromagnetic zone, it detects the reader's activation signal.
The reader decodes the data encoded in the tag's integrated circuit (silicon chip) and the data is passed to the host computer for processing.
The purpose of an RFID system is to enable data to be transmitted by a portable device, called a tag, which is read by an RFID reader and processed according to the needs of a particular application. The data transmitted by the tag may provide identification or location information, or specifics about the product tagged, such as price, color, date of purchase, etc. RFID technology has been used by thousands of companies for a decade or more. . RFID
43
quickly gained attention because of its ability to track moving objects. As the technology is refined, more pervasive - and invasive - uses for RFID tags are in the works.
5.6.2 Applications
RFID has been used in manufacturing plants for more than a decade. It's used to track parts and work in process and to reduce defects, increase throughput and manage the production of different versions of the same product.
SupplyChainManagement
RFID technology has been used in closed loop supply chains or to automate parts of the supply chain within a company's control for years. As standards emerge, companies are increasingly turning to RFID to track shipments among supply chain partners.
Retailing
Retailers such as Best Buy, Metro, Target, Tesco and Wal-Mart are in the forefront of RFID adoption. These retailers are currently focused on improving supply chain efficiency and making sure product is on the shelf when customers want to buy it.
Payment Systems
RFID is all the rage in the supply chain world, but the technology is also catching on as a convenient payment mechanism. One of the most popular uses of RFID today is to pay for road tolls without stopping. These active systems have caught on in many countries, and quick service restaurants are experimenting with using the same active RFID tags to pay for meals at drive-through windows.
frequency RFID tags. Recently, vendors have introduced 13.56 MHz systems that offer longer read range. The advantage of RFID is it is convenient (an employee can hold up a badge to unlock a door, rather than looking for a key or swiping a magnetic stripe card) and because there is no contact between the card and reader, there is less wear and tear, and therefore less maintenance. As RFID technology evolves and becomes less expensive and more robust, it's likely that companies and RFID vendors will develop many new applications to solve common and unique business problems.
5.7 Buzzer
A buzzer or beeper is an audio signaling device, which may be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.
Applications:
Microwave ovens and House hold appliances Annunciate panels Electronic metronomes
45
CHAPTER 6
SOFTWARE DEVELOPMENT USING UVISION KEIL IDE
Step 1: Give a double click on uvision 4 icon on the desktop, it will generate a window as
shown below.
Step 2: To create new project go to project select new micro vision project . Step 3: select a drive where you would like to create your project. Step 4: Create a new folder and name it with your project name. Step 5: Open that project folder and give a name of your project executable file and save it. Step 6: After saving it will show some window there you select your microcontroller
company i.e NXP from Phillips.
Step 7: Select your chip as LPC2148 Step 8: After selecting chip click on OK then it will display some window asking to add
STARTUP file. Select YES .
Step 9: A target is created and startup filoe is added to your project target and is shown
below.
Step 10: To write your project code select a new file from FILE menu bar. Step 11: It will display some text editor ,to save that file select SAVE option from FILE
menu bar.
Step 12: By giving a file name lwith extension .C for c files and save it. Step 13: Write the code of your project and save it. Step 14: To add our c file to target give a right click on Source Group ,choose ADD files to
Group option.
Step 15: It will display some window there select the file you have to add and click on ADD
option.
Step 16: The file will be added to our target and it shows in the project window. Step 17: Now give a right click on target in the project window and select Options for
Target.
Step 18: It will shoe some window, in that go to output option and choose Create Hex file
option by selecting that box.
Step 19: In the same window go to Linker option and choose Use Memory Layout from
Target Dialog by selecting the box,and click OK.
Step 20: Now to Compile your project go to Project select Build Target option or press F7.
46
Step 21: In the build OUT PUT window you can see the errors and warnings if there in your
code.And here your project Hex file will be created.
47
Step 1-Communications
Set COM Port Baud Rate Device Interface :COM1 : 9600 : LPC2148 :None(ISP)
Step 2-Erase
Select the box Erase all Flash + Code Rd Prot
Step 4-Options
Select the box Verify after programming.
48
Power up the microcontroller board using USB cable, make serial cable connection between PC and microcontrollers UART0 db9 connector. To make the board enter programming mode Hold down Boot switch (isp) and Reset, then release Reset first and finally Boot.
Step 5-Start
Click the Start button
To start MikroC IDE click Start>Programs> Mikroelektronika>mikroC> mikroC. The initial screen will appear followed by the main window. If any project is opened close the project to create new project. Click the Close Project icon or select Project > Close Project from the drop-down menu: Click the New Project icon or select Project > New Project from the drop-down menu:
Compiler will create the project file and an accompanying source file, named same as your project. This source file will be automatically opened in the Code Editor, so we can write the source code. This is the Code Editor:
Build:
Now its time to build our project. First, save your file by clicking on the Save Icon, or click Ctrl+S. Select Project > Build from the drop-down menu, or click the Build Icon. You can also use the shortcut Ctrl+F9.
50
CHAPTER-7 RESULTS
Results at central stations:
When the passanger uses his RFID tag at any bus or bus stop, he has to enter details like source and destination. 51
After details are entered it displays no of seats remaining & filled. To confirm the ticket one has to press C. This data is sent to central station.
52
53
Fig 8.3 ARM 7 devolopment board with on board LPC2148 Micro-controller interfaced with RFID, hex key pad:
54
CONCLUSION
The Flexible Bus Systems is an efficient and a smart Demand Responsive Transit (DRT). It is flexible in a sense that it can change dynamically according to the demand of the passenger. The system can fulfil the demands of the passengers in a way that they have to wait less on the Bus Stops and even if they miss the Bus they can be entertained by the next bus without Waiting for very long. The use of Zigbee for communication between the Buses and the Bus Stops greatly reduce the total cost of the system. Everything is connected to the Control Centre which is the brain of the system. Control Centre and Bus Stops are connected through the internet and Buses and Control Centre are connected to each other through Bus Stops. All the characters (Buses, Bus Stops and Passengers) are updated with latest information all the times which makes The Flexible Bus Systems more information rich and reliable
55
REFERENCES
1 Shahin Farahani, Zigbee Wireless Networks and Transceivers
2 Lee, E., Ryu, K., Paik, I.: A Concept for Ubiquitous Transportation Systems and Related development Methodology. In: International IEEE Conference on Intelligent Transportation Systems, pp.37-42(2008) 3 Yuwei Li, Jessica Wang, Justin Chen, Michael Cassidy, Design of a DemandResponsive Transit System (California PATH Working Paper UCB-ITS-PWP-2007-4) 4 ZHANG Feizhou, CAO Xuejun, YANG Dongkai, Intelligent Scheduling of Public Traffic Vehicles Based on a Hybrid Genetic Algorithm (TSINGHUA SCIENCE AND TECHNOLOGY, ISSN 1007-0214 09/25 pp625-631, Volume 13, Number 5, October 2008) 5 Jin Xu, Zhe Huang, An Intelligent Model for Urban Demandresponsive Transport System Control (Journal of Software, Vol. 4, No. September 2009) 6 Remy Chevrier, Philippe Canalda, Pascal Chatonnay and Didier Josselin, Comparison of three Algorithms for solving the Convergent Demand Responsive Transportation Problem (Proceedings of the IEEE ITSC 2006) 7 Zigbee Standards Organization, Zigbee Specification, ZigBee Document 053474r17, January 17, 2008. 8 Tomohiro Utsumi, Shin Konno, Yusuke Kanno, Ken-ichi Yukimatsu,Mahito Kobayashi, Masashi Hashimoto, A Feasibility study on theBuffer-Less Routing Networks using Deflection Routing Control(Proceedings of IEICE Vol. J92-B No. 11 pp. 1741-1749 2009).
56
APPENDIX
#include <LPC214X.H> #include"header.h" #include"string.h" #define total_buses 4 #define bs1 0x31 #define BUZ_ON IO1CLR=(1<<31) #define BUZ_OFF IO1SET=(1<<31) volatile unsigned int no_persons=0,rem_seats=0;; unsigned char busroot[4][250] = { {"FROM : DSNR\tTO:JNTU \r\n sop no. stopname \r\n 1. DSNR \t2.Malakpet\r\n3. chaderghat\t4.koti\r\n5. abids \t6.lakdikappol\r\n7. khairtabad\t8.panjagutta\r\n9. ameerpet \r\n"}, {"FROM : DSNR\tTO:JNTU \r\n sop no. stopname \r\n 1. DSNR \t2.Malakpet\r\n3. chaderghat\t4.koti\r\n5. abids \t6.lakdikappol\r\n7. khairtabad\t8.panjagutta\r\n9. ameerpet \r\n"}, {"FROM : DSNR\tTO:JNTU \r\n sop no. stopname \r\n 1. DSNR \t2.Malakpet\r\n3. chaderghat\t4.koti\r\n5. abids \t6.lakdikappol\r\n7. khairtabad\t8.panjagutta\r\n9. ameerpet \r\n"}, {"FROM : DSNR\tTO:JNTU \r\n sop no. stopname \r\n 1. DSNR \t2.Malakpet\r\n3. chaderghat\t4.koti\r\n5. abids \t6.lakdikappol\r\n7. khairtabad\t8.panjagutta\r\n9. ameerpet \r\n"}}; unsigned char rfid_data[11],central_data[20],rfid_flag=0; const char tag[4][11] ={{"1D004526C2\0"},{"1D0043FE71\0"}, {"1C00FFF69F\0"},{"1E00C8CB74\0"}}; unsigned int tag_id=0,tag_index=0,index=0,keypad_flag=0,k=0,central_flag=0,i=16,bus_number=0,len=0,src=0,ds t=0,nop1=0; unsigned char tx_data[11],*bus_no,*source,*destin,*nop,key[3],DEC[4],unit_data[7]; int main() { 57
PINSEL0 = 0x00050005; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; IO0DIR = (1<<22) | (1<<21) | (1<<20) | (1<<19) | (1<<18) | (1<<17) | (1<<16); //keypad initialization IODIR1 = 0xC00f0000; IOCLR1 = 0x000f0000; IOCLR0 |= 0x0000f800; IO1SET = (1<<31); VPBDIV = 0x01; uart1_init(); uart0_init(); LCD_Init(); Delay(20); display_title1(); send_string0("\r\n Flexible BUS System "); send_string0("\r\n BUS No.1"); tx_data[0] = 'S'; tx_data[1] = 'P'; tx_data[2] = '1'; flushtext(); unit_data[0] = 'U'; unit_data[1] = '1'; unit_data[2] = 'R'; while(1) { if(rfid_flag == 1) { rfid_flag = 0; send_string0(rfid_data); 58 //P1.16-P1.19 (COLUMNS - outputs) //making outputs(clms) low p1.16,17,18,19 //making inputs(rows) low p0.12,13,11,15
tag_id = findtag_index(rfid_data); if(tag_id < 20) { send_string0("\r\n id is"); send_char0(tag_id+48); tx_data[3] = (unsigned char)(tag_id+48); send_string0("\r\n Enter Bus details like \r\n -->Root Number \r\n -->Source and Destination \r\n -->Number of persons \r\n after entering press 'C' to exit"); k = 0;i=16; keypad_flag = 0; display_title2(); b: display1(); keypad_flag = 0; k=0;i=16; while(keypad_flag == 0) bus_no = keypad_scan(); temp1 = data; if(data == 0) {
{ DEC[1]=DEC[2]=DEC[3]='\0';; } if(i==2) { DEC[3]='\0'; } if(i==1) { DEC[2]=DEC[3]='\0'; } while(temp1>0) { temp = temp1%10; temp1 = temp1/10; DEC[i] = temp + 48; i--; } } void buzzer() { BUZ_ON; Delay(30); BUZ_OFF; } LCD_Command(0x01); LCD_Command(0x80); LCD_String("Keypad scanning"); LCD_Command(0xC0); LCD_String("NOP :"); 60
} void display5() { LCD_Command(0x01); LCD_Command(0x80); LCD_String("Bus Root No. : 1"); LCD_Command(0xC0); LCD_String("C:60 F:"); LCD_String(DEC); } void display6() { LCD_Command(0xCA); LCD_String("A:"); LCD_Data(central_data[9]); LCD_Data(central_data[10]); } void HexatoDeci(unsigned int data) { unsigned int temp,temp1,i; i = 0;
61
} else if(choice==6) { UART0_SendStr("\r\n EXITING DATA BASE UPDATION_ADMIN "); return; } else if(choice==5) { UART0_SendStr("\r\n Seat updation "); seat_updation(); goto p; } else if(choice==4) { UART0_SendStr("\r\n Enter Block to clear (0/1) "); UART0_GetByte(); clear_memory(rdata-48); UART0_SendStr("\r\n CLEARED THE DATA BASE BY ADMIN "); } else if(choice==3) { display_memory_contents(0); display_memory_contents(1); goto p; } else if(choice==1) { bn=0x00; uen=0; UART0_SendStr("\r\n RFID TAG ID(1Bytes): "); 63
for(j=0;j<1;j++) { UART0_GetByte(); rftc[j]=rdata; UART0_SendByte(rftc[j]); uen++; } UART0_SendStr("\r\n CHECKING DATA BASE for RFID TAG.... "); for(i=1;i<=tdbp_blk0;i++) { i2c_read(BLK_0,((i*16)-1)); for(j=0;j<1;j++) str[j]=I2C_RD_Buf[j]; f=strcmp(rftc,str); if(f==0)//same as if(f) { UART0_SendStr("\r\n TAG ID FOUND "); fat=i; break; } } if(fat==0) { UART0_SendStr("\r\n TAG ID NOT FOUND"); UART0_SendStr("\r\n Want to create a new entry (Y/N) :"); UART0_GetByte(); UART0_SendByte(rdata); if(rdata=='Y' || rdata=='y') { fdbp_blk0=fdbp_blk0+1; 64
if(fdbp_blk0!=tdbp_blk0+1) { fdbp_blk1=fdbp_blk1+1; if(fdbp_blk1!=tdbp_blk1+1) { UART0_SendStr("\r\n Creating new entry ..."); fat=fdbp_blk1; } else { UART0_SendStr("\r\n Memory full ..."); goto p; } } else goto p; } UART0_SendStr("\r\n ENTER FARE (3Bytes)(000-999): "); for(j=0;j<3;j++) { UART0_GetByte(); fare[j]=rdata; UART0_SendByte(fare[j]); uen++; if((rdata-48)<0 || (rdata-48)>9) { UART0_SendStr("\r\n Wrong entry ..ENTER DIGITS "); uen--; j--; 65
} } UART0_SendStr("\r\n writing/reading to memory ------- "); for(j=0;j<1;j++) I2C_WR_Buf[j]=rn[j]; for(j=1;j<2;j++) I2C_WR_Buf[j]=sc[j-1]; for(j=2;j<5;j++) I2C_WR_Buf[j]=fare[j-2]; for(j=5;j<6;j++) I2C_WR_Buf[j]='6'; for(j=6;j<7;j++) I2C_WR_Buf[j]='0'; for(j=7;j<16;j++) I2C_WR_Buf[j]='\0'; i2c_write(BLK_1,((fat*16)-1)); i2c_read(BLK_1,((fat*16)-1)); UART0_SendStr(&I2C_RD_Buf[0]); } goto p;
66
PINSEL2 = 0x00000000; IO0DIR = (1<<22) | (1<<21) | (1<<20) | (1<<19) | (1<<18) | (1<<17) | (1<<16); //keypad initialization IODIR1 = 0x800f0000; IOCLR1 = 0x000f0000; IOCLR0 |= 0x0000f800; IO1SET = (1<<31); VPBDIV = 0x01; uart1_init(); uart0_init(); LCD_Init(); Delay(20); display_title1(); send_string0("\r\n Flexible BUS System "); send_string0("\r\n BUS STOP No.1"); tx_data[0] = 'S'; tx_data[1] = 'B'; tx_data[2] = '1'; flushtext(); while(1) { if(rfid_flag == 1) { rfid_flag = 0; send_string0(rfid_data); tag_id = findtag_index(rfid_data); if(tag_id < 20) { send_string0("\r\n id is"); 68 //P1.16-P1.19 (COLUMNS - outputs) //making outputs(clms) low p1.16,17,18,19 //making inputs(rows) low p0.12,13,11,15
send_char0(tag_id+48); tx_data[3] = (unsigned char)(tag_id+48); send_string0("\r\n Enter Bus details like \r\n -->Root Number \r\n -->Source and Destination \r\n -->Number of persons \r\n after entering press 'C' to exit"); k = 0;i=16; keypad_flag = 0; display_title2(); b: display1(); keypad_flag = 0; k=0;i=16; while(keypad_flag == 0) bus_no = keypad_scan(); keypad_flag = 0; send_string0("\r\n bn:"); send_string0(bus_no); len = strlen(bus_no); if(len == 1) bus_number = (bus_no[0]-0x30); else if(len == 2) bus_number = (bus_no[0]-0x30)*10 + (bus_no[1]-0x30);
if(bus_number>total_buses) { send_string0("\r\n Invalid bus number try again"); key[j]='\0'; } void display_title1() { LCD_Command(0x01); LCD_Command(0x80); LCD_String("Flexible Bus sys"); LCD_Command(0xC0); 69
send_string0("key pad scanning\n"); } void display1() { LCD_Command(0x01); LCD_Command(0x80); LCD_String("Keypad scanning"); LCD_Command(0xC0); LCD_String("Bus No :"); } void display2() { LCD_Command(0x01); LCD_Command(0x80); LCD_String("Keypad scanning"); LCD_Command(0xC0); LCD_String("Source :"); } void display3() { LCD_Command(0x01); 70
LCD_Command(0x80); LCD_String("Keypad scanning"); LCD_Command(0xC0); LCD_String("Destin :"); } void display4() { LCD_Command(0x01); LCD_Command(0x80); LCD_String("Keypad scanning"); LCD_Command(0xC0); LCD_String("NOP :"); } void buzzer() { BUZ_ON; Delay(30); BUZ_OFF; }
71