Maker Pro
Maker Pro

GPS NMEA, Failover Circuit upgrade attempt.

I am not sure it could take up to a month to arrive from china. I should have them early september. I will check at the electronics shop in a nearby city tomorrow and with a little luck i may have one tomorrow.

The 20M2 chips should arrive by the end of next week.
 
My good friend, your last code didnt work either.
I have the feeling that something is going on with the qualifier. I think that if we get it to work with the code that echoes back the sentences it will work for our project also
 
There is an other detail that i am not sure if you have read. If i connect GPS 1 (c.4) with the picaxe before i power up the picaxe, it does nothing, No leds come on nothing, and when i remove GPS it goes turns all LED's on and the Relay High.

When i connect GPS2 (B.1) with the picaxe before i power up the picaxe, only the GPS1 bad data led (C.1) comes on and nothing else happens untill i remove it where again it turns all LED's on and the Relay High.

Strange behavior
 
My good friend, your last code didnt work either.
I have the feeling that something is going on with the qualifier. I think that if we get it to work with the code that echoes back the sentences it will work for our project also

I'm not sure how to do this.. other than what we have done.

There is an other detail that i am not sure if you have read. If i connect GPS 1 (c.4) with the picaxe before i power up the picaxe, it does nothing, No leds come on nothing, and when i remove GPS it goes turns all LED's on and the Relay High.

When i connect GPS2 (B.1) with the picaxe before i power up the picaxe, only the GPS1 bad data led (C.1) comes on and nothing else happens untill i remove it where again it turns all LED's on and the Relay High.

Strange behavior

Not sure whats happening here either, I hope the max232 solves this issue otherwise its back to the drawing board! One question, are both gps's the same baud rate?
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
I know the question was directed at Constantine but I read through some of it too. Page 12 is really painful to read, as it's mostly commented code shown in light green on a white background. It's an example of how not using code tags makes eye strain!

BTW, Ash is doing a fine job plugging through this with you but I also would be running some code tests for you as well. My problem is I'd want to simulate the GPS signal by using VB6 and its MSCommControl. Unfortunately VB6 is very old and 4800 baud is not a valid transfer rate with this old control.

Chris

Chris
 
Hi Chris,

I was speaking to Constantine last night and we managed to solve the problem!

We set the internal frequency to 8MHz and shortened the qualifer to ("SA") as opposed to ("$GPGSA").. and it worked! I'm not sure if it was the frequency change or the qualifier change that did it.. waiting for Constantine to carry out more tests.

Below is the current code:

Code:
#picaxe 14m2 'Identify the PICAXE being used as an 14M2.

SETFREQ M8

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_8, ("SA"),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_8, ("SA"),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.
 
Well after running more tests today i figured out that it was the frequency increase that made it work.

That's good.. it means the problem wasn't an incomplete data for the NMEA qualifier.

I wondered if the 4MHz frequency needed to be set? The manual does state its 4MHz by default though.
 
So an other question i now have is this.

While the resistor configuration works with the picaxe, i will use the MAX232 as soon as i get them.
After reading the max232 Datasheet i still can not figure out how to connect it with the picaxe.
From what i understand it can accept 2 RS232 inputs and give 2 TTL outputs, so 1 chip is enough for our project.
 
I made a new diagram that includes a MAX232 for connecting both GPS to the picaxe.

Could you check and let me know if there is something that needs to be changed ?

One thing i need confirmed is the connection between MAX232 and picaxe.

Thanks !
 

Attachments

  • diagram.png
    diagram.png
    31.7 KB · Views: 81
I made a new diagram that includes a MAX232 for connecting both GPS to the picaxe.

Could you check and let me know if there is something that needs to be changed ?

One thing i need confirmed is the connection between MAX232 and picaxe.

Thanks !

Circuit Diagram looks okay to me :) and the MAX232 looks to be connected correctly.

I noticed you've moved GPS2 Input to C.3 which is good :)

Whats the purpose of the 4 10k resistors on the picaxe?
 
Top