Category Archives: SiRiMa – the Bell-y Project

A tower bell ‘simulator’

Additional controls

Input controls

I’m intending that Sirima will run as a self-contained unit – it won’t use a computer display, but will have switches for the settings.  until it gets used for real, I can’t be sure what features will be the most useful, but certainly I want to control:

  • the number of bells that are being rung,
  • the speed,
  • the method or exercise being rung ; and
  • let the ringers choose which bells they are ringing.

My thought is that I can control these with a multi-position switch or potentiometer which outputs a different voltage according to its setting.  This is read by an analogue to digital converter.  And there is a suitable one readily available, the MCP3008 which has eight input channels and uses the SPI interface of the Pi, so I could connect 8 input switches.

Multiplexing the output
Update 07/04/22

This got me thinking that I hadn’t investigated whether there is a chip that can control multiple output channels without using too many of the GPIO pins.  One possibility is the SN74HC595N 8-bit shift register with 8 x 3-state (high, low, off) latching output registers.  The 74HC259 is a directly addressable latch that might be even better.  The outputs can source 35 mA: I thought this would be enough to drive my LEDs directly, just need limiting resistors, but I’ve realised that the total current from all the outputs is 70 mA, which is not be enough to drive all the LEDs at the same time.  However, you can get a Darlington Driver Array chip  (18-pin DIP) such as the ULN2801A, which can supply up to 500 mA per Darlington pair, more than plenty for my LEDs

I’m coming to realise that I can greatly simplify my circuit board by making use of these ICs which are remarkably inexpensive – I have been rather blinkered by out-of-date techniques!

If the machine is successful, it would be much easier to make another one using these techniques.

 

 

Interference on sound channel

Sirima is working but the 5v switched power supply that I have installed doesn’t seem to be adequate.  I am getting both a low voltage warning and strange whistling and buzzing noises on the sound output.

These problems are connected, since when I disconnect the new power supply and plug in my ‘proper’ Pi power supply wall plug, the voltage and sound are fine.  I suspect the problem might be the power lead, which I took from a disused mobile phone charger.  The wires within it are quite thin and there seems to be a voltage drop (of maybe 0.5 v) when the Pi’s power demand is high.  I gather that the strange noises are probably caused by ‘sheath currents’ due to multiple earth paths, but it is pretty hard to work out where these are flowing.

