About   |   Projects   |   Elsewhere   |   Work   |   Feeds   |   Contact

Posts Tagged ‘arduino’

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

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