Friday, November 06, 2015

Creating an MP3 sound sytem

Introduction

As part of my ongoing investigations into sound systems, I thought I would have a go at 'modifying' a self contained USB MP3 player to provide a sound system for my Ford(ish) Railmotor.

 It turned out to be a relatively straightforward conversion requiring very few additional components - a voltage regulator to provide the power and the sound files which were mostly downloaded from the internet.

Pros
  • Relatively cheap - mine cost about £5.00 a couple of years ago. I notice there are several variants of this still available on eBay for around £6.50. I paid for some of my sound files (around $10), but it could have been done with free sound files or my own recordings
  • Comes complete with micro SD slot, amplifier, loudspeaker, battery and case (even includes a built-in FM radio)
  • Loud enough to be heard across the garden
  • Easily adaptable
  • Plays 'real' sound files to produce quite high quality sound
  • Plays very long sound files (a 1Gb SD card could hold around 18 hours of sound effects)
  • You can make and play your own tailor-made sound effects
Cons
  • There is about a pause of about 1 second when switching between tracks
  • Requires a little bit of time and effort to make the modifications to the player and the edit your own sound files
  • Not much else, really
I control my player remotely from my Deltang Tx22 transmitter through a Deltang Rx61b receiver, though any receiver which provides outputs from the direction switch (Channel 3) could be used.

Dismantling the MP3 Player

 At first, I couldn't see how the gadget fitted together, but after reading an article by Mike Jeffries in the December 2014 edition of the Garden Rail magazine in which he dismantled a similar sound system, I realised it wasn't too difficult.

The base was prised off with a small flat-bladed screwdriver.

It was held in place by some sort of silicone based glue which was still quite gummy, but with some gentle persuasion it became detached. At the same time the plug for the speaker disconnected itself from the socket.

The wires to the battery were snipped off. I wanted to be able to remember which wire was attached where as there was nothing printed on the circuit board indicating how the battery should be connected.

The two screws holding the circuit board to the base were removed.

The lithium-ion battery was glued to the underside of the speaker and needed a fair bit of leverage to become free .......

In the end, I sliced the plastic sleeve and removed the battery from it as I was anxious not to damage the battery case.

 The speaker grille was prised away from the case, bringing the speaker with it. Again, this was held in place with silicone-based adhesive.


Connecting the circuit board to the receiver

 The switches which enable the user to move forwards and backwards through the MP3 files on the card were held in place on the circuit board with a large blob of hot-glue.

This needed to be very carefully cut away to avoid damaging the board or the delicate contacts on the back of the switches. 

 Scrutiny of the board revealed that the left hand contacts (viewed from the back) on the switches were connected to ground (ie the negative side of the battery), so leads were carefully soldered to the contacts on the right of the 'next' and 'previous' switches using the thinnest wire I could lay my hands-on.

To check that these wires would act as triggers to move forwards and back through the tracks on the SD card, the board was wired up to the speaker and a 4.5v battery. The ends of the flying leads were then touched on to the negative terminal of the battery and, reassuringly, the player moved back and forth through the tracks.

Powering the MP3 player

 The MP3 player runs off 5v and as the loco is powered by a 12v battery I needed to find a way of powering it. As there is plenty of space in the railbus I could easily have added another 4.5v or 5v battery pack and linked the negative leads of the two battery packs to ensure the 0v logic signals would still work. However, I like to keep things simple when it comes to recharging and so decided it would be easier to make a voltage regulator circuit using an LM7805 voltage regulator. There is plenty of guidance on the internet for making this circuit - eg http://www.learningaboutelectronics.com/Articles/How-to-connect-a-voltage-regulator-in-a-circuit.

Mine was mounted on a small piece of stripboard and covered with some clear heatshrink sleeving as the mounting plate of the regulator is 'live'.

I decided not to clamp the regulator to a heatsink, even though the regulator did run quite hot when I wired everything up and turned the sound up to full power. To reduce the current draw I replaced the 4 ohm speaker which was supplied with the MP3 player with a small 8 ohm speaker. The voltage regulator still gets quite warm but now not alarmingly so.

Tailoring the receiver output pads on the receiver

 The receiver installed in my railbus is an Rx61b (v603) as it was installed a couple of years ago. The programming information for this older version of the Rx is still there in detail on the Deltang website and so I could see from the chart for the Rx61b-22-v603, that pads 4 and 5 provide 3.3v outputs in response to Channel 3 (the direction switch on Deltang transmitters).

Item

Setting Details
P1 output

Servo
Bind button (Ch5)

Slow-motion servo for coupling
Press bind button to open coupling
Release bind button to close coupling

P2 output

Front Light
(auto)

Led needs current limiting resistor

P3 output

Rear Light
(auto)

Led needs current limiting resistor

P4 output On/Off
Direction switch (Ch3)

Item being switched needs current limiting resistor
Switch right for ON (center/left OFF)

P5 output On/Off
Direction switch (Ch3)

Item being switched needs current limiting resistor
Switch left for ON (center/right OFF)

P6 output On/Off
Bind button (Ch5)

Item being switched needs current limiting resistor
ON while button pressed, OFF when released (momentary)

