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.

Sendin SMS problem in SIM908 GPS positioning

Status
Not open for further replies.

Mithun_K_Das

Advanced Member level 3
Advanced Member level 3
Joined
Apr 24, 2010
Messages
899
Helped
24
Reputation
48
Reaction score
26
Trophy points
1,318
Location
Dhaka, Bangladesh, Bangladesh
Visit site
Activity points
8,254
I was working with SIM908 few months ago. Last time when I used, it was ok. Recently I made some modification to the code. Here is the code,

Code:
/*******************************************************************************
*                   Program for 'GPS Position Tracker for Car accident'        *
*                          Compiler: MicroC Pro for PIC v.5.6.1                *
*                         Program Written by Engr. Mithun K. Das               *
*                        e-mail: mithun060@gmail.com; 01722448270              *
*                          MCU: PIC16F690; X-Tal:8MHz(internal)                *
*                                     16-Dec,2014                              *
*******************************************************************************/

/*

$GPGGA,025526.000,0653.409140,N,07954.150015,E,1,7 ,1.08,22.013,M,-96.608,M,,*4D
$GPGLL,0653.409140,N,07954.150015,E,025526.000,A,A *58
$GPGSA,A,3,21,29,18,24,22,25,15,,,,,,1.98,1.08,1.6 7*0F
$GPGSV,4,1,14,21,58,020,36,14,56,246,25,29,38,173, 36,18,32,354,36*7E
$GPGSV,4,2,14,24,30,071,49,22,25,317,34,06,19,304, 20,25,11,157,33*7E
$GPGSV,4,3,14,15,06,035,32,03,04,310,,31,03,205,,3 0,00,240,*78
$GPGSV,4,4,14,42,,,39,50,,,39*7F
$GPRMC,025526.000,A,0653.409140,N,07954.150015,E,0 .000,115.0,260313,,,A*6F
$GPVTG,115.0,T,,M,0.000,N,0.000,K,A*08
$GPZDA,025526.000,26,03,2013,,*57

*/

unsigned char text[64] = "32,000219.001,V,0.000000,N,0.000000,E,0.00,0.00,101010,,E,A";
char *string;
int i = 0, latitude, longitude,kk=0;
unsigned short ready;
short checkGPS=0;
short ACC_Conformation=0;
int Acc_Count=0;
short OK_Button=0;



void UART_Write_CText(const char *cptr)
{
    char chr;
    for ( ; chr = *cptr ; ++cptr ) UART1_Write(chr);
}

void GPS_Int(void);
void SMS_Int(void);

void interrupt() 
{
    if (RCIF_bit == 1)
    {       // If interrupt is generated by RCIF
            text[i] = UART1_Read(); // Read data and store it to txrt string
            i++;             // Increment string index
            if (i >= 25)
            {                 // If index = 768,
                 i = 0;        //   set it to zero
                 ready = 1;    // Ready for parsing GPS data
            }
            RCIF_bit = 0;    // Set RCIF to 0
            INTF_bit = 0;//clear flag
    }
    
    if(INTF_bit==1)
    {
       checkGPS = 1;
       INTF_bit = 0;//clear flag
    }
}

