Interface Arduino with Loconet for Model Railway

I want to interface an Arduino based Command station like the DCCEX CSB1 which uses an ESP32 to a Loconet which there does seem to be quite a number of options but the next problem is interfacing the Loconet back to I2C so I can connect PCA9685 modules to operate Servo's ... is there anything out there which would do this ... also it makes a bit more challenging as I use iTrain software which can interface to a USB to Loconet board and in iTrain I have address's 100 to 150 for servo's ...Regards John

Why do you want to use a PCA9685 to operate the servo's? If you need a Arduino to connect to LocoNet, than you can also use this Arduino to operate the servo directly. I2C is much more limited regarding the wire length than LocoNet. So place one Arduino near a couple of servos and connect it to Loconet and the servos directly. If you want to use the mrrwa/LocoNet library, you need an Arduino with two 16-bit timers, e.g. a cheap and small pro micro.
To easily move the servos slowly — e.g., for turnouts or semaphore signals — you can use my MobaTools library.

I already have 5 PCA9685 on my layout 0x40 to 0x44, the problem I have is they are run at quite a distance from the Command board like 25 feet from the CSB1 Command ESP32 the I2C connection does go to a TCA9548 MUX the input side is 3.3v and output is 5v and I am using 7 of the channels to split the I2C bus but due to the length of lead i'm having problems with dropping out I do have LCA4311 to boost signal but that seems to help a bit so the Loconet looked a good option but i'm unsure about one of the boards which drives the 2 x PCA9685 as the guy selling is only developing the sketch to operate ...so am looking for other options ...

John

“simplest” always is in the eye of the beholder.

  1. sprinkle Nanos throughout the layout, one per PCA9685 or cluster of PCA9685, interface with RS485.

  2. sprinkle pro Micros throughout the layout, interface via DCC(see post 2).

  3. sprinkle some variant of ESP32 around the layout, interface with PCA9685 or drive a few servos directly; use Wifi for comms. Have to deal with the 3.3V-5V signal issues, but it’s not insurmountable.

  4. put a few Megas on the layout, do more servos/node, fewer nodes. Still need a communication method

And probably a dozen more variants.

I2C is, as you’re finding out, a localized bus. Without grilling you on the details of your implementation, and on your cognizance level of the best ways to optimize I2C(best pullup values, communication speeds, wiring), I’d suggest one of the other methods.

But, the devil is in the details. Room size, layout topography, owner’s skill level at both electronics and code, all play into the ultimate success of your implementation.

I’ve done the RS485 Nano approach, with MCP23017 boards for Tortoises, and it works quite well. I’ve also got several Nano nodes with up to 16 servos and attendant buttons(analog string) and LEDs(WS2812D), all working quite well.

I now also have an 8 servo, 8 Touch Toggle Nano-based solution in the works, which can be expanded quite a bit if you use a Mega instead of a Nano. It also works with the ubiquitous TTP223 touch buttons. Still needs a communication layer for some applications, but I’ve left D0-D2 for MAX485 to be added down the road. This version allows use of the very common Nano breakout boards for connecting both the Touch Button/TTP223 and the servos.

There are many options. Sounds to me like you’ve gone partway down a road, and now want to refactor. Don’t try too hard to keep what isn’t working, instead try for the best solution.

Feel free to reach out by PM to discuss the nuances, if you’d rather.

DCC can also be done with the Nano solution. Only if John stays at LocoNet, pro Micros are needed ( at least with the mrrwa libraries ).

Quite right, my bad, I conflated DCC and LocoNet. Both are needlessly complicated protocols in my mind for what is needed; they offer simplicity of wiring at the expense of shoehorning a lot of unnecessary baggage into the small mind of a Nano.

DCC - the benefit of using DCC is chiefly in taking advantage of the rail-based comms, avoiding wiring any form of control network. But, DCC doesn’t readily support bidirectional traffic, so…

Loconet - if one already has Digitrax, then Loconet has the advantage of already being present on the layout, particularly if one is using distributed boosters or distributed throttle panels. But often the routing for those needs isn’t optimal for what is needed for turnout control, so the networks grow significantly anyway. If you don’t have Loconet, then why Loconet vs RS485? It will probably depend on other factors, like folding in other Loconet-capable devices.

For me, one or more distributed RS485 networks was the way to go; if I was starting today, I’d seriously look at doing it all via Wifi, but I’d want to build quite an experimental test apparatus before I committed.

As I said, simplicity is in the eye of the beholder.

That's all true, as long as you build all the electronics yourself. If you have a mix of commercial and homemade components, I think it's better to stick with “standards” — in this case, DCC or LocoNet.
In the end, it's up to John to decide. He knows his layout best.

1 Like

That would be my first thought, ESP32's with an ESP NOW network. You could deliver most protocols, that would not be limited to servos only, over a wide area with minimal installation