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
Bookmarks