void main() 
{
  TRISA2_bit = 1;//set as input
  TRISC0_bit = 0;//set as output
  TRISC1_bit = 0;//set as output
  TRISC3_bit = 1;//set as output
  ANSEL = 0x00;
  ANSELH = 0x00;//all digital
  ADCON0 = 0x00;
  ADCON1 = 0x07;//all digital
  C1ON_bit = 0; // Disable comparators
  C2ON_bit = 0;

  RC1_bit = 1;
  RC0_bit = 1;//LEDs on
  
  UART1_Init(9600);//initialize UART at br 9600 bps
  Delay_ms(15000);// leave some time for UART
  
  RCIE_bit = 1; // Enable USART Receiver interrupt
  GIE_bit = 1; // Enable Global interrupt
  PEIE_bit = 1; // Enable Peripheral interrupt
  RCIF_bit = 0;//clear flag
  
  INTE_bit = 1;//ebalbe INT
  INTEDG_bit = 0;//rising edge
  INTF_bit = 0;// clear flag
  
  
  //UART_Write_CText("ATE0\r");//Eco OFF
  UART1_Write((char)13);
  UART1_Write((char)10);

  SMS_Int(void);
  UART_Write_CText("GPS is ready to get data. It may take few moments.");// ask for GPS
  Delay_ms(1000);
  UART1_Write((char)26);//send Ctrl+Z
  ready = 0;
  checkGPS = 0;
  RC1_bit = 0;
  RC0_bit = 0;//LEDs on
  
  
 while(1)
 {
     OERR_bit = 0;// clear Overrun Error bit
     FERR_bit = 0;//clear Farming Error bit
     GPS_Int(void);

     if(checkGPS)
     {
           INTE_bit = 0;//Disable INT
           RC1_bit = 1;//LED  ON
           if(Acc_Count<5)Acc_Count++;
           if(Acc_Count>4)ACC_Conformation = 1;
           Delay_ms(10);
     }
     else
     {
          RC1_bit = 0;//LED off
          Acc_Count = 0;//clear fount
     }
     
     if(RC3_bit==0)//OK_Button Pressed
     {
          checkGPS = 0;
          Delay_ms(100);
     }
     
     
     
     if(ACC_Conformation == 1)
     {
          GPS_Int(void);
          Delay_ms(1000);
          GIE_bit = 1;
          PEIE_bit = 1;
          RCIE_bit = 1; // Enable USART Receiver interrupt
          RCIF_bit = 0; // Set RCIF to 0
          i = 0;
          Delay_ms(100);
          UART_Write_CText("AT+CGPSINF=32\r");// ask for GPS
          Delay_ms(5000);


          if(ready == 1)
          {               // If the data in txt array is ready do:
              GIE_bit = 0;//disable all interrupt
                for(kk=0;kk<50;kk++)
                {
                   RC1_bit = ~RC1_bit;
                   Delay_ms(100);
                }
              RC1_bit = 0;//LED off
              RCIE_bit = 0; // Disable USART Receiver interrupt
              SMS_Int(void);
              UART1_Write_Text("GPS response:");// ask for GPS
              for(i=0;i<64;i++)
              {
                  UART1_Write(text[i]);//send gps data
                  Delay_ms(10);
              }

              UART1_Write_Text("\r");// ask for GPS
              Delay_ms(1000);
              UART1_Write((char)26);//send Ctrl+Z
              checkGPS = 0;
              i =0;
              ACC_Conformation = 0;//clear ACC_Conformation
              Acc_Count = 0;//clear count
              ready = 0;
              INTE_bit = 1;//Enable INT
              GIE_bit = 1;//Enable all interrupt
          }
     }

 }//while(1)
}//void main

void GPS_Int(void)
{
      RC0_bit = 1;//LED on
      UART_Write_CText("AT+CGPSPWR=1\r");//send AT+CGPSPWR=1 and Enter
      Delay_ms(1000);
      RC0_bit = 0;//LED on
      UART_Write_CText("AT+CGPSRST=1\r");//select GPS mode, 1 = Autonomous, 0 = Cold
      Delay_ms(3000);//leave 3sec to GPS setup
}

void SMS_Int(void)
{
     RC1_bit = 1;
     UART_Write_CText("AT+cmgf=1\r");
     Delay_ms(500);
     RC1_bit = 0;
     Delay_ms(300);
     UART_Write_CText("AT+cmgs=");
     UART1_Write((char)'"');
     UART_Write_CText("01722448270");
     UART1_Write((char)'"');
     UART1_Write((char)13);
     UART1_Write((char)10);
     RC1_bit = 1;
     Delay_ms(500);
     RC1_bit = 0;
}

//end of the program

Simulation is fully ok and all functions are working well. Its taking GPS data, and sending SMS.

But in real hardware, its working a little bit different. When its sending a SMS, it sents only the part ""GPS response:"" and rest of the data (UART1_Write(text);//send gps data) is sent blank.


Its really confusing. What is the mistake here...? I checked the UART data connecting PC UART/COM with parallel with the device Tx,Rx, Its working well even that text (data) is written well to the SMS. But its only the first part in my cellphone. No GPS data. and its seems like a gap.


:(
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top