From my research I've seen two main ways of expanding the number of I/O on a standard Arduino. I2C and chaining latches are the main methods I have seen.
So here is what I am trying to do, and I am interested in any suggestions that are constructive.
I want to have 16 rotary encoders each with momentary switches.
For each encoder there are 2 8 segment displays(7 segment plus decimal).
16 momentary switch on top of the ones on the encoder.
There will also be 16 LED to indicate which ones are on or not.
The idea here, if you are not familiar with it is to have a step sequencer made popular by Roland X0X series of devices from the 80s so I also need to be able to write midi out, but for now Im looking for a good way to approach the problem with the limited i/o.
Now I know I could get more i/o from a mega but in most of the cases for this it doesn't seem like there is a reason I can not use one of the i/o expansion methods.
So let me explain my thinking on how I want this to work.
Rotary encoder controls the note A0-G9 with the decimal on the first being a sharp/flat and the other being indicating if it's a glide note.
If you press the encoder in it switches to controlling the level 00-99 of that note.
The other momentary buttons will be used to turn on/off the steps and any number can be pressed at a time. This toggles the state and the state on/off will be represented by the respective LED.
Hopefully someone has some good ideas for me, I've already had a single encoder running with my lcd as the output so I wan't relying on the serial console for output.
Reading 16 rotary encoders without missing a "click" is a very demanding task. Add to that reading 16 pushbuttons and controlling a large number of LED's.
To do this at a decent speed you would probably need to use optical encoders that do not need debouncing.
You are right it would be taxing, however we can assume that if a rotary is being tuned no buttons are being pressed and I don't know about you but I can only turn two knobs at a time. I skipped contortionist class.
The 16 on/off buttons however would be more of an issue as it's not uncommon to press 4-8 at a time. I was thinking a buffer of some sort shouldn't affect response time too badly.
So in this design I am ok with only one rotary being functional at any one time.
Contortionist or not, even if you only turn two of the encoders at a time, you would have to check all of them, as the Arduino board can not predict which two you are going to turn.
I'm not saying this is impossible, cheap MIDI controller boxes with loads of encoders are all over the place, but i don't know what kind of processors are powering them.
Ok, it seems I have to build a logic table first for the encoders. This is just for 2 encoders, and if I am understanding encoders correctly this is the complete state table. For 16 encoders I would need to monitor 32 bits. At this point it may be more logical to use a separate microcontroller that has 32 interrupt channels then just send a 32bit word to man controller or something similar. Any suggestions on doing that?
There is no micro-controller in the world that as 32 interrupts, you can set a timer interrupt and poll all your encoders at something like 10Khz, if it is humam interface then that is more than enough.
I would make 16 modules, each with the smallest ATtiny that will do the job of reading the encoders/switches and controlling the LEDs. Hook up their MOSI/MISO pins in series then every 10mS or whatever blat 16 bytes to them with LED info while at the same time receive 16 bytes with switch/encoder info.
I haven't tried this serial SPI trick but see no reason it wouldn't work.
Well you need some kind of IO expanding chip or maybe go up to a Mega, an ATtiny85 costs around $4 so yes that's $64 to start with. But with all those encoders and displays it's not going to be a cheap project, and the modular approach allows easy swapping of modules for in-the-field maintainance.
I guess it depends on some other factors like budget, is this a commercial product, a one-off or big production run etc.
It's a personal project that once I have ti working I will post all the docs and code to the public. Everyone wants a TR-909 and the step sequencer used in these devices is one of the most sought after but no one wants to pay the outrageous price for whats now a collectors item.
So aside from doing it on the tightest budget possible it's a learning project for me. I bought the Arduino only know ing the bare basics you have to know to get a HAM license, so my electronics knowledge is defiantly at the beginner level.
Richard mentioned port expanders, have a look at chips like the MCP23017 (has interrupts) and MAX6956/6957/7300 (no interrupts), PCA9555, PCF8574, PCF8575C (have interrupts).
I need to read more on rotary encoders though, Im not sure I totally understand all the aspects because I was told a common clock could be used on all the encoders but Im not sure.