Too long, don't want to read? Skip to the video and picture links
So, I've been working on this electronics system for an O gauge locomotive on and off for the past 8 months-ish and want to share with you guys what I've done so far for anyone who is interested in this kind of stuff. I am relatively new to this forum, but I have done some business through the WTB section. @Budkole sold me the beautiful locomotive 5426 you see in the video. It worked out fairly well considering it had some electronics issues, and I planned on replacing them all anyways (As a side note, 3rd rail locomotives are impressively good looking and smooth running. The motor/printer belt system is indeed a beast. This is the first one I have owned!).
My goal with this project was to come up with something that was 100% programmable, ran on battery power, and could be controlled from pretty far away - hence fairly ideal for outdoor use as well. I wanted it to be comparable to TMCC, ERR, or protosound, if not better. Right now I only have the one locomotive that I have converted, but the system is designed to control many at once.
The electronics within the locomotive are controlled by an arduino and include a radio transceiver, amp, motor controller, various mosfets, neopixel leds, voltage converters, and some passive components... there is also a peristaltic pump to bring smoke fluid from an auxiliary tender to the unit in the boiler. The speakers have been upgraded and placed in the boiler as well (in my opinion it sounds a bit more realistic with the sound coming from here). The battery is a 3S lipo 3000mah and seems to last a long time as long as the smoke unit is off. I haven't done any official battery testing yet, and probably won't until I can put it on a layout with cars behind it. The smoke unit has a 4 ohm resistor in it, so it can draw 3 amps at a full charge of 12.6V, that's 40 watts... so that alone would drain the battery completely in well under an hour assuming I don't want to get below 11.1V to avoid having to balance charge it all the time (and make last more cycles). That's part of the reason why I bothered to make the smoke unit power adjustable.
The blue central controller - also based around arduino - relays commands to the locomotive via radio. It can theoretically send data at 2Mbps so it can control many locomotives at once (more than I will ever be able to afford) up to about a football field away (in theory up to a kilometer, but less because of interference). The central controller can function on its own with scripts or be controlled manually via bluetooth from an android device, as seen in the video below.
Both the controller and locomotive are battery powered. The controller can easily be powered by a 5v usb cord as well. The locomotive cannot currently be powered by track, but in the future I will add functionality so it can use DC track power; or at least be able to charge on track without plugging it in.
Just below is the video I made demoing all of the functionality. Right now, I can write basic scripts that tell locomotives to go a certain distance and then perform a certain action. I'm working on a more advanced location based tracking system, but it won't matter much without a layout or other locomotives. Thus, considering my setup is just a straight track on my apartment floor, the video isn't super exciting, and my filming equipment isn't exactly professional grade...but it does showcase all of the functionality so far.
Demo Video: https://www.youtube.com/watch?v=C7qy0MdIsFA
Here are also some random pictures from the build process: https://imgur.com/a/az9Vd7U
In my opinion, I'm pretty happy with where it is now, but there are some small issues that you may notice in the video. For one, the sound isn't perfect. There is some clipping, especially with the whistle, though I have some ideas on how to fix this. I think the board is running out of memory when the locomotive starts going fast and playing lots of chuff sounds as well, as it occasionally skips a beat, and sometimes completely cuts out when blowing the whistle at the highest speeds. The sound files also probably need to be trimmed to be shorter as the locomotive starts moving faster so they don't overlap as much. Overall though, even though I'm only using free 11khz samples up-scaled to 44khz, I think the quality of the sound combined with the improved speakers is still better than the railking stuff I grew up with, but maybe not quite as good as something like Loksound.
You'll also notice that the higher the speed gets, the wonkier the speedometer gets too. I think this is caused by either the program may be skipping calculations due to memory issues or delay between the android device and central controller. The delay between the controller and the locomotive is basically nothing... however, there is some noticeable delay between the android device and the controller via bluetooth, and I don't know whats causing that. Its only really noticeable when trying to blow the two-step whistle. I could circumvent this by adding a screen to the central controller and cutting out the android device, but arduino is limited in its ability to drive a screen, and that would also be very expensive.
The voltage divider reading the battery is also wonky, but I think that is due to general electronic interference in the system...regardless, its accurate enough to tell you when it needs charged to prevent over-discharging.
I should note that if you are paying attention to the "distance to objective" and "total distance" values in the video, you will see that the locomotive only starts decelerating at the target rather than stopping suddenly. It can be programed to slow down before reaching the target so that the scripting is more accurate, but I didn't get that in depth for the video. Overall, I'd say the controller could put a locomotive within plus or minus a foot of where you want it to go on a layout... this is partly due to the limitation of communicating in integers or bytes to save bandwidth.
For the future, I have many plans. I will certainly share more if people are interested in seeing how this turns out over the next year or so.
Cheers!