Railwy layout control

Hi all.

I'm building a rail model layout, and I'd like to manage the turnouts and signals through an Arduino Uno R3. I'm not a native English speaker, so I apologize in advance.

What I need to control:

  • 12 turnouts, driven by a single coil, DC polarity controlled. The power must be between 9 and 12v, 700 mah, with a pulse duration between 100 and 200 ms. The turnout position triggers the LEDs powering.

  • About 20 semaphores: they are two or three aspect signals, where the LEDs share a common anode. I want to simulate the old tungsten lamp behaviour, with slow power on and dimming.

I know how to do it in 'analogue mode' with DPDT momentary switches, relays... but the gradual powering on & off of 50 LEDs thrown me into the Arduino world, and in the future it would allow me to incorporate other things like block occupation control, etc. It's an opportunity to learn something new.

After some tests with a Uno R3 board, some motor drivers like L298N & HW-130, one Adafruit's PCA9865... I wonder about the clever way to implement it.

As they are a simple coils that must be energized full on / off for a few ms only, is a motor driver a waste and maybe a simple relay would do the Job? Is it advisable to command the motor drivers from a PCA9865?

Is a PCA9865 a good solution for the LEDs?

Thanks in advance for your time and help, and sorry for the mistakes I've surely committed.

Motor drivers are good for when you need to swap direction/polarity. Your application does not need to do this. For turning on/off 9-12V, the easiest would be to use a transistor, controlled by a pin on the Uno. Your specification of 700mah does not make sense for a coil. That is a specification of power. How many Amps does it require? That will dictate the transistor.

As for the PCA9865, it will give you 16 PWM pins so you will only get 16 dimmable LEDs. If you need more, you will need a second PCA9865.

Good luck!

Sounds to me like polarity does need to be swapped.

1 Like

I suggest a bigger board, but also a multiplexer for the LEDS. Learn about MOSFETS in order to make the LEDS look like old-style incandescent. L298 is ancient, look for MOSFET-controlled motor drivers (Pololu is a good supplier with lots of info)

  • Welcome to the group.

  • Always show us a good annotated schematic of your proposed circuit.
    Too often, words are not enough.
    Show us good images of your ‘actual’ wiring and you setup.
    Give links to components.

1 Like

I was fortunate with the turnouts I used; dual coils, low current (not even close to 500mA) and the energized coil was mechanically disconnected internally as soon as it switched. So I was able to get away with a ULN2803A Darlington array to control 4 turnouts (I had control over the input voltage so I had no problem with loosing a bit of voltage in the driver). Even so I used a capacitive discharge unit and a timed pulse on the Arduino to make sure the coil didn't end up being continuously powered by some freak failure.

You'll lose a bit of voltage with these. If that's a factor, maybe think about a more modern solution like a TB6612. If it's not, an L293 (not an L293D as found on many HW-130s) or SN754410 could provide a similar sized solution to the one I ended up going with.

There is also an international section here - is there any language more suitable for you?

You would need 2 SPDT relay modules per coil. Or one 2x relay module per coil. Or one 4x relay module for 2x coils. You get the idea. A single SPDT relay cannot reverse the current through the coil.

It's not inadvisable. It would work. There are other 16-channel i2c chips which might be simpler & cheaper, but keeping all your i2c chips the same also makes sense.

Hi.

Yes, the polarity have to be swapped, I'm sorry I didn't explain it properly

  • I’m old and a bit partial towards DPDT/SPDT relays.

Thanks a lot to everybody for your time, and thanks for all that info! Now I have a lot of options to study...

Thanks, my native language is Spanish. This was the forum I found looking for help, I didn't realize that there are those other options.

An L9110 dual H-bridge board (eBay/Ali/etc.) is a cheaper/easier solution than four relays. That, and a Mega could reduce complexity.
Leo..

1 Like
  • Admittingly I know nothing about model RR stuff including the terminology.

  • If I understand things correctly, this might fit what's needed.

  • The 12 turnouts would be connected to the terminal strips.

Edit

  • Changed relays to SPDT

It sounds to me that you are not (yet) proficient in electronics and hardware. My suggestion is to enlist in sites dedicated to this hobby:

https://groups.io/g/jmriusers/topics
https://groups.io/g/arduini/topics

From the sound of your post you may have a couple of years to get in the deeper end of this hobby :). But the bright side is that this is very rewarding.

Thanks, I'll gather info about MOSFETS as you suggest.

Thanks a lot LarryD!

Thanks. Yes, I'm barely starting to learn, thanks for your links!

That won't work if the solenoids need bi-directional drive.
These boards can drive two bi-directional solenoids.
Leo..

I'm a railroader too, and I don't like to have a big board controlling everything by itself. E.g. I use small boards like a nano near the controlled devices to keep the wires short - especially for the turnouts, but also for the semaphores. One Nano for a group of devices beeing nearby.
There are several model-railroad proven communication protocols like DCC or LocoNet to connect the different Arduinos. Look at the links @brice3010 provided.

[Edit] Of course, you still need a central Arduino that reads the control elements and sends the commands to the distributed Arduinos. But this Arduino does not need to know how to switch a turnout or set a signal.aspect. He only commands in which direction a turnout should be set or which aspect should be shown. This is how model railroads usually work nowadays.

1 Like