-
Categories
-
Platforms
-
Content
Ash, I haven't done so myself but have you read any GPS NMEA posts on the Picaxe forum? While I like to keep things here at EP there is little doubt that the Picaxe forum will have pertinent data.Are you sure its not supposed to be T4800_4 instead of N4800_4?
Testing this out wouldn't hurt.. I'm reading other peoples experiences with reading GPS NMEA data using PICAXE and they all use T.
Ash, I haven't done so myself but have you read any GPS NMEA posts on the Picaxe forum? While I like to keep things here at EP there is little doubt that the Picaxe forum will have pertinent data.
Chris
I wrote this, which is supposed to echo back an NMEA sentence like the following:
$GPGSA,A,3,02,24,25,32,,,,,,,,,2.79,1.62,2.27*0E
main:
SERIN c.4, N4800_4, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
SERout b.1, N4800_4, (b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12)
goto main
In simulation it works. In real life it echoes back part of the sentence and the rest in characters i dont understand.
I will post them here later.
If Ashley could write a code that would echo back at least GSA sentence then may be able to figure out what is wrong.
#picaxe 14m2
#DEFINE INPUT_PIN C.4
main:
GPS1_Read:
SERIN INPUT_PIN, N4800_4, ("$GPGSA,"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27
pause 1
SERTXD(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27)
pause 1000
goto main
No worries.P.S Sorry for not replying sooner !
#picaxe 14m2 #DEFINE INPUT_PIN C.4 main: GPS1_Read: SERIN INPUT_PIN, N4800_4, ("$GPGSA,"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27 pause 1 SERTXD(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27) pause 1000 goto main
I thought VisualGps was freeware. I guess not.
I will order a few and see what happens after i ge them.I've noticed some do use a max232 to convert logic levels.
No worries.
I only use the serial download cable for downloading the program. then i move the picaxe to the breadboard and use 3 wires going to the computers DB9 connector.
PC pin2 connected to whatever transmit pin on picaxe, PC Pin3 connected to whatever receive pin on Picaxe and last PC pin5 to common ground wire
#picaxe 14m2
#DEFINE INPUT_PIN C.4
#DEFINE OUTPUT_PIN B.1
main:
SERIN INPUT_PIN, N4800_4, ("$GPGSA,"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27
pause 1
SEROUT OUTPUT_PIN,N4800_4,(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27)
pause 1000
goto main
I dont know why but it didn't work. I got nothing at all at the output.You already made a SEROUT program which is similar to mine below:
Uh, that would be because b28 doesn't exist. M2 parts can provide "b" variables from b0 to b27. You can see this in the Variables Window incorporated in the editor.when i try to add the variable b28 after b27 it gives me theError: Unknown symbol - b28 Why ?
That makes sense.h, that would be because b28 doesn't exist.
Perhaps try a different nmea sentence. . To see if the problem is the DOP sentence.
Read up on the SerIn command in the pdf. I think it will light some bulbs in both of your wonderfully fertile young minds.... This IS NOT an insult.
Chris
#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.4
#DEFINE GPS2_SERIN B.1
#DEFINE GPS1_BAD_DATA C.1
#DEFINE GPS2_BAD_DATA C.2
#DEFINE GPS1_TIMEOUT_LED B.4
#DEFINE GPS2_TIMEOUT_LED B.3
#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 GPS1_TIMEOUT_LED 'Turns off gps1 timeout LED indicator at pin b.4
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 GPS2_TIMEOUT_LED ' Turns off gps2 timeout LED indicator at pin b.3
goto GPS2_Scan 'Read bits and quality of signal/data
TIMEOUT1:
Let GPS1_TIMEOUT=1
goto GPS1_Scan
TIMEOUT2:
Let GPS2_TIMEOUT=1
goto GPS2_Scan
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
if GPS1_TIMEOUT=1 then
HIGH GPS1_TIMEOUT_LED ' turns on gps1 timeout led indicator at pinb.4
Let GPS1_Error=3
else
LOW GPS1_TIMEOUT_LED ' turns off gps1 timeout led indicator at pinb.4
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
if GPS2_TIMEOUT=1 then
HIGH GPS2_TIMEOUT_LED ' turns on gps2 timeout led indicator at pinb.4
Let GPS2_Error=3
else
LOW GPS2_TIMEOUT_LED ' turns off gps2 timeout led indicator at pinb.4
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_BAD_DATA
HIGH GPS2_BAD_DATA
endif
if GPS2_Error<3 then
LOW Buzzer
HIGH Relay 'Set GPS2 as output
HIGH GPS1_BAD_DATA
LOW GPS2_BAD_DATA
endif
else
if GPS2_Error=3 then
LOW Buzzer
LOW Relay 'Set GPS1 as output
LOW GPS1_BAD_DATA
HIGH GPS2_BAD_DATA
endif
if GPS2_Error<3 then 'During this state DOP determines output if GPS1/2 Data ok
LOW Buzzer
LOW GPS1_BAD_DATA
LOW GPS2_BAD_DATA
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.
I'm also curious about the qualifier's trailing Comma that's enclosed in the quotes. Is the Comma part of the qualifier string? If it isn't it shouldn't be within the quotes.