About   |   Projects   |   Elsewhere   |   Work   |   Feeds   |   Contact

Archive for the ‘Play’ Category

Howduino and panda hacking

3556669644_7e72ed13e0.jpg
I spent yesterday in Liverpool at Howduino – billed as a “one day event about connecting the internet to the real world, breathing life into inanimate objects and creating new ways to interact with things”, it took place at FACT (somewhere that’s worthy of a blog post in itself).

Imagine a room full of geeks, artists and hackers who’d been let loose with soldering irons and toys, and then throw in the capabilities of Arduino boards. The end results ranged from painting with bristlebots through to circuit-bent Furbies.

I took my panda along, together with a box of analogue meters. Ebay is a fantastic source of that kind of retro kit, and I’ve picked up several moving-needle meters from the late 50s for less than a tenner each. The main plan, though, was to fit an old aircraft fuel-flow meter into the panda so he could display trends and changes in an easier-to-visualise way than the LEDs.

The meter itself is just a basic voltmeter with a dial calibrated from 0 to 800 lbs per hour – presumably it came out of some kind of jet, although I’m not sure how big an engine that would imply. There’s an XLR-style bayonet connection on the back, but I drilled two holes into the back of the case and soldered flyleads onto the internal terminals to make things easier. Then the panda got hacked open, and the meter was hot-glued into the wound.

Actually getting it to work was a bit of a challenge, however. The first problem is that the meter is *incredibly* sensitive – full-scale deflection takes less than 0.5 volts. The Arduino’s analogue outputs range from 0 to 5V, so I had to connect the Arduino output to a voltage divider (having first tried to figure out the right resistor values with a rotary potentiometer.) The PWM output from the Arduino runs from 0 (off) to 1023 (full on) with the duty cycle ranging roughly linearly between the two, so it’s just a case of adjusting the deflection to full-scale at 1023, and the rest falls into place.

The biggest problem, though, was with the Arduino itself. I’ve got a Ethernet shield which fits on top of the main board, and had that linked to an old ADSL router with a 4-port hub. Getting to the outside world took longer than I could be bothered with tinkering, so I ended up running a server locally on my Mac with MAMP to give the Arduino something to talk to.

Getting it talking needs the Ethernet library, and that’s buggy. It would connect fine the first time, but then crashed immediately you tried to establish a second connection. Adrian McEwan (who organised the whole thing) pointed me in the direction of a patched version, but I didn’t R the FM closely enough and only installed the library file. You actually have to remove the (old) compiled version as well – once I’d figured that out, the code started to function as it was supposed to.

The Arduino sketch establishes a connection to a server and grabs an XML file using the Ethernet methods. That then gets parsed using the unfeasibly low-tech string library and finally converts the XML value into a PWM value which controls the duty cycle of the analogue output. Because of the inertia of the needle, the pulses are smoothed out and the display reads steady.

The XML file could come from virtually anywhere – Pachube for example – but I’ve got a few Ruby scripts running on one of my servers that does some manipulation before creating the final values as XML. The challenge now is going to be the data source – and ideally something with a range from 0 to 800, and units of pounds per hour. Any suggestions?

24 May 2009

Play

2 comments

Panda vivisection redux

Market BearSigning up for Howduino in Liverpool on May 23rd has been a bit of a kick up the proverbial for my otherwise somewhat-moribund Market Bear project.   The panda is now vivisected and has LEDs for eyes, with a rather alarming trail of wires leading from his tail.   Getting the LEDs to sit in place was something of a challenge, but I eventually hit on the idea of threading two legs of the LED through a four-hole button, and using the other two holes of the button to secure it with thread to the inside of the panda’s “eye sockets”.

Codewise, I’d originally planned on putting up a simple Ruby script that spat out a webpage which could be ingested by the Arduino code (via the Ethernet shield).  The problem with that approach is that an HTML page comes with an awful lot of cruft that the Arduino has to dump, which is expensive on memory.   So after a bit of head-scratching, inspiration struck and I’m now generating XML from the Ruby script, which is a) a much cleaner format to have to parse; and b) altogether smaller.

I’ve also used the project as a reason for bootstrapping my Git-fu, so the code is now up on Github for the world to laugh at.   Up until now I’d always thought that the “social coding” strapline of Github was a bit – well, possibly pretentious, and certainly abstract – after all, there aren’t many activities LESS social than coding (unless you’re pair programming.)   But taking the plunge and committing code that other people might see is suprisingly nerve-racking – what if it’s rubbish?  What if people laugh at it?  What if they realise that you’re actually doing more adapting of other people’s code than creation of your own?   All of the above are true in my case, of course.

In any case, the panda continues to be sacrificed in a noble cause, and I’ll be interested to find out what people make of it in a couple of weeks…

5 May 2009

Play

2 comments

Mashed-up expenses

With all the controversy over MPs’ expenses, I wasn’t unduly surprised to see that Parliament have released the raw data in PDF form. Nice for presentational purposes, but bugger-all use for analysis. Funny, that?

