Are you using a serial interrupt to feed NMEA data into the GPS object?
No I am not using a serial interupt, just the loop()
Because if not it's only your loop() call to
Read_GPS
which is causing the GPS object to read data from the serial port. At higher refresh rates it might be losing data, which will probably cause the apparent fix rate to drop because the parser will be getting confused.
So using these resources (LINK1 & LINK2) regarding GPS serial interrupt (they used different GPS's though). I have tried to implement the interrupt to feed NMEA data into GPS.
I have added a GPS.available()>0 which then calls GPS.Read()
, however this still does not work at higher refresh rates so I believe I do not understand how to implement the GPS interrupt properly without losing data.
void loop() //Main Loop
{
#if PRESENT_GPSSHIELD== 1 ---------NEW CODE - interrupt?
if (GPS.available() >0) {
//LOGcounter=0;
Read_GPS(); //This reads GPS Data
//Serial.println(GPScounter);
GPScounter =0;
}
#endif
if((millis()-timer)>=20) // Main loop runs at 50Hz therefore number input should be 20 - adjust accordingly for specific Hz Rate
{
counter++;
LOGcounter++;
GPScounter++;
Printcounter++;
timer_old = timer;
timer=millis();
if (timer>timer_old)
{
G_Dt = (timer-timer_old)/200.0; // Real time of loop run. We use this on the DCM algorithm (gyro integration time)
if (G_Dt > 1)
G_Dt = 0; // ignore integration times over 200 ms
}
else
G_Dt = 0;
#if PRESENT_IMU== 1
// *** DCM algorithm
// Data adquisition
Read_Gyro(); // This read gyro data
Read_Accel(); // Read I2C accelerometer
if (counter > 5) // Read compass data at 10Hz... (5 loop runs)
{
counter=0;
Read_Compass(); // Read I2C magnetometer
Compass_Heading(); // Calculate magnetic heading
}
// Calculations...
Matrix_update();
Normalize();
Drift_correction();
Euler_angles();
// ***
#endif
#if LOG_DATA== 1
if (LOGcounter >= (50/(SAMPLE_RATE)) ) // Log data at 1or5o10 Hz... depending on GPS refresh settings
{
//counter=0;
logdata();
LOGcounter = 0;
}
#endif
if (Printcounter >= (50/(SAMPLE_RATE)) ) // Print data at 1or5o10 Hz... depending on GPS refresh settings
{
PrintSerialData();
Printcounter=0;
}
}
//delay(50);
}