Arduino 3DOF Head Tracker

Hi Mike,

I've not seen your data sheet, but I think those output frequencies are usually the maximum frequencies the sensors can be use to detect. If your thing is vibrating at higher than 88Hz, the gyro will not be able to respond fast enough to output the true motion. So there it is probably better to try to sample at lower frequencies than the maximum.

I am sampling everything at 100Hz, which I think is more than enough, you should be able to get away sampling everything at 50Hz.

The analogReference(EXTERNAL) is used to map the voltage from the sensor to the analogRead() function for increased resolution. Because my arduino is at 5V, without the external reference, analogRead returns 1024 for 5V, 0 for 0V, but the maximum output of my sensors are 3V, so I'm only using 3/5th of the full resolution, by sending 3V to the analogue reference pin, and setting the analogReference(EXTERNAL), the voltages are mapped: 0V -> 0, 3V -> 1024.

Now, the 5K resistor is use to connect the external voltage to the analogue reference pin, not the analogue in pins!

Next I will be using Zitron's code to convert the filtered unit-less values I am outputting now, to degrees, Elevation, and Roll. Maybe someone can advise what to do with the Z-axis value ... at the moment it is only telling me whether the project is upside down or not.

You can use the arctan2(x,y) function like in my code to combine the Z value with X or Y, this way you can get a full +/-180 dgr values, with better accuracy.

Another issue - how to separate Elevation and Roll from the 'impulse acceleration' caused by motion? I would like to provide separate outputs to the computer for these, and have been trying to do this in the Visual Basic program with little success.

If the accelerometer is all you have, you can't! If you have the gyro working, you can use some sophisticated mathematical filters to reduce the effect of motion by combining the gyro and accelerometer readings. I am in the process of trying to do this myself...

Cool project, good luck!
-Z-