Don C

Hi all,

We (2 club members) are constructing an n-scale layout, a 7.5 scale mile folded dogbone with continuous running, a lower deck with staging (complete) and an upper deck for some switching interest (in progress).

We use Digitrax, JMRI, Arduinos and servos for switch motor control. Currently the layout is operating as a loop and we can run 4 or more trains at a time. Switch control is done with JMRI running on a Rasp-pi 4 or Digitrax switch commands from controllers. Since there is only 2 of us now, one has to constantly go to the computer to throw switches (control from the controllers is awkward at best at least for us, can't remember the switch numbers).

The Arduinos we use are an ATMega 2560 to get block sensor data back to JMRI and 2 Pro Minis to control the switch servos.  All sketches were provided by Dr. Geoff Bunza and with modifications for this layout are working perfectly. 

Here is what we are aming for and need help accomplishing. We want to add manual switch control (remote panels) to the Arduinos to allow both of us to run trains with feed back to JMRI to keep in sync, to keep the panels updated properly.

Hardware is not a problem for us, its the programming to accomplish this. I have a general understanding of programming but loose it if it gets to complicated.  I can muddle my way through a simple program but when multiple libraries are included I can only assume they work well.

Don

Reply 0
Don C

The following is a block

The following is a block diagram of the layout control showing what is in now (solid lines) and what is proposed (dashed lines):

ntrol(1).jpg 

Currently the layout is setup with 34 switches and will require 2 ATMegas to control those with capabilities to go to 44 or so.  The interface to JMRI is a big question mark, not coming from JMRI but getting feedback to JMRI for updates. Dr. Bunza has a python script that sets up listeners to JMRI for the turnout table and may be something we could use. He has a sketch for the ATmega that fronts those listeners. Expanding on that sketch may be the way to go. 

I'm going to start there.

Any help would be greatly appreciated.

All will have to be done on the bench using bread boards as the layout is out of bounds due to the Covid-19 crisis, The park is closed and gated.

Those parts are on order, we'll see if they arrive. Up to 2 weeks they say.

Don

Reply 0
bcsanches

Hello,   you can use DCC++

Hello,

you can use DCC++ only for processing your layout inputs. It can talk with JMRI and it is just a matter of configuring JMRI to process the inputs and send signals to activate the turnouts. 

Do you know anything about DCC++?

Reply 0
Logger01

Multiple Options

You have several additional options.

As noted by Sanches you could expand your USB Layout Control Bus (LCB) with additional Arduino boards. The last time I checked JMRI  does not have great support for panel inputs on DCC++, but that is always a moving target. The maximum length of the bus between the panels, hubs and the RPi will also be limited by the maximum usable lengths for USB cables.

If you have IPads, IPhones, Android pads or Android Phones available, you can use them as Wireless remote panels through JMRI PanelPro. See the webThrottle - Web control for locos, panels, turnouts and routes page. This has been my favorite option for modular layouts when we were not being shutdown by excessive wireless traffic.

Since you are already using the Digitrax LocoNet LCB, you could use LocoNet compatible I/O modules like the RR-CirKits boards as panel switch inputs. RR-CirKits boards are supported within JMRI. There are other manufactures who make similar products, and you can also find DIY LocoNet compatible designs on the net.

You could add another LCB like the NMRA LCC. RR-CirKits also supplies LCC compatible I/O modules which are supported by PanelPro.

Another possible LCB option would be the MERG CBUS and I/O boards. You have to be a member of MERG to purchase board kits, but there is lots of support and, for the most part, setting up panels and panel I/O is fairly easy. MERG CBUS is well supported within PanelPro. (Note: After decades of running Loconet LCB compatible systems, I donated and or gifted all of my Digitrax equipment to the families of wounded veterans and some to clubs. My small scale test /demo layouts now run on MERG systems with smattering of SPROG, DCC++ and DIY hardware.) (Note: MERG kit operations are currently shutdown due to You Know What. )

Ken K

gSkidder.GIF 

Reply 0
Geoff Bunza geoffb

@Don re: Things to Consider

Hi Don,

In no particular order you might consider these things:

1.  USB connections to Arduinos can be extended to well over 100 feet in length using cheap, powered USB extenders and standard networking cables - cheap and effective. Check Amazon.com for more options than you need. They work great with the both sensor and turnout channels -- I checked.

2. Adding significant complexity to a DCC++ Arduino runs a significant risk of messing up the DCC hardware timing generated by the Arduino and its driver shield.Be careful. Adding libraries is sometimes problematic.

3. Having both throttles and panel switches control track switches of any sort is problematic without additional effort. JMRI fundamentally thinks it has accurate, global knowledge of your layout. This assumption is violated if you provide the ability to have a panel button operate a track switch, without feedback to JMRI. And even with feedback to JMRI there will be a (hopefully) short period of time when the Arduino throws the switch and JMRI is updated. If you intend to automate layout/train operations this could lead to odd problems. By the way before a casual reader jumps on me, I mean hardware panel switches not JMRI panels and switches, as I think this is what you originally referred to.

The bulk sensor channels you are using could be used to feedback the position of your individual turnouts to JMRI, using simple contact sensors (micro switches) that have been demonstrated in several articles and blogs on MRH -- a simple search should get you there. You would have to route those sensors to the proper place and logic in JMRI - not something I can readily solve for you, but it has been done. Regardless of several other thousand approaches, some variant of this is likely the cheapest overall approach.

4. Last, here is a general development comment: Completely design a build a small, operational segment of your layout first, before replicating your approach. Try to consider if not incorporate your future plans -- like signaling and/or automation. It will serve your future efforts well. You will face JMRI, Arduino, and scripting issues.

This is a great project. Good luck with your layout.
Have fun! 
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Jim at BSME

A thought/question

Could your remote physical panels be simply input to JMRI that says I'm requesting to throw this switch and the JMRI actually sends the commands to throw the switch? That way no feedback is needed, and JMRI is always the one in control and knows what way the switch is thrown.

Don I would like more information about what you have already done, is it documented somewhere? For one I'm curious what you are using for block sensors?

Thanks,

 

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
Logger01

JMRI Turnout Control

Quote:

Could your remote physical panels be simply input to JMRI that says I'm requesting to throw this switch and the JMRI actually sends the commands to throw the switch? That way no feedback is needed, and JMRI is always the one in control and knows what way the switch is thrown.

Jim, Although you can setup JMRI to simply monitor turnouts, what you described is actually the normal mode for operating turnouts with JMRI. That is JMRI detects when an operator actuates a switch (sensor) and then sends a command to throw the turnout. This allows for multiple panels or wireless devices (iPads, cellphones) to control a turnout or other layout features (signals).

Ken K

gSkidder.GIF 

Reply 0
Don C

Thanks for all of the inputs

Thanks for all of the inputs so soon.  Maybe being on lockdown has something to do with it. Not a lot of stuff you can do stuck at home, and I don't like housework.

@bcsanches  I have no experience with DCC++ so I would like to not add another story line to the mix.

@logger01,  Ken, that is a very good suggestion and I will look into it.  As there are only 2 of us using the railroad, and we both have ipads, remote control through a web interface looks promising for throwout control without additional hardware. Could you expand on this and let me know how to put a JMRI panel(s) wirelessly on an ipad?  Or would I need to run JMRI on the ipad?  Throttles using enginedriver or something similar is fairly easy to do although the only attempt at the club didn't work. We have several dual Digitrax throttles.

Edit: I have watched a Youtube video showing how to do it. The Pi has wireless and the Web server autostarts on it when JMRI is run.

@Dr. Geoff  The listeners that are setup with your turnout sensor sketch, are they looking for a high=throw, low=closed to keep JMRI updated?  If this is the case, all of my switch motors have switches attached to provide that.  The layout is only 16' X6' with 2 decks so I don't think cable lengths will pose any real issues that can't be overcome. Will put the arduinos where they work best. If I replace the current detectors with your DCC version of TwinT5 detectors, can the LOAD pin be connected to the sense pins of the ATMega Sensor to inform JMRI of block detection? I need something more sensitive than the ones I am using.

@Jim B  My block detectors are a version of Rob Paisley's DCC current detectors. May change to Digitrax BDL168s or something more sensitive to detection.

   http://www.circuitous.ca/CircuitIndex.html     

I created singles instead of using his double sensors.  Finding the correct nmber of turns through the coil is a work in progress. Not a lot of my freight cars are equiped with resistor wheel sets yet.

I will be setting up a small rsetup here at home.  I have several Pro Minis, servos, hand made switches (Fast tracks). I won't be able to try the ipad solution until the Rasp-Pi arrives and gets setup, it has shipped from Canada.

Thanks for the inputs fellows, food for thought.

Don

Reply 0
NebraskaCentral

My Arduino Controlled Layout (yet another option to consider)

I believe my layout’s components match the desired end state for your layout.

  • Completely controlled by Arduinos interfaced to JMRI
  • Very little code required on Arduino
  • No custom scripts or changes required in JMRI (using all native, already built functionality)

When building this layout, I did exactly as the previous posters suggested:

  • @Dr. Geoff -  “Completely design and build a small, operational segment of your layout first”
  • @Jim B. and @Logger01 -  “…normal mode for operating turnouts with JMRI….”

First, I want to give credit where credit is due:

Layout Details

The genesis for this layout was to prove that my ideas and desire for control and automation could be accomplished before building my larger empire.  As previously stated, there is no modification to JMRI or custom scripts required.  I use JMRI’s built-in functionality for CMRI.  I can successfully control turnouts from either JMRI, a browser connected phone/tablet, or the control panel and everything stays in “sync” because of JMRI’s Logix.  The Arduinos run Michael Adams’ Arduino CMRI library.  In fact my first “test” was doing the breadboard example from his website (it has sample code and screenshots of just how easy and simple this configuration is.)  This is a very low cost solution.  Besides the obvious parts needed (Raspberry Pi and Arduinos), the only additional parts needed are the MAX485 chips and an USB-RS485 interface (both of which I got on Amazon.)  I should also note this layout is 1’ x 4’ (N-Scale), and I use SG90 Servo’s with momentary switches (likely very similar to what Don C is already using) to toggle the turnouts.

Layout Network Topology

0Network.png 

Layout

20Top(2).png 

Let me know your thoughts or if you have questions….I was considering contacting Joe Fugate and seeing if this layout’s build and electronics would be worthy of an article or two in his magazine. 

-Steve

Reply 0
Don C

@Steve

This is very interesting and  looks pretty simple to implement and may be something to look into after I get my breadboarding materials, and Rasp-pi.  Kind of mind numbing to my 72 year old mind. Something else to confuse me with but interesting at the same time.

Thanks

Don C

I currently do not have any mechanical switches on the layout for servo control, something I was thinking about adding.

Reply 0
mike41

Thank you Steeve

This is exactly what I am looking for.
Reply 0
Don C

@logger01

Received the Rasp Pi yesterday and put Steve Todds img on it and I have been able to get the ipad to show the panels and am able to operate all the turnouts just fine.  I will use this for awhile to see if it causes any problems with the running of the layout once we can get back in.  I'll show the other operator how to connect as well.

Good for now.

Thanks all.

Don

Reply 0
Ron Ventura Notace

@Steve - I’d love an article on this.

I’m sure many of us would love an article showing how you did this: Arduino code, wiring etc. Please contact Joe about this.

Ron Ventura

Melbourne, Australia

Reply 0
Logger01

@Don

Don, very glad to hear that you have JMRI running with the WiFi links to the iPad. We found that once operators got the hang of using the iPads, they wanted us to add additional functions to the layout and PanelPro. Layout functions creep

Ken K

gSkidder.GIF 

Reply 0
Don C

@Logger01

Ken, 

That is what I have found to be the case.  The more home grown electronics involved the more ideas I have to implement even more.

Maybe signaling is next but I don't have a clue.....yet!

Don

Reply 0
Reply