EM-406A, CAN-Bus, Arduino Mega 2560 (URGENT)

I am working on a program using a Arduino Mega 2560 clone (from SainSmart, boards are identical to R3), the SparkFun CAN-Bus shield, and the USGlobalSat EM-406A GPS unit. The library being used is the TinyGPS series of libraries from Mikal Hart. I am trying to get engine information, do some calculations with it, pair it with latitude and longitude, and write the data to an SD card.

A few days ago, I was not having any issues getting information from my GPS (though I couldn’t do it AND get information from the engine… that’s different, though) and I haven’t done much with my project since. Now, I’m trying to get it to do both the engine data and the GPS data. Problem is, there’s an error.

The EM-406A is apparently getting a lock on the GPS satellites, because the LED is blinking, as it does when the device is being tracked. However, when I try and upload the sketch to the Arduino Mega, I get the result pictured in the screenie below. The EM-406A is connected through a CAN-Bus shield (also from SparkFun) and uses SoftwareSerial on pins 3 & 4. I have also tried pins 4 and 5. I have tried this with two different CAN-Bus shields and two different EM-406As. The only thing that’s remained constant is the Arduino Mega. The original hardware combination worked fine just a week or so ago, but, I noticed that pin 6 on the EM-406A connector (the one nearest the outside edge of the shield) was bent and was thus not properly connected. I’m not sure when this damage occured. This pin is one of two ground pins on the connector. The Mega continued to work, but since I haven’t had the GPS logging part of the program working yet, it’s unknown if this caused damage. Furthermore, the second shield/GPS combo did not have this damage.

Speaking of the Mega, it may be worth noting that the pins are jumpered due to incompatibilities between the Uno (which the shield was designed for) and the Mega. The jumpers are as follows:

13->52

12->50

11->51

10->53

I have tried uploading several of Hart’s sample sketches to the Mega in order to see if changing parameters on the program (the pins through which software serial is connected) works. It doesn’t help at all. If the problem was caused by something in my sketch, it would not have been duplicated in Hart’s sketches. The sketch I’m working with is below.

Here’s the kicker: this is my final project for my senior year in college and two other people are relying on me to get this to work. The presentation for this project is May 5th, two weeks from now. This is a critical component in my project. What do I need to do to figure out what I’m doing wrong and fix it? :pray:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);

  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();
}

Here’s the kicker: this is my final project for my senior year in college and two other people are relying on me to get this to work. The presentation for this project is May 5th, two weeks from now. This is a critical component in my project. What do I need to do to figure out what I’m doing wrong and fix it?

1) start sooner
  1. take another class on basic debugging

  2. tell you friends to pull their freaking weight

  3. enroll in a decent class that might include something on debugging

  4. profit???

skimask:

Here’s the kicker: this is my final project for my senior year in college and two other people are relying on me to get this to work. The presentation for this project is May 5th, two weeks from now. This is a critical component in my project. What do I need to do to figure out what I’m doing wrong and fix it?

1) start sooner
  1. take another class on basic debugging

  2. tell you friends to pull their freaking weight

  3. enroll in a decent class that might include something on debugging

  4. profit???

I started months ago. As I said, this whole thing was working fine up until tonight. This isn’t the only project I have to work on, and I’ve had to delegate my time accordingly. One of the friends is pulling tons of his weight by working on the web aspect of this project. The other is working on the presentation itself. They aren’t as familiar with the Arduino and electronics as I am. I’m here because neither of them could figure out the problem after looking at it. I’ve taken classes on debugging.

I’m asking you for your help. Either give it to me or let me wallow in my problem. I would appreciate not being fed more of the old “read the manual” and “take a class” lines. It’s harmful to the reputations of the hacking and maker communities. No one got here without tripping up and needing a little help when stuck in the muck. I provided you pretty much every bit of information I could on the problem I’m having; if you think it can be solved by “basic debugging”, then you’ve obviously seen a problem in my implementation. If you have, let me know what it is, and I’ll get out of your hair and stop bothering you for help on this forum that we all come to in our spare time without any expectation of monetary return.

