Maker Pro
Maker Pro

GPS NMEA, Failover Circuit upgrade attempt.

I was thinking that we may be able to avoid the above if we change the following.

'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

this way if GPS1 is ok and GPS2 is timeout then relay goes High (GPS1 is connected)
if GPS2 is ok and GPS1 is timeout then when gps2 scan occures we instruct it to check if PGS1_timeout = 1 and then to set relay High.

Yes I like your thinking, this should solve the problem :)

However.. In the program we have an error variable to filter out anomalies by incrementing to 3 when there is bad data and decrementing back to 0 to indicate good data. The TIMEOUT function does not include this.. and if a gPS is giving good NMEA sentences and throws an anomaly with the TIMEOUT period.. the output will switch too quickly. So I think we should increase the timeout period in milliseconds accordingly.. or put it an error variable to filter anomalies.


Also i dont understand how Active_GPS tag works...

isnt it suppesed to chech the "bold" number in the sentence ?

$GPGSA,A,3,02,24,25,32,,,,,,,,,2.79,1.62,2.27*0E,3.01,1.99,2.25*015*00

where 1 = nofix (bad data)
2 = 3dfix (bad or missing data)
3 = 3dfix (and complete data)

i have simulated with 1 and 2 and doesnt look to affect the output of the faut leds.

What am i missing here ?

While simulating you need to take into account the error variable which I've just described.. if a GPS recieves a 1 or a 2 after three consecutive cycles.. the error variable will increment to 3 and then the output relay will switch accordingly.
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
The picaxe manual states the following:
The serin command is used to receive serial data into an input pin of the microcontroller. It cannot be used with the serial download input pin, which requires use of the serrxd command instead.

The previous diagrams where incorrectly designed by ny nistake. After reading the code i noticed that GPS2 is connected to pin B.1 not (B.0).

So there are two issues here:

1) Pic C.5 is the serial download pin. In the simulation it works but..... Can it really be used ?

2) The serin command is used to receive data into an INPUT pin of the microcontroller.
"C" pins are the input pins of picaxe 14m2 so can B.1 be used ?
Though all pins can be set as input or output pins....

I am not sure...

I will wait to make that clear before i correct the diagram.
Much earlier in this thread I think I mentioned caveats involved when using the program download (Serial In) pin for anything other than actually programming the chip. I suggest reading up on the "Disconnect" and "Reconnect" commands found in Picaxe_Manual2 (Basic Commands); when using C.5 for anything other than programming the chip. On that note, using C.5 for anything other than programming the chip should be avoided if you have another unused input pin you can use. looking at the schematic I never did understand why C.5 is being used.

You guys also need to use Code Tags when you post code. It makes reading code much clearer.

Chris
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
Looking back, once again, I see that the Serial Out (B.0) which is also a reserved programming pin is being used too! Why? There are plenty of unused pins you can use. Pins associated with programming the chip should be avoided unless the developer has no other choice.

Chris
picaxe-gps-png.28124
 
However.. In the program we have an error variable to filter out anomalies by incrementing to 3 when there is bad data and decrementing back to 0 to indicate good data. The TIMEOUT function does not include this.. and if a gPS is giving good NMEA sentences and throws an anomaly with the TIMEOUT period.. the output will switch too quickly. So I think we should increase the timeout period in milliseconds accordingly.. or put it an error variable to filter anomalies.

I dont think increasing the timout time is needed because if memmory serves well at baud rate of 4800bps 1 second is required for the gps to transmit all sentences and based on my experience it is not possible after gps startup not to transmit anything (good data or not).

While simulating you need to take into account the error variable which I've just described.. if a GPS recieves a 1 or a 2 after three consecutive cycles.. the error variable will increment to 3 and then the output relay will switch accordingly.

Got it...
 
Looking back, once again, I see that the Serial Out (B.0) which is also a reserved programming pin is being used too! Why? There are plenty of unused pins you can use. Pins associated with programming the chip should be avoided unless the developer has no other choice.

Chris

That was a mistake on my drawing :)

Dont worry. B.1 is GPS2 input and as far as C.5 is concerned we can change that to c.4, right Ash ?
 
Ok here is the code as i altered it today:

I have changed the following :

Renamed the GPS1_FAULT to GPS1_BAD_DATA
GPS2_FAULT to GPS2_BAD_DATA
Changed input from C.5 to C.4 = #DEFINE GPS1_SERIN C.4

Added
#DEFINE GPS1_TIMEOUT_LED B.4 to turn on a led at pinb.4 when gps1 is timeout
#DEFINE GPS2_TIMEOUT_LED B.3 to turn on a led at pinb.3 when gps2 is timeout
 

Attachments

  • GPS CODE 8 aug 2016.txt
    4.7 KB · Views: 126
Ok here i have assembled a list of possible scenarios and how picaxe reacts while simulating the code posted on post #106

there are a few problems at line 7 and 10

Basicly i wanted it to set buzzer high not only when both gps are timeout or both give bad data but also when one is timeout and the other gives bad data.

At line 10 of the list, GPS1 bad data led will not go high because timeout2: ends with a goto main command.
 

Attachments

  • GPS SCENARIOS.png
    GPS SCENARIOS.png
    41.2 KB · Views: 105
If *we* get to fix theese issues i think the code will be ready to field test !!!

* Dear friend Ashley, this is way beyond my programming skill. I do count on you.
This whole code is your work !
 
Last edited:
If *we* get to fix theese issues i think the code will be ready to field test !!!

* Dear friend Ashley, this is way beyond my programming skill. I do count on you.
This whole code is your work !

We will fix them :) I think I may have to combine the timeout loops we added to the scan loops.. I've started this already and will post the results later when I'm home from work.
 
Ok. about the code i have so far.

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

the above part i understand.

if GPS2_Error<3 then
LOW Buzzer
HIGH Relay 'Set GPS2 as output
HIGH GPS1_BAD_DATA ' Set gps1 bad data led high
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

But this one i do not

I see the GPS2_ERROR but i do not see GPS1_error anywhere...
 
I see the GPS2_ERROR but i do not see GPS1_error anywhere...

I'm not sure whats happened there but the first line of code should read 'if GPS1_ERROR<3 then' like below. I've used an else statement here, so might be confusing.

Code:
    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

Also, I have modified the code and it seems to work.. but I do not have time right now to simulate it fully. Although your scenario table is useful Constantine! All I have done is added a GPS1 and GPS 2 version of the below code.. to each scan loop. It simply sets either of the GPS#_ERROR variables to 3 depending on which one receives a timeout. Therefore it works nicely with previously written code.

Code:
        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

See text file below for entire code:
 

Attachments

  • GPS 10th Aug.txt
    5.1 KB · Views: 121
I run all the scenario table ant it seems to work perfect.
My only concern is the GPS PRN's.
Different Sattelites have different PRN number. if more that 4 PRN numbers are displayed then the program will never run like it shuld because the GSA sentence will be longer and the Picaxe will be unable to read the correct field to determine DOP value.
I have to complete the tests with the real GPS and underway to make sure it works as expected.
I think that theese rockwell gps will only display up tp 4 PRN numbers
 
Top