How to extract data from neo 6m gps module

Go To Last Post
61 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I have tried to use Ublox Neo 6M GPS module (UART). I have successfully tested the module with USB to TTL Converter.

Now i have a Query how to Grep the data ? In linux i always used command GREP to capture some specific text.

How about capturing some strings in C ?

GPS Data file is as below. (I want to extract time and show on 7-Segment Display / LCD)

Characters shown bold are the UTC Time which i need to capture... which command should be used ?

Thanks

$GPGSA,A,3,25,29,12,21,18,05,15,,,,,,3.47,1.42,3.16*05
$GPGSV,3,1,10,02,15,062,07,05,38,038,17,12,36,184,33,15,32,144,21*70
$GPGSV,3,2,10,18,28,222,45,21,26,288,42,25,53,232,42,26,27,104,20*78
$GPGSV,3,3,10,29,52,344,32,39,34,249,40*70
$GPGLL,2227.57129,N,07004.19412,E,172518.00,A,D*65
$GPRMC,172519.00,A,2227.57131,N,07004.19415,E,0.114,,040614,,,D*70
$GPVTG,,T,,M,0.114,N,0.211,K,D*20
$GPGGA,172519.00,2227.57131,N,07004.19415,E,2,07,1.42,34.0,M,-55.6,M,,0000*45

Last Edited: Sat. Jun 7, 2014 - 03:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

strtok() or (shudder) sscanf()

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search this site and Google for e.g. "parse NMEA string".

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, i found more informaiton about using strtok() or (shudder) sscanf() from google. But now question is should i store first complete data i mean one shot of data given by gps at one time

$GPGSA,A,3,25,29,12,21,18,05,15,,,,,,3.47,1.42,3.16*05
$GPGSV,3,1,10,02,15,062,07,05,38,038,17,12,36,184,33,15,32,144,21*70
$GPGSV,3,2,10,18,28,222,45,21,26,288,42,25,53,232,42,26,27,104,20*78
$GPGSV,3,3,10,29,52,344,32,39,34,249,40*70
$GPGLL,2227.57129,N,07004.19412,E,172518.00,A,D*65
$GPRMC,172519.00,A,2227.57131,N,07004.19415,E,0.114,,040614,,,D*70
$GPVTG,,T,,M,0.114,N,0.211,K,D*20
$GPGGA,172519.00,2227.57131,N,07004.19415,E,2,07,1.42,34.0,M,-55.6,M,,0000*45

and put this data into array ? or we can search for what we want while the data is being input to MCU via UART ? i am afraid that doing online job would make it miss something ?

Please guide..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your choice. If you want to save memory, you decode it character by character and only store the fields you are interested in. First up you need to detect the start of a message then keep track of the checksum. Next level is to detect the message you're interested in then extract the field you want.
What does the Arduino code do?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Personal choice, but I would definitively recommend to first read in a complete line to a string variable or circular buffer, and then do the decoding/parsing after that.

With such an arrangement, and a proper modularized design, you can test the parsing separately. Perhaps not even in an AVR, but e.g. in a C/C++ environment on your PC.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why would anyone be worrying about strtok/sscanf for NMEA parsing at this stage. There are about a thousand implementations of NMEA sentence parsing on the internet. Some good, some not so good, some parse whole sentences, some use a sate machine. All can be tested in isolation without even owning a micro or an NMEA producer. When happy graft the decode engine into your AVR code.

I'd probably start by exploring the stock Arduino solution for this - if it's used for Arduino it's probably used in tens of thousands of different GPS gadgets. The only challenge with Arduino code is extracting it from the environment but, as I say, NMEA decode is a high level function that (apart from UART byte input) is not tied to the hardware in any way.

As always, developing and testing something like this is a far more pleasant experience done in the environment of a PC program than fiddling about on a micro. Just stick some example strings:

$GPGSA,A,3,25,29,12,21,18,05,15,,,,,,3.47,1.42,3.16*05
$GPGSV,3,1,10,02,15,062,07,05,38,038,17,12,36,184,33,15,32,144,21*70
$GPGSV,3,2,10,18,28,222,45,21,26,288,42,25,53,232,42,26,27,104,20*78
$GPGSV,3,3,10,29,52,344,32,39,34,249,40*70
$GPGLL,2227.57129,N,07004.19412,E,172518.00,A,D*65
$GPRMC,172519.00,A,2227.57131,N,07004.19415,E,0.114,,040614,,,D*70
$GPVTG,,T,,M,0.114,N,0.211,K,D*20
$GPGGA,172519.00,2227.57131,N,07004.19415,E,2,07,1.42,34.0,M,-55.6,M,,0000*45

into an initialized char array and then feed them into the parser and see what comes out the other end.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I have learned how to use sscanf to parse the static data. But what about the data from UART. It would be dynamic every time it wont start from $GPRMC for which i have created the formatted input sscanf :o how to extract the required data and store and then parse it ?

which command in c will help to extract data from $GPRMC upto \n or \r or \0 ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ensure you get a line of data - detect the cr/lf at the end.
Personally i think sscanf is not a good method. Did you investigate arduino code?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No i did not looked much to Arduino library..i search google for NMEA parse but did not get fruitful information how to select and process particular sentence from UART register UDR.

So according to you ? which function should be used ? instead of sscanf ? I tried strtok but it can only print data how to store token seperated values to different array ? that's why i selected sscanf...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I described earlier how i would do it - actually how i have done it in the past. I have a state machine that looks for the start $, puts the chars into a buffer whilst accumulating the checksum, then if i get a *, then the next two chars are the checksum.if the checksum works out, then that is a good sentence. You can add extra states to look for only one sentence or you can process a complete sentence.

Google for 'arduino gps'

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
It would be dynamic every time it wont start from $GPRMC

So you just need to wait until you do have a complete $GPRMC sentence!

Quote:
how to extract the required data and store and then parse it ?

Did you look at the links I posted?
They show you exactly this :!:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
I described earlier how i would do it - actually how i have done it in the past. I have a state machine...

Likewise - that is the way I would do it, and the way I have done it.

The links I posted show how to do this.
I have successfully used the code from that article.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
i search google for NMEA parse but did not get fruitful

In what way "unfruitful" :?:

Don't expect to find ready-to-use drop-in solutions (though you may get lucky) - look to learn techniques which can be applied...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok finally i have created my own program to extract $GPRMC Data which will give me time and Date. Irrespective location of $GPRMC....currently i have used NMEA[] Buffer to store the date of 8 lines from GPS temporary.. i have created this for dynamic format so where ever the position of the $GPRMC is ...it will catch it and process it accordingly. I have tested this code on Code blocks and works fine. Will try now on breadboard with Atmega8.

Any suggestions ? please...do comment..

C Program
[url]http://pastebin.com/8LFXM1Da[/url]

output is

172519.000000 40614 (Time Date)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your code assumes the data you get is properly formed. Most of the time it is...but what happens if you get bad data? How will you know?

C strings are terminated by a null byte. You might want to use this feature to determine the end of the string rather than blindly scanning an array.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please check I have added contion to check if \n or \r is found break;

[url]http://pastebin.com/hmBRB57y[/url]

is this ok ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does it work? Seems like having the GPS output going to the AVR would tell you in seconds. How long does it take for some AVRfreak on another continent to deskcheck your program? What is your location narrowed down to a continent anyway? I think we all assume you are from Earth. I think.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i think this will help me to break the loop once the end of string is received


if(NMEA[z] == '\n' || '\r' || '\0');
break;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Of course the End-Of-String can also be recognized by the $ at the start of the next string...

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Of course the End-Of-String can also be recognized by the $ at the start of the next string...

This might cause a more or less substantial delay depending on if/when the next string arrives.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
i think this will help me to break the loop once the end of string is received

if(NMEA[z] == '\n' || '\r' || '\0');
                break;


No, I don't think it will.

What does the expression

 '\n' || '\r' || '\0'

evaluate to...?

8)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

\n for new line \r for return \0 for null character detection..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Err..... Not quite - especially the way you've written the expression. Time you get your C textbook out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hhhhhmmmmmmm while compiling i did not get any error... you mean to say


if(NMEA[z] == ('\n') || ('\r') || ('\0'));
break;

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No you just can't do that in C. If you want to test that one item for 3 possibilities you need to check each one individually then OR their results. So:

if ((NMEA[z] == '\n') ||
(NMEA[z] == '\r') ||
(NMEA[z] == '\0')) {
break;
}

Oh and in adding the {} (which I'd recommend you ALWAYS use!) I notice that as it stands you have a ';' at the end of the if() anyway so the "break;" is not conditional but would always be taken.

I'm surprised your compiler was not warning you about this already? Certainly any half decent code analyser (lint, cppcheck, etc) would have been screaming at this stage!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
hhhhhmmmmmmm while compiling i did not get any error...

Because there is no error as far as the language is concerned!

But the code you've written does not do what you want :!:

asking wrote:
you mean to say
if(NMEA[z] == ('\n') || ('\r') || ('\0'));


No.

Again, evaluate the expression on the right-hand side of the '==' operator:

('\n') || ('\r') || ('\0'))

It is a single expression - it has a single value :!:

http://blog.antronics.co.uk/2011...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
asking wrote:
hhhhhmmmmmmm while compiling i did not get any error...

Because there is no error as far as the language is concerned!

But the code you've written does not do what you want :!:


A woman said to her husband, "go to the shop and get a loaf of bread. If they have eggs, get half a dozen"

He came back with 6 loaves of bread.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have tested the Print on LCD using GPSFeed Simulator program for windows and using USB-TTL connected to my Atmega8. I can easily read the NMEA String. But when i connected my NEO-6M GPS Module instead of Simulator i am getting symbols and random characters instead of NORMAL NMEA String. Means what could be wrong ? Surprisingly...if i connect GPS Module to PC it shows Perfect NMEA Strings.... Means MCU is not able to catch proper characters from NEO-6M GPS Module... i have kept 9600 Baud Rate default. Update frequency is 5HZ as default from GPS Module ? do we need to consider 5HZ ? for MCU Programming ?

My Code:


# define F_CPU 11592000UL
# define BAUDRATE 9600
# define BAUD_PRESCALE ((( F_CPU / ( BAUDRATE * 16UL))) - 1)
#define AS 20 // SIZE OF ARRAY

#define MAX 300 //max size of sentence buffer
char NMEA[300];
#include <avr/io.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <lcd.h>
#include <util/delay.h>

char kalpesh;
char buffer[10];
char buffer1[50];
int z = 0, i1 = 0;
int result;
double fp,fp1,fp2,fp3;
uint16_t int4, int5;
char a[AS], b[AS], c[AS], d[AS], e[AS], f[AS], g[AS], h[AS], i[AS], j[AS], k[AS], l[AS], m[AS];

// function to initialize UART
void uart_init (void)
{
UCSRB = (1<<TXEN)|(1<<RXEN)|(0<<RXCIE); //enable receiver and transmitter
UCSRC = (0<<UMSEL)|(1<<UCSZ0)|(1<<UCSZ1);// 8bit data format // UMSEL 0 FOR ASYNCH
UBRRH = (BAUD_PRESCALE>>8);//set baud rate
UBRRL = BAUD_PRESCALE;
}

void uart_transmit (char data)
{
while (!(UCSRA) && (1<<UDRE)); // wait while register is free
UDR = data; // load data in the register
}

// function to receive data
char uart_recieve (void)
{
while((UCSRA & (1 << RXC)) == 0); // wait while data is being received
return UDR; // return 8-bit data
}

// function to received data ATMEL Example

unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) );
/* Get and return received data from buffer */
return UDR;
}

void uart_puts(char *str)
{
while(*str)
{
uart_transmit(*str++);
}
}

