Posts Tagged ‘gadgets’

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.)

h1

Another Day of Battery Life

December 16, 2014

To make a ring, I needed to minimize everything. Of course, if you’ve seen the picture, you already know I didn’t actually minimize much.

Still, batteries in wearables are a pain. For this wearable with my “you have to take it apart to charge it” methodology, well, longer battery life means this hack will exist longer. The more I take it apart, the more like it is that I’ll repurpose the parts to do something else. (I have this idea for a different ring…)

Minimizing power in Arduino is a topic that has been taken on by plenty of other people. And I happily reused their code and methods(Thank, you Nick Gammon!).

However, when planning a device, it is helpful to determine the size of battery you need. To that end, I made an Excel sheet (sorry, I default there) which I’ve put into a Google spreadsheet so you can see it with the math. The first sheet (words) describes the process in words. The second sheet (numbers) reflects the same information but with numbers. You fill in the orange boxes, it generates the green one.

The first step is to determine the different power states of the device. For Wordy, it is either on (display showing) or sleeping (Arduino asleep, accelerometer configured to wake and interrupt it).

 

My next step was to figure out how much time the system would spend in each of these states. My goal is for the ring to be on for about five seconds every five minutes. Sometimes it will be on more, as I play with it a lot. More often it will be sleeping, such as left on a table overnight. (Note: if you build a Wordy, I strongly recommend setting the ring so it will lose at Pong. Sometimes if you leave it on the X side with no Y tilt, the ring will play Pong by itself indefinitely.) Starting with the idea of five seconds per five minutes means I’ll probably be on the conservative side (unless it plays a Pong marathon without me).

Next, I measured how much current each state. I used my shiny new DVM-with-current-sensing (my old one didn’t have that (though it did have a more melodious beep in resistance mode)). You can use a resistor if you feel like doing it old school style.

(This pic is from my book. If you were unaware I wrote a book, well, yes, I did and it is full of jokes. And dinosaurs. But mostly embedded systems.)

Finally, I calculated how long the device would last given a 40mAh battery (the largest I was willing to use due to size constraints). The result turned out to be much greater than I expected.

This does not have to be the order of events: you might start with the idea of how long you want the device to last and choose the battery accordingly. Or you may have a fixed battery and a predetermined life and need to determine how much time you can spend in each state. Happily, the math works in all the different ways.

Note that this value I got was greatly in excess of my self-imposed goal (which was a puny two hours). It is also greatly in excess of what I said in the build instructions (which was 48 hours). My wear-time was even greater than the estimated value: I charged on Tuesday afternoon and it died on Saturday night.

Though, I’m pretty sure I can do better than these power numbers.

When I measured the MicroView without the accelerometer, the on-state power fluctuated between 10mA and 14mA, depending on how much of the screen was lit. (All current measurements were taken around 3.7V.) If I modify numbers on the spreadsheet, the on-state power of 10mA to 14mA, it changes from 3.5 days to 3.1 days. I switched it back to 12mA as reasonable middle ground.

The accelerometer doesn’t add much to this on-state value. On the other hand, for the sleep-state power, it is a very different situation. The MicroView alone took 0.14mA. The MicroView and accelerometer together take 0.31mA. If I change the sleep-state power from 0.31mA to 0.14mA, the amount of battery life expected changes from 3.2 days to 4.9 days.

The accelerometer datasheet says the accelerometer’s current consumption is 6uA to 165uA. Looking at the numbers above (0.31mA-0.14mA = 0.17mA ~= 165uA), it is clear I should be able to reduce the sleep-state power by reading over the accelerometer datasheet again. (There is also an application note about wake/sleep features.)

Skimming through the app note, I don’t care too much about the precision of the data (though I might in Pong mode but that is an active mode so it is ok to use more power there). It would be no problem to turn the system from 14-bit mode to 8-bit mode.

Sleep mode is limited to 50Hz sampling but that is what I’m sampling at anyway. Why am I still seeing the max current?

Ahh, according to the oversampling chart, I may see 165uA due to high resolution sampling. I can go to 24uA with normal sampling or 14uA with low power. However, I want some filtering either through oversampling or via the low noise setting. The combination of low noise + low power is back to 24uA.

Making only one change (from high resolution to normal sampling) should be enough to increase my battery life from 3.3 days to 4.6 days. That’s exciting. Excuse me, I need to go see if that’ll work and what else I need to change.

[Note: this was crossposted from Wordy’s Hackaday page project log.]

h1

Hackaday: Wordy

December 9, 2014

I wanted to make build instructions for Wordy but since it uses both SparkFun and Adafruit parts, I couldn’t decide where. Though I did say I was going to put my next project up on Hackaday. I did that. There is a link to the code there as well as build instructions. Anyone here want to check it out for me? Maybe suggest what I forgot?

Wordy Ring

One thing already on my list is a project log of different ring making methods I tried. I’m going to do another pass with Sculpey, taking pics as I go. I also need a final picture of it all together, I plan to take that when I wear it out tonight.

h1

Giant rings are IN, right?

December 3, 2014

I finished up the working modes of my ring, so rev1 of the software is done. Here’s what it does:

On TAP: shows a vocabulary word. On tap or double tap, shows definition.

On DOUBLE TAP: starts Pong game, paddle position set by tilt of accelerometer.

On UPSIDE DOWN SHAKE: says to consider a question, waits for upside down shake (or punch) to give a response.

On PUNCH: puts up a punch word and a couple rectangles for emphasis.

As long as the wires are secure, this all works pretty well. I still need to format some of the Magic 8 ball style responses. And I could go through the vocabulary words to make shorter (better) definitions. I can probably pick up about 50 words too (yay!). I may continue to get rid of nonsensical floating point stuff so I can put more definitions in. Oh, and I should check the power usage, I didn’t minimize the accelerometer’s draw.

However, those tweaks can all wait as I need to make it wearable again. The button version was wearable but the ring blanks from that are a little too small for the accelerometer+battery stack up.

microView with accelerometer and battery

From another angle

MicroView, accelerometer and battery

 

On the back of the MicroView is a dab of funtac (that stretchy sticky stuff you might have used to hang posters in your dorm room), a modified Adafruit 5V tolerant MMA8451 board (ahem, they didn’t need all that space for logos and mounting holes). Tiny wires are soldered to the board, then hot glued. On the other side, they are soldered to the MicroView.

On top of the accelerometer is a SparkFun 40mAh LiPo battery with its connector snipped. It is held on to the accelerometer with funtac (sometimes I build things entirely from funtac). I needed the battery on the outside so I can remove it for charging. The

This all stacks up higher than I wanted and doesn’t leave much space for attaching the ring to the device. With the button+battery version of the ring, I pressed the MicroView pins into the ring blank and press fit it all together. That doesn’t work so well now, especially as the poorly pressed fit doesn’t hold the power on.

Add connectors

 

I snipped some jumper wire so I could build a connector on the inside of the ring blank. This was just a trial run. It worked out ok but I think I want to do something a little different for the real ones, maybe destroy 8 wires to get 16 connectors. Having attachments only on the pins of interest has some downsides (especially if I don’t line them up properly). More connector ends also lets me add some needed rigidity. Even these few fix the press fit problem. The female connectors are all too bulky though I may look around some more.

Ring on

 

It doesn’t look too bad. Though I think the new black version are going to be better (still waiting for those to dry).

photo 4

Well, let’s see it on!

OnThe 5s timeout on the screen makes it impossible to get an in-focus shot by myself.  Ahh well, you get the idea. This angle is probably the nicest. From the side where you can see the stackup, not so nice. (Realistically, it wouldn’t be hard to cover this.)

head on

But I can’t leave it on that shot, one more, a little prettier.

Sideview

h1

Stuff I need

December 2, 2014

I know, I write this blog so people can read it. But then I hope only my husband reads it. Which he does but usually only after I’ve told him about whatever I wrote.

Anyway, I find myself going to the same pages a lot. I figure I can reduce my tabs by putting a few links here:

Yeah, I’m still working on my little ring. With a tap, it gives a word. Another tap, the definition. With a double tap, it starts pong (you tilt your hand to move the paddle). Another double tap (or win/lose), pong ends.

Today I hope to use the motion thresholds on the MMA8451 to detect when you turn your hand upside-down and shake (ahem, ask me a question!). I’ve already got the answer strings in there and I’m using 27166 bytes, out of 32k. Though I’m down to 100 words (instead of the 200 I started with).

Better get to work now that I can close some of these tabs.