0

Ultimate GPS breakout sends stange stuff after some time
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Ultimate GPS breakout sends stange stuff after some time

by kutt on Thu Jan 10, 2019 12:14 pm

Hello,

I don't know how I can describe it in a better way, but lets start what I did:

I need the output of the Ultimate GPS at 4800 baud, because I have an other device, which only supports this rate. I am aware of the issues this may cause, because the time between 2 complete GPS sets is not enough at 4800baud even at 1Hz rate.

So I cut out everything I don't need.

This is a cut-out of my current code:
Code: Select all | TOGGLE FULL SIZE
in setup:
  GPS.begin(9600);
  GPS.sendCommand("PMTK314,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*29\n");
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand("$PMTK251,4800*14\n");
  delay(500);
  mySerial.end();
  delay(500);
  GPS.begin(4800);
  delay(500);

  GPS.sendCommand(PGCMD_ANTENNA);
  useInterrupt(true);


As you see I connect via 9600baud after start-up, then I define what kind of data I want, set the module to 4800baud and reconnect with this rate.
This works very good. The Arduino opens a 2nd serial port at 4800baud and does the following:

first I hook into timer0
Code: Select all | TOGGLE FULL SIZE
void useInterrupt(boolean v) {
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}


and every millisecond:

Code: Select all | TOGGLE FULL SIZE
SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
  //if (c) Serial.print(c);
  if (c) UDR0 = c;
}


So basically if data is available from the GPS device it gets directly piped to the other serial port.
The Arduino displays then the data on a LCD every 2 seconds.

At the other serial Port is a TTL to USB brige and a Raspberry reads it.

As said: all this works really good, but after 12 to 48h it suddently stops. After a lot of debugging I figured that the Ultimate GPS seems to send at a different bautrate again. I still have to debug this furter by hooking into the TX line of the Ultimate GPS wit an other Arduino. I think it starts sending again at 9600baud for some weird reason?

So the output in the Raspberry looks like this:

Code: Select all | TOGGLE FULL SIZE
 cat /dev/ttyUSB0
▒▒▒▒b$ !▒▒▒ń▒ƅŅ▒Ĥ▒▒▒Ƅ▒ĤņƤ▒▒▒▒b$ !▒▒▒*▒▒▒b$ "▒▒▒▒▒▒▒y▒▒̈́▒兦▒▒Ŧ▒Ƅ▒Z▒▒D▒▒▒▒▒F▒▒▒▒*▒f▒@▒PuTTY% ▒▒▒▒Ą▒▒▒▒Æ▒兦▒▒▒䦧▒▒F▒▒▒▒▒c$ ▒▒Ƥ▒▒ĆĤ▒Ĥ▒▒Ŧ▒▒䦆▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒Ĥ妆J▒▒▒▒b$ !▒▒▒▒▒F▒▒*▒▒f▒E▒$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒䦧▒▒F▒▒▒▒▒b$ ▒▒Ƥ▒▒ćĤ▒Ĥ▒▒Ʀ▒▒䦆▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒Ą䆆▒▒▒▒▒b$ #▒▒▒▒▒F▒▒▒▒▒f▒E▒$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒䦧▒▒F▒▒▒▒▒▒b$ ▒▒Ƥ▒▒ĆĤ▒Ĥ▒▒Ǧ▒▒䦇▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒䅦▒▒▒▒▒Ɔ▒▒▒▒▒b$ !▒▒▒▒▒F▒▒▒▒▒f▒D▒PuTTY$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒䦦▒▒F▒▒*▒▒▒b$ ▒▒Ƥ▒▒ą▒J▒Ĥ▒▒Ʀ▒▒䦇▒▒c$▒"▒▒▒▒▒▒▒▒▒▒Ä▒▒z▒▒▒Ɔ焇▒▒▒▒▒b$  ▒▒▒▒▒F▒▒▒▒▒f▒A▒% ▒▒▒▒▒Ą▒▒▒▒Ä▒慦▒▒▒▒䦦▒▒F▒▒▒▒▒b$▒▒▒Ƥ▒▒ĆĤ▒Ĥ▒▒Ǧ▒▒䦆▒▒b$ !▒▒PuTTY▒Ņ▒▒▒Ņ▒▒Ħ▒▒Ĥ▒▒▒ƥ▒▒ņĦ▒▒b$  i▒▒▒ĦŦŤ▒ƅ▒▒▒ŤIǥť▒▒Ħ▒▒▒b$ !▒Y▒Ą▒ƅŅ▒Ĥ▒▒▒Ƅ▒+▒ņƤ▒▒▒▒bPuTTY% !▒▒▒▒▒▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒Ąꄇ▒▒▒▒▒b% !▒ć▒▒y▒▒▒▒▒f▒D▒$ ▒▒▒▒�▒y▒▒Ä▒兦▒▒▒䦡ۧF▒▒▒▒▒%b$ ▒▒Ʀ▒▒ĆĤ▒Ĥ▒▒Ʀ▒▒䦅▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒▒^C


