LCD displaying problem..


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Jan 2007
    Location
    Brazil
    Posts
    108

    Default LCD displaying problem..

    Hello all!

    I'm trying to display this:

    Code:
    speed   VAR   WORD
    LCDOUT $FE,$8D, DEC speed, "km/h"
    LCD results:

    Let's say speed is increasing and then decresing:
    Code:
      98km/h
      99km/h
    100km/h
    101km/h
    100km/h
    99km/hh  ----> THE PROBLEM
    What is the 'secret' to solve this little problem?

    Thanks..

    Sylvio

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try clearing the screen.
    Code:
    speed   VAR   WORD
    LCDOUT $FE,1             'CLEARS THE SCREEN
    LCDOUT $FE,$8D, DEC speed, "km/h"
    OR
    Code:
    LCDOUT $FE,1,$8D, DEC speed, "km/h"
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    There are several ways, but the easiest is to add some blank spaces after "km/h" so your code instead looks like

    LCDOUT $FE,$8D, DEC speed, "km/h "
    Charles Linquist

  4. #4
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    There are several ways, but the easiest is to add some blank spaces after "km/h" so your code instead looks like

    LCDOUT $FE,$8D, DEC speed, "km/h "
    But that would result in the display moving about.

    Better to conditionally add space BEFORE the value to be display eg

    If speed < 10 then LCDOUT " " ' 1 space
    If speed < 100 then LCDOUT " " ' 1 space
    LCDUT DEC speed,"km/h"

    IF the speed is 100 or greater then no spaces are prefixed
    If the speed is 10-99 then one space will be prefixed
    If the speed is below 10 then both conditions will be met and two spaces prefixed resulting the display remaining in a static position on the screen
    Keith

    www.diyha.co.uk
    www.kat5.tv

  5. #5
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default My 2 cents

    First of all, I wonder about this line: LCDOUT $FE,$8D, DEC speed, "km/h "
    --- > $8D ??? I think you meant $80 (beginning of first line)

    Then, if it's the case you can use:

    If speed < 100 then X= 1
    If speed < 10 then X = 2
    LCDOUT $FE,$8D + X, DEC speed, "km/h"


    Cleaver!

  6. #6
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by GrandPa View Post
    First of all, I wonder about this line: LCDOUT $FE,$8D, DEC speed, "km/h "
    --- > $8D ??? I think you meant $80 (beginning of first line)

    Then, if it's the case you can use:

    If speed < 100 then X= 1
    If speed < 10 then X = 2
    LCDOUT $FE,$8D + X, DEC speed, "km/h"


    Cleaver!
    Whilst that would keep the "km/h" in the same position on the screen it WONT clear text that is previously written which is why you need to print spaces.

    With the above code you would get the following

    9 would give "9km/h"

    49 would give "49km/h"

    103 would give "103km/h"

    but when the speed drops you would get the following problem due to not clearing the leading digits

    87 would give "187km/h" (the "1" not being cleared)
    5 would give "185km/h" (both the "1" and the "8" not being cleared)
    Last edited by keithdoxey; - 29th July 2007 at 11:29. Reason: keyboard is getting knackered and some letters were missing!!!!
    Keith

    www.diyha.co.uk
    www.kat5.tv

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Actually GrandPa your option won't work.

    Your logic is good, but you haven't completely thought it thru... (you still had $8D instead of $80 by the way - but forgetting that)...

    Suppose you're dropping in speed... 101, 100, 99 <<< and there's the problem...

    The last display was 100, you now shift over by one character postition and you display '99' over the top of the '00' part of 100. You haven't erased the '1' so your display goes...

    101, 100, 199, 198 etc etc...

    Keith hit it in one... but if you don't want a waving km/h display those first... and then just concentrate on the numbers. You can have leading or trailing blanks then (depending if you want left or right numeric justification).

    OK... Keith got there first... *smiles*

  8. #8
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    OK... Keith got there first... *smiles*
    That makes a change

    Normally I type a reply and post it to find that 3 or 4 other people have replied whilst I was typing.

    The problem was even worse on one forum when I didnt have access during the day. By the time I got to read the messages there was no point in replying until I had read all messages as invariably someone eles had already said what I was going to!


    Quote Originally Posted by grandpa
    $8D ??? I think you meant $80 (beginning of first line)
    $80 would indeed be the start of the first line but $8D would be character position 14 on the first line. With a 20 character display this would give space for xxxkm/h to be right justified on the display which is what I suspect sirvo is trying to achieve.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  9. #9
    Join Date
    Apr 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Wow

    Man I learn alot reading this forum!

    Where is the above mentioned "$8D" command documented? I had no idea you could do that? I knew you could shift right or left but did not know you could "jump" to a position...

    Thanks to everyone for the education!

    Bill12780

  10. #10
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bill12780 View Post
    Man I learn alot reading this forum!

    Where is the above mentioned "$8D" command documented? I had no idea you could do that? I knew you could shift right or left but did not know you could "jump" to a position...

    Thanks to everyone for the education!

    Bill12780
    Hi Bill,

    It isnt specifically mentioned in the PBP manual as it depends on the LCD driver chip in your display but for any HD44780 or compatable controller it will work.

    Download the datasheet for an HD44780 and look for the section on setting the registers.

    DDRAM is the command to look at.

    With bit 7 set you are setting where the data sent to the display is written.

    %1xxxxxxx

    $80 which is %10000000 is the first display position on Line1
    $C0 which is %11000000 is the first position on line 2

    increasign either of those values will move you along the line so that you can write at any position. This means you dont have to rewrite the entire display if all that is changing is a single character.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  11. #11
    Join Date
    Jan 2007
    Location
    Brazil
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by keithdoxey View Post
    That makes a change
    $80 would indeed be the start of the first line but $8D would be character position 14 on the first line. With a 20 character display this would give space for xxxkm/h to be right justified on the display which is what I suspect sirvo is trying to achieve.
    EXACTLY! I'm using a 4x20 display and the speed is going to be right justified!

    Thanks All for helping!

    Regards

    Sylvio,

  12. #12
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by bill12780 View Post
    Man I learn alot reading this forum!

    Where is the above mentioned "$8D" command documented? I had no idea you could do that? I knew you could shift right or left but did not know you could "jump" to a position...

    Thanks to everyone for the education!

    Bill12780
    Although Keith answered your question quite well, this information is documented on page 94 of the PicBasic Pro manual under the LCDOUT command section (pg 94 of the online version here http://www.melabs.com/downloads/pbpm304.pdf )
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  13. #13
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier View Post
    Although Keith answered your question quite well, this information is documented on page 94 of the PicBasic Pro manual
    Oops

    Cant find my printed manual at the moment to check if it is in there but on my Intranet I have the HTML version of the manual which I use as my reference.

    It must be a much older version as it doesnt have the sentance about

    LCDOUT $FE, $80+4.

    It just says "See the data sheet for the particular LCD device for the character memory locations and additional commands"
    Keith

    www.diyha.co.uk
    www.kat5.tv

  14. #14
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Wink Fixed

    This will cover everything

    LCDOUT $FE,1, $80 + X, "your text here"

    OR

    LCDOUT $FE,1, $80 + X, #VAR here


    Where X is the number of needed space.
    Can also be broken in 2 instructions: LCDOUT $FE,1 : LCDOUT $FE, $80 + X, ...

    Note: I strongly recommend against using spaces, mainly because it eats up more program memory, hard to see on source code too:

    Code:
    ex 1 : lcdout $FE,$80,"               99"  ---> 294 bytes used
    ex 2 : lcdout $FE,$80+15,"99"            ---> 200 bytes used
    Can make a big difference if used extensively!

    Hope It helps you sirvo and bill12780
    Last edited by GrandPa; - 30th July 2007 at 00:45.

  15. #15
    Join Date
    Apr 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default another revelation!

    Feels like I am at the Church of the Blessed PIC!

    Ok so here is a prime example of why you should read the entire section of the commmand.

    I glazed over it to get to the defines section so I could change the default port from A to D. I totally skipped the section on memory mapping.

    If I had read it, it would not have been such a revelation that the "commands" has they are refered to (in the manual) are actually "pointers" (for lack of a better term) to memory location within the LCD. I thought it was all PBP thing. Not LCD specific. Now I now...hahaha

    I am going to go over the Datasheet for the HD44780 when I get a sec. Cause I bet I can finally figure out how they do scrolling (horizontal and vertical). But for now still working on my Keypad project...

    Thanks you two! Time here is never wasted in my opinion. I learn something new each and everytime I come in here.

    Oh and by the way...I have just (like a month ago) ordered the upgrade from MElabs to 2.47. My orginal (your not gonna belive this) came on a FLOPPY! So I ordered the printed manual as well. My manual is the same as the online version. I am a bit old school (Still have my old TI Logic Databooks!) I like having the printed book. You can order just the manual from MELabs for like 10-15 bucks...

    Thanks again everyone!
    Bill12780

  16. #16
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Thumbs up Goto next level when ready

    Bill

    Ask (search) about BIG number whenever you feel ready. Someone made a really nice routine to display 4*4 number on LCD.

    J-P

  17. #17
    Join Date
    Apr 2007
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Thank you kind sir for the info...

    Grandpa,

    Here is the the link of which you speak of.

    Its mostly all over my head at this point. But I am learning fast. I book marked it and post it here for others refrence.


    http://www.picbasic.co.uk/forum/showthread.php?p=26736

    Thanks all!

    Bill12780

Similar Threads

  1. LCD problem with 16F628
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 19th September 2016, 08:28
  2. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  3. LCD problem
    By Andre_Pretorius in forum General
    Replies: 8
    Last Post: - 27th January 2009, 15:47
  4. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07

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