Hi Ron, just a suggestion: by wiring the relays as you did, short circuits can happen. For example, if R1 is on and R2 off the green wire will be connected to both red and black, and blue will short circuit aswell. This can be dangerous and can happen if, for example, you make a small coding mistake. I suggest you to rewire the relays, so that every relay controls the polarity of one wire. It is really easy to do: connect black and red to the outer connectors (NC and NO) and keep the green wire in the middle. This way, the green wire can either be connected to the black or blue one but not both at the same time. Then use the next relay to do the same for the blue wire. In the end it will look like this: red/green/black and red/blue/black. This way no short circuit can happen and I think it is much safer. If there is any error in the coding, both switch leads will have the same polarization and nothing will happen. It is much safer! Cheers
He's correct. Infact, your code shorts out the signals every time you make a change. The relays are switched sequentially so for a few microseconds the red and black are shorted together. Having said that, arduino's ( and newer ESP32s etc ) are a great resource. I use them to switch points, signal between sections, control decoupling ramps, drive crossing gates, lights, drive semaphor signals and at the heart of my PCM power supplies.
I'm not even done the video and that issue is making me twitchy. Regarding someone else saying use DPDT (double post, double throw) relays. Yes, but keep in mind the relay module he's using (should) have the appropriate protection to keep the relays from frying the Arduino. So replacement relays need that as well, one can't just drop in a relay on its own.
@@phyzzip yeah, I am disappointed he did not address this issue at all. It is outright dangerous if other people try this and do not have much experience with electronics.
Really enjoyed your video describing relay controls. I am an electronic repairman working for the local steel mill now for 31 years. Your hard work describing how relay control and wiring them to match the design was amazingly simple to follow. Most instructional material start with the blue print side of the whole picture and move into the actual wiring content later. I was really amazed how clear you kept your message to us the viewer and not confuse yourself ! Outstanding job sir ! Looking forward to more of your videos
Hey Ron your right it's about as clear as mud it's amazing to me how much you go through now day to run a train layouts great video and thank you for sharing
Your use of the term “normally on” could be confusing to some. The relay contacts are “normally open” (NO) and “normally closed” (NC). Normally open is not the same as normally on.
Great to meet you in person at the Texas Express Ron! This was a very informative video - I am working on EXACTLY this (lining routes into my staging and classification yards via direct Arduino control rather than sending DCC commands). SUBBED! 🙂
I have used the Arduino to control multiple servos. Actually seen a 3D printed mounting to use a servo for throwing rail switches that looked to be a cheap alternative. That relay bank looks like a solution to controlling my small metal mill.
I bought an arduino starter set over a year ago for exactly this purpose, but have not had time to start. I am familiar with wiring of relays as my turnout frogs are controlled that way. Great to see your method, and I would really appreciate a look at your sketch. Thanks from the UK, and well done, a really good presentation.
Hi Ron, I appreciate that it has been a year since making this video. However, have you considered making the relay boards yourself. There is more than one reason why I suggest this. Firstly, your schematic while correct works ok, if a relay does not switch there is a situation where there would be a short. Your system relies on BOTH relays for each pair to operate together. If you replaced the relays for DPDT you would have one relay switching two lines and also you would only use half the relays. The common terminal of each pole would connect to + & - respectively and the motor to the NC of each pole. You would connect NC of one pole to the NO of the other pole on both poles. This way of doing things would also eliminate any problems in mis-coding an output and not firing both relays at the same time. Regards, Geoff.
Great video! Massive amount of info to convey here. Always enjoy your vids, and this one is no different, but I was out when the sketch thing appeared! Too much for this 64 yo brain to follow! But it will be massively helpful to many modelers! Keep up the great work!
Very interesting. I’ve written some Arduino Sketches. You got that one very clean. If a viewer wants to build a similar set of switches, can the sketch be downloaded?
Thanks Ron for good ideas for making the control panel and using Ardurino to control the turnouts. I didn't see a button for the first turnout in the ladder, the one leading to the passing siding. It seems like you'd need a push button for that AND a separate one for the passing siding turnouts. Maybe I'm missing something. Anyway, thanks for showing us this cool project.
Depending on the current draw of the tortoise switch machines you could also use a ULN2803A integrated circuit to control them from the Arduino. If you really wanted you could design a PCB in Kicad or a similar program that fits onto the Arduino directly and get a really compact setup. The IC mentioned above is also good for driving LEDs for building lights an similar use cases.
Is it possible to get a copy of the sketch you used? I’m interested in building a similar panel and would like to use the sketch as the basis to customize. Thanks
Very Good . But where I can get a copy of the Arduino Sketch . I not in programming with Arduino but I start to try. So is it possible get the sketch ? Thank You for the help.
Im workingon Arduino code for crossover and wye interlockings and pannel board lights. I have yet to find a purpose build control that will control multiple switches in relation to each other.
Speaking of which how do i find a good switcher engine for my Layout cause I've looked on the Midwest model railroad website multiple times and i haven't been able to find anything
Surely if you used the common of the relay as your output and you supplied the (NO) with+12v and the (NC) -12v from the ATX power supply then you would only need 1 relay instead of 2, you would need to control the voltage level after the output to control power levels.
There is another way which will eliminate the second relay. What you need is the 12 supply and 2 1000 ohm 1/4 watt resistors for each tortoise. I can't draw pictures so use visualization. Draw a horizontal line for +12 volts. From that line attach one end of the 1000 ohm resistor to +12 and the other end to one of the motor leads on the tortoise and repeat for the other motor lead. Now run your wires from the tortoise to the outer leads of the relay. Finally run the return lead from the 12 volt power supply to the common or center lead of the relay. Now what happens is you are switching the +12 volt power from one tortoise motor lead to the other and the opposite lead is pulled to the +12 return. Energize the relay and it reverses the connections. The resistors limit the current to about 12 milliamps which is sufficient to run the motor . You can use the same circuit with a SPDT toggle switch.
Ron, what is your thought process behind reading for a button press and then release? I think you are overcomplicating things! All you need is something like "if (digitalRead(button1) == LOW)" followed by your relay code, because even the briefest of presses is going to seem like eons to the Arduino (which is running such a simple loop many thousands of times/sec). Once the if statement condition has triggered (button1 has gone LOW) the Arduino is going to run the relay code to completion before it moves on, regardless of whether the button stops being pressed or not (which it won't be checking for anyway, it's busy executing the relay code). Whether the button *isn't* being pushed is irrelevant anyway, because the code isn't checking for that. All the Arduino knows is- button pushed -> put relays in x state. Additionally, there's no need for debounce here because each button is linked to a single state. If for example you had a turnout that flipped its position when a button was pushed, *that* would need debounce, because it's a toggle. Yes, the simplified if statement I described above would run several times each push owing to the Arduino's clock speed...but so what? On the first loop it sets your relays to the desired state, on the second loop it effectively does nothing because your relays are already in the desired state, and so on.
See the entire project of building and controlling this staging yard here: tinyurl.com/yc62dc88
Hi Ron, just a suggestion: by wiring the relays as you did, short circuits can happen. For example, if R1 is on and R2 off the green wire will be connected to both red and black, and blue will short circuit aswell. This can be dangerous and can happen if, for example, you make a small coding mistake. I suggest you to rewire the relays, so that every relay controls the polarity of one wire. It is really easy to do: connect black and red to the outer connectors (NC and NO) and keep the green wire in the middle. This way, the green wire can either be connected to the black or blue one but not both at the same time. Then use the next relay to do the same for the blue wire. In the end it will look like this: red/green/black and red/blue/black. This way no short circuit can happen and I think it is much safer. If there is any error in the coding, both switch leads will have the same polarization and nothing will happen. It is much safer!
Cheers
He's correct. Infact, your code shorts out the signals every time you make a change. The relays are switched sequentially so for a few microseconds the red and black are shorted together. Having said that, arduino's ( and newer ESP32s etc ) are a great resource. I use them to switch points, signal between sections, control decoupling ramps, drive crossing gates, lights, drive semaphor signals and at the heart of my PCM power supplies.
@@peterwhiting6303 Use dpdt relay to avoid problem and half of the logic.
@@galenerickson7380 I use 2 i/o lines and mosfets with solenoid switches, so no relays.
I'm not even done the video and that issue is making me twitchy. Regarding someone else saying use DPDT (double post, double throw) relays. Yes, but keep in mind the relay module he's using (should) have the appropriate protection to keep the relays from frying the Arduino. So replacement relays need that as well, one can't just drop in a relay on its own.
@@phyzzip yeah, I am disappointed he did not address this issue at all. It is outright dangerous if other people try this and do not have much experience with electronics.
I'm fully enjoying your time back with us and your latest project.
Really enjoyed your video describing relay controls. I am an electronic repairman working for the local steel mill now for 31 years. Your hard work describing how relay control and wiring them to match the design was amazingly simple to follow. Most instructional material start with the blue print side of the whole picture and move into the actual wiring content later. I was really amazed how clear you kept your message to us the viewer and not confuse yourself ! Outstanding job sir ! Looking forward to more of your videos
Thank you. That is a real compliment since I am NO electronics expert and have to seriously think through the process myself.
Hey Ron your right it's about as clear as mud it's amazing to me how much you go through now day to run a train layouts great video and thank you for sharing
Your use of the term “normally on” could be confusing to some. The relay contacts are “normally open” (NO) and “normally closed” (NC). Normally open is not the same as normally on.
Great to meet you in person at the Texas Express Ron! This was a very informative video - I am working on EXACTLY this (lining routes into my staging and classification yards via direct Arduino control rather than sending DCC commands). SUBBED! 🙂
Yes, was good to meet you too. I need to get down and operate on your layout sometime.
I have used the Arduino to control multiple servos. Actually seen a 3D printed mounting to use a servo for throwing rail switches that looked to be a cheap alternative. That relay bank looks like a solution to controlling my small metal mill.
I designed such a bracket, which will be the subject of a future video.
I bought an arduino starter set over a year ago for exactly this purpose, but have not had time to start. I am familiar with wiring of relays as my turnout frogs are controlled that way. Great to see your method, and I would really appreciate a look at your sketch. Thanks from the UK, and well done, a really good presentation.
Very interesting build Ron. I am looking forward to seeing the finalized build.
Awesome Video Ron! Where did you purchase the Ribbon Cable, and the buttons you used on the bread board?
All of the parts are available on Amazon.
@@RonsTrainsNThings Is there a particular type? Do they come with clips? Do you happen to have links? This is all new to me, Thanks for the help
Great job Ron! The Train Freak has some led turnout buttons that might be of interest to you.
Hi Ron, I appreciate that it has been a year since making this video. However, have you considered making the relay boards yourself. There is more than one reason why I suggest this. Firstly, your schematic while correct works ok, if a relay does not switch there is a situation where there would be a short. Your system relies on BOTH relays for each pair to operate together. If you replaced the relays for DPDT you would have one relay switching two lines and also you would only use half the relays. The common terminal of each pole would connect to + & - respectively and the motor to the NC of each pole. You would connect NC of one pole to the NO of the other pole on both poles. This way of doing things would also eliminate any problems in mis-coding an output and not firing both relays at the same time. Regards, Geoff.
Awesome Video! Where did you purchase the ribbon cable and temporary buttons?
Great video! Massive amount of info to convey here. Always enjoy your vids, and this one is no different, but I was out when the sketch thing appeared! Too much for this 64 yo brain to follow! But it will be massively helpful to many modelers! Keep up the great work!
That's a fine looking arduino project!
Thanks, Jimmy.
Very interesting. I’ve written some Arduino Sketches. You got that one very clean. If a viewer wants to build a similar set of switches, can the sketch be downloaded?
I am building a new website that will include free resources including this sketch. Coming very soon.
thank you for sharing a great detailed video
all great watching
Ron, NO is "normally open" and NC is "normally closed" in relay terminology
Thanks Ron for good ideas for making the control panel and using Ardurino to control the turnouts. I didn't see a button for the first turnout in the ladder, the one leading to the passing siding. It seems like you'd need a push button for that AND a separate one for the passing siding turnouts. Maybe I'm missing something. Anyway, thanks for showing us this cool project.
Depending on the current draw of the tortoise switch machines you could also use a ULN2803A integrated circuit to control them from the Arduino. If you really wanted you could design a PCB in Kicad or a similar program that fits onto the Arduino directly and get a really compact setup.
The IC mentioned above is also good for driving LEDs for building lights an similar use cases.
Very informative; and so glad it is working for you
Is it possible to automate the shunting process too?
Hi Ron , Enjoy all your videos, where can I download the sketch for my Arduino.
Is it possible to get a copy of the sketch you used? I’m interested in building a similar panel and would like to use the sketch as the basis to customize. Thanks
Good Job Very informative Ron thank you.
That is a great project very interesting
Very Good . But where I can get a copy of the Arduino Sketch . I not in programming with Arduino but I start to try. So is it possible get the sketch ? Thank You for the help.
Nugget has the exact same relay board set up to control the heaters/lights/fogger on his 🐍 tank. You remember Nugget right?
Im workingon Arduino code for crossover and wye interlockings and pannel board lights. I have yet to find a purpose build control that will control multiple switches in relation to each other.
Awesome Ron 👌 👏 👍
Speaking of which how do i find a good switcher engine for my Layout cause I've looked on the Midwest model railroad website multiple times and i haven't been able to find anything
Surely if you used the common of the relay as your output and you supplied the (NO) with+12v and the (NC) -12v from the ATX power supply then you would only need 1 relay instead of 2, you would need to control the voltage level after the output to control power levels.
HELLO RON ITS IS RANDY AND I LIKE U VIDEO IS COOL RON THANKS FRIENDS RANDY
You can run both relays for a turnout with one arduino pin
No doubt I'm showing my ignorance, but why not use LCC to do this?
Form C relays, NC/C/NO
likehow you did it any chance of downloading code
I am working on a new website which will include some free resources including this sketch. Coming very soon.
Oh no, you said Arduino. :)
Why Arduino over using Digitrax, NCE, DCC Concepts, etc... solutions?
A, because I don't have any of those systems. B, because I do NOT want to control them through my DCC system. C, because Arduino is a TON cheaper.
@@RonsTrainsNThings thanks for the response. I didn’t realize you were not using one of the main commercial products for locomotion control.
@@HumancityJunction No, I have an old MRC Prodigy Advanced² that has been upgraded a few times.
There is another way which will eliminate the second relay. What you need is the 12 supply and 2 1000 ohm 1/4 watt resistors for each tortoise. I can't draw pictures so use visualization. Draw a horizontal line for +12 volts. From that line attach one end of the 1000 ohm resistor to +12 and the other end to one of the motor leads on the tortoise and repeat for the other motor lead. Now run your wires from the tortoise to the outer leads of the relay. Finally run the return lead from the 12 volt power supply to the common or center lead of the relay. Now what happens is you are switching the +12 volt power from one tortoise motor lead to the other and the opposite lead is pulled to the +12 return. Energize the relay and it reverses the connections. The resistors limit the current to about 12 milliamps which is sufficient to run the motor . You can use the same circuit with a SPDT toggle switch.
One more thing, there is no chance of a short circuit happening since you are using only one relay. The resistors limit the current.
Dang Ron, too technical for this 27 year old lol I'll stick with Walthers Layout control until my brain can process what I just watched 🤣🤣
🤣🤣🤣 It is easier than you think.
Thanks for sharing the information but I think I hurt my brain ( just a small sprain but i'll recover) 🤣🤣😂😂🤷♂🤷♂
Ron, what is your thought process behind reading for a button press and then release? I think you are overcomplicating things! All you need is something like "if (digitalRead(button1) == LOW)" followed by your relay code, because even the briefest of presses is going to seem like eons to the Arduino (which is running such a simple loop many thousands of times/sec). Once the if statement condition has triggered (button1 has gone LOW) the Arduino is going to run the relay code to completion before it moves on, regardless of whether the button stops being pressed or not (which it won't be checking for anyway, it's busy executing the relay code). Whether the button *isn't* being pushed is irrelevant anyway, because the code isn't checking for that. All the Arduino knows is- button pushed -> put relays in x state.
Additionally, there's no need for debounce here because each button is linked to a single state. If for example you had a turnout that flipped its position when a button was pushed, *that* would need debounce, because it's a toggle. Yes, the simplified if statement I described above would run several times each push owing to the Arduino's clock speed...but so what? On the first loop it sets your relays to the desired state, on the second loop it effectively does nothing because your relays are already in the desired state, and so on.
Way to technical for me.It's interesting watching and listening to how you accomplished all of it though.
Normal on is not the proper phrase