Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GPS and GSM interface with ATMEGA16

Status
Not open for further replies.

ashutosh121

Newbie level 3
Joined
Oct 18, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
can anyone plz explain the interfacing of GPS and GSM with ATMEGA16
 

ashutosh121,

try find something useful on next threads:

Interfacing of GSM modem with Atmega16

I believe you can contact some of members on forum which were in previous threads. I am sure somebody will answer you on private message.

Regard!

---------- Post added at 20:59 ---------- Previous post was at 20:51 ----------

ashutosh121,

there are pro tools (for me that are professional tools):
**broken link removed**
**broken link removed**

Maybe, you do not plan to buy some of that board, but on sites like I propose to you I found good idea how to solve some my ideas.
 
Last edited by a moderator:

plz can u explain me the code...
ashutosh121,

Ok, you do not like to looking for literature, is not a problem :) But, give me some more information what you plan to do, how you plan to interface ATmega16 and GSM (for start)? Do you have some development board or something similar? Do you have any schematics to show me, or you just have an idea for project?

---------- Post added at 22:57 ---------- Previous post was at 22:40 ----------

ashutosh121,

Try with this example to conclude something, maybe it will be useful to you. Do not forget this example is not complete project, there are not libraries for UART and for LCD. This example is for development board EasyAVR6 and you need Telit GSM board.

Code:
/*
 * Project name:
     GSM_Test
 * Copyright:
     (c) MikroElektronika, 2005-2010.
  * Revision History:
     20090617:
       - initial release;
 * Description:
     This is a simple project which demonstrates the use of SmartGM862-GPS Board.
     Upon programming the MCU, connect your SmartGM862-GPS Board to PORTC of your EasyAVR6 development board.
     The goal of this simple example is to display some basic functions of the GSM module like
     making and answering a call and hanging up. Note that you'll have to enter the number you wish
     to dial to in the atc3 constant.
 * Test configuration:
     MCU:             ATmega16
                      [url]http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf[/url]
     Dev.Board:       EasyAVR6
                      [url=http://www.mikroe.com/eng/products/view/321/easyavr6-development-system/]EasyAVR6 Development System - AVR Development Board[/url]
     Oscillator:      External, 8.0000 MHz
     Ext. Modules:    SmartGM862-GPS Board extra board
                      [url=http://www.mikroe.com/eng/products/view/469/smartgm862-gps-board/]SmartGM862-GPS Board - Telit GM862-GPS GSM/GPRS development tool - mikroElektronika[/url]
                      ac:SmartGM862-GPS       
     SW:              mikroC PRO for AVR
                      [url=http://www.mikroe.com/eng/products/view/228/mikroc-pro-for-avr/]MikroElektronika - mikroC PRO for AVR - C compiler for AVR microcontroller device development[/url]
 * NOTES:
     - Put the pull-down resistors on the PORTA
     - Pull-up resistors on the PD0(Rx) and PD1(Tx) pins, pull-down PB0(RTS)
     - In order to connect SmartGM862-GPS to EasyAVR6 dev. board you need to use SmartAdapt2 board:
       [url=http://www.mikroe.com/eng/products/view/158/smartadapt2-board/]SmartADAPT2 Board - 16-pin configuration adapter with voltage selection - mikroElektronika[/url]
     - SmartGM862-GPS extra board: SW1.3 and SW1.7 ON       
*/

// Lcd module connections
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;

sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End Lcd module connections


// set of AT commands
const char atc1[] = "ATE0";                      // disable command echo
const char atc2[] = "AT# CAP= 1";                // enables handsfree external mic/ear audio path
const char atc3[] = "ATD123456789;";             // place a call to phone number 123456789
                                                 // instead of 123456789 insert your phone number
const char atc4[] = "ATH";                       // hang up
const char atc5[] = "ATA";                       // answer a call
const char atc6[] = "AT#HFMICG=4";               // handsfree microphone gain
const char atc7[] = "AT#SHFEC=1";                // handsfree echo canceller
const char atc8[] = "AT+CLVL=12";                // loudspeaker volume level
const char atc9[] = "AT#SRS= 3,0";               // select ringer sound
const char atc10[] = "ATS0=0";                   // number of rings to auto answer (auto answer disabled)


