Bits, Bytes, and Interfaces Issues

A project log for SmoothMove - A New Human Computer Interface

Small, Ergonomic, Portable and better than any other travel mouse

ChrisChris 08/21/2018 at 03:560 Comments


So the hardware side of things is shaping up pretty nicely. I have some parts picked out and I plan on doing to circuit board design in the coming days.

In the meantime I figured that I should probably start working on the equally important software side of things as well. 

The biggest hurdle that I have to face here is actually interfacing with the touchpad itself. I looked around on Cirque's website and their resource section definitely leaves something to be desired. Nonetheless, I was able to find what I was looking for, a Github repo, albeit a pretty sparse one. 

Up until this point I have not worked much with software so I was hoping for something that was somewhat plug and play. Unfortunately this piece of hardware isn't exactly in the hobbyist limelight, so I wasn't expecting much. In the repo there is some Arduino code for both I2C and SPI  as a means of communication with the device. Which I have to say is pretty cool. All it takes is the removal of a single SMD resistor to change between I2C and SPI modes.

While the Arduino code was very tempting, at the start of this project I had committed myself to using the ESP-IDF provided by Esspressif. In my short experince with it, I have found it a pleasure to use, and it really helps the ESP32 live up to it's full potential.

So how do we actually talk to this thing?

Good question. I am still not entirely sure, but I have made a lot of progress.  It seems like the time that Cirque could have spent developing their Github repo, was actually spent writing excellent hardware (PDF) and interfacing (PDF) documentation.  After reading through the documents a couple times, I almost came close to feeling like I knew what I was doing!

The way they want you to interface with this device is I think is pretty clever. They call it Register Access Protocol, and it is pretty simple. This protocol only has two functions, read and write. With these read and write functions you can access a ton of different information about the device and what it is sensing. Below you can see a list of all the different registers that not only provide information to the user, but can also be written to in order to configure the device to suit your needs. 

One of the most intriguing of these options is the have to do with the 0x0A and the 0x0B registers, which appear to contain some data on the  Z-axis. I was initially confused about this because you know, it's a trackpad. After reading through some more of the documentation, it appears that the trackpad can sense a rough distance between your finger and the pad. This opens lots of possibilities for making various gestures and shortcuts to help improve the actual user experince.

....Anyway, here is the code

I decided to use the I2C mode of the trackpad for my application. I figured that while I2C may only be half-duplex, and therefore slower, I2C uses less pins and will hopefully make routing the PCB a little bit easier. I am just hoping that I2C is still fast enough.

Anyway, here is the code. After reading the ESP-IDF documentation it turns out that using I2C isn't actually too hard. 

First, the write RAP_WRITE function. (Disclaimer: this code has not yet been tested and is probably incorrect).

This is pretty simple and has two arguments, the address of the register that you would like to write, and the value that will be written to said register. 

Second the, RAP_READ function. This is really the one that will get used the most and will allow us to access data from registers containing position data. I know for a fact that I need to test this one and I have to admit that I don't fully understand it yet. 

The code is based of the I2C examples that come with the ESP-IDF documentation and the timing and structure of the commands are based off the provided expectations in the interface information for the CIrque trackpad. 

So why can't you test the code yet?

Unfortunately, I can't test the code yet because I have no way of physically connecting my fancy circular trackpad to a breadboard. The trackpad uses a 12 pin FFC/FPC connector or "Flexible Flat Cable."  The pitch on the cable is simply too small to reliably solder anything to. I spent about an hour trying to solder hair thin magnet wire to the FPC connectors that I ordered. Just when I got one wire soldered on, I would accidently desolder the neighboring wire. 

In the end I managed to get 6 wires soldered onto the tiny connector that I had, but when going for the 7th wire there was a catastrophic failure and I managed to desolder all but 2 wires. Below is the ultimate result of some wasted time. 

Not pretty, and sorry for potato quality, it's really tiny. 

When that didn't pan out I then tired melting the insulation off the FPC but that was hardly the "clean" solution that I was looking for...

I also messed around a bit with making my own breakout board but that didn't pan out either. Long story short I ordered a FPC breakout from Adafruit that is definitely less than ideal, but at least it will allow me to actually prototype something. The clock is ticking.

So what is next?

Well I still have to actually make this thing. I have messed around with the HID bluetooth example from the ESP-IDF and got my ESP-32 to successfully connect to my computer and phone and send mouse clicks. So once I figure out how to actually extract sensor data from the trackpad I still have to handle all of the mouse logic of moving and clicking and whatever other gestures I might want to add. 

In other news, according to the datasheet, there appears to be some built in shortcut/gesture stuff programed right into the trackpad itself, which could make things easier. I have seen something about scrolling and a secondary mouse click which is very exciting. We will see how that goes.

In the next week I hope to be able to make a somewhat functional prototype. Once that is figured out then it will be time for an actual circuit board and order materials! So