Might have bit off more than I can chew. 56 buttons, 5 rotaries and 2 joys

PaulRB:
So your on-off-on momentary switches are, effectively, two momentary push buttons in the matrix?

Just wanted to check something: you show the encoders in the above diagram. But all that is connected is the "select" button they have inside. The encoder outputs themselves are shown unconnected.

Glad this apprentice could show a master something new :smiley: Yes, I figured since they aren't held closed and are only momentary they function as a normal push button. My only "latching" switches are the parking break, emergency break and the ACC position of the keyed switch. The joystick buttons may be held closed while the joystick is moved about it's axis's but are otherwise momentary.

I haven't made it to the encoders yet. I was going to experiment to see if they could also be included into the matrix as each turn CW or CCW will act as a momentary button press as well.

Thank you. I'm all about this old dog learning new tricks and after I watched half a youtube tutorial on using the program I jumped right in.

I do have a few 20k and 10k resistors and will get the diodes on order. When I see your diagram maybe it will make more sense but I still don't follow the M1-M6 matrix. Will the 6 different axis be using 7 input ports (1 common input and 6 using diodes) on the LEO with one common ground?

I'm good with complicated when the end result is one happy son!! Very appreciative of all the help I'm getting.

Fihn:
My only "latching" switches are the parking break, emergency break and the ACC position of the keyed switch.

If you have any latching switches in the matrix, then ghosting will be a problem if you do not add the diodes. Now that discussion is ended ;D

Fihn:
I haven't made it to the encoders yet. I was going to experiment to see if they could also be included into the matrix as each turn CW or CCW will act as a momentary button press as well.

This is a good question. The pulses from encoders can be very short if the knobs are turned at more than a slow rate. Your code to scan the matrix will need to be fast to avoid missing any pulses, and your matrix will be scanning some analog inputs, making it slower than scanning only digital inputs. It will be interesting to find out if this works well enough to avoid missed encoder pulses. Missing pulses makes the encoder feel as though it is not moving at an expected rate, or even "sticking".

Can I ask a favour? Don’t quote entire replies in your posts. It makes the thread very long but does not add anything. Just quote the relevant parts, like I did above. Or if you don’t need to quote anything, just use “REPLY” button instead of “Quote”.

I checked, I had 200k resistors not 20k. Will these 20K work? They are 1/4W 20k 1/4 Watt or would 1/2 Watt be better?

Will do Paul, sorry about that. So the encoders should be read on digital inputs only so as to reduce the risk of missed pulses?

200K is too high and will make the matrix susceptible to background noise, I suspect.

I don’t know for sure if scanning the matrix will be fast enough to catch every encoder pulse or not. It will be interesting to find out. It’s certainly more convenient to have them in the matrix.

Fihn:
I checked, I had 200k resistors not 20k. Will these work? 10k 1/4 Watt or would 1/2 Watt be better?

Even 200K should do, what resistors between 200K and 10K you have? Their value isn't that important for this purpose to be honest.

Fihn:
So the encoders should be read on digital inputs only so as to reduce the risk of missed pulses?

What he's talking about is "digitalRead" vs "analogRead", actual pin does not matter (you can't analogRead digital only pin). He might be right, but it's easy fix – just put regular switches instead of encoders.

Fihn:
When I see your diagram maybe it will make more sense but I still don't follow the M1-M6 matrix. Will the 6 different axis be using 7 input ports (1 common input and 6 using diodes) on the LEO with one common ground?

Ok, lets clear some things – all dashed lines will be outputs (8 "OUTPUT"s in the code).
All solid lines will be inputs (7 "INPUT"s in the code).

In Your hand drawing you've named all wires, name them in EasyEDA as well.

Now you have to add two more inputs (solid lines) to your matrix, one input will be digital input as other (for rotary encoders), second input should go to LEO analog input pin. After you will have 9 inputs (8 digital and 1 analog).

Look in my analog diagram – that 1 analog pin should be connected there.

M1 to M6 pins should be connected to your outputs (dashed lines), no matter what order, but don't connect same output to more than one "M" pin – they should be separate outputs.

PaulRB:
I don't know for sure if scanning the matrix will be fast enough to catch every encoder pulse or not. It will be interesting to find out. It's certainly more convenient to have them in the matrix.

Yes it is – Arduino samples matrix many times faster than pulse itself happens, I'm using this method in my matrix.

I have 6 200k resistors and 20 100M resistors.

I think I follow your diagram now. M1-M6 are going back to digital "ports" and the analog is well, going to an analog "A0". As with my current wiring, once I hit the first switch on the M1 line the next switch will be one that has M2 connected making the matrix. Essentially M1-M6 would make a 36 key matrix?

I think you did not understand, this image is for ANALOG JOYSTICKS connections:

Those 6 components on the bottom are "variable resistors" that represents your analog joystick one axes (6 axes total as I understand).

Please read my posts on this page again – I updated part about encoders.

Just buy cheapest you can get 10K resistors (they are more common and cheaper), those you linked earlier (20K 1/4W) would be fine as well.

Please name your wires so I can be more specific on my instructions. You can do that by using "Net labels" (in wiring tools) in EasyEDA.

