fredag den 14. november 2014

Used a couple of rainy days to explore the GUI/scripting possibilities on Windows.

  • Lua - wxLua. Very nice with Lua and all, but wxWidgets has a pretty steep learning curve. Also the resulting self contained binary would be rather large.

  • PowerShell - Some nice concepts, but just too horrible overall

  • Autoit. - A BASIC variant and it shows. But a very nice set of tools with Gui builder, exe wrapper etc. good help files and rich library

Autoit it was. And the resulting announcement to our wintering marina community can be seen below

After a couple of grey days in the anchorage, a tool for downloading/viewing todays Skiron grib file has magically emerged on my computer.
The Skiron grib files are kindly made available on by a fellow sailor and AFAICT are produced from much the same model as those on the Poseidon web site. Only far more convenient as GRIB files ..

This may be a little over engineered, but basically pressing the Go! button should suffice for most. The rest of the UI is hopefully relatively self explanatory.

For the technically inclined, the source code can be found at this link

Due to restrictions in gmail you must download the program at this link.
Just save it to somewhere on the computer and double-click.

Enjoy /Flemming

mandag den 15. oktober 2012

Anchor winch remote - An exercise in futility

Last spring, wanting to add another outlet for the anchorwinch remote I toasted the "up" by reversing the polarity in the socket. Bummer.

Taking it apart revealed two hexfet's, but replacing those didn't cut it. The remote has a button for "up", "down" and "on", so the simplest thing would have been to simply route the gates for the hexfets to ground through the "up" and "down" buttons. Could have been done with four 10k resistors beside the hexfets.

Alas that would leave the "on" button orphaned. The original functionality was to enable operation for one minute and lit an LED for that period when on was pressed.

Enter an attiny13, two more driving transistors with resistors, an LED and a voltage regulator. Not to speak of writing the program to control it all of course.

On button, I hope you feel pleased ...

Old PCB, New board, the remote and a test load on the left. At least the number  of components is not as  big as  on the old one
Popping into place

tirsdag den 13. marts 2012

Boat project: AIS SART Alarm

This will be a small box to attach to your AIS receivers NMEA output. It will scan the output stream for type type 14 AIVDM messages coming from an Ais SART such as the easyRESCUE. Alternatively MMSI numbers in the 970xxxxxx range will also trigger an alarm.

The decoding is done with an Atmel ATtiny to roughly $ 1,- which will drive an LED and a piezo buzzer. A pushbutton is attached to an input pin.
  • During normal operation the LED will blink slowly when AIS messages are seen.
    A push button press will test the buzzer.
  • When a SART transmission is detected, the LED will blink fast and the buzzer is activated.
    A pushbutton press will disable the buzzer, but the LED will keep blinking fast.
    Additional presses will toggle the buzzer.
  • When the SART in question (by MMSI) stops transmitting, the buzzer will be re-armed.
This can all be built for appx. ten dollars. AIS SART detectors retail for about 500 ...

Watch this space for a diagram coming up soon.

Boat project: Autopilot remote and MOB FOB

Lots of people are sailing around with Autohelm autopilots, for which no wireless remotes are available (to my knowledge anyway).

Hobby sites like and sells a wireless fob for the 2.4 GHz band that fits the bill nicely with 5 buttons and a programmable Atmel ATtiny 24 on board. On the receiver end, another Avr talks to the receiver radio and the Seatalk bus.

The 5 available buttons may be laid out like:
  • Left: Port 1 degree
  • Mid + Left or Up: Port 10 degrees.
  • Right: Starboard 1 degree
  • Mid + Right or Down: Stb. 10 degrees.
  • 2 Mid presses followed by left/right within 3 secs: Tack 100 degrees.
    This will be given as 10x10 degree commands on the bus to suit all pilot types.
  • The receiver Avr will listen on a uart for GPS XTE (Cross track error) NMEA commands.
  • A switch will determine whether these should be used for driving the autopilot from the active route in the GPS.
In addition the remotes can be used as MOB FOB's:
  • The att24's watchdog is used to wakeup the uC and send a keepalive message every 30 secs.
  • If the signal does not arrive (because the FOB drowned by going overboard) the receiver will issue an alarm as for the AIS SART.
  • Some kind of procedure for signing the FOB's in and out needs to be devised. ??
    Maybe provide a USB socket (In AVR Firmware) (com port) and and a windows app?
  • When reproprogramming the att24 in the FOB, a serial number must be flashed in.

torsdag den 8. marts 2012

A Microscopic Event Lib

Many years ago, an extremely able colleague of mine introduced me to what could be called Asynchronous Programming. From GUI programming, we know the notion of callback registering and execution. When applying this principle to streams and time as well, programs can handle (seeming) concurrency just as responsive as using threading. I have never looked back ..

Although I rate myself as pretty good at managing preemptive concurrency, I *hate* the added complexity of protecting all shared data. And last but not least, the flow of execution is much easier to grasp when all callbacks run to completion before falling back into the main loop.

The catch of course, is that *everything* needs to asynchronous. Ie. all operations must complete in a short amount of time, or be arranged so that a callback is called upon completion. Also factoring everything into callbacks can be tedious in a language like C that doesn't have anonymous functions, let alone closures.

This of course has been realized by brighter minds already, and that is why libevent exists. However this is a relatively heavyweight, certainly in embedded Linux where megabytes of storage can be counted on one hand.

And this is why the micro event lib (libuevent) came into being. The tediousness of C is addressed with a Lua binding. Lua of course has closures, so this style of coding becomes next to effortless.

Go check it out on GoogleCode ..