Tag Archives: automation

Train your rat: behavioural science at home

via Raspberry Pi

Skinner boxes are a kind of apparatus used for conditioning and training animals in scientific studies. You’ll almost certainly have read about them or seen them on TV: an animal is rewarded with a treat for pressing a button; or trained to respond to a patter of lights or other stimuli (like shapes, music and other sounds, or drawings). This is the sort of arrangement where a sequence of behavioural primitives (light flashes green, animal pokes green button, is rewarded with a snack) can be threaded together to create really useful data for behavioural scientists. Is it harder for an old mouse to learn to solve the puzzle than a young mouse might find it? Do other environmental variables, like diet, gender or temperature affect the results?

rat eating someone's lunch

An example rat, engaging in behaviour.

They’re not just used by behavioural scientists: a Skinner box can be a useful device for training pets, especially pets with a reasonable amount of smarts, like parrots or rats. It can automate the process you may have already used with your pet, where “correct” behaviour is rewarded – walk to heel, get a doggy snack. (We also find this approach helpful here at Pi Towers. When Gordon behaves himself, we give him a biscuit.)

Skinner boxes are also pretty expensive.  So Katherine Scott, computer vision and robotics expert, electronics ninja and rat owner/trainer, has built her own, which she intends to release as an open source device when she’s finished refining it.

Open Skinner box

Prototype Open Skinner box, with ratty customer.

Katherine didn’t just want any old Skinner box, though – Open Skinner box is an Internet of Things device, and she says:

I wanted to create not just a Skinner Box but a web enabled Skinner Box, a sorta internet of things Skinner Box. So what features should it have? I came up with the following list:

  1. I should be able to see the rats using the Raspberry Pi’s camera.
  2. The camera data should be used to create a rough correlate of the rat’s activity.
  3. The box should run experiments automatically.
  4. I should be able to buzz and feed the rats remotely.
  5. The web interface should give a live feed of all of the events as they happen.
  6. The web interface should be able to give me daily digests of the rats activity and training.
Live camera output from the box

Live camera output from the box


Rat stats

Katherine presented Open Skinner box at Pycon: you can watch a video of her presentation at her website, and find schematics, source code, sample rat-stats, thoughts on where the device is going next, and much more there too.

Here at Pi Towers, we’ve been contemplating the acquisition of an office rodent, so we can make sure that the pet projects we’re working on for the resources section here work properly. (How many hamsters does it take to trigger a home-made tinfoil switch? What’s the best design for a Twitter-enabled food hopper?) If you’ve got suggestions for names, please leave them in the comments below.

Automated decanter

via Raspberry Pi

I had mail from Jürgen Huber at Logi.cals, an Austrian software firm, who have been using a Raspberry Pi in a demo at trade fairs to show off logi.CAD 3, their new, free, software tool for automation. It’s right up our street: they’ve made an automatic decanting machine.

Decanting machines, usually operated by via a hand crank and a threaded rod, turn up in the sort of restaurant I don’t go to as much as I’d like to: the sort of places where you’ll find old bottles of fine wine with delicate contents, which need very careful decanting to gently aerate the wine without over-oxygenating it, while leaving behind any sediment.

Logi.cals’ version looks a bit less gentleman’s-club, and a bit more spaceship.

Here it is in action, making some poor sommelier somewhere slightly less useful.

Micro switches check that both a glass and a bottle are present (which reminds me: we really need to update the Pi Towers coffee machine to detect a mug in order to stop the carpet getting soggy). Light barriers assess the position of the bottle, and capacitive sensors detect flow, and detect how much wine there is in the glass. The bottle is weighed so the Pi knows how much wine is left; the glass is also weighed with a strain gauge so that the Pi knows what’s in there. Jürgen’s team even added an emergency brake.

A stepper motor tilts the bottle gently. The team at Logi.cals used two expansion boards: a PiFace and a Quick2Wire board, to talk to the I2C bus, the motor and the strain gauges: you can read more about the setup at their website.

It’s a great proof of concept. This isn’t going to be a commercial product, so if you’re a wine waiter, you can sleep easy: the rest of us will be dreaming sweetly about robo-boozing.

Jack the (DVD) Ripper

