Guidance on Midi Board - 64 rotary encoder > usb midi > Abeton using Teensy 3.2

Status
Not open for further replies.

BambooSam

Active member
Hey guys, I am designing a large midi board project that will utilize 64 rotary encoder/push buttons. Has anyone done anything similar using the Teensy 3?

My biggest issue I think may be latency and how to get that as low as possible, and of course not miss any encoder state changes.

64 encoders * (2 bit pins + 1 button pin) = 192 digital pins that need to be read. So I would right off the bat need 24 74HC165 shift registers.
Do you think the Teensy 3.2 interfacing with 24 74HC165s will be fast enough to simply scan the pins and hopefully not miss any state changes? or is this going to be much trickier than that? Complex interrupt circuit?

What issues do you foresee I will run into? Any advice is greatly appreciated!

Also, does anyone know how to handle values being sent from Ableton live back to the midi controller? I am guessing it may just always send data after any change occurs to a parameter and send it to the linked usb midi board.
 
With a mechanical encoder, you typically have up to 5ms contact bounce anyway. So you don't need very high polling rates.

With fast enough shift registers, you can do something like 24MHz with hardware SPI or 6MHz with bit banging to read your registers - more than fast enough.

Using interrupts won't really be useful, particularly since you need to be worried about contact bounce.

As a starting point, I would look at something like a 500-1000Hz polling rate and perform debouncing along the lines of this:
http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html
 
You might consider using a 74AHC373, which would let you read 8 data bits at a time. D5 (MSB), D21, D20, D6, D18, D19, D14, D2 (LSB) work nicely as a multiplexed data/address bus, and properly wired you can grab 8 bits with two reads, two ANDs, and one OR.

If you use something like some 74AHC154's and some glue logic you could sample all the input bits pretty quickly, well below 1ms.
 
Anyone know of a 16 channel shift register that can notify the micrcocontroller via external interrupt of a change in state of one of the inputs? That would be a fantastic solution. I will never use more than 4 rotary encoders at the same time, so what I could do is once I get notified of a change, scan that specific shift register to find which one/s have changed then run a routine to constantly check those states for additional change, when one doesn't change within however many ms I could stop that routine for that specific rotary encoder. Simple. but I would need a shift register that can notify me of change, I dont know if they even exist.
 
Last edited:
I think if you're looking for a monitoring shift register you're headed toward FPGA-land.

Have you considered the 74AHC674? It's a 16-bit parallel-in, serial-out shift register. I haven't looked at it closely, but I suspect you could use Teensy pins for clock, load-strobe, and data, in a very tight data-acquisition loop. It would be pretty zippy, and you could do the "did it change?" in software.
 
Large MIDI controllers are a popular project for Teensy. Many people have built them successfully, but many others have unfortunately become lost in endless technical problems. By far the most common mistake is choosing a difficult-to-troubleshoot signal input path. Sometimes the difficulty is mundane, like a big rat's nest of same colored, too short wires and perhaps flaky connections, where attempting to fix one wire tends to break one or two more. Sometimes the problems are complex, like long shift register chains that can't really be debugged well without a logic analyzer or oscilloscope (and the knowledge & experience to use it). Usually these paths are chosen from a desire to save money. Often the focus is too much on the cost of electronic parts, which end up being a relatively small portion of the entire project, when you factor in the many expensive buttons, knobs, pots, and the many parts of physical fabrication.

Even if it adds some cost, I highly recommend taking a modular approach. Make each group buttons or knobs a module which can be disconnected and tested easily. If using shift registers or other electronics with memory/state, come up with a plan for how you'll test and troubleshoot. Components without internal memory/state, like mux chips, are much simpler to diagnose using only a multimeter or LEDs which show signal levels.

I know this is probably just stating the obvious, but do think ahead about how you will get inside your controller and get easy access to all its pieces and how you'll troubleshoot if things don't work. Spending a little more for quality connectors, wires, and electronics you can troublehshoot with the tools and skills you have can make all the difference.
 
Anyone know of a 16 channel shift register that can notify the micrcocontroller via external interrupt of a change in state of one of the inputs?

Not exactly a shift register, but take a look at the Microchip MCP23S17, a 16 bit I/O expander for SPI, it has configurable interrupt pins. AFAIR you can have up to 8 on a single SPI bus (they work with an address instead of Chip select, I think).
 
Even if it adds some cost, I highly recommend taking a modular approach. Make each group buttons or knobs a module which can be disconnected and tested easily. If using shift registers or other electronics with memory/state, come up with a plan for how you'll test and troubleshoot. Components without internal memory/state, like mux chips, are much simpler to diagnose using only a multimeter or LEDs which show signal levels.

That is exactly what I realized I should do, thank you for re confirming that. For the sake of simplicity and speed, I've decided to use multiple Teensy LCs because they are fantastic and so cheap to handle various "modules", then use a master teensy to communicate with them through serial, which will also communicate with the computer usb/midi.

So my goal now is to control 16 rotary encoders w/pushbuttons and a handful of ws2812s with a Teensy LC. I should be fine with using 6 74HC595s right? With proper programming I shouldn't be too worried about speed/latency?
 
Last edited:
I don't know if you have encoders yet, but these guys are on sale again. They work well with the T3.2 and T3.6 using the built in encoder library. Ground the middle pin, connect each outer pin to the Teensy digital pin with a 1000 pF cap to ground. I haven't tried any multiplexing schemes yet.

Note, I have no business relationships with these people. Just buy stuff when they have a sale. I have several hundred of these encoders already, but 20 cents each is the cheapest I have seen. I will get more!

http://www.goldmine-elec-products.com/prodinfo.asp?number=G20056C
 
Status
Not open for further replies.
Back
Top