Odo-meter for Knight Rider.


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Looks like you found some code that controls the display for the Odometer, I do not see anything here which does the math of turning 8000 counts into 1 mile. What I do see is this code writes to and reads from the eeprom and displays that on the 7 segment display, you would need to add some math routines to convert. In this case you know 8000 pulses = 1 mile so 8000/1.61 = 4968.944
    not quite 5000, rounded up to 4969. Set up a 16 bit timer, preloaded with the difference between 65535 and 4969 and when it overflows you have traveled 1km, you will likely have to adjust that number some to account for "latency" in the pic while you are reloading the number in the timer. Oh, it is THREAD not Threat.
    I don't think you'd really need any sort of timer unless you were trying to convert the odo input into a speed output. If it's just an odometer pulse input (which we're not even sure if the O/P is able to read that input in the first place), then it is just a simple matter of counting.
    If you do know it is actually 8000 pulses per mile, then yes, you are right in that 8000 / 1.61 = 4968.944.
    But since PBP can't do fractional numbers, and to add a bit more accuracy...
    km_travelled = ( pulses_total * 412 ) / 2048
    and to make it execute just a bit faster
    km_travelled = ( pulses_total * 103 ) >> 9
    Therefore, if you get 8000 pulses,
    8000 * 103 / 512 = 1609 = 1.609 kilometers.

    Hopefully this user's actual compiler (whether it be Proton or PBP) is capable of LONG (32 bit) variables, because using the above example, this will overflow after 13.18 kilometers. If a 32 bit variable is available, it'll be capable of counting up to 431,912 km's.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Oh sorry I did know now

    Darrel Taylor
    I did just really not know at other site not from this forum....

    I'll move to other site....

    But thanks to all to explaining me.
    Last edited by captain nguyen; - 27th July 2008 at 01:08.

Similar Threads

  1. Hall Effect flow meter with 16F876
    By revelator in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th March 2010, 21:42
  2. VU Meter
    By Andre_Pretorius in forum General
    Replies: 4
    Last Post: - 20th May 2009, 17:17
  3. PIC10F206 - What is the LOWEST Power @ Rest or Sleep
    By rixtalbert in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 18th March 2007, 15:42

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