Model Train Turnout Control using Arduino and PCA9685

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ต.ค. 2024

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

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

    thank you. as someone that has never done this, that brief explanation was great.

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

    Thanks for a great piece of elegant code which works beautifully.
    I had previously had a working breadboard working using Toms Trains code and diagram on an UNO as per the wiring diagram. When substituting the UNO with the Mega and wiring as per your wiring diagram link (same as Toms Trains), the servos would not run because I had kept the SDA and SCL comms wires on the Analogue IP's A4 and A5 as per the wiring diagram of the UNO. Sorted it by wiring to the dedicated SDA and SCL pins on the Mega which I was originally unaware of. Might help a few others from a bit of head scratching who are newbies like me!

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

      Appreciate your input!

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

    an excellent video with clear explanations and what I've been searching for. but, like Graham Metcalf, I really don't need the LED outputs although they make this very realistic. as a newcomer to Arduino, I have little experience in programming so am hoping Mr Metcalf might be forthcoming with a little guidance on the subject. keep up the good work.

  • @JohnHill-qo3hb
    @JohnHill-qo3hb 2 ปีที่แล้ว

    Thanks so very much, just what I was looking for... SUBED

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

    Hello, Do you have a diagram to show how to connect more than two servos? Can this system allow up to 16 servos for 16 points on the PCA9685? Also, what toggle switches are you using--for example: spdt (for motor and leds)? or spst? thank you.

  • @SuperSpuddo
    @SuperSpuddo 15 วันที่ผ่านมา

    What alterations do I need to make to the code if I don't want the LEDs?

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

    Great video. I followed your instructions and have 2 turnouts working almost as I want them to.
    My question to you is, in your video, you say you are using toggle switches but your diagram has push buttons. How would I wire it up to use toggle switches?

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

      Never mind, I figured it out on my own. Still, a great video. I will be using all 16 pads of the 9685 once I get the rest of my servos.

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

    Hi there, I have started wiring my layout with servos controlled by a MEGA board and PCA9685s (probably need 3) and using your excellent sketch. I didn't feel the need to have LEDs as the switches themselves indicate the throw direction, as in a real signal box. I'm having a few issues with random twitches on some servos and wondered if there is a solution to this, or is it just that some of my servos need replacing? I am using standard SG90 servos.

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

      Good to hear. I've experienced that as well. Unfortunately I think some of those cheap servos do have twitching issue. I'd suggest to change out that servos to see if it improves. If not the issue maybe elsewhere such as loose connection

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

      @@SATODEN Many thanks for the quick reply. I will try to get some better servos. Another question please, is there any way of turning off power to the servos without having them all twitch when I turn it back on?

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

      @@oleyorkie I thought about that too. One way I thought of doing is to sandwich capacitor between PCA 9685 and the power source. But then I found out that pca9695 does have a built in capacitor. Maybe there are better way of doing this but I don’t have an answer for you.

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

      ​@@SATODEN I think I have found a solution. I connected the OE pin to +5V via a 10k resistor, using a toggle switch. That kills the output and stops the servos chattering. I am about to try connecting a second PCA 9685. I have modified the sketch to include PWM2 and hope I can just continue adding servo channels. Thanks again for your help.

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

    What am i missing, looking at the diagrams you show only 2 servos per Uno, how are you wiring in the other servos and switches

  • @kennethd.bryant9279
    @kennethd.bryant9279 2 ปีที่แล้ว

    you're right about the power coming from the Arduino.. only 40 mv total but there is a power board for about $5 us that takes an old PC Power Supply and gives you all the voltages and power you need to run the servos through the PCA6985. and the power supplies are cheap also (ATX units).

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

      Just to be clear, power from arduino would not run servos. Pca requires external power supply in order to run servos

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

    thanks for this , I am looking to run two PCA9865's on this with 4 to 5 servos on each , what do I need to change in the code to get the second PCA9865 working ?

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

      I think the numbers of pins available on Mega you will be limited to one PCA board per mega. I think you’ll need to run a second mega to run second pca board purely from pins available on Mega

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

    I would love to use is code, to control my turnouts, but I have them set up with momentary switches, I have no idea how to modify your code to allow these switches to be used, instead of toggle switches. Can you help.

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

      Unfortunately this code would not work with momentary switches or at least I can't think of the way it would. my suggestion is to use this same code and test it out with your momentary switch using a breadbord

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

    Hey awesome job you made there, one question is it possible to connect this arduino thingy (with switches and pca9685) and signals, for example on a switch i got 2 signals and when i do the thingy and send my train left that signal goes green, Hope you understood what i asked (bad english sorry)...

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

      That's totally possible using a simple micro switch. I too control simple red and green light using the existing servo motor. I have a video for changing light with micro switch so check it out.

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

      @@SATODEN ty

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

    Thanks for this video and the schematic, especially with Tom's site being gone. I've made my own version of this but am having some weird issues that may be due to me misunderstanding the 2nd page of your diagram. In the 2nd page, did you take the + and - power for the switches and LEDs from the 5v power going to the PCA9685, or from the arduino as in the first page? I built my system taking the 5v from the arduino as in the first page, the 5v wall wart is going to the PCA9685 only. What is happening for me is all my lights work correctly, but when I attach my first servo it goes crazy and wants to continually spin in one direction. I now have a broken and not useable but still test worthy servo that I'll use until I suss this issue out. The only change I made in the code was changing the number of servos to 15, added the 2 lines of code and changed pins numbers and angles (60 and 120 are my starting points). This difference is the only thing I can come up with as my issue, even though it all worked on the breadboard. I can make a video if that will help. Thanks again for this video, schematic and code. Billion thanks if you help me fix whatever I've messed up. If not, still thanks. ;-)

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

      Thats strange. I have two different power sources. One is Arduino itself 5v. The other is for PCA9685. PCA9685 VCC connection uses 5v from Arduino. So, LED, Switch, PCA9685 all uses power from 5v pin. Servo is a different story. The fact that you have your servo moving made me think that your circuit is fine. Because PCA9685 will not be able to move servo from Arduino power alone. So that rules out the circuit issue. What I would suggest is 1. use the original code (Unedited) 2. use the same servo with a different pin. Try to eliminate possible issue one section at a time. Let me know.

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

      Second thought, PCA9685 needs to be powered by both 5v via VCC and the external power source. So branch out the power from arduino to PCA9685 and see what happens.

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

      After thinking about it a bit I just went ahead and tried the power hub you mention on pg. 2. Same result. Any ideas?

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

      @@WisenheimerYZTV Did you download PCA9685 driver?

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

      @@SATODEN Yes, I have the driver. It all worked on the breadboard with your original code. I've reconnected to how I originally had power run and reupload your original code. Works great, so I probably justr messed up the code somehow. I also found that the angle numbers are way different. In the servo test and set codes I used to check my servos, the angles are 0 - 180. Not so in your code, where my angle of 60 is what killed the test servo. 280 - 500 seem to be the angles I need. Hmm... I am missing something important somewhere. My biggest issue... my brain. Thanks for helping me suss this out. Not sure what exactly I did, but if I have to bust out a nano to get my last 2 servos going so be it. I'd rather not... any ideas? Did I add the 2 lines of code wrong, I wonder? Probably. Most likely. Educated guess - yes, yes I messed it up. lol I hope to get this all running so I can confuse myself more by adding nrf24l01 communication. I will surely mess that up. In the meantime.... is copying and pasting 2 lines of code the wrong thing to do? Cuz that's what I did. I thought I did, anyways. Comparing side by side... scratching head. lol

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

    i do have one question. when you activate the toggle, it is always open or always closed, not momentary?

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

      Hey Mike, if you get two prong toggle it will always be either closed or open. If you get three prong I assume a turnout will still be closed or open but your toggle switch will have the neutral position. I would recommend using 2 prong

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

      @@SATODEN I was asking because I already have a few SPST momentary switches from another project. I will have to get some always open or always closed SPST toggles to try this out.

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

    Thank you for awesome video. As Tom's website is not working anymore I couldn't find any information about how to wire toggle switches and LED's. Your diagram helped a lot. If you don't mind can you show how actually you made and organized your control panel, please? There is a lot of information of how to control it though JMRI but I actually want to make it just like you using toggle switches and LED's and can't find anything about it. Thank you again

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

      Anatolii, Thank you for your comment. Wow I did not know that the website is gone. I wonder what happened. Let me see what I can do. I will get back to you.

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

      @@SATODEN So I checked again and it looks like your video is basically the only source of information about how to wire control panel with LED's and toggle switches. All other sources do not use 9685 board or use JMRI as a control software. So thank you again for your help. Really appreciate it.

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

      @@anatoliidudko7029 Sorry, I didnt forget about this. I will def put something together for you this week.

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

      @@SATODEN Take your time. You already heled me a lot. At least I know that it's something that I can make myself. You made a short but highly informative video.

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

      @@SATODEN Sorry to bother you again, but can you please make an update about your control panel wiring? Thank you