Wednesday, April 25, 2018

Convert GPS Time of Week and GPS Week Number to Current Datetime (Year, Month, Day, Weekday)


Sistem kalender di GPS menggunakan jumlah minggu (week number) dan jumlah detik dalam seminggu (time second of week) , dihitung sejak waktu "Epoch". Waktu GPS Epoch adalah 6 Januari 1980 waktu 00:00:00. Selanjutnya GPS akan menghitung jumlah setiap minggunya dari waktu "Epoch". Satu minggu "GPS week" ditetapkan mulai hari Minggu. CATATAN: 6 Januari 1980 adalah hari minggu pertama di tahun 1980.

Sistem kalender di komputer UNIX memiliki waktu Epoch 1 Januari 1970 waktu 00:00:00, ISO mendefinisikan minggu pertama tahun ini sebagai "Satu waktu yang berisi hari keempat Januari, yang setara dengan mengatakan bahwa itu adalah minggu pertama yang tumpang tindih dengan tahun baru setidaknya empat hari ".

Arduino library Timelib.h dari PaulStoffregen menggunakan UNIX Epoch Time (01 Jan 1970) , sedangkan GPS Epoch Time adalah 06 January 1980. Untuk itu ditambahkan offset 315964800 detik. Tambahkan lagi offset 7 jam untuk Zona Waktu Lokal Jakarta yaitu WIB, UTC +7.

Data yang diterima dari IMU adalah GPS Week dan  GPS Time of Week in Second. Rubah GPS Week ke second, dengan mengalikan GPS Week x 7 x 24 x 60 x 60. Kemudian tambahkan "GPS Week" yang sudah dalam satuan detik dengan "GPS Time of Week in Second"



Sample Streams  http://www.gpsinformation.org/dale/nmea.htm

 Garmin etrex summit outputs


$GPRMC,002454,A,3553.5295,N,13938.6570,E,0.0,43.1,180700,7.1,W,A*3F
$GPRMB,A,,,,,,,,,,,,A,A*0B
$GPGGA,002454,3553.5295,N,13938.6570,E,1,05,2.2,18.3,M,39.0,M,,*7F
$GPGSA,A,3,01,04,07,16,20,,,,,,,,3.6,2.2,2.7*35
$GPGSV,3,1,09,01,38,103,37,02,23,215,00,04,38,297,37,05,00,328,00*70
$GPGSV,3,2,09,07,77,299,47,11,07,087,00,16,74,041,47,20,38,044,43*73
$GPGSV,3,3,09,24,12,282,00*4D
$GPGLL,3553.5295,N,13938.6570,E,002454,A,A*4F
$GPBOD,,T,,M,,*47
$PGRME,8.6,M,9.6,M,12.9,M*15
$PGRMZ,51,f*30
$HCHDG,101.1,,,7.1,W*3C
$GPRTE,1,1,c,*37
$GPRMC,002456,A,3553.5295,N,13938.6570,E,0.0,43.1,180700,7.1,W,A*3D
 

Some observations as compared to the G-12:

  • Information is buffered. It is all for the same second.
  • Information is only updated every two seconds at 4800 b/s.
  • Lat/Lon numbers have an extra digit.
  • This is NMEA 2.3 data as indicated by the extra A at the end of RMC, RMB and GLL.
  • Note that the satellites in use have been shoved to the left of the GSA message instead of the slot location.
  • The RMC sentence starts the sequence.
  • Note the HCHDG sentence for the built in compass.
  • Except for the compass output this sentence list is similar for most Garmin units designed around the time of the Summit receivers, beginning with the emap. 

NMEA sentences

