cmbsys

GPS Decoder

The purpose of the GPS Decoder project is to read and decode GPS-generated NMEA data. The data is processed and make decisions are made concerning the activation of solidstate control relays.

The GPS Decoder project, (GDP) is a receive-only serial device. The GDP is designed to monitor the serial data output from a GPS receiver that supports the NMEA serial protocol. The GDP decodes the “RMB” NMEA sentence to extract alarm and waypoint ID information. The GDP uses the waypoint id, the alarm information to potentially assert control relays.

Waypoint ID

The GDP decodes the waypoint id portion of the "RMB" sentence. It extracts the first 2 characters from the waypoint ID. The first character of the waypoint ID is used to assert one of 3 control relays. The recognized characters include; 'C', 'D' and 'T'.

The GDP also extracts the second character of the waypoint ID. For proper recognition this character must be a digit between '0' and '7'. This allows up to eight unique triggers for each control relay.

Note that a waypoint id and trigger can only be asserted once per flight. This prevents accidental activation of a control relay. It also allows the same waypoints to occur more than once in a particular route.

The GDP supports multiple modes of operation for decoding the "RMB" sentence:

Alarm Mode - This mode of operation decodes the "RMB" sentence and evaluates the alarm condition; the alarm status triggers the control function.

  • Difference mode - This mode of operation detects that the waypoint destination field has changed since the previous sentence. The difference triggers the control function.
  • Both - In this mode of operation either the Alarm, or the Difference will trigger the control function. This is the default mode.
  • None - This mode does not allow triggering of the control function.

The mode selection can be altered using the command mode described in this document.

Hardware

The GDP employs a number of dedicated hardware features including:

  • MicroController - Fast 10 Mhz operation. Low power consumption, 5 mA @ 3 Volts full speed operation. 12 µA during idle operation, power consumption so low that no on/off switch is needed. Extra capacity for future enhancements
  • EEPROM - 256 bytes of nonvolatile memory for retaining configuration settings, etc.
  • Serial port - Dedicated hardware serial port for reliable communication
  • Solid-state relays - Fast, rugged, reliable solid-state relays. Can't drop out due to vibration or bumps. Can switch 0-60 volts DC, 0-3 Amps with 12 Amps surge. Fast turn on, 50 µsec
  • Status indicators - Two LED status indicators, indicating operating status.
  • Pin connector - Provide rugged control relay connections.
  • Batteries - Only two inexpensive AA batteries required for operation. Provides continuous full power operation for up 10 days. During sleep mode, for the batteries will last the shelf life of the battery

Detail

The hardware for the GDP is straight-forward. Serial data is transmitted from a GPS, is chopped and level translated by diode D1, and Resistors R3 and R10. The result is fed to IC2, which inverts the serial stream. The serial input is then input to the microcontroller. The microcontroller decodes the serial stream and interprets the results as either NMEA data, or command inputs. Depending on the results of the decoding, Relays RLY1-RLY3 may be activated. Two status LEDs are used to indicates various states.

Click on image for a larger view

Software

The GDP software is designed for robust operation with the following features:

  • Multi-tasking - Co-operative multi-tasking operation. All priority operations (control relays) have dedicated tasks.
  • Interrupt driven - Dedicated interrupt-driven serial ports with 64-byte ring buffer as well as timer interrupt to ensure fast, responsive operation.
  • One time triggers - Control relay trigger events are allowed to occur only once per flight for safe, robust operation.
  • Sleep mode - A background task monitors activity on the serial port. If no commands are received for 90 seconds the GDP shuts down to low power mode. Normal operation resumes when any character is received.
  • Sentence evaluation - Robust sentence evaluation does not activate a control relay unless a complete “RMB” sentence is received with a valid checksum. If a checksum error is encountered, the red status LED will blink.
  • Command processor - In addition to processing the NMEA sentence, the GDP command processor accepts additional commands over the serial port. These commands are used for setup/configuration as well as providing tools to aid during integration.

Construction and Checkout

The GDP is simple enough that it can be constructed on a piece of perfboard using standard construction techniques. Get the Firmware

When assembling the board, double-check the polarity of IC1, it is best to use a socket for this component.

After you have completed assembly, it's a good idea to double check for bad or missed solder joints, and reversed polarity of components. If all is well, it's time to “let the smoke out”.

After the batteries are installed the red and green status indicators blink 15 times to indicate that the unit is operational. The green LED alternates 1/8 second on, 1 second off to indicate that the unit is powered-up and is ready to receive serial input. If no serial input is received for 90, seconds the status LEDs blink 5 times and the GDP enters low power mode. Input on the serial port “wakes” the GDP.

Operation

