More Powerful LCD Commands


Closed Thread
Results 1 to 32 of 32
  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Cool More Powerful LCD Commands

    If we had single commands to do these, that would be nice!

    left align
    right align
    center
    justify
    one space between each character


    --------------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    If those functions could be added without making the basic LCDOUT command use more code space it would be cool.

    Just out of curiousity I had tried writing my own LCD control code (4bit, 8bit, & serial) - it was much easier than expected! And you can add in extra functions as needed.

    Arch

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Usually i use an external EEPROM to save the strings. As i use always the same routine to display strings, i format my strings to fit directly on the LCD, then, if i have to display results right, left or somewhere esle on the string i use specific structure to store LCD address in the EEPROM or in the program to point directly on the wanted LCD location.

    Using a HEX editor make things easy to figure out how your data will be display on your LCD.

    It's flexible even if it use a bit much EEPROM storage.

    OR, Using another EEPROM structure, you can specify the origine point, the string lenght and do what you need with.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I see mister_e but it takes extra work, doesn’t it?

    Who are the people that will really read "PBP Wish List" and then consider some of the posts for the next version?

    In other words, is there really a consideration of the posts here?

    If so, if they like an idea here at "PBP Wish List", will they really consider putting them into the next version and, may be, will name it with the member’s who posted it?

    Code:
    sayzer $fe,$cx,”Hello Word”	'right align “Hello Word” on lcd
    
    mister_e 0, eeprom		'format the entire eeprom 
                                    'and assign 0 to each location.



    Trademarks: name of “mister_e” belongs to mister_e




    --------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    I don't want to start yet another "heated debate", but

    I feel LCDOUT "as it is" gives you all you need to get started quickly on a standard character display.

    With a bit of creativity you can achieve almost anything on a standard LCD.
    (even simple graphics)

    If you want more, go be creative and write your own routines that do exactly what you want (or need) and nothing else.
    You will learn a lot and in addition you will (most likely) save some codespace.

    Of Course LCDOUT could have more bells and whistles, but then it would require even more code space than it already does to simply display "Hello World"
    (would it be a real benefit if it would require at least an 18F PIC to simply display two lines of text on any LCD?)

    I started with HD44780 (or compatible) LCDs and was happy to have the (in my oppinion) powerful LCDOUT.
    Today I use all kinds of displays with different controllers and I prefer Displays with SPI or I2C to save some port pins.
    With those "non HD44780" Controllers LCDOUT is of no use at all,
    one has just to be creative.

    It is even more complex with GLCDs, which Controller should be supported?
    There is actually no standard.

    What I really like with PBP is: it is bullet proof.

    Several other compilers have all kinds of "special features" but actually lack of basic functionality and reliability.
    (One never knows where to start searching for the cause of an unexpected result)

    I have never found a real bug in PBP
    ok, sometimes code didn't work as expected,
    but looking closer to it I had to realise:
    it simply worked as designed!

    PBP follows one simple rule:
    GARBAGE IN - GARBAGE OUT
    (I have seen other Products where you get GARBAGE OUT whatever you put in)

    If one takes the time to study the excellent PBP Manual
    and the datasheets of all hardware involved in the specific design
    and follows some design rules
    it will work reliably not only on the bench but also in the field.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  6. #6
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Smile 2 wire LCD interface

    It would be awesome if PBP had a 2 wire LCD suppurt.
    Maybe something like LCDOUT2 or something . . .
    To clarify what i mean, i have attached a schematic and the ASM source code from Myke's page.
    << http://www.myke.com/lcd.htm >>> This is given at the end of the page.
    Is it possible to incorporate this in PBP ???
    He uses a shift register to send data and a resistor-diode AND logic to strobe the enable bit of the LCD . . .
    How can i do this in PBP ? ? ?
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by shahidali55; - 22nd April 2007 at 10:50.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I2CWRITE or SHIFTOUT should do the trick...

    But to me, any 1 wire serial adapter would be good enough.

    Code:
    Start:
        HSERIN [TheData] ' OR DEBUGIN/SERIN/SERIN2
        LCDOUT TheData
        GOTO Start
    Fantastic situation to use any of your forgiven or useless PIC. Like PIC16F84, 16C54 etc etc
    Last edited by mister_e; - 22nd April 2007 at 19:40.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Fantastic situation to use any of your forgiven or useless PIC. Like PIC16F84, 16C54 etc etc
    Hey Steve, looks like you still have plenty of F84's & C54's on the shelf.
    (Probably even C84's)

    How about RoHS compliance of your stock ;-)
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    HEY RALPH! Well i followed your suggestion a while back (more than 2 years ago) (http://www.picbasic.co.uk/forum/show...88&postcount=7) ... i use them on my pinboard... or as staple

    Reuse
    Old and
    Hassling
    Stock

    C84?

    PS: i know you love'em, so i can send you a few LMAO!
    Last edited by mister_e; - 24th April 2007 at 23:27.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Question

    So how exactly am i suppose to use I2CWRITE or SHIFTOUT to print on LCD using the circuit i had attached earlier ?
    Will i have to do some modification to the circuit or will it directly work if i just send the LCD commands to SHIFTOUT ? ? ?

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shahidali55 View Post
    So how exactly am i suppose to use I2CWRITE or SHIFTOUT to print on LCD using the circuit i had attached earlier ?
    Will i have to do some modification to the circuit or will it directly work if i just send the LCD commands to SHIFTOUT ? ? ?
    That circuit/idea was never designed for I2C, it's always been for SHIFTOUT. I've got one of his books, that's what it says, that's the way it's designed.

  12. #12
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Question 2-wire

    Has anyone designed a HD44780 2-wire (or 3-wire) LCD interface?
    Has anyone got an example code in picbasic?

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shahidali55 View Post
    Has anyone designed a HD44780 2-wire (or 3-wire) LCD interface?
    Has anyone got an example code in picbasic?

    TX side - SEROUT directly replaces LCDOUT (pick your serial transmit format, i.e. baud rate, parity, etc)

    RX side - SERIN data feeds byte information directly to LCDOUT (again, pick your serial receive format to math the transmit side)

    3 wires - power, ground, serial transmit data

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    2 Wire: The master side may use I2CWRITE. On the slave side, you will need to build your OWN I2C routine, using the MSSP or Bit banging. Maybe you could use some part of the following...
    http://www.melabs.com/resources/samp...p/i2cslave.bas

    Still possible to set a PIC USART in Synchronous mode.

    3 wire: The master side may use SHIFTOUT. On the slave side, same rule apply..
    http://www.melabs.com/resources/samp...p/spislave.bas

    To me, a 1 wire solution is more valuable. But if your board already have a I2C bus... it's tempting to use it.
    Last edited by mister_e; - 5th June 2007 at 15:02.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Question Using shift registers ? ? ?

    Can it be done without using a PIC on the slave side?
    Like 12F629 --> Shift register --> LCD

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shahidali55 View Post
    Can it be done without using a PIC on the slave side?
    Like 12F629 --> Shift register --> LCD
    See your other post on the subject. The idea is well documented in Myke Predko's book. All you have to do is think about it a bit...the idea will hit...

  17. #17
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yes the shift register could work... As long as you can deal with the limitations. It's a cheap an proved to work solution so far.

    anyway, here's the link Skimask talked about http://www.myke.com/lcd.htm
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  18. #18
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Question

    mister-e , in the "C" psuedo-code give on the link mentioned above ,
    This is what i understood so far.
    To send any data to the LCD, the "LCDNybble" function has to be called twice with the character / command data in the variable "Nybble".
    The Nybble variable should be fed with the corresponding upper and lower bits sequentially.

    Does the "LCDNybble" function take care of pulsing the E pin of LCD?
    Myke has mentioned that before strobing the E pin, a 450ns pause is necessary.
    Will PAUSEUS 1 work?
    Last edited by shahidali55; - 6th June 2007 at 14:43.

  19. #19
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shahidali55 View Post
    Myke has mentioned that before strobing the E pin, a 450ns pause is necessary.
    Will PAUSEUS 1 work?
    PAUSEUS 1 = 1000ns
    1000ns > 450ns
    Yes

  20. #20
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Math are good... but depending your OSC speed, you may want to use a serie of @ NOP instead.

    Have a look in the manual about PAUSEUS limitations.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  21. #21
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Post

    Based on the pseudo C code on page http://www.myke.com/lcd.htm,
    i made my own code. I have attached it with this post.
    Can someone chech it out and tell if what i've done is correct?
    I tested the commands using Dincer's JavaScript LCD Simulator V 1.05.
    (http://www.geocities.com/dinceraydin.../djlcdsim.html)
    This code should display the digit "1" on the display.
    Attached Files Attached Files
    Last edited by shahidali55; - 6th June 2007 at 19:43.

  22. #22
    Join Date
    Mar 2008
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    might be kinda nice to have a least-significant-digit location set. for instance if you need to display a variable that changes from 1 digit (0-9) to 3 digits (100, etc), and you need to display 4 of them at a time, the code starts to get very lengthy....

    i normally do an IF+THEN and if less than X, then add a space, but doing this for 4 variables, with 1 to 3 digits gets be rather long, and very hard to debug...

    LCDOUT $FE, 1, DEC VAR [10], "Hello" 'display decimal value of <VAR> with least significant digit at space 10

  23. #23
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sorry i don't follow you could you shed some light on that?

    Why not updating only some fields on the LCD? Do you need Left/Right Aligned thingy?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  24. #24
    Join Date
    Jun 2006
    Location
    California
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    I know this an old post, but could you elaborate a little more on how one would store strings in an external EEPROM and retrieve them. I can see where this might come in handy when building menus. "HSEROUT" is a little hungry for code space. I did a search on the forum, but nothing jumped out.
    Thanks, David

    Quote Originally Posted by mister_e View Post
    Usually i use an external EEPROM to save the strings. As i use always the same routine to display strings, i format my strings to fit directly on the LCD, then, if i have to display results right, left or somewhere esle on the string i use specific structure to store LCD address in the EEPROM or in the program to point directly on the wanted LCD location.

    Using a HEX editor make things easy to figure out how your data will be display on your LCD.

    It's flexible even if it use a bit much EEPROM storage.

    OR, Using another EEPROM structure, you can specify the origine point, the string lenght and do what you need with.

  25. #25
    Join Date
    Mar 2008
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Sorry i don't follow you could you shed some light on that?

    Why not updating only some fields on the LCD? Do you need Left/Right Aligned thingy?

    if you say this:


    VAR = 1
    LCDOUT $FE, 1, " ", DEC VAR 'three spaces

    you will get on the screen
    >___1< but lets say your variable becomes 100, you will get:
    >___100< i want to get it to say:
    >_100<


    so the first digit of the variable is the "setpoint," and if its one or 5 digits long, the first one will always be in the same place. not too big of a deal, but if you want to run 2 or 3 variables on the screen at the same time (and vary from 1 to 100), then it kinda sucks to program that....

  26. #26
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DavidK View Post
    I know this an old post, but could you elaborate a little more on how one would store strings in an external EEPROM and retrieve them. I can see where this might come in handy when building menus. "HSEROUT" is a little hungry for code space. I did a search on the forum, but nothing jumped out.
    Thanks, David
    Use a HEX editor, create your Menus (i used HEXWorkshop from bpsoft), then dump it in your EEPROM with a EEPROM programmer or else fancy method, like a custom PC application which will send the EEPROM dump to your PIC via Rs232 or USB.

    An then, depending your EEPROM you really just need I2CREAD/SHIFTIN then a LCDOUT.

    That's one method, you can also use the following method using the code space.
    http://www.pbpgroup.com/modules/wfse...p?articleid=10

    And there's a load of different version of it in this forum to.

    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  27. #27
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by reaper0995 View Post
    if you say this:


    VAR = 1
    LCDOUT $FE, 1, " ", DEC VAR 'three spaces

    you will get on the screen
    >___1< but lets say your variable becomes 100, you will get:
    >___100< i want to get it to say:
    >_100<


    so the first digit of the variable is the "setpoint," and if its one or 5 digits long, the first one will always be in the same place. not too big of a deal, but if you want to run 2 or 3 variables on the screen at the same time (and vary from 1 to 100), then it kinda sucks to program that....
    This is why i asked
    Why not updating only some fields on the LCD?
    just clear the specific LCD areas where you need to write to.. then yes you must implement some kind of text justification. For that, you'll need to implement a kind of LEN(YourVar) who return the length of your variable, amount of character.

    Think about a simple loop, begin with a variable (says LENof) set to 1. Divide your variable to display by ten.. if the result is still greater increment Lenof variable... loop until your result is still greater than 10. once your done, you know the LENof your variable. Then it's just a matter to use or not REP " "\AmountOfSpace the right way for your text justification.

    That's one way.
    Last edited by mister_e; - 21st April 2008 at 21:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  28. #28
    Join Date
    Jun 2006
    Location
    California
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Steve
    Yes I use the embedded strings as part of my Logo Display. Works great BTW.

    I also tried the custom approach and built a HyperTerm interface to an 24LC128 EEPROM, but the problem is viewing all the lines at once or editing a single entry. I will look at your Hex Workshop.
    Thanks for the info
    David

    Quote Originally Posted by mister_e View Post
    Use a HEX editor, create your Menus (i used HEXWorkshop from bpsoft), then dump it in your EEPROM with a EEPROM programmer or else fancy method, like a custom PC application which will send the EEPROM dump to your PIC via Rs232 or USB.

    An then, depending your EEPROM you really just need I2CREAD/SHIFTIN then a LCDOUT.

    That's one method, you can also use the following method using the code space.
    http://www.pbpgroup.com/modules/wfse...p?articleid=10

    And there's a load of different version of it in this forum to.

    HTH

  29. #29
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    A routine very similar to mister_e's could easily be used to centre text to the LCD screen.
    It's almost funny to see such a request of the language itself.

    For a 16 character display, count the length of the message to display, divide that by 2,
    and print the message that many spaces to the left of centre (or 8 minus that figure).

    If you want to print it all to the right, start from 16 (or length of the LCD screen) minus the length of the message.

    To use EEPROM, set a two byte qualifier recognised by your program, then you can count the bytes until
    you reach the next qualifier to gain the length of the message.
    You only need to use the LCDOUT command once in your whole program to send one single variable byte at a time.
    Same with serout, sound, etc. as they can be called from other routines. any more is overkill.

    PBP only includes these routines once in your program, no matter how many times you use them.
    There's no reason why the programmer should do any different.
    Last edited by Art; - 22nd April 2008 at 10:41.

  30. #30
    Join Date
    Jun 2006
    Location
    California
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Art
    Interesting!!

    I may need a little coaching. My goal is to print up a set of instructions, save them as a text file (formatted for screen width), convert to hex then burn to an EEPROM. Calls would be made to EEPROM strings by line number. Not sure this is all possible but nice idea. This could be used for either LCD, RS-232 or USB connections.
    David

    Quote Originally Posted by Art View Post
    A routine very similar to mister_e's could easily be used to centre text to the LCD screen.
    It's almost funny to see such a request of the language itself.

    For a 16 character display, count the length of the message to display, divide that by 2,
    and print the message that many spaces to the left of centre (or 8 minus that figure).

    If you want to print it all to the right, start from 16 (or length of the LCD screen) minus the length of the message.

    To use EEPROM, set a two byte qualifier recognised by your program, then you can count the bytes until
    you reach the next qualifier to gain the length of the message.
    You only need to use the LCDOUT command once in your whole program to send one single variable byte at a time.
    Same with serout, sound, etc. as they can be called from other routines. any more is overkill.

    PBP only includes these routines once in your program, no matter how many times you use them.
    There's no reason why the programmer should do any different.

  31. #31
    Join Date
    Apr 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Thumbs up 16F84 serial slave code

    OK, two things, 16F84 is rapidly becoming part of history and there is a lot of stock around to use yet. I have a lot of various types of LCD's of the standard 44780 type and it would be great to dedicate several 84's to becoming an 8 bit LCD driver with serial in essentially making it a serial display. Sure, serial displays are common now, but they are still $30 or more and basic 44780 displays are available in surplus outlets for $1. I'd rather save a couple of bytes of mem by using the display in 8 bit mode.

    Second, is the LCDOUT modifiable so that a standardized PIC to LCD pin out can be used? There are about as many ways to wire an LCD as there pins. I like to use B0-B7 and A0-A2 for all 8 bit LCD configurations with 84, 627,628. And, what is the code standard for a serial in LCD module, it gets very confusing out there, everyone has an opinion.

    Move along, these aren't the droids we are looking for
    Last edited by alphahr; - 23rd April 2008 at 22:22. Reason: syntax error

  32. #32
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Check the post 16 on this thread: http://www.picbasic.co.uk/forum/showthread.php?t=4972
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 20:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 20:54
  3. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 27th June 2007, 00:07
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 15:44

Members who have read this thread : 1

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