Here is the whole code as i have altered it according to my prev. post.
#picaxe 14m2 'Identify the PICAXE being used as an 14M2.
let b11 = 0 '
let b12 = 0
let b13 = 0
let b14 = 0
let b15 = 0
let b16 = 0
let b17 = 0
let b18 = 0
'The variables below have been assigned to labels, so now.. instead of writing b11 i can write GPS1_Data and the program automatically subsitutees b11 where the text GPS1_Data is written.
'This helps making the program readable and simple when lots of variables is used.
#DEFINE GPS1_Data b11
#DEFINE GPS1_Signal b12
#DEFINE GPS2_Data b13
#DEFINE GPS2_Signal b14
#DEFINE GPS1_Error b15
#DEFINE GPS2_Error b16
#DEFINE GPS1_DOP w10
#DEFINE GPS2_DOP w11
#DEFINE Buzzer C.0
#DEFINE Relay B.5
#DEFINE GPS1_SERIN C.5
#DEFINE GPS2_SERIN B.1
#DEFINE GPS1_FAULT C.1
#DEFINE GPS2_FAULT C.2
#DEFINE GPS1_TIMEOUT b17
#DEFINE GPS2_TIMEOUT b18
main: 'Start 'main' program.
GPS1_Read: 'Read GPSA Sentence from GPS1
SERIN[2000,TIMEOUT1], GPS1_SERIN, N4800_4, ("$GPGSA"),b0,b0,b0,b1,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b2,b3,b4,b5
pause 1 '1us Delay
w10=b2-48*10+b4-48*10+b5-48 'Convert ASCII to Binary
pause 1 '1us Delay
GPS1_TIMEOUT=0 'Reset Timeout
LOW BUZZER 'Reset BUZZER
goto GPS1_Scan 'Read bits and quality of signal/data
GPS2_Read: 'Read GPSA Sentence from GPS1
SERIN[2000,TIMEOUT2], GPS2_SERIN, N4800_4, ("$GPGSA"),b0,b0,b0,b6,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b7,b8,b9,b10
pause 1 '1us Delay
w11=b7-48*10+b9-48*10+b10-48 'Convert ASCII to Binary
pause 1 '1us Delay
GPS2_TIMEOUT=0 'Reset Timeout
LOW BUZZER 'Reset BUZZER
goto GPS2_Scan 'Read bits and quality of signal/data
'TIMEOUT FUNCTION
TIMEOUT1:
Let GPS1_TIMEOUT=1
goto GPS2_Read
TIMEOUT2:
Let GPS2_TIMEOUT=1
if GPS1_TIMEOUT=1 AND GPS2_TIMEOUT=1 then
HIGH BUZZER 'HIGH BUZZER if both serin commands timeout
endif
if GPS1_TIMEOUT=0 AND GPS2_TIMEOUT=1 then
LOW Relay
endif
goto main
GPS1_Scan:
if b1=49 then
Let GPS1_Signal=0 'if b1=1 then the GPS has no signal
endif
if b1=50 then
Let GPS1_Data=0 'if b1=2 then data might be missing or corrupt
Let GPS1_Signal=0
endif
if b1=51 then
Let GPS1_Signal=1 'if b1=3 we have signal and complete data
Let GPS1_Data=1 'if b0=44 there is a comma before DOP and thus complete data
endif
if b0!=44 then
Let GPS1_Data=0 'if b0 is not a comma (,) then data might be missing or corrupt
endif
'Error variable is held between 0 and 3. If more than 3 sentences are bad
'the value becomes 3 and the GPS is considered inactive. (Filters anomalies)
if GPS1_Signal=0 then
if GPS1_Error<3 then
inc GPS1_Error
endif
endif
if GPS1_Signal=1 then
if GPS1_Error>0 then
dec GPS1_Error
endif
endif
goto GPS2_Read 'Read GPSA Sentence from GPS2
GPS2_Scan:
if GPS1_TIMEOUT=1 then
High relay
endif
if b6=49 then
let GPS2_Signal = 0 'if b6=1 then the GPS has no signal
endif
if b6=50 then
Let GPS2_Data=0 'if b6=2 then data might be missing or corrupt
Let GPS2_Signal=0
endif
if b6=51 then
Let GPS2_Signal=1 'if b6=3 we have signal and complete data
Let GPS2_Data=1
endif
if b0!=44 then
Let GPS1_Data=0 'if b0 is not a comma (,) then data might be missing or corrupt
endif
'Error variable is held between 0 and 3. If more than 3 sentences are bad
'the value becomes 3 and the GPS is considered inactive. (Filters anomalies)
if GPS2_Signal=0 then
if GPS2_Error<3 then
inc GPS2_Error
endif
endif
if GPS2_Signal=1 then
if GPS2_Error>0 then
dec GPS2_Error
endif
endif
goto Active_GPS
Active_GPS:
if GPS1_Error =3 then
if GPS2_Error=3 then
HIGH Buzzer 'No active GPS, sound alarm
HIGH GPS1_FAULT
HIGH GPS2_FAULT
endif
if GPS2_Error<3 then
LOW Buzzer
HIGH Relay 'Set GPS2 as output
HIGH GPS1_FAULT
LOW GPS2_FAULT
endif
else
if GPS2_Error=3 then
LOW Buzzer
LOW Relay 'Set GPS1 as output
LOW GPS1_FAULT
HIGH GPS2_FAULT
endif
if GPS2_Error<3 then 'During this state DOP determines output if GPS1/2 Data ok
LOW Buzzer
LOW GPS1_FAULT
LOW GPS2_FAULT
if GPS1_Data=1 AND GPS2_Data=1 then 'Only compare DOP if both GPS data is complete with no errors
goto Active_DOP
endif
endif
endif
goto main
Active_DOP:
if GPS2_DOP < GPS1_DOP then 'If GPS2_DOP has lower DOP
HIGH Relay 'Set GPS2 as output
endif
if GPS1_DOP < GPS2_DOP then 'If GPS1_DOP has lower DOP
LOW Relay 'Set GPS1 as output
endif
pause 5000
goto main 'Go to 'main' program.