Getting started with Ublox Part 2 – Setting Airborne Dynamic Model

Ok firstly we need to switch the RX&TX connections over on the board as we were passing through to the in board Serial to USB chip. This is important, don’t do this and nothing will work

So amend the wiring as follows :

Arduino 5V to GPS Board 5V
Arduino GND to GPS Board GND
Arduino Pin 0 (RX) to GPS Board TX
Arduino Pin 1 (TX) to GPS Board RX
Arduino Pin 2 to GPS Board EN

Load the following code up on your Arduino (close down U-Center at this point as it will be hanging on to the serial port).  This code is derived from Jon Sowman and Joey flight computer CUSF https://github.com/cuspaceflight/joey-m/tree/master/firmware

This code opens the serial port, send the binary command to set the dynamic model, waits for confirmation this has been acknowledged by the GPS. Once done it just drops to the main loop where it just blinks the Status LED once a second to indicate success.

#include <util/delay.h>

#define GPSENABLE 2
#define STATUSLED 13

void setup() {
 pinMode(GPSENABLE, OUTPUT);
 pinMode(STATUSLED, OUTPUT);
 Serial.begin(9600);
 _delay_ms(500);
 digitalWrite(GPSENABLE, HIGH);
 _delay_ms(500);
 setGPS_DynamicModel6();
}
void loop() {
 digitalWrite(STATUSLED,!digitalRead(STATUSLED));
 _delay_ms(1000);
}
void setGPS_DynamicModel6()
{
 int gps_set_sucess=0;
 uint8_t setdm6[] = {
 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06,
 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,
 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C,
 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC };
 while(!gps_set_sucess)
 {
 sendUBX(setdm6, sizeof(setdm6)/sizeof(uint8_t));
 gps_set_sucess=getUBX_ACK(setdm6);
 }
}
void sendUBX(uint8_t *MSG, uint8_t len) {
 Serial.flush();
 Serial.write(0xFF);
 _delay_ms(500);
 for(int i=0; i<len; i++) {
 Serial.write(MSG[i]);
 }
}
boolean getUBX_ACK(uint8_t *MSG) {
 uint8_t b;
 uint8_t ackByteID = 0;
 uint8_t ackPacket[10];
 unsigned long startTime = millis();

// Construct the expected ACK packet
 ackPacket[0] = 0xB5; // header
 ackPacket[1] = 0x62; // header
 ackPacket[2] = 0x05; // class
 ackPacket[3] = 0x01; // id
 ackPacket[4] = 0x02; // length
 ackPacket[5] = 0x00;
 ackPacket[6] = MSG[2]; // ACK class
 ackPacket[7] = MSG[3]; // ACK id
 ackPacket[8] = 0; // CK_A
 ackPacket[9] = 0; // CK_B

// Calculate the checksums
 for (uint8_t ubxi=2; ubxi<8; ubxi++) {
 ackPacket[8] = ackPacket[8] + ackPacket[ubxi];
 ackPacket[9] = ackPacket[9] + ackPacket[8];
 }

while (1) {

// Test for success
 if (ackByteID > 9) {
 // All packets in order!
 return true;
 }

// Timeout if no valid response in 3 seconds
 if (millis() - startTime > 3000) {
 return false;
 }

// Make sure data is available to read
 if (Serial.available()) {
 b = Serial.read();

// Check that bytes arrive in sequence as per expected ACK packet
 if (b == ackPacket[ackByteID]) {
 ackByteID++;
 }
 else {
 ackByteID = 0; // Reset and look again, invalid order
 }
 }
 }
}

So there you go that’s the module in Dynamic Model 6 – Airborne < 1g which is generally the one you want for High Altitude ballooning. If your application is rocketry there is mode 8 – Airborne < 4g. Its quite viable to drop back to mode 3 – Pedestrian when below 9km in altitude. The airborne modes have large positional deviation, whereas the pedestrian modes have small deviation. Airborne modes are still perfectly accurate enough to locate a payload.

Ok so what next ? You have a choice at this point you can write a parser to read NMEA GNGGA strings to obtain your location information, you can use a prebuilt library that does this such as TinyGPS or finally you can use the UBX protocol to poll the module for information. I’ll discuss using UBX in the next article.

  1. Dear admin,
    I noticed open message view in u-center that my GNSS module does NOT remember the configuration. Moreover, I would like to know what I have to do to change GNSS information frequency transission.
    Thank in advance.
    Nik

  2. Hi Nik,

    The MAX modules have no EEPROM to save settings so will reset on power up. I’m unsure what you mean by frequency transmission do you mean the navigation rate i.e messages per second ?

    Anthony

  3. Hi Anthony,
    It’s a pity. An EEPROM shold be useful in some cases. But I think I can solve the problem adding the battery so the module will always reach power from the battery. It could work?

    Yes I mean navigation rate i.e the messages per second (sorry about my English 😳 😳 😳 ).
    Many thanks.
    NG

  4. The larger units like the LEA have built in EEPROM.
    You can adjust the navigation rate from its default 1Hz via UBX->CFG->RATE.
    By default its set to 1hz so adjust Measurement period till you get desired rate.
    Note: you won’t get the full 18hz update rate in multi GNSS Mode you will need to switch to GPS only (UBX-CFG->GNSS enable only GPS)
    Note2: At 18hz you’ll probably need to increase the baud rate from 9,600.

  5. Ernst Schulz

    Hallo,

    to set Airborn < 1g mode the u-Center 8.20 (MAX M8Q)

    give me this binary command:

    0000 B5 62 06 24 24 00 FF FF 06 03 00 00 00 00 µb$$ÿÿ
    000E 10 27 00 00 05 00 FA 00 FA 00 64 00 2C 01 'úúd,
    001C 00 3C 00 00 00 00 C8 00 00 00 00 00 00 00 <È
    002A 1A 28

    In the programm

    you have this binary command.

    int gps_set_sucess=0;
    uint8_t setdm6[] = {
    0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06,
    0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00,
    0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C,
    0x01, 0x00, 0x00 ❗ , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16 ❗ , 0xDC ❗ };
    (

    Why there are differences?

    Ernst Schulz

  6. I suspect there may be some additional stuff set in your command over my command with the newer version of U-Center. The important bits are set correctly and the last two hex parts will change if you change anything as these are checksum. Grab the U-Blox M8 Receiver Description/Protocol Document and have a look in there which bits you’re setting over mine and what they do.

    Cheers

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Human test : * Time limit is exhausted. Please reload CAPTCHA.