1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

How do I put a comma in a decimal number and place it on the screen of the LCD?

Discussion in 'Oshonsoft' started by Winch, Dec 28, 2015.

  1. Winch

    Winch New Member

    Joined:
    Sep 5, 2014
    Messages:
    24
    Likes:
    0
    How do I put a comma in a decimal number and place it on the screen of the LCD?
    I read an AD input and would like to insert a comma in the result. (see the code)

    Code (text):
    Adcin 0, an0  'read AN0 and write value to AN0

        Lcdcmdout LcdLine1Pos(12)
        Lcdout #an0

        Lcdcmdout LcdLine1Pos(1)
        Lcdout "Volt"
            pc1 = an0 * 6 / 10
                Lcdcmdout LcdLine1Pos(6)
        Lcdout #pc1
            WaitMs 250
        Lcdcmdout LcdClear

    Goto main
    End
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    I am not entirely sure what you want but

    Lcdout ","

    will place a comma in the next location... If you want to place a comma in the decimal number you will need to split it up!!!

    Show me an example output of what you need.... ie

    Volt 1,024

    If this is what you need I would use a function to build a string...
     
  3. Winch

    Winch New Member

    Joined:
    Sep 5, 2014
    Messages:
    24
    Likes:
    0
    Yes, I need your example of the "volt 1,024"
    Basicly I reed the AD converter and set the code to the right voltage.
    In this proces I need that comma in the end result!
    I was hoping that there was a special code for this kind of problem.
    What is your idea of the string?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE

    I wrote a floating point LCD out function ( before Vladimir included singles )

    Code (basic):

    number(5) as byte

    number(0) = value / 1000 MOD 10 + 48
    number(1) = ","
    number(2) = value /100 MOD 10 + 48
    number(3) = value /10 MOD 10 + 48
    number(4) = value MOD 10 + 48
    number(5) = 0

    for x = 0 to 5
       Lcdout #number(x)
    next x
     
    Something like this
     
  6. Winch

    Winch New Member

    Joined:
    Sep 5, 2014
    Messages:
    24
    Likes:
    0
    Dear Ian,
    I try your solution but it doesn't work?
    I see what you are doing but it works like a counter!

    At the end I write the next code (see below)

    Code (text):
    main:  'endless loop

    Adcin 0, an0  'read AN0 and write value to AN0

        Lcdcmdout LcdLine2Pos(12)  'write from position 12
        Lcdout #an0  'just to see on the screen what the digital number is!

        Lcdcmdout LcdLine1Pos(1)  'write from first position
        Lcdout "Volt"  'write the word "volt" on the screen!
       
            pc0 = an0 * 594 / 100000 Mod 10
        Lcdcmdout LcdLine1Pos(6)
        Lcdout #pc0

            pc1 = an0 * 594 / 10000 Mod 10
        Lcdcmdout LcdLine1Pos(7)
        Lcdout #pc1

        Lcdcmdout LcdLine1Pos(8)
        Lcdout ","

            pc2 = an0 * 594 / 1000 Mod 10
        Lcdcmdout LcdLine1Pos(9)
        Lcdout #pc2

    Goto main
    End            
     
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    Whatever works for you.... Looks good..
     

Share This Page