Pages: [1]   Go Down
Author Topic: GPS clock  (Read 637 times)
0 Members and 1 Guest are viewing this topic.
Chicago IL
Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am a new user to arduino and am making a clock that gets time from an old tripmate GPS and displays the time on some 12" seven segment displays.  Is it possible to decode the NMEA strings from the gps and store the time into a variable so it could be displayed?  a string would look like this
$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,071281,003.1,W*43

and 123519 would be the time (12:35:19)

if it is possible, can some one give some example code?

« Last Edit: November 09, 2006, 11:33:10 pm by karlcswanson » Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

I've done this before on different chips.  The strategy is basically that you have to keep reading the serial port, and when you see an "R", you check for an "M", and if that's true, you check for a "C", and if that's true  you check for a comma (so you have checked for the  string "RMC," ). If these checks are true,  you know the next values in the serial buffer will be the time, which comes right after it.

Here's a <<guess>> as to how you might start to do this on the Arduino, You'll need to figure out the escape character for the comma than comes between $GPRMC and the time. You also have to make sure that the RS-232 from the GPS unit is not inverted and that it's in 5V form. Usually a Maxim MAX232 chip will do the trick.

This code is just a guess... it's not going to work, but it might be a start. You may want to throw in some Serial.println commands for the serial monitor, so that you can see what's being stored in variables.

D
____________________________    

void loop () {
  // read the serial port
  serbyte = Serial.read();

  // if the input is '-1' then there is no data
  // at the input, otherwise store it
  if (serbyte != -1) {
    val = serbyte;
  }

  if (val == 'R') {
    val = Serial.read();
     if (val == 'M') {
      val = Serial.read();
        if (val == 'C') {
         val = Serial.read();
           if (val == '\'') {                 // this might not be the right way to define a comma!
      
             // capture the time into variables here.
      
      
      
      }
    }
  }
}
  delay(10);
}


« Last Edit: November 11, 2006, 01:02:07 am by Daniel » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
        if (val == '\'') {                 // this might not be the right way to define a comma!  
 

No, you compared val with a single quote. I guess you should just write
        if (val == ',') {

If you want to check for a comma.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 36
blablablabla
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

regex for arduino would be GREAT  smiley-grin
Logged

Chicago IL
Offline Offline
Newbie
*
Karma: 0
Posts: 36
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How would i capture those variables?
Logged

Pages: [1]   Go Up
Jump to: