PDA

View Full Version : Dummy needs LCD tutorial,



TK5EP
- 28th September 2005, 09:06
Hi All,

I start with PICs and have some problems regarding LCD display.

For a 628, i wrote some lines of code to read a frequency in PORTA.4 and display the result after applying a formula.
The format of the displayed datas is like 0 km/h to 180 km/h

When the data displayed is for ex. 120 km/h and the next one 10 km/h i have the remaining m/h of the first data still displayed , so i have 10 km/h h displayed.

Do i have to clear the LCd before each display or format the data to have the same length to avoid this problem ?

Also, if i want to display a small cursor ( like || ) that would move on the line like a bargraph, how can i create and display this ?

Is there a tutorial about LCDs somewhere ? I didn't find it.

Greetings from Corsica, Patrick.

Luciano
- 28th September 2005, 09:32
When the data displayed is for ex. 120 km/h and the next one 10 km/h .
Good brakes or wall?

If you clear the LCD you will have a flickering LCD.

For the bargraph just print the ASCII value 255 on the second line of the LCD.
Will be like that █ █ █ █ █ █.



Luciano

Melanie
- 28th September 2005, 11:43
When displaying your km/h data, suffix it with one or two ASCII spaces ($20 Decimal 32). This will overwrite any characters remaining from the end of the prvious display.

It's neater to RIGHT JUSTIFY numeric displays, this saves the km/h waving about along the right-hand side of the numeric value which becomes a distraction... this probably will look a lot more professional...



LCDOUT $FE,$80
If kmh<100 then LCDOUT " "
If kmh<10 then LCDOUT " "
LCDOUT #kmh," km/h" ' note no trailing spaces required

rather than this, which despite being simpler code, ends up looking tatty...


LCDOUT $FE,$80,#kmh," km/h " ' note the couple of trailing spaces here

Acetronics2
- 28th September 2005, 12:27
Hi, Patrick

I Committed something about bargraphs, some years ago, I do not know where it was coming from ( Parallax, may be ...)

Here is a listing to show ...

Alain

TK5EP
- 28th September 2005, 12:37
Hi Melanie and Luciano,

Nor good brakes or wall, simply wanting to display wind speed coming from an anemometer.
I understand that i have to format the data so it overwrites the previous one.
Melanie, no difference in your code if kmh<100 or kmh<10 ?

What about displaying a moving cursor about half the wide of a full black character (ASCII 255 as you mentionend)

I want to display the wind speed in full character in km/h and/or a sliding narrow cursor one the second line under a scale on the 1st one.

Melanie, is there a tutorial or an good explanation about the LCD display ?

Thanks for your help.

Melanie
- 28th September 2005, 13:25
No tutorial - just program, play and learn from doing.

Assuming you'll never exceed 255 km/h wind speed (byte variable) and you don't live in Louisianna...

My example right-justified... so the maximum you can display is three characters (100-255 km/h).

If your spped is less than 100 km/h, then you prefix with one blank... this covers 10-99 km/h.

If your speed is less than 10km/h, then you need to prefix with two blanks (0-9 km/h).

Using this method, you get a stationary "km/h" label with the digits moving to the left. A lot neater than digits moving to the right with the "km/h" label flapping about behind them.

TK5EP
- 28th September 2005, 13:26
Merci Alain

I'm starting with PICs and it's my first project. I have some good experience in BASIC but have to adapt my knowledges to Picbasic.

I use a demo version (PROTON lite) but i'm thinking to change to Melabs, the forum and support seems to be much better !
Unfortunately, the Melabs demo allows only 35 lines... and the registered version is a bit expensive for an occasional project !
With 35 lines you have to be a bit tricky....

Greetings from sunny Corsica,

Melanie
- 28th September 2005, 13:30
> the (MeLabs) forum and support seems to be much better

Now why do you say that? Just curiosity (though it did bring a smile when I read that). At a glance, they have ten-times the amount of activity that this forum has for roughly the same number of members...

TK5EP
- 28th September 2005, 13:33
Well, in Louisinia my anemometer would be broken. It's limited to 180 km/h !

OK, i understand it now. My 2nd question was because i saw no difference between both lines, i think you forgot a space between " " in the line for kmh<10. Do i have it right ?

