RPM Sensing


Closed Thread
Results 1 to 5 of 5

Thread: RPM Sensing

  1. #1
    Join Date
    May 2021
    Posts
    2

    Default RPM Sensing

    This works but is much too slow to use with a gas engine 6,100 rpm

    Main:
    ' clear the variables and timer
    t1_count = 0
    TMR1 = 0 : TMR1 = 0 ' not sure why I have to clear it twice
    PIR1.0 = 0


    ' start the timer and let it count for 1 second
    T1CON.0 = 1
    PAUSE 1000 ' this has to be shorter than 131072 counts
    T1CON.0 = 0 ' Stop the timer
    ' read the variables and check for an overflow
    t1_count = TMR1
    IF PIR1.0 = 1 THEN t1_count = t1_count + 65536
    ' send serial message with count, RPM
    HSEROUT ["Count = ", DEC t1_count, " RPM = ", DEC (t1_count * 15 ) , 10,13]
    GOTO main

    This works but a lot of Jitter

    'Each Pulse in Tick = 625nS.
    'RPM = 60 / (Ticker * 625nS)
    '60 / 625nS = 96000000
    'RPM_In = 96000000 / Ticker
    Tick = 0 ' Set Var to Zero
    D_Tick = 0 ' Set Var to Zero
    Ticker = 0 ' Set Var to Zero
    Pulsin PortB.0 ,1, Tick ' Measure Pulse Time High Per Rev.
    RCTIME PortB.0 ,0, D_Tick ' Measure Pulse Time Low Per Rev.
    Ticker = (Tick + D_Tick) ' Ticker = Pulse High + Pulse Low
    RPM_IN = (96000000 / Ticker) ' 96,000,000 Devide by Ticker = RPM

    HSEROUT " RPM = ", DEC RPM_IN , 10,13]

    I know that an interrupt code would be much more accurate and more steady do not know how to start making an interrupt driven code
    Help Please

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


    Did you find this post helpful? Yes | No

    Default Re: RPM Sensing

    TMR1 = 0 : TMR1 = 0 ' not sure why I have to clear it twice
    I think you're supposed to:
    Code:
    TMR1H = 0
    TMR1L = 0
    Your "PAUSE 1000" means that at best, you can only update your t1_count (tachometer) value once every second. Is that sufficient?

    I'd like to suggest reading Microchip's AN1980 Application Note. It deals with the Angular Timer function on the PIC16F161x parts, but lots of practical information that should help you.

  3. #3
    Join Date
    May 2021
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: RPM Sensing

    I have Complete Code for a Simple Ignition system 9 pages long -- it works well 100% accurate RPM Readout buut some what over kill for RPM readout
    I can display it if someone would be interested helping me trim it.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: RPM Sensing

    read this
    http://www.picbasic.co.uk/forum/showthread.php?t=16153

    what you have posted so far is unlikely to get much of a response.
    the more info you provide the better, at least post your best attempt {in code tags} with chip type and config, pbp version ...
    connection details better still a schematic even hand drawn along with some detail of the tacho input signal and how its been conditioned
    to become a useful pic input will help
    Last edited by richard; - 15th May 2021 at 07:34.
    Warning I'm not a teacher

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: RPM Sensing

    Have a look here : http://support.melabs.com/forum/picb...-code#post8248

    some similarities encountered ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. RPM With Timer1
    By mel4853 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 29th June 2009, 21:50
  2. mTouch capacitive sensing
    By jrprogrammer in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 1st November 2008, 22:54
  3. RPM Sensing
    By Helmutt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2008, 19:28
  4. RPM counter
    By RUBiksCUbe in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 24th November 2005, 17:08
  5. Rpm
    By jetpr in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2005, 14:46

Members who have read this thread : 3

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