Maximizing the number of Piezo using 8 CD405xB Multiplexers

Hi, I am a new Arduino Mega user who is building a 64 key Marimba.
In order to get that many keys, I am adding multiplexers.

My goal is to be able to play (4) of the 64 notes "at once" (Because I play with 4 mallets etc)

Does anyone see an issue using: (8) Dual-Circuit 4x1 Multiplexers (CD405xB)
• Each multiplexer would support two notes at a time (1 per circuit). 16 Digital control pins needed for this. And then I can assign each piezo to notes on each bank of (4) that are not likely to be played at the same time.

Essentially this would allow me to play at least (4) notes as a time unless (2) of those notes just happened to be within the same bank of 4. Is that the best way to go here?

Thanks,

Justin

What you have not explained, is what you want these multiplexers to do - is it for input, or output?

Almost certainly you should be using something else such as shift registers.

Thanks Paul,

Multiplexers to allow the use of 64 Individual Piezo Sensors to be connected to the 16 analog inputs of my Arduino Mega2560 to be triggered when the Marimba keys are played and heard through Garage Band.

Also that happy face was not intentional.

I meant:

Does anyone see an issue using: Eight Dual-Circuit 4x1 Multiplexers (CD405xB)

Thanks!

Justin

And also be able to play softly and loudly, not just ON OFF

Thanks!

Justin

Besides being slow?
I'd go with 8-channel external ADC read via SPI.
Example, MCP3008, MCP3208

Thanks for the reply CrossRoads,

As a newbie, I am doing my very best to understand this here.

I am looking at all the possible posts, but I am simply having difficulty getting a precise understanding here, so I appreciate your time.

I have read many notes with people looking to expand their inputs and I/O, some using Multiplexers, some with Shift Registers, and some with ADC.

I found this:

Pro's of using a multiplexer:

  • yes, it is faster than a serial shift register
  • there are analog versions
    con's of using a multiplexer:
  • uses more pins (for 40 sensors you'd need at least 7 pins).
  • you can only get data from 1 sensor at a time.

Pro's of using a shift register:

  • they can be daisy chained for a large number of sensors
  • only uses 3 pins, no matter how many bits
  • you can get data for multiple bits at the same time
    con's of using a shift register:
  • digital (1 bit per sensor) only
  • takes a little more work to get the data (slower)

• First, would you be able to add the Pros and Cons of using ADC to this?

• Second, I guess what I still don't understand is which options will allow sensitivity readings on Piezo from 0-5V instead of just High Low?

• And finally, Paul said that using eight multiplexers would be "slow". Can you give me a real-world example of that speed? For example, would it be slow compared to a super fast computer but is still really fast for playing drum rolls, or "slow" like I would get 1 note per second slow? I find it confusing because I read Pauls response that shift registers are faster, but the note I pasted in says multiplexers are faster.

I hope these questions makes sense. Still looking for the definitive how to guide to choosing between Multiplexer/ADC/Shift Registers etc.

Thanks all!

Justin

MCP3208,8-channel mux into fast ADC, needs 24 clock cycles in 3 SPI.transfers at 2 MHz clock rate for a 12 bit read.
24 * 1/2000000 = 12uS. Plus maybe a couple uS to result of 2 SPI.transfers (byte) into an int for use. Total time sample all 64 notes, about 1mS, so around 1000 samples/second. 64 channels = 8 chip selects + SCK/MOSI/MISO. 1st byte out is channel info, 2 bytes back are the data:

digitalWrite (ssPinX, LOW); // replace with direct port manipulation, ex PORTD = PORTD & 0b11111011; for PORTD bit 2
SPI.transfer(channelSelectInfo); // data out on MOSI
upperNibble = SPI.transfer(0); // 4 bits of data in on MISO, 0b0000NNNN
lowerByte = SPI.transfer(0); // 8 bits of data in on MISO, 0bLLLLLLLL
digitalWrite (ssPinX, HIGH); // ex PORTD = PORTD | 0b00000100;
array[0] = (upperNibble <<8) +lowerByte; // resulting data: 0b0000NNNNLLLLLLLL
// repeat 64 more times for array[1] to array[63] - don't put in a for loop

Vs 10-bit analogRead() that takes 110us. And you need to control the muxes in front of the ADC channels in the uC before performing that read. Time for just reading the ADCs (not controlling muxes) = >7mS, so less than 142 samples/second. Needs 8 analog inputs + 3 address lines to the CD4051, and takes 400nS (6-7 clock cycles) from address change to channel path change being ready.
Which do you think will seem more responsive?

Thanks so much for all the info!!

While I review that, which make take me a while to comprehend, I do just want to confirm from a real world standpoint that you are talking about using 64 Piezo sensors into 8 MCP3208, which then get connect to 3 Digital Pins (per MCP3208)

• Can you please confirm that doing this would allow more that one key at a time per ADC? And if not, would it make sense then for me to use (16) of these to spread out the 64 keys as much as possible?

• Also, Can you please confirm that doing this would allow sensitivity on the piezo sensors 0-5V versus just HIGH and LOW?

Thanks so much!

Justin