Nerdenator:
I started months ago. As I said, this whole thing was working fine up until tonight.

Step 1 of debugging...when it quits working, back up.

I’ve taken classes on debugging.

What was it's name?

Either give it to me or let me wallow in my problem.

Start wallerin'...

I would appreciate not being fed more of the old “read the manual” and “take a class” lines.

Why? Because that's what fixes the problem the majority of the time and you'd rather have somebody else invest their time into your problem?

It’s harmful to the reputations of the hacking and maker communities.

Ya...bass-ackwards...

Supposedly, you’re in a “college”…a learning institution.

Get on with the process of learning rather than getting somebody else to fix your problems for you…'cause that works in the real world…then you get fired…then a bear eats your car.

Don’t let a bear eat your car.

skimask:

Nerdenator:
I started months ago. As I said, this whole thing was working fine up until tonight.

Step 1 of debugging...when it quits working, back up.

I’ve taken classes on debugging.

What was it's name?

Either give it to me or let me wallow in my problem.

Start wallerin'...

I would appreciate not being fed more of the old “read the manual” and “take a class” lines.

Why? Because that's what fixes the problem the majority of the time and you'd rather have somebody else invest their time into your problem?

It’s harmful to the reputations of the hacking and maker communities.

Ya...bass-ackwards...

Supposedly, you’re in a “college”…a learning institution.

Get on with the process of learning rather than getting somebody else to fix your problems for you…'cause that works in the real world…then you get fired…then a bear eats your car.

Don’t let a bear eat your car.

“Why? Because that’s what fixes the problem the majority of the time and you’d rather have somebody else invest their time into your problem?”

I’ve already read the manual. That’s how I know that the EM-406A is receiving a signal. It’s how I know that the pin that was bent was a ground pin. Now I’m here because between that and the fact that the sketch should work, I’m not sure where the problem lies and I would like some insights as to how to fix the problem.

Don’t act like your time is so important that you are being bothered by my posting here. This is a volunteer forum. You don’t have to post here; it’s not your job to do so. You do so because you find pleasure in working on electronics. If my posting bothers you that much, you’re free to not respond or ignore it. I’m not trolling; I’m not spamming; I’m not trying to be confrontational. You’ve spent more time telling me to take off than you would have either helping me fix the problem (since I’ve seen no direct evidence that you could do so) or just not responding at all.

If you have something constructive to offer me, offer it. If you don’t, don’t respond. I’m here to learn. I want to know what’s wrong. Now either tell me what it is, or get out.

Mods, listen, I don’t know how affiliated you are with SFE (if you’re employees, if you’re volunteers, etc.) but I do factor this sort of thing in when I’m buying components. If I can’t get help when I need it because some guy who lives on top of a nuclear missile base feels the need to be snarky, I think I’ll take my business elsewhere. Do a better job of moderating your forums. This is a disgrace.

I don’t think you’re getting your moneys worth…

Greetings,

Hope you got this sorted in time!

I’m putting the finishing touches on a logger/display I’ve built for my vehicle using the Can-Bus shield and a Mega 2560. I found that using one of the extra hardware serial interfaces on the Mega was much more reliable than using software serial. You can also check to make sure you’re actually getting data from the GPS module by uploading a “blank” sketch to the board:

void setup(){}
void loop(){}

Then connect the serial output of the GPS to the Serial (i.e. not Serial1, Serial2 or Serial3) pins of the board and open up the serial monitor. You should see a stream of data immediately regardless of location fix.

I also found that to keep the TingGPS++ library happy I had to poll the serial buffer quite frequently, I’m currently refreshing the data every 50ms or so, from memory pushing the refresh time out past a second caused the values to hang - I guess due to the serial buffer overflowing.

Cheers