project report 22.pdf

download project report 22.pdf

of 93

Transcript of project report 22.pdf

  • 8/16/2019 project report 22.pdf

    1/93

    1

    Chapter-1

    INTRODUCTION

    1.1 Overview 

     Now-a-days advertisement is going digital. The big shops and the shopping centers use

    digital displays now. Also, in trains and buses the information like platform number,

    ticket information is displayed in digital boards. People are now adapted to the idea of the

    world at its finger-tips. The use mobile phones have increased drastically over years.

    Control and communication has become important in all the parts of the world.  This gave

    us the idea to use mobile phones to receive message and then display it on an electronic

     board. The GSM technology is used. GSM stands for Global System for Mobile

    Communication. Due to this international roaming capability of GSM, user can send

    message to receiver from any part of the world. It is has the system for SMS Short

    Message Service.

    This is an embedded based project. An embedded system is a combination of hardware

    and software and perhaps other mechanical parts designed to perform a specific function.

    A Notice Board is a very essential device in any institution/organization or public utility

     place like bus stations, railway stations and parks. The main aim of this project is to

    design an SMS driven automatic display which reduces the manual operation. The

    information can in turn be updated instantly at the desired location. Updates can be done

    in individual displays without disturbing other displays. The message to be displayed is

    sent as an SMS to a GSM receiver module. This message is then stored in PC and is sent

    to the LCD displays through the controller. The messages stored in the computer acts as a

    record for future reference. The monitoring system includes a micro-miniature camera

    which would be capable of acquiring 3 mega pixel color images, transfer them on to a

     personal computer through a Universal Serial Bus (USB) link, and also store the image in

    a micro SD card after applying an image  compression algorithm. The report explains how

  • 8/16/2019 project report 22.pdf

    2/93

    2

    a raw image data is captured by a CCD sensor and interfacing of the sensor with an

    ARM7 processor.

    1.2 Background 

    What makes SMS messaging so successful worldwide?

    SMS is a success all over the world. The number of SMS messages exchanged every day

    is enormous. SMS messaging is now one of the most important revenue sources of

    wireless carriers. What is so special about SMS that makes it so popular worldwide?

    Some of the reasons are discussed below. SMS messages can be sent and read at any

    time: Nowadays, almost every person has a mobile phone and carries it most of the time.

    With a mobile phone, you can send and read SMS messages at any time, no matter you

    are in your office, on a bus or at home. SMS messages can be sent to an offline mobile

     phone: Unlike a phone call, user can send an SMS message to user’s friend even when

    user’s friend  has not switched on the mobile phone or when user’s friend  is in a place

    where the wireless signal is temporarily unavailable. The SMS system of the mobile

    network operator will store the SMS message and later send it to user’s friend when

    user’s friend  mobile phone is online. All GSM mobile phones support it. Not only that

    user can exchange SMS messages with mobile users of the same wireless carrier, but user

    can also exchange SMS messages with mobile users of many other wireless carriers

    worldwide.

    SMS is a suitable technology for wireless applications to build on: Here are some of the

    reasons that make SMS a suitable technology for wireless applications to build on:

      Firstly, SMS messaging is supported by 100% GSM mobile phones. Building

    wireless applications on top of the SMS technology can maximize the potential

    user base.

      Secondly, SMS messages are capable of carrying binary data besides text. They

    can be used to transfer ringtones, pictures, operator logos, wallpapers, animations,

    VCards, VCals (calendar entries), etc.

  • 8/16/2019 project report 22.pdf

    3/93

    3

      Thirdly, SMS supports reverse billing, which enables payment to be made

    conveniently. For example, suppose user want to develop a commercial ringtone

    download application that charges a fee from the user for each ringtone

    downloaded. One way to accept payment is to use a reverse billing phone number

    obtained from a wireless carrier. To buy a ringtone, the user will write an ordinary

    SMS text message that contains the ID of the ringtone he/she wants to buy and

    send it to user’s  SMS application's reverse billing phone number. User’s  SMS

    application will then send back one or more reverse billing SMS messages that

    carry the ringtone. The user will be charged a fee for the reverse billing SMS

    messages he/she received. The fee will be included in the user's monthly mobile

     phone bill or be deducted from his/her prepaid card credits. Depending on the

    agreement between user and the wireless carrier, all or part of the money received

    will be given to user.

    1.3 Objective 

    1.  This project is a remote notice board with a GSM modem at the receivers end.

    2.  So if the user wants to display any message, he can send the information by SMS and

    thus update the LCD display accordingly.

    3. 

    As engineer’s main aim is to make life simple with help of technology, this is one

    step to simplify real time noticing.

    1.4 

    Characteristics

    It is High Quality Product (Not hobby grade) and Its Quad-Band GSM/GPRS and its

    frequency 850/ 900/ 1800/ 1900 MHz. It is built in RS232 Level Converter (MAX3232)

    and it has configurable baud rate. It is SMA connector with GSM L Type Antenna. It

    Built in SIM Card holder and in Network Status LED. Most Status & Controlling Pins are

    available at Connector. Its Normal operation temperature: -20 °C to +55 °C and Input

    Voltage: 5V-12V DC. 

  • 8/16/2019 project report 22.pdf

    4/93

    4

    1.5 Applications

    1. 

    Educational Institutions and Organizations:  Currently user rely on putting up

     papers on notice boards to inform people of events. This method can be discarded by

    using wireless notice boards to display information in real time. 

    2.  Crime Prevention:   Display boards put up on roads will display tips on public

    security, accident prevention, information on criminals on the run. The board will

    help flash messages such as vehicle thefts as and when they occur.  

    3. 

    Managing Traffic: 

      In metropolitan cities user frequently come across traffic jams.One way to avoid this would be inform people beforehand to take alternate routes. A

    wireless notice board serves well for this purpose. 

    4.  Advertisement:  In shopping malls user get to hear the offers on various products

    from time to time. Instead everyone continuously display the information regarding

    the products and related offers on electronic display boards. 

    5.  Railway Station:   Instead of announcing the delay in arrival of trains user   can display

    the information. 

    1.6 Merits

    1.  User friendly:  Messages are only to be typed on a mobile or a computer, which in

    turn are displayed wirelessly on the display unit. 

    2.  Eliminates use of printers:  Since everyone don’t use papers to display information,

     printers are also of no use in this system.

    3.  Faster means of transferring information:  There is no delay in transmission of

    information. Messages are displayed in a matter of seconds after typing. 

  • 8/16/2019 project report 22.pdf

    5/93

    5

    4.  Long Range:  As long as everyone have the required network coverage everyone can

    send messages from any part of the world. 

    1.7 

    Needs

    1.  Uses in Banks: There is a huge mass of population which depends upon the banks for

    all their monetary transactions. To keep a proper track of such huge mass of people

    and their transactions this technology helps with certain degree of effectiveness.

    2.  Uses for Traffic Control: It’s known to all of us that traffic are the good servants of

    the people and also the major invention to help people but only if it is managed well.

    So with the use of this technology we can maintain the flow of traffic according to the

    needs of the people and also considering the availability of roads.

    3.  Uses for advertisement: We can make use of this technology to display the different

    advertisement on display panels to reach the larger number of people at a time and in

    the populated places like shopping malls, road sides as well as at the theaters, discos,

    hotels, motels, restaurants etc. about their products and features.

    4.  Uses in Educational sector: Currently in India we are relying on the old style of

    displaying news by hanging bare time consuming papers on the notice board whichcan be replaced by remote controlled notice boards at the colleges and universities,

    also at the time of examination scheduling and result publishing etc.

    5.  Stock Exchange: The stock exchange is the hot topic nowadays. There are millions

    of sales of shares every hours and it is very necessary to maintain the real time

    services with the certain measures of reliability because it deals with the money large

    number of the small or bigger investors. With the help of this technology we can

    make it far easier and reliable.

  • 8/16/2019 project report 22.pdf

    6/93

    6

    Chapter-2 

    IMPLEMENTATION OF PROTOTYPE MODEL

    2.1: Block Diagram 

    Fig.2.1: block diagram 

    2.2: Description of Block Diagram 

    The design of the project is basically divided into two section :-

    1.  Transmitting section

    2.  Receiving section

  • 8/16/2019 project report 22.pdf

    7/93

    7

    2.2.1: Transmitting Section

    Transmitting Section consists of just mobile which has inbuilt GSM modem for wireless

    data transfer through GSM.Since it is a multiuser system, various users are authenticated

    to use the system or display messages on the notice board.For security, individual

     passwords are provided to authorized users. To display their message on notice board, a

    user need to authenticate itself with the system by sending message containing the

    assigned password and the text to the receiver section’s SIM number. 

    2.2.2: Receiving Section

    The receiving section’s system verifies password and sends response to the user

    and displays the text on the electronic notice board.

    Fig. 2.2: Block Diagram of Receiving Section

    2.2.3: GSM Network  

    It consists of Global System for Mobile Communication. It is originally from Group of

    Special Mobile. It is the most popular standard for mobile phone in the world. GSM is a

    cellular network, which means that mobile phones connect to it by searching for cells inthe immediate vicinity. The modulation used in GSM is Gaussian minimum-shift keying

    (GMSK), signal to be modulated onto the carrier is first smoothed with a Gaussian low

     pass filter prior to being fed to a frequency modulator which greatly reduces adjacent

    channel interference.For this type of application we needed the GSM cell phone which

    supports AT commands. After many searches we found out that Motorola C168 is the

  • 8/16/2019 project report 22.pdf

    8/93

    8

    only mobile which supports each and every AT command. For   serial communication we

    have used 2.5mm jack cable with the jack provided in mobile.

    Fig.2.3: 5mm Jack For serial communication

  • 8/16/2019 project report 22.pdf

    9/93

    9

    2.4: Flow Chart

    Fig.2.4: Flow Chart 

  • 8/16/2019 project report 22.pdf

    10/93

    10

    2.4: Circuit Diagram

    Fig 2.5: Circuit diagram 

    2.5: Operation 

    Initially an authorized mobile user will send a message containing information to choose

    the required LCD display. For security purpose we have included a password. Access

    will be granted to the user who is aware of the password. Once the message is received it

    is stored in the computer. Here a real time clock displays the time in the graphical LCD.

    The graphical display can be used to view the marks of the students or any information

    about the institution or organization. When there is a high priority message (mobile user)

    the current information that is displayed will be held up and this high priority message

    will be displayed. The audio driver which has the pre-recorded voice will announce the

    arrival of new messages.

  • 8/16/2019 project report 22.pdf

    11/93

    11

    2.5.1: AT Commands

    AT commands are instructions used to control a modem. AT is the abbreviation of AT

    tension. Every command line starts with "AT" or "at". That's why modem commands are

    called AT commands. Many of the commands that are used to control wired dial-up

    modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to

    online data state), are also supported by GSM/GPRS modems and mobile phones.

    Besides this common AT command set, GSM/GPRS modems and mobile phones support

    an AT command set that is specific to the GSM technology, which includes SMS-related

    commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from

    storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages).

    2.5.2: Reading Messages 

    To enable a computer / PC to read SMS messages from a message storage area, the

    GSM/GPRS modem or mobile phone has to support either of the AT commands +CMGR

    (command name in text: Read Messages) and +CMGL (command name in text: List

    Messages). The +CMGR AT command is used to read an SMS message at a certain

    location of the message storage area, while the +CMGL AT command is used to read

    SMS messages that have a certain status from the message storage area. The status can be"received unread", "received read", "stored unsent", "stored sent", etc. The +CMGL AT

    command also allows you to retrieve all SMS messages stored in the message storage

    area Following is an example for illustrating the difference between +CMGR and

    +CMGL. Suppose you want to use your computer / PC to read a text message from the

    message storage area and you know the index at which the SMS text message is located.

    In this case, you should use the +CMGR AT command. Here is the command line to be

    typed (assume the SMS text message is stored at index 3) :

    AT+CMGR=3

    The GSM/GPRS modem or mobile phone should return something like this:

    +CMGR: "REC

  • 8/16/2019 project report 22.pdf

    12/93

    12

    READ","+85291234567","07/02/18,00:12:05+32"

    Hello, welcome to our SMS tutorial.

    OK

    2.5.3: Software

    For more efficient and hasty programming user went for Bascom AVR which is specially

    for AVRs like ATmega16. It is because it have the in-built functions for LCD’s , UARTs

    etc. so and also by simulation user can check our output on virtual LCD. Also by direct

    connection out AVR user can burn the program from Bascom AVR only. Here user

     provide a basic starting of a code to configure LCD and UART

    $regfile = "m48def.dat" ' we use the M48

    $crystal = 8000000 ` crystal frequency

    $baud = 19200 ` baud rate

    $hwstack = 32 ` hardware stack

    $frame size = 24

    Dim A As Byte , C As Integer , S As String * 4

    A = 1

    So as given, code is very easy to write and it have many other advantages than our

    conventional AVR Studio 4 software.

  • 8/16/2019 project report 22.pdf

    13/93

    13

    2.5.4: Schematic and Layout

    Here we use Express PCB to design Schematic and Layout of our main circuit before

     printing. This software is very easy to use for beginners. Let I explain you the steps for

    PCB

      There are two parts to Express PCB, CAD software and board manufacturing

    service.CAD software includes Express SCH for drawing schematics and Express

    PCB for designing circuit boards. After completing PC board design, we provide

    a low cost, high quality and fast source for having boards made. Here is how it

    works:

    1.  It is recommend that you begin your project by drawing a schematic using

    Express SCH. Drawing a schematic is not required, but it will save you time

    when designing your board and reduce the possibility of wiring errors.

    2. 

     Next, use the Express PCB program to lay out PC board. If you link schematic

    to the Express PCB program, the program will guide you through the wiring

     process by highlighting how the components should be connected.

    3.  When layout is complete, the Express PCB program will tell you the exact

    cost to have your boards made.

    4. 

    To order the boards, simply enter your name, address and billing information

    into Express PCB and press the Send button in the Order Boards Via The

    Internet dialog box.

    5.  In a few business days (typically 2 or 3) an overnight courier will deliver your

    PC boards.

  • 8/16/2019 project report 22.pdf

    14/93

    14

    2.6: Working 

    1.  Using GSM mobile user can send message to any distant located e-notice board from

    any remote area.

    2.  By interfacing the GSM modem with mobile phone user can send text message from

    any remote area.

    3.  GSM MODEM, SIM, LCD (Liquid Crystal Display), microcontroller,power supply

    and also some connecting wires are the common peripherals required for developing

    any GSM based applications. As the components required for the application are

    available at pocket friendly prices and due to their ease of accessibility enhanced

    GSM based applications.

  • 8/16/2019 project report 22.pdf

    15/93

    15

    Chapter-3 

    HARDWARE REQUIREMENT

    3.1: Components

    Essential components for assembling GSM based applications including:

    1.  GSM MODEM

    2.  SIM

    3.  Power supply or Power Adapter

    4.  LCD

    5.  Voltage Regulator

    6.  Transformer

    7.  Capacitor

    8. 

    LED

    9.  Resistor

    10. Push Switch

    11. Microcontroller

    3.1.1: GSM Modem 

    It is a wireless MODEM-just like dial-up MODEM works with GSM wireless

    network. The difference between dial-up MODEM and wireless MODEM is, wireless

    MODEM send and receive data through radio waves whereas dial-up MODEM send and

    receives data through a fixed telephone line. GSM (Global System for Mobile

    Communications, originally Groupe Spécial Mobile), is a standard developed by

  • 8/16/2019 project report 22.pdf

    16/93

    16

    the European Telecommunications Standards Institute (ETSI) to describe protocols for

    second-generation (2G)  digital cellular networks used by mobile phones. As of 2014 it

    has become the default global standard for mobile communications - with over 90%

    market share, operating in over 219 countries and territories. 2G networks developed as a

    replacement for first generation (1G)  analog cellular networks, and the GSM standard

    originally described a digital, circuit-switched network optimized for full

    duplex voice telephony. This expanded over time to include data communications, first

     by circuit-switched transport, then by packet data transport via GPRS (General Packet

    Radio Services) and EDGE (Enhanced Data rates for GSM Evolution or EGPRS).

    Subsequently, the 3GPP developed third-generation (3G) UMTS standards followed by

    fourth-generation (4G) LTE Advanced standards, which do not form part of the ETSI

    GSM standard. "GSM" is a trademark owned by the GSM Association.  It may also refer

    to the (initially) most common voice codec used, Full Rate. 

    Fig. 3.1: GSM MODEM available in local market.

    http://en.wikipedia.org/wiki/European_Telecommunications_Standards_Institutehttp://en.wikipedia.org/wiki/2Ghttp://en.wikipedia.org/wiki/Cellular_networkhttp://en.wikipedia.org/wiki/Mobile_phonehttp://en.wikipedia.org/wiki/1Ghttp://en.wikipedia.org/wiki/Duplex_(telecommunications)#Full_duplexhttp://en.wikipedia.org/wiki/Duplex_(telecommunications)#Full_duplexhttp://en.wikipedia.org/wiki/Telephonyhttp://en.wikipedia.org/wiki/Network_packethttp://en.wikipedia.org/wiki/GPRShttp://en.wikipedia.org/wiki/EDGEhttp://en.wikipedia.org/wiki/3GPPhttp://en.wikipedia.org/wiki/3Ghttp://en.wikipedia.org/wiki/UMTShttp://en.wikipedia.org/wiki/4Ghttp://en.wikipedia.org/wiki/LTE_Advancedhttp://en.wikipedia.org/wiki/Trademarkhttp://en.wikipedia.org/wiki/GSM_Associationhttp://en.wikipedia.org/wiki/Full_Ratehttp://en.wikipedia.org/wiki/Full_Ratehttp://en.wikipedia.org/wiki/GSM_Associationhttp://en.wikipedia.org/wiki/Trademarkhttp://en.wikipedia.org/wiki/LTE_Advancedhttp://en.wikipedia.org/wiki/4Ghttp://en.wikipedia.org/wiki/UMTShttp://en.wikipedia.org/wiki/3Ghttp://en.wikipedia.org/wiki/3GPPhttp://en.wikipedia.org/wiki/EDGEhttp://en.wikipedia.org/wiki/GPRShttp://en.wikipedia.org/wiki/Network_packethttp://en.wikipedia.org/wiki/Telephonyhttp://en.wikipedia.org/wiki/Duplex_(telecommunications)#Full_duplexhttp://en.wikipedia.org/wiki/Duplex_(telecommunications)#Full_duplexhttp://en.wikipedia.org/wiki/1Ghttp://en.wikipedia.org/wiki/Mobile_phonehttp://en.wikipedia.org/wiki/Cellular_networkhttp://en.wikipedia.org/wiki/2Ghttp://en.wikipedia.org/wiki/European_Telecommunications_Standards_Institute

  • 8/16/2019 project report 22.pdf

    17/93

    17

    3.1.1.1: Technical Details 

    Fig. 3.2: Structure of GSM Network  

    3.1.1.2: Network Structure

    The network is structured into a number of discrete sections:

    1.  Base Station Subsystem:  the base stations and their controllers explained.

    2.  Network and Switching Subsystem:  the part of the network most similar to a fixed

    network, sometimes just called the "core network."

    3.  GPRS Core Network :  the optional part which allows packet-based Internet

    connections.

    4.  Operations support system (OSS): network maintenance.

    http://en.wikipedia.org/wiki/Base_Station_Subsystemhttp://en.wikipedia.org/wiki/Network_and_Switching_Subsystemhttp://en.wikipedia.org/wiki/GPRS_Core_Networkhttp://en.wikipedia.org/wiki/Operations_support_systemhttp://en.wikipedia.org/wiki/Operations_support_systemhttp://en.wikipedia.org/wiki/GPRS_Core_Networkhttp://en.wikipedia.org/wiki/Network_and_Switching_Subsystemhttp://en.wikipedia.org/wiki/Base_Station_Subsystem

  • 8/16/2019 project report 22.pdf

    18/93

    18

    3.1.1.3: Pin Diagram of GSM Module

    Fig. 3.3: Pin Diagram of GSM Module 

    3.1.2 Subscriber Identity Module (SIM)

    One of the key features of GSM is the Subscriber Identity Module, commonly known as

    a SIM card. The SIM is a detachable smart car d containing the user's subscription

    information and phone book. This allows the user to retain his or her information after

    switching handsets. Alternatively, the user can also change operators while retaining the

    handset simply by changing the SIM. Some operators will block this by allowing the

     phone to use only a single SIM, or only a SIM issued by them; this practice is known

    as SIM locking 

    http://en.wikipedia.org/wiki/Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Smart_cardhttp://en.wikipedia.org/wiki/SIM_lockhttp://en.wikipedia.org/wiki/SIM_lockhttp://en.wikipedia.org/wiki/SIM_lockhttp://en.wikipedia.org/wiki/Smart_cardhttp://en.wikipedia.org/wiki/Subscriber_Identity_Module

  • 8/16/2019 project report 22.pdf

    19/93

    19

    3.1.2.1: Phone locking

    Sometimes mobile network operators r estrict handsets that they sell for use with their

    own network. This is called locking and is implemented by a software feature of the

     phone. A subscriber may usually contact the provider to remove the lock for a fee, utilize

     private services to remove the lock, or use software and websites to unlock the handset

    themselves. In some countries (e.g., Bangladesh, Brazil, Chile, Germany, Hong Kong, 

    India,  Iran, Lebanon, Malaysia, Nepal, Pakistan, Singapore, South Africa) all phones are

    sold unlocked.

    3.1.2.2: GSM service security

    GSM was designed with a moderate level of service security. The system was designed to

    authenticate the subscriber using a pre-shared key and challenge-response. 

    Communications between the subscriber and the base station can be encrypted. The

    development of  UMTS introduces an optional Universal Subscriber Identity

    Module (USIM), that uses a longer authentication key to give greater security, as well as

    mutually authenticating the network and the user, whereas GSM only authenticates the

    user to the network (and not vice versa). The security model therefore offers

    confidentiality and authentication, but limited authorization capabilities, and no non-repudiation.

    GSM uses  General Packet Radio Service  (GPRS) for data transmissions like browsing the

    web. The most commonly deployed GPRS ciphers were publicly broken in 2011. The

    researchers revealed flaws in the commonly used GEA/1 and GEA/2 ciphers and

     published the open-source "GPRS decode" software for sniffing GPRS networks. They

    also noted that some carriers do not encrypt the data (i.e., using GEA/0) in order to detect

    the use of traffic or protocols they do not like (e.g. , Skype), leaving customers

    unprotected. GEA/3 seems to remain relatively hard to break and is said to be in use on

    some more modern networks. If used with USIM to prevent connections to fake base

    stations and downgrade attacks, users will be protected in the medium term, though

    migration to 128-bit GEA/4 is still recommended.

    http://en.wikipedia.org/wiki/Mobile_network_operatorhttp://en.wikipedia.org/wiki/Bangladeshhttp://en.wikipedia.org/wiki/Brazilhttp://en.wikipedia.org/wiki/Chilehttp://en.wikipedia.org/wiki/Germanyhttp://en.wikipedia.org/wiki/Hong_Konghttp://en.wikipedia.org/wiki/Indiahttp://en.wikipedia.org/wiki/Iranhttp://en.wikipedia.org/wiki/Lebanonhttp://en.wikipedia.org/wiki/Malaysiahttp://en.wikipedia.org/wiki/Nepalhttp://en.wikipedia.org/wiki/Pakistanhttp://en.wikipedia.org/wiki/Singaporehttp://en.wikipedia.org/wiki/South_Africahttp://en.wikipedia.org/wiki/Pre-shared_keyhttp://en.wikipedia.org/wiki/Challenge-response_authenticationhttp://en.wikipedia.org/wiki/Universal_Mobile_Telecommunications_Systemhttp://en.wikipedia.org/wiki/Universal_Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Universal_Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Non-repudiationhttp://en.wikipedia.org/wiki/Non-repudiationhttp://en.wikipedia.org/wiki/General_Packet_Radio_Servicehttp://en.wikipedia.org/wiki/Packet_analyzerhttp://en.wikipedia.org/wiki/Skypehttp://en.wikipedia.org/wiki/Subscriber_Identity_Modulehttp://en.wikipedia.org/w/index.php?title=Fake_base_station&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=Fake_base_station&action=edit&redlink=1http://en.wikipedia.org/wiki/Downgrade_attackhttp://en.wikipedia.org/wiki/Downgrade_attackhttp://en.wikipedia.org/w/index.php?title=Fake_base_station&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=Fake_base_station&action=edit&redlink=1http://en.wikipedia.org/wiki/Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Skypehttp://en.wikipedia.org/wiki/Packet_analyzerhttp://en.wikipedia.org/wiki/General_Packet_Radio_Servicehttp://en.wikipedia.org/wiki/Non-repudiationhttp://en.wikipedia.org/wiki/Non-repudiationhttp://en.wikipedia.org/wiki/Universal_Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Universal_Subscriber_Identity_Modulehttp://en.wikipedia.org/wiki/Universal_Mobile_Telecommunications_Systemhttp://en.wikipedia.org/wiki/Challenge-response_authenticationhttp://en.wikipedia.org/wiki/Pre-shared_keyhttp://en.wikipedia.org/wiki/South_Africahttp://en.wikipedia.org/wiki/Singaporehttp://en.wikipedia.org/wiki/Pakistanhttp://en.wikipedia.org/wiki/Nepalhttp://en.wikipedia.org/wiki/Malaysiahttp://en.wikipedia.org/wiki/Lebanonhttp://en.wikipedia.org/wiki/Iranhttp://en.wikipedia.org/wiki/Indiahttp://en.wikipedia.org/wiki/Hong_Konghttp://en.wikipedia.org/wiki/Germanyhttp://en.wikipedia.org/wiki/Chilehttp://en.wikipedia.org/wiki/Brazilhttp://en.wikipedia.org/wiki/Bangladeshhttp://en.wikipedia.org/wiki/Mobile_network_operator

  • 8/16/2019 project report 22.pdf

    20/93

    20

    3.1.3: Power Supply

    Power supply is the source of electrical power. Normally any electronic circuit uses +5v

    DC power for its regular working .User can directly built +5v Dc power supply using 4

    diodes, filter capacitors and regulator IC-7805(Integrated Circuit)or can directly purchase

    a +5v DC power adopter from the local market.

    Fig. 3.4: +5v DC power supply for microcontroller  

    3.1.4: Liquid Crystal Display (LCD)

    One of the most common devices attached to an 8051 is an LCD display. Some of the

    most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16

    characters per line by 2 lines and 20 characters per line by 2 lines, respectively. In recent

    years the LCD is finding widespread use replacing LED‟s. This is due to the following

    reasons:

      Declining prices

      Ability to display numbers, characters and graphics.

      Incorporation of a refreshing controller into the LCD.

      Ease of programming.

    The command register stores the command instructions given to the LCD. A command is

    an instruction given to LCD to do a predefined task like initializing it, clearing its screen,

    setting the cursor position, controlling display etc. The data register stores the data to be

    displayed on the LCD. The data is the ASCII value of the character to be displayed on the

    LCD.

  • 8/16/2019 project report 22.pdf

    21/93

    21

    Fig. 3.5: 16x2 LCD

    3.1.4.1: Features

      It has 5 x 8 dots with cursor.

      Built- in controller (KS 0066 or Equivalent) In 16X2 LCD.

      It consist of + 5V power supply (Also available for + 3V).

      This LCD has 1/16 duty cycle.

    Table 3.1: Pin Configuration of LCD

  • 8/16/2019 project report 22.pdf

    22/93

    22

    3.1.4.2: Important Signals

    The following pins are important to LCD‟s while programming:

    A.  Enable (EN):  The EN line is called "Enable." This control line is used to tell the

    LCD that you are sending it data. To send data to the LCD, your program should

    make sure this line is low (0) and then set the other two control lines and/or put

    data on the data bus. When the other lines are completely ready, bring EN high

    (1) and wait for the minimum amount of time required by the LCD datasheet (this

    varies from LCD to LCD), and end by bringing it low (0) again.

    B.  Register Select (RS):  The RS line is the "Register Select" line. When RS is low

    (0), the data is to be treated as a command or special instruction (such as clear

    screen, position cursor, etc.). When RS is high (1), the data being sent is text data

    which should be displayed on the screen. For example, to display the letter "T" on

    the screen you would set RS high.

    C.  Read/Write (R/W):  The RW line is the "Read/Write" control line. When RW is

    low (0), the information on the data bus is being written to the LCD. When RW is

    high (1), the program is effectively querying (or reading) the LCD. Only one

    instruction ("Get LCD status") is a read command. All others are write

    commands--so RW will almost always be low. The 10k Potentiometer controls

    the contrast of the LCD panel.

    3.1.5: Voltage Regulator

    7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linearvoltage regulator ICs. The voltage source in a circuit may have fluctuations and would

    not give the fixed voltage output. The voltage regulator IC maintains the output voltage at

    a constant value. The xx in 78xx indicates the fixed output voltage it is designed to

     provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be

    connected at input and output pins depending upon the respective voltage levels.

  • 8/16/2019 project report 22.pdf

    23/93

    23

    Fig. 3.6: Voltage Regulator 7805  Fig. 3.7: Pin diagram of Voltage

    Regulator 7805

    3.1.6: Transformer 

    Transformer is a static electrical device which transfers electrical energy from one circuit

    to another circuit. Transformer working can be easily understood by its primary and

    secondary windings.

    Fig. 3.8: Step down Transformer

    3.1.7: Capacitor

    The capacitor's function is to store electricity, or electrical energy.  

    The capacitor also functions as a filter, passing alternating current (AC), and blocking

    direct current (DC).  This symbol is used to indicate a capacitor in a circuit diagram. 

  • 8/16/2019 project report 22.pdf

    24/93

    24

    The capacitor is constructed with two electrode plates facing each other, but separated by

    an insulator.  When DC voltage is applied to the capacitor,  an electric charge is stored on

    each electrode. While the capacitor is charging up, current flows. The current will stop

    flowing when the capacitor has fully charged.

    Fig. 3.9: Circuit Diagram of Capacitor

    When a circuit tester, such as an analog meter set to measure resistance, is connected to a

    10 microfarad (µF) electrolytic capacitor, a current will flow, but only for a moment. You

    can confirm that the meter's needle moves off of zero, but returns to zero right away.

    When user connect the meter's probes to the capacitor in reverse, you will note that

    current once again flows for a moment. Once again, when the capacitor has fully charged,

    the current stops flowing. So the capacitor can be used as a filter that blocks DC current.

    (A "DC cut" filter.) However, in the case of alternating current, the current will be

    allowed to pass. Alternating current is similar to repeatedly switching the test meter's

     probes back and forth on the capacitor. Current flows every time the probes are switched.

    Sometimes, a three-digit code is used to indicate the value of a capacitor. There are two

    ways in which the capacitance can be written. One uses letters and numbers, the other

    uses only numbers. In either case, there are only three characters used. [10n] and [103]

    denote the same value of capacitance. The method used differs depending on the

    capacitor supplier. In the case that the value is displayed with the three-digit code, the 1st

    and 2nd digits from the left show the 1st figure and the 2nd figure, and the 3rd digit is a

    multiplier which determines how many zeros are to be added to the capacitance. Pico

    farad (pF) units are written this way.

  • 8/16/2019 project report 22.pdf

    25/93

    25

    3.1.7.1: Breakdown Voltage 

    When using a capacitor, you must pay attention to the maximum voltage which can be

    used. This is the "breakdown voltage." The breakdown voltage depends on the kind of

    capacitor being used. You must be especially careful with electrolytic capacitors because

    the breakdown voltage is comparatively low. The breakdown voltage of electrolytic

    capacitors is displayed as Working Voltage. The breakdown voltage is the voltage that

    when exceeded will cause the dielectric (insulator) inside the capacitor to break down and

    conduct. When this happens, the failure can be catastrophic.

    3.1.8 Light Emitting Diode (LED) 

    A light-emitting diode (LED) is a two-lead semiconductor light source. It is apn-

     junction diode, which emits light when activated. When a suitable voltage is applied to

    the leads, electrons are able to recombine with electron holes  within the device, releasing

    energy in the form of  photons.  This effect is called  electroluminescence, and the color of

    the light (corresponding to the energy of the photon) is determined by the energy band

    gap of the semiconductor.

    An LED is often small in area (less than 1 mm2) and integrated optical components may

     be used to shape its radiation pattern. Appearing as practical electronic components in

    1962,[6] the earliest LEDs emitted low-intensity infrared light. Infrared LEDs are still

    frequently used as transmitting elements in remote-control circuits, such as those in

    remote controls for a wide variety of consumer electronics. The first visible-light LEDs

    were also of low intensity, and limited to red. Modern LEDs are available across

    the visible, ultraviolet, and infrared wavelengths, with very high brightness.

    Early LEDs were often used as indicator lamps for electronic devices, replacing small

    incandescent bulbs. They were soon packaged into numeric readouts in the form

    of  seven-segment displays, and were commonly seen in digital clocks. Recent

    developments in LEDs permit them to be used in environmental and task lighting. LEDs

    http://en.wikipedia.org/wiki/Semiconductorhttp://en.wikipedia.org/wiki/Light_sourcehttp://en.wikipedia.org/wiki/Pn-junctionhttp://en.wikipedia.org/wiki/Pn-junctionhttp://en.wikipedia.org/wiki/Diodehttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Electronshttp://en.wikipedia.org/wiki/Electron_holeshttp://en.wikipedia.org/wiki/Photonhttp://en.wikipedia.org/wiki/Electroluminescencehttp://en.wikipedia.org/wiki/Band_gaphttp://en.wikipedia.org/wiki/Band_gaphttp://en.wikipedia.org/wiki/Radiation_patternhttp://en.wikipedia.org/wiki/Light-emitting_diode#cite_note-LemelsonMIT-6http://en.wikipedia.org/wiki/Visible_spectrumhttp://en.wikipedia.org/wiki/Ultraviolethttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Seven-segment_displayhttp://en.wikipedia.org/wiki/Seven-segment_displayhttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Ultraviolethttp://en.wikipedia.org/wiki/Visible_spectrumhttp://en.wikipedia.org/wiki/Light-emitting_diode#cite_note-LemelsonMIT-6http://en.wikipedia.org/wiki/Radiation_patternhttp://en.wikipedia.org/wiki/Band_gaphttp://en.wikipedia.org/wiki/Band_gaphttp://en.wikipedia.org/wiki/Electroluminescencehttp://en.wikipedia.org/wiki/Photonhttp://en.wikipedia.org/wiki/Electron_holeshttp://en.wikipedia.org/wiki/Electronshttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Diodehttp://en.wikipedia.org/wiki/Pn-junctionhttp://en.wikipedia.org/wiki/Pn-junctionhttp://en.wikipedia.org/wiki/Light_sourcehttp://en.wikipedia.org/wiki/Semiconductor

  • 8/16/2019 project report 22.pdf

    26/93

    26

    have many advantages over incandescent light sources including lower energy

    consumption, longer lifetime, improved physical robustness, smaller size, and faster

    switching. Light-emitting diodes are now used in applications as diverse as aviation

    lighting, automotive headlamps, advertising, general lighting, traffic signals, and camera

    flashes. However, LEDs powerful enough for room lighting are still relatively expensive,

    and require more precise current and heat management than compact fluorescent

    lamp sources of comparable output. LEDs have allowed new text, video displays, and

    sensors to be developed, while their high switching rates are also useful in advanced

    communications technology.

    Fig. 3.10: Diagram of LED

    Fig.3.11: Characteristics of Diode 

    http://en.wikipedia.org/wiki/Navigation_light#Aviation_navigation_lightshttp://en.wikipedia.org/wiki/Navigation_light#Aviation_navigation_lightshttp://en.wikipedia.org/wiki/Automotive_lighting#Light_emitting_diodes_.28LED.29http://en.wikipedia.org/wiki/Lightinghttp://en.wikipedia.org/wiki/Traffic_signalhttp://en.wikipedia.org/wiki/Fluorescent_lamphttp://en.wikipedia.org/wiki/Fluorescent_lamphttp://en.wikipedia.org/wiki/File:LED,_5mm,_green_(en).svghttp://en.wikipedia.org/wiki/Fluorescent_lamphttp://en.wikipedia.org/wiki/Fluorescent_lamphttp://en.wikipedia.org/wiki/Traffic_signalhttp://en.wikipedia.org/wiki/Lightinghttp://en.wikipedia.org/wiki/Automotive_lighting#Light_emitting_diodes_.28LED.29http://en.wikipedia.org/wiki/Navigation_light#Aviation_navigation_lightshttp://en.wikipedia.org/wiki/Navigation_light#Aviation_navigation_lights

  • 8/16/2019 project report 22.pdf

    27/93

    27

    The graph above shows the electrical characteristics of a typical diode. When a small

    voltage is applied to the diode in the forward direction, current flows easily. Because the

    diode has a certain amount of resistance, the voltage will drop slightly as current flows

    through the diode. A typical diode causes a voltage drop of about 0.6 - 1V (VF) (In the

    case of silicon diode, almost 0.6V). This voltage drop needs to be taken into

    consideration in a circuit which uses many diodes in series. Also, the amount of current

     passing through the diodes must be considered. When voltage is applied in the reverse

    direction through a diode, the diode will have a great resistance to current flow. Different

    diodes have different characteristics when reverse-biased. A given diode should be

    selected depending on how it will be used in the circuit. The current that will flow

    through a diode biased in the reverse direction will vary from several mA to just µA,

    which is very small. The limiting voltages and currents permissible must be considered

    on a case by case basis. For example, when using diodes for rectification, part of the time

    they will be required to withstand a reverse voltage. If the diodes are not chosen

    carefully, they will break down.

    3.1.9 Resistor 

    The resistor's function is to reduce the flow of electric current.  

    This symbol is used to indicate a resistor in a circuit diagram, known as a

    schematic. Resistance value is designated in units called the "Ohm." A 1000 Ohm resistor

    is typically shown as 1K-Ohm ( kilo Ohm ), and 1000 K-Ohms is written as 1M-Ohm

    (mega ohm).

    There are two classes of resistors; fixed resistors and the variable resistors.

    They are also classified according to the material from which they are made. The typical

    resistor is made of either carbon film or metal film. There are other types as well, butthese are the most common.  The resistance value of the resistor is not the only thing to

    consider when selecting a resistor for use in a circuit. The "tolerance" and the electric

     power ratings of the resistor are also important.  The tolerance of a resistor denotes how

    close it is to the actual rated resistance value. For example, a ±5% tolerance would

    indicate a resistor that is within ±5% of the specified resistance value. 

  • 8/16/2019 project report 22.pdf

    28/93

    28

    The power rating indicates how much power the resistor can safely tolerate. The

    maximum rated power of the resistor is specified in Watts.  

    Power is calculated using the square of the current ( I2  ) x the resistance value ( R ) of the

    resistor. If the maximum rating of the resistor is exceeded, it will become extremely hot,

    and even burn. Resistors in electronic circuits are typically rated 1/8W, 1/4W, and

    1/2W.When powering a light emitting diode, a comparatively large current flows through

    the resistor, so you need to consider the power rating of the resistor you choose.

    Fig. 3.12: Diagram of Resistor  

    3.1.10 Switch

    A wide variety of PIN diode and GaAs high-speed, high-isolation switches are availablefrom Mini-Circuits, including models with built-in TTL drivers, operating up to 5 GHz.

    Select from SPST, SPDT, and SP4T models in EMI-shielded plug-in, TO-8, surface-

    mount and connector zed packages. PIN diode units are available in SPST/SPDT

    configurations as well as SPDT/SP4T models with built-in drivers with 2μ sec switching

    speed, tough enough to pass stringent MIL-STD-202 tests. Despite their small size, the

    TO-8 models (TOSW-230 and TOSW- 425) provide isolation as high as 40 dB, only 1.1

    dB insertion loss, with a 1dB compression point of +27 dBm. Switching speed as fast as

    2 neno sec is offered with Mini-Circuits GaAs switches, available in absorptive and

    reflective models, with and without TTL built-in drivers. All models are available with

    SMA connectorized or surface-mount packages. The connectorized packages are

    miniature, easily mountable, and well suited for test set-ups. Surface-mount units are

    offered in a low-cost plastic package and hermetic ceramic cases for military

  • 8/16/2019 project report 22.pdf

    29/93

    29

    applications. These packages are rugged enough to pass MIL-STD-883 vibration,

    mechanical and thermal shock, fine and gross leak tests. These fast acting switches can

    operate from DC up to 5 GHz with 50dB isolation and only 1 dB insertion loss. The

    absorptive models exhibit a typical VSWR of 1.5 in the "OFF" state.

    Fig. 3.13: Diagram of Switch 

    3.1.11 Microcontroller

    A microcontroller is a small computer on a single integrated circuit containing a

     processor core, memory and programmable input/output peripherals. Due to simplicity in

    design and pocket friendly prices, microcontroller is widely adopted for various fields

    including automobiles, medical science, defense, domestic applications, industrial use,

    energy management and lots more domains. Microcontrollers are commonly built using

    CMOS (Complementary Metal Oxide semiconductor) technology resulting optimum

     performance with the least consumption of power. As it is designed to perform a specifictask ,latency of the task is fast and is more reliable. Microcontroller is the heart of

    system. It is used for interfacing the display, memory and peripherals with GSM modem.

    1.  The microcontroller used in this project is ATmega16.

    2.  It is a low power CMOS 8-bit microcontroller based on the AVR enhanced RISC

    (reduced instruction set computing) architecture.

    Fig. 3.14: Circuit Diagram of Microcontroller  

  • 8/16/2019 project report 22.pdf

    30/93

    30

    3.1.11.1: Pin Diagram 

    Fig.3.15: Pin Diagram of Microcontroller  

    3.1.11.2: Pin Description 

    VCC Digital supply voltage.

    GND Ground.

    Port A (PA7.PA0) Port A serves as the analog inputs to the A/D Converter.

  • 8/16/2019 project report 22.pdf

    31/93

    31

    Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used.

    Port pins can provide internal pull-up resistors (selected for each bit). The Port A output

     buffers have symmetrical drive characteristics with both high sink and source capability.

    When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source

    current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a

    reset condition becomes active, even if the clock is not running.

    Port B (PB7.PB0)

    Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each

     bit). The Port B output buffers have symmetrical drive characteristics with both high sink

    and source capability. As inputs, Port B pins that are externally pulled low will source

    current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset

    condition becomes active, even if the clock is not running. Port B also serves the

    functions of various special features of the ATmega16 as listed on page 55.

    Port C (PC7.PC0)

    Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each

     bit). The Port C output buffers have symmetrical drive characteristics with both high sink

    and source capability. As inputs, Port C pins that are externally pulled low will source

    current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset

    condition becomes active, even if the clock is not running. If the JTAG interface is

    enabled, the pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be

    activated even if a reset occurs. Port C also serves the functions of the JTAG interface

    and other special features of the ATmega16 as listed on page 58.

    Port D (PD7.PD0)

    Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each

     bit). The Port D output buffers have symmetrical drive characteristics with both high sink

    and source capability. As inputs, Port D pins that are externally pulled low will source

    current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset

    condition becomes active, even if the clock is not running.

  • 8/16/2019 project report 22.pdf

    32/93

    32

    Port D also serves the functions of various special features of the ATmega16 as listed on

     page 60.

    RESET Reset Input.

    A low level on this pin for longer than the minimum pulse length will generate a reset,

    even if the clock is not running. The minimum pulse length is given in Table 15 on page

    35. Shorter pulses are not guaranteed to generate a reset.

    XTAL1

    Input to the inverting Oscillator amplifier and input to the internal clock operating circuit. 

    XTAL2

    Output from the inverting Oscillator amplifier. 

    AVCC

    AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally

    connected to VCC, even if the ADC is not used. If the ADC is used, it should be

    connected to VCC through a low-pass filter. 

    AREF

    AREF is the analog reference pin for the A/D Converter.

    3.1.11.3: Operation 

    The AVR core combines a rich instruction set with 32 general purpose working registers.  

    All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing 

    two independent registers to be accessed in one single instruction executed in one clock  

    cycle. The resulting architecture is more code efficient while achieving throughputs up to  

    ten times faster than conventional CISC microcontrollers. 

    The ATmega16 provides the following features: 16K bytes of In-System Programmable  

    Flash Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K  

     byte SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG

    interface for Boundary-scan, On-chip Debugging support and programming, three 

  • 8/16/2019 project report 22.pdf

    33/93

    33

    flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial 

     programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit 

    ADC with optional differential input stage with programmable gain (TQFP package

    only),  a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and

    six  software selectable power saving modes.

    The ATmega16 AVR is supported with a full suite of program and system development

    tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit

    emulators, and evaluation kits.

    3.1.11.4: Features 

     

    This is High-performance, Low-power AVR® 8-bit Microcontroller.

      It is having Advanced RISC Architecture.

      131 Powerful Instructions  –  Most Single-clock Cycle Execution

      32 x 8 General Purpose Working Registers

      Fully Static Operation

      Up to 16 MIPS Throughput at 16 MHz

      On-chip 2-cycle Multiplier

       Nonvolatile Program and Data Memories

      16K Bytes of In-System Self-Programmable Flash

    Endurance: 10,000 Write/Erase Cycles

      Optional Boot Code Section with Independent Lock Bits

    In-System Programming by On-chip Boot Program

    True Read-While-Write Operation

      512 Bytes EEPROM

    1K Byte Internal SRM

    Programming Lock for Software Security

      JTAG (IEEE std. 1149.1 Compliant) Interface

      Boundary-scan Capabilities According to the JTAG Standard

      Extensive On-chip Debug Support

  • 8/16/2019 project report 22.pdf

    34/93

    34

      Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG

    Interface

      Peripheral Features

      Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes

      One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture

    Mode.

      Real Time Counter with Separate Oscillator

      Four PWM Channels

      8-channel, 10-bit ADC

    8 Single-ended Channels

    7 Differential Channels in TQFP Package Only

    2 Differential Channels with Programmable Gain at 1x, 10x, or 200x

      Byte-oriented Two-wire Serial Interface

      Programmable Serial USART

      Master/Slave SPI Serial Interface

      Programmable Watchdog Timer with Separate On-chip Oscillator

      On-chip Analog Comparator

      Special Microcontroller Features

      Power-on Reset and Programmable Brown-out Detection

      Internal Calibrated RC Oscillator

      External and Internal Interrupt Sources

      Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby

    and Extended Standby

      I/O and Packages

      32 Programmable I/O Lines

      40-pin PDIP, 44-lead TQFP, and 44-pad MLF

     

    Operating Voltages

      2.7 - 5.5V for ATmega16L

      4.5 - 5.5V for ATmega16

      Speed Grades

      0 - 8 MHz for ATmega16L

  • 8/16/2019 project report 22.pdf

    35/93

    35

      0 - 16 MHz for ATmega16

    3.1.11.5: Block Diagram of Microcontroller (ATmega16)  

    Fig.3.16:  Block Diagram of Microcontroller (ATmega16)

  • 8/16/2019 project report 22.pdf

    36/93

    36

    Chapter-4 

    SOFTWARE DESCRIPTION

    4.1 Concept of Embedded C 

    4.1.1 Introduction

    An embedded system is some combination of computer hardware and software, either

    fixed in capability or programmable, that is specifically designed for a particular

    function. Industrial machines, automobiles, medical equipment, cameras, household

    appliances, airplanes, vending machines and toys (as well as the more obvious cellular

     phone and PDA) are among the myriad possible hosts of an embedded system. Embedded

    systems that are programmable are provided with programming interfaces, and embedded

    systems programming is a specialized occupation.

    Most C programmers are spoiled because they program in environments where not only

    is there a standard library implementation, but there are frequently a number of other

    libraries available for use. The cold fact is, that in embedded systems, there rarely are

    many of the libraries that programmers have grown used to, but occasionally an

    embedded system might not have a complete standard library, if there is a standard

    library at all. Few embedded systems have capability for dynamic linking, so if standard

    library functions are to be available at all, they often need to be directly linked into the

    executable. C remains a very popular language for microcontroller developers due to the

    code efficiency and reduced overhead and development time. C offers low level control

    and is considered more readable than assembly. Many free C compilers are available for

    a wide variety of development platforms. The compilers are part of an IDEs with ICD

    support, breakpoints, single-stepping and an assembly window. The performance of C

    compilers has improved considerably in recent years, and they are claimed to be more or

    less as good as assembly, depending on who you ask. Most tools now offer options for

    customizing the compiler optimization. Additionally, using C increases portability, since

    C code can be compiled for different types of processors.

  • 8/16/2019 project report 22.pdf

    37/93

    37

    4.1.2: Difference between C and Embedded C

    Though C and embedded C appear different and are used in different contexts, they have

    more similarities than the differences. Most of the constructs are same; the difference lies

    in their applications.

      C is used for desktop computers, while embedded C is for microcontroller based

    applications.

      C takes more resources of a desktop PC like memory, OS, etc. while

     programming on desktop systems what embedded C cannot. Embedded C has to

    use the limited resources (RAM, ROM, I/Os) on an embedded processor. Thus,

     program code must fit into the available program memory. If code exceeds the

    limit, the system is likely to crash.

      Compilers for C (ANSI C) typically generate OS dependent executable files.

    Embedded C requires compilers to create files to be downloaded to the Microcontrollers

    /microprocessors where it needs to run. Embedded compilers give access to all resources

    which is not provided in compilers for desktop computer applications. Embedded systems

    often have the real-time constraints, which is usually not there with desktop computer

    applications.

      Embedded systems often do not have a console, which is available in case of

    desktop applications. The C programming language is perhaps the most popular

     programming language for programming embedded systems. C continues to be a very

     popular language for micro-controller developers/programmers due to the code efficiency

    and reduced overhead and development time. C offers low-level control and is considered

    more readable than assembly language which is a little difficult to understand. Assembly

    language requires more code writing, whereas C is easy to understand and requires less

    coding. Plus, using C increases portability, since C code can be compiled for different

    types of processors. We can program microcontrollers using 8051, PIC. We can develop

    our programs as per our electronic hardware using 8051 microcontroller. For example we

    can blink led, increment decrement counters, token displays etc.

  • 8/16/2019 project report 22.pdf

    38/93

    38

    C remains a very popular language for micro-controller developers due to the code

    efficiency and reduced overhead and development time. C offers low-level control and is

    considered more readable than assembly. Many free C compilers are available for a wide

    variety of development platforms. The compilers are part of an IDEs with ICD support,

     breakpoints, single-stepping and an assembly window. The performance of C compilers

    has improved considerably in recent years, and they are claimed to be more or less as

    good as assembly, depending on who you ask. Most tools now offer options for

    customizing the compiler optimization. Additionally, using C increases portability, since

    C code can be compiled for different types of processors.  

    4.1.3: Concept of Embedded Systems in ‘C’ 

    An embedded system is a system that connects preprogrammed software on a controller

    embedded in the computer hardware. The software is installed on the controller, the

     brains of the electronic device. Each embedded system is used for one specific function.

    A complex device like a PDA or smart phone may have embedded devices that can

    control several functions. However, embedded systems are not as complex or

     programmable as a personal computer. C is one of the most commonly used

     programming languages in embedded devices. Embedded systems are used to control

    electronic devices such as DVD players, cell phones, watches and medical devices. Video

    cards and network switches are embedded systems used in computer peripherals. The

    cruise control and anti-lock brakes in a car are also embedded systems. Embedded

    systems are cheaper than complex processors due to their simplicity and frequent mass

     production. Software written in a language like C is used to control the mechanical

    devices within the embedded system. 

    4.1.3.1: Reasons C is Common in Embedded Systems 

    C is one of the most commonly used software languages used on embedded device

    controllers. One reason is because it is one of the few software languages that operates on

     both 8 bit controllers and 64 bit PCs, meaning that many computer programmers can

  • 8/16/2019 project report 22.pdf

    39/93

    39

    write C software for both personal computers and embedded devices. The C language can

    also use very simple commands to control the device, freeing up the limited memory of

    the device to hold many commands or parameters. C can be written for both

    microcontrollers and digital signal processors.

    4.1.3.2: C Languages Used in Embedded Systems 

    C and C!! are used frequently in creation of embedded systems. Embedded systems are

    rarely programmed using the C++ because embedded systems rarely have the memory

    space for the complex programming used in C++. C# is occasionally used on embedded

    Linux systems.

    4.1.3.3: How C Programs Are Created and Installed on Embedded

    Systems

    Code is written in C on a programmer's PC. Code is run through a compiler on the

     programmer's PC to create a software program. The embedded system software may be

    run through a simulator on the programmer's computer. The software program is copied

    onto the controller using a "programmer." The controller is then tested on a "test bed" to

    ensure that it works properly.

    4.1.3.4: Common Embedded Systems that Use C 

    Bluetooth devices are programmed in C. PIC microcontrollers such as those used in web

    cameras are frequently programmed in C. PIC microcontrollers programmed in C have

    also been used in LED (light emitting diodes) devices and LCD (liquid crystal display)

    monitors. USB devices are embedded devices frequently coded in C.

    4.1.3.5: Standards for Embedded System Programming in C

    The American National Standards Institute (ANSI) has written standards for the C

     programming language. The International Standards Organization wrote standard

    ISO/IEC 9899 for the C programming language. The Motor Industry Software Reliability

  • 8/16/2019 project report 22.pdf

    40/93

    40

    Association has created a proprietary set of standards for programming in C for

    embedded devices in automobiles.

    4.1.4: How ‘C’ is used Differently for Embedded Programming

    If you are new to embedded C programming, you will notice that there are only subtle

    differences between a regular C program and an embedded C program. The following is a

    list of the most important differences between C programming for embedded systems and

    C programming for PCs.

    4.1.5: Keil Software

    Keil development tools for the 8051 Microcontroller Architecture support every level ofsoftware developer from the professional applications engineer to the student just

    learning about embedded software development. The Keil 8051 Development Tools are

    designed to solve the complex problems facing  embedded software developers.

      When starting a new project, simply select the microcontroller you use from the

    Device Database and the μVision IDE sets all compiler, assembler, linker, and memory 

    options for you.

       Numerous example programs are included to help you get started with the most

     popular embedded 8051 devices.

  • 8/16/2019 project report 22.pdf

    41/93

    41

    Chapter 5

    SYSTEM DESIGN

    5.1: Functional Decomposition

    Fig 5.1: functional decomposition diagram 

    The constituent parts involved in the process are

     

    Mobile phone

     

    GSM (global system for mobile)

      Microcontroller

      LCD display

    First block portrays to be GSM which receives, verifies and forwards the message to the

    Microcontroller. Micro is the second block. Micro processes the message and sends to the

  • 8/16/2019 project report 22.pdf

    42/93

    42

    LCD. LCD behaving as the third constituent part displays the message until it is invoked

     by micro to display a new message.

    5.2: State Transition Diagram 

    Fig 5.2: state transition diagram 

    The state transition refers to all the finite states the system enters during the process,

     pointing out the behavior of the system when the message is received from the end user.

    Just as soon as the message is received from the user the message is validated by

    comparing with the password characters. The message is stored and sent to display. In the

    other scenario the invalid user message is discarded by the microcontroller and later

    keeps checking for any new recent messages.

  • 8/16/2019 project report 22.pdf

    43/93

    43

    FUTURE SCOPE

    Temperature display during periods wherein no message buffers are empty is one

    such theoretical improvement that is well possible. Another very interesting and

    significant improvement would be to accommodate multiple receiver MODEMS at

    different positions in the geographical area carrying duplicate SIM cards. Multilingual

    display can be another added variation in the project.

    Alphanumeric LCDs have a limitation on size as well as no. of characters. These can be

    replaced with large LED display boards. Robots can be controlled in a similar fashion by

    sending the commands to the robots.

    This technology could be further modified and more upgraded as per individual need and

    interest. We have discussed some basic ideas of this technology. And depending on

    innovative applications user can upgrade as per requirement.

  • 8/16/2019 project report 22.pdf

    44/93

    44

    CONCLUSION

    The prototype of the GSM based display toolkit was efficiently designed. This prototype

    has facilities to be integrated with a display board thus making it truly mobile. The toolkit

    accepts the SMS, stores it, validates it and then displays it in the LCD module. The SMS

    is deleted from the SIM each time it is read, thus making room for the next SMS. The

    major constraints incorporated are the use of ‘*’ as the termination character of the SMS

    and the display of one SMS as a time. These limitations can be removed by the use of

    higher end microcontrollers and extended RAM. The prototype can be implemented

    using commercial display boards. In this case, it can solve the problem of instantinformation transfer in the campus.

  • 8/16/2019 project report 22.pdf

    45/93

    45

    References

      http://www.daimlerchrysler.com/dccomDatasheet of NE555

      http://www.gm.com/company/careers/career_paths/rnd/nws_071800.html 

      http://www.ehow.com/about_6677935_description-visual-basic.html 

  • 8/16/2019 project report 22.pdf

    46/93

    46

    Appendix

    Appendix-A Programming

    // File Name : 'lcd_lib.c’ 

    // Title : 8 and 4 bit LCd interface

    // Author : Scienceprog.com - Copyright (C) 2007

    // Created : 2007-03-29

    // Revised : 2007-08-08

    // Version : 1.0

    // Target MCU : Atmel AVR series

    // This code is distributed under the GNU Public License

    // which can be found at http://www.gnu.org/licenses/gpl.txt

    /#include "lcd_lib.h"

    #include

    #include

    #include

    #include

    const uint8_t LcdCustomChar[] PROGMEM=//define 8 custom LCD chars

    {

    0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // 0. 0/5 full progress block

    0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, // 1. 1/5 full progress block

    0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, // 2. 2/5 full progress block

    0x00, 0x1F, 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00, // 3. 3/5 full progress block

  • 8/16/2019 project report 22.pdf

    47/93

    47

    0x00, 0x1F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x00, // 4. 4/5 full progress block

    0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, // 5. 5/5 full progress block

    0x03, 0x07, 0x0F, 0x1F, 0x0F, 0x07, 0x03, 0x00, // 6. rewind arrow

    0x18, 0x1C, 0x1E, 0x1F, 0x1E, 0x1C, 0x18, 0x00, // 7. fast forward arrow

    };

    Void LCD send Char(uint8_t ch ) //Sends Char to LCD{

    LDP= (ch&0b11110000);LCP|=1

  • 8/16/2019 project report 22.pdf

    48/93

    48

     _delay_ms(1);

    LCP&=~(1

  • 8/16/2019 project report 22.pdf

    49/93

    49

    LCP|=1

  • 8/16/2019 project report 22.pdf

    50/93

    50

    {register uint8_t i;

    if (!data) return;

    // print data

    for(i=0; i

  • 8/16/2019 project report 22.pdf

    51/93

    51

    {uint8_t i;

    LCDGotoXY(x,y);

    for(i=0;(uint8_t)pgm_read_byte(&FlashLoc[i]);i++)

    { LCDsendChar((uint8_t)pgm_read_byte(&FlashLoc[i]));

    }

    }

    //defines char symbol in CGRAM

    /*

    const uint8_t backslash[] PROGMEM=

    {

    0b00000000,//back slash

    0b00010000,

    0b00001000,

    0b00000100,

    0b00000010,

    0b00000001,

    0b00000000,

    0b00000000

    };

    LCDdefinechar(backslash,0);

    */

    void LCDdefinechar(const uint8_t *pc,uint8_t char_code){

    uint8_t a, pcc;

    uint16_t i;

    a=(char_code

  • 8/16/2019 project report 22.pdf

    52/93

    52

    for (i=0; i

  • 8/16/2019 project report 22.pdf

    53/93

    53

    {LCDsendCommand(0x0C);

    }

    void LCDblank(void) //blanks LCD

    { LCDsendCommand(0x08);

    }

    void LCDvisible(void) //Shows LCD

    { LCDsendCommand(0x0C);

    }

    void LCDcursorLeft(uint8_t n) //Moves cursor by n poisitions left

    {int i;

    for ( i=0;i

  • 8/16/2019 project report 22.pdf

    54/93

    54

    // draw a progress bar displaying (progress / maxprogress)

    // starting from the current cursor position

    // with a total length of "length" characters

    // ***note, LCD chars 0-5 must be programmed as the bar characters

    // char 0 = empty ... char 5 = full

    // total pixel length of bargraph equals length*PROGRESSPIXELS_PER_CHAR;

    // pixel length of bar itself is

     pixelprogress =

    ((progress*(length*PROGRESSPIXELS_PER_CHAR))/maxprogress);

    // print exactly "length" characters

    for(i=0; i pixelprogress )

    { // this is a partial or empty block

    if( ((i*(uint16_t)PROGRESSPIXELS_PER_CHAR)) >

     pixelprogress )

    { // this is an empty block

    // use space character?

    c = 0;

    }

    else

    { // this is a partial block

    c = pixelprogress % PROGRESSPIXELS_PER_CHAR;

    }

  • 8/16/2019 project report 22.pdf

    55/93

    55

    }

    else

    { // this is a full block

    c = 5;

    }// write character to display

    LCDsendChar(c);

    }

    }

    void LCDdisplay(char arr[])

    { LCDstring(arr,strlen(arr));

    }

    // File Name : 'lcd_lib.h'

    // Title : 8 and 4 bit LCd interface

    // Author : Scienceprog.com - Copyright (C) 2007

    // Created : 2007-03-29

    // Revised : 2007-08-08

    // Version : 1.0

    // Target MCU : Atmel AVR series

    //

    // This code is distributed under the GNU Public License

    // which can be found at http://www.gnu.org/licenses/gpl.txt

    #ifndef LCD_LIB

    #define LCD_LIB

    #include

  • 8/16/2019 project report 22.pdf

    56/93

    56

    #define LCD_RS 0 //define MCU pin connected to LCD RS

    #define LCD_RW 1 //define MCU pin connected to LCD R/W

    #define LCD_E 2 //define MCU pin connected to LCD E

    #define LCD_D4 4 //define MCU pin connected to LCD D3

    #define LCD_D5 5 //define MCU pin connected to LCD D4

    #define LCD_D6 6 //define MCU pin connected to LCD D5

    #define LCD_D7 7 //define MCU pin connected to LCD D6

    #define LDP PORTC //define MCU port connected to LCD data pins

    #define LCP PORTC //define MCU port connected to LCD control pins

    #define LDDR DDRC //define MCU direction register for port connected to LCD data

     pins

    #define LCDR DDRC //define MCU direction register for port connected to LCD control

     pins

    #define LCD_CLR 0 //DB0: clear display

    #define LCD_HOME 1 //DB1: return to home position

    #define LCD_ENTRY_MODE 2 //DB2: set entry mode

    #define LCD_ENTRY_INC 1 //DB1: increment

    #define LCD_ENTRY_SHIFT 0 //DB2: shift

    #define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on

    #define LCD_ON_DISPLAY 2 //DB2: turn display on

    #define LCD_ON_CURSOR 1 //DB1: turn cursor on

    #define LCD_ON_BLINK 0 //DB0: blinking cursor

    #define LCD_MOVE 4 //DB4: move cursor/display

    #define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)

  • 8/16/2019 project report 22.pdf

    57/93

    57

    #define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)

    #define LCD_FUNCTION 5 //DB5: function set

    #define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)

    #define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)

    #define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)

    #define LCD_CGRAM 6 //DB6: set CG RAM address

    #define LCD_DDRAM 7 //DB7: set DD RAM address

    // reading:

    #define LCD_BUSY 7 //DB7: LCD is busy

    #define LCD_LINES 2 //visible lines

    #define LCD_LINE_LENGTH 16 //line length (in characters)

    // cursor position to DDRAM mapping

    #define LCD_LINE0_DDRAMADDR 0x00

    #define LCD_LINE1_DDRAMADDR 0x40

    #define LCD_LINE2_DDRAMADDR 0x14

    #define LCD_LINE3_DDRAMADDR 0x54

    // progress bar defines

    #define PROGRESSPIXELS_PER_CHAR 6

    Void LCD send Char (uint8_t); //forms data ready to send to 74HC164

    Void LCD send Command (uint8_t); //forms data ready to send to 74HC164

    Void LCD int (void); //Initializes LCD

    Void LCD clr (void); //Clears LCD

    Void LCD home (void); //LCD cursor home

    Void LCD string (uint8_t*, uint8_t); //Outputs string to LCD

    void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position

  • 8/16/2019 project report 22.pdf

    58/93

    58

    void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD atx,y

    void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM

    void LCDshiftRight(uint8_t); //shift by n characters Right

    Void LCD shift Left (uint8_t) ; //shift by n characters Left

    Void LCD cursor on (void); //Underline cursor ON

    Void LCD cursor On Blink (void); //Underline blinking cursor ON

    Void LCD cursor OFF (void); //Cursor OFF

    Void LCD blank (void); //LCD blank but not cleared

    Void LCD visible (void); //LCD visible

    Void LCD cursor Left (uint8_t); //Shift cursor left by n

    Void LCD cursor Right (uint8_t); //shift cursor right by n

    // displays a horizontal progress bar at the current cursor location

    // is the value the bar graph should indicate

    // is the value at the end of the bar graph

    // is the number of LCD characters that the bar graph should cover

    //adapted from AVRLIB - displays progress only for 8 bit variables

    Void LCD progress Bar (uint8_t progress, uint8_t max progress, uint8_t length);

    Void LCD display (char []);

    #endif

    #define F_CPU 12000000UL

    #include

    #include

    #include "lcd_lib.h"

    #include "sim300.h"

    char A[20]= " ";

  • 8/16/2019 project report 22.pdf

    59/93

    59

    void Halt();

    int main(void)

    { //Initialize LCD Module

    LCDinit();

    LCDclr();

    //Intro Message

    LCDGotoXY(0,0);

    LCDdisplay("GSM MSG BOARD");

     _delay_ms(1000);

    LCDclr();

    //Initialize SIM300 module

    LCDdisplay("Initializing........");

    int8_t r= SIM300Init();

     _delay_ms(1000);

     _delay_ms(1000);

    //Check the status of initialization

    switch(r)

    { case SIM300_OK:

    LCDGotoXY(0,1);

    LCDdisplay("OK");

     break;

    case SIM300_TIMEOUT:

    LCDGotoXY(0,1);

    LCDdisplay("NO Response");

    Halt();

  • 8/16/2019 project report 22.pdf

    60/93

    60

    case SIM300_INVALID_RESPONSE:

    LCDGotoXY(0,1);

    LCDdisplay("INVALID RESPONSE");

    Halt();

    case SIM300_FAIL:

    LCDGotoXY(0,1);

    LCDdisplay("FAIL");

    Halt();

    default:

    LCDGotoXY(0,1);

    LCDdisplay("UNKNOWN ERROR");

    Halt();

    }

     _delay_ms(1000);

    //IMEI No display

    LCDclr();

    char imei[16];

    r=SIM300GetIMEI(imei);

    if(r==SIM300_TIMEOUT)

    { LCDdisplay("COMM ERROR !");

    Halt();

    }

    sprintf(A, "IMEI:%d", imei);

    LCDGotoXY(0,0);

    LCDstring(A,14);

  • 8/16/2019 project report 22.pdf

    61/93

    61

     _delay_ms(1000);

    //Manufacturer ID

    LCDclr();

    char man_id[48];

    r=SIM300GetManufacturer(man_id)

    if(r==SIM300_TIMEOUT)

    { LCDdisplay(“CommError !”); 

    Halt();

    }

    LCDdisplay("Manufacturer:");

    sprintf(A, "%d", man_id);

    LCDGotoXY(0,1);

    LCDstring(A,14);

     _delay_ms(1000);

    //Manufacturer ID

    LCDclr();

    char model[48];

    r=SIM300GetModel(model);

    if(r==SIM300_TIMEOUT)

    { LCDdisplay("Comm Error !");

    Halt();

    }

    LCDdisplay("Model:");

    sprintf(A, "%d", model);

    LCDGotoXY(0,1);

    LCDstring(A,14);

  • 8/16/2019 project report 22.pdf

    62/93

    62

     _delay_ms(1000);

    //Check Sim Card Presence

    LCDclr();

    LCDdisplay("Checking SIMCard");

     _delay_ms(1000);

    r=SIM300IsSIMInserted();

    if (r==SIM300_SIM_NOT_PRESENT)

    { //Sim card is NOT present

    LCDGotoXY(0,1);

    LCDdisplay("No SIM Card !");

    Halt();

    }

    else if(r==SIM300_TIMEOUT)

    { //Communication Error

    LCDGotoXY(0,1);

    LCDdisplay("Comm Error !");

    Halt();

    }

    else if(r==SIM300_SIM_PRESENT)

    { //Sim card present

    LCDGotoXY(0,1);

    LCDdisplay("SIM Card Present");

     _delay_ms(1000);

    }

    //Network search

  • 8/16/2019 project report 22.pdf

    63/93

    63

    LCDclr();

    LCDdisplay("SearchingNetwork");

    uint8_t nw_found=0;

    uint16_t tries=0;

    uint8_t x=0;

    while(!nw_found)

    {r=SIM300GetNetStat();

    if(r==SIM300_NW_SEARCHING)

    { LCDGotoXY(0,1);

    LCD display("%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");

    LCD Goto XY(x,1);

    LCD display("%1");

    LCD Goto XY(17,1);

    x++;

    if(x==16) x=0;

     _delay_m(50);

    tries++;

    if(tries==600)

     break;}

    else

     break;

    }

    LCDclr();

    if(r==SIM300_NW_REGISTERED_HOME)

    { LCDdisplay("Network Found");

  • 8/16/2019 project report 22.pdf

    64/93

    64

    }

    else

    { LCDdisplay("Cant Connt to NW!");

    Halt();

    }

     _delay_ms(1000);

    LCDclr();

    //Show Provider Name

    char pname[32];

    r=SIM300GetProviderName(pname);

    if(r==0)

    {

    LCDdisplay("Comm Error !");

    Halt();

    }

    LCDdisplay(pname);

     _delay_ms(1000);

    /* //Send MSG

    LCDclr();

    LCDdisplay("Sending Msg");

    uint8_t ref;

    r=SIM300SendMsg("+919939XXXXXX","Test",&ref);//Change phone number to some

    valid value!

    if(r==SIM300_OK)

    {LCDdisplayXY(0,1,"Success");

  • 8/16/2019 project report 22.pdf

    65/93

    65

    LCDWriteIntXY(9,1,ref,3);

    }

    else if(r==SIM300_TIMEOUT)

    { LCDdisplayXY(0,1,"Time out !");

    }

    else

    { LCDdisplayXY(0,1,"Fail !");

    }

     _delay_ms(2000);

    //Wait for MSG

    uint8_t id = 0;

    int x = 0;

    UFlushBuffer();

    while(1)

    {LCDclr();

    LCDdisplay("Waiting for msg");

    x=0;

    int8_t vx=1;

    while(SIM300WaitForMsg(&id)!=SIM300_OK)

    {

    LCDGotoXY(0,1);

    LCDdisplay("%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");

    LCDGotoXY(x,1);

    LCDdisplay("%1");

    LCDGotoXY(17,1);

  • 8/16/2019 project report 22.pdf

    66/93

    66

    x+=vx;

    if(x==15 || x==0) vx=vx*-1;

    }

    LCDGotoXY(0,1);

    LCDdisplay("MSG Received ");

     _delay_ms(1000);

    //Now read and display msg

    LCDclr();

    char msg[300];

    r=SIM300ReadMsg(id,msg)

    if(r==SIM300_OK)

    {LCDdisplay(msg);

     _delay_ms(3000);

    }else

    { LCDdisplay("Err Reading Msg !");

     _delay_ms(3000);

    }

    //Finally delete the msg

    if (SIM300DeleteMsg(id)!=SIM300_OK)

    {LCDdisplay("Err Deleting Msg !");

     _delay_ms(3000);

    }

    }

    Halt();}

    void Halt()

  • 8/16/2019 project report 22.pdf

    67/93

    67

    {while(1);

    }

    #ifndef MYUTILS_H

    #define MYUTILS_H

    #define _CONCAT(a,b) a##b

    #define PORT(x) _CONCAT(PORT,x)

    #define PIN(x) _CONCAT(PIN,x)

    #define DDR(x) _CONCAT(DDR,x)

    #endif

    #include

    #include

    #include

    #include "usart.h"

    #include "lcd_lib.h"

    #include "sim300.h"

    //A common buffer used to read response from SIM300

    char sim300_buffer[128];

    int8_t SIM300Init()

    {

    //Init USART lib

    set_uartbaud(9600);

    //Check communication line

    SIM300Cmd("AT"); //Test command

    //Now wait for response

    uint16_t i=0;

  • 8/16/2019 project report 22.pdf

    68/93

    68

    //correct response is 6 byte long

    //So wait until we have got 6 bytes

    //in buffer.

    while(i

  • 8/16/2019 project report 22.pdf

    69/93

    69

    while(i

  • 8/16/2019 project report 22.pdf

    70/93

    70

    for(i=2;i

  • 8/16/2019 project report 22.pdf

    71/93

    71

    SIM300Cmd("AT+CREG?");

    //Now wait for response

    uint16_t i=0;

    //correct response is 20 byte long

    //So wait until we have got 20 bytes

    //in buffer.

    while(i

  • 8/16/2019 project report 22.pdf

    72/93

    72

    //We waited so long but got no response

    //So tell caller that we timed out

    return SIM300_TIMEOUT;

    }

    int8_t SIM300IsSIMInserted()

    { UFlushBuffer();

    //Send Command

    SIM300Cmd("AT+CSMINS?");

    //Now wait for response

    uint16_t i=0;

    //correct response is 22 byte long

    //So wait until we have got 22 bytes

    //in buffer.

    while(i

  • 8/16/2019 project report 22.pdf

    73/93

    73

    else

    return SIM300_SIM_NOT_PRESENT;

    }

    }

    //We waited so long but got no response

    //So tell caller that we timed out

    return SIM300_TIMEOUT;

    }

    uint8_t SIM300GetProviderName(char *name)

    { UFlushBuffer();

    //Send Command

    SIM300Cmd("AT+CSPN?");

    uint8_t len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

    char *start,*end;

    start=strchr(sim300_buffer,'"');

    start++;

    end=strchr(start,'"');

    *end='\0';

    strcpy(name,start);

    return strlen(name);

    }

    int8_t SIM300GetIMEI(char *emei)

    { UFlushBuffer();

  • 8/16/2019 project report 22.pdf

    74/93

    74

    //Send Command

    SIM300Cmd("AT+GSN");

    uint8_t len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    strcpy(emei,sim300_buffer+2);

    return SIM300_OK;

    }

    int8_t SIM300GetManufacturer(char *man_id)

    { UFlushBuffer();

    //Send Command

    SIM300Cmd("AT+GMI");

    uint8_t len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    strcpy(man_id,sim300_buffer+2);//+2 for removing leading CR LF

    return SIM300_OK;

    }

    int8_t SIM300GetModel(char *model)

    { UFlushBuffer();

    //Send Command

    SIM300Cmd("AT+GMM");

    uint8_t len=SIM300WaitForResponse(1000);

  • 8/16/2019 project report 22.pdf

    75/93

    75

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    strcpy(model,sim300_buffer+2);//+2 for removing leading CR LF

    return SIM300_OK;

    }

    int8_t SIM300DeleteMsg(uint8_t i)

    { UFlushBuffer();

    //String for storing the command to be sent

    char cmd[16];

    //Build command string

    sprintf(cmd,"AT+CMGD=%d",i);

    //Send Command

    SIM300Cmd(cmd);

    uint8_t len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    //Check if the response is OK

    if(strcasecmp(sim300_buffer+2,"OK")==0)

    return SIM300_OK;

    else

    return SIM300_FAIL;

    }

  • 8/16/2019 project report 22.pdf

    76/93

    76

    int8_t SIM300WaitForMsg(uint8_t *id)

    { uint8_t len=SIM300WaitForResponse(250);

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    if(strncasecmp(sim300_buffer+2,"+CMTI:",6)==0)

    { char str_id[4];

    char *start;

    start=strchr(sim300_buffer,',');

    start++;

    strcpy(str_id,start);

    *id=atoi(str_id);

    return SIM300_OK;

    } else

    return SIM300_FAIL;

    }

    int8_t SIM300ReadMsg(uint8_t i, char *msg)

    {

    //Clear pending data in queue

    UFlushBuffer();

    //String for storing the command to be sent

    char cmd[16];

    //Build command string

  • 8/16/2019 project report 22.pdf

    77/93

    77

    sprintf(cmd,"AT+CMGR=%d",i);

    //Send Command

    SIM300Cmd(cmd);

    uint8_t len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

    sim300_buffer[len-1]='\0';

    //Check of SIM NOT Ready error

    if(strcasecmp(sim300_buffer+2,"+CMS ERROR: 517")==0)

    { //SIM NOT Ready

    return SIM300_SIM_NOT_READY;

    }

    //MSG Slot Empty

    if(strcasecmp(sim300_buffer+2,"OK")==0)

    { return SIM300_MSG_EMPTY;

    }

    //Now read the actual msg text

    len=SIM300WaitForResponse(1000);

    if(len==0)

    return SIM300_TIMEOUT;

  • 8/16/2019 project report 22.pdf

    78/93

    78

    sim300_buffer[len-1]='\0';

    strcpy(msg,sim300_buffer+1);//+1 for removing trailing LF of prev line

    return SIM300_OK;

    }

    int8_t SIM300SendMsg(const char *num, const char *msg,uint8_t *msg_ref)

    { UFlushBuffer();

    char cmd[25];

    sprintf(cmd,"AT+CMGS= %s",num);