GPS issues - Arduino does not display

Hello - I've been playing around with GPS for the last couple of days using

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267027090 to get started - it has GREAT info and Kevin has been nice to help, but I still didn't get it working.

There is a snippet of code there that says it will cause the NEMA sentences to display on the serial monitor that I used. Should I have changed anything for my setup?

void setup(){
  Serial.begin(4800);
}

void loop(){
  if (Serial.available() > 0){
    Serial.write(Serial.read());
  }
}

I then went to playground for: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267027090 and did a copy 'n paste of the code - the code compiles and loads nicely. BOTH systems give exactly the same results - garbage on Arduino serial monitor set to COM6. Yes, I do have the baud set at 4800 in all places.

I have used NEMA 0183 output from two different GPS with the exact same results - on the Arduino serial monitor I get:

ÊÖn⾶ÊòN:":
.*F

.NúN2>2>F":>.NÆN>
"*6F
6

N¢N>F>.N*
F:
N:

2:>

not sure why that did not display on same line - on the serial monitor it's all a single scrolling line.

If I put either of the two GPS engines direct to COM4 port and monitor the NEMA 0183 sentences with either TerraTermPro or even with Arduino serial monitor (setting both to COM4 and 4800 baud) they both display the correct NEMA 0183 sentence.

$GPRMC,173847.915,A,3030.7112,N,08752.9299,W,0.06,98.08,180310,,*20

There are a lot of other lines displayed and they look good, but the $GPRMC sentence is where all the lat/long, speed, etc is located - those are correct for my location.

From the results printed to serial monitors without going thru the Arduino we can tell the GPS is talking in NEMA sentences. The only wiring required is to put the GPS TX wire to digital pin 0 to see output. The Arduino is on COM6 (for USB connection).

Any suggestions and ideas would be appreciated. I did not paste the code as it is an exact copy 'n paste from the playground area. If desired, I can add the code.

I'm using a desktop, ASUS MB, XP-SP2 with Arduino IDE 0018.

Thanks for any and all help,

Ken H.

The only wiring required is to put the GPS TX wire to digital pin 0 to see output

Are the grounds connected?

I have tried it both ways, and with one of the GPS engines it's powered from the Arduino so is sharing the only ground. No ground loops there.

When I said "only wiring to put TX to pin 0" that was other than power. The GPS that's powered from Arduino has 3 wires - TX, Vcc, and Gnd. Since such good data is coming over the COM4 port, I don't "think" it's a ground loop problem.

Thanks for the input.

[edit]From some reading I've done it looks like there might be a timing issue. Note there are characters OK, with some that are not good. With the baud set to anything other than 4800 it's really garbage. Almost as if the timing was "almost" there. I am now lost - hope someone has some ideas or suggestions.[/edit]

Thanks for any input or suggestions.

Ken H>

I think I have a better understanding what's happening - let me try to ask the question again. GPS connected to Arduino with 3 wires, GPS TX, Vcc, and Gnd.

I understand this snippet of code should display to serial monitor set to 4800 baud what is coming in on Arduino pin 0 (serial RX)/

void setup(){
  Serial.begin(4800);
}

void loop(){
  if (Serial.available() > 0){
    Serial.write(Serial.read());
  }
}

This is what is displayed in the Arduino serial monitor:

ÊÖn⾶ÊòN:":.*F.NúN2>2>F":>.NÆN>"6F6N¢N>F>.NF:N:>2:>

That is with GPS and serial monitor all set to 4800 baud to match the code snippet.

IF the GPS TX wire is lifted from Arduino and input to a separate hardwired COM port and the Arduino serial monitor is set to that port (COM4 for example) the correct NEMA output from GPS is displayed:

$GPRMC,173847.915,A,3030.7112,N,08752.9299,W,0.06,98.08,180310,,*20

this shows the correct lat/long.

Can anyone suggest how to make the Arduino serial read the NEMA input? Is it a timing issue with the software COM port used by Arduino?

Thanks to all for any suggestions or ideas.

Ken H>

Have you got 7 bit data with parity?
Try AND ing your received characters with 0x7F before displaying them.
i.e.Serial.write(Serial.read() & 0x7F);

[edit]Second thoughts - is this an inversion, i.e. not TTL serial, but RS-232 -like serial?[/edit]

The GPS has a default of 4800,n,8,1 for NMEA - and I have the COM4 set for 8 bit data. I don't see anywhere the Arduino COM port has those settings - would it be default 7 bit? Or 8 bit?

Thank you for the idea - hope you have more guidance for me. I used the following:

void setup(){
  Serial.begin(4800);
}
void loop(){
  if (Serial.available() > 0){
   Serial.write(Serial.read() & 0x7F);
    //Serial.write(Serial.read());
  }
}

Is that how you meant for the AND'ing to be added?

Just saw your second question - I think it's serial. This is the line from the GPS datasheet: "Software command setting (Default : 4800,n,8,1 for NMEA )"

Remember, the data displays correctly on a standard COM port to a terminal program (Tera Term Pro or Arduino serial monitor) that is set to the hard wired COM port, not the USB port for Arduino.

Thanks for help on this - I think it's something fairly simple, but still beyond my simple abilities.

Ken H.

