# Measuring wind direction accurately with rotary encoder

Hi,
I've been asked to help with a project that involves measuring wind direction very accurately.

The direction will be restricted to a range of 20-30 degrees, but needs to be measured to an accuracy of +- 1/2 degree.

I was thinking of using a rotary encoder (like this one maybe) Rotary Encoder - 1024 P/R (Quadrature) - COM-11102 - SparkFun Electronics and simply attaching a small wind vane to it. The wind will blow, the vane will align with the wind and the encoder will turn, I just need to measure the position of the encoder.

Has anyone used this encoder, and can they tell me how freely the spindle rotates? The wind-strengths being measure are relatively low 5-15 m/s, so the encoder needs to be very low friction and move very easily. Or is there a better way if doing this?

Thanks

As that encoder is relative, how do you plan to determine the absolute wind direction?

Funny that Sparkfun mentions that it outputs grey code. There is a z output from looking at the pics.

If the direction is restricted then maybe a pot on the direction axis and the encoder on the speed axis.

I don't see how you can do it with only one.

Has anyone used this encoder, and can they tell me how freely the spindle rotates? The wind-strengths being measure are relatively low 5-15 m/s, so the encoder needs to be very low friction and move very easily. Or is there a better way if doing this?

use a gearbox might help, would also increase accuracy ...?

As that encoder is relative, how do you plan to determine the absolute wind direction?

I've not worked with encoders before, but I assume I can just align it with a known direction during the setup phase, and then measure all positions relative to one known position?

use a gearbox might help, would also increase accuracy

A gearbox would add friction wouldn't it? The encoder has 1000 pulses/rev or 2 and-a-bit per degree, which should give an accuracy to within 1/2 a degree.

I had thought that the biggest issue would be the shafts resistance to turning - it needs to be smooth enough for a gentle breeze to turn a weather vane on the shaft.

Fulliautomatix:
I've not worked with encoders before, but I assume I can just align it with a known direction during the setup phase, and then measure all positions relative to one known position?

Yes, that will work

A gearbox would add friction wouldn't it? The encoder has 1000 pulses/rev or 2 and-a-bit per degree, which should give an accuracy to within 1/2 a degree.

I had thought that the biggest issue would be the shafts resistance to turning - it needs to be smooth enough for a gentle breeze to turn a weather vane on the shaft.

Yes it would add friction but apparently the rotary encoder is accurate enough.
You might investigate in interrupts (attachInterrupts) as that is the way to handle pulses fast.

You might add a digital compass on top of the vane, to get some rougher direction?

Do you need to use a rotary encoder? How about using a high quality analog potentiomenter and feed its output into one of the Arduino's analog inputs.

For example, most potentiometers that I've seen rotate about 270 degrees. If you conected the potentiomenter's output to one of the Arduino's analog inputs, the Arduino would divide up the potentiometers output (from full clockwise to full counter-clockwise) into 1024 divisions. Since you said that you only need to measure 20-30 degrees of rotation, you could scale the analog input's voltage (using the MAP function) so that only 20-30 degrees of rotation would be divided up into 1024 divisions - much more accurate that the rotary encoder. Then you could write software so that 512 would be the center, 0 would be 15 degrees left, and 1023 would be 15 degrees right. With additional math you could figure out angles.

As far as knowing the heading/direction of wind, if you are doing the installation there should be a fairly simple way to align the center point of the 30 degrees that you want to measure using a regular compass. Use some sort of physical "stops" to prevent the wind vane from rotating past the angle that you don't want to measure.

Matt