Sensors into DCC++ base station

MrChuck Mar 11, 2020

  1. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    I'm interested in adding sensors to my DCC++ setup but after reading the docs and looking at some YT videos I have ended up quite confused.

    I have a DCC++ installation based on an Arduino Uno and using JMRI running on Ubuntu. This bit is all fine and I've had no trouble getting it working. I have also seen that at the program level, the Arduino is quite capable of reading e.g. an infrared sensor and doing stuff depending on whether it's tripped or not.

    What I can't figure out is how to achieve what's in the diagram, within the JMRI suite. I think there is intermediate hardware and software needed for the box marked "?"--or is there?
    Can the Uno do this by itself, and if so, how? What are the interconnections needed?

    When it comes to cost and complexity, it's seems these are more or less inversely proportional to each other. I don't mind a solution involving kit form stuff, but would prefer something cost effective off the shelf. But it all depends what's out there. Some of the solutions seem to require a tremendous amount of apparatus to get the first thing working, after which you can then do hundreds more with not much extra effort. But the learning curve seems extremely steep.

    I only want to do simple stuff at the moment, like detect a station using IR sensors and stop there, then move off again. Maybe trip a level crossing. I've had a look at the layout requirements in JMRI and I'm not too concerned about that side of it--what I'm stuck on at the moment is how to physically implement the sensors which you then configure into the layout.

    I'd like to expand it eventually to read points/turnouts (strike out whichever) state from microswitches. But I won't need to operate points--I run them analogue using MODRATEC WIT controls, because I like the interaction. Can't let the machines have all the fun!

    I hope this question is succinct enough to get some responses, but if there's anything that needs clarifying I will if I can.
    Canitbedone.png
     
  2. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
  3. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    Thanks Keith. As chance would have it, I had just found and was reading SMA28 from this same site when your post turned up!
    I may not even need to switch to a Mega since there appears to be a sensor shield for the uno form factor from yourduino--as long as it works.
    Has anyone else tried doing it this way?

    Can't tell from the yourduino site though how many connections are supported. Fewer obviously but there are no docs visible. I have asked them to send some if available.

    From what I've seen so far, there is significant integration effort involved no matter what you do. I'm not afraid to cut a bit of code if I have to, as long as there are some templates or guidelines or docs or something to give an idea of what's going on.

    Anyway now for some more light reading :-D
     
  4. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    One other thing: what would be the easiest route?
     
  5. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    easiest is to go commercial route and use loconet or LCC like these products. http://www.rr-cirkits.com/description/index.html

    JMRI can interact with loconet or lcc through serial(usb)port

    Also start looking at and learning scripts in jmri if you want to do the start stop stuff you're talking about
     
  6. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    Lot of developments since I last posted. I have Geoff's sensor scheme up and running--works like a charm, so I'm going to try SMA29 as well to control JMRI turnouts. Knocked together some jython scripts to test doing things with sensor inputs--all good. Now working on logix to read lots of sensors and take actions exactly as in the lead-off post for this thread.

    JMRI seems to be like donuts. Is there anything it can't do??
     
  7. ardsuppi

    ardsuppi TrainBoard Member

    33
    8
    3
    I'm not a JMRI user, but within DCC++ Arduino+Motorshield setup you can use free pins directly on that board to simply connect sensors.

    Free pins on UnoRev3 are:
    digital: 2 4 6 7
    analog: 16 17 18 19 (A2 A3 A4 A5)

    On a Mega board, these free inputs are much more.

    Attached a file (in italian) that explains the connections and setup within Rocrail for automation using infrared sensors.
     

    Attached Files:

  8. MrChuck

    MrChuck TrainBoard Member

    27
    6
    2
    All entirely correct as far as I know. However Geoff's solution is very neat and provides up to 68 sensors per Mega. It can be extended to as many Ards as you have USB ports for. And the integration into the rest of JMRI is very good.
     
    ardsuppi likes this.
  9. ardsuppi

    ardsuppi TrainBoard Member

    33
    8
    3
    I took these current sensors https://www.ebay.it/itm/5A-20A-30A-Range-A...E-/173585256771 in the version "ZMCT103C 5A # 2"

    Together with my dear electronic technical friend we have created a small circuit to be applied on each sensor to bring the sensor output to a voltage level (and voltage difference between OFF and ON state) in a way to be read by arduino board as a High/Low signal.

    This is the simple scheme created:
    - the OUT on the right goes on a free of both digital and analog arduino pin
    -5v power supply and ground must be shared with arduino board

    [​IMG]
    All resistors are 1/4W
    The 22K gray resistor is optional and depends on the sensitivity of the sensor to the square wave current of the DCC signal.
    The trimmer is used to calibrate the circuit to compensate for any physical distance of the sensor from the absorption point.
    From the test carried out, to read the absorption of the local decoder only (even with the lights off), 5 of 0.5 mm wire passages are necessary through the toroid.
    https://drive.google.com/file/d/1FHIp8wZ9_vPZNGK4NuvUbhrtK64f3u2w/view?usp=sharing


    Here is the video of the automatic operation with Rocrail and Arduino DCC ++:
    - the 5V power supply of the two circuits/sensors was taken directly from arduino via USB

    [​IMG]
     
  10. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    @MrChuck Do you think I could convince you to write up some documentation how others can implement what you have done? It doesn't have to be fancy. If you have a picture or two or a diagram, great, but if you just have text and steps, we can put it into our documentation. We can always take photographs or draw things in Fritzing go along with the text. We are busy compiling documentation now to create a new manual and online web pages.
     
  11. ardsuppi

    ardsuppi TrainBoard Member

    33
    8
    3

Share This Page