torstai 29. elokuuta 2013

First Gauge with SVG and Node.js

I couldn't get javascript access to Canboat's streaming json working with my meager js skills.  I need anyway access also to another streaming source, namely gpsd nmea 0183 data, so I figured I would give wind data a try with Node.js and Websockets.

This turned into a proto with a Node http server that
  • spawns "source" process that mimics canboat:
    • actual captured N2K data from our boat in a file
    • read by simple shell script, output a line per second and piped to
    • canboat analyzer that outputs the message in json, message per line
  • serves a single html file with embedded SVG wind gauge & websocket client that updates the wind direction based on the streamed json messages
  • streames N2K messages in json over websockets with Primus
The whole stack was a breeze and I made really good progress with almost no sidesteps.
The result is in my humble opinion a pretty neat in-browser wind direction visualization that handles  issues such as reconnects automatically. Responsive UI no less, sizes to the size & orientation of your screen/window.

Next steps:
  • capturing a real data set: actual sail or at least motoring around rather than just sitting at the docks
  • getting the whole thing up and running on Pi, accessible via a wifi access point on the Pi
  • adding the gpsd NMEA 0183 data from the plotter (COG etc)
  • calculating and displaying TWA
Apparently there are multiple (1, 2, 3) simple NMEA 0183 parsers in Javascript, have to see which one suits my needs best.

sunnuntai 25. elokuuta 2013

Actisense NGT-1: shortcut to N2K data

After googling around for CAN on Raspberry and looking at Pican installation instructions with associated kernel tweaking I decided to cough up the cash for Actisense NGT-1.
Instead of using Raspberry for the initial test I decided that everything would be a tad easier with my Macbook. I would have needed the Macbook for ssh to Raspberry anyway, so I decided to try NGT-1 out with that.
After a bit of jury rigging the cabling (NGT-1 comes with Micronet connector, I have SeaTalk NG) and installing the Actisense FTDI driver I could admire flashing lights, but actisense_serial was not giving me anything. Debug messages showed that open() call never returned, so after  a bit of googling I added the O_NONBLOCK flag in the best "try something, maybe it will work" programming fashion and lo and behold, I got data!

{"timestamp":"2013-08-24-15:36:10.113","prio":"3","src":"105","dst":"255","pgn":"128267","description":"Water Depth","fields":{"SID":"0","Depth":"8.50","Offset":"0.000"}}
{"timestamp":"2013-08-24-15:36:10.140","prio":"2","src":"105","dst":"255","pgn":"130306","description":"Wind Data","fields":{"SID":"0","Wind Speed":"2.93","Wind Angle":"341.9","Reference":"Apparent"}}
{"timestamp":"2013-08-24-15:36:10.140","prio":"2","src":"105","dst":"255","pgn":"128259","description":"Speed","fields":{"SID":"0","Speed Water Referenced":"0.00","Speed Water Referenced Type":"-0"}}
{"timestamp":"2013-08-24-15:36:10.140","prio":"6","src":"105","dst":"255","pgn":"128275","description":"Distance Log","fields":{"Log":"1424188","Trip Log":"1424188"}}

Now I have all the data I need from the N2K bus, plus some unrecognized PGN 130822, coming from either i70 or ITC-5:

{"timestamp":"2013-08-24-15:36:09.140","prio":"7","src":"105","dst":"255","pgn":"130822","description":"Unknown PGN","fields":{ "Manufacturer Code": "Raymarine","Industry Code":"Marine"}}


perjantai 9. elokuuta 2013

The starting point

The starting point is our 35ft sailing vessel with basic navigation instrumentation including a chart plotter, echosounder, mechanical log and wind instrument.

The target is to have all current & other nice to have boat data available on wifi as data for other applications such as iNavX and a simple (sic) platform to create whatever navigation displays I can think of displayed on browsers connected to the boat's wifi.

Current inventory:
My first experiment was to get AIS targets to display in the navigation apps on the iPad. Once I got the cable connected with correct polarity I was able to stream the AIS data as UDP packets on the local wifi and have it show up in iNavX on iPad.

AIS targets from VHF in iNavX on iPad

For lack of time I decided to postpone Raspberry installation for this season and instead hooked the VHF up with the plotter to get usable AIS display no matter the state of my Raspberry setup.

As to the goal that I'm after: the built in layouts on my i70 are somewhat lacking. You can configure different layouts for a bunch of numbers on a display that is really readable, but the visualizations are pretty lame. Or what do you think of the graphical temperature "gauge" in the picture below? Another good example is history graphs that have no indication of the range of the values.
Dumb sea water gauge
Since it appears that the manufacturer is not about to give us incrementally better firmware build your own is starting to sound like a viable option.

And btw I have currently no way to upgrade the firmware on my i70 with my minimal N2K setup...

So what I'm after is an easy way to develop new gauges and displays. One example would be a multi-gauge in the likeness of B & G Sailsteer: one gauge to visualize multiple data points in an easy to grasp way. As a starting point I wrote some Javascript based on Steelseries gauges to mimic Sailsteer.
Sailsteer-like gauge drawn with custom JS.
Freeboard is a real life project with somewhat similar goals, but I would rather skip the Arduino and have just the Raspberry directly off the N2K bus with PICAN and Canboat.