WORKS!1

holy smokes, it works! GPS EM-406 to Arduino:



#define rxPin 7
#define txPin 8
#define ledPin 13

#define bit4800Delay 188 
#define halfBit4800Delay 94 
//definitions for 4800 baud communication

byte val;
boolean ledPinOn;

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(txPin,  HIGH); //set transmit pin to high
  digitalWrite(ledPin,  HIGH); //turn on debug led  
  ledPinOn = true;
  
  // set the data rate for the SoftwareSerial port
  Serial.begin(4800); //4800 is the baud rate for EM306
}

int SWread()
{
  byte val = 0;
  
  while (digitalRead(rxPin));
  //wait for start bit
  
  
  if (digitalRead(rxPin) == LOW) {
    
    
    delayMicroseconds(halfBit4800Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit4800Delay);
     val |= digitalRead(rxPin) << offset; 
     //iterate through bit mask.
     //Or, in other words, each bit is sent after a bit4800delay,
     //from MSB to LSB. get the first most significant bit, shift it left, etc.
    }
    //wait for stop bit + extra
    delayMicroseconds(bit4800Delay); 
    delayMicroseconds(bit4800Delay);
    return val;
  }

}

void loop() {
  Serial.print(SWread(), BYTE); 
  if(ledPinOn == true) ledPinOn = false;
  else ledPinOn = true;
  digitalWrite(ledPin,  ledPinOn);
 
  // toggle an LED just so you see the thing's alive.  
  // this LED will go on with every OTHER character received:
  

}

output (but with no spaces between commas):
$GPGGA,062032.000,3922.1678,N,07640.0290,W,1,06,1.5,132.3,M,-33.6,M,,0000*6D $GPGSA,A,3,28,11,17,08,27,19,,,,,,,2.4,1.5,1.9*31 $GPRMC,062032.000,A,3922.1678,N,07640.0290,W,0.16,134.81,210507,,*11 $GPGGA,062033.000,3922.1678,N,07640.0290,W,1,06,1.5,132.3,M,-33.6,M,,0000*6C $GPGSA,A,3,28,11,17,08,27,19,,,,,,,2.4,1.5,1.9*31 $GPGSV,3,1,09,28,70,332,41,11,57,067,43,08,49,205,38,17,43,269,26*7D $GPGSV,3,2,09,27,29,187,29,20,14,122,,19,09,063,24,26,05,289,*7C $GPGSV,3,3,09,29,04,281,*44 $GPRMC,062033.000,A,3922.1678,N,07640.0290,W,0.18,139.48,210507,,*16

Now, to parse the $GPRMC -- the recommended minimum specific gnss data...

Posted by provolot on May 21, 2007 2:21 AM | | Comments (0)

TrackBack

TrackBack URL for this entry:
http://www.provolot.com/cgi-bin/mt5/mt-tb.cgi/56

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)