Anemometer Trouble

Ninja MacNinja

New Member
I am having trouble with my anemometer not providing values. It is a cheap Maplin product which I have seen lots of posts about, but none are solving my problem. The anemometer provides one click per 1.492mph over 1 second. The anemometer itself pulses from 4.08V to 0V, on a 4.5v source, which is twice per revolution. I have spent all day looking at and trying different codes from the forums, but with no luck. I am trying to get this to display on the AXE134Y but I am only getting a 0 value. I based my code on that of a previous forum post, which is below. Any help would be great.

main:
count C.1, 1000, b1
let b5=b1*1492/1000
serout B.3,N2400,(254,128)
serout B.3,N2400,(254,1)
serout B.3,N2400,(#b5," ","mp/h")
 

inglewoodpete

Senior Member
I wrote some code for an 08M2 connected to a Davis anemometer. Obviously different to a Maplin one (not available in Australia as far as I know). My code was to control an animated video display rather than display the actual wind speed.

You don't mention which PICAXE model you are using or what speed it is running at. I imagine your code provides poor granularity at low wind speeds since you are counting pulses during a second (assuming 1000mS at the PICAXE's default speed.

A couple of years have passed since I developed the code shown below. I used the PICAXE to measure the pulse width to get better low speed numbers. Linearity was not a problem for my project but this method may not work well for you.
Code:
[color=Green]'
' **** GetSpeed: Read anemometer pulse width and calculate speed 
'
'        Used:    wPulseWidth             '10uS increments @4 MHz
'        Output:  bWindSpeed              'Inverse of pulse width
'[/color]
[color=Black]GetSpeed:[/color][color=Blue]SetFreq m2
         Pause [/color][color=Navy]2
         [/color][color=Blue]Pulsin [/color][color=Black]iWindSpeed, cRise, wPulseWidth  [/color][color=Green]'Rising edge
         [/color][color=Blue]SetFreq m4
         Pause [/color][color=Navy]2
         [/color][color=Blue]If [/color][color=Black]wPulseWidth [/color][color=DarkCyan]= [/color][color=Navy]0 [/color][color=Blue]Then          [/color][color=Green]'Counter timeout: wind speed very low
            [/color][color=Black]bWindSpeed [/color][color=DarkCyan]= [/color][color=Navy]0
         [/color][color=Blue]Else
            [/color][color=Black]bWindSpeed [/color][color=DarkCyan]= [/color][color=Navy]65535 [/color][color=DarkCyan]- [/color][color=Black]wPulseWidth [/color][color=DarkCyan]+ [/color][color=Navy]1 [/color][color=DarkCyan]/ [/color][color=Navy]256
         [/color][color=Blue]Endif
         Return[/color]
 

hippy

Technical Support
Staff member
Probably the first thing to do is just report the value of the count on the terminal display -

Code:
#terminal 4800 ; or #terminal 9600
main:
  count C.1, 1000, b1
  sertxd( "Count=", #b1, CR, LF )
  goto main
If the count is always zero there is perhaps some hardware issue, the sensor connected to the wrong input pad, wrong signal wire used, missing power connection etc. Might be worth posting a photo of your hardware.
 

oracacle

Senior Member
I ran this in the simulator and it works just fine

Code:
[color=Black]main:
      [/color][color=Blue]let [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]40                   [/color][color=Green]'simulate 40 pulses
      [/color][color=Blue]let [/color][color=Purple]b1 [/color][color=DarkCyan]= [/color][color=Purple]b0 [/color][color=DarkCyan]* [/color][color=Navy]1492 [/color][color=DarkCyan]/ [/color][color=Navy]1000     [/color][color=Green]'do maths
      [/color][color=Blue]end[/color]
I would do as hippy suggests and check the picaxe is getting a signal. you can check the sensor itself by connecting it to a battery and led just to make sure it actually working before you pull your hair out.
 

AllyCat

Senior Member
Hi,

Yes, as others have said, it's probably a hardware (or pin mis-naming) issue.

Using b5 is OK and it may never "see" more than 65 mph, but it would be wise to change the scaling to 149/100 or 746/500, since you're in Scotland. ;)

The commercial stations using that anemometer all measure over a 2 second period to resolve down to 0.7 mph.

Cheers, Alan.
 

erco

Senior Member
Using count, you'd need to sample for several seconds at moderate windspeed.

Per iwp's example, pulsin might yield more usable data faster, but since it times out at 0.65536 seconds, ~3 mph would be the minimum value measured with your hardware. I'd call that wind "light and variable" anyway.
 

oracacle

Senior Member
while this does not help with no data issue, you can display your decimal places if you so wish,
a piece of test code to display speed in terminal window
Code:
[color=Black]init:
      [/color][color=Blue]let [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]1[/color]
[color=Black]main:
      [/color][color=Blue]let [/color][color=Purple]w1 [/color][color=DarkCyan]= [/color][color=Purple]b0 [/color][color=DarkCyan]* [/color][color=Navy]1492
      [/color][color=Blue]let [/color][color=Purple]bptr [/color][color=DarkCyan]= [/color][color=Navy]4
      [/color][color=Blue]bintoascii [/color][color=Purple]w1[/color][color=Black], [/color][color=Purple]@bptrinc[/color][color=Black], [/color][color=Purple]@bptrinc[/color][color=Black],[/color][color=Purple]@bptrinc[/color][color=Black],[/color][color=Purple]@bptrinc[/color][color=Black],[/color][color=Purple]@bptrinc
      [/color][color=Blue]let [/color][color=Purple]bptr [/color][color=DarkCyan]= [/color][color=Navy]4
      [/color][color=Blue]do
            if [/color][color=Purple]bptr [/color][color=DarkCyan]= [/color][color=Navy]6 [/color][color=Blue]then
                  sertxd ([/color][color=Red]"."[/color][color=Blue])
            end if
            let [/color][color=Purple]b1 [/color][color=DarkCyan]= [/color][color=Purple]@bptrinc
            [/color][color=Blue]sertxd ([/color][color=Purple]b1[/color][color=Blue])
            if [/color][color=Purple]bptr [/color][color=DarkCyan]= [/color][color=Navy]9 [/color][color=Blue]then exit
      loop
      [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Purple]b0 [/color][color=DarkCyan]+ [/color][color=Navy]1 [/color][color=DarkCyan]max [/color][color=Navy]44
      [/color][color=Blue]sertxd ([/color][color=Navy]13[/color][color=Black],[/color][color=Navy]10[/color][color=Blue])
      goto [/color][color=Black]main[/color]
 

inglewoodpete

Senior Member
Using count, you'd need to sample for several seconds at moderate windspeed.

Per iwp's example, pulsin might yield more usable data faster, but since it times out at 0.65536 seconds, ~3 mph would be the minimum value measured with your hardware. I'd call that wind "light and variable" anyway.
I think that's why I dropped the speed to 2 MHz for the duration of the pulsin command - can accept a longer pulse duration (slower wind speed).
 

neiltechspec

Senior Member
This is what I use for Wind speed using a modified Maplin Sensor.
The reed has been replaced with SS411P & 4 magnets for reliability, this gives the same number of pulses as the standard reed unit.

Note the symbol winda is a word vairable, the wsens ones are byte variables

serout ip_out,baud,("Measure Windspeed over 5 sec",cr,lf)
count wsens,1000,wind1 ;1st count of pulses in 1 sec
count wsens,1000,wind2 ;2nd count of pulses in 1 sec
count wsens,1000,wind3 ;3rd count of pulses in 1 sec
count wsens,1000,wind4 ;4th count of pulses in 1 sec
count wsens,1000,wind5 ;5th count of pulses in 1 sec

winda = wind1+wind2+wind3+wind4+wind5
winda = winda *10 /5 *149 /100

bintoascii winda,b3,b4,b5

serout ip_out,baud,("Average: ",b3,b4,".",b5," Mph",cr,lf)

Neil.
 

Ninja MacNinja

New Member
Thanks guys. I originally had it set at 16MHz as I had seen this worked on a previous project. As suggested there did seem to be an issue with one of my connections although I did get a pulse with my multimeter. After setting up an LED in parallel it now seems to be measuring the pulses. I have now used the following code and I seem top be getting values. Noture these are correct but I will go for a wee jolly to a weather station round the corner and check this out, although there doesn't seem to be much wind today, just rain. Thanks.

#terminal 4800 ; or #terminal 9600
main:
count C.1, 1000, b1
let b5=b1*1492/1000
sertxd(#b5,"mph", CR, LF )
serout B.3,N2400,(254,128)
serout B.3,N2400,(254,1)
serout B.3,N2400,(#b5," mph")
goto main
 

Ninja MacNinja

New Member
Ok, so I am now back from the weather station and I have got some pretty similar readings to those produced by the Met Office. I was getting between 7-10 mph with the Met Office readings going from 8-10, which I guess are time averages. Just thought I would let you know how I got on as you contributed.
 

Ninja MacNinja

New Member
Yeah that's what I done. I stay in a village with one of the METAR stations just outside it. Just a five min drive. Ill be going back again and spend longer logging the data once I have time and its a nice day. It was raining yesterday.
 
Top