Bars on 4*20 LCD

Thread Starter

FroceMaster

Joined Jan 28, 2012
702
Hi,
I have a project, and now a have a little question.
I want to make a "bar" on each digit , depending on data in microchip.
"Underscore" is simpel to make "_"

but the next 5 "bar" is difficult.

the full bar 7 is also pretty simpel to make.

like the attached file.

How can this be done ?
i use 16F1509

Rgds
FroceMaster
 

Attachments

shteii01

Joined Feb 19, 2010
4,644
Your LCD has its own microcontroller. It is the job of LCD microcontroller to do those things. The job of your PIC 16F is to tell LCD micro WHEN to do it.

Get the LCD datasheet, there should be a section on what characters the LCD can display (LCD micro can generate). You may have the bar graph characters already available to you, they would be listed in that section of datasheet.

If the bar graph characters are not available. Then you will have to make them. Again. The LCD datasheet will have a section on how to make Custom Characters, use that information to create the bar graph characters that you are missing.
 

djsfantasi

Joined Apr 11, 2010
9,163
What specific 4x20 LCD are you using? The ones that I have used have a custom character option. Hopefully someone who has actually used this feature can explain how to define the five characters that you need. But, s/he'll need to know the specific device.
 

spinnaker

Joined Oct 29, 2009
7,830
Check your datasheet but chances are you can send the LCD a a chr(255) character which will display a single block. You can string them together for a bar of sorts.
 

shteii01

Joined Feb 19, 2010
4,644
Check your datasheet but chances are you can send the LCD a a chr(255) character which will display a single block. You can string them together for a bar of sorts.
From what they said and showed, they already figured out how to do smallest bar and largest bar. They want the rest of the bars that steadily increase in height. This tells me they want horizontally increasing bar graph, not vertical like the one you are suggesting.
 

djsfantasi

Joined Apr 11, 2010
9,163
@FroceMaster , do you want the bars to display horizontally or vertically? Spinnaker's suggestion would give you four bars horizontally. If you don't mind displaying two columns of four bars, that would give you eight bars horizontally.

But your original statement appeared that you wanted to use the individual pixels in a character to give you eight bar values (0-8). That would be a vertical display and you can show up to 20 values.

So what is it?

Note: Thank you for the product link, but I can't read whatever language it is written in!
 

shteii01

Joined Feb 19, 2010
4,644
@FroceMaster , do you want the bars to display horizontally or vertically? Spinnaker's suggestion would give you four bars horizontally. If you don't mind displaying two columns of four bars, that would give you eight bars horizontally.

But your original statement appeared that you wanted to use the individual pixels in a character to give you eight bar values (0-8). That would be a vertical display and you can show up to 20 values.

So what is it?

Note: Thank you for the product link, but I can't read whatever language it is written in!
dk in the link would make me guess Denmark.
But datasheet should be in English, anyway.
Yep, datasheet is in English.
 

spinnaker

Joined Oct 29, 2009
7,830
From what they said and showed, they already figured out how to do smallest bar and largest bar. They want the rest of the bars that steadily increase in height. This tells me they want horizontally increasing bar graph, not vertical like the one you are suggesting.

Then the LCD should be capable of custom characters. I have not yet done them but should not be soo hard to do.
 

shteii01

Joined Feb 19, 2010
4,644
Ok. Bad news.
1. Font map does not have the bars, so you have to create them.
2. I did not see a section that walks you through creating custom characters.

Looking at the font map. They do have several blocks that have no character assigned to them. I assume that they can be used to create custom characters like your various height bars. I think I saw instructions on how to write to the CGRAM (character graphic RAM) so theoretically you can define those bars. However, you will have to figure it out or find someone who already figured it out and copy their procedure.

Or you can buy lcd display that have the procedure defined in their datasheet so you would not need to stumble around the internetz looking for info.
 

Thread Starter

FroceMaster

Joined Jan 28, 2012
702
The bars should be horizontal
I Will try to send custum to The Lcd later
8 horizontal lines gives me 32 in value. And that is just fine.
 

