Go Down

Topic: Parallax GPS Smart Mode (Read 2075 times) previous topic - next topic

MRLindstrom

Mar 12, 2010, 10:37 pm Last Edit: Mar 12, 2010, 10:39 pm by MRLindstrom Reason: 1
I've looked over the GPS example where it is using the RAW data, but I am building something that would make better use of the "Smart Mode."  Right now all I am trying to do is read from the GPS to see if the data is valid.  From my reading what needs to be done to get that data is send:

!GPS followed by a byte of data containing the equivalent of a 1 in decimal.

This is straight from the manual:

Code: [Select]
To send a command to the GPS Receiver Module, the user must first send the header string, which is "!GPS" without the quotes, followed by the specific command byte of their choice.

Code: [Select]
Each command consists of a single byte in hexadecimal. Depending on the command, a specific number of data bytes will be returned.

and here is the command I am using:

Code: [Select]

Cmd     Constant     Description     Returned     Bytes     Variables (1 Byte Each Unless Noted)
0x01 | GetValid | Check validity of data string | 1 | 0 = Not Valid, 1 = Valid


Here is the code I am trying to use:

Code: [Select]
int incomingByte = 0;

void setup() {
 Serial.begin(4800);
}
void loop() {
 if (Serial.available() > 0) {
   incomingByte = Serial.read();
   Serial.println(incomingByte);
   Serial.flush();
 }
 Serial.print("!GPS");
 Serial.write(1);
}


I have both the TX and RX pins on the Arduino (Duemilanove) connected to the SIO port on the Parallax GPS Receiver.

Here is an example of the output I am getting right now:

Code: [Select]
!GPS
71
!GPS
80
!GPS
83
!GPS
1
!GPS
51
!GPS
51
!GPS
13
!GPS
10
!GPS
33
!GPS
71
!GPS
80
!GPS
83
!GPS
1
!GPS
55
!GPS
49
!GPS
13
!GPS
10
!GPS
33
!GPS
71
!GPS
80
!GPS
83
!GPS
1
!GPS
56
!GPS
48
!GPS
13
!GPS
10
!GPS
33
!GPS
71
!GPS
80
!GPS
83
.
.
.


As you can see from the manual clipping above, that command should only return a single byte of data... however, it seems to continuously send data once I issue the command.  If I take out the last 2 lines of code the GPS does not send any data whatsoever.

Anyone have any ideas?

MRLindstrom

I think part of the problem is that since the GPS module sends/receives on the same pin, any commands that I issue are read by the arduino RX pin (since they are both the TX and RX pins are connected to the same pin on the GPS).  Is there a way I can get around this without having 2 serial ports?

PaulS

#2
Mar 12, 2010, 11:02 pm Last Edit: Mar 12, 2010, 11:02 pm by PaulS Reason: 1
You are reading and writing on the same serial port, so you are echoing what you've written, as well as anything read from the GPS.

You'd be much better off connecting the GPS to another set of pins, and using NewSoftSerial to talk to it.

MRLindstrom

Thank you for turning me on to that NewSoftwareSerial it seems very useful.  I guess my next question is, how do i get Serial.write(1) to send that one has a hex 1 and not the ascii equivalent of 1?

PaulS

The NewSoftSerial library has print and write methods, just like the HardwareSerial class. The write method simply streams the byte-sized variable's bits to the serial port.

The print methods default to converting the arguments to strings, but the write method does not.

MRLindstrom

#5
Mar 15, 2010, 07:25 am Last Edit: Mar 15, 2010, 07:28 am by MRLindstrom Reason: 1
Still having no luck with this... I tried the NewSoftSerial route... but like I had said before, since the GPS only has a single I/O port whatever I write on one serial port will inevitably show up on the other.

I've tried, with some different code, to send "!GPS" followed by a 1 and I attached an LCD so I could display the results of what was being read on the serial port without echoing more text.

The results are as follows:

Received: 33   (! in ascii)
Received: 71   (G in ascii)
Received: 80   (P in ascii)
Received: 83   (S in ascii)
Received: 13   (Carriage return in ascii?????) <--- shouldn't this be a 1?
Received: -1
Received: -1
Received: -1
Received: -1

I don't understand where that 13 is coming from... here is the code I am now using:

Code: [Select]

#include <LiquidCrystal.h>

boolean requested = false;
int byteRead = 0;

LiquidCrystal lcd(12, 11, 10, 4, 5, 6, 7);

byte one = B00000001;
byte zero = B00000000;
byte time = B00000011;

void  setup() {
 Serial.begin(4800);
 lcd.begin(16,2);
 lcd.clear();
}

void loop() {
 while (!requested) {
   Serial.print("!GPS");
   Serial.write(one);
   requested = !requested;
 }
 while (requested) {
   lcd.clear();
   for (int i=0; i < 9; i++) {
     lcd.setCursor(0, 0);
     byteRead = Serial.read();
     lcd.print("Received: ");
     lcd.print(byteRead, DEC);
     delay(1000);
   }
   lcd.clear();
   Serial.flush();
   requested = !requested;
 }
}

tcharron

Try using "Serial.print(one, BYTE)" instead of the write command that you're using.  "write" is a private function in the most recent version of NewSoftSerial.  You should download the newest version.

Instead of your loop through 8 bytes, why not use this:

Code: [Select]

 while (requested) {
   lcd.clear();
   while (Serial.available()) {
     lcd.setCursor(0, 0);
     byteRead = Serial.read();
     lcd.print("Received: ");
     lcd.print(byteRead, DEC);
     delay(1000);
   }
   lcd.clear();
   requested = !requested;
 }


MRLindstrom

Getting this back in a never ending cycle:

33      !
71      G
80      P
83      S
13      CR
33      !
71      G
80      P
83      S
13      CR
33      !
71      G
80      P
83      S
13      CR

MRLindstrom

Ok, I realized a big mistake... I failed to clear the LCD between re-printing the received values.

As such, when I thought 13 was being read, it was really a 1 being read with the 3 being left over from the 83 written to the LCD before it.  

I still, however, cannot get the GPS module to return any values.

MRLindstrom

For anyone else that needs the information.

When the TX pin on the Arduino goes into its idle state, it will assert itself HIGH.  By doing this, it will inhibit the GPS from ever responding.

To solve this issue, you need to connect a diode as follows:
1. Connect the TX Pin of the Arduino the anode side of a standard 1N914 diode

2. Connect the RX Pin of the Arduino the cathode side of the diode

3. Connect the SIO Pin of the GPS to the cathode side of the diode

TX Pin -->|-- RX Pin ---- SIO on GPS

anode -->|-- cathode (diode)

---- (wire)

All credit for this goes to Mike Green of the parallax forums who can be found here:
http://forums.parallax.com/forums/profile.aspx?f=15&m=436519&p=1453

KenH

Have you looked at this thread?

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1267027090

It has some good info on GPS - I've got his info and wanting to do a GPS also.  I've got an engine I can use that puts out NEMA 0183 sentences.

Ken H>

MRLindstrom

#11
Mar 16, 2010, 07:08 pm Last Edit: Mar 16, 2010, 11:50 pm by MRLindstrom Reason: 1
Parsing through all of the NMEA strings takes a long time (processing wise).  That's not to say it's not possible... just very time consuming.  I have one project that makes use of the GPS tutorial here: http://www.arduino.cc/playground/Tutorials/GPS .  But, using the smart mode is way more convenient since the receiver is able to do all that work for you.

KenH

I was not able to get to the Parallax link - I'm not a member there.

Let me see if I understand what your are saying - the playground GPS tutorial receives all the strings from GPS, then picks the info desired making it a time consuming operation rather than sending a command for only info desired?

You are way ahead of me on GPS - The two GPS I have (Garmin and the other is just an engine/antenna combo) both start sending NEMA 0183 sentences on power up.  These sentences are ASIIC text that can be displayed on hyperterm - or other serial monitor.

I have posted a topic with my problems getting correct text to display via the Arduino - the NEMA 0183 sentences display nicely when read thru a standard COM port, but not thru the Arduino USB port.

Ken

ALIBE

hi just read your posting here

and in particular the
Quote
TX Pin -->|-- RX Pin ---- SIO on GPS


from reading what Mike Green described in the thread you provided, it seems that he is recommending. Cathode to be connected to Tx

so...is the below what you did.  
Quote
TX Pin --|<-- RX Pin ---- SIO on GPS


Thanks for sharing - it is going to help mein my project.


Go Up