Jump to content
 

railtronics

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by railtronics

  1. Hello Dave,

    I just purchased an Arduino Uno and would like to throw turnouts using DCC, a servo and the Arduino board. Would you be willing to share your code so I am not reinventing the wheel? If I am able to add any improvements, I will share them.

    Thank You,

    John

    You know how it happens, you start looking at one problem and you end up solving another. I was looking at ways to maximise the utilisation of the power generated by my solar panels by controlling the distribution of the power in my house using a microcontroller and some bits. This led me to the Arduino family of microcontroller boards.

    These boards are reasonably cheap, quite capable and dead easy to programming as there is a ton of free bits of software available. I still haven't sorted out my household power control (yet) but I've learned a lot about the technology and started to look for other things to do with it.

    My local model railway club, Winchester Railway Modellers, is currently building a new exhibition layout, Redbridge Wharf. More details here: http://www.rmweb.co.uk/community/index.php?/topic/58444-wrm-redbridge-wharf/

    The fiddleyard for this layout has over 40 turnouts which would break the bank if we used Tortoise motors. We need something cheaper but don't fancy subjecting our handmade track to the thumping of solenoids. Servos seem like a good idea. We would also like to be able to operate the layout using conventional DC switching or DCC magic. We need a servo controller and DCC accessory decoder that is cheap(ish). This is where the Arduino comes in.

    The Arduino can control a number of servos using a single wire to each. Each servo is connected to 0 volts, +5 volts and one of the PWM outputs of the Arduino. Using a PWM output is native to the microcontroller and requires no extra circuitry. The 0 and 5 volt lines are taken from an external power supply, probably one salvaged from an old PC.

    What I have done is to hook up a couple of servos in this manner plus a couple of toggle switches. Again the Arduino can easily detect switch input, just switch one of the digital inputs to 0 volts. The toggle switch is used to detect whether the servo should be thrown to the left or right. That's DC control sorted then.

    You need to be able to calibrate the throw for the servos really so another pushbutton switch has been added. Pushing this starts a calibration sequence on the last servo switched. One push and the servo centres, push again and the servo starts slowly stepping right, push again and the limit of throw is set and the servo returns to centre then starts slowly stepping in the other direction. Push the button once more and the other extreme throw is set and we are done.

    So thats's DC control and calibration sorted what about DCC? Luckily some folks have thought of this before and come up with a solution (or two). A bit of external circuitry is added using an optoisolator (to prevent the white smoke escaping from the Arduino) providing a connection to the controller. The Arduino detects the pulses of the DCC signal and interprets them as individual message packets. Just need to look for the accessory messages and activate the relavent servos. Easy peasy.

    Here's a pic of my breadboarded test set up.

     

    IMG_20130405_121809_zps639f07b1.jpg

    It 'ain't pretty but it works. The white box on the right is a cheapo 12v power supply as used in LED lighting rigs. It's feeding the Arduino.

     

    If a DCC signal is detected the toggle switches are ignored so the one lash up works happily as a servo controller with or without DCC controller.

    I've tested it with my Sprog and also a friend's ZTC 511 and all seems OK. Currently it doesn't work with my Roco Multimaus so there is some debugging to do.

    There is also an embryonic command line interface which allows commands to be entered from a PC connected to the USB interface so I think it would be fairly simple to set up a scheme whereby the settings could be extracted from a board and reloaded. Quite useful if you need to replace a faulty board quickly.

    I haven't yet got it controlling a Tortoise motor which would be cool as we have some of those to control on the scenic part of the layout. I'm sure it can be done with a bit of fiddling. There's also a lot of cleaning up needed in the code. All good fun.

    Cheers
    Dave

×
×
  • Create New...