I briefly toyed with attempting to convert from PDF to spreadsheet, but the Guardian got there first – and they’ve released the raw data in Google spreadsheet form so anyone can mash it up and see what happens. Cue some hacking…

MySociety’s TheyWorkForYou site has an API that allows you to do all kinds of intriguing things, including retrieving geographical data about constituencies. A few Ruby scripts later, I’ve got the raw data pulled down – the latitude and longitude of the constituency centre point, from which it’s a very quick job to calculate the distance from Westminster using a great circle calculation. I figured that as I was mainly interested in travel, using Westminster tube station as the centre point from which distances were calculated would be a good-enough approximation. Of course, it’s a bit of a rough calculation – the centre of the constituency isn’t necessarily the point from which the Member travels, and if the constituency has an odd shape it’ll distort the result slightly. But no more than they’ve been distorting the system…

The results are here –> http://spreadsheets.google.com/ccc?key=pX5xUAGpnOKXBe3rY77M9AA&hl=en_GB There are one or two glitches – for some reason, the Northern Ireland constituencies don’t have lat/long data so those are broken, and there’s the possibility that things got slightly mixed up for MPs that share surnames. But a quick scan suggests it’s OK.

The next stage would be to start correlating between distances and expenditure on travel, and plotting this in interesting ways. Cue a rapid learning curve on Google Maps.   This is something of an overnight hack project, but it does raise some interesting questions about the way data can be interpreted in ways that the originators probably didn’t expect – I’d be amazed if Google Maps mashups ever crossed the minds of the Commons Fees Office when they (reluctantly) released the information.   Given the raw data, some controversy and geeks with time on their hands, it’s unsurprising that interesting things result.

2 April 2009

Play

No comments yet

Toy abuse for fun and (non)profit

3345221754_7dd629b539This is a panda who has been volunteered to donate his eyes in the cause of – well, something or other.

I picked him up in a charity shop for a pound (is there anything sadder than the toy shelf in a charity shop?  I can’t help wondering how many toys ended up there after their owners were struck down by childhood leukemia or something) so technically, he’s recycled.   I chose a panda for two reasons – one, because I happen to like pandas; and two because their black eye patches mean that you can’t normally see their eyes particularly well.  This will become more important later…

The original idea was sparked by the phrase “a bear market” – so instead, this is a market bear.   In place of eyes, he’s going to have tri-colour LEDs – which will change colour according to how well the stock market is doing.   When it’s going down, he’ll glow red, and when it’s going up, he’ll glow green.   And if there’s been no change, the LEDs will just light up yellow.

There’s also going to be a button inside his paw, which will rebase the scale to the current value of the market – so squeezing his paw will switch the LEDs back to yellow, and then they’ll change colour the next time the market changes.

Although you can’t see it from the photos, he’s actually a glove puppet.  That’s ideal for my vivisectionist purposes, because it means he’s hollow enough to stuff the electronics up inside.   These are an Arduino microcontroller and an Arduino Ethernet shield, which will connect him to the interwebs.   Ideally I’d have preferred a wifi connection because then he won’t have cables emerging from his colon, but that’s for the next generation of mutilated soft toys.

The software is in two parts – there’s a server-side component, which grabs the market data from the Guardian website (I’m using the Guardian because their site is nicely laid out for scraping purposes, and they hopefully won’t be too upset if they find out) and then does the calculation to decide whether it’s up or down.   That feeds back an “up”, “down” or “same” response when polled by the Arduino sketch – which feeds the appropriate voltage onto the analogue outputs to light up the LEDs.   Squeezing his paw fires off a message to the server to rebase the calculations, so the up/down/same algorithm can start from wherever the market is standing at the point of squeeze.

The next stage is to grab the magnitude of the change and fade the LED up and down accordingly – bright for a big change, and dimmer if it’s smaller.   But getting my head around the Arduino Ethernet library is a big enough challenge for the moment, so to start with I’m going with the simple version.   So far it’s working on a breadboard, so the next stage is to build the circuits for implantation into the eye “sockets” and paw.  Extracting the eyes was something of a challenge, because they’re fixed in with fasteners designed to withstand small children gnawing on them – so removal was a case of sheer brute force and application of Tools.   There’s a set on Flickr which documents the whole gruesome process.

[Update: Panda vivisection redux]

12 March 2009

Play

1 comment

I've been climbing mountains again

Lunch at the top

23 January 2009

Play

No comments yet

Today I climbed a mountain

Today I climbed up a mountain

There was a lot of water around.

This is what I saw when I got to the top:

The video is a little bit wobbly because it was blowing a gale up there, and I had trouble standing upright *and* holding a camera steady…

20 January 2009

Play

No comments yet

Lyddle End ideas

img_1983I’ve had a Lyddle End model sitting on my desk for a few weeks now, and I’ve been getting increasingly depressed seeing the waves of imagination that all the other ideas have been born of.   Which put me in a bit of a dystopian mood, hence this.

