You're reading ...
Hardware, Software

Arduino as a combined DCC servo- and function decoder

The high speed opto-couplers came in this weekend. That meant it was getting time to try connect the Arduino to DCC and make it work as a function- and/or servo decoder.

A big thanks goes to the people behind the site mynabay since they had made available the software needed to ‘collect’ the DCC commands from the rails.

What I added is software that operates maximum 6 servos, while at the same time all other Arduino pins can be used as digital outputs, to switch functions.

Given the low price of an Arduino as compared to a ‘real’ DCC servo or -function decoder board this is highly cost effective way of switching your junctions and controlling other functions.

More info plus the download link for that software will be available soon on the software page.

About RudyB

Hobbyist

Discussion

25 thoughts on “Arduino as a combined DCC servo- and function decoder

  1. Hi Rudy,
    Excellent videos on how to use the Mynabay software together with your tuning code. Great stuff.
    Any advice on max distance from Arduino to the servo and the wire gauge to use?
    Thanks
    Peter

    Like

    Posted by Peter | July 6, 2019, 00:47
    • I have one on my layout that is 3 feet long and it still works OK, but the general advice is it is best to place an extra Arduino if needed to keep the servo wires around 1 or 2 feet.

      Like

      Posted by RudyB | July 6, 2019, 06:32
  2. Hi again Rudy,
    My optocoupler arrived today, so I’m all set. Just 1 question. How large is your layout, and have you had any issues with voltage drop from the Arduino output to the most distant point/turnout.?. Wondering if I need to use lower AWG wire gauge to reach 20 feet.
    Thanks
    Peter in Canada

    Like

    Posted by Peter | July 3, 2019, 01:35
  3. Hi Rudy, can you confirm that there I no issue with the current load due to the servos when actuating turnouts?
    I’ve heard that thi works for unloaded servos, but that with a real load , the current spikes and can damage the arduino. Comments.

    Peter

    Like

    Posted by Peter Philebrown | April 5, 2019, 16:30
    • The Arduino on board power supply canfeed one servo. As soon as you want to control more servos, always use an external 5V power supply that candeliver enough current. Connect the power supply GND to the Arduino GND.

      Like

      Posted by RudyB | April 5, 2019, 19:53
  4. Hi Rudy , i’m wondering you’ve ever published a diagram showing the placement of the optocoupler and other components on stripboard ?.

    Like

    Posted by gary | April 18, 2017, 21:43
  5. Hi Rudy,
    I also intend to use the Arduino in combination with the new Daisy II central from Uhlenbrock on a TT-scale railway.
    Is it possible to publish the electronic diagram on the breadboard that contains the optocoupler and how it is connected to the Arduino?
    Thanks in advance.

    NicoTT

    Like

    Posted by Nico Teering | January 18, 2015, 10:46
  6. Hi Rudy
    http://www.aliexpress.com/wholesale?catId=4099&initiative_id=AS_20150106142321&SearchText=arduino+optocoupler

    I see what you saying now, 1 Optocoupler circuit to run up 12 servos on each Arduino
    The Arduino 0ptocoupler from Aliexpress could i use one of these
    thanks for help
    Roger

    Like

    Posted by Roger Newton | January 6, 2015, 22:38
    • Roger, the items from the link you sent are relais with optical isolation. That’s not what we need here. Try to find a 6n137 optocoupler, or one with similar timing specifications (rising and falling edges in the tens nanoseconds area).

      Like

      Posted by rudyb2014 | January 6, 2015, 23:21
    • Hi Rodger.
      Don’t know if you are in the uk.
      I got these from ebay. Search item number 371154577600.
      Their shop is shut until the 12th. They arrived within 2 days just before Christmas.
      David Hi

      Like

      Posted by david | January 7, 2015, 00:16
  7. Hi Rudy
    I been studying your DCC SERVO as usual great Video
    the high speed Optocoupler you are using is pretty straight forward with a breadboard
    as for making a fixed unit for running 12 Servo would the Arduino Optocouplers you can buy from
    Alliexpress where you can buy 2.4 6.8 12 16 units all on a circuit for 3 to 8 dollers be a good idea
    Or are they not high speed optocouplers
    Any input from you will be helpful
    thanks
    Roger Newton

    Like

    Posted by Roger Newton | January 6, 2015, 11:27
    • Hi Roger,

      I’m not sure if I understand what your plans are with regard to those opto-couplers? Of course I’m not going to use the breadboard with the definitive layout, I’m going to solder the 4 components on a small piece ‘experiment’ pcb, that has the standard holes.

      Only one opto-coupler circuit is needed, the output signal of which can be fed to all the Arduino’s. Unless you plan to have your Arduino’s spread out over the layout at large distances from each other. In that case it would be advisable to have a local opto-coupler circuit with each Arduino.

      Then still I don’t see what would be the use of a 12 or 16 fold opto-coupler circuit like you mention? Maybe if you can send the link then I can understand better what you mean?

      Like

      Posted by rudyb2014 | January 6, 2015, 16:13
  8. Fantastic. Just what i have been looking for and will start putting together tomorrow

    Like

    Posted by david c | December 20, 2014, 02:15
  9. thank you

    Like

    Posted by Chaminda Weerawarna | December 18, 2014, 13:05
  10. Hi Rudy,
    I’m getting the following error msg when trying to upload.Can you help me.

    In file included from DCC_Monitor.pde:1:0:
    C:\Users\Chaminda\Documents\Arduino\libraries\DCC_Decoder/DCC_Decoder.h:131:11: error: ‘prog_char’ does not name a type
    const prog_char* ResultString(byte resultCode);
    ^
    Error compiling.

    Like

    Posted by Chaminda Weerawarna | December 17, 2014, 00:40
    • Error message sounds like it is something in the mynaby software. I can’t reproduce same error. Please (re-)check if everything is installed as shown in the video. If it is, but still does not work, try downloading the mynabay labrary from their website, place it in your library folder and see if it works standalone, without errors. Then try the RB-DCC software, it should find and use that library without errors.

      Like

      Posted by rudyb2014 | December 17, 2014, 09:09
  11. The code is available now via this link.

    Like

    Posted by rudyb2014 | December 5, 2014, 09:53
  12. Hi Rudy, this is fantastic.Thank you for sharing.I have spent hell a lot of money for ECOS detector unit.So this will help everyone to save money.Thank you very much for sharing.Hope you’ll make available the software for this as well.
    Chaminda from Sri Lanka

    Like

    Posted by Chaminda Weerawarna | December 5, 2014, 02:45
  13. This looks like an excellent concept and I would be very interested in trying this out once I have the time to get my head around arduino 🙂

    Like

    Posted by Dave | October 17, 2014, 08:21
  14. Yeah thats great.
    Ever since I have started to “play” with the arduino, I thought that it must be possible to decode the DC singal and have a fully field-programmable DCC decoder for e.g. servos or whatever function I want to program.
    I am very very intetested to see the code for what you are showing in that video.
    Kind Regards,
    Martin (Germany)

    Like

    Posted by Martin | October 8, 2014, 18:54

Leave a comment

Archive of all posts