gpsPosition (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All devices.

Firmware version:

1.00 / 1.00.00


Use this function block to read the current position from an external GPS smart-antenna connected to the serial port on the RTCU device.

On devices with an in-build GPS receiver the gpsFix() function should used.

 

When using this function to get the current position from an external GPS receiver, the external GPS receiver must send the RMC status with regular intervals (typically every second). The baud rate must be 4800 bps and the external GPS receiver must be connected to the RTCU through RS232 port #0.

 

When using the GPS SmartAntenna with the RTCU DX4i pro it is important to first power on the SmartAntenna by using boardDCOut function.

 

Input:

None.

 

Output:

valid : BOOL;

TRUE if GPS has valid position, otherwise FALSE.

 

year : SINT

Years since 2000.

 

month : SINT

Month (1..12).

 

day : SINT

Date (1..31).

 

hour : SINT

Hour (0..23).

 

minute : SINT

Minute (0..59).

 

second : SINT

Second (0..59).

 

latdegrees : SINT

Negative is south (-90..+90).

 

latminutes : SINT

Minutes (0..59).

 

latdecimalminutes : INT

Decimal minutes (0..9999).

 

londegrees : INT

Negative is west (-180..+180).

 

lonminutes : SINT

Minutes (0..59).

 

londecimalminutes : INT

Decimal minutes (0..9999).

 

speed : DINT

Speed over ground in meters/hour.

 

course : DINT

Course over ground. In xxx.xx degrees (multiplied by 100).

 

Declaration:

FUNCTION_BLOCK gpsPosition;
VAR_OUTPUT
  valid             : BOOL;   | GPS has valid position.
  year             : SINT;   | years since 2000
  month             : SINT;   | month (1..12)
  day               : SINT;   | date (1..31)
  hour             : SINT;   | hour (0..23)
  minute           : SINT;   | minute (0..59)
  second           : SINT;   | second (0..59)
  latdegrees       : SINT;   | Negative is South (-90..+90)
  latminutes       : SINT;   | minutes (0..59)
  latdecimalminutes : INT;     | decimal minutes (0..9999)
  londegrees       : INT;     | Negative is West (-180..+180)
  lonminutes       : SINT;   | minutes (0..59)
  londecimalminutes : INT;     | decimal minutes (0..9999)
  speed             : DINT;   | Speed over ground in meters/hour
  course           : DINT;   | Course over ground. In xxx.xx degrees (multiplied by 100)
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
VAR
  gps : gpsPosition;
END_VAR;
 
 

 
// Turn on the GPS SmartAntenna power on the RTCU DX4i pro.
boardDCOut(enable:=on);
BEGIN
  // Call the GPS to get a new position fix
  gps();
  // Check for valid position from GPS
  IF gps.valid THEN
    DebugMsg(message:=strFormat(format:="valid=\1", v1:=INT(gps.valid)));
 
    DebugMsg(message:=strFormat(format:="latdegrees=\4", v4:=gps.latdegrees));
    DebugMsg(message:=strFormat(format:="latminutes=\4", v4:=gps.latminutes));
    DebugMsg(message:=strFormat(format:="latdecimalminutes=\4", v4:=gps.latdecimalminutes));
     
    DebugMsg(message:=strFormat(format:="londegrees=\4", v4:=gps.londegrees));
    DebugMsg(message:=strFormat(format:="lonminutes=\4", v4:=gps.lonminutes));
    DebugMsg(message:=strFormat(format:="londecimalminutes=\4", v4:=gps.londecimalminutes));
 
    DebugMsg(message:=strFormat(format:="cog=\4", v4:=gps.course));
    DebugMsg(message:=strFormat(format:="sog=\4", v4:=gps.speed));
 
    DebugMsg(message:=strFormat(format:="year=\4", v4:=gps.year));
    DebugMsg(message:=strFormat(format:="month=\4", v4:=gps.month));
    DebugMsg(message:=strFormat(format:="day=\4", v4:=gps.day));
    DebugMsg(message:=strFormat(format:="hour=\4", v4:=gps.hour));
    DebugMsg(message:=strFormat(format:="min=\4", v4:=gps.minute));
    DebugMsg(message:=strFormat(format:="sec=\4", v4:=gps.second));
  END_IF;
END;
 
END_PROGRAM;