Hi all, I've been getting some questions about hooking up hall effect keyboards so we can actually use them. Here is an explanation of two ways of doing sensing. Method #1 is 2KRO and #2 is NKRO. Both have their advantages. Vintage keyboards (usually) use the 2KRO method, and I am currently wiring my keypad prototype as NKRO. First some properties of the switches.
Hall effect switches were manufactured by microswitch (honeywell) from 1968 and were used in normal keyboards until the mid-1980's and for industrial automation until at least 2005. They are usually operated by 5V in keyboards and output a signal that's close to that from 2 output pins when pressed (note: some hall effect switches only have 1 output pin. They are not covered here. Some switches, especially for those in keypunches only output a pulse and not a continuous signal. these are also not covered here). Note that there are two main versions of the switch, an older "rail mounted" style, and a newer "sealed" style. These techniques should apply to both (but I think the older style requires more current)
Edit: here's a topic where I go over the electrical considerations of the switches https://geekhack.org/index.php?topic=87453.0
OK First method: 2KRO.
- Use the circuit in place (no major PCB modification required)
Much quicker and easier
- Only 2KRO (possibly only 1KRO on some keyboards but these are likely rare)
Requires custom controller code (need to wire for sense/sense operation)
Edit: many hall effect keyboards are wired with one output of switches connected to rows and the other to columns but not all of them are.
Here's some pictures I made to help explain
This is how they are wired. It's a little hard to see, depending on how well you can read schematics. I created a custom hall effect sensor component and laid out everything in LTSpice. Here you see all the 5V and the ground pins of the switches connected together, and all output 1 collected in columns and output 2 connected in rows. Next we will see what happens when a switch is pressed.
Here we see what happens when Switch at R2 C2 is pressed. You can see voltage going out on one row (red line) and one column (green line). The controller would detect this and recognize the switch is pressed, sending the proper keycode to the computer. The power and ground lines are all active, but I didn't highlight them for the sake of simplicity, All the other rows and columns have 0V on them because no other switches are pressed.
Here we see two switches at R2C2 and R2C3 pressed. Since they are the same row, the red line at row 2 has 5V coming out of it, and the green lines at Rows 2 and 3 have 5v coming out of them. The controller would detect this and output both keycodes to the computer. Again All the other rows and columns have 0V on them because no other switches are pressed.
Here we see two switches at R2C2 and R1C2 pressed. Since they are the same Column, the green line at column 2 has 5V coming out of it, and the red lines at Rows 1 and 2 have 5v coming out of them. The controller would detect this and output both keycodes to the computer. Again All the other rows and columns have 0V on them because no other switches are pressed.
Here we see an example of blocking, If three switches at R1C2 and R2C2 and R2C3 are all pressed, we have two rows with 5V coming out of them and two columns with 5V coming out of them. The controller cannot distinguish if the switch at R1C3 is pressed or not if the other 3 are pressed, so in this case we see that the keyboard's physical matrix only supports 2KRO. You can also see that this 2KRO sense/sense technique is much the same as a standard sense/strobe 2KRO technique, with the exception that the columns have 5V coming out of them, instead of having 5V coming in.
Note that you can just hook this up to a standard keyboard controller and it won't damage the switches, but since the controller is outputting 5V on the columns and the keyswitches are also outputting 5v on the columns (when pressed) the controller will not be able to detect which keyswitches on the columns are pressed, it has to sense both rows and columns for keypress events.
How to modify a keyboard that is wired this way to a modern controller? you would first wire the 5V up to power/ground (USB power should be sufficient, but I recommend an external USB charger for testing) the map out the matrix and wire up one pin output to columns and the other output to rows. Note that in some keyboards, they will have pin 1 of most switches connected to all rows, and then have pin 2 of like 2-3 switches connected to rows, the other pin output is on columns. So be careful when wiring the matrix. Then cut the power to the on-board microcontroller and cut the wires to the keyboard sense circuitry (usually a bunch of pull-up resistors) so all that is isolated form the keyswitch matrix. Then you would program the matrix into your microcontroller firmware and then change the input detection from strobe.sense to sense/sense. In this configuration a scanrate has no meaning, because it is sensing all the time. Since hall sensors settle much faster than traditional switches you would have much higher performance.
*note* if anyone would like to help me modify a firmware like Kiibohd or TMK in this way I would greatly appreciate it. PM me for details but be aware I'm not on GH that much, and working fulltime while taking classes, so I won't have a lot of free time.
Method 2 NKRO.
This method takes advantage of the fact that when switches are off, they have no output. It's like a switch behind a diode for a standard NKRO keyboard. So what we do now is to power only a single column of switches at a time, read what's coming on the rows, then power it off and repeat. This is pretty much exactly the same as how a standard keyboard works, it sends a voltage output to the columns and then senses the rows for voltage back, which it will get for any switch pressed in the row. For this reason we can theoretically use unmodified keyboard controllers and firmware for this However it requires some hardware mods. First a circuit description.
Edit: here's a topic where I have started modifying a keyboard to this version https://geekhack.org/index.php?topic=89262.0
Here we have the ground pins all connected to eachother, and the power pins are connected together to columns. The switch output pins are connected to rows. You can connect both outputs together for added reliability if you want (some keyboards do this, some have one output floating. more on this later.) Note you nly need one of the two outputs for this method. The power pins are all connected to the controller, which turns on one column with a voltage strobe, and reads back what it gets on the rows to see if any key in that column is pressed. Then it turns on another column and reads again. *note* you can't just connect the columns to a controller and expect it to work. More on this later. Here's a circuit diagram
Here we see all the switch grounds connected, the power pins are connected to columns, and both switch outputs are on the rows. Let's go through a sense cycle to see how this works.
Here we have switch at R1C3 is pressed, and C3 is currently being strobed by the controller. You can see R1 is active (5V out) and R2 is not (0V out). The controller senses this as Switch R1C3 is pressed and sends the appropriate scancode. In this example you could also be pressing any switch in C1 or C2 and no output would occur since the switch is off (unpowered). I have drawn little arrows on the power line because it is taking voltage IN from the controller.
Let's assume, we are still pressing R1C3 and the controller moves over to the next column.
Here R1C3 is pressed, and column 2 is currently being strobed by the controller. Again I have lit up the red line from the controller with arrows pointing in because power is coming out of the controller and in to the switches here. Nothing is pressed in C2 so none of the lines have output. Even though R1C3 is pressed, there is no output because the switch is off. I hope you can see now how NKRO occurrs. You can just wire the switches up on rows without diodes and it'll work this way because an unpowered switch has no output.
Now unfortunately you can't just wire up a matrix of switches this way very easily. Let's look at electrical considerations. The reason this is the case is because each switch is an active component and consumes power when it's unpressed and even more power when it is pressed. Whatever is strobing the columns here has to be able to power a full column of (usually 5-6 depending on what sort of matrix you are using) switches, which each consume power (see my other thread about how much, and in what circumstances) and most microcontrollers can only output enough current to power about 2 switches reliably. So if you try to wire up a whole column of switches, the controller cant power them all and you risk damaging the controller or (more likely) they just won't work, The switches will probably be undamaged / unaffected, since they are quite hardy. So how to get NKRO to work? You will need some way to amplify the current coming out of the microcontrolelr pins, and you can do this with transistors! Here's an example circuit diagram with NPN transistors on the high side of the switch.
Here we have the same NKRO example as above, but with transistors on each of the power rows. Here the microcontroller columns are connected to the vertical lines and turn the transistors "on" thus sending power to that line of switches and making them work. Other details such as biasing resistors for the transistors are left as an exercise to the reader (in practice I found out they can be omitted, with the only resistors needed are pullup resistors on the outputs more on this later). Now the basic idea is the microcontroller turns the resistor on which sends power from the 5V rail to the column in question. I haven't had transistor theory in classes yet so I might have wired it wrong or picked the wrong kind of resistor. The operation is the same as the above.
Wiring considerations. This is much more difficult than the above. This is because the switches have to be PCB mounted. You could in theory wire up the sealed type without the PCB, but the sensors can slide out of the switches, so you are just relying on some friction to hold it together. The rail mounted type has no contact between the sensor and the magnets whatsoever, so a PCB is fully required here. So you have to keep the PCB, but since the wiring is different, you have to cut (or drill) every connection from the switch's power pin to the power rail, then get some wire and solder it to every switch thereby creating columns for your controller to strobe (through transistors). Then you have to wire up the rows to form a matrix. In practice this usually means you have to cut (or drill) those traces too so that you can make a matrix of your choosing. Here you can either connect both outputs together, leave one of them "floating" or connect the unused output to ground through a resistor. Best practice would probably be #3, and #1 takes a bit more effort, but you see many examples of keyboards wired up as #2, so its up to you to leave it like that if you want. If you're getting weird errors in testing, then you can try to ground unused outputs or connect them to used ones to fix issues. Then you have to wire up all the columns to transistors, then to the microcontroller. I was thinking of making a PCB with transistors on it that you could use as a strip, but that takes time and I havent done it yet, but this would make it a lot easier for people to wire it up for the various myriad of keyboards out there.
Note that the BUD Honeywell Hall effect keypad was successfully wired up to a teensy and working without any of this. I believe it is wiring the switches up in a 1*16 matrix, which is perfectly suitable for a small keyboard like that but of little use to larger keyboards.
OK SO I have gone over two methods of wiring. There is one other thing that is important, and that's what to do with the output. In practice the output of these switches is quite poor, if you just try and measure it outright, so you need to connect them up with a pull-up resistor to the input of your controller. I am told that the teensy has internal pull-ups, but I have not tested this yet. Most of the keyboards you see have pull-up resistors, and I have soldered mine in for testing purposes on my prototype.
Note, that with pull-up resistors the output is inverted, so it's High (5V) when the switch is unpressed, and low (0V) when it's pressed. You could run this through an inverter before the controller, or program the controller to accept inverted input.
Controller selection. I have been asked about wiring these keyboards up to an xwhatsit controller. Since the xwhatsit operates as a sense/strobe style, you would have to do method 2, drill and re-wire the PCB, and solder transistors on the strobe outputs to power the columns. You would also have to make sure the xwhatsit can read the voltage coming out, or you may also need pull-up resistors on the outputs, and then you would have to invert it. You could just enable the internal pull-ups in the controller and program it to invert the signals, and it would work, but if you are OK with 2KRO this can be achieved much more easily with method 1 (and a standard teensy controller running firmware with a customizeable sense/strobe section that you could reprogram to sense/sense operation.)
Another thing to consider for using a standard controller is that it takes some "time" to power the column on before it will output. it also takes some "time" (dure to capacitance) for the output to turn "off" after the column is depowered. I don't know how the controller works, but you would want to have a bit of "time" in between when a column is depowered and when a column is powered, otherwise you will get one erroneous keypress every time a column is switched. This might be unnecessary, since it takes a bit of time to power on the new column, but it would definitely require some testing.
Other considerations: You can operate a hall effect keyswitch at least 2 orders of magnitude faster than a standard contact-based one because there is no "ringing" or debouncing to do, and the output ramps up and settles extremely quickly. So you could operate it with a 60KHz scanrate instead of a 1KHz one common in contact based keybaords today. The "hall effect sensing and application" article by Honeywell indicates that you can operate them at a 100-KHz scanrate, but I have not been able to get more than about 60 KHz in practice. I'm hoping to learn more about High speed circuits to see why this is the case). This is because the hall effect switches are schmitt triggered, so they have a little built in hysteresis. Theoretically you can do the same with other inherently linear switches like capacitance based ones. SO even if you are using method 2 and have to wait for a bit between pressing columns, you can still operate it 10 times faster than a contact-based keyboard and have some comfortable amount of headroom. They also have no contact so they are rated for 30 Billion keypresses. I have tested them underwater, and they can take voltage inputs of up to 30V and still work fine. Overall they are excellent switches, which are sadly only linear. I hope to include a solenoid in my keyboards in the future to add some of the delightful clickety-clack.
That's all for now!