From PropClock to Gyro’clock

Hello! It’s been a really long time since my last blog post. Excuse? School! Since school started I barely had time to work on my project. Although, I did work on it here and there and made a bit of progress. Finally I got some time to visit my blog and give you an update on the project.

PropClock to Gyro’clock

First of all a name change for the project. I thought ‘PropClock’ is a confusing name for this project because even though the principal of operation is the same as that of a propeller clock, this project doesn’t really have a propeller. You have to spin it yourself to make it work. So I came up with another more appropriate name: Gyro’clock! The appropriateness (or silliness) of that name will become more clear as you read along.

Accelerometer to Gyroscope

As I explained in my previous post, one of the biggest problems I encountered on the first keychain ‘propeller’ clock is not being able to accurately determine the angle of the spinning device. Back then I used a MMA8452Q accelerometer to determine the angle of rotation by using the gravity vector as a reference. The problem with that method is the noise in the accelerometer readout, which is significant in short time scales. The accelerometer is too sensitive to all the random forces that occur when device is spinning in the air.

This time around I want to measure the rotation angle with much better accuracy to display the time at the same position in space. So move over accelerometer, and here comes the gyroscope! Hopefully the name Gyro’clock is making a bit more sense now. Unlike an accelerometer, a gyroscope is not sensitive to forces. It is only sensitive to the rate of rotation of the device. This makes a gyroscope readings very accurate in short time scales. However, since the gyroscope spits out the rotation rate, we have to integrate it to obtain the rotation angle. Errors in integration accumulate over time making the calculated angle slowly drift away from the true angle. Also we need to figure out a way to define a reference angle. Otherwise any angle calculated from the gyroscope readings will be meaningless.

After a bit of research, I found that a better solution is to use both an accelerometer and a gyroscope to calculate the rotation angle. The accelerometer readings can be used to correct for the angular drift observed in gyroscope measurement by implementing a complimentary filter (more on this technique later on).

LEDs to Neopixel stick

I was really excited to run in to Adafruit’s Neopixel stick. This stick has 8 tightly packed RGB LEDs. Each LED can be addressed individually using a single data pin. Adafruit also has an Arduino library to go with it, and this makes controlling the LEDs really simple.

The Neopixel stick is an almost perfect choice for this project, but it still doesn’t solve one of the key issues I faced in the first keychain clock design. When the device is spun in the air it tumbles around the axis parallel to the chain so the LEDs may not be facing you all the time (the tumble effect). Ideally you would want the LEDs to have a 360 degree field of view or be symmetric along the chain axis.

Although the tumble effect doesn’t significantly affect the functionality of the device, it doesn’t allow a consistent sustained image to be displayed. One solution for this is to aerodynamically design the case of the device in such a way that the LEDs will always face the same direction when spinning. I will continue to search for a simpler solution to this problem, but at this point the Neopixel stick is the best candidate for the job.

A single microprocessor to dual processors

Since this device will need to fit on a keychain and be able to carry around in a pocket I want to use a reasonably compact low power microprocessor. So my first choice is the ATTINY85 since it only has 8 pins! The only issue I have encountered so far with the ATTINY is it’s limited program memory. 8 KB is simply not enough space to implement all of calculating the rotation angle, real time clock, time display and time setting functions.

So I decided to split it up between two ATTINY’s. One of them will be dedicated to calculating the rotation angle since that takes the most amount of processing power, while the other will keep track of time and display it when interrupted by the orientation detection processor.

So what have I actually done?

At this moment I have narrowed down the parts I need to build a first prototype of the Gyro’clock. They are:

  • Adafruit’s L3GD20H three axis gyroscope
  • MMA8452 three axis accelerometer
  • Adafruit’s Neopixel stick
  • Two ATTINY85 microcontrollers
  • 150 mAh rechargeable Lithium Polymer battery
  • Adafruits micro USB Lipo battery charger with 5V boost

I have ordered the parts. While they make their way to me, hopefully before the end of the year, I am working on developing the firmware. I have found some helper libraries to go with the gyroscope, accelerometer and the Neopixel array, and it should make coding significantly easier. The libraries are written for use with the ATmega328p processors, so I have to make some minor modifications to use them with the ATTINY’s.

Hopefully when the parts arrive I will have something interesting to show. Until then stay tuned and Thanks for reading!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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