Servo Motor Control for Model Railways Part 1 of 3 - Setup with Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ค. 2024
  • This is the first part in a three part guide on how to connect servo motors to an Arduino and control them using JMRI in order to throw points or operate semaphore signals on a model railway.
    This will work for both analogue and digital layouts and is a step towards layout automation.
    It's also very cheap compared to other methods of operating points such as using digital accessort decoders, capacitor discharge units (CDUs) and solenoid motors.
    Links to other parts of the series:
    Part 2 - • Servo Motor Control fo...
    Part 3 - • Servo Motor Control fo...
    Links to resources needed in tutorial:
    Arduino software - www.arduino.cc/
    Auto485 library - github.com/madleech/Auto485/
    CMRI Library - github.com/madleech/ArduinoCMRI
    Ebay and Amazon Affiliate Links
    (Full disclosure, as an Amazon Associate and Ebay partner I earn from qualifying purchases through these links and this helps to support the channel)
    Arduino Uno:
    amzn.to/2ODZoTO
    ebay.us/HYHkvP
    Servo Driver Board (PCA9685):
    amzn.to/2NoTKo3
    ebay.us/rVpaAJ
    SG90 Servos:
    amzn.to/2N3uzY4
    ebay.us/Xvuu72
    Variable Voltage Power Supply:
    amzn.to/3b4wtj9
    26AWG Servo Cable:
    amzn.to/3daEp55
    ebay.us/L1q3FE
    Crimping Tool:
    amzn.to/3tRJXHE
    ebay.us/XE2Dxl
    Jumper Wires:
    amzn.to/2N574Os
    ebay.us/Ujpvxn
    Chapters:
    00:00 - Introduction
    03:04 - Safety
    03:30 - Components & Tools
    05:31 - Step 1 - Connect Arduino to servo driver
    08:35 - Step 2 - Connect power supply to servo driver
    11:48 - Step 3 - Connect servos to servo driver
    12:58 - Step 4 - Connect Arduino to computer
    13:29 - Step 5 - Install Arduino software
    14:41 - Step 6 - Install Arduino libraries
    16:15 - Step 7 - Upload sketch and test
    17:30 - Summary
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 136

  • @nigelgarwellsupertiger1981
    @nigelgarwellsupertiger1981 2 ปีที่แล้ว

    1 Watched the (3) videos. Stunned by how easy (and cheap) it is.
    2 Bought the super duper kit from your Amazon store - hours of fun ahead.
    3 Just showed wife the three servos doing their stuff - the cat was more interested!
    4 Now to try my “wire in tube”, so the servos can be surface mounted behind back scenery.
    5 Link all this to the railway via JMRI - so will be watching those videos again!
    All the the videos are superb in both quality and subject matter, thank you & keep it up.

  • @miketooke9152
    @miketooke9152 2 ปีที่แล้ว +1

    All working for me! Just an additional tip for any complete newbies like me - once you have run the servo test program - it will keep running forever. The only easy way to stop it I could find was : file / examples / eeprom / eeprom - compile and upload.

    • @garytaylor5959
      @garytaylor5959 2 ปีที่แล้ว

      Hi Mike did you use Eeprom clear.

    • @miketooke9152
      @miketooke9152 2 ปีที่แล้ว

      @@garytaylor5959 Sorry - yes I did, as I was then going on to test something else.

  • @pedalcarguy
    @pedalcarguy 3 ปีที่แล้ว +3

    Thank you for providing us with these gold nuggets of information! I am starting on my first real layout ever, so I really appreciate your insights. Servos clearly are the way to go!

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +1

      Thanks for watching 👍 Unless you have lots of 💰 to spend on fancy tortoise motors I think servos have to be the best/cheapest method.

  • @gjdanco4260
    @gjdanco4260 3 ปีที่แล้ว +4

    Hi Rob
    Thank you for this 3 part video. What's impressive is the way you described the process. Those of us with minimal arduino experience can follow along. My servos successfully worked the very first time. Cheers from Canada👍

  • @mikejj101
    @mikejj101 6 หลายเดือนก่อน +2

    Brilliant videos Rob

  • @JasonYen0418
    @JasonYen0418 หลายเดือนก่อน

    Very useful channel, Thank you! I try to set up my DCC train layout studying from it. Sufficient infomration, let me dreams come true!

  • @DavidSmith-gf5qe
    @DavidSmith-gf5qe 2 ปีที่แล้ว

    Thank-you Rob. I did most in about 20 minutes whilst watching. I used an old laptop with windows XP as I can move from desk to loft etc to control railway. In short, latest software is not compatible with XP, v 1.8.9 is according to a thread I found, so loaded that. Also had to point software update for USB driver to the arduino/drivers folder. 3.5 hours to resolve the XP issues, so magic to then see my 2 test servos with synchronised twitching. :-) Pace/style of your delivery is excelent (says the retired vido producer). Thank-you again for parts 1, 2 and 3 and I'll be revisiting your DCC controller videos too. :-)

  • @yogimoninc
    @yogimoninc ปีที่แล้ว +1

    Beautifully succinct video, clear concise and no waffle, really useful.

  • @henrybest4057
    @henrybest4057 3 ปีที่แล้ว +4

    Two advantages of using servos over solenoids that you didn't mention:-
    1) They are a lot less noisy...you don't get that load CLUNK when the points are changed.
    2) If you remove the over-centre springs from the points you get a more prototypical slow movement of the tie bar.

  • @paulhargreaves1497
    @paulhargreaves1497 2 ปีที่แล้ว +1

    Simply brilliant! Lovely and clear, subscribed!

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      Thanks Paul 👍

    • @paulhargreaves1497
      @paulhargreaves1497 2 ปีที่แล้ว

      @@LittleWicketRailway Got my Arduino clone and servos this morning....working to the test stage! Thanks again Rob. 40+ years away from the hobby....what a change from a (single) metal bogied class 37!

  • @hughsmodelrailway2055
    @hughsmodelrailway2055 3 ปีที่แล้ว +1

    Fantastic series of videos Rob 👍👋👋
    Keep safe
    Best wishes my friend
    Hugh 👋☕️☕️

  • @crescentjunction
    @crescentjunction 2 ปีที่แล้ว +3

    Thanks so much! I've been working with the Adafruit Servo shield, which is the same as the PCA9685 you are using but after some soldering it mounts directly on top of the UNO or MEGA. I've been using this as a standalone setup to control turnout servos using pushbuttons to set several turnouts at once for a route as in a yard throat.
    One other thing to note: after adding the libraries you must restart the Arduino IDE. Looking forward to catching up on the rest of your videos.

    • @kenrsullivan
      @kenrsullivan 2 ปีที่แล้ว

      I'm looking into buying the PCA9685 board with the Adafruit servo bonnet/hat. How do you trigger the servo's to move from that adafruit board? My TH-cam about has contact info if you want to message me. Cheers!

  • @JimE-ch7uw
    @JimE-ch7uw ปีที่แล้ว

    Great video and channel. So much to learn, thank you. Might be worth updating the affiliate links to search terms as some of the products are not available

  • @rcav8r2
    @rcav8r2 2 ปีที่แล้ว

    Rob; Great series of videos. Very easy to follow. Apologies for the long post, but I want to be thorough. I seem to have a weird problem. I can only control 2 servos. It does not matter which 2 (out of 8). If I comment all servos out except for 2 of them (It doesn't matter which 2) , those 2 work just fine when controlling via JMRI/CMRI. If I add a 3rd to the mix, none of them work. I can control any 2 of the 8, but only 2 can be uncommented in the sketch.
    I tried using just an UNO with the PCA9685 and then a mega with sensor shield ( and without) I swapped between 3 different PCA9685 boards. All behave the same.
    Power supply measures a steady 5.03 volts for the servo power supply when servos are moving and when not .
    As I am not using a 485 bus, I tried commenting those lines out and changed the CMRI line to this:
    CMRI cmri(CMRI_ADDR, 24, 48, Serial);
    Same results.
    I wrote a sketch to cycle through all 8 servos one by one and this sketch works great. Even tested all 3 PCA9685 boards with this. And tried with the UNO and Mega with and without sensor shield. All is well with any combination.
    Any input would be greatly appreciated.
    Thanks
    Dave

  • @davidminshall9356
    @davidminshall9356 ปีที่แล้ว

    Great 3 part video Rob. You have allowed me to understand a lot more although the coding is going to be my downfall especially after watching the video on slowing down the movement of the points. I'll just have to watch the video a few more times!

  • @9501599
    @9501599 2 ปีที่แล้ว +1

    Man buying these components aren't easy. They don't ship to New Zealand, yet they ship internationally...go figure. I have often thought about using servos but all of the various railway guys use point motors so I am liking this video 📹😀. Searching for the components is an interesting exercise 😉.

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      If you can afford the fancy tortoise point motors or similar then they do look really good, but you could probably fit 10 servos for the price of each tortoise. Shame that getting parts is so hard in NZ, there must be a market for them.

    • @9501599
      @9501599 2 ปีที่แล้ว

      @@LittleWicketRailway hello again, I managed to get the parts so I'll need to watch ⌚no watch your video a few more times to get my head around the down loading stuff. 😀 fun, fun oh did I say fun? 🤔

  • @thelittlewesternmodelrailway
    @thelittlewesternmodelrailway 2 ปีที่แล้ว

    Hi Rob! So I'm finally getting round to using your videos on my layout, I wanted to ask:
    I have an Arduino setup for DCC++EX Control and I will have one for a sensor hub. I'm assuming I need a 3rd to run the servos or can this be done with the 'Sensor Hub' too? Probably a stupid question due to them needing different Shields.
    Anyway thanks for the video series, I've watched them multiple times and finally ready to use them myself!
    Take care

  • @alanwiggins8073
    @alanwiggins8073 6 หลายเดือนก่อน

    Hi Rob. Watched all of your Arduino vids - very well presented, simple to follow and great for muppets like me to understand whats going on. I have a question though - you mention that each servo driver needs a separate power supply, so could i run a 5v bus wire and attach the boards to it? I have 67 sets of points, and not enough plug sockets to power each board! Thanks, Alan

  • @scentgrasslakerailway
    @scentgrasslakerailway 4 หลายเดือนก่อน

    Great information, will this sketch work within the DCC++EX sketch or because it is C/MRI will it not?

  • @DavidTaylor-dl8qs
    @DavidTaylor-dl8qs ปีที่แล้ว

    Hi Rob, Having seen your 3 videos concerning point and signal control via Arduino and servo drives I am interested to to see if I can apply some of your principles to my garden layout. I model in 16mm scale using battery and steam driven locos. My points are operated via solenoid actuators and miles and miles of 22AWG wiring. Due to the distances I have had to standardise on 22AWg wire because of the volt drop.
    I have been experimenting with Micron receivers with servo output to 6 servors, and a Micron T/X I have ended up with signal problems to servos due to the wire runs because of volt drop and that is why I have taken the path using old technology namely peco solenoids, micro switches, LED lights for route identification it works but I believe your method of control is very attractive.
    Could your system be integrated with the arduino and servo drive as per your videos noting the distances I have to operate the points and signals. The longest distance from the central control point the the furthest point is in the region of 20meters.
    I am interested to hear if any of your viewers are using your system on large gauge garden railways, and also your views and comments, hoping to hear from you.
    Kindest regards,
    David Taylor (Spain)

  • @nickhillier8893
    @nickhillier8893 3 ปีที่แล้ว +1

    I enjoyed your videos having just seen them in youtube. Have bought a megapoints system, it seems to work fine at present although at the moment have only connected them on a testing board. One thing I noticed on a servo is that it gives a kick when you switch mains power on. Is there any way of avoiding this as some of my points are surface mounted with only a small travel needed, so that when I switch on power it kicks and the points move, would appreciate any suggestions.
    Nic

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +1

      Hi Nick, afraid I don't know much about the megapoints system. The servos must be receiving a signal when the power is turned on, you'll need to work out where that signal comes from and how to stop it. The guys are megapoints might be able to help if it's their system you're using. It's a word of mouth hobby and most suppliers want their customers to have a good experience, so I'd drop them an email and see what they say.

  • @aliciahoflack138
    @aliciahoflack138 2 ปีที่แล้ว

    @little wicket railway were did you find the stl for the servo mount?

  • @darkfrag83
    @darkfrag83 2 ปีที่แล้ว

    Can you go about controlling the servos without the arduinos for example from centre off switches as you would using solonoid point motors on an analogue system?

  • @clivemedley8538
    @clivemedley8538 3 ปีที่แล้ว +1

    Great informative videos Rob, thanks. Just a quick question on fitting the servo's to the points if I may. I am using n gauge peco electrofrog points so, when inserting the servo rod, do I need to remove the point spring as you do for tortoise, cobalt, etc? Thanks and, hope the move goes well. Clive

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +1

      Hi Clive, I've got to be honest and say that I've never used n gauge so I couldn't tell you, I doubt it would be a requirement. For OO it's a matter of preference. A servo should easily be able to overcome the force of any spring if it's fitted correctly, so it's not a performance thing, but it looks smoother if the spring is removed. Without a spring you'll need to make sure the servo is calibrated correctly to ensure the blade is securely up against the rail, without stressing the servo, since the spring won't be there to take up any slack.
      I've accidentally removed some point springs before whilst ballasting and my only warning would be that once removed they don't go back in without a fight, they have a tendancy go missing easily and it's hard to get/make replacements.

    • @clivemedley8538
      @clivemedley8538 3 ปีที่แล้ว

      @@LittleWicketRailway thanks Rob, I think I will see how I get on programming the servos first and then decide if I can get them to stay in a position I am happy with. May try removing the spring on an old point and see how it goes. Thanks again.

  • @donz.519
    @donz.519 3 ปีที่แล้ว

    I might that I really enjoy watching your videos on adding tech to your layout. That being said, I am still a little perplexed on one thing. Can a whole model train be Ean with one ardiuno or am I looking at multiple ardiunos by the time I'm done. The layout that I have is close to 24 feet by 24 feet and there are 40 turnouts in the engine yard alone.

    • @paulhargreaves1497
      @paulhargreaves1497 2 ปีที่แล้ว +1

      I'm no expert, but see Rob's video on piggy backing boards........you'll probably have to make your own wire looms, but chances are one board can sit near enough points to be fully used. Then linked to a distant one which controls more. etc etc

  • @JensRohde
    @JensRohde 3 ปีที่แล้ว +1

    Hi Rob,
    Good series! I'm in the process of starting up again with model railroads. Due to space constraints, I've decided to go with N scale. And there I have looked at Kato Unitrack. But their points come with the electronics installed. So that would be solenoid driven points, or I'm I missing something?
    -Jens

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Jens, I'm really sorry, but I don't have a clue about the Kato points. I've just had a look on here (www.rmweb.co.uk/community/index.php?/topic/136954-operating-kato-unitrack-points-via-dcc/) and it sounds like they're solenoids.

    • @JensRohde
      @JensRohde 3 ปีที่แล้ว

      @@LittleWicketRailway No worries. You can't know it all :) - I've decided to go with Fleischmann N-scale instead, and they come without building switching. So I can use servos now.

  • @mattsynth
    @mattsynth 2 ปีที่แล้ว +1

    Hi Rob, I have been using your code to control my servos with great success. I was wondering if there was a way to slow down the speed of the servo by adding code into your loop. The servos jump into place and I am afraid over time they will eventually damage the turnouts. Thanks, Matt

    • @SeanWalsh75
      @SeanWalsh75 2 ปีที่แล้ว

      I just watched his new video on this - th-cam.com/video/6sAGNx8bkQU/w-d-xo.html

  • @thelittlewesternmodelrailway
    @thelittlewesternmodelrailway 2 ปีที่แล้ว +2

    Hi Rob, I wonder, with the Servo Driver PCB. Do you think it’s possible to have just a Physical button control, like a toggle?
    Or does it require the power and commands from the DCC++ arduino to do the logic? Thanks.

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว +1

      It's possible to have it so that a servo can be operated by a button, but you'd still need a 5V power supply and a way of generating the PWM signal. An Arduino is probably overkill for a single servo, but it's easy. You could probably create your own circuit and program a microcontroller to do only what you need for a more compact package.

  • @anatoliidudko7029
    @anatoliidudko7029 3 ปีที่แล้ว +2

    This is fantastic video. I wish you can make one that describes how to add leds and toggle switches and control it from conventional control panel without JMRI. Any ideas on how to make and wire it? Thank you

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +2

      Thanks! I've had a few requests for this and it's something I'm looking into 👍

    • @anatoliidudko7029
      @anatoliidudko7029 3 ปีที่แล้ว +1

      @@LittleWicketRailway Thanks. That would be great as I could not find any video or wiring diagram about it. So that would be a huge help for newbie like me.

  • @tgribbon1962
    @tgribbon1962 ปีที่แล้ว +1

    brilliant 👏 👏 👏

  • @paulsmith5821
    @paulsmith5821 3 ปีที่แล้ว +1

    Hi Rob, I'm really enjoying your videos as I want to go down the automation route on my layout. Currently I use JMRI / DCC++ with an Arduino to manually control the trains, all my points are switch controlled with solenoid motors which is what I need to use JMRI for next. As I'd also like to use your IR sensor system for train detection and this system for point control using servos, is there a limit on the number of Arduinos that can be connected to a laptop though or can I add one to each USB port? At this rate I'll be up to 3 separate boards.

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +3

      Hi Paul, I use three separate boards for DCC++, servos and sensors. I've started using a powered USB hub (must have its own power supply) to connect them to the computer.
      I'm looking into combining some of the sketches so servos and sensors could maybe run off the same board.
      I'm also looking at using wireless ESP32 boards to save on wiring and connections.
      Afraid progress has been a bit slow on the tech front, but try to get some guides out in Jan.

    • @paulsmith5821
      @paulsmith5821 3 ปีที่แล้ว +1

      @@LittleWicketRailway Thanks for your reply Rob, I'm glad that multiple Arduinos work ok. As my layout is built with solenoid motors I don't fancy swapping them all out for servos so I'm going to use an 8 channel accessory decoder for the part I want to try automating first. I'll then use your IR sensor system for train detection as, like yourself, I don't fancy pulling up the track to fit the insulators required for current block detection. I'll let you know how I get on during January. I may even pop up a video!

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Little wicket has solenoid motors too which are controlled using accessory decoders with capacitor discharge units fitted. You don't need to change them to servos.
      Using IR sensors to do automation is slightly trickier than using a combo of IR and current sensors, you may find that you end up writing scripts rather than using the built in JMRI automation or having to make use of JMRI Logix. But it can still work well.

    • @janeswift9961
      @janeswift9961 3 ปีที่แล้ว +1

      If the Arduino is handling automated non-interactive applications (eg reversing loops and block signalling) then they only need to be connected to the computer to upload the sketches, thereafter they can run from a 5 volt DC power supply, indefinitely. Arduinos that are handling points/turnouts/switches and DCC++ will need to be connected to the computer full time.

  • @victormaitland-smith6121
    @victormaitland-smith6121 3 ปีที่แล้ว +1

    Hey, I thought the tute was very good and well presented. One thing that stumps me is the polarity switching for the electro frogs. How is this going to happen?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Victor, thanks! I think you would need to add a microswitch onto the servo mount that switched the polarity as the servo moved positions. Just like the microswitch for the position sensor. The MERG servo mount can have two micro switches, one on either side.

  • @lullo1957
    @lullo1957 3 ปีที่แล้ว +1

    Hi. I was wondering after configuring the signals and switches I dont want to use JMRI to steer the layout, but manual with some toggle switches. Is that possible and where do I connect the switches? On the arduino board or on the 9685?

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      Hi Hans. That's definitely possible, but will need more coding in the sketch. If you add the switches to the Ardunio as inputs then you can write code for them to activate the servos.

  • @KimboH55
    @KimboH55 8 หลายเดือนก่อน +1

    Thanks!

  • @garypeat
    @garypeat 3 ปีที่แล้ว +1

    Hi there, I currently use an Arduino and motorshield with dcc++ through JMRI to control my engines, can I piggy back the servo board from this or do I need another arduino and power supply etc?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Not something I've tried, but it might be possible depending on what pins are still available and how much memory is left on the board. You'll need to combine the sketches. You'll still need another 5V power supply connected to the PCA9685 to power the servos if you plan on having more than a couple attached though.

  • @robertmarshall9970
    @robertmarshall9970 3 ปีที่แล้ว +1

    Hi Rob
    If you are using DCC++ how do you connect 2 Ardunio's to the same computer?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Robert,
      I use multiple Arduinos, each with their own USB cable connected to the computer. The computer allocates each one with a different COM address (COM01, COM02, etc...) so that you can refer to them in your scripts.
      Using multiple boards probably isn't the most efficient way of doing things and it obviously takes up multiple USB slots. The benefits of having multiple boards is that if something goes wrong with sensors then I know which part of the electronics to look at.
      It's probably possible to combine some of the sketches, but it's not something I've looked into. I think I recall reading a blog, maybe from the N-Scaler who combined lots of functions onto a Mega board.

  • @Theoriginalborgy
    @Theoriginalborgy 3 ปีที่แล้ว +1

    This is interesting. I’m still running DC but I would like to use servo motor for my points but with independent switches for each point. I can’t find anything to do this ? any ideas. Thanks

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +2

      Hi Leigh! Definitely possible either with or without JMRI. You might need to do a bit of programming, especially if you're not using JMRI. Switches are setup as inputs and the Arduino changes the servo based on the switch. Can also add in some LEDs as outputs for route indiction. I plan on doing a mimic panel with switch control of turnouts in the future, just need time 😀

  • @brice3011
    @brice3011 2 ปีที่แล้ว

    10:48 better apply a little bit of solder to stripped wire ends so that these do not fray when trying to insert in screw connectors

  • @newnorfolkmrr1754
    @newnorfolkmrr1754 11 หลายเดือนก่อน

    Rob, great video. Everything worked first time 👍🏼 Now controlling 16 servos through JMRI/CMRI. I'm getting a buzzing noise from some of the servos. Have you experienced this? Not sure if they're faulty or aren't lubricated enough. Do you know if there's a coding fix to stop them jittering? Thanks, Ian

    • @lestaylor7767
      @lestaylor7767 8 หลายเดือนก่อน +1

      Hello,
      I've been following the video's and got one working but for some reason trying to get 4 servos working is being extremely frustrating. As you have mastered 16 can you point me in the right direction.
      All I have done in the servo script is change from 1 servo to 4 but only the 1st servo responds.
      Is there anything else you did different to get your 16 working please. (tried changing DE_PIN 2 to 0 and still make no difference.
      Desperate to move on, but also just lost 2 of my point springs so need the servo's to change and hold.
      Any help would be appreciated

    • @newnorfolkmrr1754
      @newnorfolkmrr1754 8 หลายเดือนก่อน

      @@lestaylor7767 Sorry for the late reply- I've been out of the country.
      The only changes that I made to Little Wicket's 'Servos.ino' sketch (available from the link in Part 2 of Little Wicket's youtube tutorial) are:
      1. Set the total number of servos (in my case 16) - #define numServos 16
      2. For each servo, define the movement parameters (one set of 'Throw' and 'Close' statements for each servo - increasing the servo number by one for each servo [0 connected to the first set of pins on the PCA9685 board / 1 connected to the second set of pns etc.]) -
      Throw[0] = 1100;
      Close[0] = 1550;
      Throw[1] = 1300;
      Close[1] = 1800;
      Throw[2] = 1300;
      Close[2] = 1650;
      Throw[3] = 1400;
      Close[3] = 1800;
      .....
      Unless you've adding a second PCA9685 board to add more servos, you shouldn't need to make other changes. I suggest you re-download Little Wicket's 'Servos.ino' sketch and make the changes suggested above and hopefully all should be OK.Feel free to get back to me if you're still having issues.

  • @ShaneRHDR
    @ShaneRHDR 3 ปีที่แล้ว +1

    Hi thanks for these video they are very useful espically for a novice like myself. You have given me food for though. The only thing is if I were to go down this route is I would want to be able to use the servos for point motors and signals. But I would perfer to use toggle switches. Is their any chance you you be able to do a video showing and explaining how to use toggle switches please. Thank you in advance. Please carry on the good video and how twos

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +2

      Hi Shane! Would you be using switches and JMRI or just switches? Either way it's posssible. I've got a video planned, but the house move is causing me a bit of stress at the moment, so I'm way behind on everything.

    • @ShaneRHDR
      @ShaneRHDR 3 ปีที่แล้ว

      @@LittleWicketRailway hi I hope the move goses well. Ideally I like it to be just the toggle switchs operating on their own without thr jrmi or any other software. Thanks in advance.

  • @dominiquemonsellier3758
    @dominiquemonsellier3758 2 ปีที่แล้ว

    Hi Rob,
    Thank you for all your videos. I followed every steps but the servos don't work. After having watched many other videos on youtube it was the same problem.
    The servos are ok when they are directly plugged on the uno but when i plug them on to the pca 9685 nothing happens.
    Yesterday I just unpluged V+ on the pca9685 and pluged the same wire on the V+PIN on the same pca9685 and IT WORKS now !!!!
    The problem is : i don't understand why!
    If anyone has the answer....
    Thanks for all your videos again!!
    Cheers from paris.

  • @ianollman5006
    @ianollman5006 3 ปีที่แล้ว +1

    Hi, it seems that there are two types of SG90 servo's, one is a continuous turn and the other is a 180 degree turn type, so just be aware to order the 180 degree which is the correct type for this project.

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      Thanks for letting me know 👍 Do you have a link to the continuous turn versions?

  • @garytaylor5959
    @garytaylor5959 2 ปีที่แล้ว

    Hi Rob. Complete newbie .Help needed , I have uploaded the test project ( 3 servo,s ) how do i stop them from testing..

  • @steveharper5536
    @steveharper5536 3 ปีที่แล้ว +1

    Hi Rob just started watching your servo introduction video's, I like the idea of using servo's for point control. I am assuming its the same installation for a DC layout.

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +2

      Yes, this will work for analogue and digital 👍 You can control signals and points using the computer, but still drive the locos using your DC controller.

    • @56NeilWatson
      @56NeilWatson 3 ปีที่แล้ว

      @@LittleWicketRailway Rob, I'm going to follow your DCC++ controller for my layout. Are two Arduino required, one to run the engines and one for the points, signals etc?

    • @janeswift9961
      @janeswift9961 3 ปีที่แล้ว +1

      @@56NeilWatson Probably, as you would need to rewrite the sketch to accommodate both functions. The loop section would have to do a lot more work too, potentially reducing the response time of the controller (serious) and servos (almost as serious). Unos are available on eBay for just a few pounds, it would just be simpler to get a second Arduin Uno IMO

    • @56NeilWatson
      @56NeilWatson 3 ปีที่แล้ว +1

      @@janeswift9961 I got myself a Mega plus sensor shield. Have seen most of Rob's presentations ..... some a number of times. Have purchased some MERG block current detectors and have got two soldered up. Bought one of their 4 board kits and plan on separating them Not a soldering expert but have considered doing a vid assembling one. Have replaced some 5mm IR sensors with 3mm to get them between the N gauge track sleepers which work well

    • @janeswift9961
      @janeswift9961 3 ปีที่แล้ว +1

      @@56NeilWatson Neil, thinking about it, if the various applications (block detection, DCC++, signals etc) were each made as a function and then called from the loop function of a sketch, it could conceivably work and be manageable, Rob's point about the memory of an Arduino is a good one though. I have also got some block detector kits from MERG, but until I can get the track I have ordered and laid on the baseboard, I can't go on to test my various bits in anger so to speak. Good luck with your project! I sometimes think a forum for Arduinos and Model Railways would be a better way to spread ideas etc rather than through TH-cam.

  • @willreflex1
    @willreflex1 3 ปีที่แล้ว

    Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"
    Sketch uses 5630 bytes (17%) of program storage space. Maximum is 32256 bytes.
    Global variables use 428 bytes (20%) of dynamic memory, leaving 1620 bytes for local variables. Maximum is 2048 bytes.
    An error occurred while uploading the sketch
    hi got this message while trying to upload the sketch
    any ideas on how to correct this
    thanks
    Will

  • @rickcaldwell7154
    @rickcaldwell7154 2 ปีที่แล้ว

    Sir I am missing something i am doing my best to drive more than 6 servo's using your system. I can make servo1 & 2 work but that is where it stops. nothing more than that. any suggestions?

  • @brice3011
    @brice3011 2 ปีที่แล้ว

    Better use jumper wires of the correct colour (8:20), red for supply voltage and black for ground.

  • @andrewwalton611
    @andrewwalton611 3 ปีที่แล้ว +1

    Thank you for explaining this first part Rob.
    i may be an idiot But, how do I stop the sketch from cycling?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Captain! If you want to stop the Servo example sketch from cycling then you can just delete the final line of code:
      if (servonum > 7) servonum = 0; // Testing the first 8 servo channels
      The Ardunio won't go back to the beginning then.

  • @rossord
    @rossord 2 ปีที่แล้ว +1

    Great videos, thanks. All boards correctly wired and all software installed, but no movement from the 3 servos! I have 1 green led showing on Arduino with tx led flashing slowly. I have red led showing on servo board. 5v power supply checked OK. Computer port OK. Any ideas, please?

    • @stewartmurphy628
      @stewartmurphy628 2 ปีที่แล้ว +1

      Just connected everything and uploaded sketch and have the same problem, no movement in servo. No green light on arduino just red. Have even tried swaping out the board but same result. Any thoughts.

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      Hi Ross. Sorry this hasn't gone smoothly (nothing ever does 1st time in my experience!). Time to do a bit of fault finding:
      Did you have any errors when you uploaded the sketch?
      Triple check your wiring between the Arduino and the PCA9685?
      100% plugged the servos in the right way round and they're definitely on pins 0, 1 and 2?

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      Hi Stewart, again, sorry this hasn't gone smoothly. There are basically 2 things to check here:
      First the sketch:
      When you upload the sketch did you get any errors?
      Did you see the lights on the Arduino flash to show that it's receiving the sketch from the computer?
      Once the sketch is received and running you should have the lights blinking similar to how they are in the video with the power on light and the TX light flashing occassionally: th-cam.com/video/ayOoUkdjHtg/w-d-xo.html
      Second the hardware:
      Have you triple checked the connections? It's easy to confuse VCC and V+ for example or mix up SCL and SDA.
      Have you got a 5V power supply connected to the PCA9685 to power the servos?
      Are the servos definitely plugged into connections 0, 1 and 2 and are they plugged in the correct way round?
      Let me know how you get on.

    • @stewartmurphy628
      @stewartmurphy628 2 ปีที่แล้ว +1

      @@LittleWicketRailway Thanks for the reply. I think it may have been a faulty servo control panel, swapped it out and it worked OK, or maybe I connected it better on the new one.
      Thanks again for the info as I am just starting to build the layout and all money saving tips are welcome.

    • @LittleWicketRailway
      @LittleWicketRailway  2 ปีที่แล้ว

      @stewart murphy glad you got it working

  • @MiniatureWorld_01
    @MiniatureWorld_01 3 ปีที่แล้ว +1

    Hi Rob thanks for sharing
    Could you explain how to daisy chain the PCA9685 for more servo control ? I mean the software side.
    How the code in arduino sketch, and what to set or how to call the second PCA pins in c/mri ?
    Make a youtube video for that. It would be great.
    Thanks

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +2

      I have just ordered another PCA9685. I'll try linking them this week and video my efforts.

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Check out th-cam.com/video/v1f_EDHV390/w-d-xo.html hope this helps :-)

    • @MiniatureWorld_01
      @MiniatureWorld_01 3 ปีที่แล้ว

      @@LittleWicketRailway
      I have found out how to do it by myself.
      But offcourse it will help others also. Just keep sharing great stuff.
      Thanks

  • @shushilkumar3664
    @shushilkumar3664 3 ปีที่แล้ว +1

    Hi Rob, I’ve just began my new adventure into model railways. I’ve been watching your videos and decided to go down the route of using Arduino. I’ve done everything that you’ve shown on the videos but unfortunately keep getting an error message. Any help would be much appreciated. Many thanks, Shushil

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Shushil, can you share the error message please?

    • @shushilkumar3664
      @shushilkumar3664 3 ปีที่แล้ว

      Hi Rob, could it be that I’m using minitrix point motors instead of the micro 9g servos?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +1

      @@shushilkumar3664 yes, I think so. Minitrix point motors look like they are electromagnet solenoid types. The servos are a completely different type of motor.

  • @Strifenkanen
    @Strifenkanen 3 ปีที่แล้ว +1

    Can you/do you use your Arduino to control the turn table?

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Yes, in theory, I think people have done this with stepper motors or servos, or basic motors with feedback systems. The key thing is getting a slow speed and being able to accurately line up the tracks. Ideally you'd like to just be able to select a track in JMRI and it would turn to that position and confirm that it was correctly lined up.
      My turntable was already motorised by Hornby and I've attached the motor to a digital decoder that I operate like it's a static locomotive. The gearing was already there to slow the rotation and they've fitted a mechanical system that's aligns the table with the exit tracks as it goes round, but it doesn't line up very well and it makes so much noise. You can't just tell it to go to a specific exit, you still need to watch it to see when it's at the exit you want, not ideal for automation. Although the mechanical system does allow a window of a few seconds between arriving at tracks and leaving again, so if the rotational speed was consistent then I could automate it using timing. Hornby have also dealt with the issue of changing track polarity as the track rotates 180.
      I did buy a lazy susan and was going to look into building my own turntable, but the Hornby one was ready to drop in and I ran out of time. Fancy a project?

    • @janeswift9961
      @janeswift9961 3 ปีที่แล้ว

      @@LittleWicketRailway Not cheap but there is a ready made solution www.dccinterface.com/ for Peco turntables. There are several videos on the subject th-cam.com/users/results?search_query=turntable+with+arduino

  • @did3d523
    @did3d523 2 ปีที่แล้ว

    how to link gyrompU6050+ PCA9685 on Same arduino nano

  • @gpakrockz
    @gpakrockz 3 ปีที่แล้ว +1

    Hi Rob Nice Video, can you please make a video for servos to be used with toggle switches please

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi! Do you mean with or without JMRI?

    • @gpakrockz
      @gpakrockz 3 ปีที่แล้ว

      Without JMRI Please

    • @rickparish75
      @rickparish75 3 ปีที่แล้ว +2

      I would like to add something to Gajantha’s request. Use toggle switches to run servos via the PCA board and also allow the same toggle switch to light LEDs for main and divergent track. Rob, you do a really nice job with your videos. I just found your channel last week and subscribed. Regards, Rick

  • @johncoleson8087
    @johncoleson8087 ปีที่แล้ว

    All worked well to the end of Part 1. Now I can't turn the servos off! every time I reconnect the power they just start whirring even if I shut down Arduino software. Even after PC reboot the next day they just start up again - HELP!

  • @martinwilkins9055
    @martinwilkins9055 3 ปีที่แล้ว +1

    Rob, ON uploading I get a long error message. I think that the important bit is probably
    Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
    Sketch uses 7100 bytes (2%) of program storage space. Maximum is 253952 bytes.
    Global variables use 434 bytes (5%) of dynamic memory, leaving 7758 bytes for local variables. Maximum is 8192 bytes.
    An error occurred while uploading the sketch
    avrdude: ser_open(): can't open device "\\.\COM4": The system cannot find the file specified.
    The above refers to a Mega and I am using a Uno and also refers to COM4 where I have my Mega Sensor installed. I have not come across a reference to a COM port in the video for this installation. Can you help please?
    Regards
    Martin Wilkins

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      Hi Martin,
      If you're using windows then it should have assigned a different COM port to each Ardunio board that you're using. You need to make sure that the correct board type and COM port are selected in the Arduino software before uploading.
      To check this in the Ardunio software and look at the Tools menu. There you can change the board that is being used from the drop down list and you can also check which ports have boards connected to them.
      It sounds like the software are defaulting to the board that you had connected before which was the Mega on COM5. You'll need to change the board to an Ardunio and you should see a different COM port available (COM5?) for the new Uno board.
      Let me know how you get on.

    • @martinwilkins9055
      @martinwilkins9055 3 ปีที่แล้ว +1

      @@LittleWicketRailway Yes thank you. As you suggested. It now works OK. Thanks

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว

      @@martinwilkins9055 Excellent!

  • @ianmayes8625
    @ianmayes8625 ปีที่แล้ว

    what dimensions is your layout?

  • @scottsmith7051
    @scottsmith7051 ปีที่แล้ว +1

    As of 10/2022 prices make this option prohibitively expensive unfortunately.

    • @LittleWicketRailway
      @LittleWicketRailway  ปีที่แล้ว +2

      Hi Scott, you can still control servos for a similar price to when I made the video. On Ebay Arduinos Unos are under £10, PCA9685s under £6.50 and servos for ~£1.50 (if buying a pack) - works out at just over £2.50 for 16 servos. You might have to wait for it to be shipped from China though. If you want to gamble on AliExpress then prices are a lot cheaper. A commercial slow action point motor (admittedly with switches built in) will cost ~£20

  • @AlecDenholm
    @AlecDenholm 3 ปีที่แล้ว +1

    Eleven pound fifty for a 5v power supply?! Use a phone charger instead for a fraction of the cost. The arduino can be powered by USB, or if you're powering the other board, you can just cut the end off a USB cable; the red and black wires inside are 5v and ground (ignore the other two, they're for data and don't carry power). Shove those in your board's terminals and you're cooking on gas, or steam depending on your modelled era.

    • @LittleWicketRailway
      @LittleWicketRailway  3 ปีที่แล้ว +1

      Hi Alec, apologies, my orginal response related to the DCC++ base station. You're right, any power supply that can reliable provide 5V DC with sufficient current for servos is fine. The power supply in the video is good because it's got variable voltage and neat connectors should you want to use it for other projects.

  • @carlploszanski4265
    @carlploszanski4265 3 หลายเดือนก่อน +1

    Hi. Decided to take the plunge and go down this road, have got all the kit you reccommend for driving servo's
    because of the way i am having to build my layout i will need to install some motors before i can run a train
    so the question is will i be able to upgrade this set up to DCC to controll the trains later without having to re-program the morors?

    • @LittleWicketRailway
      @LittleWicketRailway  3 หลายเดือนก่อน

      You should be able to convert your layout to DCC with no problem and still use these servos controlled via CMRI.

  • @davidgorman2665
    @davidgorman2665 ปีที่แล้ว

    :( none of my servos moved

  • @carlploszanski4265
    @carlploszanski4265 4 หลายเดือนก่อน +1

    I am a real thicko when it comes to setting up computor programs and just know i will make a hash of it so my question is can these mini servos be controlled without a computor?

    • @LittleWicketRailway
      @LittleWicketRailway  3 หลายเดือนก่อน

      These servos need a servo controller of some type. There are products on the market that will allow you to set them up for switch operation (example megapointscontrollers.co.uk/product/servo-controller-12/?v=79cba1185463). Or you can use an Arduino to control them when a button is pushed, but that still involves some programming.