Welcome to the Parallax Discussion Forums, sign-up to participate.
Theory of Operation: There are a few things that need to happen to the RAW data in order to determine a relative Deg value. As it is, the RAW data has a value associated to it of Deg/sec but there is no real weight or meaning to that value if you don't integrate time with the reading. It's just an arbitrary unit of measurement without time associated to it. We need to integrate time into the equation in order to get a valid Deg value. The easy way to do this is to clear an accumulator, take as many RAW readings as you can in a fixed or known amount of time and add those readings to the accumulator. An initial reading of the accumulator is used as a Reference to 'normalize' the remainder of the data. This isn't the best approach, but it will work for this demonstration. It's basically a single value that represents several data samples and could be looked at as though it were an average although we aren't dividing it over a number of samples like you would with an average. Ideally this value would be dynamic and track over time instead of an initial reading up front. So, the remaining values from the accumulator are subtracted from the Reference value, and added to a Rotation accumulator. The number of Samples taken within the fixed amount of time can be calculated (or even directly counted) by dividing the initial accumulator value by 512 (<- the mid position of the 10-Bit ADC representing Vdd/2) In the program Example the 'fixed time' is 1/50th of a second and the calculations are basically as follows... Hope it helps.