Author Topic: Handwiring help - diode direction  (Read 7895 times)

0 Members and 1 Guest are viewing this topic.

Offline noot

  • Thread Starter
  • Posts: 5
Handwiring help - diode direction
« on: Mon, 15 April 2019, 22:15:47 »
Hello,
Ive recently started to hand-wire my Apple m0110 following Troy Fletcher's guide https://www.youtube.com/watch?v=WyAbaqZUuf0&t=131s

He mentions at the beginning of the video that the diode direction doesn't matter but he prefers that the black side faces downward.
Since we are both using alps switches I follow what he does and begin soldering.
The problem appears when I look at other guides, I see everyone have their diodes facing the opposite direction than what I have, mentioning that it has to be that way.

My question is, does the diode direction matter when handwiring a keyboard as Fletcher mentions?



Offline nevin

  • Posts: 1646
  • Location: US
Keeb.io Viterbi, Apple m0110, Apple m0120, Apple m0110a, Apple 658-4081, Apple M1242, Apple AEK II, MK96, GH60/Pure, Cherry g84-4100, Adesso AKP-220B, Magicforce 68

Offline Blitzschnitzel

  • Posts: 103
Re: Handwiring help - diode direction
« Reply #2 on: Tue, 16 April 2019, 04:23:23 »
As long as you stick to one orientation it shouldn't matter. It all goes into IO pins anyways.

Offline Findecanor

  • Posts: 5040
  • Location: Koriko
Re: Handwiring help - diode direction
« Reply #3 on: Tue, 16 April 2019, 10:19:09 »
The convention is to say that you strobe each "column" and sense the "rows".
You strobe each column in turn by outputting a 0 on it, and each time read all the "rows" all at once. Each row has a pull-up resistor on its I/O pin. Thus, each diode must be oriented so that current flows from a row to a column.

Which set of lines you choose to be "rows" or "columns" is up to you.
But if you change the diode direction, then you would also have to change in your firmware which set is rows and which set is columns.
On the AVR series and other microcontrollers used for DIY keyboards, every GPIO pin could be configured as either output or input with an internal pull-up resistor.
If you had used some kind of chip such as a multiplexer or shift register then which set of lines it was on would have been important, and you might have needed external pull-up resistors.
« Last Edit: Tue, 16 April 2019, 11:02:03 by Findecanor »
🍉

Offline noot

  • Thread Starter
  • Posts: 5
Re: Handwiring help - diode direction
« Reply #4 on: Tue, 16 April 2019, 15:52:58 »
Which set of lines you choose to be "rows" or "columns" is up to you.
But if you change the diode direction, then you would also have to change in your firmware which set is rows and which set is columns.
On the AVR series and other microcontrollers used for DIY keyboards, every GPIO pin could be configured as either output or input with an internal pull-up resistor.
Im 17 and have very little education on the matter so excuse my dumb questions.
Since my diodes are the way they are in the picture (with the black side connected the switch pin) in what way do I have to change my firmware? Do I just program the rows as columns and the columns as rows?
And by lines do you mean either the rows/columns of the board?
Thanks for your reply.

Offline Findecanor

  • Posts: 5040
  • Location: Koriko
Re: Handwiring help - diode direction
« Reply #5 on: Tue, 16 April 2019, 18:42:06 »
Do I just program the rows as columns and the columns as rows? And by lines do you mean either the rows/columns of the board?
I'm sorry. By "lines", I meant the wires. Wires can be called lines too, just like "powerlines" are wires ... And on a PCB, they would be visible as lines on a surface as well, but now you are handwiring. :)

Which end the ring on the diode is indicates the direction of current. The diode prevents current from flowing the other way.

I assume that you plan to use someone else's firmware especially for a handwired M0110. Then you would have to wire it exactly like how the author of that firmware had done it, or you would have to modify the source code.

You would have to not just swap the values for number of rows and number of columns but also shuffle around the order of your keys in the keymap.
For each layer there would be a C array of all keys. The order of the keys in each such array depends on the layout of your matrix: which lines are rows and which are columns.

Each keymaps layer in TMK and QMK is usually written using a C macro that maps from a (somewhat) physical layout of your keys to the actual layout of the matrix -- the key order. You would then have to shuffle around only in that macro's body to change the order, not in the parameters to the macro.
« Last Edit: Tue, 16 April 2019, 18:56:58 by Findecanor »
🍉

Offline Anakey

  • Posts: 87
Re: Handwiring help - diode direction
« Reply #6 on: Wed, 17 April 2019, 07:27:20 »
I think you would need to de solder the diodes and instead solder them the other way around. The idea of the diode is that it controls the pass of current therefore when you press a switch you would want current going through one pin, then through the switch, then through the diode. If the diode is in the wrong orientation then instead of allowing the current to flow through when the switch contacts are closed it would block it. If you changed the column to row direction then the switch would function, however you would loose the anti ghosting property of having a diode in the first place.

Offline Findecanor

  • Posts: 5040
  • Location: Koriko
Re: Handwiring help - diode direction
« Reply #7 on: Wed, 17 April 2019, 08:38:24 »
If you changed the column to row direction then the switch would function, however you would loose the anti ghosting property of having a diode in the first place.
when you press a switch you would want current going through one pin, then through the switch, then through the diode.
The order between a switch and a diode in series does not matter.
Both column—diode—switch—row and column—switch—diode—row work.

There is precedent for this with the ErgoDox, where the left and right PCBs are mirror-images of one-another.
Because the PCB is symmetrical and diodes and switches are in the same positions on both halves, diodes will have to be installed left-to-right on one side and right-to-left on the other.
Back in the day, a few builders had soldered on Cherry MX switches for PCB-mounting with diodes preinstalled, but forgotten to open up the switches for the left side and flip the direction of each diode before soldering them on.
Therefore, a flag was added to the original ErgoDox firmware to flip rows and columns on the left side, in the firmware.
« Last Edit: Wed, 17 April 2019, 08:53:45 by Findecanor »
🍉

Offline noot

  • Thread Starter
  • Posts: 5
Re: Handwiring help - diode direction
« Reply #8 on: Wed, 17 April 2019, 09:00:05 »
You would have to not just swap the values for number of rows and number of columns but also shuffle around the order of your keys in the keymap.
For each layer there would be a C array of all keys. The order of the keys in each such array depends on the layout of your matrix: which lines are rows and which are columns.

I think you would need to de solder the diodes and instead solder them the other way around. The idea of the diode is that it controls the pass of current therefore when you press a switch you would want current going through one pin, then through the switch, then through the diode. If the diode is in the wrong orientation then instead of allowing the current to flow through when the switch contacts are closed it would block it. If you changed the column to row direction then the switch would function, however you would loose the anti ghosting property of having a diode in the first place.
Thanks for the insight,

I think I may have found the solution:
In EasyAVR there is a config value called |strobe_cols = True| that allows me to tell the firmware what direction my diodes go. As Anakey mentioned, the anti-ghosting feature might not work but ill take it.