ublox NEO-M9N accelerometer app

Hi,

I have placed an order for a ublox NEO-M9N GPS module from Sparkfun and will be connecting it a MicroMod ATP board loaded with a Teensy MicroMod.

I want to write a simple application that can do the following:

Measure 0-60mph times

Measure 60-130mph times

If possible, output altitude data at each sample point

And I want to do this at the fastest rate the M9N can output at - 25Hz.

I don’t need someone to write the app for me, I just need guidance no how to setup the module and the callback(s) as there are quite a few examples in the github repo and I’m not quite sure which are relevant.

If there is a reference manual of some sort that can aid, I will happily review it.

Thanks,

David

Hello David,

You could log position, velocity and altitude data from the module to microSD card, do your run, and then post-process the data to extract the acceleration times.

Or, you could monitor velocity in real time, wait for it to go slightly above zero, record the start time in your code, keep monitoring the velocity until it reaches 60mph, record the end time, subtract the two and display the difference on an LCD or OLED display.

You need to decide if you are going to log / monitor NMEA data (which is human-readable), or use the u-blox UBX binary data (more efficient but not human-readable). Let me know which, and I will try and point you at the closest examples.

Best wishes,

Paul

Hi Paul,

I’m running a simple 3-axis accelerometer, so I can use that to trigger my read start from the GPS.

I would rather use the binary data and process it on the fly with the Teensy, as I need the data as accurate as possible.

I will be displaying the output on an LCD.

Hi David,

OK. It sounds like the “Auto” PVT Callback example does most of what you need:

https://github.com/sparkfun/SparkFun_u- … llback.ino

Change myGNSS.setNavigationFrequency(2); to myGNSS.setNavigationFrequency(25); to run at 25Hz.

Delete the delay(50); in the loop. Replace the Serial.print with your LCD display code.

The full definition of UBX_NAV_PVT_data_t is here:

https://github.com/sparkfun/SparkFun_u- … #L359-L441

I think gSpeed is what you need (2-D ground speed in mm/s). You will need to convert from mm/s to mph.

Please also see this example:

https://github.com/sparkfun/SparkFun_u- … cModel.ino

You need to set the dynamic model to DYN_MODEL_AUTOMOTIVE for best results.

myGNSS.setDynamicModel(DYN_MODEL_AUTOMOTIVE, VAL_LAYER_RAM_BBR);

The PVT iTOW (Time Of Week - in milliseconds) will give you the exact timing of the PVT measurement. It may be more accurate to use that instead of recording the millis() when the data arrived.

Good luck! Sounds like a fun project,

Paul

Unless this is going in a plane / aircraft? In which case you need AIRBORNE1g . There are also AIRBORNE2g and AIRBORNE4g if you need them.

If you are airborne, then you’ll need to work with the three North East Down velocities instead: velN, velE, velD. Calculate the hypotenuse to give your velocity in 3D.

Best,

Paul

Hi Paul,

Thanks for all the info!

This is going in a car :slight_smile:

I’ll also want to log altitude in order to determine slope of the entire run

I’ll be using the KX132 accelerometer to trigger the recordings as soon as some g-force is applied - I’ll want to use a callback there too, instead of having to poll the sensor each time - I saw you contributed to the library as well :slight_smile:

I think with the info you already provided plus the info I need above, I will have enough to get started and become familiar with the GPS apis (I deal alot with CAN bus, but not with GPS at all)

Thanks,

David