MMcLaren

Joined Feb 14, 2010
861
After initializing your LCD you want to send the 'Set CGRAM address' command. Then send custom character pattern data, eight bytes for each character, for up to eight characters total. Print those custom characters in DATA mode (RS=0) using character values 0x00 through 0x07.

Here's an excerpt from an old PIC assembly language program that I hope may be helpful. Note the character patterns;

Code:
        radix   dec

#define line1   128+0           ; DDRAM + 0
#define line2   128+64          ; DDRAM + 64
#define line3   128+20          ; DDRAM + 20
#define line4   128+64+20       ; DDRAM + 84

#define cgram   64+0            ; CGRAM + 0..63
Code:
        call    InitLCD         ; initialize LCD subsystem        |B0
;
;  load "up arrow" and "down arrow" custom characters
;
        PutLCD  cmd,cgram+0     ; cgram addr + 0..63              |B0
        PutLCD  dat,b'00100'    ; upload char 0 "Up Arrow"        |B0
        PutLCD  dat,b'01110'    ;                                 |B0
        PutLCD  dat,b'11111'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00000'    ;                                 |B0
        PutLCD  dat,b'00100'    ; upload char 1 "Dn Arrow"        |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'11111'    ;                                 |B0
        PutLCD  dat,b'01110'    ;                                 |B0
        PutLCD  dat,b'00100'    ;                                 |B0
        PutLCD  dat,b'00000'    ;                                 |B0
;
;  paint the LCD screen
;
        PutLCD  cmd,line1+0     ; ddram addr line 1, tab 0        |B0
        PutLCD  dat,0           ; display <up arrow> char         |B0
        PutLCD  cmd,line1+3     ; ddram addr line 1, tab 3        |B0
        PutLCD  str,"K8LH Klock"
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
If you google"Custom alphanumeric fonts" you will find some tutorials explaining how to make and store custom characters to make these bars. Displaying them is as simple as printing a character as they take the first eight ASCII codes.

And yeah, eight. You just get eight custom characters. But if you are not displaying all eight you can keep changing some.
 

MMcLaren

Joined Feb 14, 2010
861
.... You just get eight custom characters. But if you are not displaying all eight you can keep changing some.
Ernie is partially correct. Eight custom characters isn't much, however, clever coding can produce some neat effects. For example, you can update those eight custom character definitions in such a way to produce a rolling odometer effect for up to eight digits at the same time on the LCD display.

Have fun. Cheerful regards, Mike

LCD Odometer FX.png
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,163
I think he only needs 5 or six special characters. The other three, he can use a blank, underscore and chr(255).

The special characters would be two complete rows of pixels through seven rows of pixels.

So eight special characters are plenty.
 

ErnieM

Joined Apr 24, 2011
8,377
I think he only needs 5 or six special characters. The other three, he can use a blank, underscore and chr(255).
These displays by the spacing of the characters mechanically insert a space between characters.

Assuming the box goes side to side in the box the only existing character that can be reused is the space for no lines.

So seven custom characters are necessary for a 5x7 font, which is the most popular size used.
 

djsfantasi

Joined Apr 11, 2010
9,163
Ok, so I think we see his graph differently. I am basing my intetpretation on what the TS said in post #1.

The underscore represents the lowest value. Except for a space, which is a zero. Chr(255) is the full scale value. As the values increase, another full horizontal row is added vertically.

I see it like a frequency meter, where separate columns represent different ranges. And the vertical axis represents the power of the signal.

Maybe I'm wrong, but I wanted to explain my interpretation because to me, other posters did not understand it.
 

MMcLaren

Joined Feb 14, 2010
861
I thought that was implied in what I wrote while staying on topic, or are we splitting hairs again?
I'm sorry, Ernie. Perhaps I misunderstood?
ErnieM said:
But if you are not displaying all eight you can keep changing some.
You can write new character patterns for any of the eight custom characters even if those characters are being displayed on screen so I don't understand your statement.
 
Top