P7 output On/Off
Bind button (Ch5)

Item being switched needs current limiting resistor
Toggle ON/OFF each time button is pressed (latching)

P8 output IR4

Battery voltage telemetry
Infrared led needs current limiting resistor

I was already using Pads 2 and 3 for direction lighting and Pad 4 to turn on and off the interior lighting, and so I needed to find another way of turning the lighting on and off. Normally, I would use the bind button (Ch 5) for the loco whistle or horn but decided I could manage without the horn if I included it in the sound files for the engine sound (see below). I therefore soldered wires to Pads 4, 5 and 7. The outputs from pads 4 and 5 could be used to move back and forward through the tracks on the SD card (provided I inverted the outputs from 3.3v to 0v) and the output from Pad 7 could be used (without modification) to operate the interior lighting.

To invert the outputs from Pads 4 and 5, I made up a couple of transistor inverter circuits with a 2N3904 transistor and a couple of resistors (See How I trigger soundcards with a Deltang receiver.)

The two transistors, together with the four resistors, were mounted on a small piece of Veroboard as I found that the legs of the transistors were a little fragile.
The output leads were connected to the push button leads on the MP3 player and the inputs connected to pads 4 and 5 on the receiver.

All that was needed now was to find or create the sound files needed for the railbus.

Creating the sound files

After some experimentation, I decided I could simulate all the situations needed for the railbus with five sound files:
  1. 20 minutes of silence
  2. Engine start and idle (for 20 minutes)
  3. Horn, gear grind and acceleration through the gears to running speed ( for 20 mins)
  4. Decelerate, brake squeal and idle (for 20 mins)
  5. Engine shut down
I decided to include 20 minutes of silence as there will be times when the railbus is stationary before I get around to turning it off manually. Also, I didn't have a spare switch or channel on my Tx22 transmitter which I could use to switch the MP3 player on and off remotely.

From 'silence', I could then advance to the 'engine start and idle file' using the direction switch. When ready, I could then advance to 'the acceleration and running file'. The distance between my stations is such that I would never need to run the bus for more than ten minutes and so a leeway of 20 minutes running sound would be fine. The bus tends to run at a fairly consistent, slowish, speed and so there seemed little need to vary the speed of the running sound by a great deal. Approaching stations, I could then advance to 'the decelerate, brake and idle file' and leave the railbus on idle for as long as necessary. Using the direction switch I could therefore either move to the next 'engine stop file' which would automatically advance round to the first 'silence' file when it stopped playing, or I could move back to the previous file and go through the acceleration and running sequence again.

For more information on how I created the sound files see How I used Audacity to create sound files for my Ford(ish) railmotor.

The Railmotor in action

Once everything had been wired-up and tested, the speaker was put into a small sound chamber made from some 2mm thick larch veneer. This, together with the circuit board was mounted in the roof of the railbus power car (suitably insulated from accidental contact with the lighting bus bars).

Of course, after all this work, the railbus required some extensive testing.


I'm considering ways in which I could overcome the 1 second pause when I change tracks. It might be possible to program a Picaxe micro controller to trigger some sound on another soundboard for a second or so to mask the silence (eg a horn, a backfire or even a chunk of miscellaneous engine sound).

I am quite happy to live with the hiccup in the sound for now - after all, I run my railway mostly for my own pleasure and am mostly the only audience for my operational sessions. When I make videos (such as the one of the test run above), I can quite easily shoot the video to avoid the pauses or them edit out.


5 comments:

Frank said...

For reducing 12V to 5V, a 7805 voltage regulator wastes 58 % of the power it takes, and therefore gets hot.

A voltage convertor module is much more efficient, for example:
http://www.ebay.co.uk/itm/DC-DC-Buck-Converter-4-28V-19v-TO-1-20V-5v-12v-step-down-power-supply-Module-/331698724547?hash=item4d3ac8dec3:g:bwMAAOSwlaxWOGaa

And just as simple to use, two wires in and two wires out.

Frank said...

Note: the convertor I mentioned is variable, it just needs to be set to 5V before use.
(Test output with voltmeter.)

Rod Hutchinson said...

Hi Rik,

I have been viewing your videos and blog about programming Deltang RX.

I have a TX22 and looking to obtain a 2nd unit.

I was wondering of you have any experience with the TX72, which I believe has programming features.

Rod Hutchinson
Australia.

GE Rik said...

Hi 'Unknown'
Thanks for that info. I'll investigate those little units - work out cheaper than voltage regulators and are less hassle.

Sorry about the delay in responding - for some reason, even though you posted your comment on 1/1, I only got the email alert this morning (19/1).

Rik

GE Rik said...

Hi Rod
I don't have any first hand experience of Tx72, but the last time I looked it provided only a very limited range of options (and presumably it will only every provide twelve settings).

I now do most of my programming with a Tx20 (see my blog posting about programming Deltang receivers - http://riksrailway.blogspot.com/2015/11/programing-deltang-receivers.html )

You can also put the Tx22 into programming mode by changing the inertia control to output to Ch4 - I've not tried it - looks like a bit of a hassle - but would save you having to buy another Tx.

Rik