gnssFix (Functionblock)

Top  Previous  Next

Architecture:

NX32 / NX32L

Device support:

MX2 turbo/encore/warp, CX1 warp(-c) mk2, NX-200, NX-400, NX-900, LX2, LX5

Firmware version:

4.00 / 1.40.00


The gnssFix function block is used to query the current position, time, and detailed satellite information from the internal GNSS module.

 

Make sure to call gpsPower or gpsPowerLP before calling gnssFix, to power on the GNSS module.

 

SBAS Support:

Please see gpsSetSBAS.

When the "mode" parameter that is returned from gnssFix is 4, it indicates that the fix is not only a 3D fix but has also been SBAS-corrected.

 

Note regarding HDOP, VDOP and PDOP:

The DOP values should be as low as possible. They describe the geometry of the satellites used. Generally a DOP value should not be higher than 6 as that will affect the accuracy negative.

Normally a DOP value will be between 2 and 3 when you have clear skies. In a city with houses screening the sky, the DOP value will be higher and accuracy will be affected.

One method to increase the accuracy of the used GNSS positions is not to use fixes with an HDOP value higher than, for example, 300.

 

All values returned by gnssFix() are in the WGS-84 datum.

 

 

Input:

None.

 

Output:

mode : SINT;

0 = No info available (GNSS module not powered on?).

1 = Fix unavailable.

2 = 2D position fix.

3 = 3D position fix.

4 = 3D position fix with SBAS-correction (this requires that SBAS has been enabled, see gpsSetSBAS).

5 = Dead Reckoning fix.

 

linsec : DINT

Linsec for the timestamp received from the GNSS receiver.

Also see clockLinsecToTime().

 

millisecond : INT

Millisecond (0..999).

 

latitude : DINT

Latitude expressed in a DINT.

Negative is south (ddmm.mmmm (multiplied by 10000)).

 

longitude : DINT

Longitude expressed in a DINT.

Negative is west (dddmm.mmmm (multiplied by 10000)).

 

speed : DINT

Speed over ground in meters/hour.

 

course : DINT

Course over ground. In xxx.xx degrees (multiplied by 100) (0=north, 90=east, 225=southwest).

 

height : INT

Height in meters over mean sea level.

 

PDOP : INT

Position dilution of precision (multiplied by 100).

 

HDOP : INT

Horizontal dilution of precision (multiplied by 100).

 

VDOP : INT

Vertical dilution of precision (multiplied by 100).

 

inview : SINT

Number of satellites in view. This is the number of satellites that are above the horizon.

If gpsPowerLP is used, this will be 0.

 

used : SINT

Number of satellites used for the solution.

 

 

Declaration:

FUNCTION_BLOCK gnssFix;
VAR_OUTPUT
  mode         : SINT;   | 0=No info available, 1=Fix not available, 2=2D position fix, 3=3D position fix, 4=3D pos. with SBAS
  linsec       : DINT;   | Linsec of time-stamp
  millisecond : INT;     | millisecond (0..999)
  latitude     : DINT;   | Negative is South (ddmm.mmmm (multiplied by 10000))
  longitude   : DINT;   | Negative is West (dddmm.mmmm (multiplied by 10000))
  speed       : DINT;   | Speed over ground in meters/hour
  course       : DINT;   | Course over ground. In xxx.xx degrees (multiplied by 100)
  height       : INT;     | Height in meters over Mean Sea Level.
  PDOP         : INT;     | Position dilution of precision (PDOP) (multipied by 100).
  HDOP         : INT;     | Horizontal dilution of precision (HDOP) (multipied by 100).
  VDOP         : INT;     | Vertical dilution of precision (VDOP) (multipied by 100).
  inview       : SINT;   | Number of satellites in view
  used         : SINT;   | Number of satellites used in solution
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
gnss : gnssFix;
  clock : clockLinsecToTime;
  index : SINT;
  str   : STRING;
END_VAR;
 
gpsPower(power := ON);
BEGIN
  gnss();
  IF gnss.mode > 1 THEN
    clock(Linsec := gnss.linsec);
    DebugFmt(message:="Mode=\1", v1:=gnss.mode);
    DebugFmt(message:="   Linsec=\4", v4:=gnss.linsec);
    DebugFmt(message:="   Time=\1:\2:\3", v1:=clock.hour, v2:=clock.minute, v3:=clock.second);
    DebugFmt(message:="   Date=\1:\2:\3", v1:=clock.year, v2:=clock.month, v3:=clock.day);
    DebugFmt(message:="   Lat: latitude=\4", v4:=gnss.latitude);
    DebugFmt(message:="   Lon: longitude=\4", v4:=gnss.longitude);
    DebugFmt(message:="   Speed=\4", v4:=gnss.speed);
    DebugFmt(message:="   Course=\4", v4:=gnss.course);
    DebugFmt(message:="   Height=\1", v1:=gnss.height);
    DebugFmt(message:="   PDOP=\1", v1:=gnss.PDOP);
    DebugFmt(message:="   HDOP=\1", v1:=gnss.HDOP);
    DebugFmt(message:="   VDOP=\1", v1:=gnss.VDOP);
    DebugFmt(message:="   In view=\1, Used=\2", v1:=gnss.inview, v2:=gnss.used);
 
  END_IF;
END;
END_PROGRAM;