GPS Serial Connection

All,
Thanks for taking the time to read my post. I am having trouble reading serial NMEA sentences from my handheld gps unit. All I ever get from either the hardware serial or software serial is gibberish as if I had the wrong baud rate. I have tried changing baud rate to no avail.

Can someone help guide me through what to check to make sure I am not losing my mind?

Thank you

MHR

Are you sure your GPS is in NMEA mode? Many/most GPS units have a (usually proprietary) binary mode in addition to NMEA.

What is your hardware configuration like? Did you try to tie the GPS connector directly to Arduino pins 0 and 1 without the appropriate TTL-rs232 conversion? If so, hopefully you haven't burned any ports on the Arduino.

We need more data on your configuration to offer useful help...

-j

Yeah, I knew I'd need to fill in the info...so here it is.

Lowrance iFinder Handheld GPS set to 9600/NMEA. Confirmed via hyperterminal.
Arduino Diecimila - I have tried both GPS tutorials with the same result. 1st (thirty) trial(s) was with hardware serial (ports 0/1:rx/tx). 2nd go round was with software serial (ports 6/7:rx/tx). I have tried varying baud rate, com port parameters, gps baud rate, etc.

I shrank my code down to just read input & write output...same result.

Also, I have confirmed that my arduino does receive some signal, that if is disconnected, the signal is lost. This is not as if I am receiving nothing. If I use serial.print(data,DEC) I get values from 0-255, but when using serial.print(data,BYTE), the characters are in no logical string.

How do you mean without the "appropriate TTL-rs232 conversion"?

Thanks

MHR

GPS set to 9600/NMEA. Confirmed via hyperterminal.

That helps. (:

How do you mean without the "appropriate TTL-rs232 conversion"?

I should write an article and post it on my web page as often as this comes up (here and other places).

The RS232 electrical specification (actually there are several, but RS232C is the one most commonly targeted, and others you are likely to encounter are compatible with RS232C) defines "mark" and "space" as the signal levels. Mark is a logic high denoted by a voltage around -9V (somewhere between -9 and -15, IIRC). Space is a logic low denoted by a voltage level of +9V (again, there is a range specified).

Two important facts to pick up one: the levels are inverted logic, and the voltages are not TTL compatible.

The easiest way to deal with the conversion is to use a device that's commonly called an RS232 transceiver or level converter. Logically, it's an inverter (and that is the symbol usually drawn on the IC's datasheet). Electrically, it has -9V/+9V RS232 voltages on one side and 0-5V TTL voltages on the other (note there are also other voltages, like 3.3V). These devices are usually packaged with several of these converters, some going each direction, in a single IC. The perennial favorite MAX232 has two TTL-to-232 ports, and two 232-to-TTL.

Another way of dealing with this is to play some games with transistors, stealing appropriate voltages from the other end of the RS232 connection. Look at the original Arduino serial for an example. this method occasionally doesn't work to well - I've been bitten a time or two.

Anyway, if your GPS has a standard serial connector you need to set up a level converter. The MAX 232 is my favorite, look at the MAXSerial version of the Freeduino for an example circuit, or just google MAX232 for a sample circuit.

-j

Okay, kg4wsv, so you got me to thinking, I should be able to measure the voltage of the tx line. Easy enough...multimeter in hand...-5V?...what? It couldn't be. No way. Could it be the pinout that I have been using has been wrong? Swap GND & RX. VIOLA!!!

Solved! But still irritating that I needed to second guess pinouts on the internet...what that couldn't possibly be wrong!!!!

Not to make light of the info you sent my way...all good. What sort of equipment uses higher signal levels? Or rather why would I, hypothetically, want higher levels.

Thanks
MHR

RS232C uses the larger voltage swing. You'd want to use them for compatibility, and for longer runs (IIRC, RS232C can run 1500, that's fifteen hundred, feet at 9600 baud).

IIRC, another RS232 spec (or maybe a common abuse of the spec) uses 0V and -5V. The levels are inverted from TTL. Somehow this seems to be compatible with lots of RS232 ports. I want to say the Garmin GPS18 series do this, but I could be remembering wrong.

I find it extremely weird that you could hook it up directly and have it work.

Doh! I think I see what's happening now. Your device is probably using the 0V, -5V voltages. When you hooked it up correctly, RX on the Arduino saw 0V and -5V (i.e. always a logic low). By switching TX and GND, you effectively inverted the signal.

I'll bet if you ever managed to get a common ground between the two (e.g. run them both off the same power supply), it would stop working with the switched lines.

-j

Why the heck does it work flawlessly through hyperterminal if it is an inverted signal? Shouldnt I be seeing the same effects there?

Why the heck does it work flawlessly through hyperterminal if it is an inverted signal?

It's not inverted, it's an RS232 signal instead of a TTL signal. Your computer has the equivalent of a MAX232 built in.

Let me back up another step - which arduino are you using, and how is it connected to the GPS?

-j

Thanks for your help/incite. I appreciate it a lot.

Arduino Diecimilia USB - bought a week ago from S.F.

DB9 Pinout for GPS:
2/TX
3/RX
5/GND

Traditionally, I have GPS pin 2 connected to pin 0 on the Arduino, and GPS pin 5 to Arduino GND. this is the way that does not work.
When it is working I have GPS pin 2 connected to Arduino GND, and GPS pin 5 connected to Arduino pin 0.

OK, I'm sticking with my story - it's the -5V/0V RS232 signal, and it's effectively inverted by hooking it up backwards.

If you want to make it work "right" (e.g. you think you may want the Arduino to talk to the GPS to plot waypoints or something), hook it up through a MAX232.

-j

Thats cool. I will look closer at a MAX232, or possibly a different GOS reciever. This handheld hookup isnt exactly practical with the long wires and all.

Thanks again kg4wsv