Thanks for your help, appreciated it.
Patrick.


No tutorial - just program, play and learn from doing.

Assuming you'll never exceed 255 km/h wind speed (byte variable) and you don't live in Louisianna...

My example right-justified... so the maximum you can display is three characters (100-255 km/h).

If your spped is less than 100 km/h, then you prefix with one blank... this covers 10-99 km/h.

If your speed is less than 10km/h, then you need to prefix with two blanks (0-9 km/h).

Using this method, you get a stationary "km/h" label with the digits moving to the left. A lot neater than digits moving to the right with the "km/h" label flapping about behind them.

Acetronics2
- 28th September 2005, 13:33
I just forgot it was written for a 16F84 ...

But, in Mel's answer, I didn't see something like :

LCDOUT $FE, $80, ... to place cursor at the beginning of the 1st line, to be sure to overwrite old text ...



Alain

PS: si ça t'intéresse, j'ai les typons pour une petite plaque de démo Kivabien avec un buzzer, trois Leds, 3 E/S , un cavalier de reset ou config et un afficheur LED 2x16...

ça aide ...beaucoup !!!

Melanie
- 28th September 2005, 13:41
> think you forgot a space between " " in the line for kmh<10. Do i have it right ?

Partially. My example is however correct.

The first IF statement adds one blank (space).
The second IF statement adds one blank.

If the value is < 10 km/h, then BOTH 'if' statements will be excuted adding a total of two blanks. If the value is > 9 and < 100, then only the FIRST 'if' statement is excuted adding only one blank.

TK5EP
- 28th September 2005, 13:41
Well, i got an answer quickly on this one, and found more infos in the archives for my level than on the other one.
I saw more posts here since one week i'm interested in PICs.

Maybe a bad guess ? But keep smiling !




> the (MeLabs) forum and support seems to be much better

Now why do you say that? Just curiosity (though it did bring a smile when I read that). At a glance, they have ten-times the amount of activity that this forum has for roughly the same number of members...

Luciano
- 28th September 2005, 13:57
* * *
Custom Characters tutorial:
http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv32.pdf

LCD Character Generator: (Freeware)
http://www.parallax.com/dl/sw/lcdcc.zip

* * *

Writing custom characters to LCD display:
http://www.picbasic.co.uk/forum/showthread.php?t=242


Luciano

TK5EP
- 28th September 2005, 13:57
Oupssss !
Next time, i will turn my keyboard 7 times before writing a post !
Sorry... :-(


> think you forgot a space between " " in the line for kmh<10. Do i have it right ?

Partially. My example is however correct.

The first IF statement adds one blank (space).
The second IF statement adds one blank.

If the value is < 10 km/h, then BOTH 'if' statements will be excuted adding a total of two blanks. If the value is > 9 and < 100, then only the FIRST 'if' statement is excuted adding only one blank.

CocaColaKid
- 28th September 2005, 14:09
For a bar graph go to http://www.picbasic.co.uk/forum/showthread.php?t=2359&highlight=LCDbar_INC.bas. Darrel wrote an include file that dones an amazing job using a bar graph.

TK5EP
- 28th September 2005, 14:34
Ciao Luciano,

Grazie mille !

That was exactly what i was looking for !
This forum seems to be the right place for me... ;-)

Thanks a million to all of you for your kindness.


* * *
Custom Characters tutorial:
http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv32.pdf

LCD Character Generator: (Freeware)
http://www.parallax.com/dl/sw/lcdcc.zip

* * *

Writing custom characters to LCD display:
http://www.picbasic.co.uk/forum/showthread.php?t=242


Luciano

Dick Ivers
- 28th September 2005, 21:59
Hi Darrell,

I love the bar graph display. Can it be set up to do the following:

1. A text line showing the current temperature in deg C with 0.1 deg resolution. (Temperature data from a thermistor via a PIC a/d data channel.)

2. Several bar graph lines showing (a.) the current temp. and (b.) the temp. as recorded in the preceeding 30 second intervals; with as many bars as is practical.

3. As a new data bar is entered the oldest bar drops off.

Possible?

NavMicroSystems
- 29th September 2005, 00:02
> the (MeLabs) forum and support seems to be much better

