How to trigger operation at every hundredth millisecond using ADA Ultimate GPS

Hi all,

Just joined the forums, been using Arduino the last month or so, but now I am need of some assistance. I am developing a Data Acquisition System, and would like to sync the GPS time with my sensor reading frequency, for example: For every hundredth millisecond, I want the system to acquire a reading.

How do I program my Arduino to take a reading whenever my GPS time is at (XXXXXX.100, XXXXXX.200, XXXXXX.300, ...)?

I am using a Adafruit Ultimate GPS V3

Thanks :slight_smile:

How do I program my Arduino to take a reading whenever my GPS time is at (XXXXXX.100, XXXXXX.200, XXXXXX.300, ...)?

That depends on how, exactly, the time is reported. Is that a string? Or is that a double/float?

Most GPS libraries (assuming your using one) do all the data collection and parsing for you and spit out results every second. You can normally increase this speed and a quick look at the Adafruit lib shows PMTK_SET_NMEA_UPDATE_10HZ should do this.

PaulS:

How do I program my Arduino to take a reading whenever my GPS time is at (XXXXXX.100, XXXXXX.200, XXXXXX.300, ...)?

That depends on how, exactly, the time is reported. Is that a string? Or is that a double/float?

Time is reported as a String

Set your GPS up to send at 10Hz and only one NMEA string, then use code something like this to save after you receive each NMEA sentence.

void loop() {
  char c;

  //…
  if (Serial.available()) {
    c = Serial.read();

    if (c == '\n') {
      //end of gps string received, save sensor data now… 
    }
  }
  //…
}

I think it would be much eaasier to do the timing with millis() using the standard approach in the Blink Without Delay example sketch.

Milllis() won't be quite as accurate as the GPS clock so you could add a correction every so often - wild guess, perhaps once per hour would be enough. It's the same idea as correcting the calendar with leap years.

...R

Did you mean every one hundred milliseconds? One hundredth millisecond would be 10 microsecond.

You have no (almost) no control of correct time. The GPS transfers its info at 57600baud (max)
You get info for whole second and the age of this timing.
Timing within seconds (or even minutes) is best done using onboard x-tal..
(dont wast time to slow communications)
........
Even with a GPS (where timing is in range of nanosecs) you wont be able to tell absolute correct time.
You MAY get as good as 1/10 (when transfer time is teken into account)