Jump to content

Recommended Posts

Posted (edited)

I'm looking to wire up a simple control panel using a Teensy or similar.

I've read and watched a bunch of how to's.

What i understand:

Doing it the dead simple way where everything goes to a terminal. You just wire all the negative terminals together and connect that to the ground. Then wire the positive of each component to a terminal on the chip. Simple!

 

What I need help understanding:
Using a matrix setup. I get how it works, but what I DON'T get is, why DON'T I have to ground the components? I'm wiring their ground terminals to input terminals on the chip, just like their non-ground terminals. How does it know which is which?

In the example below (obviously this applies to the buttons without LEDs too) how does it know that the blue wires are grounded, without connecting them all to the ground? 
106088491_ScreenShot2019-06-26at3_46_20PM.thumb.png.a75a00c2dd0d748e240e9c85336fba8e.png
 

Edited by von_Michelstamm

Share this post


Link to post
Share on other sites
Posted (edited)

furthermore, will something like this work? It's a 5x5 matrix, but I also ran 4 of the inputs to 2 three-way switches along with one of the blue wires.

 

Screen Shot 2019-06-26 at 6.04.07 PM.png

Edited by von_Michelstamm

Share this post


Link to post
Share on other sites
Posted (edited)
On 6/26/2019 at 7:49 PM, von_Michelstamm said:

What i understand:

Doing it the dead simple way where everything goes to a terminal. You just wire all the negative terminals together and connect that to the ground. Then wire the positive of each component to a terminal on the chip. Simple!

 

This method limit buttons inputs to available number of pins for digital inputs in the controller.

Eg. If controller have 12 pins for digital inputs this method allow use only 12 buttons.

 

 

Quote

What I need help understanding:

Using a matrix setup. I get how it works, but what I DON'T get is, why DON'T I have to ground the components?I

 

In Matrix forget about "ground" and think only in "columns" and rows".

But you can take "rows" of matrix as "ground", since diodes is placed pointed for "rows" (diodes force current flow only in one direction).

Now in matrix the same 12 pins for digital inputs can handle up to 6x6 matrix, or 36 buttons. :good:

 

With an ~$5  Arduino PRO Micro (ATMEGA32u4, 16 mhz, 5v) or ~$20 Teensy 2.0, ++2.0 and MMjoy2 firmware you can use matrix or "shift register" - an i/c that can handle up to 8 buttons via serial protocol, hence use only 5 pins in board, but shift register i/c can be chained to use up to ~96 9or 120, don't remember) buttons with MMjoy2 firmware.

 

Example of matrix with BU0836 (applicable to MMjoy2), with 6 columns and 2 rows (6x2) = 12 buttons.

 

 

 


 

Matrix.jpg

 
 

 

 

In matrix is necessary place diodes in one pin of each  button/switch for avoid "keyboard ghost", diodes force electric current to flow only in one direction - toward "rows" (why you can "row" pins as ground" - but is not).

 

MMJoy2 matrix: https://tinyurl.com/y8xk8qmv

 

See a ON-OF-ON switch (SPDT, DPDT*...) as just 2 switches sharing the same body and wire then in 2 inputs of matrix, sharing one wire in their middle pin.

*For certain commands an DPDT is preferable, because allow use one side for one function and the other for another.

 

I don't understand the purpose of this 5 way rotary switch in your scheme, but think this will not work well,  since suggest that only one "row" or "column" work ag given time.

Edited by Sokol1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Now adding a ON-OFF-ON toggle switch (latch) SPDT in the same 6x2 matrix:

 

 

 


 

MMjoy2-matrix.jpg
 

 

 

"Columns" 1 and 2 is shared with switches external pins, since each "column" can be shared with up to 6 buttons an are used only for.

 

Same with "row 1" shared again with toggle switch middle pin. 

 

Notice that "row 1" wire only goes to 5 buttons pins and  each "row" or "column" wire can be shared with up to 6 buttons.

Happens that "row1" can be shared only with buttons of "column 1" and there already was used 6 buttons, just that toggle switch middle pin is require only one "row" wire.

 

This 6x2 matrix accept two more buttons, sharing  HAT "row 6" wire and wire from any of "column" from 2 to 6.

 

BTW - Noticeable too how the matrix wiring became a "spider web". :)

An solution for this, when plan use high number of buttons is make a matrix PCB.

Edited by Sokol1

Share this post


Link to post
Share on other sites
Posted (edited)
On 6/28/2019 at 4:17 PM, Sokol1 said:

don't understand the purpose of this 5 way rotary switch in your scheme, but think this will not work well,  since suggest that only one "row" or "column" work ag given time.

The rotary is a way to switch gunner stations.

So the solution to that is:

1) put the rotary switch at the end of the circuit, so it doesn’t turn off things after it

2) wire all the rotary terminals in serial along one row (like the hat in your diagram).

 

What’s the purpose of the diodes? To prevent ghosting? 

Edited by von_Michelstamm

Share this post


Link to post
Share on other sites
Posted (edited)

@Sokol1 helped me with my Custom ButtonBox. 
I'm at work now but as soon as possible I will share it with you!
It wasn't very complex and works very well.

I builded it with Arduino PRO Micro, Debolestis Shift Register, some cheap buttons, switch buttons and potentiometers.

 

I have some pics:

 

[1] The project.

ProjetoCaixaReduzido.png.56cfd4f8cfba780a06f4ef9b9e62cb96.png

 

[2] 2 x Shift Registers

Shift_Registers_1.png.f7b53849265c1aa81ca46fce772b710c.png

 

[3] The prototype.

DSC_6090.JPG.24ec1a3d2b2944e8bee9ac55fc9c4cb5.JPG

 

 

EDIT:

 

56 minutes ago, von_Michelstamm said:

What’s the purpose of the diodes? To prevent ghosting? 

 

IMO, Shift registers is lot better than Diodes and there aren't ghosting anymore.

 

EDIT [2]:

 

Here is the ghosting effect while using keyboard: https://youtu.be/m33DMV9gGIY

 

and here is my prototype working without ghosting effect: https://youtu.be/oxG6YjayiBA

 

Here is ghosting effect in my Dell keyboard: https://youtu.be/5uoB5ohKZnk

 

EDIT [3]:
Here you can find some useful command list to use in buttonbox and some already builded buttonbox to inspire you:

 

Edited by SCG_ErwinP
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
58 minutes ago, von_Michelstamm said:

The rotary is a way to switch gunner stations.

So the solution to that is:

1) put the rotary switch at the end of the circuit, so it doesn’t turn off things after it

2) wire all the rotary terminals in serial along one row (like the hat in your diagram).

 

Understand. Anyway need test in practice.

 

Quote

What’s the purpose of the diodes? To prevent ghosting? 

 

Yes, if not used when 3 or more buttons are ON at same time, ghost appear, easy to happens with latch toggle switches, because they remain ON all time after toggled. *

 

Several  latch toggle switches ON - e.g. lights control, don't cause "collateral effect" for games -game commands only look for state - On or OFF change, but cause "ghost" press.

 

* Lynx CUB firmware for some Arduinos treat latch toggle switches in a different way, when toggle ON only a briefly signal is send for Windows/games (like press and release a keyboard key), same when toggled OFF**.

 

http://lynx.dk/cub-firmware/

 

** MMjoy2 firmware allow set a button in latch toggle switch ON and in OFF, but the signal is continuous - button remain highlight in Windows Games Controller.

 

The popular BU0836 don't have this function, need external keymapper, see bellow.

 

DCS has support - by manual edit LUA files for ON-OFF switches, but IL-2:Gb no - unless for flaps (one command for Up another for Down), then you need use a external keymaper with sopport for "send key on press" and send "key on release", eg.  Joystick Gremlin, JoyToKey, XPadder, SVMapper... but due a hold/delay issue*** in game code only Joystick Gremlin result practical - if keep default keymap assignments.

 

*** When you map LCtrl+F, for example in JoyToKey, game (IL-2:GB) seed F, Ctrl+F. Joystick Gremlin has a "hold" function.

33 minutes ago, SCG_ErwinP said:

[2] 2 x Shift Registers

Shift_Registers_1.png.f7b53849265c1aa81ca46fce772b710c.png

 

I guess Arduino is lot better than Diodes and there aren't ghosting anymore.

 

I think you want mean: "Shift Register" is lot better than Diodes an there aren't ghosting anymore". :)

 

Yes, Shift Register circuit deal with ghost like diodes deal in Matrix, both do the same thing, just in different way.

 

Shift Register advantages:

 

Easy connections, are 2 pins for each button.

Take on 5 pins in Arduino, since use serial connection, hence require support for serial in firmware.

More easy to "troubleshooting" non working buttons. In Matrix is PITA, because disconnect one button disconnect all after.

 

Disadvantages:

 

Require external PCB

Use more wires after Shift Register PCB - wire 36 buttons means 72 wires, in Matrix is need just 12 (6x6) since you chained wires.

In some cases, e.g. rewire a joystick may space inside grip are tight for fit the PCB e.g. Suncom F-15, but is not issue for button box due plenty space in the  case.

 

As "rule of the thumb" use matrix is practical for relatively few buttons ~20/30.

Edited by Sokol1

Share this post


Link to post
Share on other sites
42 minutes ago, Sokol1 said:

I think you want mean: "Shift Register" is lot better than Diodes an there aren't ghosting anymore".

Yes..

Share this post


Link to post
Share on other sites
Posted (edited)

Does the shift you guys are describing function like a shift key? Ideally i want all the buttons to have a single available function, and not need a modifier to get a second set of functions.

Here's a revised matrix design (no shift.) Everything is a button unless otherwise described. One extra button and one rotary encoder position didn't fit into the matrix so i wired them out separately (lighter red and blue color)
Does this look workable? Am I "getting" it?

1932380801_ScreenShot2019-07-01at3_37_45PM.thumb.png.a9e91094bd87566dc2d60362454f142d.png

