16F877@4Mhz calculate Pulsin to RPM


Results 1 to 25 of 25

Threaded View

  1. #18
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Leigh,

    Just took a quick look at your program, and I can't answer all those questions, but did notice one thing.

    The capture function of the CCP simply latches the Timer value into the CCPRH:L register when the specified event occurs. In this case thats after 4 RISING edges. To get a meaningfull result, the timer has to be started at the same time as the CCP starts counting it's 4 periods.

    You can just leave the timer turned off and let it capture 0 the first time, then as soon as the CCP1IF (PIR1.2) is raised, imediately start the timer, then reset the CCP1IF. On the next capture you should have a valid result.

    I don't know about all the rest, but one thing at a time usually works best.

    Maybe something like this
    Code:
    CCP1CON = %00000110			' Enable the CCP1 capture, every 4th rising edge
    loop:
    T1CON = %00010000 			' TMR1 prescale=1:2  Timer OFF
    TMR1H = 0                               ' Zero the Timer
    TMR1L = 0
    capture = 0
    StartLoop:
    	IF (capture = 0) Then StartLoop	' Wait here for the first capture
                    T1CON.0 = 1             ' Start the Timer
                    capture = 0             ' Reset  the capture flag
    CaptureLoop:
    	IF (capture = 0) Then CaptureLoop	' Wait here until captured
    	period.lowbyte = CCPR1L		' Store the captured value in
    	period.highbyte = CCPR1H	' period variable
    DT
    Last edited by Darrel Taylor; - 23rd April 2004 at 05:52.

Similar Threads

  1. Interrupt RPM and Taylors Elapsed time on 18F4620
    By Tobias in forum mel PIC BASIC Pro
    Replies: 70
    Last Post: - 3rd February 2010, 16:12
  2. Slow code needs a tune up
    By Tobias in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th January 2010, 15:05
  3. Pulsin vs. Interrupt RPM measurement
    By Tobias in forum General
    Replies: 1
    Last Post: - 31st December 2009, 01:29
  4. 16f877A and tmr1 external crystal question
    By comwarrior in forum General
    Replies: 3
    Last Post: - 13th July 2009, 00:40
  5. RPM - DIV32 Problem
    By davewanna in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th April 2008, 04:33

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