Ice Tube firmware - GPS Checksum checked!

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Ice Tube firmware - GPS Checksum checked!

Post by wbp »

I have now added code to check the GPS Checksum, and the GPS Status, to my firmware, after a request from "grumpygasbag". This turned out to be a bit of a challenge; the examples of how to do this that I found on the web were a good start but didn't really work as is.

If the GPS feature is enabled, and no valid GPRMC message has been received for about 10 seconds, the clock will now flash " no gps " every other second. It was fun testing this feature - I created a small Faraday cage using two metal colanders to complete isolate the GPS receiver in my clock.

I think this has to be pretty much the last mod - there really isn't any memory left after this. To add more features we're going to have to upgrade to a 328 chip or take something out.

Enjoy!
William
Attachments
ice tube.120727wm.zip
Ice Tube Clock firmware version 120727Wm with GPS checking
(51.07 KiB) Downloaded 117 times

User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by wbp »

This update also fixes the problem with the alarm activating at midnight.

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

Hi William,

Ok. That was quick!

I've downloaded the firmware and will give it a shot ASAP.

There's just one little problem: the "10 second" timeout. My 433MHz GPS data retransmission system sends data in 7-second bursts every 3 minutes or so. That's because if the transmission is continuous, it completely blots out all other 433MHz transmission in and around the house and in Oz that includes all the remotes for our garages and fans etc etc. So with a 10-second timeout for data reception, my clock will be blinking "no GPS" all the time.

How I change the code to make the 10-second timeout somewhat longer (like maybe an hour or more)?

I know, I'm a pain in the butt :-(

J

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

Hi again,

I assume the important part of the code for the GPS timeout is this line....

else if ( gpsEnabled && (gpsTimeout>5) && (time_s % 2) ) { // if no data from gps
display_str(" no gps ");

Can I just change the '5' to something that is a calculated multiple of that to achieve a much longer timeout as already mentioned?

Cheers,

J

User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by wbp »

Well, mostly. That code is pretty simple. The counter is only a byte. it gets incremented once a second and reset to zero by the code that parses the GPRMC message when it sees an "A" for the status flag. So if you want to make it longer than 255 seconds, you have to increase the size of the counter to uint16_t - easily enough to do. Then change the comparison to >300 for 5 minutes or >600 for 10 minutes or whatever suits you. I'd have put all this in the Menu but there isn't any room left without taking something else out.

How's that?

William

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

Hi William,

I think I can make those changes to the code myself. Thanks for the pointers. I don't think it needs to be a menu item. For most people your timeout period would be fine.

If my changes work out ok, anyone who needs a longer timeout can do the same.

Cheers,

J

User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by wbp »

J,

Change this:

Code: Select all

uint8_t gpsTimeout = 255;  // how long since we received valid GPS data?
to this:

Code: Select all

uint16_t gpsTimeout = 255;  // how long since we received valid GPS data?
Then the counter can go to 65535 seconds before it wraps.

The code that increments the counter does not check for wrap - like I said it's pretty simple. If the GPS is enabled and nothing is ever received it will wrap back to zero every 255 (or in your case 65535) seconds. All this does is stop the blinking "no gps" message every so often.

William

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

Hi,

I was just in the process of changing the code, so thanks.

Excuse my complete ignorance, but why in...

uint16_t gpsTimeout = 255; // how long since we received valid GPS data?

...don't you have to increase the 255 to 65535?

I've also made some changes to the makefile to suit my usbasp programmer and my Mac. I hope that works! :-)

J

User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by wbp »

The idea behind initializing that variable is to set it to something that will cause the "no gps" message until a good signal is received, so set it to any number that suits you... Actually now that I think about it the 255 is wrong, because the first increment will wrap it to zero, so it won't start flashing "no gps" until the counter gets up to whatever is being tested for. You could just set it to zero and then it won't complain on power up until there has been no signal for however long you set the timeout check to. Since we're not launching rockets here anything that suits you is fine.

The code that increments the gpsTimeout variable could also check to see if it had reached some max value and not increment it if so. Thusly:

Code: Select all

#define gpsTimeoutLimit 300  // 5 minutes
uint16_t gpsTimeout = gpsTimeoutLimit+1;
[...]
	if (gpsTimeout<=gpsTimeoutLimit)
		gpsTimeout++;  // 1 second has gone by
[...]
    } else if ( gpsEnabled && (gpsTimeout>gpsTimeoutLimit) && (time_s % 2) ) {  // if no data from gps
      display_str(" no gps ");  // flash a message every other second
    } else {
[...]
That's the general idea, anyway...
William

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

Your original idea is exactly what is needed - 'no gps' flashing until a valid string is received. That then confirms that the first burst of data from the 433MHz retransmitter has done its job.

What I think I want is a 30 minute timeout, and including the message until a valid string comes in, so, adapting your suggested code, this is what I think I'll try...

Code: Select all

    #define gpsTimeoutLimit 1800  // 30 minutes
    uint16_t gpsTimeout = gpsTimeoutLimit+1;
    [...]
       if (gpsTimeout<=gpsTimeoutLimit)
          gpsTimeout++;  // 1 second has gone by
    [...]
        } else if ( gpsEnabled && (gpsTimeout>gpsTimeoutLimit) && (time_s % 2) ) {  // if no data from gps
          display_str(" no gps ");  // flash a message every other second
        } else {
    [...]

User avatar
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by grumpygasbag »

William,

I realise this is completely outrageous but all my attempts to figure out how to compile a grumpy-friendly version of the code have failed. I made the changes to the iv.c file that you suggested (was that the correct thing to do?) but neither using your original makefile on my daughter's PC nor my efforts at compiling on my Mac worked. All sorts of errors popped up. Not surprising, I guess. I have absolutely no idea what I'm doing :-(

Is there any chance you could compile a hex file for me with a 30 minute GPStimeout along the lines suggested above?

Pathetic. I know

J :oops:

User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube firmware - GPS Checksum checked!

Post by wbp »

J,

Send me an email with a list of the messages. There are a bunch of warnings, that might be all you are seeing. Meanwhile I'll do a build with a 30 minute timeout and send it to you. I have your email address from the PM you sent.

William

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”