Gyros and Cap Sensing

It was a long slog of a day. 10 hours in front of the computer working through odds and ends. It’s odd that while I’m trying to bring embodied life to this machine that I’m neglecting my own body. Anyway, spent the day testing out sensors. First thing I tried was a gyro. I’ve not used one before, but I’ve heard they’re better for sensing rotation. Why?…I can’t remember (you’ll have to forgive me, it’s been a long day). Anyways, I got this board thinking it offered a full 6 axis…ahhh, but that would be too straight-forward for a board called 6 degrees of freedom. In fact, you have to buy two additional daughter boards to get all 6 axis. No biggee. I still got one gyro to test out. And it worked straight off (you gotta love this movement towards breakout boards). Turns out gyros only sense the rate of rotation so you have to sum the changes over your sample rate…ie ANGLE += GYRO_READING * SAMPLE_INTERVAL/SECOND. See my reference here. I sent the raw data to Processing to do the Integration and use the results to rotate a cube. Worked great. The rotation wasn’t scaled, meaning the rotation of the gyro didn’t match the rotation of the cube, so on a whim I divided the result by PI. Now it matches the rotation perfectly…or so it seems. I think it’s just chance that PI works, because my sensor data could be anything right?…for now that’s not my concern. Though I’d love to hear from those in the know. Also there’s quite a bit of drift with these sensors, something I’ll also have to address later. But on first glance, these are usable. Here’s the code.

With the gyro working I moved back to testing the capacitive sensors. These have always been a pain, and a concern. They’re integral to the working of the robot as it must sense contact with a body, and ideally this is done through the surface of plastic body, like an iPod. At the same time, it’s been finicky. There’s been plenty of false triggers to cause me heartache. I’ve usually gone with the QTouch sensors in the past. The problem with these is that they’re relatively closed systems. They do all the processing for you, giving you binary output based on whether anyone’s touching the device. There’s a way to calibrate the sensitivity with an external capacitor. Still, I find that it’s tricky to find the right one for an application, and each sensor may perform differently! They can also be slow, operating in milliseconds sometimes in the hundreds. I’ve chosen them in the past because I assumed that since they were dedicated devices that they were the most robust. Still not satisfied with their performance today, I decided to compare the QTouch with some DIY alternatives. First, I went back to this technique I’ve liked in the past. This Arduino program simply toggles a the pull-up resistor on a pin, and counts the cycles it takes for that pin to actually go High. When you touch the pin (or any attached electrode) the capacitance you add increases the amount of time it takes, yielding anywhere between 0 and 16 cycles. It’s actually quite stable compared with the QTouch. The data doesn’t drift and it is consistent in how it responds. Unfortunately, the resolution isn’t very high, but more importantly it can’t sense very far for some reason. You pretty much have to directly touch the electrode, and that doesn’t work for me because I need to go through a 1mm or so of plastic. So finally I tried this technique. I think it works something similar to the previous example, detecting changes in an RC network, but in truth I haven’t got around to reading how it works…instead, I just tried it. I’m pleased to say that with the right resistors (I chose 200k) it works like a charm. First, data varies with proximity to the electrode which means that I have more control over the responses than I do with the QTouch. Also it can be fast (in the 10’s of microseconds) depending on the resistors you use. Also, the responsiveness is fairly consistent, when you move your hand close the data changes, although values drift over time, and I’m not sure on what that depends. So again, drift will be something that I have to figure out (knock on wood) fairly soon. I did extract the standard deviation which is helpful for sorting out quick changes caused by touches, from slow drifting data. So, it looks like Paul Badger’s technique (thank you) will be the one I go with for my prototype PCB. Still, I will likely place pads for the QTouch sensors anyways just in case there’s something I’m overlooking, and then I can have jumpers between the two sub-circuits.

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s