Hello world! Blog Mk III

I’ve decided to start blogging again, mostly this will be just a way of documenting my projects and reminding myself how I solved problems in the past, but I guess it’s always possible other people might be interested in my projects as well.

This will be about the third (or possibly fourth) iteration of this blog. It went on a long hiatus for a while there, and then got a reboot on wordpress hosting. Hopefully this AWS version will have stick around for a while. I’ve migrated all my old content onto this blog, most of it is horribly out of date now, but there are probably some nuggets of usefulness in there somewhere, and if nothing else it’s interesting reminiscing for me!

I’m planning on blogging about my three main projects I currently have underway:

  • an inverted pendulum robot that I am modelling on DPA’s excellent nBot
  • a programmable power supply – based heavily on Gerry Sweeney’s amazing work
  • my adventures in risc-v using PicoRV32 and a Spartan 6 FPGA dev board from aliexpress

More posts on each of these projects to follow.


Mapping NHibernate collections one way

I encountered an issue with an NHibernate mapping today that took me a short while to solve so I thought I’d post here to remind myself in future.

I wanted to map a parent child relationship but only manage the persistence from the parent end. Here’s an example:

Blog -< Post

  public class Blog
        public Blog()

        public virtual int BlogId { get; set; }

        public virtual IList<Post> Posts { get; set; }

Which might have the following mappings:

The problem I was having was that saving the blog entity was causing a SQL exception complaining that BlogId wasn’t a nullable field on the Post table. In the end the fix was easy – remove the not null constraint!

The reason being that nhibernate likes to save the Post records first, then go back and update the foreign key values once it has saved the Blog entity.

ASP.NET MVC3 Razor view engine – some initial observations

Over the last couple of days I’ve started playing around with the razor view engine that comes with ASP.NET MVC 3. The first thing you notice is how much cleaner your markup pages look. It’s a real pleasure to code your markup without having to pollute it with masses of special code nuggets to demarcate your C# code. If you haven’t seen any examples yet check out Scottgu’s intro to Razor.

The error reporting still looks like it could do with a little work though. For example yesterday I put code very similar to this in my view:

