LS20031 GPS to Orangutan with AVR

I am connecting the LS20031 GPS to an Orangutan328. I have tried some basic serial code to see if i am getting the ‘$’ arriving which suggests the GPS is transmitting to the controller OK.

I am now trying to get some smarter, full GPS reading code going. There is not much to choose from. TinyGPS doesn’t look right for me (I am a c, not c++ experienced person - and then only just! So it looked daunting).

I have been trying the WebBotLib which seems to have a pretty good NMEA GPS system, but I am having trouble getting that to run.

So I guess two directions here:

  1. Use a more appropriate GPS library - any suggestions and hopefully example code?

  2. (I think) I am very close to getting the WebBotLib going. I have had trouble with an apparent double definition of delay_ms but got around that, now I am just having trouble with the definition of the UART I think. When I define HW_UART it needs to get pointed to the UART, but I am not sure where to get that.

My code looks like:

#include <stdio.h>
// #include "uart.h"
// Following line to avoid double definition of delay_ms etc.
#define OrangutanTime_h
#include <pololu/orangutan.h>


#include "Sensors/GPS/gps.h" 
#include "Sensors/GPS/NMEA/gpsNMEA.h"
#include "sys/atmega328P.h"


double longitude;
double latitude;


int main()
{
	HW_UART* theUart = &UART;                                                    <-- problem line!!!!
	GPS_NMEA myGPS = MAKE_GPS_NMEA(&theUart,57600);
	// serial_set_baud_rate(57600);
	// uartSetBaudRate(UART0, (BAUD_RATE)57600);

	print("Hello");
	delay_ms(1000);

	
	while(1);
	{
	if( gpsNMEAprocess(&myGPS) ){
		// We have received something
				if(myGPS.info.valid){
				// And we have a satellite fix
					if( myGPS.info.changes.values.longitude &&
					myGPS.info.changes.values.latitude){
				// Longitude and latitude have been updated - so fetch the values 
				// NB It doesn't mean that the values have changed
					 longitude = myGPS.info.longitude;
					 latitude = myGPS.info.latitude;
					 // as a test - lets show the number of satellites we have on the LCD
					 clear();
					 print_long(myGPS.info.numSatellites);
					 print(" satellites");
			 		}
				}
		}
	}	


}

produces this error:

Build started 23.4.2011 at 22:00:50
avr-gcc -I"C:\Users\Barry\Documents\Barry\Orangutan\Projects\GPS…\Lib" -I"C:\Users\Barry\Documents\Barry\Orangutan\Projects\GPS…\Lib\WebBotLib" -mmcu=atmega328p -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -f
short-enums -MD -MP -MT GPS.o -MF dep/GPS.o.d -c …/GPS.c
…/GPS.c: In function ‘main’:
…/GPS.c:20: error: expected expression before ‘UART’
…/GPS.c:21: error: request for member ‘uart’ in something not a structure or union
make: *** [GPS.o] Error 1
Build failed with 2 errors and 0 warnings…

on the line: HW_UART* theUart = &UART;

I got this line of code from the WebBotLib manual page 142 with the sample code - defining a number of UARTS:

int i;
for(i=0;i<NUM_UARTS;i++){
HW_UART* theUart = &Uarts[i];
// You can now pass in ‘theUart’ as the reference
}

I have tried all different configurations with no luck. I think I need a real pointer to the UART … not the definition UART I am using

Any suggestions down either path??

Thanks in advance.

barry.

I’ve been using nmealib http://nmea.sourceforge.net/
It comes with some samples, look at the parser file example and in the code replace the txt file with your serial buffer. In the code your latitude and longitude is info.lat/100 and info.lon/100. It also comes with a documentation.
I’m assuming this is what you’re after, if you need help with it ask, although I’m using it on linux with the serial to usb adapter.

Thanks, I will look at that … but now I need to collect and assemble the string before parsing …

I have been trying the variant of TinyGPS off AVRFreaks which potentially reads the string as it comes in - but that does not use the Orangutan serial code and I am struggling with that … grrr. There is always a gap!

Barry

Hello.

You don’t have to use the Pololu AVR C/C++ Library or OrangutanSerial code. You can load any code you want on to an Orangutan. As long as it is valid AVR code that was compiled for the right processor and doesn’t make false assumptions about the connected hardware or clock speed, it should run fine.

The clocks on the Orangutans are all 20 MHz and this affects baud rate settings, so you probably have to tell that information to TinyGPS somehow to get it to work properly.

You can also pick and choose which parts of the Pololu AVR C/C++ Library you want to use. If you want to use OrangutanLCD but don’t want to use OrangutanSerial, then just try removing any line of your code that calls an OrangutanSerial function. (I think that would work, but there might be some linker problems if your other library tries to use the UART’s RX or TX ISRs. I would try it and see.)

As for your other problem: you commented out the line that includes “uart.h” so I think that would cause lots of problems on the line “HW_UART* theUart = &UART;”

Also please use “code” tags in future posts so that the code you post is more readable.

–David