Massive 256 analog input MIDI controller - Arduino Mega - losing voltage?

So as the title suggests, I am building a rather large 256-max input MIDI controller with the Arduino Mega for an old and beloved synth that never had proper knob per function capabilities.

Basically I have been able to do a lot with the Arduino Mega and I've been able to connect 16 individual MUX chips which have 16 inputs on each. Everything seems to function properly in my setup and the MIDI library (albeit kind of lacking in some documentation) is pretty straight forward.

Disclaimer, I'm a programmer not an electrical guy and new to Arduino.

My issue is that when I connect about 40-ish analog inputs to the Mega and I turn all the pots all the way to the high position then when I wiggle a various pot, the data received diminishes and loses its 0-1023 range. And is instead in the 0-960 range. Is this normal?

I am powering all the analog pots via the Ardiuno Mega's 5v rail. Is there another solution for this? Am I running out of voltage when all the pots are turned up? Of course, if I am running out of juice then what am I todo when I try and connect all 200+ pots?

Any help on this would be greatly appreciated.

Please show a schematic (photo/scan of a hand drawn one will do). Which value are your pots (40 1k pots might indeed be a little much as that would be 200mA)? Anything else connected?

Hey thanks for the quick reply,

So I have about (6-7) MUX chips and around (40) 10k pots connected. I dont have a schematic of the complete circuit just yet (I will upload when I have soon) But basically its a bunch of MUX chips going to 10k pots (because I heard that 10k is a better resistance for getting the proper values for MIDI controllers).

5V/10000 x 40 = 20mA. Should not be a current draw issue unless they are wired wrong.

The 5V and Gnd should be the outer legs of the pots, and the wiper from the middle going to the mux. Current flow should be constant, and very small. 0.5mA/pot with 10K pots. With 256 pots, only 128mA.
What is the mux chip being used, and it’s current draw?

Here are 5 drawn up for example into a 8-channel part. 16-channel would be similar but with 4 select lines.
Pots_MuxChip.jpg

10k, 0.5 mA per pot, so that's 20 mA for forty of them. No problem there. But if you go for 256 of them, that's 128 mA. That's a lot for an Arduino, and not recommended.

How much power do those MUX chips take?

Solution: external power supply for those chips. Use a 7805 or similar regulator and you'll have plenty of clean power for your MUX chips. You may need to add a heat sink though, depending on how much power your really draw and your supply voltage.

The Mega itself uses about 70mA. 128mA more shouldn't be a problem.
The muxers run on fumes.
Power the Mega with 7.5-9volt regulated on the DC socket.
You might have to read the analogue pin twice, and use the second reading.
That many pots and chips also means a large area and hum pickup.
A metal case, grounded to Arduino ground, might be needed.
Leo..

Am I running out of voltage when all the pots are turned up?

That sounds like a wiring layout problem. It sounds like you chain the 5V and ground from pot to pot.

I dont have a schematic of the complete circuit just yet

You have to draw a schematic before you know how to wire it up. If you think you don't then you are going to have a hard time learning electronics.

Stable values and a range of 0-1023 might not be possible, but that shouldn't be a problem.
The right code can "fix" a lot. Don't know how many values (resolution) you expect/need.
Leo..

