h1

I’ve got an IMU in my pocket and it wants out

December 23, 2014

I have this idea for another ring…

I ordered an Adafruit 9-DOF IMU board for a client who went on holiday vacation before signing the contract so now I’ve got this board burning a hole in my pocket. Given how much I spent at their site, Adafruit sent along a free Trinket board. At the same time, I was starting slides for a presentation entitled “Introduction to Inertial” and working out scheduling details to have ThingM’s Tod Kurt on our Embedded podcast. Combine all these things and what do you get?

One thing you don’t get is something that will easily fit on a ring. Still, if it could, what would I want it to do? Maybe I’ll even get boards made…

The idea stemmed from a magnetometer first. I’ve read about anklets with several cell-phone motors and a magnetometer that subtly teaches you which way is north. I’d love a little ring that glowed white when I was facing north, red when west, and green for east. It would be dark for south. It would be a neat little beacon.

Never mind that the almost-always-on LED will drain a battery fairly quickly so ring mounted will need to be easily rechargeable. Never mind that I’ll need an accelerometer to tilt compensate the magnetometer (oh! must add why to the presentation!). Of course, adding an accel does give me a way to turn it off and on.

Well, if I’m to make the ring, I need to write the code. Hardware is not my forte but if I get it working well, I can probably get help laying out an ATtiny and a magnetometer/accelerometer chip. Though, as long as I’ve got a whole IMU to play with, I might as well use it all.

I spent a few days stripping the Adafruit sensor code of anything I considered unnecessary (floating point? gone! functions that make the sensors interface generic? gone!) so it would fit on the ATtiny in the Trinket (5000 bytes of code space! whee!). And then I wised up and realized I was going to spend all my time making atan2 tables, I should do the prototype on a regular Arduino.

It is funny how 32k feels HUGE and the ATmega is blazingly fast compared to the ATtiny. I stopped rewriting the Adafruit code and started writing the code I wanted. This was a good decision as it gives me more time to play (and since that’s what this is for me, making it seem like work was a good way to get frustrated and move on to another, more fun project).

I think the accelerometer mode should be the simplest. It should glow red if gravity is felt in the X direction (positive or negative), green if Y, blue if Z. This would let me talk about how accelerometers are used as gravity sensors the majority of the time. While free fall detection and actual acceleration are interesting, mostly we want our devices to know which way is down. (Since I’ll use double taps to move between accel, gyro, mag, and off modes, discussing gestures will be natural.)

For the gyro mode, the LED will light proportionally to how fast the rate sensors see movement. This will go nicely with my notes about how rate sensors are only useful when things are moving.

The mag mode will be the North Star implementation I described before.

I started out wanting a ring on a Trinket. Now I want a multi feature demo tool in a box.

(Note: I cross posted this project log from a new Hackaday project. I’ll be putting build details over there as I get it working. I’ll probably post here when I write less technical stuff.)