Sunday, 30 November 2008

Servo Board V2 Firmware

I have spent today fighting gdb and gdb-proxy in an attempt to update the firmware for the PWM board (Servo board). I spent the first two hours going 'aargh' because msp430-gdb kept issuing me with missing data stack errors and empty symbol tables. Eventually from looking at last years code i was able to view work out what was wrong. Weirdly, adding a static variable into my code (which was only assigned to once) was enough to solve my problem, however this makes no sense why.

The reason the firmware needed upgrading is because we have put a beefier MSP micro-controller on the board, subsequently the board layout has changed. Once I got my head around both the motor controllers i2c routines and the old pwm firmware i began merging bits of code together. After a suitable amount of time, anger, coffee, realisation of how stupid i was being and more coffee, I managed to get the new board to seep all the servo pins back and forth, demonstrating that this part of the board works.

Enjoy the video - I did!

Some Photos:

The new servo board. The two LEDs indicate both power supplies are connected. The third LED which isn't illuminated, should be, however due to some primate-like soldering skills, there appears to be a short.

The servos in motion.

The MSP430 programmer. I mounted it on an old credit card to make the wiring a little more secure. Despite it looking horrible, it actually works surprisingly well. Honest.

Saturday, 29 November 2008

Tongue Extraction

I have just completed my first ever Dynamic Programming project for Intelligent Algorithms module COMP3032. The task was to extract a contour which corresponds to the human tongue shown in the ultrasound image shown below:

The first step was to narrow the search area by applying some boundary conditions. The red points in the image above represent these conditions. The region is extracted by joining up the points and sampling along the lines. Next an energy functional was defined to describe a 'good contour'. An optimal contour will be smooth and have high intensity. The end result is shown below (Note: pixel values have been inverted i.e. negative image):

The contour is a good representation of the tongue and because the energy functional places equal emphasis on smoothness and intensity, it is not affected by the noise (high intensity pixels near the centre of the search area). With a week left before the deadline I hope to improve the computation time and experiment with changing the various parameters.

Sunday, 23 November 2008

Trouble in Ambridge

My Dad likes the Archers, so does my mum. Up until about 5 years ago, My dad would record the omnibus onto cassette for playing in the car during commutes to work and back, likewise my mum would listen to it in the house on the hi-fi. Then my dad bought a car without a tape player, so I taught him how to record the omnibus using his computer (connected to the hifi with a line-in cable), this worked but required editing the audio file in Audacity which my dad never got on well with.

Finally earlier this year my Dad entered the 21st Century and began downloading the archers podcast from the BBC website. This was by far the simplest and quickest way. This was until the company my Dad works for banned multimedia content downloading on the company network. The only other connection in the house is dial-up so i promised to develop a work around.

I have written a python script which parses the RSS feed for the archers podcast, extracts the .mp3 links, downloads them to a temporary directory, compresses them into a single zip file which, with the help of a bash scrip, gets uploaded to my University web space for my dad to download every Saturday. The script is shown below, but the reason I blog about this is because for the first time in my linux lifetime, I have written a script to do a task in less time that it would have taken to just do it manually! (hence time to blog)

The only remaining task is to get the script to trigger automatically every Saturday without me having to remember. But Google calendar reminders will suffice for the time being!

import feedparser
import urllib
import os
import zipfile

TEMP_ADDRESS = "/tmp/archers/"

feed = feedparser.parse(ARCHERS_XML_URL)

shows = feed["entries"]
episodes = []

for show in shows:
mp3_url = str(show["links"][0]["href"])
print "Retrieving: "+mp3_url
fname = os.path.basename(mp3_url)
f = urllib.urlretrieve(mp3_url, TEMP_ADDRESS+fname)
except IOError:
print "Couldn't retrieve file: "+mp3_url


all = zipfile.ZipFile(TEMP_ADDRESS+"", 'w')
for file in episodes:
print "added "+file+" to zip archive"
print "Faile to write "+file+" to zip archive"
all = zipfile.ZipFile(TEMP_ADDRESS+"", 'r')
if all.testzip() == None:
print "succesfully wrote episodes to zip file"
print "failure writing episodes to zip file"
print "end"