This problem has been driving me nuts for most of the day, because i can't find any logical reason for it to do what it does.
summary of the problem: I have a project that is acting as a sensor node with gps location, LCD GUI, SD logging, and xbee networking. I had everything working except the LCD in the last program revision. Upon adding the LCD GUI programming in the form of a subroutine LCDmain() to the main loop(), I start losing data from the GPS. Namely the last 5-10 characters of the GPRMC sentence. When I comment out the LCDmain() subroutine the program works again, even if i also run it once in the setup() section. Im running the baud rate at 57600 right now, but it does the same thing at 9600.
The incorrect string:
$GPRMC,232005.000,A,42xx.2558,N,071xx.1477,W,0.00,208.06,240$GPGGA,232006.000,42xx.2558,N,071xx.1477,W,1,10,0.87,57.4,M,-33.2,M,,*65
$GPRMC,232006.000,A,42xx.2558,N,071xx.1477,W,0.02,208.06,240
The correct string:
$GPGGA,232803.000,42xx.2596,N,071xx.1464,W,1,10,0.87,61.1,M,-33.2,M,,68
$GPRMC,232803.000,A,42xx.2596,N,071xx.1464,W,0.06,208.06,240614,,,A72
The GPS Sentence Subroutine:
//=======================================================================================================
//Get the GPGGA or GPRMC sent
void Get_Sent()
{
if (Serial1.available()>0) //Is there Data waiting from the GPS?
{
CharIn = Serial1.read(); //Retrieve the character
Serial.print(CharIn); //Print the character to the serial monitor **for troubleshooting purposes**
if ((CharIn == '
The Main Loop():
//=======================================================================================================
//Main loop
void loop()
{
while ((Serial.available()>0)||(Serial1.available()>0)||(Serial2.available()>0)||inProc)
{
Serial_to_GPS();
Get_Sent();
Xbee_cmd_get();
}
// Serial.print("yes");
Extract_Sent();
print_time();
send_data(Cmd_Check());
LCDmain();
Ready_Data();
// loop_timer();
if ((minute()%2 ==0) && (second() == 0))
{
En = true;
}
}
The LCDmain() code is too large at the moment to post, has very few comments, and, at this point, has no interaction with any of the other parts of the program.) || (InSent != NMEAsentLayout)) //If there is a new sentence incoming, or a sentence already in transmission ($ designates the start of the sentence)
{
if (CharIn == '
[/code]
The Main Loop():
§_DISCOURSE_HOISTED_CODE_1_§
The LCDmain() code is too large at the moment to post, has very few comments, and, at this point, has no interaction with any of the other parts of the program.) //If this is the beginning of a new sentence
{
inProc = true; //inProc locks the serial coms while loop
// Serial.println("inProc = true"); //for Troubleshooting
InSent = ""; //Clear the incoming sentence string
// Serial.print("`"); //for Troubleshooting
}else if (CharIn == '') //If the incoming character is a '' indicating the end of the sentence
{
if (InSent.substring(0,5) == SentPrefA) //if the first five letters of the sentence are "GPGGA"
{
GgaSent = InSent; //move the finished sentence into the GPGGA sentence String for later parsing
// Serial.println(GgaSent); //for Troubleshooting
// Serial.println("~"); //for Troubleshooting
}else if (InSent.substring(0,5) == SentPrefB) //if the first five letters of the sentence are "GPRMC"
{
RmcSent = InSent; //move the finished sentence into the GPRMC sentence String for later parsing
// Serial.println(RmcSent); //for Troubleshooting
// Serial.println("~"); //for Troubleshooting
}
InSent = NMEAsentLayout; //put dummy sentence into the incoming sentence string
inProc = false; //unlock the serial coms while loop
// Serial.print("~"); //for Troubleshooting
// Serial.println("inProc = false"); //for Troubleshooting
}else if (InSent.length()<= 100) //If the sentence has not gotten too long(indicating a problem)
{
InSent.concat(CharIn); //concatonate the character to the incoming sentence string
// Serial.print(CharIn);
}else
{
InSent = NMEAsentLayout; //put dummy sentence into the incoming sentence string
inProc = false; //unlock the serial coms while loop
// Serial.println("inProc = false"); //for Troubleshooting
}
}else //if ther is data incoming, and it is not the start of a new sentence and there is no sentence currently in transmission
{
// Serial.println(" Junk"); //for Troubleshooting
// Serial.print(CharIn); //for Troubleshooting
}
}
}
[/code]
The Main Loop():
§_DISCOURSE_HOISTED_CODE_1_§
The LCDmain() code is too large at the moment to post, has very few comments, and, at this point, has no interaction with any of the other parts of the program.