NMEA consists of sentences, the first word of which, called a data type, defines the interpretation of the rest of the sentence. Each Data type would have its own unique interpretation and is defined in the NMEA standard. The GGA sentence (shown below) shows an example that provides essential fix data. Other sentences may repeat some of the same information but will also supply new data. Whatever device or program that reads the data can watch for the data sentence that it is interested in and simply ignore other sentences that is doesn't care about. In the NMEA standard there are no commands to indicate that the gps should do something different. Instead each receiver just sends all of the data and expects much of it to be ignored. Some receivers have commands inside the unit that can select a subset of all the sentences or, in some cases, even the individual sentences to send. There is no way to indicate anything back to the unit as to whether the sentence is being read correctly or to request a re-send of some data you didn't get. Instead the receiving unit just checks the checksum and ignores the data if the checksum is bad figuring the data will be sent again sometime later.
There are many sentences in the NMEA standard for all kinds of devices that may be used in a Marine environment. Some of the ones that have applicability to gps receivers are listed below: (all message start with GP.)
  • AAM - Waypoint Arrival Alarm
  • ALM - Almanac data
  • APA - Auto Pilot A sentence
  • APB - Auto Pilot B sentence
  • BOD - Bearing Origin to Destination
  • BWC - Bearing using Great Circle route
  • DTM - Datum being used.
  • GGA - Fix information
  • GLL - Lat/Lon data
  • GRS - GPS Range Residuals
  • GSA - Overall Satellite data
  • GST - GPS Pseudorange Noise Statistics
  • GSV - Detailed Satellite data
  • MSK - send control for a beacon receiver
  • MSS - Beacon receiver status information.
  • RMA - recommended Loran data
  • RMB - recommended navigation data for gps
  • RMC - recommended minimum data for gps
  • RTE - route message
  • TRF - Transit Fix Data
  • STN - Multiple Data ID
  • VBW - dual Ground / Water Spped
  • VTG - Vector track an Speed over the Ground
  • WCV - Waypoint closure velocity (Velocity Made Good)
  • WPL - Waypoint Location information
  • XTC - cross track error
  • XTE - measured cross track error
  • ZTG - Zulu (UTC) time and time to go (to destination)
  • ZDA - Date and Time
Some gps receivers with special capabilities output these special messages.
  • HCHDG - Compass output
  • PSLIB - Remote Control for a DGPS receiver

Decode of selected position sentences

The most important NMEA sentences include the GGA which provides the current Fix data, the RMC which provides the minimum gps sentences information, and the GSA which provides the Satellite status data.


GGA - essential fix data which provide 3D location and accuracy data.
 $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 *
If the height of geoid is missing then the altitude should be suspect. Some non-standard implementations report altitude with respect to the ellipsoid rather than geoid altitude. Some units do not report negative altitudes at all. This is the only sentence that reports altitude.



RMC - NMEA has its own version of essential gps pvt (position, velocity, time) data. It is called RMC, The Recommended Minimum, which will look similar to:
$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

Where:
     RMC          Recommended Minimum sentence C
     123519       Fix taken at 12:35:19 UTC
     A            Status A=active or V=Void.
     4807.038,N   Latitude 48 deg 07.038' N
     01131.000,E  Longitude 11 deg 31.000' E
     022.4        Speed over the ground in knots
     084.4        Track angle in degrees True
     230394       Date - 23rd of March 1994
     003.1,W      Magnetic Variation
     *6A          The checksum data, always begins with *




HCHDG - Compass output is used on Garmin etrex summit, vista , and 76S receivers to output the value of the internal flux-gate compass. Only the magnetic heading and magnetic variation is shown in the message.
  $HCHDG,101.1,,,7.1,W*3C

where:
     HCHDG    Magnetic heading, deviation, variation
     101.1    heading
     ,,       deviation (no data)
     7.1,W    variation
 

HDG Heading–Deviation & Variation

       1 2 3 4 5 6
       | | | | | |
$--HDG,x.x,x.x,a,x.x,a*hh
1) Magnetic Sensor heading in degrees
2) Magnetic Deviation, degrees
3) Magnetic Deviation direction, E = Easterly, W = Westerly
4) Magnetic Variation degrees
5) Magnetic Variation direction, E = Easterly, W = Westerly
6)checksum
 

HDT Heading–True

       12 3
       || |
$--HDT,x.x,T*hh
1) Heading Degrees, true
2) T = True
3) Checksum
 
 

HPRTransducer Measurements (proprietary data)

1234 567
|||||||
$PTNTHPR,x.x,a,x.x,a,x.x,a*hh
1)Heading
2)N for Number
3)Pitch in degrees
4)N for Number
5)Roll in degrees
6)N for Number
7)checksum

Checksum

The checksum is the 8-bit exclusive OR (no start or stop bits)of all charactersin the sentence, including “,” and “^” delimiters, between but not including “$” or “!” and the “*” delimiters. The hexadecimal value of the most significant and least significant 4 bits of the result isconverted to two
ASCII characters (0-9, A-F (upper case)) for transmission. The most significant character is transmitted first.
 
 http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3870.0
 http://diy.torrens.org/HowTo/solmetalog.html
 http://www.tronico.fi/OH6NT/docs/NMEA0183.pdf
http://www.kontest.ru/datasheet/honeywell/hmr3000d00232.pdf