via Raspberry Pi

The shelves in my living room are groaning under the weight of DVD boxed sets – and I just can’t bring myself to sit down and rip them all. All that waiting around! And it’s impossible to remember that you’re going to have to swap discs to and from a drive every hour or so. So the pile of boxed sets grows, and grows, and grows, and soon I will have enough be able to start building a new house to keep the DVDs in out of the packaging.

So I was extremely pleased to be introduced to Jack the (DVD) Ripper, a 3d printed, Raspberry Pi-powered device that pulls a DVD from a stack, drops it into a drive, and, when the drive opens after ripping is finished, picks it up again and puts it in another pile.

The whole system runs autonomously, so you can go and get on with whatever it is you do when you aren’t ripping DVDs.

Andy Ayre, who built the project, has made a five-part tutorial available, with an introduction and parts list, mechanics, electronics, software and troubleshooting tips. Datasheets, documentation, software and everything else you’ll need are available on GitHub. We love it – you get to save a ton of time and have some fun with 3d printing and motors, all at once.

Pato surveillance system

via Raspberry Pi

Pato is a little green bird who Jorge Rancé found, injured, on the street in Barcelona, and rescued. He was in a bad way, with a broken leg and the feathery equivalent of a terrible hair day.

Pato after a visit to the vet, his broken leg in plaster

Jorge took Pato to the vet to be patched up, and took him home to recuperate in a large birdcage at his house. But he worried that he wouldn’t be there to oversee Pato’s recovery while he was at work. Fortunately, Jorge has a Raspberry Pi. So, using a Pi-Face to interface between the Pi and some sensors, he set up PATOSS: Pato Surveillance System. Now Jorge (and you) can check out how Pato is doing from anywhere in the world.

PATOSS monitors Pato’s recovery by streaming video of what he’s up to to the web, checks on the ambient temperature and the water levels in his little dish, and tweets once an hour to let Jorge know whether everything’s as it should be, with a live picture from Pato’s webcam. The data is transmitted via a wifi dongle.

(If you’re following the PATOSS feed today, don’t panic; Jorge says that the water level monitor is not currently hooked up, so it’s reporting low levels, but Pato does actually have plenty to drink.)

Jorge has full build instructions on his website, with a hardware list (and prices), code, diagrams and tips on housing. The whole PATOSS system is Creative Commons licensed so you can adapt it for your own needs – it’ll be interesting to see if anyone comes up with a Raspberry Pi camera board variant.

PATOSS (left) and Pato (right)

This sort of build is easy to replicate at home. We think it’s a particularly good project for kids with small pets at home who want to apply some computer science to something they really care about. They’ll be able to see real-world results and share them with friends: what could be better than being able to check up on Woffles the hamster’s daily grind via Twitter from school? If you and your children’s pets end up using a PATOSS system at home, please let us know – I’d love to share your results!


PiPlanter: a plant growth monitor

via Raspberry Pi

We’ve see a lot of clever irrigation devices for gardeners being made with the Pi, but PiPlanter is the most complete (and the best documented) system we’ve seen so far. It does far more than simple irrigation. PiPlanter monitors temperature, ambient light, ambient humidity and soil humidity; it outputs that data to a MySQL database, controls a pump to water the plants depending on that data, and outputs the data as graphs and text. (It also tweets that text and uploads the graphs to Flickr hourly so that Devon, the PiPlanter’s owner, can keep an eye on things.)

Devon has documented the build minutely, with circuit diagrams, a ton of code, and several videos. Here, he explains more about the sensor array he built.

You can read much more at Devon’s blog, and replicate the project yourself. Thanks Devon: more power to your green thumb!

Pi-Rex: a bark-activated door opener for dogs

via Raspberry Pi

Here’s a weekend project from Dave Hunt for dog owners whose best friends can’t work out whether they want to be inside or outside.

Dave came up with Pi-Rex when the sleep deprivation caused by his new dog barking to be let in or out alternately became too much to bear. She tends to do it at the same time every morning. Dave says: “I could do this with a timer switch and a door strike, but where’s the fun in that?” Indeed, Dave. So instead, he’s made a door that responds to barking. Barking.

