HobbyKing.com New Products Flash Sale
Reply
Thread Tools
This thread is privately moderated by RHTizzy, who may elect to delete unwanted replies.
Old Aug 28, 2012, 01:32 PM
Registered User
RHTizzy's Avatar
The Netherlands, NH, Bussum
Joined Feb 2012
207 Posts
Build Log
MT3339 self initialise on boot - finally

Quote:
Originally Posted by RHTizzy View Post
Okay did some digging and can report the following: it's definitely not just the ublox that suffers from the reset issue. In fact as far as Ive gathered most gps modules don't hold on to their settings indefinitely unless flashed and most are sold without any user flash cycles left. More on point, the LS20031 is an mtk3339 and eosbandi's gps sketch includes a comment that it's only good for the mtk3329. There are people who have claimed to have the 3339 working in binary mode but they are not specific about what it is they've got working. What I (and I'm sure others like me) are looking for is the ability to initialise the mtk339 on fc boot so it isn't reliant on user settings or the battery to hold on to the appropriate baudrate and nmea sentence settings. As it is, it works in nmea mode and will report it's position to the fc but it's far from optimal as far as cpu load goes and has an appaling accuracy regardless of the number of sats fixed...
After some extensive research, the following works for the Locosys LS200031 with MT3339 chip and will initalise the GPS module on boot regardless of default settings or default speed. It will reconfigure the GPS unit to 115200bps, 10Hz, with GGA+RMC NMEA sentences (minimum needed but I also added GSA so miniGPS can utilise the data).

No need to replace the GPS.ino, just add the following code in the GPS sketch in the section that starts with
Code:
// This code is used for parsing NMEA data
#if defined(GPS_SERIAL)
As such:
Code:
// This code is used for parsing NMEA data
#if defined(GPS_SERIAL)
//Tizzy mod
#if defined(MT3339)
  #define MT_SET_SPEED  "$PMTK251,115200*1F\r\n"
  #define MT_SET_STRING "$PMTK314,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"
  #define MT_SET_10HZ   "$PMTK300,100,0,0,0,0*2C\r\n"
  void SerialWriteBuffer(uint8_t port, uint8_t *buffer, uint8_t size)
  {
    uint8_t i;
    uint8_t *ptr;  
    ptr = buffer;
    for (i=0;i<size;i++) {
      SerialWrite(port,*ptr);
      ptr++;
    }  
  }
  void MT3339_init(void)
  {
    const unsigned long baudrates[5] = {9600U, 19200U, 38400U, 57600U, 115200U};
    for (uint8_t i=0; i<5; i++) {            // Carlonb from idea of EOSBANDI (autosearch of default baud rate)
      SerialOpen(GPS_SERIAL,baudrates[i]);
      delay(200);
      SerialWriteBuffer(GPS_SERIAL, (uint8_t *)MT_SET_SPEED, sizeof(MT_SET_SPEED)-1);
      delay(200);
      SerialEnd(GPS_SERIAL);
      delay(200);
    }      
    SerialOpen(GPS_SERIAL,GPS_BAUD); //default config.h setting is 115200
    SerialWriteBuffer(GPS_SERIAL, (uint8_t *)MT_SET_STRING, sizeof(MT_SET_STRING)-1);
    delay(1000);
    SerialWriteBuffer(GPS_SERIAL, (uint8_t *)MT_SET_10HZ, sizeof(MT_SET_10HZ)-1);
    delay(300);
  }
#endif
// End Tizzy mod
Then insert the following in the Multiwii_2_1 sketch (first and last line already exist)
Code:
  #if defined(GPS_SERIAL)
     #if defined(MT3339)
           MT3339_init();
           delay(200);
     #endif
 SerialOpen(GPS_SERIAL,GPS_BAUD);
And last of all add the following code to config.h (anywhere in the GPS settings will do)
Code:
#define MT3339     // LS20031 utilizes the MTK 3339 chip
RHTizzy is offline Find More Posts by RHTizzy
Last edited by RHTizzy; Jan 08, 2013 at 11:56 AM.
Reply With Quote
Sign up now
to remove ads between posts
Reply

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Whoops! Classic: Taliban commander turns self in... for reward on ‘Wanted’ poster P-51C Life, The Universe, and Politics 6 Apr 17, 2012 08:43 PM
Question Replace plastic hex bolt and self tapping screws on 600N fan casing ? Azile Fuel Heli Talk 0 Feb 25, 2012 03:25 PM
Discussion Self serving request-"like" nitroplanes on Facebook for 15% off gjalil21 Electric Plane Talk 8 Feb 24, 2012 01:43 PM
Discussion Self serving request-"like" nitroplanes on Facebook for 15% off gjalil21 Nitro Planes 0 Feb 23, 2012 09:11 PM