Interesting Tech Projects
Andy
Located in Tucson, Arizona, USA
Homepage: http://www.britishideas.com
Posts by Andy
Radio Controlled Aircraft for Stroke Victims
Oct 23rd
This post introduces my open source radio control project. It allows an RC aircraft to be controlled from a Wii Nunchuk, i.e. with one hand! Videos will be posted when they are available but so far it is working great in the flight simulator and with a stationary aircraft.
All documentation, source files and binary files are available for free from this site, so you can build your own. Be sure to read the disclaimer before you start however.
I would love to hear your success stories using this modular system!
Creating Package Installers for MonoMac
Sep 25th
When developing applications with Mono/MonoMac it is very useful to create an installer that bundles Mono with your application. MonoMac includes a utility for creating an installer but unfortunately it is bug ridden and limited. Here are the steps that work for me.
Note: make sure you have Xcode installed.
- Delete any existing bundle. For example MyApplication.app. This is important because if the bundle already exists when you try to create it MonoMac will give you the cryptic error message “Unhandled error in packaging”
- In MonoDevelop go to Project -> Create Mac Installer… and choose to only create a bundle

This should create a bundle with a name like MyApplication.app - Start PackageMaker by going to Spotlight and searching for it. It can also be found in /Developer/Applications/Utilities.
- Drag your bundle MyApplication.app to the left hand side of PackageMaker.
- Select the package, click on “Components” and uncheck “Allow Relocation”

- Build and run the installer
You may or may not want to uncheck the option to allow relocation. On your development Mac if you don’t uncheck this then the installer will find a version of your application inside your MonoDevelop solution and overwrite it rather than putting it into /Applications. This makes it appear as if the installer didn’t work. On non-development Macs this option allows the application to be overwritten even if the user has moved it after installing an older version.
Global Objects With MonoMac
Sep 24th
When developing for C# and using Windows Forms creating and using global objects is trivial:
public static class Program
{
public static Foo MyFoo = new Foo();
static void main()
{
Main = new MainForm(MyFoo);
}
}
The same can’t be said for MonoMac. The mistake is to equate the static MainClass class as being the same as the WinForms Program class in the example shown.
The solution is to put the global class instantiation inside the NSApplication delegate. MonoMac creates this automatically and calls it AppDelegate. The above example becomes:
public partial class AppDelegate : NSApplicationDelegate
{
MainWindowController mainWindowController;
public Foo MyFoo = new Foo();
public AppDelegate ()
{
}
public override void FinishedLaunching (NSObject notification)
{
mainWindowController = new MainWindowController(MyFoo);
mainWindowController.Window.MakeKeyAndOrderFront(this);
}
}
Not All Wii Nunchuks Are Created Equal
Aug 29th
What is the difference between the two Nunchuks below?
Quite a lot actually. The one on the left was bought on ebay for £3.50 and came with no packaging or information. The one on the right was bought from Amazon for £11.20 and came with Nintendo packaging and a warranty. Read on for details of all the differences I discovered. More >
Reading a Wii Nunchuck Using I2C
Aug 20th
There are plenty of descriptions on how to read the joystick, accelerometer and button values from a Wii Nunchuck using I2C but I haven’t seen any waveforms. So here are mine. Click on the images to see them in full size.
The I2C bus was running at about 100kHz. The time between the handshake and the first data read sequence is about 1.8ms and the time between each subsequent data read sequence is also about 1.8ms, although I feel that these times can probably be reduced.
Unlike many code examples I have seen there are no delays between each write operation in the handshake or between the write and read operations of the data read sequence.
First up is the handshake to send “unencrypted” data:
Next is the data read sequence containing a six byte chuck of data with the values we need:
Hopefully these will be useful to people developing application with a Wii Nunchuck.
Fast Reading of XML Files
Jul 14th
I recently had the need to parse 780MB XML files, and quickly. My preferred language for PC development is C# because I can work quickly and efficiently with it, however I was a bit wary of the speed of XML file processing. Thankfully Mike Taulty has worked out a solution using LINQ and XmlReader, providing the user friendliness of LINQ with the speed of XmlReader.
An initial test showed that a 39MB XML file is processed in 4.9 seconds using Mono on a quad core server running Ubuntu. This is about 8MB/second which means that my 780MB file should be processed in around 98 seconds. Nice!
Convert Any Audio Source Into MP3
Jul 6th
Here is my method that I know works. If you have a better one feel free to post it in the comments section. It may not produce the best quality audio but I’m sure it can be improved.
Obtain a 3.5mm to 3.5mm audio cable, for example this one. Connect one end to the audio source (for example a PC) and the other end to the microphone in on your linux box (I tried line in but that didn’t work for some reason).
Make sure ALSA utilities and ffmpeg are installed (at a console prompt):
$ sudo apt-get install alsa-utils ffpmeg
Start recording with:
$ arecord -f cd -t wav test.wav
Start the audio source and once complete press Ctrl-C to stop recording. Convert to MP3 with:
$ ffmpeg -b 128k -i test.wav test.mp3
I then run the file through MP3Gain as the recordings tend to be a bit quiet and add tags in iTunes.
Internationalization in Silverlight
May 10th
For some reason Microsoft have made it difficult to work out how to support multiple languages in Silverlight. The solution isn’t hard, once you manage to work it out. It is complicated by the fact that accessing string tables in C# is completely different to accessing them in XAML. Plus there is a nasty bug in Visual Studio which apparently still isn’t fixed.
However, never fear. After trying several approaches, all of which failed in some way, the solution can be found on timheuer.com. Tim presents a clear and straightforward method without needing to do anything weird (except for the Visual Studio bug workaround).
Graphing Ping Times
Mar 29th
I recently had the need to generate a graph of ping times between my PC and a British Telecom server. After a quick web search the only options I found were commercial programs or free software that was incredibly bloated, complex to configure and with lots of dependencies. There must be a simpler way, and there is. Perl.
Here is my script:
#!/usr/bin/perl
# Converts ping output into a CSV file for graphing
# andy at british ideas dot com - March 29th 2011
# Public Domain
# Run using:
# ping -D 100.101.102.103 | ./pingtocsv.pl > output.csv
# or:
# cat pingdump.txt | ./pingtocsv.pl > output.csv
print "Measurement Time,Ping Time\n";
while (<STDIN>) {
if ($_ =~ m/^\[([0-9\.]+)\].*time\=([0-9\.]+).*/i) {
print "$1,$2\n";
}
}
close(STDIN);
The Progress of Linux
Mar 4th
Back in 1998 I tried installing RedHat 6 on a spare PC. When the desktop loaded it was, ummm, wobbly. I then spent the best part of the next two weeks fighing with X configuration files setting obscure items such as front and back porches in a futile attempt to stabilize the display so it would be usable. I gave up.
Fast forward to March 2011 and Ubuntu 10.10. I’ve used lots of different versions of Ubuntu since 2006 on a variety of machines including for CNC control, but the last time I installed in a dual boot system was two years ago. Ubuntu 10.10 works fine in a virtual machine inside Windows 7 but I wanted to run it at full speed. More >


