Author Topic: Bud Keypad (hall effect) to USB Conversion  (Read 5479 times)

0 Members and 1 Guest are viewing this topic.

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Bud Keypad (hall effect) to USB Conversion
« on: Mon, 01 May 2017, 09:42:42 »
Hi all, I had to quit my last project (split spacebar model M) because I couldn't get the controller to work. I now suspect that it's just an issue with the soarer converter interpreting a key as one of those weird ones, and me not knowing the internal code for it. Right now I've drilled the traces off the PCB and will wire up a teensy once they arrive.

Current project is to wire up a fully modded NKRO-capable hall effect keyboard using the method of strobing the power lines of the columns and reading the rows. This effectively converts the keyboard to a standard "strobe / sense" model so in theory you can use any of the available keyboard controller firmwares without modification.

What I have done already: drilled the power lines off the PCB and wired up them into coulmns

Soldered resistors to each column with the emitter on the column, base attached to a 5V busbar, and collector will be connected to a teensy output through a resistor. I need to figure out what size resistor I need (I am used to using a transistor as an amplifier, not a switch) and then wire it up to a teensy and go for it. I would have finished this on Saturday but I realized I was out of teensy and had to order more.

Why the resistors? Well the hall switches are active and therefore require current to run. You can see how much in this topic: https://geekhack.org/index.php?topic=87453.msg2355651#msg2355651 Unfortunately a teensy cannot provide sufficient current to drive the switches, so we will use the teensy to turn a transistor "on" (requires very little current) and the transistor will turn the column of switches "on". Since there is only one column active at a time you know any output you sense on the rows is from a switch in that column (since unpowered columns don't output anything) therefore you can get NKRO without diodes.

How was the KB wired before? The keyboard was wired with all the switches powered at once, and the outputs sent to a pull-up resistor and then into a chip. oddly enough, only the labelled keys 0-9 are wired, the others are powered but the outs are not connected to anything. How are most hall effect kbs wired? since the switch has 2 outputs, they wire up one to "rows" and one to "columns" and then read it from there. You can create a controller of sorts from basic logic gates, and more advanced keyboards with proper controllers can be set up also. These should have 2KRO.

Picture time!
P1090855 by dork_vader_exe, on Flickr
P1090853 by dork_vader_exe, on Flickr
P1090854 by dork_vader_exe, on Flickr

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #1 on: Sat, 06 May 2017, 11:47:55 »
update: When soldering it up, you may have noticed I'm using a 2N2222 NPN transistor on the high side instead of the low. that's definitely not because I got the + and - sides of the hall sensor confused... The good news is that I wasn't 100% sure of the pinout of the transistor and just picked a datasheet (2N2222 and 2N 2222A are different....), wired it up and see if I blow them up.

I'm inclined to just wire it up and see if the resistors blow up. I'm pretty sure it won't blow up the expensive teensy, and I have another 96 of these (plus 100 3904 and 3906 ) so I don't really care.

Now we need to calculate the value of the base resistor. I'm more used to transistors in amplifier circuits, so I'll be  doing some research here. I think we'll go for a 1K and see if that works.

so the 2N2222 has a hFE of 50-75 when IC=.1-10mA but this is at 10V. I'll assume hFE is 50

I want the IB to be no more than 1mA since I'm told the teensy can do about 4, just to be safe

Based on my observations, the hall sensors draw about 4mA. with a hFE of 50, I should be able to get away with only 0.08mA R=V/I so R must be max 62K so R is 62K max, and for 1mA, then we need a 5K resistor.

