Тёмный

DIY Arduino Model Railroad Reversing Loop 

DIY and Digital Railroad
Подписаться 63 тыс.
Просмотров 30 тыс.
50% 1

Welcome Everybody! Be sure to subscribe! Today we are tackling something that I have wanted to do for awhile, an arduino based reversing loop!
A quick note on the programming at 11:06 the pinMode should be sensor2
Github Link to download sketch
github.com/DIY...
Schematic (I am terrible at creating schematics haha)
photos.app.goo...
Arduino Snap Switch control
• Model Train Switch Con...
Parts Used
Arduino UNO
amzn.to/2tw01Ej
L298P Motorshield
amzn.to/39GyXCN
Dual Relay
amzn.to/39AxT3o
Sensors
amzn.to/2ZUHg9N
Breadboard
amzn.to/2ZUHqxV
Dupont Wires
amzn.to/2QMUD7H
12V Power supply
amzn.to/2sNTnsY
Support the channel with some Merchandise!
teespring.com/...
You can contact me at diyanddigitalrr@gmail.com

Опубликовано:

 

11 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 102   
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Ok everyone! The link I had was private. I set it to public. The project link should work now!
@aubreykloppers9202
@aubreykloppers9202 Год назад
I am from South Africa and am busy building a track for my kids (8, 6, 4). Your stuff is FLIPPEN COOL! Thank you :)
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
Hey everyone! Thanks to @David Mead. He caught a typo at 11:06. The pinMode should be sensor2
@RobiBue
@RobiBue 4 года назад
DIY & Digital Railroad I have a question: the enum LOOPSTATES are outside of the setup() block. Is that supposed to be like that? And then another Q/comment: why not make the pin variables const? They are constants anyway, and it just ensures that they won’t get changed accidentally. Just to clarify: I have no experience with arduino, that’s why I am asking. I’m just curious as l am interested in arduino and pi boards, but haven’t worked with either. Just been watching vids and reading up on possibilities to decide what project I’ll be taking on eventually...
@jvanamb
@jvanamb 4 года назад
Jimmy; Great info and video. And especially for hanging the N.Y.C. 20th Century Limited. poster. From 1915 to 1967 my Great-Uncle John Lynch was one of the three longest tenured Loco Engineers on the 4-8-4 Hudson & 4-8-4 Streamlined Hudson (J-1 Class & J-3a Class). In memory of his years "ON THE LINE" it is also one of the HO Scale HardBodies I run on my home layout. Thanks; Jim
@sebastienduchesne9285
@sebastienduchesne9285 5 месяцев назад
Thx for this awesome video !!! You helped me alot with my reversing loop setup. Keep up the good work you're doing a great job !!!
@nesr8786
@nesr8786 4 года назад
Happy New Year Jimmy ,thank you ,im glad you are continuing the Arduino tutorials, cant wait for the next ,take care for now.Mac
@SteveH-TN
@SteveH-TN Год назад
Thanks for sharing your thoughts and information. You have me considering using a Ardurino on my MRR Design(s) after more thought.
@HHExpress
@HHExpress 4 года назад
Nice tutorial Jimmy, I'm building a N scale track as well and document every step. I do not have DCC but de regular Analog DC version. However I learned already a lot from your videos in controlling the trains. I have a long way to go but getting there.
@kevinhunter6095
@kevinhunter6095 4 года назад
At 3:40 the for dependability and safety the wiring of the relay contacts should be reversed with the power feed going to the outside terminals and the track connected to the inside terminals. As shown, if one relay drops an instant before the other a dead short is created as both power lines will be connected to a single rail. When the wiring is reversed under the same conditions both rails will be connected to a single supply side; a much less destructive situation.
@davidtrott9469
@davidtrott9469 Год назад
For a simple reversing loop it would be simpler to use a one DPDT relay rather than the two SPDT Relays - however even then the track feeds should still come from the common pins on the relays (as Kevin pointed out) - because any mechanic failure such as one pole getting stuck won't result in a short circuit. Additionally if the track plan was more complicated and you needed more than two track feeds then using multiple SPDT relays where each relay controlled the "polarity" (I know it's AC) of each feed would allow you more flexibility, for example if you had 3 feeds you could control the "Polarity" of each feed individually - you cannot do that if wired per the video.
@kevinhunter6095
@kevinhunter6095 Год назад
@@davidtrott9469 The odd circumstance many discover is that single pole relays of the type shown are often less than half the price of a similar DPDT relay, and use little or no extra power. Further single pole availability is much higher, probably leading to the odd price differential. Just things to keep in mind when shopping...
@hctreintje
@hctreintje 4 года назад
Fantastic i heff made a reversing loop like you and it works perfect and beter dan al athor systems THANKS !! HC Treintje Belgium.
@jodepa01
@jodepa01 4 года назад
Hello Jimmy, first of all I wish you and your family a Happy New Year and for me many videos from you :). Nice video but is it possible in the future to have a zoomed in pic of your accessories and connections? Just for understanding! Thx.
@gizmobar5514
@gizmobar5514 4 года назад
Hello Jimmy, had question but did some study on the motor shield and solved my question on how to connect a tortoise switch machine so problem solved. Waiting on your next video and thank you!
@bernardc2553
@bernardc2553 4 года назад
I'm so in..Altho I'm still in the Steam-age, I'm learning that's to teacher like yourself Jimmy,love these ardunio tutorials
@bernardc2553
@bernardc2553 4 года назад
Oh BTW trains ARE coming outta boxes THIS YR. 40+loco's bass included so the good 1's re motor & decoders where I'm going BTW HAPPY NEW YR to you and yours thanks again
@chriscall8545
@chriscall8545 6 месяцев назад
liked your approach to the revers loop. Have built and n using the DCC EX command station. I have two reversing loops on my layout. The question , do I have to link the reversing loop (Arduino system )to the command station or can it function on its own with sensors controlling the turn outs and phase change
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Hey Everyone! There is now a Github link with bug fixes for the code! Check the description!
@alexs5700
@alexs5700 4 года назад
another good tutorial Thanks alot Jimmy all the best for 2020
@masterdplos2689
@masterdplos2689 4 года назад
Thanks for the video. I’m starting my n scale layout and was worried about reverse modules depending on a shortcut detection. This is great! Just one question: I’m planning to use android controlled servos for my turnouts. How would you make them talk to this great module?
@ShipinPro
@ShipinPro 4 года назад
Seems there is a major bug in the sketch, the values being passed to the functions "switchXX" are sensor1, sensor2, which is essentially the Analog pin nos. that the IR sensors are connected to, instead the readings of the analog pins A2,A3 should be passed. The analogRead(sensor1) should be changed to int sensor1Val = analogRead(sensor1); sensor2Val = analogRead(sensor2);, which should then be passed such as switchR1(sensor1Val,sensor2Val); and so on...
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
I know this is a looong time for a reply, but I adjusted the code. github.com/DIYandDigitalRR/DCC-Reversing-Loop
@ludgermimberg2908
@ludgermimberg2908 4 года назад
Jimmy, nice idea and good to see. I was thinking about something similar, needing more effort on HW side. I guess I think about that again. It can obviously be done with less. Looking at the code in the video and on the google drive though: Analog inputs can also be used as digital inputs. So a digitalRead() will work as well. In the loop() you read both sensors (line 30 and 31) but you assign them never to a variable. So the Serial.print() should always print the pin numbers of A2 and A3 - I believe - "15" and "16" to the serial monitor. I assume you want to set the power of to the motor shield via PWM. That would be a analogWrite(), not digitalWrite() in the switchxx() functions. I assume the digitalWrite(power, 255) is somehow understood as a digitalWrite(power, 1) by the compiler. Additionally, the switch functions will always be called with pin number for the sensor pins (see above) and those are always less than 200. And with that the code should just loop through the sates about every two seconds. But your video shows clearly that the loop works. Do you have updated code for us? Or am I just missing something?
@paparoysworkshop
@paparoysworkshop Год назад
I think I see one flaw in this system. If the track switch for some reason flipped unexpectedly, or was manually switched, then the system would short out. This concept relies heavily on the track always being in the right position for the train entering. It is a nice video, but personally, I would not use this system. The short-circuit detection method is more reliable. Also, since my own track has multiple exits within the reverse loops, the train does not always exit back on to the track it came from. Therefore, the next train entering the reverse loop would be in for a shock (literally). Again, nice video. My criticism is meant to be constructive. I'm not attacking your ideas.
@chriscall8545
@chriscall8545 8 месяцев назад
Like the build but how long can the wires be. Also will this work with the DCC Command station and the DCC EX motored shield
@gizmobar5514
@gizmobar5514 4 года назад
Hello Jimmy, again another great video and being one that is very new to arduino and understanding them and the language is a huge problem for me so may I ask how do you connect a tortoise switch machine to this?
@Deadbuck73
@Deadbuck73 4 года назад
I’m in trouble! My kitchen aid mixer has a dough hook but no bread board! When two hobbies.... baking and trains collide.... 😆
@Dikkedimi
@Dikkedimi 4 года назад
exactly what i was looking for, thanks!
@garethdavies8673
@garethdavies8673 4 года назад
A very interesting and useful video . Thank you for sharing your expertise
@rosiespringer
@rosiespringer Месяц назад
Great video, but I not sure what the bumping music in the background adds to it, just a distraction you my mind.
@InvertLogic
@InvertLogic 4 года назад
Thats a nice solution. I will try it with my layout.
@chr1sda1sey
@chr1sda1sey 4 года назад
Very smooth and informative
@silverfaux8545
@silverfaux8545 Год назад
Question. Can I run both ends of the loop like this with one arduino, two sets of sensors and 2 relay boards? Thanks in advance for the help.
@lukeashworth8125
@lukeashworth8125 Год назад
Jimmy is there a way of using a servo instead of using kato switch like you use with the same setup
@espen379
@espen379 Год назад
Great video. Can you achieve the by using current sensors instead of ir?
@justinheath7989
@justinheath7989 6 месяцев назад
I have a complicated track plan that o would love to do and it has two reversing loops I believe. Would it be possible to show you the plan and help me work out what I would need to put and is it even possible. This would be my first ardurino project and if like to use it so the turnout controlled polarity that controls signals again if possible.
@MrMelston1777
@MrMelston1777 2 года назад
This is another great video but I am having some trouble understanding what the different pin variables are for. There is no overview that really explains what these are for. I can see in the final sketch what the code does but I am having trouble mapping that back to what is happening on the layout. The variable names are somewhat descriptive but the effect of turning some high and others low isn't clear to me. After watching to the end I could (sort of) figure out what the purpose of the loopState variable was but the rest is not even that clear. BTW, I am a software engineer with 35+ years of experience (beginning with C). I am just now starting my exploration of Arduino and really loving it. @diyandigitalrailroad I could recommend a few things to make your listings a bit easier to follow if you like. Nothing major, though. I like your presentations, overall.
@pbakker8982
@pbakker8982 Год назад
Is it possible to add the line diagram of all the connections?
@stabletoaster6328
@stabletoaster6328 День назад
Is it possible to make a dc reversing loop
@phillipharmon7550
@phillipharmon7550 3 года назад
Hi Jimmy, Love the video but I am still having trouble with the arduino sketch, I'm getting a message that switch R2 was not declared in this scope in the second phrase of the primary void loop. I assumed it was a syntax error but I cannot find any inconsistency with your original. Is it possible I missed an edit, or there was something not on the video? I'm a Linux novice and still learning definitions. Also I did not have a dual relay handy and am trying to use two single relays. Will this require any change to the code? Thanks again for your help.
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Hey Phillip! I have created a new download link for the code. It's a github page. github.com/DIYandDigitalRR/DCC-Reversing-Loop
@phillipharmon7550
@phillipharmon7550 3 года назад
@@DIYDigitalRailroad Thanks so much, just seeing this. I'll head over and update the code. Uh,oh github returns the page does not exist. But I do see your other arduino, & sensor fixes??? By way of more information. My sketch compiles and uploads, but when it runs on the arduino it flashes both of the relays continuously every .5 seconds. It does not seem to respond to the optical sensors at all. Even when disconnected from the sensors the arduino keeps reversing and switching both relays at the same time. Could a mechanical connection be at fault as opposed to software? Or could there be a missing line or direction not in the video? Regards, asking a lot in Maryland.
@isdits
@isdits Год назад
Is there an automatic reversing loop for dc trains?
@isdits
@isdits Год назад
surely there's an easier way to do this by now?
@joang9171
@joang9171 4 года назад
Happy New Year indeed. I'm loving this Arduino stuff but I have a question. Can track polarity reversal (not interested in the turnout driver portion) be done using short circuit detection rather than the optical sensors? That is what I'd like to see. Sadly I'm not tech savvy enough to puzzle it out on my own so please keep it simple.
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
Yes that is actually how most commercially available reversing loop modules work.
@davidammon7662
@davidammon7662 4 года назад
@@DIYDigitalRailroad I have a twin track N Scale layout. I want a loop to join the 2 tracks toether, so I dont need the turnout control. Do I still use the motor sheild or could I do it with the relay shield? Not keen on the short circuit method. Modern DCC controllers tend to spot short circuit too quickly
@sonysnapper
@sonysnapper 4 года назад
I'm late in watching this. Missing is the explanation of the logic of what this is doing. Break? I assume "break" is some obscure motor shield command? This seems more expensive and complex than the commercial auto reversers. What are you using for a switch machine?
@zinethar
@zinethar 4 года назад
Is there a typo in your sketch? In your PinMode things shouldn't the last one be sensor2? To me it makes no sense to declare the same thing twice.
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
Good catch. I will adjust it in the downloadable sketch.
@BK-oo1bl
@BK-oo1bl 9 месяцев назад
Do you know if this can be done with dc and not dcc?
@fy7chris
@fy7chris 2 года назад
Great tutorial but I ended up switching it off after a few minutes as that background music is so annoying and you can’t turn the volume down or you miss the commentary.
@zinethar
@zinethar 2 года назад
OK I guess I'm just having a dense day but I finally after static test was trying it on my actual railroad reversing loop. Everything seems to be OK but for the life of me I can't seem to figure out where the red and black wires from my Kato switch machine should connect. The diagram seems to say out1 and out 2 on motor shield but that doesn't exist as labeled?
@DIYDigitalRailroad
@DIYDigitalRailroad 2 года назад
No worries! I really need to update this one. The terminals are A and B on the motorshield. Each should have 2 terminals
@charlyzink5045
@charlyzink5045 4 года назад
hello again, have you had the opportunity to resolve the problem with either the code or the setup?
@patrickmaloney6440
@patrickmaloney6440 4 года назад
Nice video Jimmy! One question... Where were the insulated frogplates? Each end of the turnout, or just at the split end?
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
They are at the split end of the turnout.
@patrickmaloney6440
@patrickmaloney6440 4 года назад
@@DIYDigitalRailroad Thanks!!
@johnlatta3998
@johnlatta3998 3 года назад
I cannot find the sketch for this anywhere. The link given no longer works. Can you provide a link I can use?
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Yes I will do that.
@coreygibson2590
@coreygibson2590 3 года назад
Hello, I have been working with this project of and on now for as cooker of weeks. I have everything hooked you exactly as you, same parts, your sketch and I'm just trying to get the static test to work. I haven't made it to hooking up the shield and track yet. I get blinking lights on my relays and continuous 16 and 17 in serial monitor. Appreciate any help. Thanks.
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Hmmm. I remember this being an error when I was prototyping it. Let me rebuild it and test.
@jcsmith725
@jcsmith725 4 года назад
I'd really like to see how you can incorporate the infrared sensors into a layout where they are hidden from sight. I'm really interested in a lot of the work you do but struggle to think how it's possible to conceal it and have it functional.
@railguy6639
@railguy6639 4 года назад
Jason, our club has used these in the past and placed them looking up between the rails. You can get smaller ones if you look around. Ambient light is also a concern. If done right, it can also count the number of units (Cars & Locos) in your train. Useful on a reversing loop in determining if your train is too long for the loop (could trigger an emergency stop command).
@railguy6639
@railguy6639 4 года назад
Nothing worse than a T-bone of your own train. :-)
@bradlegault5731
@bradlegault5731 4 года назад
Will a L293d motor shield work?
@bruce12000
@bruce12000 2 года назад
Hello when the polarity from the main track is reverse while the train pass in front of the second sensor will it not affect all the rest of the Dcc accessory and other locks?
@DIYDigitalRailroad
@DIYDigitalRailroad 2 года назад
So the reversing loop is electrically isolated from the rest of the system. The switch in polarity actually prevents a short circuit.
@bruce12000
@bruce12000 2 года назад
@@DIYDigitalRailroad sorry for the autocorrect I was talking about other locomotives already running on the main track while this one passing through the reverse loop isolated while the sensor detect and reverse polarity on the main track Im new to DCC and from what I have learned is the Main reason to go towards Dcc was to be able to run multiple locomotives at the same time like doing yard work and switching from one main to an other or changing locomotives on the turntable to get it ready to pull out one more train but if the polarity is reverse will not all locomotives will go backwards when you try to make it go forward? I mean if all locomotives was programmed with the positive on the inside and the negative on the outside and now after one locomotives that have pass through the reverse loop will it not reverse the polarity of the rest of the layout too?
@MrGarthah
@MrGarthah 4 года назад
would be nice if there was a text file for sketch really like this approach over frog juicer as turnouts are also controlled
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
I can make that happen.
@regus06
@regus06 4 года назад
Hello, sorry for my bad language, I'm from France. Can I use this for a turntable. One sensor on the main track and the other sensor under the track of the bridge and connect all the track after the turntable to the main track. Thank you for your help.
@pierre-de-standing
@pierre-de-standing 2 года назад
I would have thought so, A turntable is a bit like a reversing loop really. Before the turntable reaches its next position, that is when you would need to switch the polarities on the turntable deck.
@halfofacouch2397
@halfofacouch2397 2 года назад
Can this be done on O gauge?
@sniffy2614
@sniffy2614 4 года назад
Can you make the cross-signal (arduino+ led + servo + DFplayer + IR or ultrasound sensor) for your next episode?
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
I am actually working on that, but I am waiting until I have the entire system worked out, including how I am mounting it to my layout.
@SheltonDCruz
@SheltonDCruz 2 года назад
may I ask how do you connect a tortoise switch machine to this?
@DIYDigitalRailroad
@DIYDigitalRailroad 2 года назад
It's actually pretty easy. Just connect pads 1 and 8 on the tortoise to the motor shield terminal and change the arduino code from 500ms to 2000ms
@jamesbraxton6132
@jamesbraxton6132 4 года назад
you should not touch the carpet with your boards , static electricity can sort them out.
@railguy6639
@railguy6639 4 года назад
Can't you use a relay instead of a motor shield to fire the turnout motor? A single DPDT relay to handle the "polarity" (or two SPDT in tandem), With one SPDT Relay to provide "power" on the hot lead. Your sensor setup stays the same. Timing: sensor read (1 or 2) set next switch state (determines the state of the DPDT "Polarity" relay), when the second sensor is reached, the Arduino momentarily pulses the power relay to fire the switch motor then returns to the power off state. Power for the turnout is provided separate (isolated) from the Arduino to avoid any possible spike. This setup would also work on duel coil "Snap-Switch" turnout motors with slight modification... the "Polarity" relay would need only one set of contacts, 1) to set switch to normal and 2) to set switch for diversion. I am new to Arduino programming but see this as a way to minimize motor shields that take up multiple pins to control.
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
Kato turnouts are different, but you can use relays for snap switches.
@railguy6639
@railguy6639 4 года назад
@@DIYDigitalRailroad I realize that Kato switches operate on a momentary pulse with the polarity of the pulse providing the direction of the switch. Theoretically, that still can be accomplished with a DPDT relay and to control polarity and a SPDT relay to control the power.
@ondrejsverma1385
@ondrejsverma1385 2 года назад
Hi, where the avoidance control is connected
@DIYDigitalRailroad
@DIYDigitalRailroad 2 года назад
Are you referring to the sensors that change the points?
@ondrejsverma1385
@ondrejsverma1385 2 года назад
@@DIYDigitalRailroad no, but motor turnout
@charlyzink5045
@charlyzink5045 4 года назад
hello, not sure if anyone else is having this problem, my setup, not connected to track but to a kato switch, seems to be in a constant loop. the switch will switch back and forth continuously every second, the ir sensors react but nothing will stop the relay from switching back and forth. the serial monitor shows a value of 16 and 17 respectively from the two sensors. have tried with different arduino uno and different sensors and motor shields. the sensors will output zero volts and then to 5 volts when activated, but the relay continues to switch back and forth. again the serial monitor shows no value change either. thanks in advance for any direction, charly
@DIYDigitalRailroad
@DIYDigitalRailroad 4 года назад
I actually had this problem when I was prototyping this. I can't remember what exactly fixed it. I'll go back to the prototype this weekend and check.
@charlyzink5045
@charlyzink5045 4 года назад
hello, have you had the opportunity to resolve the problem with either the code or the setup?
@charlyzink5045
@charlyzink5045 4 года назад
hello, any progress on the problem with the setup or the code?
@MikeFerrell
@MikeFerrell 4 года назад
Did you ever solve this? I get exactly the same issue
@ShipinPro
@ShipinPro 4 года назад
@@MikeFerrell I have posted the fix above
@johnlatta3998
@johnlatta3998 3 года назад
Has anyone ever gotten this sketch to work? Jimmy keeps saying he'll post the updated code, but he never does. Makes ya' kind of wander...
@DIYDigitalRailroad
@DIYDigitalRailroad 3 года назад
Ok crazy story. So I thought I had fixed the link issue ages ago. I could see it every time I clicked and I figured that people were just having issues with firewalls or cookies or something else because it's github. I saw your comment and I was like "Ok what is the issue???" I looked really hard at the github page and discovered........it was set to PRIVATE........I feel so dumb haha! It should work now!
@johnlatta3998
@johnlatta3998 3 года назад
@@DIYDigitalRailroad Thank You! I thought there might be something flakey going on. I truly appreciate your looking into this. Can't wait to try it out as I'm trying to automate my layout as much as possible. Thanks again.
@charlyzink5045
@charlyzink5045 4 года назад
ok was this a great video as everyone has mentioned? has anyone else had the problem with the setup or the code as i have? i have asked for help being the newbie i am and have received none, not even from the peanut gallery. great ideas but maybe there is more help elsewhere.
@mikefochtman7164
@mikefochtman7164 3 года назад
I think the code has a few bugs. The analogRead() functions aren't assigning their return values to anything. Should be more like: val1 = analogRead(sensor1); val2 = analogRead(sensor2); Frankly, he must have done some debugging before he got it to run and then forgot to update the sketch. I could be wrong though, just my $0.02.
@danieljarvis3125
@danieljarvis3125 10 месяцев назад
The music is annoying and distracting. 👿
@troysimpson9550
@troysimpson9550 4 года назад
Would this work for strait DC as well?
Далее
Fully Automate Your DCC Reverse Loops (197)
23:21
Просмотров 57 тыс.
RC Helicopter Trick
00:13
Просмотров 6 млн
Model Railroad DC or DCC? How To Wire REVERSE LOOPS!
15:49
DCC Auto-Reversing Devices
14:34
Просмотров 5 тыс.
Laying Curved Flex Track on a Model Railroad Layout
24:54
RC Helicopter Trick
00:13
Просмотров 6 млн