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 sparkfun.com and lipoly.de 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 ..