You absolutely have to watch the video. I’m not sure whether I enjoyed Dave’s dog impression or his reaction to the door opening the most, but the combined effect had me snorting coffee.

A noise detection circuit tuned to respond to loud dog sounds fires a motor which unlocks the door, and a weight (actually a large bird feeder) and pulley system swings the unlocked door open. Dave says: “I picked up the audio detection circuit in Maplin as a DIY kit for €9.99, the kind of ones where you get all the components and a PCB in a bag, and solder them all together. It took about 30 minutes, but worked perfectly; I could bark, and the LEDs would light as I barked. My family thought I was gone mad when they heard me making dog noises in my workshop.”

Dave, this is magnificent work.

If you want to set up Dave’s dog-operated system in your own house, head over to his website, where all the code you’ll need, some wiring instructions and a parts list are available. He suggests you might like to sample the audio collected and make the door respond to…known barks. I do have one question, Dave: have you trained the dog to shut the door behind herself yet?

Open source PLC

via Hack a Day» hardware


In industrial applications, controlling relays, servos, solenoids, and the like isn’t just a matter of wiring in an Arduino and plugging in some code. No, for reliable operation you’ll need a PLC – a programmable logic controller – to automate all your hardware. PLCs are usually pretty expensive pieces of hardware, which led [Warwick] to come up with his own. He built two versions, one large and one small that can handle just about any task thrown at them.

Both devices are powered by an ATMEL SAM7S ARM chip running at 48 MHz. The smaller of the two devices has 10 digital inputs, 4 analog inputs, and 8 digital outputs able to sink 200 mA each. The larger PLC has 22 digital ins, 6 analog ins, and 16 digital outputs. Both of these devices have a ton of connectivity with USB, RS-232 and RS-485 ports

Below you can see the large PLC being used as a barcode scanner and as a strange device using compressed air to levitate a ping-pong ball. There’s also a demo of the smaller PLC lighting up some LEDs.

Filed under: hardware

Pi-powered cat feeder

via Raspberry Pi

Mooncake, the Official Raspberry Pi Cat, is fed biscuits twice a day by an off-the-shelf cat-feeding robo-hopper that we bought before Raspberry Pi was a reality. (She also gets that horrible-smelling cat food in gravy from a packet, served up by real live humans.) I’ve just found out what to replace the robot with when it breaks.

Mooncake, well-nourished, “helping” us to dispatch fund-raising stickers

Dave at Twin Cities Maker has made a Pi-powered cat-feeding robot which dispenses two sorts of biscuits, so your fickle pet has a choice of different liver-flavoured kibbles throughout the day.

Dave’s cat feeder, with toaster for scale

It’s much more functional than the one I bought from the pet shop years ago; for a start, it’s wi-fi enabled, so it can be sent instructions remotely. And Dave has plans for making it even whizzier, with sound clips (Cat from Red Dwarf), a camera and a mobile webUI.

Work in progress: this is an Adafruit PermaProto with a couple of solder bridges at the top left. Instructions are on Dave’s blog.

There are full build details, code and a parts list over at Twin Cities Maker. Here’s the feeder in action:

We’re looking forward to see what additions Dave develops for the feeder. Seriously; if you can make this thing self-cleaning, Dave, you can sit back and never have to work again. Cat owners the world over will be banging your door down.

Calibrating a 3D printer with a Raspberry Pi

via Raspberry Pi

Jon Wise mailed Eben last night to tell us about a 3D printing project he’s been working on, and we thought it was so great we watched the video three times before going to bed. If you’ve ever used a 3D printer you’ll know that they need regular calibrating to make sure that the output is accurate. You have to ensure that various parts are parallel and orthogonal to each other, or your 3D object is likely to come out wonky; things are moving around on three axes, and usually you’ll be doing that calibration by hand.

Jon is sick of hand-calibrating, so he’s used a Pi to do the work for him. This video is a demonstration of how his setup works, using a pencil instead of the usual extrusion nozzle so you can better see what’s going on.

We got talking to Jon about how significant he thought the improvement in resolution you can get from automating calibration might be. He said:

I do not see it as competition to a machine tool approach, but for building products in new areas. I have a friend who would like to build edible products and this was one of the prompts to try alternative layouts – it would be easier to clean icing sugar off the flat base plate than from belts and bearings and the build platform could go into the dish-washer.

The design could be easily scaled by running on a large sheet of material as the arms are light and take no bending forces. The overall size will be big compared to the product but all designs have some down-sides. The key aspect is that anyone can make it. The rack and pinion bits are available from hobby stores and can be linked to any length. The motors come from old printers. There isn’t anything else.


We think this project is great. Using computing to automate repetitive tasks like this frees up time to use your brain to do other more interesting things, and leaves you more productive and more cheerful. It’s one of the reasons we think that giving everybody the opportunity to learn how to do this stuff is so important. What have you automated recently?


via Raspberry Pi

Coffee and computing go hand in hand. The world’s first live streaming webcam was pointed at a coffee pot in the Cambridge University Computer Lab’s Trojan Room (yes, Americans, I know you think that sounds funny), back in the days when it was on a shared site in the centre of Cambridge and none of us had even heard of the internet.

It was 1991. A young Quentin Stafford-Fraser was researching ATM networks in the Trojan Room, and drinking too much coffee. Other people in the lab also liked fresh coffee, but there was only one coffee machine between 15 researchers, it was a long walk up an awful lot of stairs to get to the Trojan Room, and all too often, the pot was empty and the walk upstairs wasted. (I think “wasted” is pushing it a bit far. Quentin’s very good conversation.)

Ever practical, Quentin pointed a camera at the Trojan Room coffee pot, hooked it up to a video frame grabber the ATM researchers were using, got Paul Jardetzky to write some server software, and wrote the client software for it himself. Researchers downstairs could now ping the coffee pot to see whether there was anything in it. “The image was only updated about three times a minute, but that was fine because the pot filled rather slowly, and it was only greyscale, which was also fine, because so was the coffee.”

Trojan Room Coffee Pot

Quentin didn’t realise it at the time, but he had laid the grounds (badoom tish) for the world’s first webcam. In 1993, the <img> tag was added to HTML, meaning you could embed pictures on a webpage. The same year, two more researchers at the lab, Dan Gordon and Martyn Johnson, made changes to the original coffee pot setup to allow it to respond to requests from the internet, and xcoffee became the first ever live webcam.

The Trojan Room Coffee Pot stayed in place (and maintained an online presence: in 1996 it got its millionth hit, and journalist Steve Farrar noted that it had had more ‘visitors’ than King’s College Chapel and was therefore the number one tourist attraction in East Anglia) until 2001, when the University Computer Lab was moved out of its ramshackle old site to a shiny new building in West Cambridge. I was lucky enough to be at the university just before the move, and drank a couple of cups of coffee from the machine, courtesy of friends at the lab. (Quentin is right about the greyscale thing. Historic it might have been, but it was bloody awful coffee.) Eventually, the pot was auctioned on eBay to raise money for coffee-making in the new lab; Der Spiegel Online bought it for £3350. Apparently, Krups refurbished it free of charge, and it’s still making greyscale coffee for an office full of German journalists.

Anyway. This long preamble doesn’t have much to do with the Pi. (About an hour after I originally posted this, Barney Livingston pointed out on Twitter that The Trojan Room Coffee Server was an Acorn Archimedes, so shares its ARM processor heritage with the Pi.) But it does demonstrate that projects involving coffee and computers have a long and storied history in this part of the world. Technology has moved on, but the coffee is still supremely important. So Sacha Wolter from Deutsche Telekom has incorporated a Raspberry Pi into his coffee machine. It’s a bit more sophisticated than the Trojan Room Coffee Pot; Sacha’s coffee machine rings him up when the coffee’s ready, and if Sacha places a call to the machine, it’ll get a pot ready for his arrival.

Sadly, Sacha hasn’t made the code available, but he does talk some more about the project in this blog post, and points the intrigued at the Pi4J project, which is meant to bridge between native libraries and Java for full access to the Raspberry Pi.

And back in the UK, Quentin Stafford-Fraser is still pratting about with webcams; those of you with long memories might recall this grab-bag from last summer which featured him…pratting about with webcams. More power to your history-making elbow, Quentin.