How many inputs is too many? Let's find out!
How many inputs is too many? Let's find out! Posted on: 25.04.2011 by Louisa Oberc Hey all!I've been planning my 'mega controller' for a few weeks, and just started to plan out the circuits. I asked myself a question that I didn't know the answer to... How many inputs can be hooked up to an atmega chip before things start to slow down. It is theoretically possible to have virtually unlimited inputs, by daisy chaining multiplexers, multiplexing multiplexers, and other various methods... The bottleneck lies in the microcontroller and how fast it can process things. Too many inputs and you'll get latency, missed button presses, and other problems. We all have dream controllers (my current one has over 200 led's, 2 lcd displays and nearly 200 controls), but since you need to hook these things up to something, it helps to know the limitations of the controller. I currently have 8 CD4021's (digital multiplexer) and 6 CD4051's (analogue multiplexer) hooked up to my arduino (using an Atmega328 microcontroller). This currently provides 64 digital inputs and 48 analogue inputs, using only 6 digital pins and 6 analogue pins Since the atmega328's only have 6 analogue inputs, I've reached my limit on the analogue side, but the digital side has plenty of breathing room left... But wait! There's more! I said I hit the limit on the analogue side, but I wasn't really telling the whole truth... The CD4051 provides 8 analogue inputs using 3 digital pins and one analogue pin. Normally you would hook up a bunch of pots or faders to the CD4051 and call it done. What if you connected 8 CD4051's instead? It would require 3 additional digital inputs, but still only one analogue input. Grade 7 math tells me that 8 x 8 = 64 analogue inputs per analogue input pin on your arduino. 6 analogue inputs times 64 = 384?!?! So using a total of 54! CD4051's, 6 digital pins and 6 analogue pins gives us 384 analog inputs! My theory is that each 'level' of CD4051's would only require one additional set of select pins on the arduino... You would be using a bunch of 4051's, but you could get a few thousand pots hooked up with a few hundred of them Of course it is completely insane to take it to that level and I will likely only try a single 8x8 setup for proof of concept benchmarking. I'll have pictures and bench mark results as time goes on For now though, my current tests are giving me very pleasing results.. Analogue inputs can be read at 34uS per input + 776uS, so right now I am scanning 48 analog inputs in 2408uS per iteration. BTW, uS = microsecond, one millionth of a second... I haven't benched the digital inputs yet, since none of my button code works with 64 inputs Pic: 6xCD4051 (top right); 8xCD4021 (top left/bottom) | |
Louisa Oberc 25.04.2011 |
Originally Posted by DJKeyWee
This may be an obvious question to those with even the most basic electronics knowledge (I'm all self taught), but when I read 'place as close as possible' I assume it means the +v side not the ground... Some IC's have power and ground next to each other making the point moot, but others (4051's for example) have them placed on opposite ends of the chip (pins 8/16)).. OSC is 'the new king in town' so to speak... it's an IP based protocol which provides much more head room as opposed to midi's puny 7bits...
Originally Posted by http://en.wikipedia.org/wiki/Open_Sound_Control
|
Lisa Lochotzki 25.04.2011 |
Originally Posted by DjNecro
I can't wait until traktor supports osc... things will be so much better... MIDI was great for a time.. but, times... they are a'changing
ooh project idea! Would there be a use for a midi->osc->midi type of box? It would have various midi in/outs and an ethernet jack... |
Louisa Oberc 25.04.2011 |
Originally Posted by DJKeyWee
I can't wait until traktor supports osc... things will be so much better... MIDI was great for a time.. but, times... they are a'changing ooh project idea! Would there be a use for a midi->osc->midi type of box? It would have various midi in/outs and an ethernet jack... |
Lisa Lochotzki 25.04.2011 |
Originally Posted by DjNecro
The advantage of the 0.1 uf on the analog line is to remove the noise on the line and smooth the results hence you can also reduce the ADC acquisition time. Noise may come from various places, you want to avoid it and get false ADC reading. You can skip this and do some ADC averaging with 16 or more adc reading... but obviously averaging need more time per input, then add unwanted delays.
As for the power decoupling, where should I put the caps? I know at least one should be on the daughter boards, but should I add an electrolytic as well, or should they just be on the motherboard?
Once you got a schematic I could have a look at and suggest few things.
As far as software filtering, I'm using an approach I found while traveling on the net one evening
.. It uses a combination of a threshold and timing. The initial movement is by threshold, then it switches to a timer based logic; sending all values until the timer stops, or more movement is detected. This gives me full range of values (which being midi is small enough already) along with solid 'debouncing' to eliminate any jitter.
For the buttons, then yes a software timer based interrupt could be used. MIDI fighter use this and seems to works pretty well. Same thing goes here, keep a previous reading and compare with the actual. If there's a mismatch output the result. What I would use is a hardware interrupt. Look at MCP23017 by example, once an input have changed, it send an interrupt signal. From there, you just need to read the chip and process the output and debouncing duties. This is actually faster than timer based, and your MCU can do better thing in meantime...like keeping the USB connection alive and process ADC reading & so on. Hope it's clear (kind of French to English language barrier here), case not just ask. |
Louisa Oberc 25.04.2011 | Hey all! I've been planning my 'mega controller' for a few weeks, and just started to plan out the circuits. I asked myself a question that I didn't know the answer to... How many inputs can be hooked up to an atmega chip before things start to slow down. It is theoretically possible to have virtually unlimited inputs, by daisy chaining multiplexers, multiplexing multiplexers, and other various methods... The bottleneck lies in the microcontroller and how fast it can process things. Too many inputs and you'll get latency, missed button presses, and other problems. We all have dream controllers (my current one has over 200 led's, 2 lcd displays and nearly 200 controls), but since you need to hook these things up to something, it helps to know the limitations of the controller. I currently have 8 CD4021's (digital multiplexer) and 6 CD4051's (analogue multiplexer) hooked up to my arduino (using an Atmega328 microcontroller). This currently provides 64 digital inputs and 48 analogue inputs, using only 6 digital pins and 6 analogue pins Since the atmega328's only have 6 analogue inputs, I've reached my limit on the analogue side, but the digital side has plenty of breathing room left... But wait! There's more! I said I hit the limit on the analogue side, but I wasn't really telling the whole truth... The CD4051 provides 8 analogue inputs using 3 digital pins and one analogue pin. Normally you would hook up a bunch of pots or faders to the CD4051 and call it done. What if you connected 8 CD4051's instead? It would require 3 additional digital inputs, but still only one analogue input. Grade 7 math tells me that 8 x 8 = 64 analogue inputs per analogue input pin on your arduino. 6 analogue inputs times 64 = 384?!?! So using a total of 54! CD4051's, 6 digital pins and 6 analogue pins gives us 384 analog inputs! My theory is that each 'level' of CD4051's would only require one additional set of select pins on the arduino... You would be using a bunch of 4051's, but you could get a few thousand pots hooked up with a few hundred of them Of course it is completely insane to take it to that level and I will likely only try a single 8x8 setup for proof of concept benchmarking. I'll have pictures and bench mark results as time goes on For now though, my current tests are giving me very pleasing results.. Analogue inputs can be read at 34uS per input + 776uS, so right now I am scanning 48 analog inputs in 2408uS per iteration. BTW, uS = microsecond, one millionth of a second... I haven't benched the digital inputs yet, since none of my button code works with 64 inputs Pic: 6xCD4051 (top right); 8xCD4021 (top left/bottom) |
Bunny Luzuriaga 14.11.2012 | Hello, is it possible to tell me which resistor you use for the cd4051? ignore my bad endlish.Thank you in advence. p.s Great job! Profi. |
Lisa Lochotzki 25.04.2011 |
Some IC's have power and ground next to each other making the point moot, but others (4051's for example) have them placed on opposite ends of the chip (pins 8/16))..
Here's some "fair to really good" reading [ame="http://en.wikipedia.org/wiki/Decoupling_capacitor"]Decoupling capacitor - Wikipedia, the free encyclopedia[/ame] I'll investigate the OSC thing. Looks interesting. |
Louisa Oberc 25.04.2011 |
Originally Posted by DJKeyWee
This may be an obvious question to those with even the most basic electronics knowledge (I'm all self taught), but when I read 'place as close as possible' I assume it means the +v side not the ground... Some IC's have power and ground next to each other making the point moot, but others (4051's for example) have them placed on opposite ends of the chip (pins 8/16)).. OSC is 'the new king in town' so to speak... it's an IP based protocol which provides much more head room as opposed to midi's puny 7bits...
Originally Posted by http://en.wikipedia.org/wiki/Open_Sound_Control
|
Lisa Lochotzki 25.04.2011 |
Originally Posted by DjNecro
I can't wait until traktor supports osc... things will be so much better... MIDI was great for a time.. but, times... they are a'changing
ooh project idea! Would there be a use for a midi->osc->midi type of box? It would have various midi in/outs and an ethernet jack... |
Lisa Lochotzki 25.04.2011 | Ok so we're going modular, multi connectors and such, we want to avoid psu glitches and all nasty thingy. What I would do,
end of the story for that one. |
Louisa Oberc 25.04.2011 |
Originally Posted by DJKeyWee
I can't wait until traktor supports osc... things will be so much better... MIDI was great for a time.. but, times... they are a'changing ooh project idea! Would there be a use for a midi->osc->midi type of box? It would have various midi in/outs and an ethernet jack... |
Louisa Oberc 25.04.2011 | I haven't started the motherboard yet, but here's what I have for the analogue module... I haven't put the caps in yet so it's fairly basic... Schematic: Board: |
Lisa Lochotzki 25.04.2011 | Yup, I never used them before though, should do the trick. 12 bit is tad useless though, you'll need a really decent layout to have the full resolution... and in the end... output only 7 bit of it |
Louisa Oberc 25.04.2011 | I just placed an order for some mcp3008's and 3208's... I assume those are the ones you would use for analogue inputs (if i'm wrong, feel free to correct me).. We will see how they fare... |
Lisa Lochotzki 25.04.2011 |
Originally Posted by DjNecro
The advantage of the 0.1 uf on the analog line is to remove the noise on the line and smooth the results hence you can also reduce the ADC acquisition time. Noise may come from various places, you want to avoid it and get false ADC reading. You can skip this and do some ADC averaging with 16 or more adc reading... but obviously averaging need more time per input, then add unwanted delays.
As for the power decoupling, where should I put the caps? I know at least one should be on the daughter boards, but should I add an electrolytic as well, or should they just be on the motherboard?
Once you got a schematic I could have a look at and suggest few things.
As far as software filtering, I'm using an approach I found while traveling on the net one evening
.. It uses a combination of a threshold and timing. The initial movement is by threshold, then it switches to a timer based logic; sending all values until the timer stops, or more movement is detected. This gives me full range of values (which being midi is small enough already) along with solid 'debouncing' to eliminate any jitter.
For the buttons, then yes a software timer based interrupt could be used. MIDI fighter use this and seems to works pretty well. Same thing goes here, keep a previous reading and compare with the actual. If there's a mismatch output the result. What I would use is a hardware interrupt. Look at MCP23017 by example, once an input have changed, it send an interrupt signal. From there, you just need to read the chip and process the output and debouncing duties. This is actually faster than timer based, and your MCU can do better thing in meantime...like keeping the USB connection alive and process ADC reading & so on. Hope it's clear (kind of French to English language barrier here), case not just ask. |
Louisa Oberc 25.04.2011 | When you mention the cap, are you talking about power decoupling or should they be on the inputs (as well as decoupling of course)? If they're on the inputs, wouldn't they add slight (probably imperceivable) delay to the readings? Would that completely eliminate any software side smoothing? As for the power decoupling, where should I put the caps? I know at least one should be on the daughter boards, but should I add an electrolytic as well, or should they just be on the motherboard? As far as software filtering, I'm using an approach I found while traveling on the net one evening .. It uses a combination of a threshold and timing. The initial movement is by threshold, then it switches to a timer based logic; sending all values until the timer stops, or more movement is detected. This gives me full range of values (which being midi is small enough already) along with solid 'debouncing' to eliminate any jitter. |
Lisa Lochotzki 25.04.2011 | No specific reason, Atmel are good, TI's are good, Zilog are good, They're all good. I just begun with Microchip and stick with them for most of my design. Yup pull-down/up is always a safe bet, add a 0.1uF on the line and you're safe. Could still do some software filter, but it add some extra unwanted delays. BTW, keep us posted, that seems to be a really nice project here. |
Louisa Oberc 25.04.2011 | Yeah, I haven't seen much in the way of cross talk at all... The only time I've seen it was with floating inputs. Neighboring inputs would affect the floating one... but in the setup I'm building I am adding 560k pull-down's on all inputs, which seems to take care of things... My intent is to build my own 'midi brain' that is as modular as possible. I want a good foundation to be able to easily play with various controller layouts.. What specifically do you not like about the atmel line? |
Lisa Lochotzki 25.04.2011 | I use Microchip's one, Check the PIC18 & PIC24 line. They have C compiler Demo & student version for those. Check out the USB framework, they have a MIDI example in it. CD4051 have crosstalk, problem is ... crosstalk However, for steady DC voltage such as MIDI controller, I'm not that sure it will be that much of a problem. At least nothing you can't monitor with MIDI-OX. |
Louisa Oberc 25.04.2011 | I've been using 4051's for multiple controllers and haven't seen any cross talk issues. While I am sure there are better chips out there, I don't have any right now, and I do have a dozen spare 4051's Could you explain why the 4051's are as bad as you say? I haven't had a whole lot of experience with the atmega's, but I am starting to reach the limitations... Notably the 10bit adc's and only one uart... I've been researching the maple (http://leaflabs.com/devices/maple/) and so far it seems to be quite the chip... I just wonder about how easy it would be to build my own board.... I've never hand soldered a QFN, and it worries me a little bit Other than the atmel line, what mcu would you recommend? In a perfect world it would have at least two hardware uart's 8+ 12bit adc's, direct usb functionality (ala the teensy)... The most important is the language... I know C/C++, but I don't know assembly, nor do I have the interest in learning |
Lisa Lochotzki 25.04.2011 | I wish you good luck with CD4051 with analogue... they have lotsa cross talk, you'll probably need to fix it in software, and then add some extra latency. I'm not a Atmel MCU fan, But I would use something bigger with more built-in A/D converter and more inputs to avoid those nasty multiplexers. THere's by far better product than 4051, check out Microchip I/O expanders. There's also Cypress and NXP one who can go up to 60 I/O on a single chip. OK nothing you can fit easily on a breadboard |
Random X 25.04.2011 | Can't wait to see what the outcome will be. |
<< Back to Reviews of DJ equipment Reply