Wind Direction Ouput

phil84

New Member
Hi All,
This is my first time posting on here as I am new to this. Currently I'm making a picaxe weather station that will display and transmit the usual weather data. All is going well so far, but I am stuck on how to read the data coming off the wind direction sensor, it is 8 reed switches that are connected to resistors. Here is a data sheet for it:-

https://www.argentdata.com/files/80422_datasheet.pdf

How would I go about displaying these 16 values e.g N E S W.

Any help would be much appreciated! :D

Phil
 

eclectic

Moderator
Welcome to the Forum.

As a starter, please read Manual 2, page 171.

readadc10

There will be many more replies, I'm sure. :)

And, do you own any PICAXE kit?

e
 

phil84

New Member
Thanks for that,
I've brought the axe002 starter board and also built a 18m2 board for the weather station.
I've had a play around with that and manage to come up with this program, only problem is that its a bit long, would be grateful if anyone had any better ways of writing this code. :)
Thanks,
Phil

main:
readadc10 C.0,w1 ; read value into w1

if w1 > 201 and w1 < 300 then
sertxd ("N", cr, lf)

elseif w1 > 601 and w1 < 700 then
sertxd ("NNE", cr, lf)

elseif w1 > 501 and w1 < 600 then
sertxd ("NE", cr, lf)

elseif w1 > 936 and w1 < 950 then
sertxd ("ENE", cr, lf)

elseif w1 > 901 and w1 < 935 then
sertxd ("E", cr, lf)

elseif w1 > 951 and w1 < 999 then
sertxd ("ESE", cr, lf)

elseif w1 > 801 and w1 < 850 then
sertxd ("SE", cr, lf)

elseif w1 > 851 and w1 < 900 then
sertxd ("SSE", cr, lf)

elseif w1 > 701 and w1 < 750 then
sertxd ("S", cr, lf)

elseif w1 > 751 and w1 < 800 then
sertxd ("SSW", cr, lf)

elseif w1 > 351 and w1 < 400 then
sertxd ("SW", cr, lf)

elseif w1 > 401 and w1 < 500 then
sertxd ("WSW", cr, lf)

elseif w1 > 1 and w1 < 100 then
sertxd ("W", cr, lf)

elseif w1 > 151 and w1 < 200 then
sertxd ("WNW", cr, lf)

elseif w1 > 101 and w1 < 150 then
sertxd ("NW", cr, lf)

elseif w1 > 301 and w1 < 350 then
sertxd ("NNW", cr, lf)

else
sertxd ("No Reading", cr, lf)
endif
pause 5000
goto main ; else loop back to start​
 

AllyCat

Senior Member
Hi Phil,

Yes, welcome to the forum. Ah, I recognise those resistor values well. ;) They're used in many weather stations manufactured by the Chinese manufacturer "Fine Offset" and "badged" under very many brand names such as Maplin and Clas Ohlson.

The resistor values are not very well chosen so there are a few levels which are rather close together, particularly at the low resistance end. So the "optimum" pull-up resistor is between 3k and 5k, although that will consume very slightly more power. I wouldn't rely on the voltage levels in that data sheet (the one for the 64.9k resistor is obviously wrong) but just measure them all on the PICaxe (and then choose threshold levels half-way between each pair). You may find that the intermediate directions (NNE, ENE .. etc.) are quite difficult to find because they require two reed switches to close at the same time and the magnet isn't really strong enough (or rather it's not well located).

Actually, you probably can't do much better than your code above because the resistance values don't run in sequence. But you could structure it as a "binary tree": a first IF detects the middle voltage level (of the 16) and branches to two more IFs that detect the middle levels in each half. Then quarters and eighths so each "decision" is made in only 4 steps.

Cheers, Alan.
 

phil84

New Member
Hi Alan,
Thanks for your help, I did get the instruments from Maplins. I like the idea of the binary tree, it will tidy up the code a bit and like you say it will make a decision in 4 steps.
Anyway thanks once again,
Phil
 

Tman1962

New Member
Phil,
Could you send me a picture and maybe some of the hardware specs/layout you are using for the wind gauge. I am trying to build one and am having some issues and would love to see how you are making yours work.
Thanks

Troy
 

marks

Senior Member
Hi phil84,
A while ago I had a weather station packup and started looking at this too
I do miss looking at the wind direction lol.
your values look similiar I think I used a 10k pulldown with it.
also found using a lengthy cable and varying supply made little difference to the values
suprisingly when I tested mine found one of the intermediate positions didnt work
problem being a glass reed switch was on an angle resoldering fixed this.
As AllyCat points out lol it has to be deadly accurate for intermediate positions to work
so think it is only really good for the 8 positions anyway which is good enough .
I was only going to use 8 statements like
IF w1 < 100 then : sertxt ("W")
I havent written any code for it yet just some scibble on paper somewhere
and most that was working out how to move a pointer graphic on an lcd lol.
 

boriz

Senior Member
How about a LOOKUP approach? Something like...

Code:
'''Pseudo code!
read adc_value
for direction=0 to 15
    lookup direction,(100,150,200,...all 16 values from lowest to highest),test_value
    if adc_value<test_value then:exit:endif
next direction
'''at this point DIRECTION contains the number 0 - to - 15 representing the wind direction angle accurate to 1/16th of a circle.
Note: The numbers need to be the threshold numbers where the reading changes from one direction to another.
 

AllyCat

Senior Member
at this point DIRECTION contains the number 0 - to - 15 representing the wind direction angle .
Hi,

Unfortunately it doesn't, because the resistance values don't run in sequence. :( That's because the intermediate directions are generated by pairs of resistors in parallel (see #4 and link at #1). So you would then need another lookup table to map the directions onto the resistance sequence.

Cheers, Alan.
 

Pongo

Senior Member
Hi,

Unfortunately it doesn't, because the resistance values don't run in sequence. :( That's because the intermediate directions are generated by pairs of resistors in parallel (see #4 and link at #1). So you would then need another lookup table to map the directions onto the resistance sequence.

Cheers, Alan.
But it would make sense to modify the code in reply #3 to use the Boris voltage threshold method because then each step is only a single comparison which should run faster.
 

AllyCat

Senior Member
Could you send me a picture and maybe some of the hardware specs/layout you are using for the wind gauge. I am trying to build one and am having some issues and would love to see how you are making yours work.
Hi Troy,

You'll find most of the details of the above "off the shelf" wind vane in this thread on another (Weather Station software) forum.

Also, the member Gina has described her own designed/built wind vane (using optical Gray code sensors and magnetic damping) in the "Homebuilt" section of that same forum. Hint: Search for "Vane" with author "Gina" in the "Homebuilt" section and you'll probably still get as many hits as you want.

Cheers, Alan.
 

BCJKiwi

Senior Member
There is a full detailed description of the way Davis do it here http://www.lexingtonwx.com/anemometer/ They use a 360 deg potentiometer without stops and the vane is mounted directly on the pot shaft. The part numbers are included on the page.

If rebuilding it may be possible to retrofit the FO with the pot which will then give 360 deg resolution using readadc instead of 8/16 points with poor accuracy.
Others have re-mounted/resized the magnet to obtain better reliability from the standard FO setup.
 

g6ejd

Senior Member
i think the Peet Bros have the best design sensor, they use two magnets on the sensor shaft and reed switches, then measure time between pulse edges for direction and number of pulses for speed. Their web page might still have an explanation with diagrams.
 
Top