Controlling Multiple Kato Switches with a Single Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 พ.ค. 2024
  • Welcome back everybody! Be sure to subscribe! Today we are doing an update to an arduino model railroad sketch that I did quite some time ago. We are showing how to control more than one Kato turnout with a single arduino. This sketch is easily expandable so that you can control several turnouts with one arduino! It’s a lot of fun and fairly simple for an arduino sketch.
    SRA Soldering Model Railroad Kit Preorder
    sra-solder.com/model-railroad...
    SRA Solder Lab (TH-cam channel)
    / srasolderlab
    Schematic
    photos.app.goo.gl/rfvQST1S2mk...
    Arduino Sketch (UPDATED 1/31/2021
    drive.google.com/file/d/1038d...
    Original Tutorial
    amzn.to/3sQDyvT
    Timestamps
    00:00 Intro
    00:42 Build
    05:24 Coding
    28:35 Testing
    29:16 Conclusion
    Tamiya Connectors
    amzn.to/3sQDyvT
    Arduino UNO
    amzn.to/3qLHQCW
    L298N Motor Driver
    amzn.to/3sSimWq
    Buttons
    amzn.to/3t3cYQq
    Resistors
    amzn.to/3a2MUvN
    Breadboard
    amzn.to/39dCuu6
    Wires
    amzn.to/3cc4IYb
    12V Power supply
    amzn.to/3qKnVnZ
    Follow us on Facebook
    / diyanddigitalrr
    You can support the channel by becoming a Patron on Patreon for as little at $1 a month!
    / diyanddigitalrr
    Check out my Etsy Store!
    www.etsy.com/shop/DIYandDigit...
    I do a lot of 3D printing
    Printers Used
    Elegoo Mars
    amzn.to/386NZSa
    Anycubic Mega Zero
    amzn.to/3mHfdpi
    Samaritan’s Purse
    www.samaritanspurse.org/
    Camera Used
    amzn.to/2X87yWR
    “The godly may trip seven times, but they will get up again.
    But one disaster is enough to overthrow the wicked.
    Don’t rejoice when your enemies fall;
    don’t be happy when they stumble.
    For the Lord will be displeased with you
    and will turn his anger away from them.
    Don’t fret because of evildoers;
    don’t envy the wicked.”
    Proverbs 24: 16-19 NLT
  • แนวปฏิบัติและการใช้ชีวิต

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

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

    I would recommend you to check out the Adafruit Motor Shield, since it used I2C to communicate with the Arduino microcontroller, you can stack multiple shields on the top of an Arduino microcontroller board. Using these shields, we can actually drive up to 128 turnouts from a single Arduino microcontroller!

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

    Champion‼️ Looking forward to the next chapter.

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

    Awesome! Just what I’ve been waiting for - thanks Jimmy!

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

    Love this tutorial, Jimmy. I'm working on a similar project myself. 👍🏼

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

    Another great tutorial, Jimmy!

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

    This is cool stuff. One day I will try doing some arduino stuff to do some layout automation. Lots of fun applications.

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

    Hi Jimmy,
    I've been thinking about more Arduinos a lot lately. And when I watched the intricacy of this project my thought went to your patrons.
    To start due to a negative situation I had with Patreon I don't, nor won't, use their crowd funding service.
    But for those who do you Arduino scripts, enhanced with closeup stills of you explanation, could be an incentive to others to join.
    My hugs and kisses to my DIY Babies.
    Jim

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

    Hi Jimmy, another fantastic video, as usual. I have watched this video series at least a dozen times trying ta understand the coding and I think I've finally got it! I was just wondering if you knew how many L298N's could be connected to an Arduino Mega? Alan

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

    I haven't watched the whole video yet, but the hardware setup looks interesting. I've done some arduino controlled Kato turnouts using the 'voltage sneak' trick where a Kato two wire bi-polar is essentially powered as if it is a typical twin coil turnout. The motor driver idea seems superior. I'm going to try to rewire a couple of projects before the next show. Thanks
    Edit: I finally got around to playing with this. I tried converting a module with a pair of turnouts to this from my original transistor and resistor "sneak path" version. It literally dropped right in. I did not have to change a single line in my arduino sketch controlling it. Now I need to go out and buy some more H-bridges to convert (and build some more) modules.
    Oh, and the delay was due to the fact that my yard which used my old circuit, wasn't used in the show. So procrastination.

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

    Hi Jimmy, nice video, just one thing. Doesn't the PWM from Arduino go to enA and enB on the L289 and in1,2,3,4 used to change direction? Thanks.

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

    Love your videos. Can I do this on my arduino running dcc ++ and somehow control through jmri?

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

    I have a crazy idea. Using Arduino mega for CTC like interlock with signals. Using double throw switches to set track and an execute button. The funny thing is that I can’t figure out the coding for it. I am working on a layout, which is on hold for the time being, that has a double track mainline with 3 branches that meet at the interlock. Two of the branches is an oval with a stage yard. And the third is a branch that I have not figure out what I am doing with it yet.

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

    Love the work you do in your videos. Question: cross over wirei

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

      Sorry, hit wrong button, cross over wiring when you throw both switches at same time??

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

    I love your tutorials Jimmy. I am starting with arduino in my layout and there are lines that I still do not understand. Would it be possible to put 2 LEDs that indicate if the point is straight or turned on a control panel? Thanks

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

      Yes, you can add LEDs on the 5V line with a 1k Ohm resistor. Put the positive (long) leg to +5V, then the resistor in series, connect the negative leg to either an analog or digital pin. Put in simple code to select green or red LED from the code groups that change the switch positions. It takes two lines per switch change.

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

      @@marieparsey53 Can you send the code for adding the leds, I have a project that is switching four kato switches and am building a control panel with less to show direction of switches.

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

    Hi Jimmy, How did you determine where to place buttons, wires, etc. on the board? The computer imput you’re doing is going to Daughter and Granddaughter. I haven’t a clue. I do manual they do brain. Thanks, Bill

  • @wells071
    @wells071 21 วันที่ผ่านมา

    Will this work with cobalt switch machines?

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

    Love these Jimmy, !!

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

    Love this project, as I am planning something like this for my next layout. I had yet to decide on using a Digitrax stationary decoder DS64 which would give me control from push buttons or my throttle. I doubt I would use the throttle much, so this saves me a couple devices.
    I have to ask though… wouldn’t this work with a relay module as well? It seems a waste of a L298 when a DPDT relay could handle the job as well. Keep the L298 for controlling something that needs variable voltages.

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

      So with standard snap switches yes. Katos are wired differently. They reverse the polarity using only 2 wires, which takes some more wiring with a relay vs the L298N

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

      @@DIYDigitalRailroad ok got it… I was thinking using the relay cross wired but then it would require a “center off” type relay and I don’t really see any of those on ready made shields. And with the cost of making said shield, I am out the cost of a few L298s. So yes motor drivers it is.

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

      Yes, relays would work as would switches. This is meant to be a building block for future automation and lighting projects.

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

    Just watched your clip. I'm not a programmer so, would it be possible to print off(PDF) the programming? Also, will this work with DCC? Can Red and Green LED's be triggered to light up on a control board when the buttons are pushed?

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

      Hello I have written code to do this. Let me know if you are interested. John

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

    Just out of curiosity (I don't use Uni-Track turnouts), does Kato use a solenoid or another type of motor? Thanks, Jimmy.

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

      It is a solenoid in the KATO turnouts.

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

      @@RoyEltham Thanks for the info Roy.

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

    I am still kind of new at this.I see in this video you are using the Motor board. Would that have worked with a 4-relay board? Maybe it is because of the Kato turnouts? I am using Atlas snap switches.

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

      Good question. Relays are what you would use for snap switches. The wiring is different though.

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

    I know this is a old video, a comment from Tech Build below brought up a question about current tech capabilities. Are there stackable shields which allow for the Arduino Uno to control more turnouts? I have 13 turnouts to control in a 6ft by 6ft layout, and it would really be nice to control from a single Arduino.

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

      BTW: In my "use-case" I am using Rail Crew 2 wire switch machines.

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

      So an arduino uno does not have enough I/O pins for 13 turnouts as each turnout would need 2 pins, but an arduino mega does. So just use a mega and you should be good to go.

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

      @@DIYDigitalRailroad Thank you for the quick reply. Dont I still need the motor driver (I am guessing called motorshield)? Do you know of any stackable shields for my use case? Would be really cool to see a video on this topic.

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

    Can this be done digitally with PCA9685? Additionally, I’d like to group adjacent turnouts together…

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

      Hi I believe "Yes". There is an instructional video (which of course, I bookmarked, but cannot find it...) on the use of the PCA9685. The guy commented that you can control up to 128 switches. Search for PCA9685 uses in model railroad or something like this. I just bought one, but have not yet started coding for it.

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

    Can this be used with Circuitron Tortoise Switch Machine?

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

      Yes. Just change the off delay (500 in the sketch) to a time the tortoise takes to fully travel (should be somewhere around 2500).

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

    Three wire turnouts?

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

    Hi Nice video! So, my question is- when I try to verify the code I get an error message at the switchoff () line. "switchoff was not declared in this scope." I changed a couple of the buttonread variable names but they have the same function as your program and are correctly defined. I spent hours tracing and checking the Arduino board
    case STOFF:
    switchoff(buttonread1, buttonread2);
    break;
    Help!?

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

      Figured out the problem- i had one character in error... oh well. I re-coded to handle 2 8-relay boards to control 7 switches using a MEGA2560. Now to add LED controls for switch state indication. Thanks for the video!!!

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

      Also, I rewired to use switch to ground logic.

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

    great, would love to see how to do this with jmri/cmri rather than buttons

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

      I honestly thought that's what this would be about when i clicked on it. Looking forward to seeing a video on that hopefully.

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

    How to add red & green led dwarf signal

  • @JoeG-firehousewhiskey
    @JoeG-firehousewhiskey 3 ปีที่แล้ว

    Thanks for the video. Is it possible to use DPDT switches instead of buttons?

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

      Yes it is possible. Just need to figure out how to hook them up.

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

      center pin is one connector, then one of the sides is the other. Acts as a Single pole single throw switch, like a push button spst. If you are doing 2 switches at same time, then each input to middle pins (1 per controller) then one side pins to each kato switch.

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

      It is possible. You only need 1 DPDT switch per turnout (with center off). The caveat is that you have to move the switch back to center very quickly to prevent burning out the coil.

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

    What if I want to remote my switches with no physical switch?

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

      This would probably require installing something like a tortoise switch motor or another servo type motor and programming the arduino to use it. I have not tackled this yet.

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

      Thanks for the info as I would like to be able to control my new layout switches using just some type of interface without a physical button. Such as using a wifi throttle.

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

      Use the i2c interface to control from a remote location.

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

    Ummm .. I think the best way to do it is using a multiplexer for arduino using just one digital output and a relay module. In your way you need multiple motor drivers (each two points) and also two digital outputs for each point. Anyway... thanks for your tutorial !

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

      I actually didn’t know what a multiplexer was until now! Now I must research. I am not a coder or electrician so I learn when people suggest new things! Thank you! Now I’m off to research!

  • @BK-oo1bl
    @BK-oo1bl 2 ปีที่แล้ว

    How many Kato turnouts can one arduino run?

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

      It depends on the configuration. A UNO-R3 by itself can handle 2 I think. A MEGA can handle up to8. NOTE- you will need a driver shield to power the KATO or ATLAS switches, or use a relay board and external 5V supply for the trigger switches and relays with a 18-24V power supply for the switch coils and external 9-16V supply for the Arduino. If you use the PCA9685 boards, I think you can go to 128 switches (check some of the videos on use of the PCA9685).

    • @BK-oo1bl
      @BK-oo1bl 2 ปีที่แล้ว

      @@marieparsey53 thanks

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

    I see a New Zealand car number plate on the wall!!!!

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

      Spent some time there! South Island mainly, but ventured up to Wellington. Loved every minute!

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

    Man is there an easy way to control kato turnouts using just the DCC EX system instead of using push buttons? I'm trying to figure a way to just control switches using a phone app

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

      that is a good question - also came up in my mind. If we are using the automation DCC-EX is offering: will this be support through this arduino?

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

    Cannot download the sketch. Just circles on Google. Bummer.

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

      So, I created a sketch in the flavor of Jimmy's approach to control 8 relays (4 Atlas-type switches.) I also added Green/Red LED indicators to show the switch states. I left the code in simple format so it is clear what each section does. It can be significantly condensed, but with a Arduino MEGA or similar, it does not matter. I think it will run on a Leonardo, but I cannot test it. It is too much for a UNO or similar- needs too many pins. I used the common 8 relay boards that you can get on ebay.
      The program can be altered for use with less than 8 relays by commenting out the appropriate lines. I did find that using digitalRead for the switches caused me a lot of headache even with debounce code helping. Had to rewrite several times, with lots of traces and state comments to sort out the issues. I do have a ton of wiring under the table, and live a mile from 20 100kW transmission towers so I probably pick up a lot of stray noise (did not check on an oscilloscope). Not sure why, but using digitalRead led to unresponsive or really exciting glittering LED random responses. The Arduino board contributors told me that the only way to go was digitalRead.... oh well. I also found that using the switch-case, approach the switchoff (default) case loses track of variable values after the second looping waiting for a button push (like 99.9999% of the time). Kind of weird. I expected the values to be retained as I experienced in C/C++ coding. Must be a quirk in the Arduinos. So, I put in some "brute force" coding to retain the LED states so the correct switch state is displayed.
      The trigger buttons are configured to operate +5V on top of the switch, a 1kOhm resistor to ground, with the switch signal taken at the top of the resistor. This is "ON equals digital LOW" configuration. The code is completely open-source without any calls to outside resources.

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

      @@marieparsey53 I'm trying to control 11 atlas snap switches with LED indicators from an Arduino Mega. Sounds like the sketch you created would work for me. Could I get a copy of your sketch to try out.

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

      @@donsopotiuck133 Hi thanks for the note. I have the code written to control two 8 relay boards. This controls 8 switches, and 16 LEDs as configured. I wrote it to be easy to troubleshoot, rather than super tight code. I think there are enough pins to expand to 11 switches on the 2560. You can copy the code sections and add/change pins and numbers as needed. I do not use pin 13 to prevent any internal upsets with the internal LED drive signals. I have a subset of this code that runs 3 different 4 relay boards in different places on my layout, as well. Let me know how to contact you.

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

      Hi again, Don
      If you are going to drive 11 LEDs (i.e., 22 if you have red/green) then use 2.2kOhm resistors in series with the LEDs. Otherwise you will be stressing the 5V regulator on the MEGA.

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

    Awesome video. I'll forgive you for creating global variables. At least notate them with 'g_'. as in "g_State1", or don't use globals at all.

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

    Very informative
    Yeah Jim is pretty smart and all but still talks to much! very annoying,