Pages: [1]   Go Down
Author Topic: gps coordinates not updated (mega itead V1)  (Read 1334 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
My itead gps shield always returns the same coordinates as long as Arduino is powered. It is exactly the same problem as described here http://arduino.cc/forum/index.php?topic=109398.0 only the solution is not helping me out.
I'm logging the Arduino mega data every second since 25 march 2013 and all the files I checked have the same behavior.
I see the same value in the GPRMC as the GPGLL message.
My robot has been running around in my garden (+-2000 m²) so that should lead to a different coordinate.
I checked the data sheet of the GPS module on the shield (EB-365 GPS module) and that did not point me to any wrong settings.
Anyone can help?

Best regards
Janje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What code are you using for getting that data?
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The itead is just reading the serial port. I'm sure that is not the problem.
I have been keeping an closer eye during run time (the GPS output is displayed on my web site ever second) and sometimes -mostly at startup- the module does send some deviations.
The previous GPS module (adafruit) always returned different values (even when staying put).
I bought the itead because it has the sd card on the side which is very practical in a mega setup.
Right now I'm not sure that was a good idea  smiley-sad
Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The itead is just reading the serial port. I'm sure that is not the problem.

But you must have logged it somehow. Writing to the SD card may influence the result as well as sending it to the computer (conflict on pins 0 and 1, or using the SoftwareSerial class, both may be a source of problems). So I ask again: please show us your code.
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm logging the data to my NAS via a hacked linksys router that connects to the serial port (pin 0 and 1)
I modded the shield so it connects to Serial3 of a mega.
I'm not using software serial.
The code is part of a very big project (20+ kg robot). I could make a demo project but then I need to change/make some hardware so that would take some time.
As you can see the hex file is not small
Code:
Device: atmega2560

Program:   62018 bytes (23.7% Full)
(.text + .data + .bootloader)

Data:       5279 bytes (64.4% Full)
(.data + .bss + .noinit)

I was wondering if there are settings I can send to the gps module. For instance Docedison mentions "Selective Availability' in the thread of my first post (but that is another gps module).

Best regards
Jantje

« Last Edit: May 11, 2013, 06:41:01 am by Jantje » Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
that connects to the serial port (pin 0 and 2)

The main serial port is on pins 0 and 1.

Quote
I modded the shield so it connects to Serial3 of a mega.

Can you show us that part of the code reading the Serial3 and the part thats printing it to Serial?

Can you post an example output (NMEA) you get (constantly)?
Does anything change on the NMEA line? The time for example?

BTW: The link to the GPS chip's datasheet (should have been provided by you): http://www.globalsat.com.tw/globalsat_admin/new_file_download.php?Pact=FileDownLoad&Pval=3551
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 68
Posts: 1926
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

indeed it is pin 0 and 1 and not 0 and 2. I fixed that.
The gps sends information exactly like the post I referred to. I copy that one here as I prefer not to share my gps location with "the big bad internet"
Quote
$GPRMC,150111.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*6B
$GPRMC,150112.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*68
$GPRMC,150113.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*69
$GPRMC,150114.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*6E
$GPRMC,150115.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*6F
$GPRMC,150116.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*6C
$GPRMC,150118.000,A, 4551.8988 ,N, 01211.8911 ,E,0.00,263.77,110612,,,D*62
For me also the time and the checksum change but the location remains the same -even going 100 meters away does not change the position-.
I stopped looking for the root cause and I ordered new gps breakout boards.
I'm still interested in a workaround and/or people having the same experience.
This is the cpp code of the basic gps class
Code:
#include "gps_Library.h"


GPSModule::GPSModule(long gpsRate, SERIALTYPE *serial)
: m_LastMessageTimeStamp(0)
{

m_LastMessageLocation.myLatitude = 0;
m_LastMessageLocation.myLongitude = 0;
m_LastMessageDirection = 0;
m_LastMessageSpeed = 0;
bufferidx = 0;
buffer[0] = 0;

LastFixMessage = 0;
m_LastMessageIsfix = false;
m_gpsSerial = serial;
m_gpsRate = gpsRate;
}


void GPSModule::setup()
{
(*m_gpsSerial).begin(m_gpsRate);
SHOW_DEBUG_INFO_LN(DEBUGLEVEL_GPS_BUSINESS, "GPS initialized");
}

// read a Hex value and return the decimal equivalent
uint8_t parseHex(char c)
{
if (c < '0') return 0;
if (c <= '9') return c - '0';
if (c < 'A') return 0;
if (c <= 'F') return (c - 'A') + 10;
return 0;
}

void GPSModule::loop()
{
char ReceivedChar;
uint8_t sum;
int InBuffer;

while ((InBuffer = (*m_gpsSerial).available()) > 0)
{
ReceivedChar = (*m_gpsSerial).read();
if (ReceivedChar=='\r') ReceivedChar=' ';
buffer[bufferidx++] = ReceivedChar;
buffer[bufferidx] = 0; //terminate with 0
if ((ReceivedChar == '$') & (bufferidx != 1))
{
SHOW_DEBUG_INFO_VAR_LN(DEBUGLEVEL_GPS_TRACE, buffer);
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: start of new line received in message");
bufferidx = 0;
buffer[bufferidx++] = ReceivedChar;
buffer[bufferidx] = 0; //terminate with 0
}

if (ReceivedChar == '\n') // the message is complete
{
buffer[bufferidx - 1] = 0;
SHOW_DEBUG_INFO_VAR_LN(DEBUGLEVEL_GPS_TRACE, buffer);
if (buffer[bufferidx - 5] != '*')
{
// no checksum?
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: there is no checksum in the message");
bufferidx = 0;
return;
}
// get received checksum
sum = parseHex(buffer[bufferidx - 4]) * 16;
sum += parseHex(buffer[bufferidx - 3]);

// check checksum
for (int i = 1; i < (bufferidx - 5); i++)
{
sum ^= buffer[i];
}
if (sum != 0)
{
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: received checksum is wrong");
bufferidx = 0;
return;
}
// got good data!

if (strstr(buffer, "GPRMC"))
{
parseGPRCMessage();
if (m_LastMessageIsfix)
{
LastFixMessage = millis();
}
processGPRMCMessage();
}
bufferidx = 0;
}

if (bufferidx == BUFFSIZE - 1)
{
SHOW_DEBUG_INFO_STRING_LN(DEBUGLEVEL_GPS_TRACE, "ERROR: received message that is longer than the buffer");
bufferidx = 0;
}

}

}

GPSDIRECTION GPSModule::getLastMessageDirection() const
{
return m_LastMessageDirection;
}

GPSLocation GPSModule::getLastMessageLocation() const
{
return m_LastMessageLocation;
}

GPSSPEED GPSModule::getLastMessageSpeed() const
{
return m_LastMessageSpeed;
}

DateTime GPSModule::getLastMessageTimeStamp() const
{

return m_LastMessageTimeStamp;
}

boolean GPSModule::hasReception() const
{
unsigned long Curtime = millis();
return (((LastFixMessage + 5000) > Curtime) && ((m_LastMessageLocation.myLatitude + m_LastMessageLocation.myLongitude) != 0));
}

void GPSModule::parseGPRCMessage()
{
m_LastMessageLocation.myLatitude = 0;
m_LastMessageLocation.myLongitude = 0;
m_LastMessageSpeed = 0;
m_LastMessageDirection = 0;

//extract the time
const char *p = buffer;
p = strchr(p, ',') + 1;
uint8_t hour = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;
uint8_t minutes = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;
uint8_t seconds = (p[0] - '0') * 10 + (p[1] - '0');
// find out if we got a fix
p = strchr(p, ',') + 1;
if (p[0] != 'A')
{
m_LastMessageIsfix = false;
//DateTime dt(0, 0, 0, hour, minutes, seconds);
}
else
{
m_LastMessageIsfix = true;
//extract the latitude
p = strchr(p, ',') + 1;
m_LastMessageLocation.myLatitude = (p[0] - '0') * 10 + (p[1] - '0');
p += 2;

while (p[0] != ',')
{
if (p[0] != '.') m_LastMessageLocation.myLatitude = m_LastMessageLocation.myLatitude * 10 + (p[0] - '0');
p++;
}
p++;
if (p[0] == 'S') m_LastMessageLocation.myLatitude *= -1;
//extract the longitude
p += 2;
m_LastMessageLocation.myLongitude = (p[0] - '0') * 100 + (p[1] - '0') * 10 + (p[2] - '0');
p += 3;
while (p[0] != ',')
{
if (p[0] != '.') m_LastMessageLocation.myLongitude = m_LastMessageLocation.myLongitude * 10 + (p[0] - '0');
p++;
}
p += 2;
if (p[0] == 'W') m_LastMessageLocation.myLongitude *= -1;
p += 1;
//extract speed
int Power = 1000;
int Count = 1;
while (p[0] != ',')
{
if (p[0] != '.')
{
m_LastMessageSpeed = m_LastMessageSpeed * 10 + (p[0] - '0');
Power /= (Count);
} else
{
Count = 10;
}
p++;
}
//The speed is in knots (1.852 km per hour = 1852 m per hour) so calculate to m/hour
m_LastMessageSpeed = m_LastMessageSpeed * 1852 * Power;
p += 1;
Power = 1000;
Count = 1;
while (p[0] != ',')
{
if (p[0] != '.')
{
m_LastMessageDirection = m_LastMessageDirection * 10 + (p[0] - '0');
Power /= Count;
} else
{
Count = 10;
}
p++;
}
m_LastMessageDirection = m_LastMessageDirection * Power;
p += 1;
uint8_t m_day = (p[0] - '0') * 10 + (p[1] - '0');
uint8_t m_month = (p[2] - '0') * 10 + (p[3] - '0');
uint8_t m_year = (p[4] - '0') * 10 + (p[5] - '0');
DateTime dt(m_year, m_month, m_day, hour, minutes, seconds);
m_LastMessageTimeStamp = dt;
}
}
Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5286
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This is the cpp code of the basic gps class

I asked for the test code that copies the complete message from Serial3 to Serial. I seriously hope you didn't use that GPS class to test if your module is working correctly. I expected a sketch that is copying everything received on Serial3 verbosely to Serial.

Did you check if at least the position it constantly transfers does match your location (or the location you had at device startup)?
Logged

Pages: [1]   Go Up
Jump to: