Close

Multiplexers: How to expand your input lines

A project log for NanoEgg Music Synthesizer

A powerful little music synthesizer with a classic look!

t-b-trzepaczT. B. Trzepacz 06/20/2016 at 10:530 Comments

Whether you are using the Arduino, the Teensy, or any other microcontroller, you'll probably have an occasion where you need more inputs than the controller can support. NanoEgg is somewhat of an extreme example of that, as it is currently designed with at least 42 knobs, a 24 key keyboard. a touch screen TFT, MIDI ports, audio output, and 2 control wheels. While I've worked to expand the number of I/O lines with my Megsy project, it is still more than the system can ever hope to handle!

Fortunately, there is this lovely device called a multiplexer that lets you select one channel of I/O at a time from multiple possible channels. I chose to use the 74HC4067, since it handles analog IO, and has a relatively large number of channels. Unfortunately, it was impossible to source a DIP version of the chip, but luckily for me there are some nice Chinese vendors on eBay that sell breakout boards; circuit boards with the surface mount version of the chip attached that long pin headers can be attached to for easy prototyping! I ordered these a few weeks ago and they finally came in.

The next step is to test it out, so I built this little circuit. While this chip will support 16 analog inputs, I got bored after eight and stopped there. Here is a circuit with the multiplexer attached to an knock-off Arduino Due.

To see the best way to wire everything up and how to code a demo, I found a nice reference page at bildr that explained everything.
http://bildr.org/2011/02/cd74hc4067-arduino/

While I realized that their code wasn't the most efficient, I integrated it easily into my existing keypad test code and optimized the output so that I could see the knob turning in action.

One thing I have noticed here is that, in comparison to the analog inputs on my Arduino Mega 2560 knockoff, the inputs on the Arduino Due are relatively stable! The jitter is only +/- 1, which can easily be smoothed out with some oversampling. This will give each knob the full range of 0 to 1023, or 10 bits. MIDI CC messages can only handle 0 to 127 ( 7 bits) so this is quite a bit more precision! This may enable me to do both coarse and fine adjustments of values with a single knob, allowing me to eliminate some of the extra knobs I have had to add and thus handle more input parameters without resorting to the touch screen display.

I suppose the next step is to design some sort of reconfigurable front panel than can be built as a printed circuit board, so that I can test different control arrangements. Progress!

Discussions