Man I hope I'm doing this right, I really don't know jack about resistors in saturation. I think the way to go is just pick a value, wire it up and see what the outcome is.

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #2 on: Sat, 06 May 2017, 12:41:02 »
P1090856 by dork_vader_exe, on Flickr
Circuit ready for sense line wiring. I will be soldering these across the rows. Since only one column of switches is powered at a time, I can measure the rows and get NKRO (unpowered switches don't output anything.) This is how it *should* work. This prototype is really a proof-of-concept. If it doesn't work I will modify it.

P1090858 by dork_vader_exe, on Flickr
P1090857 by dork_vader_exe, on Flickr
Circuit with sense wires connected. The black heatshrink is actually crucial to the operation, to insulate the crossing points. *note* for this circuit it's not really required to wire it this way, I could have modified the ribbon cable or soldered to the solder points on top. This was easier though


P1090860 by dork_vader_exe, on Flickr
P1090859 by dork_vader_exe, on Flickr
everything wired to teensy. I chose 6.8K resistor, hopefully that will be fine... I picked the pins at random, so they were convenient to solder.


P1090861 by dork_vader_exe, on Flickr
P1090862 by dork_vader_exe, on Flickr
Sorry for blurry photos, I cranked the ISO up so shutter speed would be better, but I still wanted a narrow aperture so more would be in focus (longer depth of field) but I shook too much. Pro tip: do *not* have caffeine before soldering or photographing.

OK so circuit description: First of all that switch there connects power from the VCC of the teensy OR the red wire into the busbar of the transistors. I have it this way so I can power the system from the PSU and measure current draw, etc. and measure the outputs with the scope. This way I can test the system electrically with the teensy in place, and then test it with the teensy just by changing the switch. I might keep it there in the "final" since it fits and the switch was also manufactured by microswitch.

Secondly, this operates in the standard strobe / sense model of KB operation. The teensy strobes the columns, which are powered through a transistor (teensy does not have enough current to power them directly) to turn "on" one column of switches at a time. Any switch pressed in the column will send 5V back to the teensy on the sense line (across the rows). any switch not powered will not send anything, whether its pressed or not. The teensy then depowers that column and powers the next one, thereby strobing the columns.

In theory you can use any standard KB firmware for this, but "debouncing" might be an issue, you may have to add a delay between powering and depowering the columns, sensing should be fine without debouncing, but since it outputs power in a linear way, you might have to modify the sense. I will keep debouncing in place to act as a delay, and because then I don't have to modify the firmware.

Then in practice I'll crank up the scanrate until it quits working. I might have to play around with other things. the teensy has internal pull up resistors (I think?) but I might want to put a pull-up on the strobe lines, if I do that I'll have to change to PNP transistors, but I have 2n3906 for that.

OK all in a days work! I have a Kentucky derby party to attend, then I want to work on the car tomorrow, so it'll probably be next week before I have another update, or maybe later depending on how I'm feeling.

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #3 on: Sun, 14 May 2017, 13:53:44 »
OK spent some more time with it. Pictures are uploading now but here is what I have learned.

An I should have known this already....

The bias resistors on the transistors are unnecessary. With them in place more power is drawn through them and dissipated in the resistor. Voltage to switches is also lower, something like 4.01V or so. Bypassing the resistor, the current draw is very little and more voltage gets to the switches, about 4.5V Either is fine of course.

With resistor its like 47.8 mA without its 0.44mA. Teensy max is ~9mA so this is quite alright.

The part I *should* have known... The switches really require a pull up resistor to be read successfully. Without it, the difference is something like a few mV of difference and I can only run it up to about 55KHz before the output disappears. I believe this is parasitic capacitance in the circuit, but we'll know more once I get some pullup resistors in there.

The good news is that this keypad already had pullup resistor networks so I'll look up what they did and basically copy it.



OK Explaining my test, I hooked up the main power supply to the busbar through the switch and to ground. I actually soldered on another ground wire for everything. I set it to 5V and it showed only about 0.0113A with all switches pressed (and 1 column powered, as expected, (though I guess I should have tested it with 2 columns powered, maybe have to put some capacitors. Still this is far under the current limit)
I hooked up a power supply with a blown panel into 2 multimeters and adjusted it for 5V. The HP Bench meter shows voltage. The red meter is showing mA through the strobe (so theoretically how much current the teensy has to source to turn on those transistors.)

Then I have a signal generator, and I set the output to 5V and DC offset to none, its connected to the ground line, and I was connecting the power clip to the transistor resistors to see what strobing the power line on the switch gave. Unfortunately 8it's a little odd because the output gets strobed a little too. I'm hoping (and expecting) this to mainly go away when I hook up the output resistors properly. Another good thing about this is that it requires 1 output resistor per row, so you can easily do it with a resistor network, and 1 transistor per column (transistors are cheap) so manufacturing a breadboard to connect these should be very straightforward. You would drill the PCB, re-wire the power lines to the columns PCB, then wire the rows to the rows PCB, then wire it to a teensy in the middle.


Edit:keypad uses a bournes 4116R-002-103 which has 15 10K resistors all connected to 1 pin
« Last Edit: Sun, 14 May 2017, 14:52:23 by dorkvader »

Offline Vibex

  • Posts: 926
  • Location: Cambridge, MA
  • Love y'all
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #4 on: Mon, 15 May 2017, 14:01:19 »
Is this the same Hall effect keypad that you brought to Keycon 2014 (wow that was so long ago!) for people to play with? Because that was a ton of fun! I can't wait for everyone to forget about Cherry/Alps and just use Hall Effect switches. :rolleyes:

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #5 on: Sat, 20 May 2017, 15:09:21 »
Is this the same Hall effect keypad that you brought to Keycon 2014 (wow that was so long ago!) for people to play with? Because that was a ton of fun! I can't wait for everyone to forget about Cherry/Alps and just use Hall Effect switches. :rolleyes:

Yep that's the one!



Update: I don't know why I didn't do this before, but I just realized the thing to do is to just copy what is there already. They have pull up resistors (so its at 5V when unpressed and 0V when pressed) running into an inverter. This is perfect for my needs and I happen to have 2 inverters already (included  in the keypad lol)

This is no big deal because you only need one "channel" per row of the keyboard, so usually 5-6, unless you need more because you have too many columns. A single pull up resistor network and a pair of inverters will cover just about any KB.

So I removed the transistor resistors and replaced them with wires, then wired up one row with a pullup and measured it again. The power is about 0.09 - 0.1 mA which is great, but I only read a voltage drop of 2.5V, and I'm not sure how well teensy can read it.

Next thing to do is to wire up an inverter and start playing with resistor values for the pull-up. Fortunately I have a decade resistor that will help. https://www.flickr.com/photos/dork_vader/albums/72157668301807126
maybe I should get a second one. hmm

Offline dorkvader

  • Thread Starter
  • Posts: 6288
  • Location: Boston area
  • all about the "hack" in "geekhack"
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #6 on: Sun, 21 May 2017, 10:12:13 »
Few pictures of testing:
P1090865 by dork_vader_exe, on Flickr


P1090863 by dork_vader_exe, on Flickr

P1090866 by dork_vader_exe, on Flickr

Offline digi

  • elite af tbh
  • * Exquisite Elder
  • Posts: 2789
  • keyboard game on fleek
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #7 on: Sun, 21 May 2017, 10:23:19 »
Next level  :eek:

Offline Generic_Green_Squid

  • Posts: 6
  • Location: Hungary, Europe
Re: Bud Keypad (hall effect) to USB Conversion
« Reply #8 on: Tue, 26 June 2018, 01:27:08 »
Great project! ;) I wish you could convert hall effect keyboards to USB more easily..