Arduino DIY DC Model Train Controller

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ค. 2024
  • Welcome Everybody! Be sure to Subscribe!
    We've built a DCC++ Base Station, now we're taking a look at how to build a DC Model Railroad controller with an Arduino!
    Schematic
    photos.app.goo.gl/yfQ1kkTEtEk...
    Parts Used in Tutorial
    Arduino UNO
    amzn.to/2t20j2f
    Arduino L298P Motorshield
    amzn.to/2t6Cbve
    Rotary Potentiometer
    amzn.to/2t3NGny
    Bread Board and prototyping wires
    amzn.to/2t1V4zs
    Single Pole toggle switch
    amzn.to/2G84Mcq
    Power supply
    amzn.to/2D6khO1
    Support the channel with some Merchandise!
    teespring.com/shop/diy-digita...
    Email: diyanddigitalrr@gmail.com
    Arduino Sketch
    (If the sketch does not work quite right, try copying it into a basic text editor like notepad, the copy it from there into the IDE)
    docs.google.com/document/d/1_...
  • แนวปฏิบัติและการใช้ชีวิต

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

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

    Very complete intro to building a model train controller... or variable speed motor control. Perfect to add to a model railroad layout. The controls can be mounted on the layout surface ,or side of the track layout substructure, for a lot smaller footprint than the usual model railroad train controllers! Just a switch and potentiometer knob, with the rest hidden below deck.

  • @hirushanilupul6088
    @hirushanilupul6088 4 ปีที่แล้ว

    Thank you for the video, the dc conroller is working well for N scale

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

    Thank you so much this is exactly what I have been looking for can’t wait to see what else you can do with this setup

  • @caveratward6218
    @caveratward6218 5 ปีที่แล้ว

    Fantastic video. Going to have a go at this. Liked and subscribed.

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

    Great Video, Learned so much in so little time. Thanks so much for spending your time making this. new Sub here.

  • @jean-claudegolovine5725
    @jean-claudegolovine5725 4 ปีที่แล้ว +1

    Thank you for this nice tutorial. I think the second "if" loop should be taken out just keep else. What happen if for some reason the value is 500!. Thank you again.

  • @angelcastillo-hw1mm
    @angelcastillo-hw1mm 3 ปีที่แล้ว

    Awsome Jimmy!! Thank you for this work! I´m working in Arduino and this will help me to Upgrade my plan! Saludos desde Argentina!! (New Sub here! XD )

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

    Thanks for the enlightening demo. Would there be additional considerations or changes to handle an analog DC HO system? In other words, can the motorshield handle the current/power for an HO loco?

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

    Great tutorial Jimmy. I'm a newbie in modelling trains though have a DC layout running. Lately I'm lured into learning Arduino. Truth is I have all the components needed to run your tutorial but don't know how to sketch yet. Is it ethical enough to ask for a copy of your sketch so I can start hands on tweaking the Arduino. Thank you so much. Rolly

  • @w.rustylane5650
    @w.rustylane5650 4 ปีที่แล้ว +1

    Wow, I didn't think an Arduino could be used as a DC throttle. I just may have to pursue this. I've got an 18 volt 3 1/2 amp computer supply that I want to use as a DC power pack. I've already gotten a PWM voltage control; just need to get a fuse inline with the DC power supply in case of a short circuit and a single pole single throw switch for controlling the direction.

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

    cool stuff... now for a touch-screen display.. thanks..😊

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

    Thanks Jimmy, Do the loco have a dc motor inside it? if so, where can we get a loco like the one shown in the video?

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

    Awesome how to!

  • @BrandonBascom
    @BrandonBascom 4 ปีที่แล้ว

    Can you use the same motor shield that we cut the vpi connect in from your other video?

  • @ejejeff1722
    @ejejeff1722 5 ปีที่แล้ว

    Thanks Jimmy! This will be perfect for adding my DC "museum" to my DCC layout

  • @redwoodcityintheuknscalera7179
    @redwoodcityintheuknscalera7179 5 ปีที่แล้ว

    this is great nice job Jimmy

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

      South Coast UK N Gauge train modeller Thank you!

  • @maddiek9
    @maddiek9 4 ปีที่แล้ว

    This is great. Could you expand on this by including Bluetooth? This would let me operate a train with an onboard (12vdc battery). Thanks

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

    Another great video, Jimmy. BTW, are there any jumpers to be cut on the motor shield as there are for the DCC++?

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

      Thank you! You do not need any jumpers like on a DCC++ system.

  • @markjohnson9136
    @markjohnson9136 5 ปีที่แล้ว

    Very cool

  • @Rafe0921
    @Rafe0921 4 ปีที่แล้ว

    If you have a 3D printer you could make a small controller box, you can also use wood, what ever the user feels is best.

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

    hello sir, can the arduino wiring be used with the sound of the engine and train horn, such as dcc sound

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

    great video you seem to be a pro at the arduino setups do you know if its possible to hook a sound crossing bell to your other video on crossing signals thanks

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

      My bad! I totally meant to reply to you! Yes it is possible! arduinos can be rigged to play sounds.

    • @seanpepple6110
      @seanpepple6110 5 ปีที่แล้ว

      awesome man could you email me so i can show you what i want to do i used your method with the flasher set up love it hers my email thanks sir seanpep11@gmail.com

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

    Is it possible to have the switch and potentiometer on a different not connected breadboard and have their outputs connected to the arduino via, for example, bluetooth? If so, how would that be done?

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

    From a technical point of view there is no reason to use an analog pin for the direction input. The digital pin works internally the same way as your code line and gives a 0 value below about 2 Volts on the pin (check the specs for correct values). The advantage of using a digital pin would be that you could use the internal pullup resistor, so besides simplifying your code you can also eliminate the external resistor

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

    Dear Jimmy, i have a question. I don't see any connections between the digitalpin 9 and 12 in your video. How are those connected with the motor A ?
    My train doesn't run. Has this someting to do with the PWR ? I read somewhere that I should lower this value ?
    Can you give me a clue? Thanks .

  • @dacuzzz
    @dacuzzz 5 ปีที่แล้ว

    pretty slick there Jimmy... &it works... hahahaha...good job... 2 thumbs up... vinny

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

      Thanks Vinny! It took a little while to get working right.

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

    what resistor did you use?

  • @coreygibson2590
    @coreygibson2590 5 ปีที่แล้ว

    Hello, great video. I just happen to have all of the parts you used so I decided to try it before I build my layout. Right now the track is just setup for testing. I currently run DC vintage controller. I built your system and it seems to be working with just a couple of issues that I will sort out. The Pot I have is a B 50k. It has a drastic jump when watching in the serial monitor. Also the loco will only move when the pot is wide open. Another is my loco runs fine all the way around using my old DC controller, but dies quick using the Arduino. Maybe my vintage PSU is AC maybe? I will use feeders and buss, but if one work, shouldn't the other? Other than that, I think I will forget DCC for now and try this approach to run at least two trains simultaneously. If that's possible. Thanks

    • @coreygibson2590
      @coreygibson2590 5 ปีที่แล้ว

      Never mind. There were issues on my end. It works fine. Locos do not run as fast as my old controller, but it does work. I had to add feeder lines just for testing. At first I had 12v to the motor shield. It ran about half speed. Then I put my 15v psu to the motor shield and it went a little faster. Right now its putting out about 11.5 to 12 volts. Thanks Again!

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

    Have you ever tried connecting the Arduino to JMRI to control the DC train or know of any one that has?

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

    I'd really like to see some automation with this dc setup, including automated throttle control. Is automated throttle possible without using PWM? I've heard some bad things with overheated motors using PWM on dc locos.

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

      You would have to add an RC filter (a resistor and capacitor) to essentially filter the square wave PWM into a nearly-smooth DC, at the output from Arduino, and then feed that through a couple of transistors to beef up the current before sending it to the track. If that is all talking gibberish to you, I'm afraid the short answer is "no". There's no built-in way to make an Arduino put out anything but PWM.

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

    Is this train special for aurdiona or any train can used for this project??

  • @crfenosi
    @crfenosi 5 ปีที่แล้ว

    Hi Jimmy, it may be possible to see a connection diagram, I have some doubts, I can not see them in the video clearly, thank you very much. Greetings from Argentina.

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

      I have made a schematic now, it is in the description below.

  • @coreygibson2590
    @coreygibson2590 5 ปีที่แล้ว

    Hello again. I am still working with your project and it works fine. I would like to add another POT and reverse switch and send that POT signal to the B output on the motor shield. I have all of the electronics hooked up to what I think is correct. I just used 2 more analogs on the shield for the new POT and reverse switch. It seems to work because as I play with your code (which I am not good at), each POT will work, but they both seem to only control output A. They never work simultaneously. I'm sure it's something with my code. Would appreciate any help!! Thanks

    • @jonnykemp1988
      @jonnykemp1988 4 ปีที่แล้ว

      Corey Gibson I assume you mean to have a second track running from motor output B? If so did you manage to get this to work? I’m considering getting everything to run this but I have 2 separate tracks which would be a lot easier to control from one Arduino rather than the additional cost of two of everything. (I.e. 2 Arduinos, 2 motor shields, 2 power supplies etc)

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

    Hi Jimmy, This is a cool project and I am planning to do this now. I have a silly question. The train has nothing to do with the circuit or the communication part? Does it run with the help of the tracks completing the circuit? Please let me know. Everything is clear to me except that part. Thanks

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

      You are correct. Think of the track as leads to the electric motor inside the locomotive.

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

      @@DIYDigitalRailroad Thanks much!

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

      I am planning to do this project with my kids. So Arduino sells the entire kit through their website?

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

    This is a well-presented video, but I have to ask, why? A microcontroller + software code + a motor driver board all to achieve what a conventional analog motor control circuit does. A handful of electronic components soldered together from a schematic would do this. Is the point just to avoid soldering?

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

    I've been searching for info on this topic and most has been good as far as they went but not a single one says how you connect the arduino to the tracks. Am I misunderstanding this process ?

  • @charliegijones
    @charliegijones 5 ปีที่แล้ว

    I bought an L298P motor shield but it looks different than yours.there is an A and B motor terminals but no power where yours is located. Another wire terminal is located to the right of the motor terminal with UMS & GND.
    Will this still work or do I have to get a different motor shield

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

      There are several different versions of the L298P motorshield. It should still work ok. If it doesn't I have the original one that I used linked in the description of the video.

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

    I have a very silly question. How do the coding interact with the DC motor? Is that the settings at beginning interact with the Arudino shield?

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

      Thats not a silly question. The arduino is essentially controlling a motor. So the code is essentially speeding up and slowing down an electric motor. This does this by using the motorshield to translate the digital signal to varying electrical power.

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

      @@DIYDigitalRailroad Thanks for your prompt response. I mean does my computer physically connect with the motor shield. I didn't see anything like that in the video, so was wondering. It's a cool project. I already purchased everything needed for the project and just have start working on it :)

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

      Hi, I still have the question of how the coding that was done in the Arduino editor interacts with the DC motor shield. Based on the video, I don't see any physical connection between the motor and a computer where we do the coding? please help.

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

      @@automationaccount4586 you write the sketch on your computer by means of the Arduino IDE and then you flash your sketch to the Arduino also with the IDE. Now the sketch is on the Arduino and it does not need the computer anymore and it will run the sketch automaticly over and over again as long as the Arduino has power. Maybe you should look up some info about what an Arduino is first.....

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

    Nice tutorial! I'm building something similar and wanted to look for some examples before I started.
    There are a number of issues with your code, though.
    analogWrite(3, Speed) ... the parameters are not min and max values.... they are pin and value, so what this command is doing is writing the value Speed in pin 3, which is the speed of the motor. The code is correct, just clarifying.
    digitalWrite(9, LOW) ... since you never set this to high, you might as well just set it to LOW once in the setup and leave it out of the loop.
    Direction = analogRead(A1) ... I don't know what kind of bad experience you had with digital inputs, but you should DEFINITELY be using a digital input here. There is no margin for error. There are no hiccups. If you have some kind of hardware problem that affects your digital pins (like bad contacts), you should go and fix that cause it will probably affect your analog pins as well. Direction is either forward or backwards, so use a digital input. Plus, you can use pinMode with the INPUT_PULLUP parameter, and do away with the resistor in the breadboard, just connect the switch between the arduino pin and ground. Be aware that when the switch is ON, your digital read will be LOW, and when it is OFF, you will read HIGH due to the internal pullup resistor. And instead of naming it A1, for digital functions, that pin is named 14.
    else if (Direction > 500) ... everything after the 'else' is unnecesary, not to mention you are leaving the value 500 out of both conditions, but that does not really affect functionality here. If having the explicit condition helps you understand the code, just add a comment like this:
    else // (Direction >= 500)
    In any case, if you switch to digital input for direction, your first condition should be something like:
    if (Direction == HIGH)
    and the other brach, would look something like:
    else // Direction == LOW
    Did you continue working on this? The real power of Arduino is that you can add a lot on top of this basic behavior. e.g.: If you are going full speed and switch direction, you may damage the train motor, plus you may derail the train, so you can make a smooth transition from the current speed and direction to the selected speed and direction.

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

    What about making a 3D printed enclosure for this?

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

      I'm actually working on that!

    • @coreygibson2590
      @coreygibson2590 5 ปีที่แล้ว

      @@DIYDigitalRailroad I was going to work on one as well. Thanks!!

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

    How do you tell it which locomotive address you are controlling?

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

      It's not DCC. It puts a PWM voltage on the track, and every DC loco on that track will run. There is no such thing as "locomotive addressing" in a DC system.

  • @CONTAINERMAN68
    @CONTAINERMAN68 5 ปีที่แล้ว

    I think I know my answer, but I'll ask anyway: How many DC locos will this setup control? How do you know what to type to program something like this? RH

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

      I haven't tested it with multiple locos yet, but It's a 12 volt power supply with 2 amps per motor I believe I would have to check. In terms of what to type, I just do my research and look at the examples that Arduino provides in their software, this one for example, I studied how to control a DC motor which is essentially the same, then I combined it with some knowledge from some other projects I've done, and bam!

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

      Arduino can also control DCC locos. If you want to control dc trains separately , you have to segment your tracks and put on each segment its own motorshield. Kind regards . P.S let your fantasy out of control the arduino solutions are incredible wide. Your old television remote , PlayStation / xbox remote,dcc controller, bluetooth or wifi android you name it remote thing clapper is usable. I am trying to use a audio midi controller and it works.

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

    It looks like the link to the merchandise is not working :(

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

      Thanks for the heads up! It should be fixed now.

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

      Here we go!

  • @DY-qp5nu
    @DY-qp5nu ปีที่แล้ว

    I need the train

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

    You don't need the "if (Direction >500)" statement because you tested for Direction

  • @perap4232
    @perap4232 4 ปีที่แล้ว

    Great Video clip! Sorry for butting in, I am interested in your initial thoughts. Have you heard about - Januke Henatalie Formula (search on google)? It is an awesome exclusive product for operating a model railroad minus the headache. Ive heard some awesome things about it and my friend Sam finally got great success with it.

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

    Excellent Video! Forgive me for the intrusion, I would love your initial thoughts. Have you thought about - Januke Henatalie Formula (Have a quick look on google cant remember the place now)? It is a good exclusive product for operating a model railroad without the normal expense. Ive heard some interesting things about it and my old buddy Taylor got amazing success with it.