Friday, November 10, 2017

Paradise ponders: gpsctl functionally complete edition..

Paradise ponders: gpsctl functionally complete edition...  gpsctl is the name of the C program I've been working on for a few weeks now.  Early this morning I added the last planned features in – it does everything I needed it to do.  I've made it publicly available, on the off chance that it will help some other nutcase who wants a stratum 1 NTP server on the cheap.

It came together very quickly in the last few days, mostly because that's when I finally got all the basic stuff up and running solidly.  Here's one example of a feature recently implemented: querying the GPS for the data it holds on visible satellites:

GNSS     ID CNo  El Azi   PRr Signal qual         Sat Hlt Orbit Src      Flags
GLONASS   2  52  43  35   0.6 Code/carrier locked Ok      Ephemeris      uea
GPS      29  51  36 158   1.2 Code/carrier locked Ok      Ephemeris      uea
GPS      15  50  52 101   0.9 Code/carrier locked Ok      Ephemeris      uea
GPS      20  50  55  52  -0.4 Code/carrier locked Ok      Ephemeris      uea
GLONASS  18  50  74 355   0.6 Code/carrier locked Ok      Ephemeris      uea
GPS      21  49  72 333  -0.9 Code/carrier locked Ok      Ephemeris      uea
GLONASS  17  49  46 125  -1.5 Code/carrier locked Ok      Ephemeris      uea
GPS      18  48  58 248   0.5 Code/carrier locked Ok      Ephemeris      uea
GPS      13  47  33  62   0.0 Code/carrier locked Ok      Ephemeris      uea
GLONASS   3  47  79 207  -2.7 Code/carrier locked Ok      Ephemeris      uea
GPS      10  45  24 240   0.4 Code/carrier locked Ok      Ephemeris      uea
Galileo   8  45  66 174   1.3 Code/carrier locked Ok      Ephemeris      uea
GLONASS  19  45  22 322  -1.3 Code/carrier locked Ok      Ephemeris      uea
Galileo   3  44  48  57   0.6 Code/carrier locked Ok      Ephemeris      uea
GPS      16  42  20 299  -1.4 Code/carrier locked Ok      Ephemeris      uea
GLONASS   4  41  22 213  -7.0 Code/carrier locked Ok      Ephemeris      uea
GPS       5  47   7  56  -1.1 Code/carrier locked Ok      Ephemeris      a
GPS      27  46  13 320  -0.4 Code/carrier locked Ok      Ephemeris      a
GPS       4  44 -91   0   0.0 Code/carrier locked Bad     None          
GPS      26  41  20 267   2.3 Code/carrier locked Ok      Ephemeris      a
Galileo   7  39  18 208   1.6 Code/carrier locked Ok      Ephemeris      a
GLONASS  10  38   3 348   4.6 Code/carrier locked Ok      Ephemeris      a
Galileo  22  37   8 124   4.6 Code/carrier locked Ok      Ephemeris      a
Galileo  26  33  14 308   7.9 Code/carrier locked Ok      Ephemeris      a
Galileo   5  13   1  39  -1.4 Unusable            Ok      Ephemeris      a
Galileo   1   0   2 307   0.0 Searching           Ok      Ephemeris      a
Flags:
  u - used for navigation fix
  d - differential correction is available
  s - carrier-smoothed pseudorange used
  e - ephemeris is available
  a - almanac is available
  S - SBAS corrections used
  R - RTCM corrections used
  P - pseudorange corrections used
  C - carrier range corrections used
  D - range rate (Doppler) corrections used


That is a lot of information, and quite useful when troubleshooting.  The results of some of the configuration code I wrote are visible here, if you know what to look for.  For example, I've configured the GPS to ignore any satellite whose elevation is within 20° of the horizon.  This prevents the use of satellites whose signal path goes through a lot of atmosphere.  Similarly, I've configured the GPS to ignore any satellite whose signal strength (as CNo) is under 30.

