Pages: [1] 2 3   Go Down
Author Topic: Can't read data from GPS module  (Read 3511 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm setting up an arduino system for a "space balloon" that's going to be launching soon(I'm working on this as a project with an engineering club at my University).  I'm using the arduino to log data from sensors onto an SD card.  However, one sensor that I cannot get it to take in data from is the GPS. 

In the payload we have the "Byonics GPS4" GPS module, with the serial data output from it connected to both the Arduino and a HAM radio transmitter. 

The GPS works just fine, I can see the location of it using aprs.fi from the HAM radio broadcast. 

However, I cannot get the data from it using the arduino. 

The GPS module outputs 4800 baud NMEA 0183 serial.  From what I've read, that uses RS-232 electrical signalling. 

As the GPS runs off of 5v power, it puts out a signal that goes from -5v to 5v(RS-232 uses the negative voltage, rather than a 0 voltage).  Using a diode and a pull-down resistor I changed the -5v signal to 0v.  I tested that on an oscilloscope, and it does work. 

Now, I ran that into the RX1 port on my Arduino Mega board, but the data was garbled looking.  Using the "Mega multple serial test" example code(slightly modified), I ran the GPS into the computer through USB.  Here is what that looked like:

(the receiving serial is set to 4800 baud, line breaks are inserted after every 100 chars received)

The GPS data is supposed to look like: "$GPGGA,201548.000,3014.5529,N,09749.5808,W,1,07,1.5,225.6,M,-22.5,M,18.8,0000*78" (example data from TinyGPS library)

I also saw some information saying that TTL and RS-232 use opposite signalling for logical 1 and 0.  That is, one uses +v as a logial 1, the other uses +v as a logical 0. 

So, I added a not gate into the circuit, taking in the 0v and 5v signal (which I convert from -5v and 5v), and inverting it to a 5v an 0v signal.  I verified that this was working with an oscilloscope.  I fed this into the arduino, and got nothing.  Rather than garbled data, I got no data.  No characters coming in through the arduino's RX line. 

So, I'm wondering what's going on here.  Should I be doing some software transformation to the garbled looking data that I'm receiving?  Is there something else I need to do to convert NMEA 0183 serial to TTL serial? 

Any help you can offer would be really appreciated. 
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A MAX232 chip will solve all of your problems. Just whacking off the -5V signal isn't enough.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately, I don't have one of those, and I don't have time to get one. 

Is there any way to do this in software, or by using more general purpose hardware components? 
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you using one of those TinyTrak units to convert the RS232 data to the radio?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using this: http://www.byonics.com/mt-rtg

but with the Bionics GPS4 (for higher altitude readings). 
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can invert the rs232 to ttl like below just using two resistors and an NPN transistor.

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11649
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

An opto coupler might provide another way to level-convert - without an oscilloscope its hard to know what's happening.  I'm worried by you saying "diode and pulldown resistor" when you should be saying diode-clamp...  Your circuit schematic?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The rs232 signal is already being inverted.  

The circuit I have is: output from the gps goes to a diode, oriented so current is not allowed to flow towards the gps(to get rid of -5v output).  Then, on the output of this diode, both a 20k resistor to ground is connected(so when the gps output goes to -5v, this line will just go to 0v), and a NOT gate(well, technically a NAND gate with both inputs connected together).  The output from this NOT gate goes to the arduino mega RX1 pin.  

On a digital oscilloscope I have connected the gps output and the converted signal(both at the same time).  The conversion is working as intended, with a 5v gps signal being converted to a 0v signal into the arduino, and a -5v gps signal being converted to a 5v signal into the arduino.  Both waveforms look the same, except for the voltage change.  

Isn't that what needs to be done to convert rs232(at 5v) to TTL serial?  I mean, it's not working, so I guess that isn't actually fully correct somehow.  Any tips on what I could be doing wrong here? 

I can post a shot of the oscillosope output if that would help, but the signal is already being inverted without a problem.  
« Last Edit: October 09, 2011, 08:44:53 am by CompWiz17 » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just found a challenge with the Serial.print() routine and data size. Give this a try and see if it echos your GPS data ok.
Code:
uint8_t inByte;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(4800);
}
void loop()
{
  if(Serial1.available())
  {
    inByte = Serial1.read();
    if(inByte != 0xFF) Serial.print(inByte);
  }
}

Serial1.available() may return a non-zero value, even tho there is nothing in the receive buffer. That is why the "if(inByte != 0xFF)".

Insure there are two wires from the RS-232 connector to the Arduino. One is signal, and the other is ground. Check to insure each is correct, especially ground.
« Last Edit: October 09, 2011, 10:50:34 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the tip, I'll give that code a try. 

And, that is exactly how it's hooked up.  ground and rs232 lines connected between gps and the arduino. 
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought the wires and connection would be good. Ham people rarely miss anything like that.

Let me know about the code. You did not post your code, so I couldn't see if you had used a char data type. In another topic, it had caused the compiler to assign a 32 bit value. Instead of returning -1 as 0xFF (8 bit), it was being returned and displayed as 0xFFFFFFFF (32 bit) using Serial.println(). That is why the uint8_t data type instead of a char on inByte.

This is the topic:
http://arduino.cc/forum/index.php/topic,74835.0.html

Add: Insure your baud rate at the lower right corner of the IDE serial window matches the baud rate set for Serial.begin(), or it will have that garbled appearance also.
« Last Edit: October 09, 2011, 02:20:32 pm by SurferTim » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Serial1.available() may return a non-zero value, even tho there is nothing in the receive buffer.
How?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 138
Posts: 5837
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Serial1.available() may return a non-zero value, even tho there is nothing in the receive buffer.
How?
My client.available() returned 1024 with nothing in the receive buffer. It was called a bug.

Mine is accurate, but another user was reporting the Serial1.available() was returning non-zero values and when the Serial1.read() was done, it returned 255 (-1) "no characters available". ?? That is why I said "may".

Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And, that is exactly how it's hooked up.  ground and rs232 lines connected between gps and the arduino. 

Maybe I mised something, but where is the GPS rs232 being converted into TTL that the arduino usually uses?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My client.available() returned 1024 with nothing in the receive buffer. It was called a bug.

Mine is accurate, but another user was reporting the Serial1.available() was returning non-zero values
Do you have a link to this other report?

The client instance you refer to is an instance of Client, and its available() method is known to have issues.

The Serial(n) instances are instances of the HardwareSerial class, and its available() method does not work the same way, and is not known to have any bugs.
Logged

Pages: [1] 2 3   Go Up
Jump to: