Hello!!! Everyone i am using a GPS Module to track location of my Device and also obtaining the time and date information from the GPS Module.
I sent this command to GPS Module to get this $GPRMC sentence.
$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29The checksum is calculated by using this site:-
http://www.hhhh.org/wiml/proj/nmeaxor.htmland my GPS Module is receiving Proper Commands and hence giving only this sentence as output
$GPRMC,001225,A,2832.1834,N,08101.0536,W,12,25,251 211,1.2,E,A*03
But my Problem is that i need India's time and Date not the UTC Time and Date.
For me to add 5:30 manually to the UTC time is very tough task and i am implementing that, which is going to become very long code.
I want to know, is it possible that my GPS Module will give Indian Time not UTC time, is it possible.
Please help me and if there is not any such way then please share an algorithm to easily easily add 5:30 to my time and date.
Posted on: June 13, 2013, 08:20:43 08:20 - Automerged
Previously i am using the Wrong Approach (Algorithm) for Implementing this in my Code.
Now Changed my Algorithm to Add 5:30 in my Code and is working fine.
Please Check if anyone find any bug, i am sharing my code:-
#include<p18f8722.h>
void main()
{
unsigned char Time_Data[] = "233000"; //23Hour 58Min 25 Seconds
unsigned char Date_Data[] = "280215"; //13 June 2013
unsigned char GPS_Date,GPS_Month,GPS_Year,GPS_Hour,GPS_Min,GPS_Sec;
unsigned char temp;
GPS_Date = (Date_Data[0]^0x30)*10 + (Date_Data[1]^0x30);
GPS_Month = (Date_Data[2]^0x30)*10 + (Date_Data[3]^0x30);
GPS_Year = (Date_Data[4]^0x30)*10 + (Date_Data[5]^0x30);
GPS_Hour = (Time_Data[0]^0x30)*10 + (Time_Data[1]^0x30);
GPS_Min = (Time_Data[2]^0x30)*10 + (Time_Data[3]^0x30);
GPS_Sec = (Time_Data[4]^0x30)*10 + (Time_Data[5]^0x30);
//Adding 30 Minutes
temp = GPS_Min + 30;
if(temp < 60)
{
GPS_Min = GPS_Min+30;
}
else
{
GPS_Min = temp - 60;
if(GPS_Hour < 23)
{
GPS_Hour = GPS_Hour+1;
}
else
{
GPS_Hour = 0;
switch(GPS_Month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if(GPS_Date < 31)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
break;
case 4:
case 6:
case 9:
case 11:
if(GPS_Date < 30)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
break;
case 2:
temp = GPS_Year%4;
if(temp==0)
{
if(GPS_Date < 29)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
}
else
{
if(GPS_Date < 28)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
}
break;
}
}
}
//Now Time to Add 5 Hours
temp = GPS_Hour + 5;
if(temp < 23)
{
GPS_Hour = GPS_Hour+5;
}
else
{
GPS_Hour = temp - 24;
switch(GPS_Month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if(GPS_Date < 31)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
break;
case 4:
case 6:
case 9:
case 11:
if(GPS_Date < 30)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
break;
case 2:
temp = GPS_Year%4;
if(temp==0)
{
if(GPS_Date < 29)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
}
else
{
if(GPS_Date < 28)
{
GPS_Date = GPS_Date+1;
}
else
{
GPS_Date = 1;
if(GPS_Month < 12)
GPS_Month = GPS_Month+1;
else
{
GPS_Month = 1;
GPS_Year = GPS_Year+1;
}
}
}
break;
}
}
while(1);
}