Hello everyone,
Excuse the crudity of this question but I'm having quite the trouble trying to run the two Adafruit Ultimate GPS v3 modules at 10Hz on the Teensy 3.2 board. The modules are connected over the hardware serial ports 1 and 3. There is also an IMU (MPU6050) connected over the I2C interface
Issues:
-By default, the GPS modules only run at 1Hz and at 9600 baud. I'm sending the required PMTK commands over their respective serial ports 1 and 3 to increase those to 10Hz and 115200 baud. I'm using Hardware Serial because the SoftwareSerial library was messing up the interrupts for the I2C interface and was unreliable at the baud rate required for 10Hz.
-When using the TinyGPS++ library, it seems that the received chars for the GPS 1 and 2 modules were the same, which led me to believe that it was behaving incorrectly, and I was getting no fixes. Since I also need to run a Kalman filter for each GPS module at 10Hz (which might not work at that speed on the Teensy), I switched to the NeoGPS library, which I'm told, requires much less system resources and is much faster.
-The NeoGPS library also does not return any successful fix messages due to possibly being misconfigured (I'm using the default configuration files)
Below is the code I'm using with the TinyGPS++ library (sans the IMU parts)
I begin and end each GPS serial port depending on which of them I want to read data from. This is probably causing some sort of data loss, or the gps object is retaining the data from previous reads, but I have no intuition on how to solve this.
With this, I'm only getting stars (*), and the same number of received characters for both GPS 1 and 2, hence my assumption that it is faulty;
#include <TinyGPS++.h>
static const uint32_t GPSBaud = 115200;
// The TinyGPS++ object
TinyGPSPlus gps;
void setup()
{
// The serial connection to the GPS device
#define GPS_1_Serial Serial1
#define GPS_2_Serial Serial3
GPS_1_Serial.begin(9600);
GPS_1_Serial.write("$PMTK220,100*2F\r\n");
//switch the GPS baud rate to 115200
GPS_1_Serial.write("$PMTK251,115200*27\r\n");
//change baud rate of serial port to 38400
GPS_1_Serial.flush();
delay(10);
GPS_1_Serial.end();
GPS_2_Serial.begin(9600);
GPS_2_Serial.write("$PMTK220,100*2F\r\n");
//switch the GPS baud rate to 115200
GPS_2_Serial.write("$PMTK251,115200*27\r\n");
//change baud rate of serial port to 38400
GPS_2_Serial.flush();
delay(10);
GPS_2_Serial.end();
Serial.begin(115200);
while (!Serial);
Serial.println(TinyGPSPlus::libraryVersion());
Serial.println();
Serial.println(F(" Fix Date Time Date Course Speed Card Chars Sentences Checksum"));
Serial.println(F(" Age Age --- from GPS ---- RX RX Fail"));
Serial.println(F("----------------------------------------------------------------------------------------------------------------------------------------"));
}
void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
//GPS________________________________________________________GPS_1___________________________________________________________________
GPS_1_Serial.begin(GPSBaud);
Serial.println("Listening to GPS_1");
printDateTime(gps.date, gps.time);
printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ", 6);
printInt(gps.charsProcessed(), true, 6);
printInt(gps.sentencesWithFix(), true, 10);
printInt(gps.failedChecksum(), true, 9);
Serial.println();
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
smartDelay(100);
GPS_1_Serial.end();
// ---------------------------------GPS_2----------------------------
GPS_2_Serial.begin(GPSBaud);
Serial.println("Listening to GPS_2");
printDateTime1(gps.date, gps.time);
printFloat1(gps.course.deg(), gps.course.isValid(), 7, 2);
printFloat1(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
printStr1(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ", 6);
printInt1(gps.charsProcessed(), true, 6);
printInt1(gps.sentencesWithFix(), true, 10);
printInt1(gps.failedChecksum(), true, 9);
Serial.println();
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
smartDelay1(100);
GPS_2_Serial.end();
}
}
The printing and delay function declarations of the TinyGPS++ library were excluded for conciseness.
The NeoGPS library version I've attempted can also be found below, outputs blank lines with an if statement, when checking for valid time and location;
The complete sketch files using said libraries can be found below
Thank you for reading
Yours faithfully,
Cem Huray