bigengineer

I got my GPS module working with some filtering for the right lines. I program mainly by trial and error so the code might not be elegant or by the book. But it works. I started with the softserial example from Heather: http://www.arduino.cc/en/Tutorial/SoftwareSerial. I changed it here and there and made it to filter out a specific NMEA rule.

I was quite suprised when I discovered how easy it is to use avr-libc library.

CosineKitty

This is a good example of software serial I/O. I did spot something potentially very inefficient:

for (int i=0;i<strlen(messageline);i++)

this causes strlen() to be called on each iteration, counting how many characters there are in the string. If the string is very short, it does not matter, much, but as the string gets longer and longer, the amount of CPU time consumed by the loop goes up as the square of the number of characters. This is because there are N characters, each strlen takes order(N) time, and there are N loops, resulting in order(N*N). Instead, I would recommend this:

for (int i=0; messageline != '\0'; i++)

Daniel

This is a great contribution. I have been trolling the forum lately looking for Arduino> Hardware info to use in teaching, as my students always want to hook up the oddest things... In that light, I added your GPS code example to the Playground. Thanks.

bigengineer

This is a great contribution. I have been trolling the forum lately looking for Arduino> Hardware info to use in teaching, as my students always want to hook up the oddest things... In that light, I added your GPS code example to the Playground.

This is a very simple program but it is exactly the kind of program that is useful for me to get started. So, now I finally managed to make up something myself I had to contribute.

This is a great contribution. I have been trolling the forum lately looking for Arduino> Hardware info to use in teaching, as my students always want to hook up the oddest things... In that light, I added your GPS code example to the Playground.

This is puzzling ... in char2string() you tie off messageline with a 0. So why are we adding code to do the byte-banging of the string out tha already exists in the Serial core library? Why not just replace this code

mopowered

Thanks bigengineer and everyone else - I now have my EM406A talking to my Arduino Decimilla (4 wires, 5V/GND/TX/RX) using the code posted. I even tried all three examples of how to print the resulting strings to the Debug Window. My problem is that they all look like this:

These are printing ALL strings BTW. I understand that the conversation from the GPS unit is 4800 baud (hence the 4800 delays) and received thru Digital pin 6 on the Arduino. I also understand that the strings are output via the onboard debug serial lines (hardware uart that the USB FTDI chip uses - with the following in Setup(): Serial.begin(9600); ) hence them showing up at 9600 baud in the Serial Debug Monitor. I get the same garbage if I set the output to 4800 via Serial.begin(4800); in Setup();

Daniel

I agree with Cheater: looks like you have the commas in between the data, but not the data in corect form. Check to see if your data needs to go through an inverter like the 74LS04 (sometimes you need to invert RS232 TTL-level data in order to read it), and also check the serial port speed in pull-down menu in the serial monitor window.

void setup() { pinMode(rx,INPUT); pinMode(tx,OUTPUT); digitalWrite(tx,HIGH); digitalWrite(13,HIGH); //turn on debugging LED SWprint('h'); //debugging hello SWprint('i'); SWprint(10); //carriage return Serial.begin(9600); // this is used to echo what is read from the GPS out the USB->SerialDebugMonitor}

mopowered

Must be a problem in the SoftwareSerial read routine because I got the exact same results (unreadable nmea-like strings) with the following code - here I'm only using the software serial for the read part and the hardware uart for the write results to debug console. You'll notice in the main loop() the same results come from either the readbyte/printbyte method or readline/printline method (commented out). I also changed the name of the char2string function to getLine: