Close

Controlling the Fidget POV

A project log for Yet Another Fidget POV (YAFPOV)

Call me Slow-on-the-Draw if you like, but I think there's a lot to be learned from this project even if it's a me-too.

doctekdoctek 09/12/2017 at 23:220 Comments

Initially, I thought I could just use acceleration on the z axis to turn the POV on and off. Since acceleration due to gravity was large compared to other accelerations (I thought), the z axis should tell me when I had picked up the POV (z acceleration low since the z axis would be perpendicular to gravity) and when I had put it down (z acceleration about 1G). What I quickly learned was that the force of my finger giving the POV a spin caused z accelerations as well as rotational accelerations. Although they didn't last long, they messed up my clever on-off scheme. Putting in time delays impacted the POV display and still didn't make it work.
Since I couldn't solve the on/off problem, I decided to split it into two problems: turn on and turn off. Reading over the accelerometer data sheet suggested a reliable way to turn the POV on: use double-tap. The ATTINY84 goes to sleep when it shuts off (discussed next), then the accelerometer issues an interrupt when it senses a double-tap. After spending some time tuning the sensing constants, I got this working reasonably well. Sometimes takes a few taps to get it going, but that's only mildly annoying. I'm sure more tuning could make the double-tap work better; I just wanted to get on with the project.
Once I understood how the accelerometer actually worked, it wasn't hard to get a turn off algorithm working. Acceleration of 1G on the z axis is sensed as originally implemented, but I also check that the x axis acceleration is small. That only happens when rotation has stopped. Basically, these two conditions mean that the POV must be laying on it's side and stopped. Now z accelerations which occur when the Fidget is given a hard spin don't cause a shut off. When the turn off condition is sensed, the ATTINY84 enters sleep mode and waits for the double tap event to occur.
The final control problem was to start the text display at a consistent location in the rotation to stabilize the display. Before I really understood the accelerometer response, I tried to use the 4D motion sensing capability of the accelerometer to determine when to display the text. But the algorithm uses only one value as a limit. If that is exceeded either by x or y accelerations, then the 4D interrupt is activated. Since y was always large, it dominated the response and kept 4D from being useful. Once I understood the accelerometer response, then I was able to just use an x value to position the display. That worked quite well and is part of my final program, T84_POV_Click_Text.ino. I'll create a video soon to show the POV in action.

Discussions