I've updated the drawing with labels and to reflect what I think is correct for the encoders and the analog line, GND and output lines to joysticks. I've also uploaded the EasyEDA file to my drive if you'd like.

Here is my hand drawn labeling schematic that might make following the solid lines (1-9) and dashed lines (A-H) a little easier as my EasyESD drawing is a little crammed together. The one I have circled as Oddball. That is the 5th encoder that I'm pretty sure can't be included with the joys but I did it in pen and couldn't erase my marks.

Hey,

looks OK so far, why you make everything so tight? Space components out a bit, don't worry – you will not run out of space :).
Add a note in your diagram cos we have to remember this – write somewhere in your diagram:
"Dashed – 8 Output, Solid – 9 Input".

Thing you should do now is connect last encoder, if you have to for now disconnect three buttons on top left (I think they are "Parking brake", "Trailer air supply" an the key) and use those wires from those buttons to connect your first rotary encoder.
After that connect those 3 buttons to "Joystick analog line" – we have to do it if you are out of digital matrix pins, it will work fine with those switches. Do not connect encoder to analog input!
I'f my math is correct by doing this you will have fully connected matrix.

Also you should test components individually (and create working code for them) to make sure they work as they should outside the matrix first.

I'll move everything around tomorrow after work and open it up a little more so it's not cluttered. So don't worry about soldering in the diodes / resistors yet? I'm still unclear how / where those will come into play other than the joystick analog line.

The current matrix I have wired together works fully so I know every button works with the exception of the joysticks using the code I posted earlier (Post #6 not original post). Will that code be getting thrown out and rewritten as something else? If so I'm really going to be lost as that was code I used from a similar project that used 32 functions in a matrix but no joysticks so I wouldn't even know where to begin :frowning:

Fihn:
I'll move everything around tomorrow after work and open it up a little more so it's not cluttered. So don't worry about soldering in the diodes / resistors yet? I'm still unclear how / where those will come into play other than the joystick analog line.

You will need 8 resistors to pulldown all digital Input lines (one resistor leg to input, other to ground, their physical location doesn't matter). You will need another 8 resistors to limit the current, they should be wired in series in every Output line, their place is between Leonardo and matrix (before buttons).
You will need to add a diode to every button input line, just after a button, like this (note – "Row" is input line in your matrix):

Make these adjustment and those mentioned in my last post and we'll go from there.

Fihn:
The current matrix I have wired together works fully so I know every button works with the exception of the joysticks using the code I posted earlier (Post #6 not original post). Will that code be getting thrown out and rewritten as something else? If so I'm really going to be lost as that was code I used from a similar project that used 32 functions in a matrix but no joysticks so I wouldn't even know where to begin :frowning:

Just because you don't know how to test ghosting it doesn't mean it's fully working :slight_smile: What comes to joystick code – we cross that bridge when we get there. Now we are designing matrix itself and you shouldn't solder it still cos it's not finished, soldering it at this point is just waste of time...

Unfortunately I had it all soldered before when I was testing my code previously. Won't take much to desolder everything. Will get on it this evening

Fihn:
Unfortunately I had it all soldered before when I was testing my code previously. Won’t take much to desolder everything. Will get on it this evening

Well, diodes has to be added, tho don’t solder/desolder anything now, lets clear out the schematics first, than solder it! Because it can change entirely.

I worked on cleaning up the drawing and to make the changes you talked about. I didn't quite get it done but I wanted to put some good time into it so it's easy to follow. I added labels everywhere there's a connection and spread everything so it's easier on the eyes. Before I keep going with it I wanted to share with you in case you think it needs cleaned up further.

Looks way better, great job!
Add names to those 3 buttons on the top left.

For now disconnect 9 (yellow) wire from buttons on the top left (will reconnect them if analog pins will be not enough).
After that count – every Input should have 8 buttons connected to it, if it doesn't – connect that pin to one of those 3 buttons until every Input line has 8 buttons (skip analog input for now).
Then count every Output, every output should have 9 buttons attached to it (including analog), if it doesn't – connect it to those 3 buttons until all have 9 buttons.

If my math is right after this you should have fully populated matrix.

P.S. where are diodes? I told you - they are required :slight_smile:

Ahh crap I knew I was forgetting something :grinning: I even put a diode on the design so I could copy / paste it into it's proper locations. I'll make further changes per your advice and finish it tomorrow after work and put it up here.

I think I finally have it. Here is the json file if you want to open it in EasyEDA and here is the exported image. I did not connect the top left two buttons as I didn't read until just now the part about reconnecting them if there is room. Those two buttons will become 9G and 9H which will completely fill the 9x8 matrix of 72 functions. Not sure if you noticed but I named each button after the position in the matrix. So a rotary encoder will be named E8F8 / H4. This is row / colume E 8, F 8 and H4 with 8 being the common pin of the encoder and E/F being CW / CCW and H4 being the encoder button.

Flickr is really annoying. I can't zoom in to examine that image in detail. As soon as I let go it zooms out again. Please attach the image file to your forum post, post it, copy the address, modify the post, click the insert image icon and paste the image address. I know it's a pain. Also I find that grey background unhelpful. Would you mind choosing another colour for the white wires and reverting to a white background please?