CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

GPS with microcontroller
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

GPS with microcontroller
PostPosted: Fri Oct 16, 2009 9:25 am     Reply with quote

Hi,
Have anyone use GPS module (GT-310FA) with pic16f877a.
I want to send some instruction to the module and read time/date from the module.
Can anyone have idea how to do this?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Oct 16, 2009 9:35 am     Reply with quote

I implemented a GPS2058 from DeLorme... Works great.

The GPS is the system clock source for the RTC. Once the RTC is set, the GPS is turned off.

I did my routine using a UART ISR that collects the string and on CR/LF parses it out.

Works great.

--- Additional:

Make sure you use a hardware UART for the GPS. Don't try to do any RS232 in software.

If you need more than 1 UART, get a PIC with 2 UARTs. The 18FxxJ11 series is the way to go for low pin-counts.

I used an 18F46J11 on a project recently and it's worked out nicely so far.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Sat Oct 17, 2009 3:07 am     Reply with quote

Can anyone give me some c code examples how to send and receive data from GPS (specially for GT-310FA).
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Oct 17, 2009 8:34 am     Reply with quote

I'll PM my code for the DeLorme unit to you later -- just please don't redistribute. Have people come to me for a copy.

I'm just about to run out on some errands and then I'll be back.

I also used the same code slightly modified for a Garmin OEM GPS/16x.

All GPS's although NMEA will be a little different (shame on them! Goodbye standards).. but it's not hard to modify for your GPS.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Mon Oct 19, 2009 5:24 am     Reply with quote

Thanks bkamen.

I am getting RMC data on my hyper terminal like this:
-------------------------------------------------------------------------------------
$GPRMC,160612.00,A,2456.4010,N,06705.1067,E,000.1,083.8,191009,000.4,E,A*35
$GPRMC,160613.00,A,2456.4011,N,06705.1065,E,000.1,083.8,191009,000.4,E,A*37
$GPRMC,160614.00,A,2456.4012,N,06705.1063,E,000.1,083.8,191009,000.4,E,A*35
$GPRMC,160615.00,A,2456.4013,N,06705.1061,E,000.1,083.8,191009,000.4,E,A*37
$GPRMC,160616.00,A,2456.4013,N,06705.1060,E,000.0,083.8,191009,000.4,E,A*34
$GPRMC,160617.00,A,2456.4013,N,06705.1058,E,000.0,083.8,191009,000.4,E,A*3E
$GPRMC,160618.00,A,2456.4013,N,06705.1056,E,000.1,083.8,191009,000.4,E,A*3E
$GPRMC,160619.00,A,2456.4013,N,06705.1053,E,000.2,083.8,191009,000.4,E,A*39
$GPRMC,160620.00,A,2456.4013,N,06705.1050,E,000.1,083.8,191009,000.4,E,A*33
$GPRMC,160621.00,A,2456.4016,N,06705.1047,E,000.1,083.8,191009,000.4,E,A*31
$GPRMC,160622.00,A,2456.4016,N,06705.1045,E,000.1,083.8,191009,000.4,E,A*30
$GPRMC,160623.00,A,2456.4016,N,06705.1042,E,000.1,083.8,191009,000.4,E,A*36
-------------------------------------------------------------------------------------

Now I want to read that data in microcontroller and display it on the LCD.
Can anyone tell me how to do it
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Oct 19, 2009 9:31 am     Reply with quote

If you'll notice, the GPS information is stored in a structure of strings and variables.

You need to decide what you want to print but essentially you would have a line that says

printf(lcd_putc,"%s", string);
or
printf(lcd_putc,"%u or %c", variable, character);


Have fun!

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Mon Oct 19, 2009 11:28 pm     Reply with quote

Thanks bkamen,
In this sentence there are strings, integers and floating numbers are present. You may find this as a silly question but I don't know how to get all these data and what type of buffers are used to store it.
Can you generate a code for me?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 20, 2009 5:49 pm     Reply with quote

hayee wrote:

In this sentence there are strings, integers and floating numbers are present. You may find this as a silly question but I don't know how to get all these data and what type of buffers are used to store it.


If you look at the code I gave you, it does that for you.
I'm guessing you didn't look closely enough.

hayee wrote:
Can you generate a code for me?


I could - but where would be the learning experience for you if I just did it for you?

Ultimately, if you'd like to hire someone to do this for you, I and others are surely willing as this is how we make our living.

Good Luck,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Tue Oct 20, 2009 10:42 pm     Reply with quote

bkamen I didn't see your code. That's why I reply. I got your code and seeing how you done it.
Anyways thanks alot for your cooperation.
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 2:46 am     Reply with quote

I saw your code. Can I read data without using interrupt?
I don't wanna use interrupt.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 6:02 am     Reply with quote

the interrupts are really nice..

while I suppose you could do it without, if your project has any other tasks going on, this would make everything run more consistently rather than stalling out "polling" for GPS sentences.

Why don't you want to use interrupts?

-ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 11:04 pm     Reply with quote

You are right I have another tasks, I am also using two more interrupts(External).
Can you explain in wordings about the steps required in reading the data from GPS module.
I have found a code by searching the forum. Will this code work? This code is using GPGGA format. I ran it by doing some changes according but it is not working. Original code is as follows.
http://www.ccsinfo.com/forum/viewtopic.php?t=36043
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Sat Oct 24, 2009 7:00 am     Reply with quote

Thanks bkamen.
I understand the RDA interrupt service routine and implement it and got the data in the microcontroller from GPS module without any error.
It is displaying on hyper terminal and on LCD.
Now the remaining part is that I have to separate time and date from the received sentence, and display it on the LCD.
Can you help me how to convert these data's in integer format because right now data is in string format.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Oct 24, 2009 11:40 am     Reply with quote

hayee wrote:
Thanks bkamen.
I understand the RDA interrupt service routine and implement it and got the data in the microcontroller from GPS module without any error.
It is displaying on hyper terminal and on LCD.
Now the remaining part is that I have to separate time and date from the received sentence, and display it on the LCD.
Can you help me how to convert these data's in integer format because right now data is in string format.



Glad to hear you're making progress.

As for displaying on the screen. Does it matter if it's in numeric vs. string format?

If you're doing nothing else but displaying the value, then you don't need it converted to numbers.

Also, if you look at the parsing routine, it should put the GPS coods into a string for you that can then be used in atof() to make a "number" out of it.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
hayee



Joined: 05 Sep 2007
Posts: 252

View user's profile Send private message

PostPosted: Mon Oct 26, 2009 12:01 am     Reply with quote

Ya I have to separate the time and date because I will use time and date parameter in my program to store some data according to time and date.
In the time I only want (hhmmss) only not the remaining (.ss) part so I think I have to use atoi() function instead of atof().
I am doing like this way in my code
Code:

for(i=0;i<6;i++)
{
 time[i]=gps_string[7+i];
}
printf(lcd_putc;"\f%s",time);

time is a char array.
time[0 to 1] have hour reading
time[2 to 3] have mins reading
time[4 to 5] have secs reading.

Now for separation of hours mins and secs I am doing like this
hours,mins,secs are char arrays
hour,min,sec are ints.
Code:

for(i=0;i<2;i++)
{
 hours[i]=time[7+i];//hours value starts from 7th position
}
hour=atoi(hours);
for(i=0;i<2;i++)
{
 mins[i]=time[9+i];//mins value starts from 9th position
}
min=atoi(hours);
for(i=0;i<2;i++)
{
 secs[i]=time[11+i];//secs value starts from 11th position
}
sec=atoi();

and after this when I display the values it shows me wrong values.
Is there any other conversion is required?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group