About   |   Projects   |   Elsewhere   |   Work   |   Feeds   |   Contact

Posts Tagged ‘panda’

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