Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Arduino for this Application?

2374 views
9 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    January 2014
  • From: Chicago area
  • 335 posts
Arduino for this Application?
Posted by Arto on Wednesday, February 21, 2018 11:24 AM

I'm adding two point to point rail lines to my layout, one short line for frieght & a second for interurban passenger service. The frieght line will have two (hidden) holding tracks and the passenger line four (hidden) holding tracks. I want to ramdomly shuffle trains back & forth between the holding tracks and the other end point of the line. I also want to slow the passenger trains to a stop gradually when they approach the station, stay there for a while, reverse, slowly starting again & head back to the hidden holding track. The point being to let these two point to point lines operate automatically by themselves.

Are Arduino appropriate for something like this or am I better off using something like JMRI & a PC?

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Wednesday, February 21, 2018 2:44 PM

DCC?

greg - Philadelphia & Reading / Reading

  • Member since
    January 2014
  • From: Chicago area
  • 335 posts
Posted by Arto on Wednesday, February 21, 2018 5:37 PM

DCC

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, February 21, 2018 5:42 PM

 I've never had any luck with JMRI scripts to run trains - plus you need block detection of some sort for it to work. RR&CO seems to work better for automation. But you still need block detections. 

An Arduino could do this, a bigger one like the Mega would have enough ports to handle the block detectioon as well. These tracks would have to be isolated from the rest of the layout, as the Arduino would act as a DCC command station. Running DCC trains liek this is fairly complicated - I know of only one commercial product that can move the train back and forth with an optional middle stop, and that's the Tam Valley DCC Train Shuttle. Not cheap and you'd need two, one for each train.

                                         --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2014
  • From: Chicago area
  • 335 posts
Posted by Arto on Wednesday, February 21, 2018 6:49 PM

Randy to the rescue, again Big Smile

I think RR&Co (Freiwald Software) is what I'm looking for. I might be able to get by with their basic (Bronze) version. The fully automated version seems a little pricey just for shuffling 4 trains back & forth on the same track.

  • Member since
    November 2016
  • 196 posts
Posted by khier on Thursday, February 22, 2018 5:29 AM

I have mo idea about JMRI and PC control, but concerning Arduino the answer is yes, it can be done. However, you will have to build a mini DCC command station around it.

You will have to install sensors to detect the locomotives once they pass a check point, and probably their direction to. The Arduino will send DCC signals to the desired locomotives to control their direction, speed and accelaration according the signals it receives and the desired operation schedule. These DCC signals are TTL, meaning 5V square signals. Therefore, a motor controller with a suitable power, or a commercial DCC booster, will be needed to process these signals and generate the appropriate voltage to operate the locomotives. And as mentioned previously, zou must separate this sections from the rest of the layot to avoid intereference between DCC commands.

Summary, yes it is feasible if you are ready to do the effort.

Regards

Walid

  • Member since
    December 2004
  • From: Pa.
  • 3,354 posts
Posted by DigitalGriffin on Thursday, February 22, 2018 7:37 AM

Randy is right, a couple block detection systems would be needed.  You could set it up running JMRI on a raspberry pi which is about $30 + the cost of the block detection board + interface unit.  But writing the scripts takes some chops.

Lenz also has it's assymetric DCC which allows you to programmatically stop a train with a couple of diodes.

Then there's the option of turning off alternate power mode like what I do.  When a block switches to DC, the DCC chip automatically engages brake mode and stops the train till a valid DCC packet is found again.

if (trainstopBlock == occupied  && trainLeaving == false) {pin5(High); Wait(60);trainLeaving = true;pin5(Low)}

pin5 activates a DPDT relay on mine.  High = DC to track.  Low = DCC (default)


Don - Specializing in layout DC->DCC conversions

Modeling C&O transition era and steel industries There's Nothing Like Big Steam!

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, February 22, 2018 9:46 AM

 The examples are out there for Arduino as a DCC command station, so that code is already developed and working. Instead of then trying to read back block occupancy via DCC (which means some interface bus - OpenLCB, CMRI, LocoNet), some form of block detection, either IR or even a comemrcial current sense solution like some NCE BD20's or RRCirKits BOD-8 can connect right to the Arduino inputs.

Not off the shelf or super easy, but fairly inexpensive (relatively) and totally standalone. A big Arduino like a Mega would have enough inputs to handle teh needed block detectiosn adn have some left over for perhaps some setup buttons to set the initial state and then start the automation.

As I mentioned, there is a ready to use commercially available solution from Tam Valley but for 2 trains on 2 different lines you'd need 2 of the units. Tradeoff is the Tam Valley unit is easy to connect to the tracks and configure, no real programming or electronics expertise needed.

                                      --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    December 2004
  • From: Pa.
  • 3,354 posts
Posted by DigitalGriffin on Thursday, February 22, 2018 12:07 PM

I'm not disagreeing with you Randy.  But it's always good to have options.   A cheaper/simpler solution (asymettric DCC or DC cutoff) might be the better one.  

As they say, there's more than one way to skin a cat.  You just need to pick the right one.

Don - Specializing in layout DC->DCC conversions

Modeling C&O transition era and steel industries There's Nothing Like Big Steam!

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, February 22, 2018 5:06 PM

It may be possible to use an Arduino driving a relay board to use detection inputs to switch certain blocks to an asymmetric signal to stop the train. The only problem is this does not allow for reversing the train at the end of the line. It can run, making as many intermediate stops as you configure blocks for, and have relays for - relay switches between standard DCC and the asymmetric signal. But no way to change direction. For a loop arrangement this would work great. Wiring would be fairly simple - break one of the DCC bus wires into 2. One goes to one pole of each relay. The other goes through a diode and then to the opposite pole of each relay. Middle (moving) contact on the relay goes to one rail, which is gapped for each relay. Other rail is continuous and got back to the other booster terminal. Relay is on one poosition, that block is fed by plain DCC. Relay flips the other way, block is fed by an asymmetrical DCC signal and the train stops. Still need block detection inputs to the Arduino as well so you know when the loco hits a particular block so you know when to flip the relay and stop the train.

                                 --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!