Author Topic: DIY capacitive keypad  (Read 5562 times)

0 Members and 1 Guest are viewing this topic.

Offline Plocploc

  • Thread Starter
  • Posts: 1
DIY capacitive keypad
« on: Thu, 04 April 2013, 04:30:00 »
Hello everybody,

I am planning to build a (USB) capacitive numpad for my gaming needs. Actually, the reason is I play some games that requires mashing 3 or 4 keys repeatedly and rather quickly, which can be really hurting for my fingers and wrist. I also do play the same kind of games on my iphone and it was quite ok, I got that idea of using a capacitive controller to go easy on my fingers.
Since my understanding in controllers is definitely basic (the only things I've made so far are several "ghetto" arcade sticks, to play Street Fighter with friends) so I might need your help.

I guess I'll have to make the keypad using the following stuffs:
Capacitive keyboard PCB (outputs I2C) > I2C-USB module > USB Cable > PC

As for the parts I indend to purchase/use:
- 12 keys capacitive PCB: https://www.sparkfun.com/products/10250
- I2C USB module: http://www.antratek.com/USB-I2C.html

My questions are:
- is that going to work?
- how can I program the I2C/USB controller to output the ASCII keycodes according to my needs? (either map the 12 keys like any standard numpad, or differently like ASDW or directional keys)
- would you recommend me using something else? Arduino?

Thanks in advance for your help.
« Last Edit: Thu, 04 April 2013, 04:33:58 by Plocploc »

Offline mkawa

  •  No Marketplace Access
  • Posts: 6562
  • (ツ)@@@. crankypants
Re: DIY capacitive keypad
« Reply #1 on: Fri, 05 April 2013, 09:21:28 »
that i2c to usb module will require you to write an OS-level driver that interprets the i2c output by the capacitive pcb into keycodes. you would be much better off putting a micro platform like the arduino pro in the video (or a teensy or a *) inbetween the capacitive touch pcb and usb. that micro will speak i2c with the capacitive pcb and use that data to implement a USB HID device that the computer will then see. hasu's keyboard firmware works with many of these platforms (avr-based ones, anyway), as long as you define the matrix in his header and def files. obviously, at 9 keys, this should be a pretty simple matrix to define :P.

the one thing to watch out for is, as the video says, the capacitive touch pcb outputs 3.3v logic levels whereas many micros have 5v gpio. you might need to interpose a logic level converter (usually a shifter, but an amplifier would also work) to interface the touch pcb and your micro platform.

to all the brilliant friends who have left us, and all the students who climb on their shoulders.

Offline Soarer

  • * Moderator
  • Posts: 1918
  • Location: UK
Re: DIY capacitive keypad
« Reply #2 on: Fri, 05 April 2013, 10:45:30 »
Teensy 3 has 3.3V IO.
Or Teensy 2 can be modified to run at 3.3V, but it's a bit fiddly soldering the suface mount regulator!

Offline mkawa

  •  No Marketplace Access
  • Posts: 6562
  • (ツ)@@@. crankypants
Re: DIY capacitive keypad
« Reply #3 on: Fri, 05 April 2013, 10:51:01 »
it's also arm-based though. i have no idea how plug-and-play hasu's code is for teensy 3. (note to self/hasu: do you (ie, hasu) want a teensy 3? i can have wcass send you one..)

that said, there is a very very simple usb hid driver on the pjrc site that might also work.

to all the brilliant friends who have left us, and all the students who climb on their shoulders.

Offline Soarer

  • * Moderator
  • Posts: 1918
  • Location: UK
Re: DIY capacitive keypad
« Reply #4 on: Fri, 05 April 2013, 10:58:47 »
I think HaaTa's been writing some code for Teensy 3, but otherwise, the PJRC HID keyboard example plus the i2c library shouldn't be hard to plug together.

Offline hasu

  • Posts: 3474
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: DIY capacitive keypad
« Reply #5 on: Sat, 06 April 2013, 10:13:54 »
Plocploc,
3.3V modded Teensy2 with PJRC's i2c and USB library looks like a easier way to me, though I don't know about i2c at all.

(mkawa, thanks. but the time is not now yet.
I'll stick with AVR for a while. But I'll like to port my code into the new architecture if I got enough time or motivation. My firmware size keeps bloating ridiculously and reaches 25KB now :o It won't fit into ATmega32U4 before too long :( This will become one of motivations to port my code.)

Offline Soarer

  • * Moderator
  • Posts: 1918
  • Location: UK
Re: DIY capacitive keypad
« Reply #6 on: Sat, 06 April 2013, 10:42:24 »
25KB?! There must be ways to reduce that!

One I found was setting PRINTF_LIB and SCANF_LIB to nothing in the makefile. Otherwise, it always links the printf_min and scanf_min code in even if you don't use it, wasting about 2KB! Also, don't use malloc - I replaced it with a sequential allocator so that I could still allocate, but not free (apart from freeing all of it). Can't remember how much that saved, maybe only 700 bytes, but it also saved some bytes of precious RAM too :)

Offline mkawa

  •  No Marketplace Access
  • Posts: 6562
  • (ツ)@@@. crankypants
Re: DIY capacitive keypad
« Reply #7 on: Sat, 06 April 2013, 20:57:26 »
25kb? omg. yes, i bet there is a huge amount of libc in there that you don't need and can safely stub out

to all the brilliant friends who have left us, and all the students who climb on their shoulders.

Offline islisis

  • Posts: 120
  • Location: Tokyo, Japan
Re: DIY capacitive keypad
« Reply #8 on: Sun, 07 April 2013, 11:35:05 »
off topic, but seriously... i would hope that GH is one of the last bastions where "capacitive" and "key" is expected to translate into tactile magic, not a merciless trend :/ too cruel...