View Full Version : Decimal point with serout?
Kman
- 7th July 2007, 07:32
How can I get the decimal point in the right place.
It shows up as 17.0 instead of 1.7
Help Please!
skimask
- 7th July 2007, 07:42
How can I get the decimal point in the right place.
It shows up as 17.0 instead of 1.7
Help Please!
Because the only time 'tenths' gets displayed is AFTER you've cleared it to zero...
Main:
SerOut2 SO,16468,["Milage = ",DEC Miles,".", DEC Tenths ,13]
VSSCount = 0 ' Clear VSS counter
TMR0 = 0 ' Clear TMR0 counter
Loop:
VSSCount = TMR0 ' Get TMR0 count
IF VSSCount > 99 Then
VSSCount = 0
Tenths = Tenths + 1
IF Tenths > 9 Then
Tenths = 0
Miles = Miles + 1
GoTo Main
EndIF
EndIF
GoTo Loop
And milage is spelled MILEAGE...:)
Kman
- 7th July 2007, 10:43
I have been trying everything! I cannot get this pic to count like a Cars odometer. ( ie.. 100.1, 100.2, 100.3 ect ). Anyone have a routine I can see?
Thanks,
kman
sayzer
- 7th July 2007, 11:40
I have been trying everything! I cannot get this pic to count like a Cars odometer. ( ie.. 100.1, 100.2, 100.3 ect ). Anyone have a routine I can see?
Thanks,
kman
100 will be one byte.
1 will be the second byte.
100.1 will be two bytes.
A VAR BYTE
B VAR BYTE
A=100
B=1
LCDOUT $fe,1,"Milage:", DEC3 A, "." ,DEC3 B
Kapiş?
------------------------------------------
Darrel Taylor
- 7th July 2007, 11:48
Kman,
You almost had it.
Just need to move the GOTO Main down 1 line, and clear the timer when it reaches 100 instead of after you Print it to the LCD/Terminal.
Main:
SerOut2 SO,16468,["Milage = ",DEC Miles,".", DEC Tenths ,13]
Loop:
VSSCount = TMR0 ' Get TMR0 count
IF VSSCount > 99 Then
VSSCount = 0
TMR0 = 0
Tenths = Tenths + 1
IF Tenths > 9 Then
Tenths = 0
Miles = Miles + 1
EndIF
GoTo Main
EndIF
GoTo Loop
OR, you can reduce it a little so that it works with the timer directly. Get's rid of VSSCount.
Main:
SerOut2 SO,16468,["Milage = ",DEC Miles,".", DEC Tenths ,13]
Loop:
IF TMR0 > 99 Then
TMR0 = 0
Tenths = Tenths + 1
IF Tenths > 9 Then
Tenths = 0
Miles = Miles + 1
EndIF
GoTo Main
EndIF
GoTo Loop
Now you just need a way to save it to EEPROM, so you don't lose the value when power is lost.
HTH,
Kman
- 7th July 2007, 14:33
Thanks Darrel ! Its counting away, and the decmal is in the proper Place!
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.