Saturday, 18 July 2015

Updating a real time clock via GPS

RTC's are bloody handy but can be a pain in the arse to update or set accurately. So I've made a simple little but handy little program to automatically update my favorite DS3231 RTC modules directly from the awesomely accurate GPS time signals. It makes them so much better to use. Low cost GPS modules are here. The days of putting the current time, adjusted for compilation error into your code are over. 

All you need is a  NMEA GPS module (I used a $10 GY-NEO6MV2), your choice of Arduino and a DS3231 RTC Module.
I wont go into detail about how to communicate with the GPS or the DS3231. Maybe I will later, but that is so well documented elsewhere on the net, that there is really little point. 
To get the DS3231 going, follow this well thought out guide from Tronixstuff. 
To get the GPS running, go to Git hub and download the TinyGPS++ library. 
If you haven't got it already, you'll also need the Time library from arduino.org. 
***NOTE 2017*** Updates to the time library have broken this code. To run it now you'll need the old time library and a early version of the Arduino IDE pre 1.6.1! This blog is neglected, and I'll probably never fix the code to run in the new IDE. Sorry. 


Get the connections right.

Once you have your GPS and and RTC connected correctly, copy and paste this code, making sure to set your GPS baud, timezone and the correct software serial pins for the GPS. I've used 14(A0) for Rx from the GPS. You don't need to worry about Tx to the GPS for this one. 



Pin13 will light solid on success and flash rapidly on failure. Or you can watch the serial monitor for a more verbose indication. There will be a few micro seconds error generated between reading the GPS time and writing that to the RTC. But it should be negligible. I haven't even bothered trying to measure it. If that error is unacceptable, then you'll need a more accurate clock for your project anyway. I have included a basic checksum test to ensure that the RTC matches GPS time. Checksum failure will cause pin 13 to flash.


Enjoy. 

Sunday, 16 November 2014

How to make an extending drawbar.

The problem:
We bought a boat. Well, we bought a derelict hull for $200. We only wanted it for the lead on the keel so we can melt it down and put it in a bigger boat. But how to does one shift a 7.5m yacht 40km with only a regular sized tandem trailer. The deal was all or nothing. We had to remove the lot, so stripping what we wanted off the hull was not an option.  We could pay to have it transported, but that would cost more than it was worth to us.

The solution:
Extend the trailers drawbar. Get the boat and a more versatile trailer. Sounds good.

Hidden behind our barn is a sad old rotten Mazda Titan with a 1 ton crane. Instant heavy duty sliding drawbar.


A few minutes with the angle grinder to remove the last two boom sections and the trucks donation is complete. Junk is awesome. Everyone should have their own backyard junkyard.


Things certainly look plausible.  


Marking out the cut for the new drawbar. Accuracy is key at this point. Find the center of the trailer and work from there. It's pretty essential to keep the drawbar straight and center. A crooked drawbar is not advisable. Our plan was to cut off the existing coupling bracket and slot the crane boom in its place. The boom would then be welded to the existing drawbar and chassis with the inner sliding section providing the drawbar extension. We were fairly trepadacious about cutting up our perfectly functional (and useful) trailer. But upgrades are upgrades. 


With the bracket cut out to fit the crane boom, it slotted together perfectly. Time for welding.


The crane boom only reached the forward section of the chassis, so for extra support we decided to weld in two lengths of 40mm hollow section back to the next crossbar. 
It's that easy. All that's left is to make a bracket for the coupling and extending the brake line and light cable.  


The coupling bracket, a short section of channel steel, braced with a triangle of plate welded where the cable pulley used to sit. Important to get this sitting straight and level. We stood it on end an knocked around with a level until it looked right. 



The completed sliding section with coupling bolted on and ready to go.


We had no trailer cable on hand. So stranded cable in garden hose had to suffice for the extension. It looks a little bit too agricultural for our taste. We've got to rewire the trailer soon anyway. So this will do until then. 


The finished product. For the brakes we just got a 1.7m length of flexible brake hose made up by an engineering shop. Cost about $80 and took them only 10 minutes. The brakes are little spongier than they used to be due to the expansion in the hose, but they still function perfectly. A better option would be stainless braided hose, but $. 
Not a bad deal for a day of grinding and welding. 

Great Success! This towed like an absolute dream. 



Make Shit.

This blog, if I can find the time and motivation will chronicle some of the various projects and general cool crap that we build here on our farm on Kaipara in New Zealand. Or it will be a place for pseudo-anonymous general musings. Or it will be forgotten, destined to join the multitudes of other blogs that were never started which clog up the internet. We'll see.