Odo-meter for Knight Rider.


Closed Thread
Results 1 to 10 of 10
  1. #1

    Default Odo-meter for Knight Rider.

    Hi,

    I'm new here, and I'm currently convert my car into KITT from Knight Rider.
    Some design are ready.
    And now I wanted making functional odo meter.




    I'm using cyberdyne speedosensor that count 8000 pulse a mile -> 5000 a KM.

    I have fount the code and adapted that not count down. only count up.
    But how can I change into 5000 pulse a KM.
    It's writed in picbasic. (*.bas)
    Oh, I'll use PIC16F628 or do you recommend other PIC.
    And I use simple RCD programmer.

    Code:
    '****************************************************************
    '*  Author  : Coenen Stijn [Stynus]                             *
    '*  Notice  : Copyright (c) 2008 ElektronicaStynus.be           *
    '*          : All Rights Reserved                               *
    '*  Date    : 20/07/2008                                        *
    '*  Version : 1.8                                               *
    '*  Notes   : Teller                                            *
    '****************************************************************
    Device  16F628
    Config WDT_OFF, PWRTE_OFF, MCLRE_OFF, INTRC_OSC_NOCLKOUT, LVP_OFF, BODEN_ON 
    ALL_DIGITAL         =   true  
    '****************************************************************         
    Symbol  Cu          =   PORTA.0
    Symbol  noPower     =   PORTA.4
    Symbol  digit2      =   PORTA.6
    Symbol  digit3      =   PORTA.7
    Symbol  digit4      =   PORTA.5
    Symbol  digita      =   PORTB.0
    Symbol  display     =   PORTB
    Symbol  digit1      =   PORTB.7
    '****************************************************************
            TRISA       =   %00111111
            TRISB       =   %00000000
    '**************************************************************** 
    Dim     CuBit       As  Bit
    Dim     index       As  Byte
    Dim     waarde      As  Byte
    Dim     waarde1000  As  Byte
    Dim     waarde100   As  Byte
    Dim     waarde10    As  Byte
    Dim     waarde1     As  Byte
    '**************************************************************** 
    'Init
    Clear
    DelayMS 1000
    'Oude tellerstand terug inlezen  
    waarde1   =   ERead 0 
    waarde10  =   ERead 1
    waarde100 =   ERead 2
    waarde1000 =  ERead 3
    
    DelayMS 1000
    '****************************************************************
    While 1 = 1
    '************************************************************
        'Knoppen inlezen
        'Count up
        If Cu = 0 And CuBit = 0 Then
            Inc waarde1
            If waarde1 = 10 Then
                waarde1 = 0
                Inc waarde10
                If waarde10 = 10 Then
                    waarde10 = 0
                    Inc waarde100
                    If waarde100 = 10 Then
                        waarde100 = 0
    		    Inc waarde1000
       	   	    If waarde1000 = 10 Then
    		       waarde1000 = 0
                        EndIf
                    EndIf            
                EndIf            
            EndIf
            CuBit = 1
        EndIf
        If Cu = 1 And CuBit = 1 Then
            CuBit = 0
        EndIf
        GoSub spanningweg
        EndIf    
        '************************************************************ 
        GoSub dispuit   
    Wend
    '**************************************************************** 
    'Subroutines
    dispuit:
        For index = 0 To 3  
            Select index
                Case 0
                    waarde  = waarde1
                Case 1
                    waarde  = waarde10          
                Case 2
                    waarde  = waarde100  
    	    Case 3
    		waarde  = waarde1000        
            EndSelect   
            Select Case waarde    
            Case 0          'gfedcba
                display =  %00111111    
            Case 1          'gfedcba
                display =  %00000110              
            Case 2          'gfedcba
                display =  %01011011              
            Case 3          'gfedcba
                display =  %01001111              
            Case 4          'gfedcba
                display =  %01100110              
            Case 5          'gfedcba
                display =  %01101101              
            Case 6          'gfedcba
                display =  %01111101             
            Case 7          'gfedcba
                display =  %00000111              
            Case 8          'gfedcba
                display =  %01111111             
            Case 9          'gfedcba
                display =  %01101111  
            'Bij fout
            Case Else       'gfedcba
                display =  %01111001     
            EndSelect
            Select index
                Case 0
                    High    digit1
                Case 1
                    High    digit2            
                Case 2
                    High    digit3    
    	    Case 3
    		High    digit4        
            EndSelect 
            DelayMS 1
            GoSub spanningweg
            Low digit1
            Low digit2
            Low digit3
    	Low digit4
        Next
    Return
    spanningweg:
        'Controleren op voedingsspanning
        If noPower = 1 Then
            EWrite 0 , [waarde1]
            DelayMS 20
            EWrite 1 , [waarde10]
            DelayMS 20
            EWrite 2 , [waarde100]
            DelayMS 20
    	EWrite 3 , [waarde1000]
    	While noPower = 1
                DelayMS 1000
            Wend
        EndIf
    Return
    '**************************************************************** 
    End

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    You posted this in the 'mel PIC BASIC' forum.
    Try this statement:

    Proton Basic <> MeLabs PicBasic AND Proton Basic <> MeLabs PicBasicPro

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Oh...

    Can admin move this threat for me?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by captain nguyen View Post
    Oh...

    Can admin move this threat for me?
    Can you find the Proton Basic forum section here?

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Do you mean "mel PIC BASIC Pro"?
    If yes, but how can I move this threat?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by captain nguyen View Post
    Do you mean "mel PIC BASIC Pro"?
    If yes, but how can I move this threat?
    There is no THREAT here.

    Apparently, you are NOT using MeLabs PicBasicPro. You are using PROTON Basic.
    Try again.
    Or maybe you expect somebody to covert a Proton Basic program to PicBasicPro for you?

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Or maybe he just doesn't realize the Proton forum is at ...

    http://www.picbasic.org/forum
    <br>
    DT

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Too Old To Change And Outta Beer . . .

    Hello Captain,
    I'm not fluent even in PBP much less Proton, but here is what I see . . . 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.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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

  10. #10


    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 00: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, 20:42
  2. VU Meter
    By Andre_Pretorius in forum General
    Replies: 4
    Last Post: - 20th May 2009, 16: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, 14:42

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