Decimal point with serout?


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kman View Post
    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.

    Code:
    A VAR BYTE
    B VAR BYTE
    
    A=100
    B=1
    
    LCDOUT $fe,1,"Milage:", DEC3 A, "." ,DEC3 B
    Kapiş?


    ------------------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default

    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.
    Code:
    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.
    Code:
    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,
    DT

  4. #4
    Join Date
    Jan 2005
    Posts
    21


    Did you find this post helpful? Yes | No

    Smile

    Thanks Darrel ! Its counting away, and the decmal is in the proper Place!

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. How do I add a decimal point?
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2009, 11:47
  3. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  4. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  5. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26

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