Trying to measure TACH pulses.


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    What about the good old analog stuff?
    Code:
    ANSELB.0 = 0   ' Enable digital input circuitry to work properly on PortB,0

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,128


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    Maybe I do not see your point Henrik. How does this help?

    Ioannis

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    Ioannis, The porta and portb default to digital input buffers DISABLED. They need to be set for digital operation before this type of use. Also I have to ask, Why are you counting pulses to get the RPM value? Seems like kind of a crude method. I would look at the time between leading edges and then compute the RPM value. Much faster...
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,128


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    Oh I see. I thought that was trivial and eagleman would have correct setup of PIC.

    Ioannis

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    Trivial yes, but trivial stuff can bite you plenty hard and since no setup code what so ever was posted and "Turn off analog functions" is the solution to 20%* of the questions posted here I thought it was worth a shot :-)

    * I have no data to back that number up.

    /Henrik.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,128


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    You are absolutely right. Too many times it was the reason for erratic behavior.

    Ioannis

  7. #7
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    eagleman, as of this reply, you show 2 posts. Let us get to know you a bit. How long have you worked with PICs? How about PBP specifically? Is this your 1st project, or is it your 17th?

    Since you're using a K40 part, you can use MFINTOSC for TIMER1. You can either use an INT0 (or IOC) type interrupt on PORTB.0, triggered by your tach pulse, or even just use TMR1GIE. In the ISR, move your TMR1H_L to your variable Tach, then clear TMR1H_L for next round. You should disable TMR1 before reading, then re-enable after you read your values. Also be sure to clear whatever Interrupt Flag got you to the ISR (INTOIF or TMR1GIF).

    The math for converting Timer pulses (Tach) to RPM is:

    RPM = (Clock / Tach) * 60

    In this case,

    RPM = (500,000 / Tach) * 60

    Right off the bat it becomes obvious that you will have to enable LONG to handle the math.

    I prefer to guide people to self discovery as opposed to handing out answers. If this doesn't make sense to you, ask specific questions. Be sure to tell us what you have tried and the results you got. (You did an excellent job in Post #1).

Similar Threads

  1. Trying to measure time between two pulses on different pins.
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 8th September 2014, 12:05
  2. Measure time in mS between two pulses
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th March 2011, 07:20
  3. Hall sensor tach
    By zipphreak in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th March 2006, 14:25
  4. Tach Project (binary counting)...
    By Netjammer in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 18th November 2004, 12:50
  5. LED Tach Sources?
    By Netjammer in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th October 2004, 03:47

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