Setting Kinoma Create Date & Time from a GPS Signal

Brian Friedkin
  

Brian Friedkin

April 16, 2015

Greetings fellow creators!

Many of our Wi-Fi connected devices synchronize their date and time using a network-based timeserver or source. Kinoma Create periodically synchronizes the device date and time from our own network server. But what happens if there is no network available? Fellow creator and hang glider enthusiast Ken Howells came up with an innovative solution.

hang-glider-kinoma crop

Ken’s Kinoma Create is mounted on his hang glider! Temperature and barometric pressure sensors on the wing tips and a GPS module mounted on the Kinoma Create supply real-time data, which is displayed on the touch screen in flight and logged for subsequent analysis. Hang gliders can remain aloft by circling in thermals – columns or bubbles of warm air rising from the surface.  Having the temperature displayed in flight can help to detect thermals and hence keep the glider in the air longer.

Hang Glider 1

Unfortunately, Ken noticed that without a Wi-Fi connection, the time stamps in the log files reset back to the Epoch, so it appeared that he was flying just after midnight in 1970. When there is no network there is no time source available. Fortunately the Adafruit Ultimate GPS Breakout sensor Ken flies with delivers the UTC time and date with each position fix.

Hang Glider 2

The serial-MTK3339 sample app shows how to integrate the GPS module with Kinoma Create. The app uses a BLL to periodically read the GPS position fix from the serial interface and displays the location on a map requested from the Google Static Maps API. A Hardware Pins simulator version of the GPS BLL is provided for testing with two feet on the ground.

Hang Glider 3

The GPS data sheet (PDF) describes the navigation data format, which includes UTC Time and Date fields. Each position fix reading is delivered as a comma separated ASCII string. The BLL parses the individual fields:

$GPRMC,064951.000,A,2307.1256,N,12016.4438,E,0.03,165.48,260406,3.05,W,A*2C

Hang Glider 4

The JavaScript Date.UTC static method returns the number of milliseconds between the UTC date/time provided by the GPS and the Epoch:

var milliseconds = Date.UTC(year, month - 1, day, hours, minutes,  seconds);

Kinoma Create provides a global K4 object (K4 is the internal name for Kinoma Create) that can be used to set the system clock from JavaScript:

K4.date = secondsFromEpoch;

To set the Kinoma Create system clock, pass the UTC seconds from the Date object:

K4.date = milliseconds / 1000;

That will set the date/time, but we also need to set the timezone, since otherwise the displayed local time will be incorrect.  The K4.timezone function can be used to set the timezone from a POSIX GMT/UTC timezone string:

K4.timezone = "PDT+07:00";

Using the K4.date and K4.timezone functions, Ken was able to set the Kinoma Create system clock while in the field without a Wi-Fi network and use the on-board Logs app to log sensor data while in flight.

Screen Shot 2015-04-15 at 7.23.59 PM

Here’s a photo of Ken in-flight using Kinoma Create for a data recording session.

Hang Glider 5

Many thanks to Ken Howells for sharing his Kinoma Create prototype with us!

Ken Howells’ first computer was an Apple 2, purchased new in 1979. He’s employed in the sport that means more to him than anything else: hang gliding. Ken assembles and test flies hang gliders. Ken first flew a hang glider in 1985 and started working for the manufacturer in 1995. Ken brought Wills Wing to the Internet in 1996 and learned a lot about server-side and client-side scripting and database interaction along the way. Ken has run a web-connected weather station and webcams since 1999. Ken likes the LAMP stack and used to know the Hayes command set pretty well. Ken reads a lot, tries to keep informed, jokes around a little too much, and never talks about himself in the third person. You can find him on Facebook

Brian Friedkin has been designing and engineering software for over thirty years. As a Principal Engineer at Apple, Brian was a member of the small engineering team that brought QuickTime to Windows. Brian is a co-founder of Kinoma, which was acquired by Marvell in 2010. At Marvell, Brian works in the Kinoma platform team on a variety of projects and supports the developer forum as BrianKinoma. Brian has created consumer-level multi-platform applications, and embedded real-time software, for key industry players including Palm, SONY, Seiko Instruments and HP.