02/04/02 –  The power supply module is a regulated switched mode unit rated at 5 amps, giving an output of 5.07 v at its terminals.  I connected it to the power rails on my circuit board which go to the appropriate GPIO pins via the ribbon cable connector.  Whilst it was much better, there was still too much whining, buzzing and popping, and the voltage was only just over 5 v. I measured the resistance of the power supply wire that I was using and found it was 0.01 ohms per centimetre.  This doesn’t seem much, but the Pi can take up to 2 amps at times.  Considering the length of the connecting wire (say 15 cm in each direction, i.e. a total of 30 cm, gives a resistance of 0.3 ohms, it would give a drop of 0.6 volts at 2 amps.  Given that the line voltage of the sound output is nominally 1 volt, then even though the Pi’s has a built-in audio power supply voltage regulator, this variability is over 4 dB and thus very audible.

Clearly, I need thicker power supply cables, some decoupling circuitry and to use more than one of the Pi’s GPIO pins to supply power, as the ribbon cable is rather thin. Even this won’t eliminate ground loops, but I’m thinking that if the proper power route has a low impedance, this will reduce ground current anyway.

As a further test, I measured the voltage of the power supply relative to earth and was rather surprised to see that it is 24 v.  It’s clear that I need  an earthed power cable, so that I can properly earth the negative rail, which is necessary for safety anyway.

And I have confirmed again that the noises disappear when I disconnect the 5v supply via my circuit board and connect in the proprietary Raspberry supply via the micro- USB socket.

 

 

 

 

Marking angles round a circle without a protractor

I wanted to arrange the LEDS on my machine equally spaced around a circle, as shown in the image above.  I couldn’t use a protractor as the inside of the enclosure is too small, but I could use drawing compasses.  I decided that I needed twelve points around the circumference of a 100 mm diameter circle. But how to work out where to place the marks?

Firstly draw the circle – 100 mm diameter means set the compasses to a radius of 50 mm.  Now there are 360 degrees in a circle, so there will be 360/12 = 30 degrees between each LED.  How can I get this?

If you wrack your brains you may remember the Sine rule from your school geometry.  I’ve written it out below and I’ve shown it on the diagram.

a/sin(A) = b/sin(B) = c/sin(C)

where a, b and c are the lengths of the three sides of the triangle and A, B and C are the angles opposite these sides.

From this, the length of the side a that we want is given by

a = b*sin(A)/sin(B)

The sine is a mathematical function that relates the ratio of the lengths the sides of a triangle to the angles enclosed. It has many uses, originally in surveying, and has sister functions Cosine and Tangent.  We don’t need to go  there now, only to know that’s why these ‘trigonometric functions’ appear on all scientific calculators.Angles round circle

Angles round circle

Since the angles inside a triangle add up to 180 degrees, and the angle A that we want is 30 degrees, the two angles opposite must add up to 150 degrees. Since the angles are both the same, they must each be  B=C=75 degrees.  And we know that the two equal sides b and c are both 50 mm long (the radius of the circle).  Using a ‘scientific’ calculator that has sines on it, we can work out that the length of the opposite side is 25.88 mm.

Set your compasses to this value and mark off this distance around the circle, starting from a suitable diameter mark.  The sixth mark should exactly sit on the opposite end of the diameter.  If it is only a tiny bit out, mark backwards from this end, back towards the beginning.  The exact positions with be exactly between the marks made from opposite ends.  If you’re not happy, adjust the compasses until these exactly coincide from both ends.

You can use the same method to mark any angle you wish – for example ten points round a circle will be at 36 degree spacing. You’ll need to recalculate the angles b and c, each of which will be
(180-36)/2 = 72 degrees.

 

Changing between two LEDs using one GPIO pin

There are plenty of circuits showing how to control a single LED from the Pi, but Sirima needs to switch between a red and a green LED and I only want to use one pin.

After some thought, I am using the circuit below

led circuit
led circuit

The left hand side of the circuit is the usual circuit that uses an NPN transistor to turn the left-hand (red) LED on when the GPIO pin voltage goes high (to + 3v3).

It seems obvious that you could use a PNP transistor to turn a different LED on when the pin goes low (to 0 v)but this doesn’t work well because there is always a ground path through the pin via its built-in protection diodes, and in any case it uses an extra transistor.

However, there is another way to deal with this, as shown in the right-hand side of the circuit.  This LED is connected to the current-limiting resistor (i.e. to the same point as the anode of the left-hand LED).  It uses a 2.4 v zener diode to limit the voltage across the right-hand LED (which requires 2.6 volts for full brightness).   When the transistor switches on, it parallels the ground path through the right-hand LED so this turns off.  Without the zener, the current would be shared between the two LEDs and they would both illuminate weakly.  Ideally the zener voltage should be a bit less than 2.4 v but I couldn’t find one readily.  [An alternative would be two use ordinary silicon two diodes in series in the conducting direction (anode towards the positive), as they each have a drop of about 0.7 v, giving 1.4v in total]  As it is, the current through the green LED is less than rated, but this doesn’t matter in my application, as the green LED is brighter than the red one at their rated current.

Not only does this circuit minimise the components needed, but only three wires are needed to operate the two diodes.

It should also be noted that in the Raspberry Pi, the state of the GPIO pins is undefined during boot-up and so it is rather random as to which LED will be illuminated at this time. To switch them all off would need a MOSFET, say, to control the 5v rail, needing another pin to be used.

Powering the Raspberry pi

My ringing machine – I’m thinking of calling it Sirima (Silent Ringing Machine) – is ready for prototyping. I’ve bought a plastic case (so the Pi’s built-in WiFi and Bluetooth can still work).  The box will house a loudspeaker, so it will only be monaural, but I don’t need more for this prototype. It will also use a circle of LEDs to show the bells as they sound. The illustration shows it part-made.  I will need to use transistors as switches to turn the LEDs on and off as the Pi’s GPIO pins can’t supply enough power.

Originally I thought there would be  eight bells, I’ve made space for 12 bells.  There will be a green LED for handstroke and a red one for backstroke,  arranged in two concentric circles, but the prototype will use just eight pairs.

The back panel of the box will house 3-pin DIN connectors for the photocell sensors, which need a 5 v power supply and have one ‘open collector’ output wire.  I have five sensors, but will just connect one to start with, as there are quite a few practical issues with mounting the sensor and routeing the cable.

I’m using a 12-watt audio amplifier module with a 4-inch (100 mm) loudspeaker.  This needs a 12-volt DC smoothed power supply and I have bought a small switched-mode 2-amp power supply.  I have a small potentiometer that I can use as a volume control which will need to be on the front panel.

I’d like a single mains power inlet for both the Pi and the amplifier.  A Pi model B (which I’m using in the prototype) can take between 0.7 to 2.5 A at 5V.   The board typically needs 0.5A.  The normal way of supplying power is via the micro-USB plug , but you can supply the power via Pin 2 (+5 V) and Pin 6 (Gnd), although there is no regulation or current protection on these.  I will also need power for the photosensors and LEDs.  From experience, it might be better if these are not powered directly from the PI’s GPIO pins as they shouldn’t need a lot of additional smoothing as long as there are no spikes on the power supply.  So I’m thinking of getting a 5v switched power supply for all this. I can then fit a mains inlet and power switch onto the back panel.

In its simplest mode, the system can just emit a bell sound whenever the motion sensor is triggered.  However, in order to practice bell control, it is necessary to have, say, six bells but with a gap for the student’s bell to ring in.  This would need some sort of start/stop button if it is running headless, or else it would be necessary to rdp into it from a laptop to do the setup.  Of course, it would be nice to have other features such as a speed control switch, but this is some way down the road.

Anyway, I’m taking a break for the next few days, so more in a little while.

The Belly Project – re-writing in Python

Having looked at my Fortran code, I can see that I require a sophisticated system interface for –  user input, a clear graphical display and bell sounds.   A little research shows that the Pygame interface (which is written in Python and is supplied with the Raspberry Pi) should provide everything I need and it would be a better use of my time to learn how to use this.  Regretfully I concluded that it would not be worth the struggle to find the Fortran interface to these.

I started to convert some of the original Fortran  code into Python, but quickly realised that so much of it is actually the user interface that I should recode this directly into Pygame functions.

So how do I get to grips with Pygame?  I’ve found an excellent tutorial  with some nice demonstrations.  I’ve used these to play individual bell sounds so that it sounds like actual ringing.

However, I realised that my original Fortran code for interpreting the so-called ‘Place notation’ of the change-ringing methods could not be tidily converted into the procedural approach used by Python.  After some thought, I came up with a much better way of doing it.

New recordings

I have also made some new recordings of individual bell sounds, which should be nicer than the old recordings that I was using.

I am now starting to think what features a ringing teaching machine should have, plus I’m starting to order the components that I think I will need.

Update 13th February 2022

My ringing machine can now ring any method – you only have to supply the place notation.  You can select to ring one of the bells and when the photo sensor detects movement, it sounds that bell.  This means you can now try to strike the bell in the right place.  I have ordered an enclosure and other components and I will rig this up so it can be tried out in the tower.  I will try using a CAT5e cable from the bell chamber to the ringing chamber (about 10 metres vertically) as this is a four-pair cable.  The sensors need 5v power plus the sensor output.  I will rig up something just to try the concept.

I intend to put a loudspeaker and amplifier into the system enclosure.  Theoretically, it would then be possible for a whole band to practice silently, i.e. for each sound to be triggered by the relevant bell sensor.   It would also be possible to have two systems running, one on the left channel and the other on the right channel.

At present, I’m not sure what will be the best system.  However, I’m currently involved in training some beginners, so maybe we can experiment.