Hi Folks. This posting relates to my intention to start experimenting with "background receiving" of GPS serial data using HSERSETUP/HSERIN, suggested by SRNET. Thanks SRNET for earlier postings, including the recent one of connecting the Ardulog data logger to the terminal output pin and recording SERTXD output to the SD card. That saved me a few minutes, before I used a dedicated pin, to find code needed for future possible use of the Ardulog.
For the big picture, see
www.gpss.co.uk/autop.htm - Snoopy's boat 10 has software unchanged for over 18 months, in an 08M based autopilot, and is on 24/7 test on Bray Lake, waiting for a suitable "launch window" for this year's Atlantic attempt. In recent weeks, I've been experimenting with different hardware and software, which we may adopt for next year's boat 11. This experimental work, using boat 6, is going well, and is summarised on my "software" page
www.gpss.co.uk/rbsoft.htm
For years, I've used code, similar to that below, on both 08M and now 28X2 hardware, to read the $GPRMC sentence of data from the GPS. This is the only sentence I need, from several others that the GPS outputs every second, including $GPGLL, $GPVTG, etc. I've had to "program around" speed limitations of the Picaxe, with help from Hippy and others, given on this thread, years ago. The solution that has worked reliably includes switching clock rate of the Picaxe to M16 for SERIN calls, then back to M8 for SERVO/SERVOPOS use.
The limitation in our autopilot software due to this approach, is that the "Navigation Check" stage, when the GPS data is read, takes several seconds, because we need to pick up the required data from several $GPRMC sentences, arriving every second. This means the 1 second "steering loop" has an interruption, which we can live with, but if reading GPS data were in the background, we would not need this interruption. Maybe the required code, such as that below, could also be simpler and tidier
Here is a typical extract from code that has worked well for years, in both 08M and 28X2:
'e.g. $GPRMC,114801.123,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
SERIN B.3, N4800_16, ( "$GPRMC," ) 'wait for $GPRMC sentence
'now we are near the latitude - start by reading 5129.89 into bytes when ,A, = GPS tracking
SERIN B.3, N4800_16, ( ",A," ), b22,b23,b24,b25,b26,b26,b27,b5 'first b26 is to skip the decimal point
What follows is code to extract the latitude from the ASCII characters, then goes on, after several other SERIN calls, to extract other data needed.
I've started to look at Picaxe documentation of HSERIN and HSERSETUP, seeing that one can stream the data into the scratchpad area.
The question will be how best to extract just the $GPRMC sentence (terminated by CR LF) from all the other data.
e.g. maybe use both SERIN, to wait for $GPRMC, then HSERIN to buffer all the $GPRMC sentence into the scratchpad ?
Question will be how fast the HSERIN acts. Could wait on just $GPRM to give more time. Any ideas ?
Robin
www.gpss.co.uk
p.s. Maybe HSERIN/HSERSETUP can only be applied to one particular pin ?
See documentation on
http://www.picaxe.com/BASIC-Commands/Serial-RS232-Interfacing/hsersetup/
I was hoping I could refer to the same pin B.3 used for all the 08M2 and 28X2 based autopilots. Maybe not ?
Maybe no need to use HSERIN - Just use SERIN with the scratchpad memory, to read the whole $GPRMC line ?
This seems to work:
readgprmc: 'read $GPRMC line into scratchpad memory 0..66
ptr=0
SERIN B.3, N4800_16, ( "$GPRMC," ),@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc
return
Looks messy, but this could help a lot: collecting all the required data from one $GPRMC sentence.