Close

Not abandoned yet.

A project log for BuzzWatch

A personal tactile interrupt generator for people with AD[H]D (and maybe others as well).

flashcactusflashcactus 04/17/2016 at 16:460 Comments

One of the mixed blessings of ADHD is that you tend to do whatever you fancy at the moment, which means lots of exciting projects... Which hang unfinished in limbo while you work on something else. When one of those projects is something that's supposed to help you deal with the whole thing, the situation gets pretty ironic.

I did somehow manage to return to this one, however, so I'm gonna try and make the most out of it. Which means I'll procrastinate by writing about what I've already done instead of actually doing something new.

Oh, well.


Some thoughts on user input.

Basically, the problem is that you have to have a simple, intuitive way to control the average time between buzzes that's not cumbersome to use. Which means (among other things) not requiring hundreds of button presses (arrrgh, how I hate those clocks which make you do this). So I decided to use a thumbwheel pot. After all, it only uses one pin. (Afterwards I had to consider the ramifications of having a fat resistor between the power rails burning power all the time, and added a transistor to shut it off, which uses up another pin.)

Now, how does one set the time with a pot? The first obvious choice would be linear scaling: seconds = α*pot_value. But I want a setting range of minutes to days, i.e. scales between 1e2 and 1e5 seconds, with a resolution no less than about ten seconds on the lower end of the scale. The ADC is 10-bit, so it's almost enough. But not enough nonetheless. Additionally, setting anything on the lower end would be a monumental pain, since there's no way you could manually turn the wheel a certain number of (π/1536)-rad steps.

The next obvious idea is to make it a quadratic or other concave polynomial. Good resolution and smaller steps on the lower end, great range, what else would you want? Well, there's one small thing. No display means no feedback, so you'll have to calculate how much to turn for the time you want. Oops.

Okay, let's try an exponent. Exponents are great; ballpark mental calculations can be done almost instantly, and if you're that kind of geek that carries a slide rule, it's even more awesome. Except for one thing: machine computation of an exponent is quite intensive. The classic way is to sum a series, which for a chip that has no multiplication command and has to do it the hard way, taking hundreds of instructions for each operation, would equate to spending most of the time awake and eating the battery. Not good.

At that point I temporarily shelved that issue, deciding that if nothing better came up, I'd just bite the bullet and go for x². Which was a good thing, because working on the other aspects led me to deciding that I need a button for, at the very least, turning the thing on&off. And since I was going to have one anyway...

See, some exponents are really easy to calculate. You just take a one and shift it left by several bits. Although if you just do that, the resolution's gonna be terrible. But if you multiply it by another number... Well, you get a poor man's floating point number, I guess. But the important part is that the mantissa can cover quite a small range. Let's say 32. Now, this is in the realm of hand-setting. You can, in fact, even buzz the number back at the user. The exponents are even better, since you only need only 3 or 4 of them, easily settable by button. And, of course, the settings are pretty easy to calculate mentally. Or with a slide rule, which is so much more awesome.

Finally, there's no need to actually reduce the resolution artificially. After all, an 8-bit number is essentially the same as its 5 MSBs shifted left by three plus some added accuracy. So here it is:

Simple, yet powerful. Great range, great resolution, minimal computational complexity on both ends.

The Button

this is what I'm going to implement next. I added it when I noticed that I had two unused pins, and one of them happened to be hooked up to INT0, which, conveniently, can wake the MCU from powerdown mode. Since the datasheet postulates that if you use INT0 to wake from sleep, you should hold it for some time (otherwise it wakes without the interrupt triggering), so hardware debouncing is pretty much required. Now to the (kinda) hard part: designing a one-button interface. Normally that would mean some kind of menu, but I don't want anything that complicated, so I could just pick the simplest button combinations:

So that's it for now. Next one will either be about my past PCB adventures, or I'll actually do something new by then. We'll see.

Discussions