Commands accepted by the command processor include:

To use the command processor, connect a serial output device such as a terminal, PC, PalmPilot, etc. to the GDP. When the '#' is received by the GDP, the red and green LEDs blink once to indicate that command processing has begun. After the final character of a command sequence is received, the red and green LEDs blink twice to indicate that command processing has ended.

Serial port configuration

The serial port input is receive only. Only two pins of connector CON1 are for serial data. The receive (2) and ground (1) pins need to be connected for normal operation. These pins should be connected to the GPS transmit anc ground respectively, The serial port settings are:

  • 4800 bps
  • 8 data bits
  • No parity
  • One stop bit

NMEA Sentence Evaluation

Input to the GDP is in the form of serial data in NMEA sentence format. Only the "RMB" sentence is evaluated. All characters of the sentence are processed, and a checksum is calculated. The command must be correctly formatted, and the checksum must match before any control functions occur.

At any point in the sentence, if the GDP detects that no control operations can be performed, it abandons processing of the sentence. Sentences that are not “RMB” sentences or sentences that do not contain waypoint IDs cause this condition.

If a complete sentence is received, but a checksum error occurs, the control relay is not asserted, and the red status LED is triggered. A full reset is necessary to clear this error indication.

If the GDP receives a valid sentence, it tests to determine if that trigger has occurred before. If so, the control relay is not asserted. To clear the lockout, reset the GDP or sending the "#r” command as described in the command processing section.

Status LEDs

A red and a green LED are used to indicates GDP status:

  • Reset - Red and green LEDs blink 15 times to indicate proper operation
  • Normal operation - Green LED alternates on for 1/8 second on, 1 second off
  • Error condition - Red LED alternates 1/2 second on, 1/2 second off
  • Going to sleep - If no serial input is received for 90 seconds the GDP enters low power mode. It blinks both status LEDs 5 times before going to sleep
  • Waking up - During sleep mode if a serial input is received, the GDP blinks both status LEDs 5 times to indicate waking up
  • Debug mode - If the command processor receives the command "#d, both status LEDs will begin to blink and the control relays toggle. This condition persists until another character is received on the serial port

Control Relays

The control relays are fast (50 µsec), solid-state (MOSFET), devices capable of switching 0-60 Volts DC. They have a current rating of 0-3 Amps with a 12 Amp surge rating. They are asserted when a waypoint alarm is asserted by the GPS as described in previous sections.

The control relays are asserted for a period defined by the "#sT00000 command described in the command processor section. The default value is 1/2 second. After the assertion period expires, the relay is de-asserted. The relays are polarity-sensitive, unlike mechanical relays. The pin connections are:

Troubleshooting

Control Relay connection

Control relay connection is described in the control relay section. Pay particular attention to polarity. Also note the "#d” command in the command processor section. This command is very useful for testing connectivity, etc.

Reset

After a successful flight, waypoints that were asserted will no longer trigger the control relays, as described in the software section. There are three ways to reset this condition:

  • Remove and re-insert the batteries.
  • Connect a serial device to the unit and send the "#r command.
  • Press the reset. This is the preferred method of resetting the unit.

FormatCommand
#d Debug mode, toggles status LEDs and control relays. This mode is useful for testing connections, etc. Sending another character terminates the mode.
#p Causes the unit to go into sleep mode
#r Resets trigger states
#sR00000

Sets "on" time of control relay. The "R" value is one of the Characters 'C', 'D' or 'T'. The 00000 field is replaced with a decimal value from 00000 to 65535. All 5 digits must be transmitted. The value indicates the number of time units the selected control relay is asserted. The time unit is 0.0016 seconds.

For example to set the assert time for the "T" control relay for two seconds, the command is: #sT01250

#tR Used to test the assertion of a control relay, the "R" value is one of the Characters 'C', 'D' or 'T'.
#m00 Used to set the trigger mode:
  • 00 = None
  • 01 = Difference
  • 02 = Alarm
  • 03 = Both

PARTS LIST FOR THE GDP

SEMICONDUCTORS
IC1PIC16F877P MicroChips microcontroller
IC24001 Quad Nand gate
D11N4001 Diode
LED1Green LED
LED2Red LED
RESISTORS
R110000-ohm 1/8-watt
R2, R347-ohm 1/8-watt
R41000000-ohm 1/8-watt
R522000-ohm 1/8-watt
R610-ohm 1/8-watt
CAPACITORS
C14.7-mf 16-WVDC, tantalum
ADDITIONAL PARTS
X110 Mhz crystal
S1Single-pole, momentary contact, PC mount
RLY1-RLY3DMO063 Crydon Solidstate relays
C18 Pin connector