Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Using servos to throw turnouts

  1. #21
    Join Date
    Jan 2014
    Location
    Leavenworth Ks
    Posts
    695
    Thanks
    2,461
    Thanked 1,767 Times in 451 Posts
    Mentioned
    21 Post(s)
    Tagged
    0 Thread(s)

    Default

    Quote Originally Posted by mosslake View Post
    Impressive yard Rodney!!

    Thanks Russ,

    It's Oroville yard on my layout and this was the 4th time I've relaid it and I hope the last.
    Rodney

    Here is my build of my n-scale railroad
    http://www.nscale.net/forums/showthr...-50-8-quot-%29

  2. #22
    Join Date
    Feb 2013
    Location
    Perth. Western Australia
    Posts
    563
    Blog Entries
    2
    Thanks
    1,473
    Thanked 769 Times in 309 Posts
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Default

    lol, looking at the size I can understand why. Good job though mate!!
    Cheers,

    Russ

    CEO of Devil's Gate Mining Co.



  3. #23
    Join Date
    Mar 2016
    Posts
    70
    Thanks
    55
    Thanked 66 Times in 43 Posts
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Quote Originally Posted by mosslake View Post
    That'd work for a semaphore signal or train order arm....
    Russ,

    Definitely could be, just a matter of the length of the control rod.

    Mark

  4. #24
    Join Date
    Feb 2014
    Location
    Oklahoma, USA
    Posts
    401
    Thanks
    360
    Thanked 898 Times in 244 Posts
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mark,

    I am sitting here listing to one servo clicking away in the background. Like Rodney, some tips on how you deactivate your servos would be appreciated. The sketch I am using - from Geoff Bunza, found at MRH - attaches the servos to pins in the beginning of the sketch. Does yours simply attach each servo as a throw command comes in, waits, and then detaches?

    Sam

  5. #25
    Join Date
    Mar 2016
    Posts
    70
    Thanks
    55
    Thanked 66 Times in 43 Posts
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Quote Originally Posted by samusi01 View Post
    Mark,

    I am sitting here listing to one servo clicking away in the background. Like Rodney, some tips on how you deactivate your servos would be appreciated. The sketch I am using - from Geoff Bunza, found at MRH - attaches the servos to pins in the beginning of the sketch. Does yours simply attach each servo as a throw command comes in, waits, and then detaches?

    Sam
    Sam (@samusi01)

    In short yes. A lot of the servo sample code 'activate' the servos during the setup() function and leave it at that. Depending on the actual servo library you are using there should be a corresponding 'detach()' function.

    I'm using the included servo library (by Michael Margolis), hence when it is time to move a servo to a new position there is a call to the attach() method (e.g. servo1.attach(servo1PWMpin)), followed by a series of .write(angle) calls, and finally a .detach().

    I also use a relay to control the power (+5V line) to the servos. During startup I found that occasionally a servo would jump wildly which usually resulted in breaking the solder joints on the points rails. So in the setup(), I first call the .attach(), followed by a .write() to set the initial angle of each servo. This starts the pulse signal for the given angle on the control wire. Then I switch the relay and provide power to the servos. Then after 1 sec I .detach() then. This may be over kill, but seems to work well for me.

    I had a quick look for Geoff's code but didn't locate it. If you give me a link I'd happily have a look.

    Mark

  6. The Following User Says Thank You to MDB For This Useful Post:


  7. #26
    Join Date
    Feb 2014
    Location
    Oklahoma, USA
    Posts
    401
    Thanks
    360
    Thanked 898 Times in 244 Posts
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mark,

    The original post by Geoff is at https://model-railroad-hobbyist.com/node/34417 and his sketch may be downloaded from there. The relevant part is as you note, and is below:

    Code:
    void setup(){
        Serial.begin(19200);     // Open serial connection.
        for (i=0; i<pwmPin; i++) {  // Set up all the output pins
        turnoutServo[i].attach (servoPin[i]);
        turnoutServo[i].write (thrownAngle[i]);
      }  
    So the next section of sketch has the portion of code that monitors JMRI and writes the servo angle. All you do is add a couple of lines to attached the relevant servo, then write, then detach?

    Like Rodney, I power (some) of my servos separately from the Arduino, i.e., not using a shield or anything. I have a +5V and GND bus which each servo is attached to and the PWM line goes to the Arduino. I'm not sure how well your relay function would work for me, nor can I claim a complete understanding of it.

    Sam

  8. #27
    Join Date
    Mar 2016
    Posts
    70
    Thanks
    55
    Thanked 66 Times in 43 Posts
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Quote Originally Posted by samusi01 View Post
    Mark,

    So the next section of sketch has the portion of code that monitors JMRI and writes the servo angle. All you do is add a couple of lines to attached the relevant servo, then write, then detach?

    Like Rodney, I power (some) of my servos separately from the Arduino, i.e., not using a shield or anything. I have a +5V and GND bus which each servo is attached to and the PWM line goes to the Arduino. I'm not sure how well your relay function would work for me, nor can I claim a complete understanding of it.

    Sam
    Sam,

    Yes, the sequence I use is 'attached the servo, then write (usually several of in a loop to give a smooth 'slow' movement), then after a short delay (say, 1sec) detach'.

    I hope the following diagram will help explain the 'relay' I use to ensure that the control pulse (which the 'write' commands create) exists before the first gets power. This is only part of the initial switch on sequence, not every time I attach and move a servo.

    power relay.PNG

    The batteries are a second source of 5V (I had trouble finding a suitable icon, so thought a battery would suffice) independent of the one powering the Arduino. I guess it could be the same power source, I found that sometimes a servo would draw too much current which resulted in the Arduino rebooting due to low voltage situation - hence I moved to a separate power source for the servos. The battery power is connected to the Normally Open side of the relay - i.e. the switch is open, hence the servo doesn't receive the 5V+. In this example you control the relay with pin 2. Setting pin 2, HIGH, will close the relay switch (some relay boards may be the other way around), and hence provide the power to the servo.

    If you don't have a issue with your servos 'jumping' when you first turn on the power then this isn't necessary. I found many of my (cheap) servos had a tendency to jump to 'zero' as soon as they where connected to power. This was my solution to avoid that problem.

    I've yet to incorporate JRMI into my setup but that is definitely on the todo list. I know I'll need to modify my code to allow for the remote operation. I already have some of that code in place as I attach via the I2C interface another Arduino to configure the various settings (servo end points, frog polarity) without needing to put the arduino out and re-program it.

    Mark


  9. The Following 2 Users Say Thank You to MDB For This Useful Post:


  10. #28
    Join Date
    Feb 2014
    Location
    Oklahoma, USA
    Posts
    401
    Thanks
    360
    Thanked 898 Times in 244 Posts
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mark,

    Thank you for the pointers. My servos do twitch when first connected to power but they don't jump to zero... that has the potential to be a large swing.

    I'm in the midst of disassembling part of my layout to improve the staging and the present plan is to use your tips and Rodney's brass tube on the servos in the staging.

    Sam

  11. #29
    Join Date
    Mar 2016
    Posts
    70
    Thanks
    55
    Thanked 66 Times in 43 Posts
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sam,

    I hope the re-modelling goes according to plan.

    Mark

Similar Threads

  1. Cheap way of using servos for turnouts
    By Richie in forum Turnout Control Devices, Signaling, & Detection.
    Replies: 48
    Last Post: 13th Nov 2013, 09:05 PM
  2. Model POwer Turnouts with servos?
    By SeabeeMike in forum Turnout Control Devices, Signaling, & Detection.
    Replies: 3
    Last Post: 28th Jan 2013, 11:22 PM
  3. Servos settings reverse after setting throw(Tam Valley)
    By Big Windy in forum Turnout Control Devices, Signaling, & Detection.
    Replies: 4
    Last Post: 7th Jul 2012, 08:17 PM
  4. Manually throw Peco turnouts
    By Steve from PA in forum Turnout Control Devices, Signaling, & Detection.
    Replies: 2
    Last Post: 31st Oct 2011, 12:47 PM
  5. Have Turnouts & Servos now....
    By Newbie51 in forum Layouts, Design, & Planning.
    Replies: 36
    Last Post: 31st Aug 2010, 09:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •