Gyroscope Vs Accelerometer

Tilt Sensors are still on their way, but my Sparkfun order came in today, along with some foam balls I orderred form Amazon! I didn’t get home until late, so I have not had too much of a chance to play with my new toys, but I did experiment a bit with the gyroscope and accelerometer as a way of getting the velocity of the ball (or at least something close enough to the velocity to fool any user).

I set up simple openFrameworks app to monitor each sensor and see how it reacted to different movements. I really wanted to get each of them in a ball using xBee, but something is going wrong with one of my xBees. I’m going to look into it tomorrow. Instead, I put the gyroscope in the ball and used long wires to attach it to the Arduino. Unfortunately, this limited the movement a lot more than I was expecting it to, and the ball really is not free rolling at all.

I was still able to get about 270 degrees of rolling out of it pretty naturally. Tracking the data made the prospect of using the gyroscope very promising. At any given angle of rotation, at least one of the two lines seemed to grow or shrink almost exactly with the speed I was moving the ball at. Taking the absolute value of which ever axis reading is further from the midpoint should give me pretty accurate data.

Next up was the accelerometer. Knowing that putting it in the ball wound up being somewhat limiting (even if it felt good to actually be rolling something around), I just wired this up with long wires, and just manipulated it by hand.

The data from this one was fairly promising as well. This gyroscope gets readings for all three axes, which may or may not be useful. In looking at the results, they tended to be fairly smooth, with the speed of rotation generally being able to be read as sin wave. Higher frequency waves resulted from me rotating it faster around that axis.

Along any given axis of rotation, generally two of the readings would follow this wave pattern, and the third would stay roughly centerred, which makes sense. To use these readings, I would probably just have to identify which axis was changing the most frame to frame and assume that was the most relevant.

One issue I did encounter, though, was that this sensor gave mysterious spikes every so often. These would probably not be hard to smooth out, but they were there.

And the winner is….


I’ll need to test more, but at this point, the gyroscope seems to do everything I need in terms of tracking velocity. In addition to not having spikes, the data will be much easier to interpret: just take the absolute value of the distance from the norm of whichever axis is giving stronger readings. In pseudo-code:
max( absolute(midPoint-yReading), absolute(midPoint-xReading))

The accelerometer would probably give me more detailed data, but I’m not sure that I need it, and the gyroscope seems to be a bit more reliable (not to mention a few bucks cheaper), and only uses two pins as opposed to the three being used by the accelerometer.

Of course, this testing may become irrelevant once I get the ball untethered and realize somehting that these tests did not pick up.

Next thing to test will be detecting range of two balls using the Infrared LEDs.

And just for fun, here’s a video of me rolling the ball around: