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
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);
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
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;
}
}
Code: Select all
SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
//if (c) Serial.print(c);
if (c) UDR0 = c;
}
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
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
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.