Displaying a decimal larger than 255 on LCD?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1


    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

  2. #2
    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

  3. #3
    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.

  4. #4


    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'

  5. #5
    timmers's Avatar
    timmers Guest


    Did you find this post helpful? Yes | No

    Default

    Indeed you are right.

    Without knowing the exact task, I just wanted to keep it simple...

  6. #6
    Join Date
    Oct 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I need to be able to count to around 2000 without rolling over so 2 bytes would be plenty. I tried the code you posted.. but it still rolled over at 255. hmmm....

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by djmachine View Post
    I need to be able to count to around 2000 without rolling over so 2 bytes would be plenty. I tried the code you posted.. but it still rolled over at 255. hmmm....
    It still rolls at 255 ? Did yoiu declare the destination variable as a word or a byte ?

    Ever count of 1 of the lower byte equates to 1 in the destination variable, and every count of 1 in the high byte equates to 256 in the destination variable.

    2000, in this scheme, consists of highbyte = 7, low byte = 208

    As you can see, you need to multiply whatever is in the highbyte by 256. In this case 256*7 = 1792. Then add the lowbyte directly, and 1792 + 208 = 2000

  8. #8
    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 " !!!
    *****************************************

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