// lcd interface messages
const LCD_MESSAGE_LENGTH = 16;
const char lcd1[] = "Initializing...";
const char lcd2[] = "Power-Up GSM!!!";
const char lcd3[] = "RA3-Continue";
const char lcd4[] = "Ready!  RA0-Dial";
const char lcd5[] = "RA1-HNG RA2-ANSW";
const char lcd6[] = "Calling...";
const char lcd7[] = "Hanging Up!";
const char lcd8[] = "Answering!";
const char lcd9[] = "RING!!!";

// responses to parse
const GSM_OK    = 0;
const GSM_RING  = 1;

char gsm_state = 0;
char response_rcvd = 0;
short responseID = -1, response = -1;
char msg[LCD_MESSAGE_LENGTH+1];

// copy const to ram string
char * CopyConst2Ram(char * dest, const char * src){
char * d ;
 d = dest;
 for(;*dest++ = *src++;)
  ;
 return d;
}

// uart rx interrupt handler
void interrupt() org IVT_ADDR_USART_RXC {
char tmp;
   tmp = UART1_Read();                           // get received byte

// process reception through state machine
// we are parsing only "OK" and "RING" responses
    switch (gsm_state) {
      case  0: {
                response = -1;                   // clear response
                if (tmp == 'O')                  // we have 'O', it could be "OK"
                  gsm_state = 1;                 // expecting 'K'
                if (tmp == 'R')                  // we have 'R', it could be "RING"
                  gsm_state = 10;                // expecting 'I'
                break;
               }
      case  1: {
                if (tmp == 'K') {                // we have 'K' ->
                  response = GSM_OK;             // we have "OK" response
                  gsm_state = 50;                // expecting CR+LF
                }
                else
                  gsm_state = 0;                 // reset state machine
                break;
               }
      case 10: {
                if (tmp == 'I')                  // we have 'I', it could be "RING"
                  gsm_state = 11;                // expecting 'N'
                else
                  gsm_state = 0;                 // reset state machine
                break;
               }
      case 11: {
                if (tmp == 'N')                  // we have 'N', it could be "RING"
                  gsm_state = 12;                // expecting 'G'
                else
                  gsm_state = 0;                 // reset state machine
                break;
               }
      case 12: {
                if (tmp == 'G') {                // we have 'G' ->
                  response = GSM_RING;           // we have "RING" response
                  gsm_state = 50;                // expecting CR+LF
                }
                else
                  gsm_state = 0;                 // reset state machine
                break;
               }
      case 50: {
                if (tmp == 13)                   // we have 13, it could be CR+LF
                  gsm_state = 51;                // expecting LF
                else
                  gsm_state = 0;                 // reset state machine
                break;
               }
      case 51: {
                if (tmp == 10) {                 // we have LF, response is complete
                  response_rcvd = 1;             // set reception flag
                  responseID = response;         // set response ID
                }
                gsm_state = 0;                   // reset state machine
                break;
               }
      default: {                                 // unwanted character
                gsm_state = 0;                   // reset state machine
                break;
               }
    }
}


// send ATC command
void send_atc(const char *s)
{
// send command string
   while(*s) {
      UART1_Write(*s++);
   }
// terminate command with CR
   UART1_Write(0x0D);
}

// get GSM response, if there is any
short get_response() {
  if (response_rcvd) {
    response_rcvd = 0;
    return responseID;
  }
  else
    return -1;
}

// wait for GSM response
void wait_response(char rspns) {
  while (get_response() != rspns)
    ;
}

// pause
void wait() {
  Delay_ms(1000);
}