I started wondering about how my Parish Hall would be used in 2050. I decided it would be an outpost of the National Identity Register where the residents of Lyddle End would go to be scanned, processed, assimilated or shipped off to reeducation camps. (By rails, of course).

19 January 2009

Play

No comments yet

Bursting a stock market bubble

BalloonsMy stock market Twitter bots (@ftse100, @nikkei225 and @dowjonesindex) are tweeting away nicely, but they’re all a bit – well, online, really.   I think it would be far cooler if it was more visual and tangible.  This is what I’ve got in mind.

A Cron job kicks off a Ruby script, which grabs the current FTSE (or whatever) price and feeds that to Processing sketch which runs an Arduino controller.  The controller is hooked up to a three-way valve – one outlet is attached to a compressed air cylinder, while the other is vented to the atmosphere.  On the third outlet there’s a party balloon – ideally one of the long, thin, sausagey types.

As the market goes up, the compressed air valve opens to inflate the balloon, and as the market drops the vent opens to deflate the balloon.  A quick glance at the balloon gives you an instant feel for the state of the market – flacid, and it’s all doom and gloom; priapic, and the IPOs are going well.

The other advantage is that it would be easy to detect a stock market bubble because the balloon would either burst or pop off the valve and fly across the room.  Although I’ve probably chosen the wrong time in the economic cycle for this to happen very often.

The cron and the Ruby and the Arduino and the Processing bit are all reasonably straight-forward, but I’m struggling to find suitable air valves.  I was wondering about using fuel injectors from a car engine, because they’re controlled by a pulse-width modulated signal, but I’m not sure whether that would work or not.   Anyone else got any ideas?

[CC-licensed photo by Jakob E]

14 January 2009

Play

1 comment

Twittering Thames

ThamesOne of my usual London commuting routes has me walking along the riverside past City Hall in the morning, and back the same way in the evening.  It’s a fairly uninspiring inland view, because it’s home to a succession of utterly forgettable glass boxes housing the likes of Ernst & Young and Norton Rose – which does at least have the benefit of making me thankful that I work in an environment where people actually do wear space cadet uniforms to meetings.

The river itself, though, more than makes up for the corporate drone hutches.   From this side, you can see the Tower of London and Tower Bridge, and just along from HMS Belfast there’s moorings for the MV Tidy Thames, which shuttles up and down the river as a floating dustcart removing the odd dead whale now and again.   This, and all the other routine traffic like the police launches and the ferries make the River Thames seem like a real, live entity that is a pale shadow of its former self – but still alive if often overlooked.

One of the things that intrigues me about the Thames is that it’s tidal, with about 6 to 7 metres of rise and fall between high and low tides.  You don’t think of rivers as being this dynamic, and it seems to change the personality of the Thames every six hours or so.   At low tide, the mud and the shingle is exposed, and it looks like a sluggish stream – but six hours later, it’s less than a metre from the top of the embankments and there are ominous whirlpools that suggest that falling in would be a Very Bad Idea indeed.

Although I walk along it most mornings, once I’m in work I can’t see the river unless I hang out of a window and annoy the bosses – so the connection gets lost.   My connection to the web is pretty much constant during working hours on the other hand, which gave me the idea of making the river twitter.  After all, if Tower Bridge can twitter when it’s going up and down, then why not the river itself?

The Port of London Authority publish the tide tables online, but in a format that’s pretty much useless (or far, far too complicated) to grab and parse into a Twitter feed.  The BBC, on the other hand, have a nicely-formatted version which lends itself rather well to being scraped.  So every hour my server grabs the page and parses it to check if there’s a high or low tide predicted within the next 60 minutes, then tweets the time and the depth if there is.  It’s fairly simple stuff with a cron job, the Hpricot parser and some Ruby glue.

Taking a cue from Tower Bridge, I think it’s important that it’s done in the first person – after all, the river’s known as Old Father Thames, and it’s easy to anthropomorphise.   I also tweaked the wording of the tweets so that if the tide is due within the next 10 minutes, the river urges you to hurry up so as not to miss it.

It’s a very trivial example of making real world objects interactive, but I think it’s indicative of something quite interesting – something that Russell “Interesting” Davies has explained far better than I can.   Buildings and other inanimate objects *do* get human traits associated with them, and I’ve always been intrigued by the concept of the company – something that doesn’t physically exist, but yet has tangible manifestations.  One of my absolute favourites is Laphroaig whisky, who allow you to “claim” a 1 square foot patch of land alongside the distillery.  Laughable if you think about it too hard, but a great way of establishing some kind of deeper “bond” with your customers (or drinkers).

And the possibilities are quite literally out of this world, at least if Lowflyingrocks has anything to do with it.

14 January 2009

Play

2 comments

Twittering the pips.

This is possibly the most pointless Twitter bot ever, but @thepips now Tweets on the hour.

It’s a British thing.

13 January 2009

Play

No comments yet