Displaying a decimal larger than 255 on LCD?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    6

    Default Displaying a decimal larger than 255 on LCD?

    Hello. Exactly as the title states.. how do I display a decimal larger than 255? I am storing a count in two bytes in an array and would like to display the 2 bytes as a decimal on the LCD which can be 0 - 65535?

    Thanks!

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by djmachine View Post
    Hello. Exactly as the title states.. how do I display a decimal larger than 255? I am storing a count in two bytes in an array and would like to display the 2 bytes as a decimal on the LCD which can be 0 - 65535?

    Thanks!

    Assuming using LCDOUT, and array elements are var[0] and var[1]

    dec var[1] dig 2, dec var[1], dig 1, dec var[1] dig 0, dec var[0] dig 2, dec var[0] dig 1, dec var[0] dig 0

    Might need a bit of a tweak, basically use the extension 'dig' to point to the digit of the 3-digit variable you wish to display. This will also display leading zeros

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Chris Barron View Post
    Assuming using LCDOUT, and array elements are var[0] and var[1]

    dec var[1] dig 2, dec var[1], dig 1, dec var[1] dig 0, dec var[0] dig 2, dec var[0] dig 1, dec var[0] dig 0

    Might need a bit of a tweak, basically use the extension 'dig' to point to the digit of the 3-digit variable you wish to display. This will also display leading zeros

    Deliberate mistake ;-).
    Var[0] can only hold up to 255 so as it stands it may not be quite correct to adopt that technique.

    What is the largest number you are using in each byte ? Does the lower byte count right up to 255 and then roll over, at the same time incrementing the higher byte ? Or, do you restrict the range of the lower byte to some other amount, such as 99 ?

    If you can't jump directly to extracting the values you need using the 'dig' directive, then you can always write a short math routing to count off the two bytes.

    sum var word
    lower var byte
    upper var byte

    sum = (upper * 255) + lower

    lcdout dec sum dig 4, dec sum dig 3, dec sum dig 2, dec sum dig 1 , dec sum dig 0

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    sum = (upper * 255) + lower
    Should be:
    Code:
    sum = (upper * 256) + lower
    Al.
    All progress began with an idea

  5. #5
    timmers's Avatar
    timmers Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Could it not be as simple as:-

    COUNTER VAR WORD
    COUNTER_H VAR COUNTER.BYTE1 'high byte
    COUNTER_L VAR COUNTER.BYTE0 'low byte

    LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.

    Tim.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by timmers View Post
    Could it not be as simple as:-

    COUNTER VAR WORD
    COUNTER_H VAR COUNTER.BYTE1 'high byte
    COUNTER_L VAR COUNTER.BYTE0 'low byte

    LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.

    Tim.
    I don't think so, because although the LCDOUT is very simple and elegant, the maximum number which can be stored in either Counter_H or Counter_L is 255. Therefore the largest value which the word sized variable Counter can be is 255255.

    There needs to be a conversion first. The high byte needs to be multiplied by 256 (not 255 as I originally pointed out) and then added to the low byte before it gets stored in the word 'Counter'

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by timmers View Post
    Could it not be as simple as:-

    COUNTER VAR WORD
    COUNTER_H VAR COUNTER.BYTE1 'high byte
    COUNTER_L VAR COUNTER.BYTE0 'low byte

    LCDOUT $FE,128,DEC4 COUNTER 'top row, position 1.

    Tim.
    Hi, You were not so far ...

    Code:
    COUNTER VAR WORD
    
    COUNTER.Highbyte = EEPROM_READ1    'high byte ( note: EEPROM_READ1 or value1, or ...xxx1)
    COUNTER.Lowbyte = EEPROM_READ2     'low byte
    
    LCDOUT $FE,128,DEC4 COUNTER    'top row, position 1.
    No multiplying necessary ...

    Alain
    Last edited by Acetronics2; - 10th March 2009 at 09:06.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by djmachine View Post
    Hello. Exactly as the title states.. how do I display a decimal larger than 255? I am storing a count in two bytes in an array and would like to display the 2 bytes as a decimal on the LCD which can be 0 - 65535?

    Thanks!

    how about:

    Code:
    MyWord = LowByte + HighByte << 8  ' Multiply HighByte by 256 (left shift 8) and add LowByte
    
    LCDOUT $fe,$1, MyWord
    Aratti had it right in post #4 I think, except I did it with leftshift instead of multiply by 256. Same thing...


    Steve
    Last edited by Byte_Butcher; - 10th March 2009 at 02:45.

Similar Threads

  1. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  2. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. 32 bit data displaying on LCD
    By selahattin in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th September 2006, 13:33
  5. 32 Bit Decimal Displaying On LCD
    By selahattin in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th January 2004, 19:24

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