RPM - DIV32 Problem


Results 1 to 11 of 11

Threaded View

  1. #1
    Join Date
    Dec 2007
    Posts
    60

    Default RPM - DIV32 Problem

    I am reading a tacho out line from an engine ECU with pulsin, scaling it, then displaying it on an LCD screen. I have had it working with the following code...

    Code:
      PULSIN PORTD.6,1,rlow                             
      PULSIN PORTD.6,0,rhigh                            
      rpm = rhigh + rlow
      rpm = rpm / 50
      rpm = 60000 / rpm
      if rpm = 65535 then
        rpm = 0
      endif
    ...
      lcdout $fe,$ca,dec rpm,"rpm  "
    in the higher RPM, the resolution drops, so I figured if I was to change my calculations to be ... rpm = 3000000 / rpm ... then the resolution would increase.

    However when I make it ...

    Code:
      PULSIN PORTD.6,1,rlow                             
      PULSIN PORTD.6,0,rhigh                            
      rpm = rhigh + rlow 
      tbase = 50 * 60000
      rpm = div32 rpm
      if rpm = 65535 then
        rpm = 0
      endif
    The result is roughly 32370rpm
    when the revs are increasing, the displayed rpm decreases, and visa-versa... but when the rpm is steady (at idle, or held steady at any RPM) the displayed rpm settles back to 32370

    Is there something I am missing here? I am successfully using DIV32 many more times in my code for other functions.

    Also I thought I might be overflowing the DIV32 integer (but according to my manual I am not) so I thought I would try....

    Code:
      PULSIN PORTD.6,1,rlow                             
      PULSIN PORTD.6,0,rhigh                            
      rpm = (rhigh + rlow) / 10
      tbase = 500 * 600
      rpm = div32 rpm
      if rpm = 65535 then
        rpm = 0
      endif
    This results in 0 being displayed all the time.

    At idle, rlow, and rhigh (which are identical) read approximately 1400 each, which when I do my maths on paper, (either method I have shown) comes out to approximately 1071rpm which would be correct




    Could somebody more intelligent or more observant than I please help me?


    Also might add I'm using a 16F877A
    Last edited by davewanna; - 11th April 2008 at 03:35.

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. Problem with Div32
    By lerameur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd April 2008, 02:54

Members who have read this thread : 1

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