Edited by von_Michelstamm

Share this post


Link to post
Share on other sites
1 hour ago, von_Michelstamm said:

Does the shift you guys are describing function like a shift key? Ideally i want all the buttons to have a single available function, and not need a modifier to get a second set of functions.

 

No this  "Shift Register" are a micro circuit: https://en.wikipedia.org/wiki/Shift_register

In the case a replacement for Button Matrix with diodes.

 

Is the CD4021BCN chip in above PCB pictures.

 



Here's a revised matrix design (no shift.) Everything is a button unless otherwise described. One extra button and one rotary encoder position didn't fit into the matrix so i wired them out separately (lighter red and blue color)

 

In general terms are OK, the problem is that in this way you draw need a controller with firmware that support both type of connections, direct with ground pin and Matrix.

For what I know, MMJoy2 firmware support Matrix and Shift Register, use one or another.

 

Ready to use USB controllers like BU0836A, DSD 12  support only Matrix or Shift Register (BU0836X), BU0836 can be used with buttons direct in ground connection but limited to 12 buttons.

 

Better redraw the scheme including rotary switch and the extra button in the Matrix, increase a row or column. 

 

The knob for wingspan need be an encoder, that require 2 buttons positions in matrix, hence require controller with support for encoder (OK with MMjoy2).

 

But the knob "dimmer" is for what function in IL-2:GB?

Matrix don't support analog axis - a potentiometer, what commonly is used for dimmer function (voltage variation), only buttons (press, toggle, momentary... switches).

 

I count 46 buttons in this scheme (what exclude use of B80836, DSD 12, their limit is 32 buttons + POV HAT). P position in rotary switch press a button or is just OFF (nothing connected) - you already have this switch, are several types, for example "make before break", "break before make"?

 

An Arduino Micro or Teensy ++2.0 with MMjoy2 firmware can handle a 10x12 matrix  =120 buttons - Il-2:GB will see up to 64, above need keymapper).

Share this post


Link to post
Share on other sites
15 hours ago, Sokol1 said:

Better redraw the scheme including rotary switch and the extra button in the Matrix, increase a row or column. 

 

Can i create a new row and column with only 2 inputs on it, even though the rest of the matrix has 9 inputs?
Or does the chip recognize that as a new matrix that is 1x2?
 

 

15 hours ago, Sokol1 said:

An Arduino Micro or Teensy ++2.0 with MMjoy2 firmware can handle a 10x12 matrix  =120 buttons - Il-2:GB will see up to 64, above need keymapper).

Are there any downsides to using a teensy compared to the other boards? which board is your favorite?

 

15 hours ago, Sokol1 said:

The knob for wingspan need be an encoder, that require 2 buttons positions in matrix, hence require controller with support for encoder (OK with MMjoy2).

  

But the knob "dimmer" is for what function in IL-2:GB?

Matrix don't support analog axis - a potentiometer, what commonly is used for dimmer function (voltage variation), only buttons (press, toggle, momentary... switches).

The dimmer is for CLOD. Good to know pots need to be handled outside the matrix.
Since some boards are either matrix or non matrix, would i need a separate board for the analog things?
This guy seems to be able to do it with this board (the knob push is in the matrix, but the pots are outside of the matrix and directly wired/grounded to the board)
https://www.youtube.com/watch?v=Z7Sc4MJ8RPM

Share this post


Link to post
Share on other sites
17 hours ago, von_Michelstamm said:

Does the shift you guys are describing function like a shift key? Ideally i want all the buttons to have a single available function, and not need a modifier to get a second set of functions.

As Sokol1 says, it's not such as a keyboard shift button but a micro-circuit.

It receives parallel inputs and send to computer as a serial input*.

That's the point about ghosting. There aren't parallel input, so, no ghosting.

 

*Shift register do this, the Arduino will complement the button box such a CPU with firmware changed by MMJoy2.

Share this post


Link to post
Share on other sites
Posted (edited)
17 hours ago, Sokol1 said:

P position in rotary switch press a button or is just OFF (nothing connected) - you already have this switch, are several types, for example "make before break", "break before make"?

 

P is for cockpit. So, no off, and every position is a button press, from cockpit through the 9 stations the game allows for.

I've removed some useless buttons (like reload, since its the middle mouse button) and added some things (three way switch for gunner engagement distance, for example) and worked it all into a matrix:
1835255285_ScreenShot2019-07-02at11_23_09AM.thumb.png.60c362e2b8b2dc65b02ae4c7f132d659.png
 

Edited by von_Michelstamm

Share this post


Link to post
Share on other sites

...

three way switch for gunner engagement distance, for example

 

With function (game command) in all 3 positions of switch you need a specific type of toggle switch, an ON-ON-ON - case want avoid use keymapper software. :)

 

https://br.mouser.com/Electromechanical/Switches/_/N-5g2h?P=1z0z2o3

 

And this type will require connection with 3 rows (and one column, or vice versa).

 

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...