timing like a stopwatch


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Default timing like a stopwatch

    hey,

    to measure the frequency of a digital source, i would use interupts for each drops or rise to measure each half wave, how would i create a timer that would basically work like a stop watch?

    so the interupt sends the program to a part where the timer is. and the timer times between each half wave and then resets to measure the next half wave... etc

    thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If your interrupt is at Zero-Cross, then it simply jumps to any of your TIMER registers, reads the current value and resets it to Zero ready for the next period. You've a shed-load of Timers to chose from in most PICs, and which one you use (8 or 16-bit) will depend on the frequency of your measured wave. You will have a few uS error (the time taken to jump to the interrupt and read the clock) which can be mitigated by how good your coding is... PICs with PWM module also have CCP... this is called a CAPTURE COMPARE MODULE which again (depending on your wave period) could be a better bet than starting/stopping Timer Registers yourself. Read all about it in your PICs Datasheet.

  3. #3
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    i have looked at the CCP which you described, on the pic im using (18f2431) it does include it, however im needing to measure 3 phases all simultaneously. this ccp only provides one pin to work with, the RC2/CCP1, and since I have 3 phases needing 3 ccp pins i can't see this method working? unlesss you can put them all through one pin? however that seems a bit unlikely since there would be no specific rises or drops...

    thanks for the reply

  4. #4
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok ive realised i can just use the motion feedback module to get what i need haha it does absolutely everything for me if i give it one command...

Similar Threads

  1. 12F683 serout timing
    By Hobie Cat in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st December 2009, 16:57
  2. 18F2550 timing
    By sstt1976 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 22nd August 2008, 00:30
  3. PIC 12c509 - No External timing components
    By stay_aliveuk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th September 2006, 17:20
  4. HSEROUT buffering and timing - 16F88
    By picster in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 5th March 2006, 17:52
  5. mplab stopwatch
    By nimonia in forum General
    Replies: 0
    Last Post: - 6th November 2005, 18:05

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