|
| 1 | +/* |
| 2 | + Use the NEO-D9S L-Band receiver to provide corrections as PMP over Serial |
| 3 | + By: SparkFun Electronics / Paul Clark |
| 4 | + Based on original code by: u-blox AG / Michael Ammann |
| 5 | + v3 updates: Decembe 22nd, 2022 |
| 6 | + License: MIT. See license file for more information. |
| 7 | +
|
| 8 | + This example shows how to obtain PMP correction data from a NEO-D9S L-Band receiver and push it over Serial (UART). |
| 9 | +
|
| 10 | + Feel like supporting open source hardware? |
| 11 | + Buy a board from SparkFun! |
| 12 | + ZED-F9P RTK2: https://www.sparkfun.com/products/16481 |
| 13 | + NEO-D9S: https://www.sparkfun.com/products/19390 |
| 14 | + Combo Board: https://www.sparkfun.com/products/20167 |
| 15 | +
|
| 16 | + Hardware Connections: |
| 17 | + Use a Qwiic cable to connect the NEO-D9S to your board |
| 18 | + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) |
| 19 | + Open the serial monitor at 115200 baud to see the output |
| 20 | +*/ |
| 21 | + |
| 22 | +#include <driver/uart.h> //Required for uart_set_rx_full_threshold() on cores <v2.0.5 |
| 23 | +HardwareSerial serialGNSS(2); // TX on 17, RX on 16 |
| 24 | + |
| 25 | +#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3 |
| 26 | +SFE_UBLOX_GNSS myLBand; // NEO-D9S |
| 27 | + |
| 28 | +//const uint32_t myLBandFreq = 1556290000; // Uncomment this line to use the US SPARTN 1.8 service |
| 29 | +const uint32_t myLBandFreq = 1545260000; // Uncomment this line to use the EU SPARTN 1.8 service |
| 30 | + |
| 31 | +#define OK(ok) (ok ? F(" -> OK") : F(" -> ERROR!")) // Convert uint8_t into OK/ERROR |
| 32 | + |
| 33 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 34 | + |
| 35 | +// Callback: pushRXMPMP will be called when new PMP data arrives |
| 36 | +// See u-blox_structs.h for the full definition of UBX_RXM_PMP_message_data_t |
| 37 | +// _____ You can use any name you like for the callback. Use the same name when you call setRXMPMPmessageCallbackPtr |
| 38 | +// / _____ This _must_ be UBX_RXM_PMP_message_data_t |
| 39 | +// | / _____ You can use any name you like for the struct |
| 40 | +// | | / |
| 41 | +// | | | |
| 42 | +void pushRXMPMP(UBX_RXM_PMP_message_data_t *pmpData) |
| 43 | +{ |
| 44 | + //Extract the raw message payload length |
| 45 | + uint16_t payloadLen = ((uint16_t)pmpData->lengthMSB << 8) | (uint16_t)pmpData->lengthLSB; |
| 46 | + |
| 47 | + uint16_t numBytesUserData = pmpData->payload[2] | ((uint16_t)pmpData->payload[3] << 8); |
| 48 | + uint16_t fecBits = pmpData->payload[20] | ((uint16_t)pmpData->payload[21] << 8); |
| 49 | + float ebno = (float)pmpData->payload[22] / 8; |
| 50 | + |
| 51 | + Serial.print(F("New RXM-PMP data received. userData: ")); |
| 52 | + Serial.print(numBytesUserData); |
| 53 | + Serial.print(F(" Bytes. fecBits: ")); |
| 54 | + Serial.print(fecBits); |
| 55 | + Serial.print(F(". ebno (dB): ")); |
| 56 | + Serial.print(ebno); |
| 57 | + Serial.println(F(".")); |
| 58 | + |
| 59 | + Serial.println(F("Pushing PMP to Serial...")); |
| 60 | + |
| 61 | + serialGNSS.write(&pmpData->payload[24], (size_t)numBytesUserData); // Push only the raw PMP userData |
| 62 | + (void)payloadLen; |
| 63 | + |
| 64 | + //serialGNSS.write(&pmpData->sync1, (size_t)payloadLen + 6); // Push the sync chars, class, ID, length and payload |
| 65 | + //serialGNSS.write(&pmpData->checksumA, (size_t)2); // Push the checksum bytes |
| 66 | +} |
| 67 | + |
| 68 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 69 | + |
| 70 | +void setup() |
| 71 | +{ |
| 72 | + delay(1000); |
| 73 | + |
| 74 | + Serial.begin(115200); |
| 75 | + Serial.println(F("NEO-D9S SPARTN Corrections")); |
| 76 | + |
| 77 | + serialGNSS.begin(38400); // UART2 on pins 16/17. |
| 78 | + |
| 79 | + Wire.begin(); //Start I2C |
| 80 | + |
| 81 | + //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 82 | + // Begin and configure the NEO-D9S L-Band receiver |
| 83 | + |
| 84 | + //myLBand.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial |
| 85 | + |
| 86 | + while (myLBand.begin(Wire, 0x43) == false) //Connect to the u-blox NEO-D9S using Wire port. The D9S default I2C address is 0x43 (not 0x42) |
| 87 | + { |
| 88 | + Serial.println(F("u-blox NEO-D9S not detected at default I2C address. Please check wiring.")); |
| 89 | + delay(2000); |
| 90 | + } |
| 91 | + Serial.println(F("u-blox NEO-D9S connected")); |
| 92 | + |
| 93 | + myLBand.newCfgValset(); // Create a new Configuration Interface message - this defaults to VAL_LAYER_RAM_BBR (change in RAM and BBR) |
| 94 | + myLBand.addCfgValset(UBLOX_CFG_PMP_CENTER_FREQUENCY, myLBandFreq); // Default 1539812500 Hz |
| 95 | + myLBand.addCfgValset(UBLOX_CFG_PMP_SEARCH_WINDOW, 2200); // Default 2200 Hz |
| 96 | + myLBand.addCfgValset(UBLOX_CFG_PMP_USE_SERVICE_ID, 0); // Default 1 |
| 97 | + myLBand.addCfgValset(UBLOX_CFG_PMP_SERVICE_ID, 21845); // Default 50821 |
| 98 | + myLBand.addCfgValset(UBLOX_CFG_PMP_DATA_RATE, 2400); // Default 2400 bps |
| 99 | + myLBand.addCfgValset(UBLOX_CFG_PMP_USE_DESCRAMBLER, 1); // Default 1 |
| 100 | + myLBand.addCfgValset(UBLOX_CFG_PMP_DESCRAMBLER_INIT, 26969); // Default 23560 |
| 101 | + myLBand.addCfgValset(UBLOX_CFG_PMP_USE_PRESCRAMBLING, 0); // Default 0 |
| 102 | + myLBand.addCfgValset(UBLOX_CFG_PMP_UNIQUE_WORD, 16238547128276412563ull); |
| 103 | + myLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_I2C, 1); // Ensure UBX-RXM-PMP is enabled on the I2C port |
| 104 | + myLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART1, 1); // Output UBX-RXM-PMP on UART1 |
| 105 | + myLBand.addCfgValset(UBLOX_CFG_UART2OUTPROT_UBX, 1); // Enable UBX output on UART2 |
| 106 | + myLBand.addCfgValset(UBLOX_CFG_MSGOUT_UBX_RXM_PMP_UART2, 1); // Output UBX-RXM-PMP on UART2 |
| 107 | + myLBand.addCfgValset(UBLOX_CFG_UART1_BAUDRATE, 38400); // match baudrate with ZED default |
| 108 | + myLBand.addCfgValset(UBLOX_CFG_UART2_BAUDRATE, 38400); // match baudrate with ZED default |
| 109 | + bool ok = myLBand.sendCfgValset(); // Apply the settings |
| 110 | + |
| 111 | + Serial.print(F("L-Band: configuration ")); |
| 112 | + Serial.println(OK(ok)); |
| 113 | + |
| 114 | + myLBand.softwareResetGNSSOnly(); // Do a restart |
| 115 | + |
| 116 | + myLBand.setRXMPMPmessageCallbackPtr(&pushRXMPMP); // Call pushRXMPMP when new PMP data arrives. Push it to the GNSS |
| 117 | + |
| 118 | +} |
| 119 | + |
| 120 | +//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 121 | + |
| 122 | +void loop() |
| 123 | +{ |
| 124 | + myLBand.checkUblox(); // Check for the arrival of new PMP data and process it. |
| 125 | + myLBand.checkCallbacks(); // Check if any LBand callbacks are waiting to be processed. |
| 126 | +} |
0 commit comments