Counting Events PIC18F8722


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136

    Default Counting Events PIC18F8722

    It's a weather station - and I'm measuring wind speed using an anemometer.

    The anemometer counts the pulses that occur in 3.6 seconds and this gives the wind speed in kph.

    I want to do this 'in the background' whilst the MCU gets on with other tasks.

    I am already using an ASM interrupt 'INT0' to count 'bucket-tips' for rainfall as a background process.

    The station runs on a PIC18F8722 mcu.

    Any advice/ideas on making the count a background process?

    Regards Bill Legge

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Well

    Setup a timer as a counter with an external clock input T*CKI pin. Then you just need to reset the counter to 0 and after 3.6 sec you stop the counter and read the value when you have time for it.

    How to know 3.6 seconds have passed is an other problem. Maybe you already have a timer running as RTC or you set up a timer to overflow after 3.6 sec. When the 3.6 s timer overflows you get an interupt and then you disable the counter clock input. If you set a flag in the 3.6 s timer interupt you can easily know that you have new valid data to be read from the counter register.

  3. #3
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Counting in the background

    Jumper,

    Thanks for the idea.

    Is there a simple/easy way to see what MCU resources the PBP compiler is using so that I don't use timers/registers/etc that will conflict?

    Regards Bill Legge

  4. #4
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default nope

    As far as I know you ned to keep track of what HW timers and counters you use your self :-) One thig to keep in mind is that if you use the HPWM in your pic that also steals a timer, usually timer 2.

    I hope you use DT's instant interupts since that is the only way in PBP to get the interupts to be performed when the happen and not as in PBP's usual way after the current command is executed.

    I would set up a timer to overflow every 0,1 sec as a RTC timebase and use that one to get the 3.6 sec (by increasing a variable in the interupt routine). By doing this you can have many events with different times beeing executed.

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. counting switch events beginner
    By mrpete in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd April 2009, 16:08
  3. DT Instant Interrupt counting
    By jderson in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 9th March 2008, 22:47
  4. Remain counting while sending out a pulse
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th January 2007, 15:51
  5. continious counting process (capture)
    By asynch in forum General
    Replies: 1
    Last Post: - 17th February 2006, 07:42

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