Processor I/O Limits - Multiplexing

Hi all!
First time post. I am building a model train set for a Christmas display. I've watched Jimmy's DIY brilliant video https://www.youtube.com/watch?v=rcSKkVcci4E about block control. But he is using one Uno for each block. I'm wondering if I could put my 16 blocks into one bigger processor and use
for ( i=0, i<15, i++) {
};
to index between all the different blocks.

My problem is I haven't found a processor that has multiple I2C busses for 16 MSP23017 mux's. I possibly will even need a third buss for Wii Nunchucks to control the trains.

Thank in advance for any advice you can pass along.
Best, Geoff

Welcome to the forum

Why do you need multiple busses for I2C ?

Surely the whole point of using a bus is that multiple devices can be connected to it and controlled independently

What you will need is enough pins to allow each device connected to the bus to have its own device select pin. A Mega would fit the bill with its multitude of digital pins

You can put 8 MSP23017s on one I2C bus by setting the A0,A1,A2 pins in hardware, so each of the 8 MSP23017s has a different address.

Or you could use the many IO pins on a Mega to select which of the MSP23017s responds.

And a Teensy 4.1 has 3 seperate I2C busses.

I've estimated 170 digital I/O points. Some of them I may PWM them for speed control or LED brightness control. I'm hoping the MSP23017 can handle that but I haven't completed my research on that issue.

For PWM you'll need something like the PCA9685 or you can use addressable LEDs like the WS2812 or PL9823.

Didn't know about the Teeny. Thanks for the suggestion.

Its very fast , heaps and heaps of memory, 8 Serial ports, 3 I2C ports, 3 SPI ports (one used for the SD card) etc etc.

Its also 3.3V logic so more suited to the average modern electronics.

I see AliExpress carries multiple revisions at multiple prices......
I then found these comparisons: https://www.pjrc.com/teensy/techspecs.html.
I was originally planning on the ESP32-12F which are significantly cheaper than the Teensy.
BUT now I have to do more research.... Really appreciate the introduction to this processor.

Might have been good to mention that in the first post ?

If what you are designing has an "estimated 170 digital I/O points" then comapred to the cost of the components, wiring and time for all that, then the cost of the microntroller is insignificant.

Sorry, of course. Next time I will write a word file first. I was attempting to keep it brief but should have included the processor I was thinking of. VERY much appreciate your feedback

The video shows 6 output pins for the two R, G, and Y lights, and 2 pins for the two sensors. You won't need the four pins for communication with adjacent blocks. That means 8 pins per block so maybe 7 or 8 blocks on an Arduino MEGA.

You could use a Red/Green LED:

to get down to 6 per block. Still a lot. You couldn't put 16 blocks on one MEGA.

You could use Neopixels to get down to 1 pin for ALL lights and get you MANY colors instead of three. That reduces the pins per block to 2 (for the two sensors) and fits 25 or more blocks on one Arduino MEGA.

It's not hypothetical. I have a full 3 colour 3 signal "searchlight" aspect display sketch that drives 3 Neopixels as the signal heads. It also includes basic block occupancy inputs for control.

I have another one for separate R,G,Y signal heads ... 4 signal indications using 12 PWM outputs of an STM32. Thus, two separate masts bearing 6 signal heads, and able to display all the standard block aspects using 2 signals.

The STM32F108 is much better suited for this task than the AVR, it has more and better PWM's. The increased processing power allows gamma correction, searchlight filter movement simulation, and incandescent on/off fading as well.

All those projects were based on the "distributed module" paradigm, where ABS logic is situated and connected along the track (just like the real thing).

I considered the possibility of consolidation in something central, like a Mega, but lost interest after thinking about the spider web of wires that would sprout from it.

If you are only implementing ABS signalling, centralization doesn't make sense for the model, for the same reasons it didn't make sense in the real world.

If one Uno per block doesn't make sense, one Nano or Pro Mini per block surely does.

That would not reflect true railroad practice. There are only 3 colour lights made with an internal mechanical RYG filter strip, and individual monochromatic lights in separate housings.

The only 2 colour light that is even close to real, would be a short "dwarf" ground mounted signal. And, only in certain track positions. Yellow is important, it's a "clear to stop" indication. So if you use a red/green LED you should also provide some way to drive both R and G to produce Y as a light mixture.

It can be quite tricky to obtain a mix that really looks yellow. The dies are in different places in the LED package and so don't diffuse perfectly. So it's hard to make the mixture convincing. It works best if the LED is driving some kind of light pipe. The Neo's have the same problem.

In reality, the real railroads (at least in North America) are rapidly decommissioning searchlight (multicolour display) signals, and replacing them with (ironically) clusters of single LED lights. So, in many places the signals now look almost the same in 2022, as they did in 1922. :slight_smile:

Friends, I can't express my appreciation enough. You have given me SO much information and advice that would have taken me weeks to find by surfing. (And I doubt that I could have found all the nuances that you have shared.) My completed project will be shared with Jimmy which I expect to by running by Christmas.

Kudos for starting in July and not hopping onto a forum mid-December in a panic :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.