Hi all,
Im having a bit of trouble getting the SUP500F receiver to work continually.
Its very strange in fact because it works sometimes, then it just stops working using the same code.
For instance, last night i was finally able to read the NMEA data stream using
http://www.sparkfun.com/tutorial/GPSQui … ng_v12.pde.
I altered the code a bit as below and loaded it to the Arduino. After which i was not able to read the gps data at all, not even after loading the example code again. The strange thing is, when i woke up this morning the example code worked, then i loaded my code and it stopped working.
#include <string.h>
#include <ctype.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#define RXPIN 3
#define TXPIN 2
#define GPSBAUD 9600
// analog inputs
int acc1 = 0;
int acc2 = 1;
int acc3 = 2;
int sensor1 = 3;
int sensor2 = 4;
int sensor3 = 5;
// digi
int ledPin1 = 13;
int ledPin2 = 12;
// vars
int ok = true;
// log format
// datetime,lat,long,altitude,direction(degrees),speed,acc_x,acc_y,acc_z,sensor1,sensor2,sensor3,vidFrame
TinyGPS gps;
NewSoftSerial nss(RXPIN, TXPIN);
void getgps(TinyGPS &gps);
void setup(){
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
Serial.begin(115200);
nss.begin(GPSBAUD);
}
void loop(){
while(nss.available()){ // While there is data on the RX pin...
// write gps data
int c = nss.read();
if(gps.encode(c)){
getgps(gps);
ok = true;
}
else{
fakeGPS();
ok = false;
}
// write sensor data
AnalogInputs();
// video frame
Serial.print("0");
// linefeed
Serial.println("");
// toggle LED
status_LED();
}
}
void status_LED(){
if(ok){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
}
else{
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin1, LOW);
}
}
void fakeGPS(){
// time
Serial.print("2010");Serial.print("-");Serial.print("01");Serial.print("-");Serial.print("01");Serial.print(" ");
Serial.print("12");Serial.print(":");Serial.print("01");Serial.print(":");Serial.print("01");Serial.print(".");Serial.print("01");Serial.print(",");
// lat long
Serial.print("0.0"); Serial.print(",");
Serial.print("0.0"); Serial.print(",");
// altitude
Serial.print("0.0"); Serial.print(",");
// direction
Serial.print("0.0"); Serial.print(",");
// speed
Serial.print("0"); Serial.print(",");
}
void getgps(TinyGPS &gps){
// get gps data
// time format = '2007-03-04 01:14:19.47'
float latitude, longitude;
int year;
byte month, day, hour, minute, second, hundredths;
gps.f_get_position(&latitude, &longitude);
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
// time
Serial.print(year, DEC);Serial.print("-");Serial.print(month, DEC);Serial.print("-");Serial.print(day, DEC);Serial.print(" ");
Serial.print(hour, DEC);Serial.print(":");Serial.print(minute, DEC);Serial.print(":");Serial.print(second, DEC);Serial.print(".");Serial.print(hundredths, DEC);Serial.print(",");
// lat long
Serial.print(latitude,5); Serial.print(",");
Serial.print(longitude,5); Serial.print(",");
// altitude
Serial.print(gps.f_altitude()); Serial.print(",");
// direction
Serial.print(gps.f_course()); Serial.print(",");
// speed
Serial.print(gps.f_speed_kmph()); Serial.print(",");
}
void AnalogInputs(){
// accelerometers
Serial.print(analogRead(acc1));Serial.print(",");
Serial.print(analogRead(acc2));Serial.print(",");
Serial.print(analogRead(acc3));Serial.print(",");
// sensors
Serial.print(analogRead(sensor1));Serial.print(",");
Serial.print(analogRead(sensor2));Serial.print(",");
Serial.print(analogRead(sensor3));Serial.print(",");
}
below is the setup.
http://img821.imageshack.us/img821/1804 … 8small.jpg
any ideas or hints?
Thanks!!