Arduino use in a model railroad... Noob hardware questions

As the title suggest, I am new to Arduino and the hardware capabilities and options. I have several goals I am trying to accomplish which can be done with switches easily enough, but I am hoping to learn abit about Arduino to see if I can step it up some.

The train layout is current DC for a reason, my son is 4yrs old should say it all lol, I have this train yard with 4 legs. If you look at the 4 legs starting with 1 on the left top, 2 on the Right top, 3 on the Left bottom, 4 on the Right bottom, I want the following....

All off
Track 1 & 2 On
Track 2 & 3 On
Track 3 & 4 On

Looking at the picture, imagine the 2 passenger cars were missing and I wanted to park a train from the inner loop in there spot on leg 1. But I have 3 other legs with trains on them. In DC, this becomes an issue. Alternating between track 1 & 3 or 2 & 4 is easy. But I need to be able to turn off track 2 & 4 altogether to avoid either of those 2 trains from moving.

I really need some form of relay solution with a On - Off - On like a DPDT switch. And the only way I see doing that is with 3 relays per leg. Where 2 relays switch 1 rail of the 2 legs, and 1 relay turns off power to both commons of the 2 relays.

This brings me to my next question, regarding 5v relays (I saw blue ones), what is the duty cycle? Can they remain in the Normally Open state for half a day?

Since this is DC, voltage starts a 0v and goes to 12 or 18v (I dont recall), and max current for the entire layout is 1 Amp. Each train takes about .3amps at full speed. So I know the 3 terminal side of the relay is strong enough. But what about the arduino side, can I trigger the relay and leave it there for an entire day of running trains?

More questions to come including stepper motor control as well as stackability. The other big question, can any of these relays and motor controls be addressed by digital addressing.

Thanks,
John

Can 1 Arduino control another? Say i have smaller Adruino's on the layout with relays and such, and a Arduino at the control where the user switches are located?

1 Like

Can 1 Arduino control another?

Yes, but that is a way too complicated method. For the size of your layout, you can use multi relay modules like this

Since they're normally open sitting on a shelf, I assume your question is "can they remain closed, with the coil energized, for half a day?"

The answer is try it and see. One of the drawbacks of the super-cheap arduino accessory hardware is that the reliability is... variable. It will probably work, but that's not something I've ever tested.

Do you have a recommended one which could remain energized all day? Once this is installed, gaining access to the unit will be difficult.

Thanks

This is what I am looking at. But with 4 legs and the desired control I want as compared to 2 DPDT switches I would think I need 6 relays (this is a correction from above statement of 12).

Not really. As long as the voltage is low (less than ~50V) it should be safe. AC vs DC makes no difference. High voltages can be dangerous, either DC or AC. But, anyway, model railroad sets tend to be DC, don't they?

Naw, DCC which is a multiplexed Digial system is really cool. Constant power applied to the rails, and digital controllers send packets to the trains via the rail to tell the train what to do. 2 Trains on the same track going different directions at different speeds with Sound and Light control.

Going DCC would solve all my problems. Just add track power. But also would defeat the purpose of my learning. Also DCC can be quiet the investment of which I have already. When I build my new 10ft x 20ft layout, I will add his to my DCC setup but that is a year down the road. Meanwhile he can learn on a DC layout. Currently with the individual power districts, and multiple train controllers, him and I can both run different trains. But this lader and the passenger loading tracks need some additional control.

So there is quite the price difference in options. Some say get the cheapest as they are all the same, and then there are those who say, do it right and buy name brand. The uno Rev 3 I found is $28 on this web store as well as Ebay. I found a compatible Uno Rev3 selling 2 for $20. The 4 relay shield on the other hand, is $27 each on this web store, and as much as $35 on ebay. And compatible relay shields for as low as $8 each.

All of these prices are for NEW items.

How do I know what is safe to buy?

1 Like

Not needed to have 2 relays per track, you just have to interrupt one side of a track with 1 relay.
I have a railway with 40 tracks running in an automated way 6 or 7 trains with 2 Arduino mega.

Now you bring up a good point, and something I considered but disregarded due to concerns. Right now the yard ladder is electronically isolated from the rest of the layout with abs plastic (I think). My layout has a single common rail with all power districts including the yard. And I have a Atlas Selector Part# 215 which allows the user to choose which of the 2 DC controllers supplies power to that power district.

With this new addition, I was thinking it may be a better idea to see if I can completely isolate both wires, but upon thinking about that with out giving it a independent dc controller, there really is no reason to touch both rails.