Which GPS are you using?

If you tied the GPS TX/GND to a com port and it worked, then you're at RS232 levels/voltages instead of TTL levels/voltages. This matches the garbage you're seeing.

You need an RS232 transceiver (MAX232, transistor trick, etc) between the RS232 GPS and the TTL arduino.

-j

Hey Thanks for the info Jason. In all the reading I've done of folks who did the GPS with Arduino it never clicked with me the Arduino used TTL. Now it makes sense.

What is required is the same circuit used by ICOM to connect the CIV-17 to a serial port - is this correct? If so, that will be easy. I've got a homebrew transistor circuit I used to connect to a 756Pro. I would put the GPS TX wire to the computer connection, then the Arduino to the ICOM pin.

Oh, your question about what GPS - I've tried a Garmin with a NEMA output, and I have a BR-304J GPS engine I wanted to use. It has the same NEMA output, but it is RS-232 because it displays correctly in a terminal window. Isn't that the way to tell if it's RS-232 or TTL? TTL would not display correctly in a terminal window?

Thanks again for the input Jason - Am I correct how to use the CIV-17 circuit?

73 de Ken H> K9FV
[edit]I found a link to the manual of the GPS I'm using.
http://www.oh5x.com/gpsinfo/BR-304%20user%20manual.html[/edit]

TTL would not display correctly in a terminal window?

That's correct, because TTL is not inverted, as RS-232 is, i.e. with RS-232, a '1' is a -ve voltage, potentially -12V, so it really isn't a good idea to connect to an Arduino. OTOH, a '0' is potentially +12V, and connecting that to an Arduino isn't a good idea either.

Good point Groove - for normal RS-232. I can see where 12vdc would fry a m168 pin!

Since the GPS are powered by 5vdc, is there much chance the RS-232 voltages could get substantially higher than 5vdc?

Thanks for the guidance and suggestions, they have helped.

Ken H.

Since the GPS are powered by 5vdc, is there much chance the RS-232 voltages could get substantially higher than 5vdc?

There is a chance, yes.
The commonly used Maxim 232 converter chips used in equipment like this are powered from +5V, but can supply and accept in excess of +/- 12V, though +/- 8V is the usual ballpark.

is required is the same circuit used by ICOM to connect the CIV-17 to a serial port - is this correct?

I'm not very familiar with the CIV-17, but a quick google makes me think that's exactly what you need.

I found a link to the manual of the GPS I'm using.
http://www.oh5x.com/gpsinfo/BR-304%20user%20manual.html

I'm pretty sure that guy will have RS232 signals. My rules of thumb:

  • if it has a connector meant for external connections (DB9, RJ-x, etc) it's most likely RS232
  • if it's a module with pins/pads, it's probably TTL (could be 3.3V or 5V)
  • if it has wires with no connector or an internal-type connector (e.g. header), it's probably TTL (especially if it's bare-board), but it could be RS232 (if it's got an enclosure, like the Garmin GPS18LVC)
    Those aren't absolute rules, but they are a pretty good first order approximation.

Since the GPS are powered by 5vdc, is there much chance the RS-232 voltages could get substantially higher than 5vdc?

Yep - the MAX232 is basically a charge pump voltage doubler and inverter, so it gets +10V and -10V from a +5 rail. Your GPS may have one inside.

-j

Thanks for the info Jason - Here is the CIV-17 interface I'm using with my ICOM rigs. Would you please take a look at it?
http://www.qsl.net/g3vgr/civ.html
Since I'm only looking at the RX pin (GPS TX), is the total circuit needed?

Looking at just the circuit from db9, pin 2 to 2N2222 collector, out base thru 4.7K resistor to tip - that's basic circuit? of course put +5vdc thru the 4.7K resistor to the collector.

Is that all the circuit would need to change the GPS RS-232 to required Arduino TTL?

Thanks again to all for taking time to help,

Ken H.
[edit]I just breadboarded that circuit and it works like a champ!!! the correct NEMA sentences are printing nicely right there
THANK YOU!!! to all that helped.
[/edit]

Yeah, that circuit is what I generally refer to as the "transistor trick". It steals voltages from elsewhere (the handshake lines in this case) to get RS232 voltages, and uses the transistor to invert them.

The transistor trick is used successfully in lots of places, but it can be problematic. The most obvious problem is when you try to connect 2 devices that are both trying the transistor trick - nobody is really supplying RS232 voltages, so there's no communication. Full duplex can also be a problem.

Even though it's a bit more complex, I prefer to stick with a MAX232 circuit whenever I can - it always works.

Congrats on the success!

-j

You are right Jason - I found the transistor circuit several yrs ago, built it and IT WORKED!! Later I read about the MAX232 chip, even got one as a sample - just never got around to building the circuit since the transistor works so well - even thru USB to serial adapters I have.

This time I just took a 2N2222 and 2 of the 4.7K resistors, stuck them on the breadboard using Vcc from the Arduino. That sure works slick. Not sure I'll ever take it to an enclosure - I've got 3 (4?) GPS laying around. I just wanted to learn something - and I did.

Thank you for your help - Decatur seems like "back home" almost - I went to school at Florence back when it was FSC, then FSU, now UNA.

73 de Ken H>