|A Picaxe Weather Station - Wind Direction|
Example plot from the software running on the PC. The wind direction is plotted as a
series of dots.
The Wind Direction - Mechanical Details
The wind direction sensor has proved to be the most troublesome! It's very erratic due, I suspect, to its location. The grub screw holding the 'hub' to the central shaft has worked loose twice. I've now filed a flat on the shaft to see if this helps.
The Wind Direction ElectronicsThere are a variety of different schemes for sensing the direction of the wind. They mostly consist of either an array of 8 reed switches arranged at 45 degree intervals with a rotating magnet or a 360-degree (continuous rotation) potentiometer.
Both methods have their advantages and disadvantages. The major advantage is that they're both simple to implement. The disadvantage is that they're subject to wear and tear - especially a potentiometer.
An alternative to using reed switches would be to use Hall-effect sensors to solve the mechanical wear but they are still limited to their 8 distinct positions... Actually, by careful placement of the magnet, both reed switches and Hall effect sensors can be persuaded to provide a "pseudo" 16-position output (22.5 degree resolution) by allowing adjacent switches to be operated at the same time.
Ideally, I wanted to try something different and eventually decided on an AS5040 rotary magnetic encoder IC. Although it's a Surface Mount Device (which I try to avoid), it has several advantages which make its use appealing!
It has several different output formats, two of which are most suited to our purpose. The best accuracy is obtained through a digital (SSI) interface. However, as the signals would have to travel at least a couple of metres between the elevated sensor and the outdoor ground unit, this would quite likely have required a separate Picaxe on the masthead with a serial link to the ground unit - unnecessarily adding to the complexity.
The AS5040 has a Pulse Width Modulation output providing pulse widths between 1µs at 0 ° and 1024 µs at 359.6° Unfortunately an 18M2 Picaxe would be struggling to resolve the shortest of the AS5040's output pulses but, by feeding the PWM output into a simple RC filter circuit, a 0-5 volt analogue signal can easily be generated up at the sensor unit providing the ground-based Picaxe with a simple analogue input accurate to within about 5 degrees of rotation. The AS5040 datasheet suggests this method is perfectly suited to replacing potentiometers so this is the method I've chosen here.
There's a more detailed description of some tests I did with the AS5040 here.
do readadc10 B.3, w0 ;Read from AS5040 magnetic bearing pause 100 w0 = w0 * 64 / 182 ; Convert to 0 - 360 (degrees) debug ; Display in Prog/Edit debug window loop(Thanks to 'hippy' and others for guidance with the maths.)