@for(int i = 0; i < 5; i++) {

And I got an error message like this:


Humm… “No overload for method ‘Write’ takes 0 arguments” – what does that mean? Well the answer is that the @ symbol before the closing curly brace isn’t needed. So the fix was simply to make the following change:

@for(int i = 0; i < 5; i++) {

I guess once you’ve used razor for even a short while things like this will become second nature, but it had me stumped for a short time and it’d be nice if the error messages due to view engine parser failures were slightly more helpful in identifiying the exact problem.

GDB, BDM and the 68332

I’ve just been through the process of reviving my 68332 board that I got quite a few years ago from robominds. I wanted step debugging support and faster download speeds than are possible with the serial port connection so I downloaded the latest file package (m68k-bdm-1.4-pre4) from the bdm sourceforge project. I used the m683xx branch in the latest release as that is the culmination of Pavel Pisa’s work to support the 68332. The kernel driver needed a few minor modifications to support the modern 2.6.32 kernel that my Ubuntu distro is using.

The most modern gdb patch supplied to work with the kernel driver was targeting gdb 5.3 which is pretty old now given that the current release of gdb is 7.2. The challenge came when gdb 5.3 wouldn’t compile with a modern gcc due to gcc using stricter casting rules these days. Patching obstack.h using the same file from gdb 6.1 as an example solved this problem.

So now I have BDM support in GDB and step debug on my 68332 target board – happy days.

My patches needed in addition to those in the m68k-bdm-1.4-pre4 release.


Back in action

A new server, a new look and a return to regular service after a bit of a hiatus from blogging.

I’ve returned to my computer vision project with a vengeance and am close to having the first part working. This includes feature location and tracking between frames, 3D reconstruction and ego motion estimation. The final piece of the puzzle is my old nemesis – Non-linear Least Squares Minimisation. For this I am using the levmar library implementation of the Levenberg-Marquardt algorithm. So far I have a partial solution in that it works well for translations, but not so well for rotations so I need to do a bit more work on that yet. Once that’s sorted the last piece of the puzzle will be implementing a kalman filter to merge the odometry data from the wheel encoders with the ego motion estimation from the vision system.

I’m simultaneously resurrecting AMI (my robotics research platform) and am working on a few upgrades for that. Getting the environment up and running was easy this time only a few hours to get the cross tool chain built and various other tools sorted and I was loading s19 records into the 68332 and seeing “Hello world!”.

I’m off to TechEd next week so that should be interesting!

Time for a change

Well, I am now in the closing hours of my last day of work at my current job. It’s been a challenging role and I have learnt a huge amount about the finance industry.

Looking forward to the future fills me with a huge amount of excitement mixed with a little bit of nervousness. It’s not every day you give up a well paying job, pack up your life and move country. I have no doubt that the next year will be full of challenges, but I am really looking forward to it all. I can’t wait to build my business into New Zealands best shopping comparison site.

But first, before anything else, I think it’s time for a holiday!

A:Hover and IE – a trap for young players

If you’re having trouble getting your a:hover effect to work in IE you might want to make sure you have an href attribute on the anchor element. The hover effect won’t work in IE unless it does.

I had something like the following:

<a onclick="somejavascriptfunction()">Anchor text</a>

Changing to this solved the issue:

<a onclick="somejavascriptfunction()" href='#'>Anchor text</a>

It’s a bit embarrassing and I should know better. I hope this post helps other people avoid wasting time like I did.

Amazons DRM free MP3s

A couple of nights ago I finally found some time to check out Amazon’s new MP3 service and so far I’m pretty impressed.


My interest in the Amazon MP3 service was piqued when I discovered all their tracks are DRM free (unlike some other crippled offerings). The songs are encoded at 256 kbps which is a pretty respectable bit rate.

Linux support!

I got even more excited when I went to the getting started page and in the “Buy and Download” section they mention they have a Linux version of their Amazon MP3 Downloader application. And they haven’t gone for some budget “one size fits all” Linux solution, but they have binaries for most of the major distros.

It’s really encouraging to see this sort of first class support for Linux by companies like Amazon.

What if I’m running 64 bit linux?

If like me you are running the amd64 build of your distro you will need to convince Amazons MP3 Downloader to run against 32 bit libraries. If you use Ubuntu then I suggest the excellent getlibs tool for installing your 32 bit dependencies. After you’ve downloaded the Ubuntu deb file, install it using:

sudo dpkg -i –force-all amazon*.deb

Then install the 32 bit dependencies with getlibs:

getlibs /usr/bin/amazonmp3

It’s dangerously easy to use

Amazon certainly seem to have a great range of music on offer. To test things out I purchased

var country_code = geoip_country_code();if (country_code != “GB”){ document.getElementById(‘ukShaka’).style.display = ‘none’;}else{document.getElementById(‘usShaka’).style.display = ‘none’;} by Kruder & Dorfmeister using 1-click. The 3 track EP cost me £2.37, you can get full albums for around £6-7 (or $9-11 US). The Amazon MP3 Downloader is a simple but effective app downloading Shakatakadoodub to my machine in a matter of seconds. From there it was a simple job to import into Banshee. One mouse click was all it took to purchase and download a DRM free EP!

I’m a happy camper

Overall I’m really impressed with this offering and can’t understand why it hasn’t had more press. It amazes me that people stick with crippled solutions like the iTunes store when you have a DRM free alternative like this available. I know where I’ll be buy my music from now…

var country_code = geoip_country_code();if (country_code != “GB”){document.getElementById(‘ukmp3’).style.display = ‘none’;}else{document.getElementById(‘usmp3’).style.display = ‘none’;}

Tomboy for windows

When working in Windows I like to use as much Open Source software as possible to make my environment as familiar to my Linux desktop as I can. I have many of the popular applications installed such as Firefox, Thunderbird, Gimp, MySql, and XEmacs (who said XEmacs wasn’t popular?!).

Recently a Tomboy preview for windows became available and a few nights ago I finally got round to installing on my laptop. Tomboy is a great application and works the way a note taking application should work.

The install is a little fiddly if you are running Vista due to a bug in the Gtk runtime installer, but it’s not too challenging to get running.

If you’ve ever wanted an application to quickly jot notes into I throughly recommend you give Tomboy a try.