Skip to main content

Reply to "TMCC Control With Arduino"

Hi Charlie,

If I was doing this, I'd forget about the Legacy IR sensors, and just use a few isolated rail sections (or something similar) to allow your Arduino to keep track of where the train is (be sure to account for "bounce" in your software or hardware.)  You can count laps, turn off the sound when the train enters one area and turn it back on when it exits, accelerate, slow to a smooth stop, make announcements, use the bell and horn, pause (or even power off the train) for any length of time, etc.  All in a big loop that could just run indefinitely -- no need for a computer, or the Legacy remote (I even power up my track and locos with my Arduino so I don't need my Legacy remote at all, when running in autonomous mode.)  You could have a button that started/stopped the whole thing to be used in the morning and afternoon (or anytime you wanted to stop and re-start the process.)  Or put it on an automatic timeclock and not even have to think about turning it on and off.

To keep things simpler, you might also consider just using TMCC commands (issued from the Arduino serial port to the Legacy base -- you don't even need an SER2 for this).  They are easier to understand/program, and they work fine on Legacy engines.  You just don't have quite as much control -- but you can easily do everything you've discussed.

The parts necessary to do this will be few and cheap, and the programming is pretty trivial once you get past the learning curve.  I would just write it in straight procedural C, a big loop.  (Guys, please don't jump on me, I have a degree in CS and ran a software company for 20 years -- but for a single-purpose trivial program like this, I'd just write it as one big loop with maybe a few functions for sending TMCC commands etc.)  Unless you want to use OOP for the fun of it ;-)

Since Prof. Chaos has already done what you want to do (though more sophisticated, and programmed in C++), I'd look at his code on Github and you'll see how to send TMCC commands and everything else you're trying to do.  He also uses RFID readers, which is another option for train detection -- but with only one train, it's overkill in my opinion.

Keep us posted, and let us know if you have any specific questions.

Randy

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×