Anemometer College Project Help

garrykneeshaw

New Member
Hi,

I am in the early stages of building an anemometer for a college project. I have built the 3 cup device and circuit using a hall effect sensor and 18M2 chip. I am now at the stage where I need to think about programming. I have very little knowledge of picaxe, my only experience is a simple flowchart for a voltage detector.

I am trying to achieve a device with an LCD screen which can show 2 different displays. first display is continuous wind speed and then when a button is pressed, a screen will show gust speed (highest speed every minute).

For the first display I am planning on using 'count' to count the pulses in a second and therefor update the screen every second with the wind speed. I have set up the device so that 1 revolution per second is equal to 1Mph so this should be fairly easy.

I think the second display will be more difficult, so far my thoughts are to store the number of pulses counted within each second into the chip memory and then somehow use picaxe to select the highest value every minute and display this on the screen. I have not used an external eeprom memory so I understand I will be limited with what I can store.

for example, in the 1st second there are 15 revolutions (store the number 15)
reset counter and in the 2nd second there are 20 revolutions (store the number 20)
and so on....
within the minute the highest count is 40 so I want to automatically select this and display it on the screen and then reset the memory to start counting again.

I have been doing some research but i'm struggling to find any example code.

any help would be greatly appreciated.

P.S. this is only a for a college project and it has to be completed in a few weeks so I realise that there are many ways to improve my device and make it more accurate but unfortunately I wont have time.

Thanks
Garry
 

lbenson

Senior Member
Welcome to the forum.

What LCD are you using? Any one I can think of would be able to display both numbers--present speed and highest speed in the past minute.

If you are looking at discrete minutes, you only need two variables (byte variables if neither count can exceed 255, word variables otherwise).

If you start over each minute, then, say, b1 is your first per-second count, and you set b2 equal to b1 (your first count this minute is also the highest so far). When you have your next per-second count in b1, you say IF b1 > b2 then : b2 = b1 : endif and at the end of the minute, you display the present value of b2, which will be the maximum per-second count for that minute. Then you start over.

The picaxe simulator can be very helpful in working this out, and you can set it up to simulate a 2-line or 4-line LCD.

(Note that it's better to use the SYMBOL token to give meaningful names to your variables: SYMBOL presentSpeed=b1 and SYMBOL maxSpeed=b2 )

Try to work out some sample code and let us see it after you've gotten something working in the simulator (or if you get stuck).

Using one more variable, this method would also allow you to display the highest speed in the present hour, and another could give you the highest in the present day. If you actually want the maximum to be a rolling value, like highest within the past 60 seconds, then you could use something like a 60-byte circular buffer in picaxe ram--still no eeprom required. (Google can be your friend for "circular buffer").
 
Last edited:

inglewoodpete

Senior Member
I have worked with wind vanes and anemomenters in the past, so your PICAXE project is feasible.

I think it helps to understand the steps you would need to take to do the task manually.

Firstly, you would need a timer running in the background, so you would know when one minute has expired. (Look for the 18M2's Time variable under system variables).

If you are searching for the fastest gust of wind, then you need to record the fastest gust. To do this, you'll need a variable to store the fastest gust. Each time you get a wind speed value, you would compare it with your fastest gust previously recorded for that minute. If the latest reading is faster than your previously stored gust, you would overwrite the gust value with he latest.

At some point, the background timer would say that a minute has expired. When that occurs, you would write down the fastest gust value (to the LCD), clear the fastest gust value and reset the background timer for a new minute to tick away.
 

garrykneeshaw

New Member
Thanks so much for the helpful replies. That's given me something to work towards. I am using the AXE033 LCD screen so yes it would be able to display both sets of data. The only reason I was planning on using a button to toggle between displays was to make it slightly more interesting when presenting the project. I will start writing the code this week and let you know how I get on with it.

Thanks again,
Garry
 

garrykneeshaw

New Member
Hi,

I have made progress with the code and managed to download it to my device. The continuous windspeed is displayed on the top line and the gust speed is displayed on the bottom line.

I count the pulses from the hall effect sensor every second and store this data in b1 (ee_add). I then store the highest value into b2 (max_count) I set the counter to count 60 times (60 seconds) and hoped that the max count would reset after this time. however, it appears to update the max speed continuously. is there a way to reset the max count every 3 minutes? I think this will give a more meaningful value of gust speed.

symbol sen_count = b0 ; counts hall pulses
symbol ee_add = b1 ; internal eeprom address
symbol max_count = b2 ; max wind speed
init:
serout B.7,N2400,(254,1)
pause 30
main:

for ee_add = 0 to 60 ; start a loop
count B.2, 1000, sen_count ; count pulses in 1sec
write ee_add,sen_count ; write sen_count into location ee_add
serout B.7,N2400,(254,128,"Wind Speed ",#sen_count, "MPH") ; display per second wind speed count

if sen_count > max_count then
max_count = sen_count
endif ; write highest value into location max_count
serout B.7,N2400,(254,192,"Gust Speed ",#max_count, "MPH") ;display gust speed
next ee_add ; next loop


goto main ; loop back to start
 

lbenson

Senior Member
On M2 devices, the "time" system variable counts seconds, so adding this code before "goto main" will allow you to do something when a desired number of seconds have passed.
Code:
if time > 18 then ' time counts seconds
  sertxd("18 seconds have passed",cr,lf)
  time = 0
endif
I used 18 seconds because it can be tested quicker. If you want 3 minutes, use 180.
 

AllyCat

Senior Member
Hi,

I think the COUNT command is "blocking" (including disabling the system interrupts) so you might find that the time variable increments much more slowly than expected (with a real chip).

However, your FOR ee_add = 0 TO 60 (strictly it should be 0 to 59 or 1 to 60) loop, combined with the one second COUNT, should take one minute to execute, so you could just put a maxcount = 0 after that loop to reset the maximum value. Or you might reset it to the average value as it normally won't be less than that

Cheers, Alan.

PS: But, you shouldn't be using WRITE in a one minute loop, because that could "wear out" the PICaxe in around 70 days (100,000 writes to the same memory location).
 
Last edited:

Aries

New Member
Why are you storing the individual values at all? You are displaying only sen_count and max_count, which are calculated without reference to any stored values. If you want to have all the values in a minute for debugging, use the temporary memory area (peek/poke) - but remember to start using it above the last of the b and w variables.
 
Top