UNO SMD R3, USB Generic HID dj controller (with simple wiring diagram)

I have had some success with the Unojoy project. in prototyping a HID dj controller,

Following that success it kick started my reading, like every newb I have plenty of questions and am uncertain where/who to ask.

Things I've learnt so far,

For a UNO to work as a HID device the firmware has to be flashed and the firmware has to be written specifically for the number of inputs/report size output

The maximum report size for HID is 64B(Bytes)

With various analogue multiplexers/demulitplexers and port expanders/shift registers, I can easily fill a 64B report (I don't think I could find a job for 512b(bits) within the dj software!)

My biggest problem is the coding, so these questions are loose,

Would the job of organising (demulitplexering, I don't know if this is the right word!) the multiplexed inputs and assigning it to the associated bit/byte in the HID report fall to the sketch or the firmware?
(I figured this out, the sketch tells the firmware)

Some hardware questions

With using de/multiplexers containing a matrix (or grid?) configuration (for digital input into analogue pins), digital outputs used up quite quickly, are there IC's available that just take +5V, ground and a Clock signal, that then put out a sequential output over several pins?, if so what are they called?

My brain is hurting so I'll leave it there. Thanks for reading.

My projects final aims are
32 pots and 100 buttons, but freely accept this will be revised again and again.

Comments, thoughts or links to similar would be great.

I've been making progress with the HID end (firmware), the HID to DJ software translation and also the project wiring design.

Does this design look suitable/viable?


(the forum appears to have chopped the edge off ,the 2 red lines on the right point to the 3 digital outs comment)

The firmware eats up RX & TX digital pins
7 digital outs are used for external chip sequencing (is there a way to reduce the number? and does it matter which digital pins? or can I use any?)
2 digital ins are for the demux'd (2*)8*8 grids

I'd like to save A0 & A1 for the future for more advanced I2C stuff
I have A2 reserved if I don't like the latency on the mixing fader

By my count I still have 3 digital outs to control a port expander to control LED's

Any comments, thoughts or errors pointed out would be greatly appreciated.
Thanks Loco,

Am I on some type of sh** list?, I'm only after a some simple verification before I spend the pittance I have on parts.

Please.

I think you're asking way too much question here...

It's not entirely clear what your question is, for one. Second, there's a lot going on here, which would take any potential helper some time to sort through and make sense of it all before they could provide a reasonable answer. Given the volume of questions through this forum, that won't happen unless someone is really intrigued by your project.

You should probably break this down a bit. What's your one, immediate road-block?

Ah I apologise, far too much reading has left me confused and cranky,

The bottom part of the picture where a 16:1 dumux's 5V and feeds 2 separate 88 grids, and each grid is multiplexed with a 4051 8:1, would feeding a 16:1 out into 2 8:1's cause problems/ increase latency excessively?

Would it be wiser to swap out the 16:1 for 2 more 8:1's

Can you be more specific about how that matrix works? I'm trying to figure out what you had in mind here...

You have a 16-channel analog switch on the left, and two 8-channel analog switches on the right. Any reason you're mixing parts here? (Not that it's a problem per se, but if you're not using 2x16 or 4x8, I assume there's gotta be a reason, which could be relevant.)

Next question: Why are you using analog multiplexing for buttons? Are they touch sensitive?

I also don't understand what you mean by "demuxes 5v". Why are you multiplexing a power rail? Are you trying to use a diode-less matrix keypad topology here? If so, why not a tri-state digital I/O expander rather than analog switches?

The matrix will be something like this, ( the right hand side example ) Sorry about the size it's from this site's playground

Because I have to buy 16:1's in packs of 5, (3 for the 48 pots 1 as a spare)

I figured I could use the remaining 16;1 to demultiplex 5V from the power rail pass it through a matrix and (re)multiplex to a digital input, then it would be a software job

Some thing that would read nothing like this, (but this kind of logic)
If demuxing control pins 2,3,4,5 == 0 0 0 0 and muxing control pins 6,7,8 == (some other binary ) then if digital in pin 10 == high then button 46 has been pressed (rough and inelegant I know, but simple)

Thinking about the mixing parts bit, it makes no good difference, that was a misguided choice on my part so I'll use all 5 16:1

Although now you've questioned the matrix, and after thinking hard at it, it needs redesigning, it's too simplistic, I need to spend a lot longer figuring out grouping my buttons for ones that need (near) simultaneous input and ones that never will.

so thank you, you have helped, and I shall look at tri state port expansion.

Hmm... well, if they are simple boolean-state buttons (either pressed or not pressed), you can use a matrix layout, and you wouldn't have to read analog values. An 8-channel analog switch from the +5v rail would indeed work well to drive the columns. You would then have each row connected via a pull-down resistor to ground, and also to the inputs of an 8-channel parallel-to-serial (input) shift register, like a CD4021.

To read button states, light up column 0 with +5v. Scan rows 0-7 consecutively and look for HIGH inputs. Then set column 0 to high impedance (open circuit). Light up column 1, and repeat the scan across rows 0-7. Set column 1 to high impedance, and light up column 2. And so on...

You don't actually read more than one button "simultaneously", but the micro can scan the matrix fast enough for it to feel that way.

Thanks for the input,
I have looked at port expansion via I2C as I can have a lot more options for (near) simultaneous pressing, although I can think of 2 sets of 32 buttons that would never be pressed together so I will look into the method described (half my buttons) which is nice because I can have 4 port expanders for inputs and 4 for outputs to drive LEDs. on the I2C lines

FWIW, with a matrix, you have to be simultaneously pressing at least three buttons to cause false-positives:

   A     B     C
0 _/ _  _/ _  _/ _

1 _/ _  _/ _  _/ _

2 _/ _  _/ _  _/ _

All buttons on column A connect together. Same with all on B, and C. Likewise, all of row 0 are connected, and again for 1 and 2. So, if you press A0, and the scanning algorithm is putting +5v on column A, row 0 will have +5v across it as well. (This is how the uC knows that A0 is pressed.) If the user then presses C0, that switch carries +5v over to the C column. This is harmless until the user also presses C1 or C2. Then, row 1 or 2 also has +5v on it, and A1 and A2 will return false-positives.

That's the trade-off for being able to read (rows * cols) buttons with only (rows + cols) pins. :wink: