Skip to content

UPRA GND.RF69x Modem PC ICD

marton bognar edited this page Jul 11, 2018 · 3 revisions

UPRA-GND.RF69x Modem

The GND transceiver hardware is based on the UHF flight COM hardware (COM.RF69x) expanded with a USB-UART interface.

GND.RF69x Modem

The firmware is modified so the hardware acts as a UHF modem. The GND.RF69x forwards the received radio packets on serial port to the PC. For the most basic operation the modem can be hooked up with a PC and a terminal software to read the radio packets.

As additional features the modem can receive NMEA commands on serial port to fine tune the frequency and send Telecommand packets to the balloon.

Communication Protocol

PC-Modem Interface

The physical layer of the PC-Modem communication is serial (UART) port. The modem has an FTDI USB-UART converter which establish communication on a virtual COM port.

Default UART configuration

Parameter Value
BaudRate 57600
Data bits 8
Stop bits 1
Parity none
Flow control none

Radio Packets

Incoming radio packets are forwarded directly to the PC via serial port.

Telemetry Packet

The Telemetry Packet is a fix 61 byte long UKHAS telemetry packet without checksum. Data segments in the packet are fixed length and also terminated by [,] (0x2C) character.

$$CCCCCCC,iii,hhmmss,(+/-)xxxx.xxx,(+/-)xxxxx.xxx,aaaaa,eeee,ooo,rrr,

Segment Description
$$ START bytes
CCCCCC callsign
iii Message ID*
hhmmss GPS time (UTC) (hh-hours, mm-minutes, ss-seconds)
(+/-)xxxx.xxx latitude (NMEA format)
(+/-)xxxxx.xxx longitude (NMEA format)
aaaaa altitude (m)
eeee external temperature (*10 °C -> eee.e°C)
ooo OBC module temperature (*10 °C -> ooo°C)
rrr COM module temperature (*10 °C -> rrr°C)

* Message ID shows the last three digits of the sent message and increments with every new message. After COM restart the Message ID set back to 0.

House-keeping Packet (TBD)

The Telemetry Packet is a fix 61 byte long custom packet. Data segments in the packet are terminated by [,] (0x2C) character.

$$CCCCCCC,iii,hhmmss,...TBD...

Segment Description
$$ START bytes
CCCCCC callsign
iii Message ID*
hhmmss GPS time (UTC) (hh-hours, mm-minutes, ss-seconds)
TBD TBD

* Message ID shows the last three digits of the sent message and increments with every new message. After COM restart the Message ID set back to 0.

Data Packet (TBD)

TBD


Modem Control

The modem communicates with the PC via NMEA protocol.

  • All transmitted data are printable ASCII characters between 0x20 (space) to 0x7e (~)
  • Data characters are all the above characters less the reserved characters (See next line)
  • Reserved characters are used by NMEA0183 for the following uses:
ASCII Hex Dec Use
[CR] 0x0d 13 Carriage return
[LF] 0x0a 10 Line feed, end delimiter
! 0x21 33 Start of encapsulation sentence delimiter
$ 0x24 36 Start delimiter
* 0x2a 42 Checksum delimiter
, 0x2c 44 Field delimiter
\ 0x5c 92 TAG block delimiter
^ 0x5e 94 Code delimiter for HEX representation of ISO/IEC 8859-1 (ASCII) characters
~ 0x7e 126 Reserved
  • Messages have a maximum length of 82 characters, including the $ or ! starting character and the ending
  • The start character for each message can be either a $ (For conventional field delimited messages) or ! (for messages that have special encapsulation in them)
  • The next five characters identify the talker (two characters) and the type of message (three characters).
  • All data fields that follow are comma-delimited.
  • Where data is unavailable, the corresponding field remains blank (it contains no character before the next delimiter ).
  • The first character that immediately follows the last data field character is an asterisk, but it is only included if a checksum is supplied.
  • The asterisk is immediately followed by a checksum represented as a two-digit hexadecimal number. The checksum is the bitwise exclusive OR of ASCII codes of all characters between the $ and *. According to the official specification, the checksum is optional for most data sentences, but is compulsory for RMA, RMB, and RMC (among others).
  • [CR][LF] ends the message.

As an example, a waypoint arrival alarm has the form:

$GPAAM,A,A,0.10,N,WPTNME*32

Another example for AIS messages is:

!AIVDM,1,1,,A,14eG;o@034o8sd<L9i:a;WF>062D,0*7D

Source: Wikipedia


Message Types

Message Description
GRHKR House-keeping packet request
GRSFQ Set radio frequency
GRACK ACK message sent by the modem

GRHKR - House-keeping request

If GRHKR message received on serial port the modem sends a house-keeping request package to the balloon. If the packet sent by the RF TCVR the modem respond with a GRACK message to the PC.

Request: $GRHKR,S,*17

Response: $GRACK,S,*2B

GRSFQ - Set frequency request

If GRSFQ message received on serial port the modem sets its RF frequency and transmits a dummy packet for testing. If the packet sent by the RF TCVR the modem respond with a GRACK message to the PC.

Request: $GRSFQ,ffffff,*cc

Response: $GRACK,F,*3E

Segment Description
$ Start byte
GRFSQ NMEA Header
ffffff RF Frequency in [kHz]
*cc Checksum*

*optional

GRACK - ACK message

Acknowledge message sent by the modem, if handshake is needed

$GRACK,a,*cc

Segment Description
$ Start byte
GRACK NMEA Header
a Acknowledge ID*
*cc Checksum**

**optional

*Acknowledge ID:

  • S - Radio Message Sent
  • F - GND Frequency Set

Checksum

The checksum at the end of each sentence is the XOR of all of the bytes in the sentence, excluding the initial dollar sign.

C Code:

#include <stdio.h>
#include <string.h>

int checksum(const char *s) 
{
    int c = 0;

    while(*s)
        c ^= *s++;

    return c;
}

int main()
{
    char mystring[] = "GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A";

    printf("String: %s\nChecksum: 0x%02X\n", mystring, checksum(mystring));

    return 0;
}

Source: Wikipedia

Python Code:

#!/usr/bin/env python

import re

""" Calculate  the checksum for NMEA sentence 
    from a GPS device. An NMEA sentence comprises
    a number of comma separated fields followed by
    a checksum (in hex) after a "*". An example
    of NMEA sentence with a correct checksum (of
    0x76) is:
    
      GPGSV,3,3,10,26,37,134,00,29,25,136,00*76"
"""

def checksum(sentence):

    """ Remove any newlines """
    if re.search("\n$", sentence):
        sentence = sentence[:-1]

    nmeadata,cksum = re.split('\*', sentence)

    calc_cksum = 0
    for s in nmeadata:
        calc_cksum ^= ord(s)

    """ Return the nmeadata, the checksum from
        sentence, and the calculated checksum
    """
    return nmeadata,'0x'+cksum,hex(calc_cksum)

if __name__=='__main__':

    """ NMEA sentence with checksum error (3rd field 
       should be 10 not 20)
    """
    line = "GPGSV,3,3,20,26,37,134,00,29,25,136,00*76\n"

    """ Get NMEA data and checksums """

    data,cksum,calc_cksum = checksum(line)

    """ Verify checksum (will report checksum error) """ 
    if cksum != calc_cksum:
        print "Error in checksum for: %s" % (data)
        print "Checksums are %s and %s" % (cksum,calc_cksum)

Source: Alan Holt (ActiveState)