Monday, May 11, 2020

DIY Numpad: Video and Gesture Sensing

I made an overview video of my numpad last week to summarize its features and build process:


Originally, I didn't intend to make such a complete video, but I had some time to burn and eventually got to this. Along the way, I learned to use the animation tools in Fusion 360 (which is a little clunky), made some cases out of oak wood I bought awhile back, and remembered how much time it takes to make and edit a good video.

Here are some photos from the oak wood CNC process:

Completed case top side.

Didn't set home correctly and crashed the collet.
Top cover cut out without any issues.

Since I had issues with alignment for double sided machining last time, I tested out a different way of doing the bottom side this time. I used a single pin set relatively deep into the wasteboard to align a hole and just ran the pocketing operation for the screw head on each hole on the back one at a time. It does require me to move the part manually for each hole but it turned out alright. The major downside is that since the whole part is already separated from the rest of the material, and the pockets are so close to the edge of the part, in wood some of the side walls break.

I coated the wood in some polyurethane after cutting.

Fun combinations of acrylic and wood case parts:


If you saw the video, you would have noticed that I didn't get the gesture detection working (only had the other features like brightness and proximity detection working). Pretty much the day after I made the video I decided to finally sit down and get to the bottom of why it worked outside on the breadboard with an Arduino and not in my numpad.

I suspected that the sensor was being partially obstructed by the adjacent keys. Testing on the breadboard and moving some obstacles closer and closer to the side of the sensor until swipes stopped working showed that the sensor in the keyboard was most likely being blocked. For one of the keyboards I desoldered the sensor and moved it up with a socket.

The next issue was definitely in the code. A quick glance at it showed the problem: I wasn't giving the I2C read from the sensor for the gesture enough time. I set the timeout to one millisecond, which is enough for all the other operations. Just the gesture data can get relatively long and the standard speed of 400kHz isn't fast enough to get all the data out in 1 ms. I raised this up to 5 ms and got different behavior from my keyboard now.

The next issue was even dumber; I just didn't realize that the specific read function used by the gesture part (used nowhere else) needed to return the number of bytes successfully read, not just true/false for success. After correcting this, we have a working sensor:


The issue with the sensor causing lockout is something I'll fix another time, or at the very least create some sample layout firmware that has gesture and typing modes. You could make some pretty funny controls with this sensor (e.g. a jank theremin, volume control, scrolling, etc.).

I've worked on this for quite awhile now, and it is fairly complete. I want to cycle back to some other projects that have just been sitting on the side before coming back to this and making the rest of the numpads. The parts taking up space on in my workspace are starting to feel slightly annoying and whole place need a good clean up anyways.

(Update) Some more photos I didn't upload before:










No comments:

Post a Comment