'SC2.BAS iPAQ switch for robot boat
'v1a 13 Sep 2009 (c) Robin Lovelock www.gpss.co.uk/autop.htm
'Thanks to LBenson, Eclectic and Hippy on www.picaxeforum.co.uk
'input is serial RS232 GPS data - to see when GPS is ready
'the GPS outputs text strings and includes ",A," after $GPRMC when ready
'e.g. $GPRMC,114801,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
'e.g. $GPRMC,114801.123,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
'output is servo controlling switching of iPAQ power ON
'note that no need to use or hold servo until just before exit
#Picaxe 08M
SETFREQ M8 '8MHz for SERIN
'wait until GPS ready $GPRMC,114801,A,5129.8944,N, etc,etc
waitgps: '
SERIN 3,N4800_8,("$GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b1 'Eclectic
'SERIN 3,N4800_8,("$GPRMC,")
'SERIN 3,N4800_8,(","),b1 'idea from lbenson on picaxe forum
if b1 <> "A" then 'this idea from eclectic on picaxe forum
goto waitgps
endif
SETFREQ M4 'standard 4MHz
PAUSE 1000
SERVO 1,91
PAUSE 1000
SERVOPOS 1,126 'toggle servo to switch on iPAQ power
PAUSE 1000
SERVOPOS 1,91
PAUSE 3000 'give servo time to travel then exit