Another feature recently implemented is querying for configuration information.  This is vital, both for figuring out what the default configuration was, and for verifying that the configuration code I wrote actually worked.  Here's an example result:

U-Blox GPS configuration
  Antenna:
    Power enabled:            yes
    Short detection:          yes
    Open detection:           no
    Power down on short:      yes
    Auto recovery from short: yes
  GNSS:
    Tracking channels:  32
    Type: GPS
      Enabled:          yes
      Minimum channels: 8
      Maximum channels: 24
    Type: SBAS
      Enabled:          no
      Minimum channels: 0
      Maximum channels: 0
    Type: Galileo
      Enabled:          yes
      Minimum channels: 8
      Maximum channels: 8
    Type: BeiDou
      Enabled:          no
      Minimum channels: 0
      Maximum channels: 0
    Type: IMES
      Enabled:          no
      Minimum channels: 0
      Maximum channels: 0
    Type: QZSS
      Enabled:          no
      Minimum channels: 0
      Maximum channels: 0
    Type: GLONASS
      Enabled:          yes
      Minimum channels: 8
      Maximum channels: 24
  Navigation engine:
    Dynamic model:                Stationary
    Fix mode:                     3D only
    Fixed altitude (2D):          0.00 meters
    Fixed altitude variance (2D): 0.0001 meters^2
    Minimum elevation:            20 degrees
    Position DoP mask:            10.0
    Time DoP mask:                10.0
    Position accuracy mask:       40 meters
    Time accuracy mask:           40 meters
    Static hold threshold:        0 cm/s
    Dynamic GNSS timeout:         60 seconds
    Threshold above C/No:         8 satellites
    C/No threshold:               40 dBHz
    Static hold max distance:     0 meters
    UTC standard:                 USNO
  Time pulse:
    Time pulse 0 enabled:         yes
    Use frequency vs. period:     no
    Use length vs. duty cycle:    yes
    Lock on GPS frequency:        yes
    LockUseOtherSet:              yes
    Align to top of second:       yes
    Polarity rising edge:         yes
    Time grid:                    UTC
    Antenna cable delay:          56 nanoseconds
    RF group delay:               20 nanoseconds
    Locked pulse period:          1000000 microseconds
    Unlocked pulse period:        1000000 microseconds
    Locked pulse length:          500000 microseconds
    Unlocked pulse length:        0 microseconds
    User configurable delay:      0 nanoseconds
  Fix rate:
    Measurement rate:                 1000 milliseconds
    Measurements per fix:             1
    Time reference:                   GPS
  Power mode:
    Power setup:                      Balanced
    Period (if interval):             0 seconds
    On time (if interval):            0 seconds


Lots of information there, too!  At least, if you're a GPS geek. :)  It's a bit mind-boggling that all this capability is in the tiny little module you see in the photo at right.  By “module”, I don't mean the green circuit board with the LEDs on it.  I mean that tiny little square module just to the right of the antenna connector.  That teensy little thing – smaller than my thumbnail.  That thing can listen simultaneously to 32 satellites, solve large systems of differential equations, and communicate at high speed with my computers.  It's quite astounding, actually.

I have some personal experience that really drives this home.  When I was in the U.S. Navy, back in the '70s, I worked on a system called SINS (for Ship's Inertial Navigation System).  There's some specific information on SINS here, and on inertial navigation systems in general here.  In the '70s, long before GPS, these were the state of the art in navigation.  A SINS system occupied a fairly large compartment shipboard, used huge amounts of power, and it had a low reliability (in my own experience, less than 50% up time).  The information it provided degraded in accuracy the longer you went since a calibration (against a known point on the earth).  At its best, at least when I was observing, it would put you within a mile or so of your actual location.  As bad as that sounds, that was far better than the alternatives available at the time.  That GPS in the photo above is smaller by far than the smallest piece of electronics in SINS – and far more accurate and reliable.  Not to mention cheaper!  A SINS system had to cost several million dollars in today's money; that GPS cost me under $100.  Amazing!