Putting your EM-406 GPS back in to NMEA mode without waiting

I've read several times that to get your EM-406 out of binary mode you need to remove power and wait three days or a week, Bah! Send it the (binary mode) command to go back to NMEA! The only catch is, you do have to know what speed it is listening/talking in binary. If you don't know that, you can try all the bit rates. If that doesn't work, then I guess that you will need to unplug for a week. :(

The following sketch will set your 406 to NMEA mode, and set which messages to send, at what rate (sorry, no faster than 1x per second), and what bit rate to communicate at. As written it will set you to 9600 baud, sending GGA and GLL messages once per second and GVS message once every 5 seconds.

Not a thing of beauty, but it does have a few comments so that 6 months from now I could sort what the heck I did last month. :) It may also serve as a starting point on how to send other binary commands to the 406.

Note: I copied it out of other (functioning) code I wrote so it should work. I have not tested this as a sketch of its own but it is quite self contained and I don't believe there are any uninitialized variables or setup required. Let me know how it works for all y'all.

Cheers!

Ken
-------------------------------------------------------------------------------------------------------------------

void GPS_Switch_Mode_To_NMEA( void )
{
int checkSum;

const byte magicHead[] =
{
0xA0, 0xA2, // start sequence
0x00, 0x18 // payload length 0x18 = 24
};

const byte magicPayload[] =
{
0x81, // Message ID for "switch to NMEA"

0x02, // means "do not change NMEA debug message mode"

// the next bunch of fields work in pairs, first the time between messages, "period", then whether or
// not to send checksum on that message
//
// "period" is the number of seconds between times that the GPS repeats the message
// zero period is "do not send message
// then 0x00 for checksum off or 0x01 for checksum on
//

0x01, // GGA period
0x01, // checksum = on

0x01, // GLL period
0x01, // checksum = on

0x00, // GSA period
0x01, // checksum = on

0x05, // GSV period
0x01, // checksum = on

0x00, // RMC period
0x01, // checksum = on

0x00, // VTG period
0x01, // checksum = on

0x00, // MSS period
0x01, // checksum = on

0x00, // unused (future message)
0x01, // unused (checksum = on)

0x00, // ZDA period
0x01, // checksum = on

0x00, // unused (future message)
0x01, // unused (checksum = on)

// baud rate in 2 bytes (9600 = 0x2580; 19200 = 0x4B00; etc. )
0x25, // baud rate high byte
0x80 // baud rate low byte
};

const byte magicTail[] =
{
0xB0, 0xB3 // end sequence
};

// send 4 byte header
for( int index = 0; index < 4; index++ )
{
Serial.print( byte(magicHead[index] ) );
}

// send message body, calculating checksum as we go
checkSum = 0;
for( int index = 0; index < 24; index++ )
{
checkSum = checkSum + magicPayload[index];
Serial.print( byte( magicPayload[index] ) );
}
checkSum = checkSum & ( 0x7FFF );

// send the 2 byte checksum
Serial.print( byte(checkSum >> 8) );
Serial.print( byte(checkSum & 0xff) );

// send the 2 byte tail
for( int index = 0; index < 2; index++ )
{
Serial.print( byte( magicTail[index] ) );
}

}

void setup()
{
Serial.begin( 57600 ); // set this to the baud rate that (you hope) your "stuck in binary" GPS is set for
// if your GPS is really wonked, you may need to repeat this trying different baud rates

GPS_Switch_Mode_To_NMEA();
}

void loop()
{

}

Views: 1340


3D Robotics
Comment by Chris Anderson on November 12, 2009 at 8:14pm
Nice one! A much needed addition...
Comment by Rana on November 14, 2009 at 10:36am
Great ! $ £ $
You need to test the sketch soon and update.
Comment by Teejay on March 29, 2010 at 5:16am
Tried this out... seems that mine is indeed wonked.

Keeping the GPS on storage for a week...
Comment by space_nut on July 27, 2010 at 9:13pm
The (free) Sirfdemo program can also put the EM406 back into "factory fresh" mode - 4800, NMEA. I used this to get my arduIMU running with the EM406 after I had used it [the GPS] a few times in other projects. And yes, I too found that the IMU code for EM406 only works when you reset it or use one "fresh from the store"
Comment by Ken on July 29, 2010 at 3:34pm
Sirfdemo requires MS Windows and a cable to connect the PC to the GPS.
Comment by John Slee on January 19, 2014 at 8:04am

This seemed to Do The Thing for me. Wrote a blog post about it with modified code. Many many thanks for posting this!

http://indigoid.blogspot.com.au/2014/01/rescuing-unhappy-em406a-gps...

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service