Accurate wind vane calibration is critical, as any small variation will significantly penalize the accuracy of many other results : apparent and true wind angle, VMG, wind direction, etc. By using the procedure described in this post, it is possible to achieve a typical resolution of 1/4 to 1/3 of degree.

The following figure illustrates the interface between the Raymarine transducer and the microcontroller. With a regulated 8.0 V supply, the wind vane produces 2 analog signals (the green and blue wires) varying typically between 2.9 and 5.3 volts. The exact range is influenced by the length of the cable going to the top of the mast. This is why it is necessary to calibrate only after the installation is complete on the boat.

The analog signals can be fed directly to two ADC (analog-to-digital) pins of the microcontroller, as the input pins can tolerate up to 5.5 V. The microcontroller uses a 5 V volt reference to convert the signals to a number ranging from 0 to 1023. All voltages higher than 5 V are reported as 1023.

This is the form of the signals produced when the vane is rotated through a complete turn from 0 (wind from the front of the boat) to 360 degrees, clockwise from above.

The following figure illustrates the interface between the Raymarine transducer and the microcontroller. With a regulated 8.0 V supply, the wind vane produces 2 analog signals (the green and blue wires) varying typically between 2.9 and 5.3 volts. The exact range is influenced by the length of the cable going to the top of the mast. This is why it is necessary to calibrate only after the installation is complete on the boat.

The analog signals can be fed directly to two ADC (analog-to-digital) pins of the microcontroller, as the input pins can tolerate up to 5.5 V. The microcontroller uses a 5 V volt reference to convert the signals to a number ranging from 0 to 1023. All voltages higher than 5 V are reported as 1023.

This is the form of the signals produced when the vane is rotated through a complete turn from 0 (wind from the front of the boat) to 360 degrees, clockwise from above.

The sine waves suggest that the rotation of the vane is translated in a back-and-forth movement of two sweepers on straight-line potentiometers. The output signals do not vary linearly with the angle, as is the case with designs based on circular potentiometers.

What is not apparent in the above figure is that:

· the voltage amplitudes of the 2 curves are slighthly different;

· their mean values are slightly different;

· the phase angle between the two is not exactly 90 degrees.

Rigorous calibration involves the precise mathematical reconstruction of these two curves from a set of measurements taken on the boat during a trial run. To illustrate the procedure, an example with a reduced set of data points is presented here. In this example,we have gathered the following simultaneous green/blue data points (converted voltages) from a trial run on the water:

570/642 530/758 531/812 541/861 558/902

581/940 609/971 643/997 678/1017 879/1021

914/1004 944/983 968/960 987/937 1002/914

1014/892 1022/870 1022/692 1008/660 989/630

965/603 936/576 899/553 856/535 804/526

776/525 747/527 715/535 683/546 651/562

620/585 592/613 569/645 550/679 539/710

534/730

We have discarded all data with a 1023 value, as they are outside the range of measurement. We can now graph these green/blue pairs as X,Y points in Excel.

