LCD displaying problem..


Closed Thread
Results 1 to 17 of 17

Hybrid View

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

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

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

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

  5. #5
    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*

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

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

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

  9. #9
    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
    __________________

  10. #10
    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,

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