Pic based Wind Speed meter


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Holmfirth England
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    Hi Bobbo,

    Did you download the PIC timer calculator linked above?
    Using this we can see what is happening much more easily.

    Lets take a look, you have a 4MHz osc, and the timer uses fosc / 4, and your using tmr0 in 16 bit mode.

    So a prescaler of 1:2 gives us a timer clock frequency of 500,000Hz so microseconds value is result x 2 BUT! we can see the interrupt frequency is 7.63Hz. This means that you need at least 7.6 pulses / second otherwise the timer will overflow.

    Lets try 1:8 prescaler. Clock freq is 125,000Hz so period = result * 8, so less resolution, but interrupt frequency is 1.9Hz, so you only need at least 2 pulses / second to give a valid result.

    You need to decide what to do here, you may want 4 or 8 or even 16 pulses / revolution to give more accurate results over a wider range of RPM.

    The timer 0 interrupt you have called _TimePeriod. You need to have a service routine that just tells you that the timer has overflowed, and therefore the wind speed is too low to measure.

    Converting microseconds to wind speed will be tricky, since the higher the wind speed the lower your result. Thinking about it, it may be easier to count the number of pulses in the time it takes for the timer to overflow. This would need many pulses / rev, but the relationship between pulses & wind speed would be proportional and easier to scale.
    For example : prescaler of 1:16, preload timer with value 3036, this gives interrupt at 1Hz. So when timer interrupt happens, stop timer, scale pulse count, and display windspeed, zero the pulse count, set timer to 3036, start the timer, and return from interrupt. When not in interrupt simply increment the number of pulses in a loop. Forget preloading the timer, 1Hz is not required, since the result will need to be scaled anyway so knowing the exact time is not needed.

    Hope this helps.

    Bob...
    Last edited by BobEdge; - 1st November 2011 at 15:18.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts