Arduino Switch Control! Installing the Kato Multi Switch Control Project on a Model Railroad!

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

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

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

    Check out SRA Soldering Products FREE guide on soldering! blog.sra-solder.com/how-to-solder-electronics-guide

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

    It's great seeing MRROne not being built and then set aside and getting upgrades as you complete other projects. It shows how your layout can continue to grow.

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

    Great new sponsor, Jimmy!
    Having good soldering tools makes a huge difference in the quality of your joints and makes it easier too. A lot of people get turned off of doing soldering because they tried it using a cheap iron and had poor results. Spend a little more on a decent iron folks, and you will have better success.

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

    Love the sketch, Changed over to this from your original Sketch from 2 years ago that had LEDs. Used it on a ATTiny85. Just the right number of pins. This Sketch works great with 4 Turnouts and adding the Leds back in, Just the right number of pins for Arduino/Nano/Pro Mini. I also added a switchstate to init the turnouts to closed on power up . One oh by the way , if you prototype this and use less turnouts than the sketch defines, make sure you tie the unused push button pins to ground with a 1 k resister.

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

    Thanks for another fantastic video Jimmy! Loved seeing how to mount it to the layout.

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

    Thank you for all the info. And, btw, check the 3-turnout sketch - the google doc one linked here. A possible typo - I think that last block (switchturn3) should be a "HIGH" for that last "powers on turnout". :)

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

    Jimmy, the number of code changes you need to make just to add a third turnout illustrates the value of user-defined classes. I can't imagine how your code would look if you added three more turnouts. (I suspect that a Nano would control up to 6 turnouts easily.) By using classes, your main program would look like this:
    TURNOUT turn1 = TURNOUT(A0, 2, 3, STRAIGHT);
    TURNOUT turn2 = TURNOUT(A1, 4, 5, STRAIGHT);
    TURNOUT turn3 = TURNOUT(A2, 6, 7, DIVERGING);
    void setup() {
    }
    void loop () {
    turn1.refresh();
    turn2.refresh();
    turn3.refresh();
    }
    Adding more turnouts requires adding TWO lines of codes for each turnout: the declaration (TURNOUT turnx = TURNOUT(etc.)) and the refresh() call (turnx.refresh()).
    All the hard work is done in the class definition contained in TURNOUT.h: the constructor (TURNOUT(i,j,k,m) ) links the turnout to the analog pin for the button (i) and the digital pins for the motor driver (j and k), and sets the initial state (m) of the turnout. The definitions of the STRAIGHT and DIVERGING constants are contained in the TURNOUT.h file. The refresh() method checks to see if a button has been pressed - if so, it moves the turnout and changes the turnout state.

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

      How do you set green/red LEDs using this approach?

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

      @@RichardFrenchRacing The long answer is truly long; but the short answer is this: In addition to a TURNOUT object, you'd have one or more SIGNAL objects. In the case of Jimmy's crossover, he has one TURNOUT (which can be straight or diverging) and four SIGNALs. Let's assume that when the turnout is straight, signals 1 and 3 display green over red, and signals 2 and 4 display red over green. When the turnout is diverging, the opposite applies. Now you have, for example, the following code:
      // Set straight
      turn1.set(STRAIGHT);
      sig1.setAspect(GREEN_OVER_RED);
      sig3.setAspect(GREEN_OVER_RED);
      sig2.setAspect(RED_OVER_GREEN);
      sig4.setAspect(RED_OVER_GREEN);
      Code within the SIGNAL class (specifically, the setAspect method) manages the LEDs, turning them on or off in accordance with the specified aspect. The SIGNAL class provides a constructor which specifies which pins the LEDs are connected to, and whether the LEDs are common anode or common cathode, so the setAspect method knows which pins to set HIGH and which pins to set LOW in order to display the desired aspect.
      Hope this answers your question!

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

      I get 2 compile errors when I tried this approach.
      1. Compilation error: 'TURNOUT' does not name a type; did you mean 'TURNOUTS_H'?
      It doesn't like the turn1.refresh() command - 'turn1' was not declared in this scope
      turn1.refresh();
      Here is my code - I'm trying it with just 1 turnout at the moment
      #include "turnout.h"
      TURNOUT turn1 = TURNOUT(A0, 2, 3, STRAIGHT);
      //TURNOUT turn2 = TURNOUT(A1, 4, 5, STRAIGHT);
      //TURNOUT turn3 = TURNOUT(A2, 6, 7, DIVERGING);
      void setup() {
      }
      void loop() {
      turn1.refresh();
      // turn2.refresh();
      // turn3.refresh();
      }

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

      @@rwissbaum9849 Thank you. I'll look into this next

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

    I sure wish there was a phone app to run switches for these in addition to what kato has for bluetooth throttle. Kato can run sound, whichbus nice if you have dcc to run that, but the ability to control turn outs etc would be much more practical for model railroaders. If kato did that, while practical, it would prob be priced way out of range for most users given the prive for their sound conttoller.
    Thanks for these explanations though. Very helpful to a newb.

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

    Jimmy, I love the how to videos, but a I am looking for more simplicity. Some people aren't as savvy with electronics, soldering and controls and are looking for plug and play type devices. Love watching you build stuff.

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

    Thanks for another awesome video

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

    I stopped using the resistors by writing on the code for all push buttons example. pinMode( switch3pin2, OUTPUT_PULLUP);

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

    Whoa, thats pretty involved. Great tutorial, but wow. I'm going for kinda the old school push button panel. There's probably no way I could code the arduino

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

    adding signals as well would be good

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

    Hi Jimmy, don't know if you see comments on old videos or not but I wasn't sure how to contact you. Anyway, THANKS so much for this video as it was a great starting point for me. However, being a somewhat old programmer (started in, well, about 1969), my first thought after getting the code to work (which was easy) was to change it so that it would work for way more turnouts. I didn't want to keep duplicating the code for each additional turnout so I'm in the process of using arrays so that all I need to do is change the single constant that defines the number of turnouts and it all works. But, as I'm going through the code I started thinking about how I might be able to make the changes so this would work with a Nano but being able to control up to say a dozen turnouts. Obviously the Nano doesn't have enough pins so:
    1) I should be able to use digital pins to determine button pushes.
    2) I'm wondering if I can use a PCA9685 to control the turnouts directly seeing as there is only a 1/2 second pulse of 12V+ on one pin or the other to the Turnout. This is my biggest question.
    Now, my "real" application involves up to about 10 Turnouts for a Fiddle Yard and I need to code in routes so that the person running trains can pick a track with a push button and that will turn all required Turnouts to the required position and light up an LED. In this application there is no "flipping" of Turnouts, just aligning multiple turnouts to a route.
    My final question is whether you are interested in the code I create and if so how would I get it to you.
    Thanks and keep up the great work.

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

    I know it’s a bit late haha but great vid man!

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

    Can you control these switches in engine driver?

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

    Could we use lever switch (1 or 0) rather than momentary push button? The lever could show the position of the turnout....

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

    Im struggling to see the advantage of this method over finding the right DPDT toggles. Adding a Nano and motor drivers just to avoid a little extra soldering? Or an I missing something?

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

    Humm Jimmy live your ardunio vids I'm not even close yet left me trying to figure out..now which end goes in the cement. .lol

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

    good vid keep posting update wot your doing on the railroad

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

    Not personally a fan of Jim, but mad credit for the consistent uploads in advanced technology in model railroading!

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

    I recommend powering any microcontroller separately. This leaves out the chance of any power backfeed through the system which could potentially harm the microcontroller and any/all other electronics. These mass produced clones do not have great quality control. Just a tip I've learned over the years.

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

    Soldering looked ugly at the beginning, you can have the most expensive kit but if you don't know what your doing its a waste of money!!!

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

    too advanced