The problem is that you get the ENTIRE string then parse it. This is not going to work well as you found out. Your CPU spends almost the entire time waiting for characters to come in slowly off the serial line. You are just waiting on bits and wasting CPU cycles
What you need to do is parse one character at a time. I bet your parser reads one character at a time from the string. Have it read one character at a time directly from the serial port. (Use a state machine. It will work for such a simple job as this) Yes if your CPU was MUCH faster your plan could work. But on some GPSes the data never has a break. You are trying to do ALL the work in the break but actually most of the down time when you should be working is between the characters. There is not a lot of work a finite state machine needs to do between characters, just move state based on a 'character class" table. I you ever studied this formally, what you are building here is a "lexer" not a parcer. The "Language" is not recursive and you never need to backtrack so it can be de-coded literally one character at a time. You DO really want the 1PPS to drive an interrupt. Thisway you just continue working on the data stream and don't wait for the PPS. When the PPS happens you do something QUICK. never do anything time consuming in the ISR or you will miss the next serial character. increment a seconds count and write two bytes the the LCD and exit On Sun, May 21, 2017 at 6:45 AM, Ben Hall <[email protected]> wrote: > Good morning all, > > A quick update for those interested on my Arduino code development for the > TruePosition boards. I've got Arduino code together than can read in the > serial stream, parse it, and display time, date, number of satellites, and > TFOM on a 2x16 LCD display. It does not do multiple screens, handle survey, > or display lat/long yet. > > What I'm having issues with is handling the 1 PPS. Ideally, I want to use > the 1PPS signal to trigger the display update. IE: > > void loop() > { > getSerialString() // uses serial.available to pull in the serial data > > parser() // this parses the data > > wait for 1PPS tick to go high > > if there has been a clock message, updateDispay() // update the display > } > > This works great when there is a just a clock message. But when there is a > clock message, an extstatus message, and a status message, it seems like it > is still parsing when the 1PPS tick comes in...so it will display seconds as > follows: 30, 31, 33, 34, 35, 36, 37, 39, etc... > > (If I don't wait for the 1PPS tick, it seems that my clock is one second > fast. I say "seems" to be fast, as the time agrees with an NTP clock on one > computer, but seems a half second slow per GPSCon's time display on the > Z3801. I think I need to put up the antenna and check against WWV.) > > I've got one of those cheap little USB logic analyzers on order to figure > out how much time elapses between the clock, extstatus, status, and 1PPS > tick. I may need something faster than an Arduino Uno to do this. > > I'm sure there is a way to do this with an interrupt...but I couldn't make > that work yesterday. More to follow. > > thanks much and 73, > ben, kd5byb > _______________________________________________ > time-nuts mailing list -- [email protected] > To unsubscribe, go to > https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts > and follow the instructions there. -- Chris Albertson Redondo Beach, California _______________________________________________ time-nuts mailing list -- [email protected] To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.
