I don't know if there's a 'correct' or 'standard' way, but typically I've handled such cases by making a scale that's twice as large as what I'm measuring, and keeping the average away from the edges. 0-360 degrees becomes -360 to 360. When the average gets close to the edge, perhaps 100 degrees away from either edge then I add or subtract 360 degrees depending on the edge. The input and output have to be changed into the correct range. If the average is below 0 then subtract 360 from the input before adding to the average, and add 360 to the average to get the output. There is an interesting corner case at 0, however, which may need some careful thought depending on the application. In this case, if the average is 0, then look at the input - if the input is above 180 then subtract 360 from the input. If below 180 then do not modify. In either case the average will have moved from 0 so the output equations can remain the same. If the input is at 360 or zero then the average remains the same, and the output is 0 (or 360 if you allow that in your system). Of course, if your input varies by 1/2 a cycle per measurement then you've got bigger problems than keeping a correct average - consult nyquist. :-) -Adam Wouter van Ooijen wrote: >Is there a (standard) way to calculate the average of a parameter that >is cyclic in nature, like the wind direction or the month of the year? > >Wouter van Ooijen > >-- ------------------------------------------- >Van Ooijen Technische Informatica: www.voti.nl >consultancy, development, PICmicro products >docent Hogeschool van Utrecht: www.voti.nl/hvu > > >_______________________________________________ >http://www.piclist.com >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist > > > > > _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist