Raspberry Pi with a Glockenspiel

Raspberry Pi and Glockenspiel

This glockenspiel has been converted to play automatically.

I found a glockenspiel in the local recycling centre and decided to have a go at automating it after seeing details on the Raspberry Pi forum and also on the PICAXE website.

It’s quite a straightforward design, using motors to rotate the hammers downwards and then using a rubber band to lift the hammer upwards one the chime has been struck.

Programming this in Python is relatively straightforward – just allocate most of the GPIO outputs to controlling the motors and then trigger them sequentially. The motors are connected to the GPIO outputs using a pair of ULN2803 darlington driver IC’s. It’s quick but as we’ll see, not the best solution.

I haven’t yet found out how to make the software do a clean exit when CTRL-C is pressed – something to do with creating an exception and then using this to shut down the GPIO outputs. Without this, it’s possible to exit while the motors are energised meaning that the peak stall current is passed through the darlington drivers. I’ve had to replace a couple already.

When I design a PCB for this, I think I’ll use a bunch of discrete darlington transistors (BCX38C) along with a current limiting device.

Overall, the sound is pleasant to listen to. I’d like to refine the software and also include the possibility of using RTTTL ringtones. I’ll probably need to filter out sharps/flats and add some kind of a transpose function. Probably a challenge for later!


Interesting programs to install on the Raspberry Pi

Click for interesting programs that can be used with the Raspberry Pi command line.

Link to PDF of interesting programs to install

I’ve found some interesting little bits that make an interesting introduction to the command line. They’re simple to use on their own, but with the addition of a pipe (the | symbol next to the Z key) it’s possible to use them to display results in a more impressive fashion.

To install, use the following:

sudo apt-get install cowsay
sudo apt-get install figlet
sudo apt-get install toilet
sudo apt-get install boxes
sudo apt-get install espeak
sudo apt-get install fortune

The attached files show how to use each of these. Alternatively a manual for each of the commands can be shown with the man command – eg:

man figlet


PICAXE controlled LEGO rover

This little LEGO rover will scurry around wherever there's space!

A LEGO rover controlled with a PICAXE motor control board

Some time ago I put together a little LEGO rover and added a PICAXE motor control board. A little bit of programming goes a long way and although the motors are slightly different speeds, this thing wanders around quite happily.

Two large lever-arm microswitches take care of sensing obstructions. If it hits these, the rover is programmed to reverse and turn away. The overall effect is quite effective for such simple programming. I also modified a 2×2 brick with a 220Ω resistor and a green superflux LED. By drilling out the internal pillar, there’s enough space to hide the superflux LED inside with its resistor. I then connected it to one of the MOSFET outputs connected to output 0. I’ve also put a 2×2 clear brick on top and this is great for spreading the light out.

The overall power supply is 6x AA Alkaline cells. I will eventually change these for NiMH but they’re in use around the house somewhere. Once the volt-drop through the L293 integrated circuits have been taken into account, it’s about the right voltage for powering the 4.5v LEGO motors.

The simple algorithm for this rover is:

go forwards
if left sensor touched, then stop, flash the LED, reverse and then rotate right
if right sensor touched, then stop, flash the LED, reverse and then rotate left
go to start

Scratch -to- Python Conversion

Scratch to Python conversion sheet - click for a PDF file

Scratch to Python conversion sheet – click for a PDF file

Just as you get used to one programming language, the goalposts change and you need another one! This little guide sheet, on two A4 pages, covers the basics of using variables, decisions, lists and loops.

It has been written for Python 3 (the most commonly encountered difference is the need to put brackets around bits that need printing).

I’m going to keep a printed version with me as I’m sure it’ll be useful for explaining the different ways of constructing decisions and loops.

If I get the time, I’ll create pages 3 & 4 – perhaps to cover using GPIO within Scratch and Python.

Python-Scratch Conversion