Saturday, February 15, 2014

Station Announcer... final version?

Some more advances in the station announcer version, and if this is not the last version, it's pretty near!!

I tried to do a very simple project, able for those who don't know a lot about electronics (like me) or know nothing about programming. It's intended for Loconet digital layouts, but it's also possible to manage it from a standard remote control, so it can work also in analogical systems. I kept the existing functionality:

* Remote control for playing MP3 files, selecting the source (memory stick, SD card, internal memory), setting the volume and save settings.
* Assign MP3 files to output events. Whenever a defined output is activated (from hand throttle, main command station or software) its assigned sound is played
* NEW: Function keys from F1 to F4 for each individual locomotive can be also assigned to a sound, without loosing its functionality. I mean we can assign a horn or break sound to a locomotive's function key that is programmed to turn off the lights or set maneuver speed and the sound will play at the same time the function is executed. Each locomotive for each function key can have a personalized sound in each function key.
* NEW: Assign a sound to a locomotive that will be played when it stops in up to 10 configured segments. Of course this segments must be retro signaled. The main goal is to play an announce when the locomotive stops in front of the station, doesn't matter the track. So basically you configure up to 10 segments informed by loconet retro-modules, assign a sound to a locomotive and when it stops on any of these segments, it's sound is played.

May be you are asking yourself if you need any identification system to know whichlocomotive is the one stopped in the station... the answer is NO, but Arduino will know which locomotive has stopped, and will play it's personalized sound or announcement.

I will explain the tricky part with a very simple introduction of how Loconet communications work:
When you use a complete communication bus like Loconet in your layout, all kind of messages, signals and instructions are sent through the bus to all its components and modules. When an output is activated from your throttle, a message is sent through the bus to all modules saying "Output number X activate". This is received by all devices listening the bus, but of course just the module in charge of output X executes the command. The same happens when a signaling module detects consumption in a segment, it sends a message saying "My section number X has been activated". The software controlling the layout also receives it, and it can react stopping a locomotive or changing a light. And finally, in the bus you also receive all instructions sent to the trains, like changes of speed, activation or deactivation of functions, ...

And basically the software in Arduino "hacks" the network interpreting all kind of messages, in IT language it's a sniffer. When it receives a message informing the activation of one of the configured sections, pays attention to the first locomotive setting it's speed to zero. In this last message the number of locomotive is informed, so it assumes that locomotive is the one that has stopped in this section and therefore plays it's configured announcement or sound.

As it is an independent and passive system, not interfering in the communications, it doesn't need any kind of special configuration in the software, throttles nor locomotives. And it works in any Loconet layout with any software, command station and decoders. Also works in a full automated system or when we drive it manually.

The hardware construction is easy: buy an Arduino Uno, plug on it a MP3 shield from Elechouse and build your own Loconet interface or buy a GCA50 board from Peter Giling to have half of the work already done.

The software part is also easy: upload the program in arduino, and connect it to the USB. To set up the parameters there is a menu shown directly in the serial console of Arduino IDE:

Typing "config" the menu shows the options to set up the sensors (up to 10), Locomotives (up to 50), clear the memory and save settings.

When setting up a locomotive we just need to type the id number (same number we use in the throttle) and the function where we want to assign a sound. It can be any of the function keys (F1 to F4) or SENSOR. SENSOR means the sound that will be played when this loco stops on any of the 10 sections configured in the first option of the main menu.

As always, now I have to clean the source code and optimize some parts before publishing it. That's the boring part once you see it's already working..... XDDD

I hope you liked it and be useful for anybody else!!!! Cheers,

No comments:

Post a Comment