Trying to measure TACH pulses.


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Mar 2018
    Posts
    2

    Arrow Trying to measure TACH pulses.

    I'm using a PIC18F67K40 on PBP gold at 64Mhz and I am trying to measure "TACH" pulses on PORTB.0 that are being simulated from a signal generator. I'm trying three different methods just to see how things work. I am thinking that once I can be assured that the pulses are being recognized by PORTB.0 in any form or fashion then I can proceed with actual circuitry work out my permanent code to recognize and report true RPM. Problem is that I can't seem to get PORTB.0 (or PORTB.1, etc..) to recognize the signal from the signal generator.
    Currently using 60-200 Hz at 5 volts from the signal generator in square wave ( with varying duty cycles, but I've tried sine, sawtooth, and various pulses types).

    My test code is basically:

    Do_Tach:
    COUNT PORTB.0, 1000, RPM ' to count number of pulses in 1 second and store in word RPM
    RPM = RPM * 60
    serout LCD_out,6,[017,0,0," RPM: ", #RPM," "] ' print out to my LCD on line 0.
    return
    Do_Count:
    COUNT PORTB.0, 1000, PCount' to count number of pulses in 1 second and store in word PCount
    serout LCD_out,6,[017,0,1,"COUNT: ",#PCount, "cnts/sec "] ' print out on my LCD line 1
    return
    Do_Pulse:
    PULSEIN PORTB.0, 1, TPulse ' read pulse on PORTB.0 and store result in word TPulse.
    serout LCD_out,6,[017,0,2,"PULSE TIME: "] ' print out on my LCD line 2
    return

    Thus runs as a loop with a loop counter and the loop count is displayed on my LCD line 3 (code not shown)

    I can see the generated signals at my board with my scope.
    I can see the loops being counted on my LCD.
    I get no response from PORTB.0 or PORTB.1

    Before I build a new board I thought it would be best to check with the forum to see if I have missed something, done something stupid or whatever. I have not tried interrupts on this but can see where it might be needed for the PULSEIN statement.
    I thought about doing an interrupt on a PORTB.0 change to read the system clock and compare it to the last interrupt time, but can't remember how to read the clock.

    Open to any criticism that would help.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,803


    Did you find this post helpful? Yes | No

    Default Re: Trying to measure TACH pulses.

    Maybe Timer module can help you on this?

    The Tachometer pulses will be counted by a timer and the timer will be gated by a controlled time base.

    This is the base of a frequency counter. And you can do other things while the timer counts pulses instead of waiting as is the case with COUNT command.

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    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

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,803


    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

  5. #5
    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

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,803


    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

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 : 2

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