I wonder if anyone has written a code for GPS time stamping of voltages from seismic geophone (or any other sensors) digitized by internal or better external ADC connected to Arduino? Since the accuracy of at least 1 millisecond is required I believe using 1 PPS signal of the GPS is the only solution.
To tackle the time resolution and accuracy issue you could:
- Attach the 1PPS signal to an interrupt pin
- In the interrupt routine record the
millis()value at the time the 1PPS signal is activated
- In the main loop do a non-blocking read of the GPS data to find and build up the time string as it is sent from the GPS (shortly after the 1PPS is triggered).
You now know what the
millis() count was the last time a 1PPS pulse arrived, and you know the current time to within a second. The 1PPS pulse will be at
HH:MM:SS.000 (or as near as damnit) so if you subtract the current
millis() from your recorded 1PPS
millis() value it gives you the number of milliseconds since the 1PPS pulse. Add that to the current time, and you have 1ms accuracy in the time:
I doubt anyone has written software for your exact situation but you should be able to cobble something together if we break down the problem.
- You want to read a value from an Analog port (or external ADC)
- You want to read the time from a GPS.
- You want to write these two readings to 'somewhere'.
Looking at the Arduino IDE tutorials there are some Analog ones that would be relevant. But the only line you need is
int sensorValue = analogRead(analogInPin); which reads a value between 0 and 1024 which relates to the output range of your sensor.
Now you want to read from a GPS, looking at the Software Serial Library Examples there is an example of how to setup a second serial port to read the GPS data. The GPS data will arrive once every 2 seconds. The PPS signal will arrive once every 1 second. So I'm not sure how you are going to use this to get millisecond accuracy. To get millisecond accuracy I would use the GPS data to correct a Real Time Clock connected over either the I2C or SPI bus. There are lots of example programs on reading from an RTC over these busses.
Write them to somewhere, well initially I would write them to the hardware serial port, back to you PC via USB, but then you might want to start looking at writing them to a SD card or via WIFI or GSM to a cloud storage solution.
Here are a list of the examples I looked at:
Hope that helps