10 years, 11 months ago.

GPS not finding a lock.

I'm using a Skylab skm53 gps, and it never finds enough satellites to give a position. Here's what the output from the mbed looks like.

GPGGA,181500.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*42 GPGGA,181501.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*43 GPGGA,181502.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*40 GPGGA,181503.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*41 GPGGA,181504.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*46 GPGGA,181505.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*47 GPGGA,181506.804,8960.0000,N,00000.0000,E,0,0137.0,M,13.0,M*44

Evidently, it has enough of a signal to give me the correct UTC time, but the position is always 90 N, 0 E. I've tried this with another gps module and gotten the exact same results. I've also tried it in both North Alabama and North Georgia. Even leaving it in the middle of a field for an hour didn't help. Am I missing something? Does it really take that long to download the tables? Any ideas??

Here's my main.cpp

#include "mbed.h"
#include "GPS.h"

Serial pc(USBTX, USBRX);
GPS gps(p9, p10);

int main() {
    while(1) {
        if(gps.sample()) {
            pc.printf("%s\n", gps.msg);
            //pc.printf("I'm doing something!");
        } else {
            pc.printf("Oh Dear! No lock :(\n");
        }
    }
}

And here's gps.cpp

/* mbed EM-406 GPS Module Library
 * Copyright (c) 2008-2010, sford
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
#include "GPS.h"

GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) {
    _gps.baud(9600);    
    longitude = 0.0;
    latitude = 0.0;        
}

int GPS::sample() {
    float time;
    char ns, ew;
    int lock;

    while(1) {        
        getline();

        // Check if it is a GPGGA msg (matches both locked and non-locked msg)
        if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d", &time, &latitude, &ns, &longitude, &ew, &lock) >= 1) { 
            lock = 1;
            if(!lock) {
                longitude = 0.0;
                latitude = 0.0;        
                return 0;
            } else {
                if(ns == 'S') {    latitude  *= -1.0; }
                if(ew == 'W') {    longitude *= -1.0; }
                float degrees = trunc(latitude / 100.0f);
                float minutes = latitude - (degrees * 100.0f);
                latitude = degrees + minutes / 60.0f;    
                degrees = trunc(longitude / 100.0f * 0.01f);
                minutes = longitude - (degrees * 100.0f);
                longitude = degrees + minutes / 60.0f;
                return 1;
            }
        }
    }
}

float GPS::trunc(float v) {
    if(v < 0.0) {
        v*= -1.0;
        v = floor(v);
        v*=-1.0;
    } else {
        v = floor(v);
    }
    return v;
}

void GPS::getline() {
    while(_gps.getc() != '$');    // wait for the start of a line
    for(int i=0; i<256; i++) {
        msg[i] = _gps.getc();
        if(msg[i] == '\r') {
            msg[i] = 0;
            return;
        }
    }
    error("Overflowed message limit");
    return;
}

You probably have too much cable to your active antenna. I assume you have an active antenna or you have too little gain from the amplifier in your active antenna. Alternatively you could be supplying 3.3 V to a 5.0V amp. It should take no more than 30 mins to download a full set of almanacs from the sats, they repeat every 12.5 mins but you have to get to the one page with the almanac date before you can begin so allow for 2 cycles.

posted by Mark Mumford 20 Dec 2013

1 Answer

10 years, 11 months ago.

Have you tested the GPS with a regular PC and terminal software?

Note that GPS signals are very weak and processors like mbed generate quite a bit of RF noise that could wipe out the GPS signal. You may have to shield off all EM from the mbed by enclosing it in a metal box.

Note that the time signal is more robust against noise than position data. It takes only one satellite to decode time, but multiple satellites to get a position fix. Depending on the GPS device the timestamp signal you see may just be from the internal clock and not UTC from the satellites.

Decoding the GPGGA message shows that there is no lock and the message is invalid, there are 0 satellites being tracked.

Example (see here) :

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M*47

Where:

  • GGA Global Positioning System Fix Data
  • 123519 Fix taken at 12:35:19 UTC
  • 4807.038,N Latitude 48 deg 07.038' N
  • 01131.000,E Longitude 11 deg 31.000' E
  • 1 Fix quality: 0 = invalid 1 = GPS fix (SPS) 2 = DGPS fix 3 = PPS fix 4 = Real Time Kinematic 5 = Float RTK 6 = estimated (dead reckoning) (2.3 feature) 7 = Manual input mode 8 = Simulation mode
  • 08 Number of satellites being tracked
  • 0.9 Horizontal dilution of position
  • 545.4,M Altitude, Meters, above mean sea level
  • 46.9,M Height of geoid (mean sea level) above WGS84
  • ellipsoid
  • (empty field) time in seconds since last DGPS update
  • (empty field) DGPS station ID number
  • *47 the checksum data, always begins with *

Accepted Answer

I figured it out! Evidently the mbed (or my usb port) can't supply the current required to lock. I powered the gps off a separate 5v supply, and it locked within a minute or so. Thanks for your help!

posted by Jordan Ford 19 Dec 2013