|
|
View previous topic :: View next topic |
Author |
Message |
cengav4r
Joined: 31 May 2012 Posts: 10
|
GPS codes not working properly |
Posted: Mon Sep 29, 2014 8:16 am |
|
|
I have 18F4550 and Crius CN-06 GPS Module. I want to print coordinate of Gps position to LCD module. Firstly, I want to printf whatever comes from GPS to LCD. UNfournately, I could not get correct NMEA format. I am getting nonsense staff. I tried the my system inside and outside and different baudrates. Could you show me my fault where is? Regards
How many minute wait necessary to GPS lock to the satellites?
Codes;
Code: |
if(getch()=='$')
{
for(i=0;i<66;i++)
{
e=getch();
GelenGps[i]=e;
printf(lcd_putc,"%c",GelenGps[i]);
delay_ms(10);
}
}
|
Last edited by cengav4r on Mon Sep 29, 2014 9:17 am; edited 2 times in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Sep 29, 2014 8:29 am |
|
|
Use the hardware UART.
Get rid of the delay.
You are using a software UART (forced by using the E1/E2 pins). This has no buffering. So one character arrives, and then you spend several hundred uSec writing this to the LCD (LCD's are _slow_), then pause for 10mSec. _Anything_ arriving in all this time is now lost. With no buffering, this is going to be the next ten characters+. You then start looking again, and at this point could even be 'mid character'. So from this point, 'garbage'....
Use the hardware UART pins.
Use a larger circular buffer (look at ex_sisr.c, and search here about this).
Then remember that even this larger buffer will overflow, unless the whole string is dealt with before the next one comes. |
|
|
cengav4r
Joined: 31 May 2012 Posts: 10
|
|
Posted: Mon Sep 29, 2014 8:51 am |
|
|
Thank you for response,
Now I tried below code. I will try it at outside. It seems OK ;). Why it is not good E1-E2 pins in order to C6-C7. If I want to get two UART what should I do? Any more good suggesstion,appreciated.
Code: | if(getch()=='$')
{
for(i=0;i<66;i++)
{
e=getch();
GelenGps[i]=e;
}
}
delay_ms(100);
for(i=0;i<66;i++)
{
printf(lcd_putc,"%c",GelenGps[i]);
delay_ms(100);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Sep 29, 2014 9:07 am |
|
|
Get a chip with two UART's.....
The software UART, is half duplex, and _requires_ that the code is sitting 'waiting' for data to arrive.
Chips like the 46J50, give another UART which is relocatable, and other extras like a second SPI also relocatable etc... |
|
|
cengav4r
Joined: 31 May 2012 Posts: 10
|
|
Posted: Mon Sep 29, 2014 9:10 am |
|
|
I tried it at outside and wait approximately 5-10 min. I get nearly correct NMEA format with some errors (which means display show full character (1111 x 1111). How can I fix these errors? (I didn't change UART pins, I used E1-E2).Thank you for everything. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Sep 29, 2014 9:18 am |
|
|
You are still running out of time.
As I already pointed out the LCD is quite slow. Slow enough that you may occasionally not finish writing in time for the next character. Worse though, USB _will_ occasionally require interrupt servicing, and when this happens, you will get corrupted characters using the software UART. |
|
|
cengav4r
Joined: 31 May 2012 Posts: 10
|
New Questions |
Posted: Tue Sep 30, 2014 7:30 am |
|
|
My current problem is How can I get data which is coming from GPS. I want to take whatever (all data) comes and send to USB.
Code: |
if(getch()=='$')
{
for(i=0;i<67;i++)
{
e=getch();
GelenGps[i]=e;
delay_us(5);
}
}
delay_ms(100);
for(i=0;i<67;i++)
{
usb_put_packet(UcNokta1,GelenGps[i] ,64, USB_DTS_TOGGLE); // Datayı Gönder..
delay_ms(500);
}
|
1.How can I get lenght of data (which is coming from GPS).I mean What should I write for(i=0;i<67;i++) 67 to ??
2.What is the best way to send data (which is coming from GPS) to USB. Interrupt?, Rtos? other??
I am getting below lines from USB. (Indoor test)
Code: | ? ?xD?T!` T?@?? ????5q v%0*??(??0L???5q v%0*??(??0L?@$
?R?5b,=GPRMGG@?,V,,,,%0*??(??0L?@$
?R?5b,>GPRMPP@?,V,,,,,,,0@??5q v%0*??(??0L?@$
?R?5b,?GPRMGG@?,V,,,,??5q v%0*??(??0L?@$
?R?5b,@GPRMGG@?,V,,,,?? ????5q v%0*??(??0L?@$
?R?5b,AGPRMAA@??xD?T!` T?@?? ????5q v%0*??(??0L?@$
?R?5??5q v%0*??(??0L?@$
?R?5b,GPGGG@? |
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Sep 30, 2014 8:22 am |
|
|
cengav4r,
You have already been told the answer several times, but you aren't listening, or you don't like the answer. To *reliably* receive serial data from the GPS you are going to need to implement an interrupt driven serial data buffering scheme, preferably with a 'circular' receive buffer. Any other method is going to be sub-optimal, as you've already seen.
So, #1, use the internal hardware UART, and #2, implement an interrupt drive serial receive scheme using the int_rda interrupt. A great example of this is CCS example program 'ex_sisr.c'.
You don't need to know the total number of characters to receive. The NMEA string always starts with the '$', and always ends with the 'CR/LF', so use these unique characters to determine when each NMEA string begins and ends.
Again, this is a rehash of previous advice, so please take it and stop coming back here asking the same question over and over. Trust me, the answer will always be the same!
John |
|
|
|
|
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
|