VN-200 User Manual
UM004
www.vectornav.com
15/47
3
Basic Communication
The VN-200 module supports two communication interfaces: serial and SPI. On the serial interface, the
module communicates over a universal asynchronous receiver/transmitter (UART) and uses ASCII text
for its command and data format. On the SPI interface, the VN-200 module communicates as a slave
device on a Serial Peripheral Interface (SPI) data bus and uses a binary command and data format. Both
interfaces support the complete command set implemented by the module. A general overview of the
command format for each interface is given in the next two Sections and formatting specific to each
command and associated parameters is provided in the protocol and register Sections (Section 4 & 5).
3.1
Serial Interface
On the serial interface, the VN-200 uses ASCII text for its command format. All commands start with a
dollar sign, followed by a five character command, a comma, command specific parameters, an asterisk,
a checksum, and a newline character. An example command is shown below:
$VNRRG,11*73
3.2
Checksum / CRC
The serial interface provides the option for either an 8-bit checksum or a 16-bit cyclic redundancy check
(CRC). In the event neither the checksum nor the CRC is needed, they can be turned off by the user.
3.2.1
8-bit Checksum
The 8-bit checksum is an XOR of all bytes between, but not including, the dollar sign ($) and asterisk (*).
All comma delimiters are included in the checksum calculation. The resultant checksum is an 8-bit
number and is represented in the command as two hexadecimal characters. The C function snippet
below calculates the correct checksum:
3.2.2
16-bit CRC
For cases where the 8-bit checksum does not provide enough error detection, a full 16-bit CRC is
available. The VN-200 uses the CRC16-CCITT algorithm. The resultant CRC is a 16-bit number and is
represented in the command as four hexadecimal characters. The C function snippet below calculates
the correct CRC:
unsigned char calculateChecksum(char* command, int length)
{
unsigned char xor = 0;
for(int i = 0; i < length; i++)
xor ^= (unsigned char)command[i];
return xor;
}