New to DCC++. Question re 90 servos

Rifty Dec 13, 2019

  1. Rifty

    Rifty New Member

    5
    0
    1
    So I have an Arduino Mega and a Motor shield and controlled by JMRI.

    Loco works beautifully. All the correct noises and throttles etc.

    On my testbed I have installed a turnout - but I do not have a DCC turnout switch/motor. I do, however, have 12 x 9g servos. These servos work fine with the "sweep" example on a bare Mega board, with an external 12v supply and a common ground on a PWM pin.

    I am not an electronics whiz, and would like advice about how I can use these servos to throw turnouts under JMRI control. I do know how to set up turnouts in JMRI and configure the base station with the ID/Pin address. When I connect up the servo as I think it should be, I just get a buzz of the servo motor engaging and not switching off. It does react to the the Throw switch in JMRI.

    What I am having difficulty with is the wiring for the servos. Do I need additional hardware/external controllers for the servos? How have others managed to get servos reacting correctly to JMRI instructions to switch a turnout when JMRI is controlling the layout via a DCC++ setup?
     
  2. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi, and welcome to the forums and the world of DCC++!

    The 9g servos need a PWM (Pulse Width Modulated) signal to operate. This basically means a fast pulsing square wave signal, the duration of the pulses dictate the angle of rotation that the servo stops at.

    An Arduino can produce the required PWM signal, but the Arduino in a DCC++ base station is already really too busy generating the DCC track signals to also produce additional servo signals. You do therefore need a second device to do this.

    Arduino Nano and based on Ruud Boer's design. It works very well and operates 4 sets of points (though I don't use JMRI on my layout, others do successfully).
    https://rudysmodelrailway.wordpress...uino-dcc-servo-and-function-decoder-software/

    [​IMG]

    Good Luck!

    Jim
     
    Last edited: Dec 13, 2019
  3. Rifty

    Rifty New Member

    5
    0
    1
    Superb response. Just what I was looking for. I have a pack of 5 Nanos and I know just what they are going to be used for!

    Thank you Jim
     
  4. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    I was editing my post when you replied!

    Just to clarify, I used the mynabay schematic as the track interface to connect to the Nano, and I use Ruud Boer's software loaded on the Nano. You simply edit his Arduino sketch (which is well commented) to configure which pins to connect to the Servo(s). You can also adjust the PWM frequency, so you can make the servo(s) run at a slow (and more realistic) speed.


    [​IMG]
     
  5. Rifty

    Rifty New Member

    5
    0
    1
    Got that, thank you. Components already on order.
     
  6. Rifty

    Rifty New Member

    5
    0
    1
    I don't see the capacitor in the photo on the schematic. What is that doing and where does it fit into the circuit (if at all)?
     
  7. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    I can't get to my layout at the moment, but from what I remember it is an electrolytic across vin and gnd pins because at one time I provided power to the Nano via those pins rather than the usb sckt.
     
  8. vasilis

    vasilis TrainBoard Member

    110
    39
    10
  9. Rifty

    Rifty New Member

    5
    0
    1
    That looks like a step too far for me, with my current competency. I will try with the simplified circuit in Ruud Boer's example. I have got thecomponents connected on a breadboard and the DCC decoder is working, and I am getting responses and packets on the Bus, and am now moving to getting the DCC++ Base Station programmed directly with the turnout and sensors, and matching them to the DCC decoder tables. I tried with JMRI, but that did not work yet. Once I have the testbed working manually, I will get it working with JMRI.

    Thanks for responding.
     
  10. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11

Share This Page