Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 05930f8

Browse files
committed
Initial commit
Some things may be missing because I was in the middle of development when stay at home orders were issued. Will be hammered out as I work through it.
1 parent 368b20a commit 05930f8

File tree

4 files changed

+219
-0
lines changed

4 files changed

+219
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ $RECYCLE.BIN/
4848
Network Trash Folder
4949
Temporary Items
5050
.apdisk
51+
52+
# VIM backup files
53+
*~
54+
[._]*.un~
55+
*.swp
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
/*
3+
Some Description
4+
By: Elias Santistevan
5+
SparkFun Electronics
6+
Date: February
7+
License: MIT. See license file for more information but you can
8+
basically do whatever you want with this code.
9+
10+
11+
Feel like supporting open source hardware?
12+
Buy a board from SparkFun!
13+
NEO-M8U: https://www.sparkfun.com/products/15136
14+
ZED-F9R: https://www.sparkfun.com/products/15136
15+
16+
Hardware Connections:
17+
Plug a Qwiic cable into the GPS and a BlackBoard
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 <Wire.h> //Needed for I2C to GPS
23+
24+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
25+
SFE_UBLOX_GPS myGPS;
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
while (!Serial); //Wait for user to open terminal
31+
Serial.println("SparkFun Ublox Example");
32+
33+
Wire.begin();
34+
35+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
36+
{
37+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
38+
while (1);
39+
}
40+
41+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
42+
43+
if (myGPS.getUdrStatus())
44+
{
45+
Serial.print("Mode: ");
46+
Serial.println(myGPS.imuMetric.fusionMode);
47+
Serial.print("Number of Sensors: ");
48+
Serial.println(myGPS.imuMetric.numSens);
49+
}
50+
}
51+
52+
void loop()
53+
{
54+
if (myGPS.getUdrStatus())
55+
Serial.println(myGPS.imuMetric.fusionMode);
56+
57+
if (myGPS.getInsInfo())
58+
{
59+
Serial.print("X validity: ");
60+
Serial.println(myGPS.imuMetric.xAngRateVald);
61+
Serial.print("X: ");
62+
Serial.println(myGPS.imuMetric.xAngRate);
63+
Serial.print("Y validity: ");
64+
Serial.println(myGPS.imuMetric.yAngRateVald);
65+
Serial.print("Y: ");
66+
Serial.println(myGPS.imuMetric.yAngRate);
67+
Serial.print("Z validity: ");
68+
Serial.println(myGPS.imuMetric.zAngRateVald);
69+
Serial.print("Z: ");
70+
Serial.println(myGPS.imuMetric.zAngRate);
71+
}
72+
delay(250);
73+
}
74+

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,3 +2709,112 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
27092709

27102710
return (true);
27112711
}
2712+
boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait)
2713+
{
2714+
// Requesting Data from the receiver
2715+
packetCfg.cls = UBX_CLASS_ESF;
2716+
packetCfg.id = UBX_ESF_STATUS;
2717+
packetCfg.len = 0;
2718+
packetCfg.startingSpot = 0;
2719+
2720+
if (sendCommand(packetCfg, maxWait) == false)
2721+
return (false); //If command send fails then bail
2722+
2723+
checkUblox();
2724+
2725+
// payload should be loaded.
2726+
imuMetric.version = extractByte(4);
2727+
imuMetric.fusionMode = extractByte(12);
2728+
imuMetric.numSens = extractByte(15);
2729+
2730+
// Individual Status Sensor in different function
2731+
return(true);
2732+
}
2733+
2734+
//
2735+
boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait)
2736+
{
2737+
packetCfg.cls = UBX_CLASS_ESF;
2738+
packetCfg.id = UBX_ESF_INS;
2739+
packetCfg.len = 0;
2740+
packetCfg.startingSpot = 0;
2741+
2742+
if (sendCommand(packetCfg, maxWait) == false)
2743+
return (false); //If command send fails then bail
2744+
2745+
checkUblox();
2746+
2747+
// Validity of each sensor value below
2748+
uint32_t validity = extractLong(0);
2749+
2750+
imuMetric.xAngRateVald = (validity && 0x0080) >> 8;
2751+
imuMetric.yAngRateVald = (validity && 0x0100) >> 9;
2752+
imuMetric.zAngRateVald = (validity && 0x0200) >> 10;
2753+
imuMetric.xAccelVald = (validity && 0x0400) >> 11;
2754+
imuMetric.yAccelVald = (validity && 0x0800) >> 12;
2755+
imuMetric.zAccelVald = (validity && 0x1000) >> 13;
2756+
2757+
imuMetric.xAngRate = extractLong(12); // deg/s
2758+
imuMetric.yAngRate = extractLong(16); // deg/s
2759+
imuMetric.zAngRate = extractLong(20); // deg/s
2760+
2761+
imuMetric.xAccel = extractLong(24); // m/s
2762+
imuMetric.yAccel = extractLong(28); // m/s
2763+
imuMetric.zAccel = extractLong(32); // m/s
2764+
2765+
return(true);
2766+
}
2767+
2768+
//
2769+
boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait)
2770+
{
2771+
2772+
packetCfg.cls = UBX_CLASS_ESF;
2773+
packetCfg.id = UBX_ESF_MEAS;
2774+
packetCfg.len = 0;
2775+
packetCfg.startingSpot = 0;
2776+
2777+
if (sendCommand(packetCfg, maxWait) == false)
2778+
return (false); //If command send fails then bail
2779+
2780+
checkUblox();
2781+
2782+
uint32_t timeStamp = extractLong(0);
2783+
uint32_t flags = extractInt(4);
2784+
2785+
uint8_t timeSent = (flags && 0x01) >> 1;
2786+
uint8_t timeEdge = (flags && 0x02) >> 2;
2787+
uint8_t tagValid = (flags && 0x04) >> 3;
2788+
uint8_t numMeas = (flags && 0x1000) >> 15;
2789+
2790+
}
2791+
2792+
boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait)
2793+
{
2794+
2795+
// Need the number of sensors to know what to sample.
2796+
getUdrStatus();
2797+
2798+
// Rate selected in UBX-CFG-MSG is not respected
2799+
packetCfg.cls = UBX_CLASS_ESF;
2800+
packetCfg.id = UBX_ESF_RAW;
2801+
packetCfg.len = 0;
2802+
packetCfg.startingSpot = 0;
2803+
2804+
if (sendCommand(packetCfg, maxWait) == false)
2805+
return (false); //If command send fails then bail
2806+
2807+
checkUblox();
2808+
2809+
uint8_t byteOffset = 8;
2810+
2811+
for(uint8_t i=0; i<imuMetric.numSens; i++){
2812+
2813+
uint32_t bitField = extractLong(4 + byteOffset * i);
2814+
imuMetric.dataType[i] = (bitField && 0xFF000000) >> 23; // Repeating Blocks on the back burner...
2815+
imuMetric.data[i] = (bitField && 0xFFFFFF)
2816+
imuMetric.timeStamp[i] = extractLong(8 + byteOffset * i);
2817+
2818+
}
2819+
}
2820+

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,10 @@ class SFE_UBLOX_GPS
582582
//Change the dynamic platform model using UBX-CFG-NAV5
583583
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);
584584

585+
boolean getUdrStatus(uint16_t maxWait = 1100);
586+
boolean getInsInfo(uint16_t maxWait = 1100);
587+
boolean getExternSensMeas(uint16_t maxWait = 1100);
588+
585589
//Survey-in specific controls
586590
struct svinStructure
587591
{
@@ -655,6 +659,33 @@ class SFE_UBLOX_GPS
655659

656660
uint16_t rtcmFrameCounter = 0; //Tracks the type of incoming byte inside RTCM frame
657661

662+
struct udrData
663+
{
664+
uint8_t version;
665+
uint8_t fusionMode;
666+
uint8_t numSens;
667+
668+
uint8_t xAngRateVald;
669+
uint8_t yAngRateVald;
670+
uint8_t zAngRateVald;
671+
uint8_t xAccelVald;
672+
uint8_t yAccelVald;
673+
uint8_t zAccelVald;
674+
675+
int32_t xAngRate;
676+
int32_t yAngRate;
677+
int32_t zAngRate;
678+
679+
int32_t xAccel;
680+
int32_t yAccel;
681+
int32_t zAccel;
682+
683+
// The array size is based on testing directly on M8U and F9R
684+
uint32_t data[7];
685+
uint32_t dataType[7];
686+
uint32_t timeStamp[7];
687+
} imuMetric;
688+
658689
private:
659690
//Depending on the sentence type the processor will load characters into different arrays
660691
enum SentenceTypes

0 commit comments

Comments
 (0)