Advice needed: Sending layout state to DCC++

MrChuck Jan 7, 2020

  1. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    First a little background. I've been using DCC++ for about six months, on an Arduino Uno with Arduino motor shield and driven with JMRI running on Ubuntu. No issues there, that was the easy bit!

    I'm using Modratec Wire-in-tube point control because I love the analogue chunkiness of them, but the switch frames can also have microswitches added which change position with the point. This should make it possible to send this information to DCC++.

    What I'm now looking at was caused by a simple question I asked myself last week, which was how do I check the state of turnouts and stop the train if they're set the wrong way. And after reading about MERG CBUS, Loconet, CMRI and so on, I'm not only thoroughly confused but also a bit alarmed at how complicated it all looks. So for the comparatively simple task of reading a microswitch and then doing something depending on which way it's set, I have no idea how to proceed.

    Also I can't get any feel for which of the competing solutions I should start looking at. What I'd prefer is the least complexity and lowest cost. I have a technical background but I'm not a programmer and certainly not a Java programmer. I can work a soldering iron but these days the eyesight is a bit of a hindrance assembling PCBs. However I can wire things together OK.

    What appears to be lacking, in contrast to the DCC++ documents, is some sort of Minimum Viable Product overview of any of the these solutions. In other words, you will need at least this, this and this to do anything at all, and for the specific task of doing this, you'll need these other pieces. You physically connect it to DCC++ as follows, and so on. As far as I can tell, the specific things I need to do are read a position sensor for train location, read the turnout position (OK or not), and if not, tell DCC++ bring the train to a stop in a timely manner. Seems simple enough!
     
  2. wvgca

    wvgca TrainBoard Member

    499
    305
    21
    what you seek, i don't think is implemented in DCC++, on the programming track there is a current sense, that is used to validate programming ...
    but the rest would require a major rewrite od the DCC++ program itself [ at the least]
     
  3. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    Are you sure about that? I could swear that I've seen references to doing this with DCC++, possibly with extra shields of some sort and as you say, modified code. But I'm practically certain people have done it somehow...
     
  4. wvgca

    wvgca TrainBoard Member

    499
    305
    21
    i have seen references, yes, but not so much within DCC++ itself ....
    the occupancy detectors are tied into friewalds traincontroller [not free] to control the actual train movement and switches
     
  5. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    You can indeed use any of the spare BaseStation Arduino pins for reading the state of 'sensors', which can be for example magnetic sensors or micro switches. Once a pin is configured in DCC++ using the <S> command, that pin will be constantly monitored, and if the voltage level changes, a <q> or <Q> status change will be sent sent out by the BS.

    I don't use JMRI, but I'm sure it can look out for <q> <Q> status levels?

    You are of course limited by the number of spare pins available on the Arduino Base Station, but if you use a Mega rather than a Uno, you have considerably more. Or, I added a multiplex chip and with a bit of code modification to DCC++ I created many more input pins to the base station. For example I can have up to 16 magnetic sensors on my layout, using only 5 spare arduino pins.

    https://github.com/DccPlusPlus/BaseStation/wiki/Commands-for-DCCpp-BaseStation
     

Share This Page