Now why do you say that? Just curiosity (though it did bring a smile when I read that). At a glance, they have ten-times the amount of activity that this forum has for roughly the same number of members...

Me as well had a smile on my face...


I don't want to start yet another "heated debate",
but to be fair,
I'm sure if Patrick had provided a bit more of information about his Project on "the other" Forum
he would have got some better response.

mister_e
- 29th September 2005, 02:20
you can't imagine MY smile... period!

Darrel Taylor
- 29th September 2005, 04:06
Hi Darrell,

I love the bar graph display. Can it be set up to do the following:

1. A text line showing the current temperature in deg C with 0.1 deg resolution. (Temperature data from a thermistor via a PIC a/d data channel.)

2. Several bar graph lines showing (a.) the current temp. and (b.) the temp. as recorded in the preceeding 30 second intervals; with as many bars as is practical.

3. As a new data bar is entered the oldest bar drops off.

Possible?Absolutely Possible!

You can have as many bars as you can fit on the screen. They can come and go anytime you please.

Just remember that when you're finished with 1 particular BAR, call the BARgraph macro 1 more time with a 0 value, to clear the area that it used. It's more efficient than clearing the screen, and re-drawing everthing else. Looks better without the flicker too .
<br>
Glad you like it! Thanks!

TK5EP
- 29th September 2005, 07:53
Sorry if i bothered someone, it was not my intention... :-(
My apologies if i did !
Some of you are on both forums and answered me on both.

Anyway, i will survey both forums and post on both. ANY help is welcome.

Patrick,


Me as well had a smile on my face...
I don't want to start yet another "heated debate",
but to be fair,
I'm sure if Patrick had provided a bit more of information about his Project on "the other" Forum
he would have got some better response.

TK5EP
- 29th September 2005, 08:31
Hi Darrell,

I too like your include and already posted a question about it, but did not get any answer.

I would like to use it with another Picbasic.

In one line you have : Remainder = R2

What is this R2 ?

Do you know if your file has been ported to other versions of Picbasic ?

Thanks,


Absolutely Possible!

You can have as many bars as you can fit on the screen. They can come and go anytime you please.

Just remember that when you're finished with 1 particular BAR, call the BARgraph macro 1 more time with a 0 value, to clear the area that it used. It's more efficient than clearing the screen, and re-drawing everthing else. Looks better without the flicker too .
<br>
Glad you like it! Thanks!

Melanie
- 29th September 2005, 08:57
You see, there are reasons why you should be using the MeLabs compiler... Darrel's magic code is one of them...

mister_e
- 30th September 2005, 02:57
Sorry if i bothered someone, it was not my intention... :-(


Oh no you didn't. You just raise an interesting fact wich make some people here laugh and some other cry. No harm at all.


You see, there are reasons why you should be using the MeLabs compiler... Darrel's magic code is one of them...
only one of them ;)

Darrel Taylor
- 30th September 2005, 05:57
already posted a question about it, but did not get any answerSorry about that! &nbsp; I was purposely ignoring it.

Some other guy came in here and said that "The Other compiler" did everything that PicBasic Pro didn't. &nbsp; So, I didn't think you needed it.

"I picked a bad day to stop sniffing glue" - Airplane.

But seriously folks, &nbsp;R2 is a PicBasic Pro system variable that holds the modulas remainder after a 31x15 divide with the DIV32 command. &nbsp;I don't use "The Other compiler", so I really don't know how you would do that.
<br>

TK5EP
- 30th September 2005, 21:40
Hi again !

I found a small example of a bargraph that i can make working with the demo version. I can't include Darrel's include...

It works OK, and i could modifiy it to my needs, i understood almost all the code except the method used to store in the CGRAM :
Lcdout $FE,64,0,0,0,0,0,0,0,0 ' blank
Lcdout $0,$10,$10,$10,$10,$10,$10,$0 ' |
Lcdout $0,$14,$14,$14,$14,$14,$14,$0 ' ||
Lcdout $0,$15,$15,$15,$15,$15,$15,$0 ' |||

Following the different other codes i've found, i would have done it this way :
lcdout $FE,$40,$00,$00,$00,$00,$00,$00,$00,$00
lcdout $FE,$48,$10,$10,$10,$10,$10,$10,$10,$00
lcdout $FE,$50,$14,$14,$14,$14,$14,$14,$14,$00
lcdout $FE,$58,$15,$15,$15,$15,$15,$15,$15,$00

or for last line lcdout $FE,$58,REP $15\7,$00

How is the 1st method working ??

BTW what does LCDOUT $FE,$CE make ?

also LCDOUT $FE,$80+1 would move the cursor to first line second character ?

FYI, i changed from the "other" compiler to MELabs one.... ;-)