And if I only have to switch 1 rail, then I would only need 1 relay to switch between the legs, and 1 relay to turn off that entire side by cutting power to the common post of the first relay.

If this is a good solution, 1 Arduino Uno with a 4 relay shield board would cover all my needs on this section of the track. Then just to write the code where 2 single momentary switches can toggle a 2 leg pair.

I should further clarify "...electronically isolated..."

I have 4 power districts where both rails are isolated between the districts with insulating joiners. Each power district is fully soldered.

All 4 districts then have feeder wires where one is a black wire and identified as a common, the other wire is of each district is a different wire (Red / Green / Yellow / Blue). Giving me 5 wires. My Atlas selector switch takes in a single wire from 2 controllers in a SPDT manor and sends to the layout depending on what controller is chosen. Or turned off if in the middle. The other wire of each controller is joined as the common and attached to the common black wire.

I always suggest your first one should have the microcontroller IC in a socket like the one below. That way you can replace it if you fry it.

You may be in Mega territory though. A mega has more control pins.

Well, I pulled the trigger and bought a Uno R3 with a 4 Relay Shield. After thinking thru my thoughts as I replied to MBaeten, I reconsidered my concern and opted to just switch 1 rail
as he suggested.

Now 1 relay will be used to switch a single rail between 1 pair of track legs using all 3 terminals, and the second relay will be used to cut the power to the common terminal on relay 1. With the need to control 2 pairs of track, I can get by with 4 relays.

This site has a lot of useful circuits (non-MCU) that can help you understand the wiring, and also has some circuits you might use:
Rob Paisley's Circuits

Okay. Going forward, please post diagrams. This kind of verbiage requires a mental reconstruction of the circuit, it's error prone.

Noted

Ok, after a engaging PM session with a user on this forum, lets reset and break this down to its simplest form and this time I am not going to go after too much at 1 time.

As a result of this PM session, I want to make something clear. I am not asking the community to develop my project as it was suggested, I am treating this as I would at work in a Engineering Design meeting. Ask for a bunch of smart people with various specialties in diverse skill sets to provide knowledge and understand so a goal can be accomplished. And I hope to learn alot which then improves my value to team.

Goal:

  • To simulate a DPDT switch (On - Off - On) with Ardunio between 2 units in a black box.

Load Env Power:

  • Variable power supply between 0 and 20v DC with a max of 1A

Load:

  • BlackBox with 2 internal units which alternate power needs. Each unit uses no more than 500mA max.

Restrictions:

  • Not so much a restriction as its a preference. I favor stackable solutions such as shields vs external boards. Reason being, its a cleaner look and will take up less space.

  • Not willing to build the external board/shield. Must be able to buy. My soldering is horrible as a result of medical reasons.

  • Reliable Hardware solution, not willing to purchase in bulk because its cheap. I have no interest in replacing at a cadence to save a few bucks.

  • Must be able to turn off the entire black box.

Blockers:

  • New to the Arduino environment hardware options.

  • Dont know the vendors with reliable hardware

Questions:

  • Are there other options other than mechanical relays such as SSR's which can have the same functionality with NC/NO?

  • Asked before, but adding here. What is the Duty Cycle of the relays when in the energized state? I believe above I was told 100%

  • Regarding relays, I have seen the term NC (Normally Closed) and NO (Normally Open). I can assume that when energized the NO is now closed. When posting questions regarding these kinds of relay, how is it best to identify what relay state I am talking about?

  • Follow Up, what is the common terminology when talking about relay?

  • Does the load being a motorized device impact the solution for electrical feedback reason?

Additional Info:

  • I am in IT with a strong background in Software Dev for use in AD, Server, and User management. What I have seen on the programming language, that seems to be the easiest obstacle to over come. Capabilities of the hardware is where a lot of learning will be needed.

You want to dictate the terms of engagement here. That is not how it works, at least with the knowledgeable people that contribute here. If you want people to join a "team", you will have to provide some kind of motivation, since it's basically for a pet project, it will likely have to be monetary. Thus, if you want to pursue it under the stated terms, you will never get any cooperation unless you request a move to "Jobs and Paid Consultancy" and state your offer.

Alternatively, you can just post your project details and questions, following closely the advice of the forum guidelines documents, and pursue this thread as a typical project topic like the other 1,000,000 here.

2 Likes

These forums were designed to help users with specific problems.