Thanks for all the help everyone! I was using a very crude sketch of the schematic and I have since recreated everything in Fritzing. I know this is not a technical schematic (because I'm not entirely sure how to do them) But this is how I have everything wired up at the moment.

My goal is to have all 6 ribbon connectors controlling front panels with 39 knobs each (currently one is shown). And I hope to have the 7th controlling master/global functions. Hopefully the layout is pretty self explanatory, let me know if you have any questions.

CrossRoads:
What is the mux chip being used, and it's current draw?

I am using the CD74HC4067 MUX chips

wvmarle:
How much power do those MUX chips take?

Im not sure, 60 - 270 Ohms perhaps? I will look into the 7805 regulator. Is there a simple diagram for using one with an arduino for powering everything.

Grumpy_Mike:
That sounds like a wiring layout problem. It sounds like you chain the 5V and ground from pot to pot.

Yes, your right. I am chaining everything together. I have uploaded a Fritzing sketch for reference. Let me know what you think.

As usual, that fritzing diagram is totally unreadable. Can't say anything sensible about the schematic.

ndstudio:
Im not sure, 60 - 270 Ohms perhaps?

I will look into the 7805 regulator.

60-70ohm is the "on" resistance of a single switch. Not relevant for this project.

Cmos (HC4067) is low power, unless you push the switching frequency.

An 7805 supply could a bad idea (could upset the ratiometric relationship of pot/Aref), and is not needed.
Leo..

Well for a start you have not got a single decoupling capacitor in the whole of your circuit.
Each chip needs a 0.1uF ceramic capacitor between the power and ground pins. Then you need a couple of larger capacitors, say 100uF scattered about the circuit especially at the end of runs.

Not sure how this is constructed, is everything soldered up? What gauge wire are you using?

What voltages do you measure at the end of the chained power rails?

OP seems to be using the Sparkfun breakout boards (at least that's what Fritz tells me).
The have onboard decoupling.
Leo..

Yes, but you still need the large stuff.

Sure, the 5volt rails to the posts could also do with decoupling.
A ratsnest like that could be a perfect aerial for hum/hash.
Leo..

Thanks for the replies. Yes, I'm using MUX breakout boards. These actually, 16CH Analog Digital MUX Breakout Board CD74HC4067

Grumpy_Mike:
Then you need a couple of larger capacitors, say 100uF scattered about the circuit especially at the end of runs.

I'm not exactly sure where that would go in the circuit, when you say end of runs do you mean when the GND and 5v are at the end of the literal circuit?

Grumpy_Mike:
Not sure how this is constructed, is everything soldered up? What gauge wire are you using?

Yeah, I have everything you see in the diagram wired up, everything is in a prototyping phase so theres lots of hardened cardboard and tape for the construction :slight_smile: (I'll take some photos here soon) I am using rather large gauge wire on the front panel but there is a standard ribbon connector intercepting everything thats going from the main MUX controller board to the front panel. (All the white wires in the diagram are the ribbon connectors) So I'm not sure if that has anything to do with it.

Grumpy_Mike:
What voltages do you measure at the end of the chained power rails?

I have been measuring everything by the data that I'm getting within the Arduino App. I'll measure the resistance I"m getting at the end of the rails next.

when you say end of runs do you mean when the GND and 5v are at the end of the literal circuit?

Yes

I'll measure the resistance I"m getting at the end of the rails next.

Measure the voltage not the resistance. And while you are at it measure the voltage on the wiper, then the same electrical point on the multiplexer input and then the multiplexer output. Change the software so you have a fixed multiplexer selection when you do this trace back.

Ok so I measured the voltage from two points

  1. Arduino GND -> Pot 5v
  2. Pot GND -> Pot 5v

All readings were the same.

However, I think i know where the issue is coming from. Turning the Pots had no effect on the over all voltage but when I would switch on one of the toggle switches then the current would drop just a hair and if I switched on all the toggle switches then the current would drop even more. Here are my readings of this.

All pots and switches on: 4.75v
All pots and switches off: 4.94v
Only pots on: 4.94v
Only switches on: 4.75v

So obviously somethings up with the switches and how I have them wired up. The circuit for the switches are really simple. I'm going

5v is going to the switches center pin
GND is going to a 220ohm resister, then after that I have my Dataline and the other end of the resistor going to the switches bottom pin.

Also, here are some actual photos of my setup if that helps.

Ah, now we have toggle switches. Please draw a full diagram and post a picture / scan of it. How many of them? Roughly 20mA per switch (based on the 220 Ohm). Also powered from the Arduino?

sterretje:
Ah, now we have toggle switches. Please draw a full diagram and post a picture / scan of it. How many of them? Roughly 20mA per switch (based on the 220 Ohm). Also powered from the Arduino?

There are 10 total toggle switches and, yes they are powered from the Arduino 5v pin. Heres a stab at a diagram.