Seeking advice on how to connect many input and outputs

Hi everyone,

I'm new to electronics and starting a new project that involves handling analog input from over 50 switches and controlling 50 or more NeoPixels based on these inputs. This is the approach I had in mind, however, I'd greatly appreciate your suggestions and insights on the best approach to accomplish this effectively.

Input:

I plan to use a CD74HC4067 16 I/O multiplexer to read inputs from switches by cycling through channels to detect triggered inputs.

Questions:

  • Is the CD74HC4067 the optimal solution for reading from more than 50 switches, or should I consider alternatives like shift registers?
  • Can I chain multiple CD74HC4067 multiplexers together to accommodate more than 16 inputs?
  • What delays and limitations should I anticipate when cycling through multiple channels for input detection?

Output:

Based on input triggers, I intend to control specific NeoPixels either individually or simultaneously.

Questions:

  • I'm aware of NeoPixel chaining but concerned about reliability. How often do NeoPixel failures disrupt the entire chain?
  • Considering alternative solutions, which multiplexer would be suitable for controlling NeoPixels efficiently without limitations that can be controlled simultaneously?

I'm open to any suggestions or recommendations to ensure the most effective and reliable solution before buying the necessary components.

Thank you in advance for your assistance!

  • Is the CD74HC4067 the optimal solution for reading from more than 50 switches, or should I consider alternatives like shift registers?

Switches - you mention analog, but then talk of switches. Are these on/off devices?

  • Can I chain multiple CD74HC4067 multiplexers together to accommodate more than 16 inputs?

You can

  • What delays and limitations should I anticipate when cycling through multiple channels for input detection?

Phrased another way, what timing is acceptable for reading all your switches? Are these human-actuated?

Thank you for your quick response.

Regarding switches; they are digital yes, sorry for the typo. Would using a CD74HC4067 multiplexor be the optimal solution in this case, please?

Regarding chaining; How would I go about chaining them, please? And would I need any additional components to accomplish this?

Regarding timing; Yes they are human actuated and for timing I was thinking around 1 second to read the input.

Looking forward to your answers.

Okay. First questions.

  • Are the switches in a single location, or widely distributed?
  • Can they be arranged as a matrix(i.e. all momentary, pushbutton, push-to-close), or are there multiple types?
  • Even if all the same, momentary, push-to-close, is it possible for many to be pressed at the same time, or are they pretty much mutually exclusive, like in a bank ATM pin pad, where the numbers get pressed in a sequence?

As for the Neopixel (output) end of things, I have no failure data to share. It may depend on your price sensitivity. The cheapo strings available on Amazon may not be what you want; better products are available from reputable distributors, but expect the cost to be much higher.
Multiplexing Neopixels throws away their inherent advantage. I'd look at (maybe) running multiple strings if I didn't want a single failure to take down a whole chain. Since the most likely reason a pixel would fail is poor design/handling, I'd simply ensure I followed every hint the manufacturer gives - filters, series resistance, and in long string scenarios, multiple supply points for the power.

Consider the MCP23017 16 bit I2C GPIO expander. Or its little brother, the 8 bit MCP23008. Each input has an internal pullup resistor for the switch (no external resistors). Also there are pin change interrupts so polling is unnecessary. You can put up to 8 MPC23017 parts on the I2C bus.

There is also the SPI version, MCP23S17.

I agree with @camsysca. Put your switches in a matrix. You will need 16 Arduino pins. If your Arduino does not have those available, use 1x I/o extender chip like pcf8575, sx1509 or mcp23017. You may or may not need a diode in series with each switch/button, depending on how they will be used.

No multiplexers needed for ws2812 LEDs. I have never had any fail, but have never connected more than 100, so maybe someone who has thousands may have a different experience. The more you have, the more likely at least one will fail in the lifetime of the project. There is a type of ws28xx which can tolerate led failures provided 2 adjacent LEDs do not fail.

To answer your questions;

  • Yes switches will be in a single location with each switch spaced around 3 cm or so from each other (still deciding the distance).
  • As for the switches, they are all of the same type and can be arranged in a matrix, yes. There can be a maximum of 10 switches pressed at the same time and no particular sequence in how they can be pressed.

Regarding NeoPixels, understood, will read the manufacturer's guidelines and will chain them together. Thank you.

@groundFungus Thanks for your suggestion, I'll look into that.

@PaulRB Thanks for your suggestions too and for confirming about the NeoPixel. I agree, it's much easier to not use a multiplexer in this case.

You will need those diodes. 1N4148 would be suitable, for example.

Others will have better advice about whether a matrix has a hope of allowing this; generally, I'd say it's problematic, unless you have some control over where that 10 would be distributed. So, "maybe it will work".
As others have suggested, multiple IO expanders or shift registers might be more appropriate for this, then. There are advantages to the MCP23017 (chiefly, built in pullups), and disadvantages($). Sounds like your switches are in a concentrated space, so might be okay on a shift register of some form.
But, is this a commercial/industrial install, or a hobby thing in your own basement? If industrial, you'll want to consider the effects of static electricity, and a host of other issues.

Thank you and apologies for the late reply. All your suggestions have been very helpful and I'll give this a shot, so thank you all!

@camsysca It will start out as a hobby thing but don't want to exclude that someday it will be for commercial use.

If I may ask further, apart from static electricity, what kind of other issues should I be aware of and how could I go about solving such issues, please? I would do my own research but your help would be appreciated as a starting point. Thank you.

I'm no expert at this, and we know nothing of what it is you're doing, but:

  • consider carefully the conditions of use. Static electricity, vibration, temperature, humidity, power quality all can play havoc with well designed equipment, let alone hobby-level toys.
  • consider carefully the repercussions of software/hardware failure. Wrong data? Errant motion? Equipment malfunction? Equipment meltdown? Heaven forbid, injury?
  • self-inventory your limitations, and find resources to appropriately fill the gaps. Very rare is the person who can solo-produce a successful more-than-trivial product from start to finish. Those who might be able to still 'yield the floor' to other experts - it's faster, and more (competent) eyes on the problem rarely hurts.

Really, there are others much closer to 'the edge' in this area who can advise better than I. I'm just a retired jack-of-all-trades; most of the above is drawn from observing what went on around me, and why it did/didn't progress.

Thank you for the detailed answers as always and I will speak to an expert before proceeding any further to ensure none of these issues happen.

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