Here are some videos of the railroad in operation.
Here are some videos of the railroad in operation.
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!
I built a crossing ramp to let me get my lawn tractor across the tracks to the infield. As long as I have a crossing, I decided I need a crossing signal. What I’d really like is a set of the twin red lights that blink in an alternating pattern when the train comes, just like a real railroad. Since I can’t find anything suitable anywhere (not even eBay or Amazon), I’ll have to build my own.
The first step was figuring out how to make this happen, and determine what parts I needed. The red lights were pretty easy. Auto parts stores have generic red lights that run on twelve volts DC that can be used for my lights. I found quite a selection on Amazon. But about nine out of ten of the lights sold today are the LED lights. I wanted the older style incandescent lights just to make it look more authentic. The LED lights are instant on and instant off, while the incandescent lights glow in and glow out. These are the lights I ordered.
The next step was to make the black round background with the black visor. I had some aluminum flashing left over from the train house. So I cut the round background with a center hole sized to the housing for the tail lights. Then I cut a piece for the visor. Everything was attached to some scrap exterior plywood left over from the train house floor. A coat of flat black paint (I used barbecue grill paint that I had left over), and the lighting housing was ready to go.
To power the lights I purchased (again on Amazon) an exterior weather box to house the components. In order to have the lights come on when the train approaches and to blink in the proper pattern, I needed to build another computer circuit. I purchased yet another (my third) Arduino computer to handle the lighting controls.
I needed to somehow have the computer sense when the engine was in close proximity so it would know to start the lighting sequence. There are InfraRed (IR) sensors available for use with Arduino computers. But there were two problems: first, IR sensors are for measuring in inches, while I needed to get a reading when the engine was several feet away. Also, in an outdoor application, I was afraid that the ambient sunlight would include the same spectrum of IR light that the sensor was trying to read, so it would be washed out.
The alternative was to use an ultra-sound sensor. I found this HC-SR04 Ultrasonic Sensor on Amazon. It emits ultra-sonic sound waves from one of the ports, and reads the reflection from the other port. Based on the time interval from send to receive, it’s easy to calculate the distance. So I wired this sensor into my Arduino computer.
Next step was to make the lights blink in an alternating pattern. The Arduino doesn’t emit enough power to run the lights. so I needed to add a couple of relays. The computer can trigger the relay, which acts as a switch to turn a separate and more powerful circuit on and off to work the lights. I was going to use an automobile relay similar to the one I used on the engine, but then found that there are relays made for Arduino projects that are easily incorporated into Arduino circuts. This is the component I used. Note that it has four relays, while I need only two (one per light). I thought it might be prudent to have some spares, as I’ve fried a few of these components while trying to get them to work.
I programmed the Arduino computer so that it’s constantly watching for something on the track within a few feet. Once it senses that it’s there, it wakes up the relays and alternately flashes the lights for a few cycles. Then it goes back to sleep.
I put all of this, including a small twelve volt battery, into the weather housing and mounted it on the crossing sign pole. I cut two small holes in the side of the box for the sensor to look through. This makes the sensor exposed to the weather, so I don’t know how long it will last before I have to replace it. We’ll see over time. Then I plugged the Arduino into my laptop computer to calibrate the settings and hoped that it would work.
Once I had everything working, I closed up the box and ran the live test. Here is a video of everything in service:
If I can find the right type of bell, I’d like to add it to the pole and get the ding ding sound while the lights flash. But most of the bells I’ve found so far are like the school bells that ring continuously. I need one that runs on twelve volts DC that can ring with individual dings. And it needs to be weather resistant. I’ll keep looking – maybe I can get that added one day.
I’ve researched bells for my application. It looks like the closest thing readily available would be either a school bell or a fire bell. But these bells ring continuously. I need a bell that I can have ding just once. Then I can control the dinging with my Arduino computer.
I posted an inquiry on a hobby forum and received a response from across the country in which someone offered a bell salvaged from an old Kodak x-ray film developing machine. The bell was powered by 120 VAC, but should be able to be modified to run on a 12 VDC by removing some of the wire windings in the armature. I’m waiting on the arrival of the bell. Then we’ll see if it can be modified to run in my crossing signal. More when it develops…