void main() {

// set PORTA inputs
  DDA0_bit = 0;                                // place a call input
  DDA1_bit = 0;                                // hang up input
  DDA2_bit = 0;                                // answer a call input
  DDA3_bit = 0;                                // continue with PIC program
  DDB0_bit = 1;                                // RTS pin

  UART1_Init(9600);                             // initialize USART module
  Delay_ms(500);

  SREG_I_bit  = 1;                     // enable global interrupt
  RXCIE_bit   = 1;                     // enable interrupt on UART receive

// set RTS pin to zero, we will use only RX i TX
  PORTB0_bit = 0;  

// setup lcd module
  Lcd_Init();
  Lcd_Cmd(_LCD_CURSOR_OFF);

// LCD_Out: power-up gsm
  LCD_Out(1,1,CopyConst2Ram(msg,lcd2));
  LCD_Out(2,1,CopyConst2Ram(msg,lcd3));

// wait for start
  while(!PINA3_bit)
   ;

  Lcd_Cmd(_LCD_CLEAR);
// LCD_Out: Initializing...
  LCD_Out(1,1,CopyConst2Ram(msg,lcd1));

  Delay_ms(5000);                                // wait for the GSM module to initialize it self

// negotiate baud rate
  while(1) {
    send_atc("AT");                              // send "AT" string until gsm sets up its baud rade
    Delay_ms(100);                               // and gets it correctly
    if (get_response() == GSM_OK)                // if gsm says "OK" on our baud rate we got it
      break;
  }


// disable command echo
  send_atc(atc1);
  wait_response(GSM_OK);

// change audio path (enables handsfree external mic/ear audio path)
  send_atc(atc2);
  wait_response(GSM_OK);

// handsfree microphone gain
   send_atc(atc6);
   wait_response(GSM_OK);

// handsfree echo canceller
   send_atc(atc7);
   wait_response(GSM_OK);

// loudspeaker volume level
   send_atc(atc8);
   wait_response(GSM_OK);

// select ringer sound
   send_atc(atc9);
   wait_response(GSM_OK);

// number of rings to auto answer (auto answer disabled)
   send_atc(atc10);
   wait_response(GSM_OK);


  while(1) {
// LCD_Out: Ready! RA0-Dial
    LCD_Out(1,1,CopyConst2Ram(msg,lcd4));
// LCD_Out: RA1-HNG RA2-ASW
    LCD_Out(2,1,CopyConst2Ram(msg,lcd5));

    if(Button(&PINA, 0, 10, 1)) {
// LCD_Out: Calling...
      Lcd_Cmd(_LCD_CLEAR);
      LCD_Out(1,1,CopyConst2Ram(msg,lcd6));

// mobile originated call to specified number
      send_atc(atc3);
      wait_response(GSM_OK);
    }

    if(Button(&PINA, 1, 10, 1)) {
// disconnect existing connection
      send_atc(atc4);
      wait_response(GSM_OK);

      Lcd_Cmd(_LCD_CLEAR);
// LCD_Out: Hanging Up!
      LCD_Out(1,1,CopyConst2Ram(msg,lcd7));
      wait();
    }

    if(Button(&PINA, 2, 10, 1)) {
// answer a call
      send_atc(atc5);
      wait_response(GSM_OK);

      Lcd_Cmd(_LCD_CLEAR);
// LCD_Out: Answering!
      LCD_Out(1,1,CopyConst2Ram(msg,lcd8));
      wait();
    }

// process gsm response
    if (response_rcvd) {
      response_rcvd = 0;                         // clear response received flag
      switch (responseID) {
        case GSM_OK   : break;                   // do nothing
        case GSM_RING : {
                        // LCD_Out:RING!!!
                          LCD_Out(1,1,CopyConst2Ram(msg,lcd9));
                          wait();
                         }
        default  : {
                                                 // process illegal responses
                   }
      }
    }
  }
}
 
Last edited by a moderator:

ckt.png

This is the circuit...
The top right corner is the GSM and below that is the GPS....
Basically,this is a system made to track a vehicle.......
when the user calls on the GSM no on the kit,it should reply to the user by sending the msg containing location of the place....
so plz can u guide me.....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top