Reply to How many inputs is too many? Let's find out!

How many inputs is too many? Let's find out!
Hey all!

I've been planning my 'mega controller' for a few weeks, and just started to plan out the circuits. I asked myself a question that I didn't know the answer to... How many inputs can be hooked up to an atmega chip before things start to slow down.

It is theoretically possible to have virtually unlimited inputs, by daisy chaining multiplexers, multiplexing multiplexers, and other various methods... The bottleneck lies in the microcontroller and how fast it can process things. Too many inputs and you'll get latency, missed button presses, and other problems.

We all have dream controllers (my current one has over 200 led's, 2 lcd displays and nearly 200 controls), but since you need to hook these things up to something, it helps to know the limitations of the controller.




I currently have 8 CD4021's (digital multiplexer) and 6 CD4051's (analogue multiplexer) hooked up to my arduino (using an Atmega328 microcontroller). This currently provides 64 digital inputs and 48 analogue inputs, using only 6 digital pins and 6 analogue pins

Since the atmega328's only have 6 analogue inputs, I've reached my limit on the analogue side, but the digital side has plenty of breathing room left...

But wait! There's more! I said I hit the limit on the analogue side, but I wasn't really telling the whole truth... The CD4051 provides 8 analogue inputs using 3 digital pins and one analogue pin. Normally you would hook up a bunch of pots or faders to the CD4051 and call it done. What if you connected 8 CD4051's instead? It would require 3 additional digital inputs, but still only one analogue input.

Grade 7 math tells me that 8 x 8 = 64 analogue inputs per analogue input pin on your arduino. 6 analogue inputs times 64 = 384?!?! So using a total of 54! CD4051's, 6 digital pins and 6 analogue pins gives us 384 analog inputs! My theory is that each 'level' of CD4051's would only require one additional set of select pins on the arduino... You would be using a bunch of 4051's, but you could get a few thousand pots hooked up with a few hundred of them

Of course it is completely insane to take it to that level and I will likely only try a single 8x8 setup for proof of concept benchmarking. I'll have pictures and bench mark results as time goes on

For now though, my current tests are giving me very pleasing results.. Analogue inputs can be read at 34uS per input + 776uS, so right now I am scanning 48 analog inputs in 2408uS per iteration. BTW, uS = microsecond, one millionth of a second...

I haven't benched the digital inputs yet, since none of my button code works with 64 inputs

Pic: 6xCD4051 (top right); 8xCD4021 (top left/bottom)

You need to login in order to write on our forum

<< Cancel

Copyright 2012-2023
DJRANKINGS.ORG n.g.o.
Chuo-ku, Osaka, Japan

Created by Ajaxel CMS

Terms & Privacy