Pic based Wind Speed meter


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    Were you interfacing the Memsic to a pic or into something like an Aurdino / Propeller / Stamp? I've used the 3-axis versions quite a bit in my Tri-copter build, but was hoping to interface to a PIC, for one thing they are a lot cheaper in SA and also easier to come by.

  2. #2
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    Quote Originally Posted by Bobbo_ZA View Post
    Were you interfacing the Memsic to a pic or into something like an Aurdino / Propeller / Stamp? I've used the 3-axis versions quite a bit in my Tri-copter build, but was hoping to interface to a PIC, for one thing they are a lot cheaper in SA and also easier to come by.
    The output is a 100Hz PWM signal, easily read with any MCU that can measure a pulse. I'm new to PICs, but "Pulsein" seems like just the ticket. The link was only to show the Memsic; the data sheet is there as well.

  3. #3
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    You Can use Hall Sensor
    By read of North and South of the magnet it account 1 return for each turn of the shaft.
    My Hobbies is PicBasic PRO

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


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    You could use the internal timer of the PIC to measure the time between pulses. I have done something similar to measure the frequency of an AC supply.

    Code:
    define OSC 40
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    
    'set up timer 
    T0CON = %00000001 '1/4 prescale fosc/4 not running (40MHz)
    TMR0H = 0  ;Clear registers
    TMR0L = 0
    
    ASM
    INT_LIST  macro    ;  IntSource,  Label,   Type, ResetFlag?
            INT_Handler    INT0_INT,  _ZERO,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT0_INT     ; enable external (INT) interrupts
    
    goto start
    
    ZERO: 'we have just detected zero cross signal.
    'first job is to sort out the timer
    @ bcf T0CON,TMR0ON ; Switch off timer
    period.lowbyte = TMR0L  'Record Result
    period.highbyte = TMR0H
    @ clrf TMR0H  ; Reset registers to zero
    @ clrf TMR0L
    @ bsf T0CON,TMR0ON  ;Start timer
    period = (period / 5) * 2  'Gives period value in microseconds
    @ INT_RETURN
    
    start:
    'wait for interrupt to happen
    goto start
    
    END
    You dont need to use interrupts either just a loop waiting for your input signal. In fact not using interrupts might be better. You could sort out your calculations and displaying the result without worrying about being interrupted.

    You would need to set up the timer to give a useable range. I use the "PIC Timer Calculator" to do this, it makes things much easier.
    You may need more than one pulse per revolution to give results at low wind speeds.

    You may need to use the timer interrupt to flag if the timer has overflowed (got to 65535 & started counting again from zero) otherwise in very low winds you may not get a pulse before overflow, & the results would be wrong. If you get a timer overflow interrupt then you can say that the wind speed is zero.

    http://pic-timer-calculator.software.informer.com/
    http://darreltaylor.com/DT_INTS-18/home.html

    Ofcourse this is all more complicated than using pulsein. But It is sometimes good to play around with more complex answers. It is the only way to learn new things. One month ago I knew nothing about using timers or Interrupts. Now it is second nature, and I wonder how I managed to get by without them.

    Regards
    Bob.

  5. #5
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    Hi Bob,

    I totally agree, I have been playing with the manual AD routines and find it much more stable than the ADCIN function ,:-), the only question is which 18F to use, currently i have a 16F876A with a LCD connected and would like to connect some temp sensors and perhaps another pressure sensor, so im not 100% sure which 18F chip would be better suited. Any advice?

    Kind Regards
    Rob

  6. #6
    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 Rob,

    That was written for a 18F1220 18 pin device. I also use 18F2420 28 pin, and 18F4550 40 pin. It depends which of the internal peripherals you want to use. Microchip have a chip selector tool on their site. You tell it what you need, and it will sugest which chips are suitable. Though it did not work last time I tried, but that was probably due to our totally slow, & unreliable internet at work.

    I love how you can get clock speeds of 40 or 48MHZ using 10 or 20MHZ resonator, and using the HS PLL Enabled option. You can pretty much ignore how long calculations etc. take. It's so fast that it usualy makes no difference to your results.

    The only things that get in the way are LCD, EEPROM, or serial comms, etc that always take a long time.

    Regards
    Bob.

  7. #7
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: Pic based Wind Speed meter

    Hi All,

    Been a slow coding month, although I have been thinking and reading on how to do it, think i have settled on a disk option using a Phototransistor and counting the triggers every 1.5s using something like:

    Count PORTB.2,1500,RPM

    Depending on the number of gaps in the disk i can then do the maths to calculate the RPM and then tweak it / calibrate it to give me a rough wind speed, :-).

    Going to start working on the mechanical parts of it this week and will post pictures and code once its done, :-)

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