This may look like a circle, but it is in fact a slightly eccentric ellipse, with its axis slightly tilted, and its center slightly off the main diagonal. The next step is to find the equation of the ellipse that best fits these points. For this step, we use the NLREG software which has a convenient example of fitting an ellipse to data points (http://www.nlreg.com/ellipse.htm)

Using the NLREG software, we obtain the following characteristics for the fitted ellipse:

Using the NLREG software, we obtain the following characteristics for the fitted ellipse:

Parameter Final estimate

------------------ ------------------

Xcenter 783.408681

Ycenter 782.546036

TiltAngle 0.0326530049 radian

Xdim 254.549343

Ydim 257.708809

We can now define the parametric equation of the ellipse

Note that NLREG has defined the ellipse with the major axis on the Y-axis before rotation (Ydim > Xdim). The parametric equation defines an ellipse on the X-axis before rotation, so we have to use the following relations in order to use it with the NLREG parameters.

Xc = Xcenter = 783.408681

Yc = Ycenter = 782.546036

a = Ydim = 257.708809

b = Xdim = 254.549343

ϕ = TiltAngle – π/2 = -1.53814332 radian

The parametric equation gives the position of any point on the ellipse as we sweep around its center from 0 to 360 degrees, beginning near the bottom and going counterclockwise. This is exactly the correspondance that we are seeking between a vane angle and any pair of green*blue values.

Yc = Ycenter = 782.546036

a = Ydim = 257.708809

b = Xdim = 254.549343

ϕ = TiltAngle – π/2 = -1.53814332 radian

The parametric equation gives the position of any point on the ellipse as we sweep around its center from 0 to 360 degrees, beginning near the bottom and going counterclockwise. This is exactly the correspondance that we are seeking between a vane angle and any pair of green*blue values.

*X*(

*t*) = 783.408681 + 257.708809 cos(

*t*) cos(-1.5381432) – 254.549343 sin(

*t*) sin(-1.5381432)

*Y*(

*t*) = 782.546036 + 257.708809 cos(

*t*) sin(-1.5381432) + 254.549343 sin(

*t*) cos(-1.5381432)

The equation reduces to

*X*(

*t*) = 783.408681 + 8.413472 cos(

*t*) + 254.4136524 sin(

*t*)

*Y*(

*t*) = 782.546036 - 257.5714342 cos(

*t*) + 8.310324 sin(

*t*)

We can now calculate and plot the fitted ellipse along the original points.

t[deg] X(t) Y(t)

0 791.8221527 524.9746018

1 796.2610018 525.1588663

2 800.6959359 525.4215335

3 805.1256041 525.7625232

4 809.5486572 526.1817317

5 813.9637478 526.6790313

6 818.369531 527.2542704

7 822.7646647 527.9072739

8 827.1478103 528.6378428

... ... ...

... ... ...

354 765.1825947 525.5169396

355 769.6165261 525.2304464

356 774.0546587 525.0223339

357 778.4956406 524.8926657

358 782.938119 524.8414812

359 787.3807408 524.868796

360 791.8221527 524.9746018

We can also now reconstruct the green and blue signals from the equation results.

We already know that the vane is pointing forward (AWA = 0) when the green signal is at or very near its maximum value. There is a (approximately) 90 degrees offset between the zero angle of the equations and the zero AWA. We will now apply a preliminary offset of 90 degrees to the results of the equation so that we can graph the curves with respect to this nominal AWA. Even if this offset is not exactly 90 degrees, the remaining small adjustment will be merged in the final offset adjustment that we will have to make to correct the alignment of the transducer with the centerline of the boat.

We use only the thick lines for calibration, where the values are between the intersection points of 964 and 602. When the green value is outside the red zone, we use the blue curve, otherwise we use the green curve. When we have determined the color of the curve to use, there are 2 possible angles for the same value, which we can separate by noting if the blue value is greater or lesser than the green value.

For efficiency, we precalculate the angle for each thick line value inside the red zone, so that the green (or blue) value defines an index in a lookup table. The lookup tables are stored in the flash memory of the microprocessor.

Green | G<B | G>B | Blue | G<B | G>B | |

602 | 133.56 | 222.65 | 602 | 222.63 | 313.68 | |

603 | 133.24 | 222.97 | 603 | 222.32 | 313.99 | |

604 | 132.92 | 223.29 | 604 | 222.01 | 314.30 | |

605 | 132.60 | 223.61 | 605 | 221.70 | 314.60 | |

606 | 132.29 | 223.92 | 606 | 221.39 | 314.91 | |

… | … | … | … | … | … | |

… | … | … | … | … | … | |

781 | 88.65 | 267.56 | 781 | 178.50 | 357.81 | |

782 | 88.42 | 267.79 | 782 | 178.27 | 358.03 | |

783 | 88.20 | 268.01 | 783 | 178.05 | 358.25 | |

784 | 87.97 | 268.24 | 784 | 177.83 | 358.48 | |

785 | 87.75 | 268.46 | 785 | 177.61 | 358.70 | |

… | … | … | … | … | … | |

… | … | … | … | … | … | |

960 | 44.18 | 312.03 | 960 | 134.63 | 41.67 | |

961 | 43.87 | 312.35 | 961 | 134.33 | 41.98 | |

962 | 43.55 | 312.66 | 962 | 134.02 | 42.29 | |

963 | 43.23 | 312.98 | 963 | 133.71 | 42.60 | |

964 | 42.92 | 313.30 | 964 | 133.39 | 42.91 |

Future enhancement considered : add an external 12-bit ADC chip connected through SPI bus to achieve a resolution better than 0.1 degree.

UPDATE : I am now using a simpler method to calibrate the wind vane. See also here for the related microcontroller code.

## No comments:

## Post a Comment