Forum Replies Created
-
AuthorPosts
-
joeyMember
ah, pserial.println works!
joeyMemberOk in attempting to figure out how to program the GPS I realized the GPS wasn’t locking on. Turns out resetting the datum was the key.
Handy setup strings for the EM-406A:
* NMEA 8N1 various baud rates:
$PSRF100,1,1200,8,1,0,*2D
$PSRF100,1,2400,8,1,0,*28
$PSRF100,1,4800,8,1,0,*22
$PSRF100,1,9600,8,1,0,*21
$PSRF100,1,19200,8,1,0,*14
$PSRF100,1,38400,8,1,0,*11
Debug On:
$PSRF105,1,*3E
Debug Off:
$PSRF105,0,*3F
Select WGS84 Datum:
$PSRF106,21,*0FNow your sketch works but mine doesn’t. Any idea on how to display debug statements? e.g. Serial.println
joeyMember@Michael wrote:
I don’t think it will display anything until some data is received.
Did you properly configure the em406 to only output RMC and GGA sentences?
No I didn’t. I figured that for diagnostics, too much would be better than none at all. I guess I can try that.
joeyMember@Michael wrote:
Hi guys, sorry for the slow response. I’m on vacation out of the country and only have limited net access.
Bottom line is that you must use polling serial comm provided by tvout. The project in my blog shows that I successfully read gps info and overlaid it. But you can’t read too much data using the polling approach. I configured my em406 gps to emit only the rmc and gga sentences. And my gps is only 1Hz. Joey, what doesnt work?
I have the same GPS. If I load the sketch on VE, even without the GPS, it doesn’t display (lights are, nobody is home, nothing outputted). I suspect the sketch is just stopped somewhere but since I can’t see the serial output for debugging. If I load some of my other sketches they do run and display. Suggestions?
joeyMemberThe provided sketch doesn’t run even if it’s just the VE and the Arduino. I did retrofit my code to match it and had the same results. It’s also harder to debug since I can’t see the output on the serial console.
joeyMemberfwiw, I found tinygps and rewrote the program using it. It uses newsoftserial too so the interrupts are still an issue.
// This is an example of how to always present your callsign and other goodies on a VE
// Note that there is no known way to display the degree symbol as the char chart is different
// joey@stan4d.net
// Make sure to install newsoftserial and tinyGPS from Mikal Hart
// http://arduiniana.org/libraries/NewSoftSerial/
#include
#include
#include
#include
// Use pins 4 and 5 to talk to the GPS. 5 is the TX pin, 4 is the RX pin
// I had to unsolder the jumpers and rewire the GPS Sheild to avoid pin 2
// pin 2 is in use by the VE
// Create an instance of the TinyGPS object
const int RXPIN=5;
const int TXPIN=4;
TinyGPS gps;
NewSoftSerial uart_gps(RXPIN, TXPIN);
// Set the GPSRATE to the baud rate of the GPS module. Most are 4800
// but some are 38400 or other. Check the datasheet!
const int GPSBAUD=4800;
// declare the GPS variables
char charTmp[10] = "";
char charTime[6] = "00:00";
char charDate[11] = "00/00/0000";
char gpsCoords[15] = "";
char gpsAlt[6] = "0000M";
// This is where you declare prototypes for the functions that will be
// using the TinyGPS library.
void getgps(TinyGPS &gps);
TVout tv;
char messageTop[96] = "";
char messageBottom[96] = "";
char messageLastline[96] = "";
const char callsign[] = "NV0N";
//TMP36 Pin Variables
const int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade
//(500 mV offset) to make negative temperatures an option
char charTemp[3] = ""; //the char representation of the float for temp
void setup() {
tv.begin(0);
// the overlay code is somehow conflicting on interrupts
// initOverlay();
tv.select_font(font6x8);
tv.fill(0);
// connect to the serial terminal at 9600 baud
Serial.begin(9600);
// connect to the GPS at the desired rate
uart_gps.begin(GPSBAUD);
// prints title with ending line break
Serial.println(" ...waiting for lock... ");
}
// Initialize ATMega registers for video overlay capability.
// Must be called after tv.begin().
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}
void loop() {
while(uart_gps.available()) // if there is data on the RX pin...
{
int c = uart_gps.read(); // load the data into a variable...
if(gps.encode(c)) // if there is a new valid sentence...
{
getgps(gps); // then grab the data.
}
}
// temperature
float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor
temperature = (((temperature - .5) * 100)*1.8) + 32; //converting from 10 mv per degree wit 500 mV offset
// setup the messages for output on the tv
// clear at start of loop
sprintf(messageTop, "");
sprintf(messageBottom, "");
sprintf(messageLastline, "");
//assemble top message
strcat(messageTop,callsign);
// assemble bottom message
strcat(messageBottom,charTime);
strcat(messageBottom," ");
strcat(messageBottom,charDate);
strcat(messageBottom,"Z ");
itoa(int(temperature),charTemp,10); // sprintf fails so we use this
strcat(messageBottom,charTemp);
strcat(messageBottom,"F");
// assemble 2nd bottom meessage
strcat(messageLastline,gpsCoords);
// write out to TV
tv.select_font(font6x8);
tv.print(0,0, messageTop);
// Serial.print("messageTop=");
// Serial.println(messageTop);
// the 4x6 font is awefully small. I thought of scrolling but that's too distracting.
// right now it's a bit small to read.
tv.select_font(font4x6);
tv.print(0,75, messageBottom);
Serial.print("messageBottom=");
Serial.println(messageBottom);
tv.print(0,85, messageLastline);
Serial.print("messageLastline=");
Serial.println(messageLastline);
}
/*
* getVoltage() - returns the voltage on the analog input defined by
* pin
*/
float getVoltage(int pin){
return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}
// The getgps function will get and print the values we want.
void getgps(TinyGPS &gps)
{
// To get all of the data into varialbes that you can use in your code,
// all you need to do is define variables and query the object for the
// data. To see the complete list of functions see keywords.txt file in
// the TinyGPS and NewSoftSerial libs.
// Define the variables that will be used
float latitude, longitude;
// Then call this function
gps.f_get_position(&latitude, &longitude);
// You can now print variables latitude and longitude
Serial.print("Lat/Long: ");
Serial.print(latitude,5);
itoa(int(latitude),gpsCoords,10); // sprintf fails so we use this
strcat(gpsCoords,".");
int floatTmp = abs((latitude - (int)latitude) * 100);
if (floatTmp < 10 ) {
strcat(gpsCoords,"0");
itoa(floatTmp, &gpsCoords[strlen(gpsCoords)], 10);
}
else {
itoa(floatTmp, &gpsCoords[strlen(gpsCoords)], 10);
}
strcat(gpsCoords,", ");
Serial.print(", ");
Serial.println(longitude,5);
itoa(int(longitude),charTmp,10); // sprintf fails so we use this
strcat(gpsCoords, charTmp);
strcat(gpsCoords,".");
floatTmp = abs((longitude - (int)longitude) * 100);
if (floatTmp < 10 ) {
strcat(gpsCoords,"0");
itoa(floatTmp, &gpsCoords[strlen(gpsCoords)], 10);
}
else {
itoa(floatTmp, &gpsCoords[strlen(gpsCoords)], 10);
}
strcat(gpsCoords," ");
// Same goes for date and time
int year;
byte month, day, hour, minute, second, hundredths;
gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
// Print data and time
Serial.print("Date: ");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(day, DEC);
Serial.print("/");
Serial.print(year);
Serial.print(" Time: ");
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.print(second, DEC);
Serial.print(".");
Serial.println(hundredths, DEC);
itoa(int(hour),charTime,10); // sprintf fails so we use this
strcat(charTime,":");
itoa(int(minute),charTmp,10); // sprintf fails so we use this
strcat(charTime, charTmp);
itoa(int(month),charDate,10); // sprintf fails so we use this
strcat(charDate,"/");
itoa(int(day),charTmp,10); // sprintf fails so we use this
strcat(charDate, charTmp);
strcat(charDate,"/");
itoa(int(year),charTmp,10); // sprintf fails so we use this
strcat(charDate, charTmp);
// Serial.print("gpsCoords=");
// Serial.println(gpsCoords);
// Here you can print the altitude and course values directly since
// there is only one value for the function
Serial.print("Altitude (meters): ");
Serial.println(gps.f_altitude());
int altitude = int(gps.f_altitude());
itoa(altitude,gpsAlt,10); // sprintf fails so we use this
strcat(gpsAlt,"M");
// XXX there is some sort of compiler bug here. This adds it to gpsCoords not gpsAlt
// Serial.print("gpsCoords2=");
// Serial.println(gpsCoords);
// Same goes for course
Serial.print("Course (degrees): ");
Serial.println(gps.f_course());
// And same goes for speed
Serial.print("Speed(kmph): ");
Serial.println(gps.f_speed_kmph());
Serial.println();
// Here you can print statistics on the sentences.
unsigned long chars;
unsigned short sentences, failed_checksum;
gps.stats(&chars, &sentences, &failed_checksum);
//Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
//Serial.println(); Serial.println();
}
joeyMemberSo with some soldering I got the stack to work but am having an issue with interrupts.
The newsoftserial uses int 0 – 4 which conflicts with
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}Is there anyway to change these interrupts?
joeyMemberlooks like the VE and the GPS Shield both share D2. I can fix that on the GPS shield so off to the workbench I go.
joeyMemberI found two possible solutions that I’ll try later today.
1) I’m using soft serials so I could potentially just change the soft serial ports!
2) If that fails I found the docs to hook my GPS directly to the board. I could try this and hook it to the VE.
J
joeyMember@Michael wrote:
I have accomplished white letters on a black bar at the bottom of the screen. Would a black bar at the bottom and top of the screen solve your problem?
That will work too!
If you can tell me what I need to solder, and where, the board is simple enough that I should be able to do it without a problem.
Joey
-
AuthorPosts