int main()
{
//DDRD = 0XFF;
DDRC = 0XFF;
// sei();
uart_init();
lcd_init(LCD_DISP_ON);
lcd_puts("SYSTEM INIT....");
_delay_ms(500);
lcd_clrscr();
char kalpesh;

while(1)
{
kalpesh = USART_Receive();
// lcd_putc(kalpesh);
for(z=0;z<300;z++)
{
NMEA[z] = kalpesh;
}
lcd_putc(NMEA[0]);
}
}# define F_CPU 11592000UL
# define BAUDRATE 9600
# define BAUD_PRESCALE ((( F_CPU / ( BAUDRATE * 16UL))) - 1)
#define AS 20 // SIZE OF ARRAY

#define MAX 300 //max size of sentence buffer

char NMEA[300];
#include <avr/io.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <lcd.h>
#include <util/delay.h>

char kalpesh;
char buffer[10];
char buffer1[50];
int z = 0, i1 = 0;
int result;
double fp,fp1,fp2,fp3;
uint16_t int4, int5;
char a[AS], b[AS], c[AS], d[AS], e[AS], f[AS], g[AS], h[AS], i[AS], j[AS], k[AS], l[AS], m[AS];

// function to initialize UART
void uart_init (void)
{
UCSRB = (1<<TXEN)|(1<<RXEN)|(0<<RXCIE); //enable receiver and transmitter
UCSRC = (0<<UMSEL)|(1<<UCSZ0)|(1<<UCSZ1);// 8bit data format // UMSEL 0 FOR ASYNCH
UBRRH = (BAUD_PRESCALE>>8);//set baud rate
UBRRL = BAUD_PRESCALE;
}

void uart_transmit (char data)
{
while (!(UCSRA) && (1<<UDRE)); // wait while register is free
UDR = data; // load data in the register
}

// function to receive data
char uart_recieve (void)
{
while((UCSRA & (1 << RXC)) == 0); // wait while data is being received
return UDR; // return 8-bit data
}

// function to received data ATMEL Example

unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) );
/* Get and return received data from buffer */
return UDR;
}

void uart_puts(char *str)
{
while(*str)
{
uart_transmit(*str++);
}
}

int main()
{
//DDRD = 0XFF;
DDRC = 0XFF;
// sei();
uart_init();
lcd_init(LCD_DISP_ON);
lcd_puts("SYSTEM INIT....");
_delay_ms(500);
lcd_clrscr();
char kalpesh;

while(1)
{
kalpesh = USART_Receive();
// lcd_putc(kalpesh);
for(z=0;z<300;z++)
{
NMEA[z] = kalpesh;
}
lcd_putc(NMEA[0]);
}
}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
But when i connected my NEO-6M GPS Module instead of Simulator i am getting symbols and random characters instead of NORMAL NMEA String. Means what could be wrong ? Surprisingly...if i connect GPS Module to PC it shows Perfect NMEA Strings....

This probably points to some fault in the communication as such between the GPS module and the AVR.

- Have you verified that the AVR is really running at 11592000 Hz?
- Can you do serial communication between your AVR and your PC reliably?

It would be useful with a schematic of how you have connected the GPS module to the AVR. It might also be helpful if you described how you connected the GPS module to the PC for the successful tests there.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I can easily type on hyperterminal and i can see on my LCD. so PC Test is successful. I have connected the RX --> TX and TX--> RX using USB-TTL PL2303 Chipset. that is why the data from PC to AVR is clearly visible when i use GPS Feed Simulation....

Regarding 11.0592MHZ i am using external crystal (without using 33pf caps) temporary...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Regarding 11.0592MHZ i am using external crystal (without using 33pf caps) temporary...

1. What makes you think it will oscillate correctly without the capacitors?

2. It is not clear to me if from your above answers if you have had successful connection between the AVR and the PC.

How about some schematics?

When answering, do not assume that we can see what is on your bench and in your head. Try to be precise and complete.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


while(1)
{
kalpesh = USART_Receive();
// lcd_putc(kalpesh);
for(z=0;z<300;z++)
{
NMEA[z] = kalpesh;
}
lcd_putc(NMEA[0]);

This is going to get the first rx char and fill your nmea buffer with it. Hardly useful methinks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

 
while(1) 
{ 
   kalpesh = USART_Receive(); 
//   lcd_putc(kalpesh); 
   for(z=0;z<300;z++) 
   { 
      NMEA[z] = kalpesh; 
   } 
    lcd_putc(NMEA[0]); 

This is going to get the first rx char and fill your nmea buffer with it. Hardly useful methinks.

Hi,

I am just testing to see what i get is what i see ? and i found that GPS module talks with PC normally and with AVR its throwing some Garbage values.... i am going to upload photos and circuit schematic soon in few mins...

on contrary...on other side... PC NMEA simulator talks fine with AVR..... i am confused.....what could be wrong ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
Quote:

Regarding 11.0592MHZ i am using external crystal (without using 33pf caps) temporary...

When answering, do not assume that we can see what is on your bench and in your head. Try to be precise and complete.

Please find the image

Actually i have no specific software so i have shown connection in block diagram...

Regarding Question 1:

What makes me think that its running @ 11.0592 is the crystal value without Caps... its working with PC..

when i type something on hyper terminal i can see in 16x2 LCD connected to AVR. So i think its working..

Regarding Question 2:

I get strings properly on the Hyperterminal from NEO-6M GPS Module using usb to TTL Converter. (i am using Putty as Terminal client on Windows 8.1)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is what i am receiving from GPS Module on 16x2 Atmega8 Setup.

[img]http://i60.tinypic.com/28jg00x.jpg[/img]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this happening because i have keep connected my USBAsp to my breadboard ? But if so then from PC --> TTL it works perfect on the same setup.... i am comfused :S

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
This is what i am receiving from GPS Module

Well, it's what's getting displayed on the LCD - that doesn't necessarily mean it's what's being received from the GPS!

You need to do some more debugging to work out whether the problem lies in the reception from the GPS, or the display to the LCD - or both.

Quote:
when i type something on hyper terminal i can see in 16x2 LCD connected to AVR. So i think its working..

Well, it works at typing speed - but the GPS will send characters a lot faster than you can type!

Your diagram shows that the MCU is "5V" and the GPS is "3.3V" - are you sure that these are compatible?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Quote:
when i type something on hyper terminal i can see in 16x2 LCD connected to AVR. So i think its working..

Well, it works at typing speed - but the GPS will send characters a lot faster than you can type!


Interesting theory! This can be tested by using some terminal program that can send a block of characters with the characters "back to back". E.g. Brays Terminal (a.k.a. just "Terminal" or "terminalbpp").

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi johan,

As you said... i tried with Terminalbpp its good app to send text file via UART. I tried and i can easily see on the LCD screen every character is readable and going fast...@ 9600. not like Garbage values as i am getting from GPS Module.. :s i don't know what's wrong..... i gave long back to back block of characters are working well with my setup using the terminal program....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the code to receive characters and the UART parameters (speed etc) are the same when you try PC-to-AVR as when you try GPS-to-AVR, then you should concentrate on the communication between the GPS module and the AVR.

The level issue has been mentioned above.

Next is other electrical issues. Common ground, for example?

If the code for the two test cases is not the same then everything is still open. So show the code - hopefully just one program, used in both cases (PC/AVR and GPS/AVR).

I would still like to see a decent schematic - rather than the "block diagrams" you have shown. I.e. every connection should be clearly depitced - signals, power supply, ground.

This might involve some work on your part that you did not anticipate, but the fact is that the problem is on your side and it is you who ask use for help. We need to know these things.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Code is the same as i shown before, just to check what is being getting into Array NMEA. Every data entered in Array is shown on LCD.

Regarding Schematic, actually i do not have any software that can show you all the required components connected. Simply i would like to say. I connected RX/Tx from GPS to Tx/Rx of AVR. Grounds are common as the system is running from one power source(USB/SMPS).

for 3.3V I am using MB102 BreadBoard Power Supply.

(3.3 V for Atmega8 and GPS Module, 5V for LCD)

[img]http://i57.tinypic.com/e71lwp.jpg[/img]

So power grounds are common for AVR & GPS. I have also connected 100nf Decoupling cap to Atmega8 and 33pf caps to XTAL 11.0592 Mhz.

Suggest any small size software for creating simple schematics so i can make one.


# define F_CPU 11592000UL
# define BAUDRATE 9600
# define BAUD_PRESCALE ((( F_CPU / ( BAUDRATE * 16UL))) - 1)
#define AS 20 // SIZE OF ARRAY

#define MAX 300 //max size of sentence buffer
char NMEA[300];
#include <avr/io.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <lcd.h>
#include <util/delay.h>

char kalpesh;
char buffer[10];
char buffer1[50];
int z = 0, i1 = 0;
int result;
double fp,fp1,fp2,fp3;
uint16_t int4, int5;
char a[AS], b[AS], c[AS], d[AS], e[AS], f[AS], g[AS], h[AS], i[AS], j[AS], k[AS], l[AS], m[AS];

// function to initialize UART
void uart_init (void)
{
UCSRB = (1<<TXEN)|(1<<RXEN)|(0<<RXCIE); //enable receiver and transmitter
UCSRC = (0<<UMSEL)|(1<<UCSZ0)|(1<<UCSZ1);// 8bit data format // UMSEL 0 FOR ASYNCH
UBRRH = (BAUD_PRESCALE>>8);//set baud rate
UBRRL = BAUD_PRESCALE;
}

void uart_transmit (char data)
{
while (!(UCSRA) && (1<<UDRE)); // wait while register is free
UDR = data; // load data in the register
}

// function to receive data
char uart_recieve (void)
{
while((UCSRA & (1 << RXC)) == 0); // wait while data is being received
return UDR; // return 8-bit data
}

// function to received data ATMEL Example

unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) );
/* Get and return received data from buffer */
return UDR;
}

void uart_puts(char *str)
{
while(*str)
{
uart_transmit(*str++);
}
}

int main()
{
//DDRD = 0XFF;
DDRC = 0XFF;
// sei();
uart_init();
lcd_init(LCD_DISP_ON);
lcd_puts("SYSTEM INIT....");
_delay_ms(500);
lcd_clrscr();
char kalpesh;

while(1)
{
kalpesh = USART_Receive();
// lcd_putc(kalpesh);
for(z=0;z<300;z++)
{
NMEA[z] = kalpesh;
}
lcd_putc(NMEA[0]);
}
}# define F_CPU 11592000UL
# define BAUDRATE 9600
# define BAUD_PRESCALE ((( F_CPU / ( BAUDRATE * 16UL))) - 1)
#define AS 20 // SIZE OF ARRAY

#define MAX 300 //max size of sentence buffer

char NMEA[300];
#include <avr/io.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <lcd.h>
#include <util/delay.h>

char kalpesh;
char buffer[10];
char buffer1[50];
int z = 0, i1 = 0;
int result;
double fp,fp1,fp2,fp3;
uint16_t int4, int5;
char a[AS], b[AS], c[AS], d[AS], e[AS], f[AS], g[AS], h[AS], i[AS], j[AS], k[AS], l[AS], m[AS];

// function to initialize UART
void uart_init (void)
{
UCSRB = (1<<TXEN)|(1<<RXEN)|(0<<RXCIE); //enable receiver and transmitter
UCSRC = (0<<UMSEL)|(1<<UCSZ0)|(1<<UCSZ1);// 8bit data format // UMSEL 0 FOR ASYNCH
UBRRH = (BAUD_PRESCALE>>8);//set baud rate
UBRRL = BAUD_PRESCALE;
}

void uart_transmit (char data)
{
while (!(UCSRA) && (1<<UDRE)); // wait while register is free
UDR = data; // load data in the register
}

// function to receive data
char uart_recieve (void)
{
while((UCSRA & (1 << RXC)) == 0); // wait while data is being received
return UDR; // return 8-bit data
}

// function to received data ATMEL Example

unsigned char USART_Receive( void )
{
/* Wait for data to be received */
while ( !(UCSRA & (1<<RXC)) );
/* Get and return received data from buffer */
return UDR;
}