There is no baudrate, where you see a correct output. Also the informations shown at the LCD are not updated anymore, so the issue must be somewhere between the Ultimate GPS and the Arduino.

My question: Could it be, that incase the data to send does not fit in the 1 second frame the module switches back to 9600baud? Or maybe it does a reset, which gives the same result? If yes: Is it possible to lower the refreshrate to 0,5Hz? Since it's a Atmega 328P (0nly one native serial port) I have to use the SoftwareSerial for the GPS readout. May this be the issue?

It's really stange, because it takes a rather long time before this happens. It's also to really reproduceable - however I kinda have the feeling, that it happens more often if a lot of satellites are in sight.

kutt
 
Posts: 14
Joined: Tue Nov 29, 2016 3:34 am

Re: Ultimate GPS breakout sends stange stuff after some time

by jps2000 on Fri Jan 11, 2019 2:00 am

You may test it if staying at 9600 this effect still happens.
Maybe the gps resets somehow or register run over. Then gps starts at default 9600 again.
Alternatively you can reset the gps every 10 hours or so or you make a kinda watchdog behavior looking for weird serial traffic

jps2000
 
Posts: 334
Joined: Fri Jun 02, 2017 4:12 pm

Re: Ultimate GPS breakout sends stange stuff after some time

by kutt on Fri Jan 11, 2019 5:14 am

jps2000 wrote:You may test it if staying at 9600 this effect still happens.
Maybe the gps resets somehow or register run over. Then gps starts at default 9600 again.
Alternatively you can reset the gps every 10 hours or so or you make a kinda watchdog behavior looking for weird serial traffic


Yea, I had the same idea. To use the Raspberry as watchdog. The GPS sends always data - even there is no fix. So if no NMEA strings come in for like 30s - pull a pin of the GPIO to reset the Arduino.

However - this is some kind of dirty workaround, since I don't really know why this happens in the first place.

Maybe I hook a USB to TTL cable to the TX line of the GPS to see what it sends to the Arduino and at which baudrate. The Arduino has also a BME280 attached, which sends temperature, pressure and humidity. So every 5 minutes I get readable output see:

!▒▒▒ť▒Ąƥ▒ń▒▒PuTTY▒▒ĆŅť▒Ą▒▒▒▒%b$ "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒Ť䄆▒▒▒▒▒b$ ▒▒▒▒▒G▒▒▒▒▒f▒A▒% ▒▒▒▒Ą▒▒▒▒Ä▒儦I▒▒▒Ʀ▒▒F▒▒▒�▒▒▒▒b% ▒▒Ť▒Ť▒ƥ▒▒ĆťƆ▒▒▒Ƈ▒▒b% "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒▒▒䥆▒▒▒▒▒b$ #▒▒▒▒▒F▒▒▒▒▒f▒▒E▒PuTTY$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒▒J▒▒▒F▒▒▒�▒▒▒▒%b$ ▒▒▒Ť▒Ť▒ƥ▒▒Ćť▒▒▒▒▒Ɔ▒▒b$ "▒▒▒▒▒▒▒▒▒▒Ä▒兦▒▒Ņ䄆▒▒▒▒▒b$ ▒▒Y▒▒F▒▒▒▒▒f▒A▒% ▒▒▒▒Ą▒▒▒*Ä▒兦▒▒▒▒Ʀ▒▒F▒+▒Ä▒▒▒▒%b$ ▒▒Ť▒Ť▒ƥ▒▒ĆťƆ▒▒▒Ɔ▒▒$b$ "▒▒▒▒▒▒k▒▒▒Ä▒兦▒▒ą*ņ▒▒▒▒▒b$ ▒▒▒▒▒A▒▒+▒*▒f▒D▒BME280: T:~29.01~H:~ 24.9~P:~ 976.61~
% ▒▒J▒ą▒▒▒▒Ä▒兦▒▒*䄦▒▒G▒▒▒�▒▒▒▒b$ ▒▒Ť▒Ť▒ƥ▒Ť▒▒Ɔ▒▒䄆▒▒b$▒"▒▒▒▒▒▒▒▒▒▒Ä▒▒z▒▒▒ĥ奆▒▒▒▒▒b$▒ ▒▒▒▒▒F▒▒▒▒▒f▒A▒$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒愦▒▒F▒▒▒Ä▒▒▒▒b$ ▒▒Ť▒Ť▒ƥ▒Ť▒▒Ɔ▒▒䄆▒▒b$ !▒▒▒▒ĦƅĤ▒ť▒ŧĤ▒ĥ▒ņŅ▒▒▒▒% $ !▒▒▒Ť▒ƅ▒ņ▒Ň[▒Ą▒Ƥ▒Ŧń▒▒▒▒b▒ !▒▒▒ť▒ĄƤ▒ń▒▒IPuTTY▒ĆŅŅ▒Ą▒b$ !▒▒▒▒▒F▒▒▒▒▒f▒E▒$ ▒▒▒▒ć▒▒▒▒Ä▒冦▒▒▒*▒▒▒▒F▒▒▒�▒▒▒▒b$ ▒▒Ť▒Ť▒ƥ▒Ť▒▒PuTTYƅ▒▒䄆▒▒b$ #▒▒▒▒▒▒▒▒▒▒Ä▒儦▒▒Ņ▒ņ▒▒▒▒▒b% ▒▒▒▒▒G▒▒▒▒▒f▒D▒$ ▒▒▒▒Ą▒▒▒▒Ä▒兦▒▒▒䄦▒▒F▒▒▒Ä▒▒▒▒


So the Ardunio still transmits @ 4800baud

Well I remember a post a few years back, where someone wrote if the GPS gets a buffer overflow it's internal watchdog does a reset. But I am not sure about this. The questions would be:

How can I prevent such a thing
Is it possible to default the GPS device to 4800baud by a firmware patch?

EDIT: I found this: https://learn.adafruit.com/adafruit-ultimate-gps/f-a-q but I can't find some kind of patchnotes/versionhistory - Does anyone know if this issue ist fixed there?

Also in the Datasheet:
Code: Select all | TOGGLE FULL SIZE
Normally, if the GPS loses power, it will revert to the factory default for baud rates, configuration, etc. A backup battery will mean that those defaults will not be lost!

Well - this is not true...

kutt
 
Posts: 14
Joined: Tue Nov 29, 2016 3:34 am

Re: Ultimate GPS breakout sends stange stuff after some time

by kutt on Mon Jan 14, 2019 5:29 am

Me again,

so I did a dirty workaround until someone may provide more informations about this issue.

I simply check if PGTOP comes in and if there are none for 5s, the Arduino closes the serial port to the GPS, reopens it at 9600 baud, set the GPS back to 4800 baud an reopens the connection with 4800 baud.

It's a solution I really don't like, because it does not fix the initial problem :/

kutt
 
Posts: 14
Joined: Tue Nov 29, 2016 3:34 am

Re: Ultimate GPS breakout sends stange stuff after some time

by adafruit_support_carter on Tue Jan 15, 2019 4:23 pm

Something is causing it to reset and change back to factory default 9600. I don't think you can change that default. So either need to prevent the reset or do something like you've done.

adafruit_support_carter
 
Posts: 9792
Joined: Tue Nov 29, 2016 2:45 pm

Re: Ultimate GPS breakout sends stange stuff after some time

by kutt on Fri Jan 25, 2019 5:52 am

Hello,

me again.

Last week I was in a traffic jam, so I had time to add a sequence, that checks when the last PGTOP sequence was sent. Like a Poor-mans watchdog.

If no PGTOP is sent the 328P reconnects @ 9600 baud, sets the GPS back to 4800 baud and reconnects at 4800 baud. It should also send a info to the PI that the "watchdog" triggered.

Well either I still have a bug in the PI, not recognizing the string, but it runs now for 10 days, 12h without a freeze of the GPS signal. I think I have to store the stream into a file to check if the GPS reset sequence is triggered at some point. (or replace the 328P with one only sending the reset for debug)

basicly the code is:
Code: Select all | TOGGLE FULL SIZE
    Serial.println("Reset_GPS");
    useInterrupt(false);

    mySerial.end();
    delay(500);

    GPS.begin(9600);
 
    GPS.sendCommand("PMTK314,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*29\n");
    GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
    GPS.sendCommand("$PMTK251,4800*14\n");
 
    delay(500);
    mySerial.end();
    delay(500);
    GPS.begin(4800);
    delay(500);
 
    GPS.sendCommand(PGCMD_ANTENNA);
    useInterrupt(true);
Attachments
vlcsnap-2019-01-25-10h34m13s715.jpg
vlcsnap-2019-01-25-10h34m13s715.jpg (382.24 KiB) Viewed 89 times

kutt
 
Posts: 14
Joined: Tue Nov 29, 2016 3:34 am

Re: Ultimate GPS breakout sends stange stuff after some time

by kutt on Mon Feb 18, 2019 2:07 pm

OK - this will be the final Update about this topic.

The System is now up for almost 35 days now - no GPS hickups anymore.

It's a dirty fix, but as long as it works I'm happy with it.

Code: Select all | TOGGLE FULL SIZE
System Uptime:  (34 d) 21:19:35

Memory Usage:
    435 MB of 927 MB (46.93 %)
Average CPU Load:
    Overall: 13.79 %

Position:
    50°5x'45.552"N 13°2x'21.822"E
    at: 2019-02-18 18:00:53 UTC

Fix: VALID, Sat's: 06, Fix: GPS fix (SPS)
    Elevation: 370.9m
    Speed:      0.1kn
    Direction: 13.02°

kutt
 
Posts: 14
Joined: Tue Nov 29, 2016 3:34 am

Please be positive and constructive with your questions and comments.