Ok. So it’s really more like “Chugs and Whistles”, but this title sounds better.
I’d like to add sound to play through some on-board speakers to give the engine the “chug-chug” sound. And maybe add a sound file for a steam whistle.
I found some sound files on the internet that I think would make a nice addition. Here’s the sound file for the “chug-chug” sound:
And here’s a couple of the steam-engine whistle sounds I’d like to use:
I’ll need to figure out how to integrate these into the on-board computer to play these sounds through some speakers.
The first step is to make the sound files available to the computer. Since I already have an Arduino computer installed to drive the motors and handle the remote control, I should be able to have it handle the sound as well. But it’s not as easy as you might think.
To store the sound file I’ll need to install an SD card and add the circuitry and programming to read a computer file. Then, I’ll need some sort of DAC (Digital to Analog Converter) to turn the digital sound file into an analog signal that can drive a speaker. And I’ll need to amplify the speaker signal, since the Arduino emits only about fifty milliamps of power – not nearly enough to power a speaker.
Since the circuitry is so complex, I looked for an alternative where I could buy some sort of component that already has this built in. After some searching, I settled on the Adafruit “Music Maker” MP3 Shield for Arduino w/3W Stereo Amp. This component includes an SD card slot, the DAC, and has a built-in amplifier.
The card requires some assembly and soldering, but is made to fit neatly with the Arduino computer. Here’s the Arduino computer and the components of the music card:
After assembling the Adafruit card, I attached it to the Arduino computer to see how it performs. And immediately realized I have a problem.
The Arduino computer card has a number of ports for attaching wires to control motors or to read sensors. But, while the Adafruit Music Maker card fits the Arduino computer like a hand in a glove, it uses all of the Arduino ports for its interface. The reason this is a problem is that I’m already using several of the ports to read sensors for the throttle and remote control unit, as well as for sending signals to drive the motor.
So to solve this problem I just bought a second Arduino computer to dedicate to the sound module. After getting it installed, I was able to read the sound files for the choo-choo and whistle sounds and play it through the speakers.
Adding a separate Arduino computer to dedicate to the sound function raised another problem. I want the choo-choo sound to begin when the train starts moving, and to stop when the train stops. So I somehow need to have the main computer controlling the throttle to signal the second computer controlling the playing of the sound. So I tied the two computers together in a Master-Slave configuration. Now, when the throttle advances beyond zero, it signals the sound computer to wake up and play its sound.
The speakers came from some old computer speakers I had laying around. I took the speakers out of the case and wired them into my circuits, using the Adafruit amplifier to get the maximum volume of sound.
Unfortunately, the sound still wasn’t very loud. It gets drowned out by the noise of the whine of the electric motors and drive train.
So then I purchased a set of car speakers and an amplifier used in car sound systems to further boost the volume. My computer speakers are rated at five watts, while the car speakers are rated 35 watts RMS with a 140 watt peak. And the amplifier includes a volume control knob that should provide some adjustment as required. Here’s what the amplifier and speakers look like:
So that’s where the sound enhancement stands at the moment. Next steps are to install the new speakers and amplifier and see (hear) what happens!