PDA

View Full Version : More Powerful LCD Commands



sayzer
- 1st June 2006, 10:15
If we had single commands to do these, that would be nice!

left align
right align
center
justify
one space between each character


--------------------------------------

Archilochus
- 1st June 2006, 16:18
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

mister_e
- 1st June 2006, 16:44
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.

sayzer
- 5th June 2006, 10:35
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?



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




--------------

NavMicroSystems
- 8th June 2006, 01:46
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.

shahidali55
- 22nd April 2007, 10:47
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 ? ? ?

mister_e
- 22nd April 2007, 19:37
I2CWRITE or SHIFTOUT should do the trick...

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



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

NavMicroSystems
- 24th April 2007, 19:49
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 ;-)

mister_e
- 24th April 2007, 21:58
HEY RALPH! Well i followed your suggestion a while back (more than 2 years ago) (http://www.picbasic.co.uk/forum/showpost.php?p=5088&postcount=7) ... i use them on my pinboard... or as staple :D

Reuse
Old and
Hassling
Stock

:eek: C84? :eek:

PS: i know you love'em, so i can send you a few LMAO!

shahidali55
- 25th April 2007, 06:07
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 ? ? ?

skimask
- 25th April 2007, 14:28
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.

shahidali55
- 5th June 2007, 10:19
Has anyone designed a HD44780 2-wire (or 3-wire) LCD interface?
Has anyone got an example code in picbasic?

skimask
- 5th June 2007, 14:43
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

mister_e
- 5th June 2007, 15:00
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/samples/pbp/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/samples/pbp/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.

shahidali55
- 5th June 2007, 18:06
Can it be done without using a PIC on the slave side?
Like 12F629 --> Shift register --> LCD

skimask
- 5th June 2007, 21:38
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...

mister_e
- 6th June 2007, 03:21
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

shahidali55
- 6th June 2007, 14:39
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?

skimask
- 6th June 2007, 14:51
Myke has mentioned that before strobing the E pin, a 450ns pause is necessary.
Will PAUSEUS 1 work?

PAUSEUS 1 = 1000ns
1000ns > 450ns
Yes

mister_e
- 6th June 2007, 16:40
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.

shahidali55
- 6th June 2007, 19:40
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/djlcdsim.html)
This code should display the digit "1" on the display.

reaper0995
- 20th April 2008, 21:06
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

mister_e
- 20th April 2008, 21:16
Sorry i don't follow you :o could you shed some light on that?

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

DavidK
- 21st April 2008, 06:05
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


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.

reaper0995
- 21st April 2008, 08:01
Sorry i don't follow you :o 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....

mister_e
- 21st April 2008, 21:20
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/wfsection/article.php?articleid=10

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

HTH

mister_e
- 21st April 2008, 21:28
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.

DavidK
- 22nd April 2008, 05:11
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


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/wfsection/article.php?articleid=10

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

HTH

Art
- 22nd April 2008, 10:32
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.

DavidK
- 22nd April 2008, 19:45
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


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.

alphahr
- 23rd April 2008, 20:28
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

Archangel
- 26th April 2008, 04:38
Check the post 16 on this thread: http://www.picbasic.co.uk/forum/showthread.php?t=4972