Greetings,

Darrel Taylor
- 1st October 2005, 05:41
CGRAM is just a 64 byte contiguous block of RAM. Once you set the address to write to, you can just continue sending bytes untill your done, or you reach the end of RAM. So, your first group of LCDOUT's will set 4 custom chars, starting at location 0.

The second group accomplishes the same thing, but also sends the address for the character each time. As long as your not going to be changing things, the first group uses less code and execution time, but the second group is easier to cut&paste into other programs, since the address goes with it. &nbsp; "6 of 1, half dozen of the other".

$FE,$CE will move the cursor to the 15th character on the second line.

and, correct on the $FE,$80+1
<br>

DynamoBen
- 1st October 2005, 16:55
I'm working on a project right now that is displaying a similar LCD display. I have a bargraph for the bottom of the display and text values for the top.

I used the following basic stamp project as a template to start from.

http://www.parallax.com/html_pages/robotics/machining/RPM_display.asp

With PBP you don't have to mess around with all the nibbles that are in this problem. Also you will need to alter some of the variables. In the end I stripped out all the subroutines that write to the display and just used LCDout. Works great! It took a little bit to understand some of the math but once you have that it makes compelete sense and works well.

TK5EP
- 1st October 2005, 17:29
Hi all,

And thanks for all the infos. Now i've understood most problems and i can display almost all what i want and it will be enough for my project.
I have to measure currents and voltages that are moving rapidly, they follow the voice shape.
I used the code sent here in this post by Acetronics. I removed all what i did not need and it works perfectly.

As the display is moving fast, it would be nice if i could display a "holding bar" for a few moments at the peak value.

What is the best way to store the peak value in a variable ?
Maybe somebody has already made a similar code ?

For the moment i did not use an analog input, i randomly generate the values.

Greetings,

crocodilebobbie
- 6th October 2005, 05:09
Hi:

I usually find a format for the LCD data which does not change and display that information formated prior to the "loop". That way the display does not flicker. The data that does display is collected and displayed inside the loop, and using pause command to slow down changes.

does that make sense?

bobbie

davids
- 3rd July 2009, 18:02
Hello, i need informations i want to use GRAPHIC LCD 128*64 with bar graphs etc but i dont know how i have the pic basic pro compiler and i want to know if i use lcdout it is not compatible for glcd....
whitch are the defines???
simple code???:(

Acetronics2
- 3rd July 2009, 21:14
Hello, i need informations i want to use GRAPHIC LCD 128*64 with bar graphs etc but i dont know how i have the pic basic pro compiler and i want to know if i use lcdout it is not compatible for glcd....
whitch are the defines???
simple code???:(

I think you didn't understand there's NO support, for the day, for GLCDs with PicBasic Pro ...

May be ... another Basiç ???

Alain

enauman
- 19th April 2011, 09:11
When displaying your km/h data, suffix it with one or two ASCII spaces ($20 Decimal 32). This will overwrite any characters remaining from the end of the prvious display.

It's neater to RIGHT JUSTIFY numeric displays, this saves the km/h waving about along the right-hand side of the numeric value which becomes a distraction... this probably will look a lot more professional...



LCDOUT $FE,$80
If kmh<100 then LCDOUT " "
If kmh<10 then LCDOUT " "
LCDOUT #kmh," km/h" ' note no trailing spaces required

rather than this, which despite being simpler code, ends up looking tatty...


LCDOUT $FE,$80,#kmh," km/h " ' note the couple of trailing spaces here



I know this is an old post... But when I try to enter an lcdout statement with a pair of quotes, I get an error saying empty string not allowed. Oh hell, I think I answered my own question. It's because I forgot the space between the quotes... Right?