void uart_puts(char *str)
{
while(*str)
{
uart_transmit(*str++);
}
}

int main()
{
//DDRD = 0XFF;
DDRC = 0XFF;
// sei();
uart_init();
lcd_init(LCD_DISP_ON);
lcd_puts("SYSTEM INIT....");
_delay_ms(500);
lcd_clrscr();
char kalpesh;

while(1)
{
kalpesh = USART_Receive();
// lcd_putc(kalpesh);
for(z=0;z<300;z++)
{
NMEA[z] = kalpesh;
}
lcd_putc(NMEA[0]);
}
}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update:

Recently i just try with different Grounds for both END. GPS \ AVR. Still same garbage values getting displayed on LCD.

:(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Finally i got it :D

It was my mistak for F_CPU 11059200UL it was F_CPU 11592000UL

While analysing in detailed i found the mistake and now my USART is working fine with GPS :) I can see proper data on LCD.

Thanks....guyz for supporting me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

It was my mistak for F_CPU 11059200UL it was F_CPU 11592000UL

So the code for the GPS/AVR case and the PC/AVR case was not the same?!

I asked (or at least implied a question regarding it), and while not crystal clear it seems to me that you stated that the same code was used in both cases.

If the test code differed between the cases, then the second half of this thread has been more or less a waste of time.

Nowhere in this thread have you posted code with the erroneous value if the F_CPU def.

Lessons:

1. Actually follow advice, answer questions to the point etc. Don't rely on assumptions or being convinced that "it can't be that...".

2. Vary things as little as possible in this kind of comparative test. The exact same code could have been used for both cases, and then you would not have had one working and the other not.

3. Or you could actually have stated that you used two different sets of code for the two test cases. If you had stated that clearly, we would immediately have asked for both, and we would most likely have spotted the difference early.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oohhhhh wait,

There are no different codes. Every where I made same mistake. You kindly check my codes everywhere I thought its 11.0592mhz but it was 11.592mhz. So for simple typing test it works..but when we transfer with high speed proper mhz reuired for proper communication. Yes for just wrong Fcpu value half of thread is waste of time. But lesson for new commer like me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:
...What is your location narrowed down to a continent anyway? I think we all assume you are from Earth. I think.

I guess 22.459521 70.069902 that tall building on Arya Samal Road next to the west-looking window.

Asking: your code looks weird.
What are you going to use this anyway?
Do you need date and time, and discard the rest, or it's just the initial phase of a project, and you'll need the others as well?
If UTC time and date is enough, I suggest using GPRMC for date, and RMC and GGA for time. Some receiver may send certain messages less often, but you can rely on GGA's time. (e.g. GSV block is sent every 5 seconds, while GGA is sent every second)

Just a few things: when you see coordinates like this: 2227.57131,N,07004.19415,E you shouldn't read those as floating point numbers, because 2227.57131 means actually 2 numbers: 22 degrees and 27.57131 minutes! Its length is between 3 and 8 decimals after the point.
Generally you can't assume a 'C' after a $ will be GPRMC. Of course if you'll never want to run this with a different receiver, you'll be OK. But we don't know how you want to use it.
I guess the previous commenters suggested using an internal interface to feed your characters one by one, put these into some sort of buffer, and parse them when ready. You assumed the whole data is already in a HUGE buffer you can't afford on many uCs.
Do you need to know time once on initialization, or you'll need updates as well after that? In second case you'll need to use your parser every time a valid NMEA sentence is received, and pass new time further if it had a valid timestamp (and checksum).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nyosigomboc

I want to extract Time & Date from GPS Module for keepig my clocks updated. this is the initial phase so i am just looking at what the input data is coming. Now will move forward how to parse the same in the easiest way.

Regards.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

asking wrote:
Now will move forward how to parse the same in the easiest way.

Did somebody mention State Machines...?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
asking wrote:
Now will move forward how to parse the same in the easiest way.

Did somebody mention State Machines...?

Yes, I am working on that :) soon will update..

Pages