Bars on 4*20 LCD

Discussion in 'Embedded Systems and Microcontrollers' started by FroceMaster, Apr 9, 2017.

  1. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    491
    4
    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
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
    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.
     
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    3,543
    1,288
    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.
     
  4. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    491
    4
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,049
    3,140
    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.
     
  6. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
    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.
     
  7. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    3,543
    1,288
    @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!
     
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
    dk in the link would make me guess Denmark.
    But datasheet should be in English, anyway.
    Yep, datasheet is in English.
     
  9. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,049
    3,140

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

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
    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.
     
  11. shteii01

    AAC Fanatic!

    Feb 19, 2010
    4,436
    703
  12. FroceMaster

    Thread Starter Active Member

    Jan 28, 2012
    491
    4
    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.
     
  13. MMcLaren

    Distinguished Member

    Feb 14, 2010
    838
    158
    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 (Text):
    1.         radix   dec
    2.  
    3. #define line1   128+0           ; DDRAM + 0
    4. #define line2   128+64          ; DDRAM + 64
    5. #define line3   128+20          ; DDRAM + 20
    6. #define line4   128+64+20       ; DDRAM + 84
    7.  
    8. #define cgram   64+0            ; CGRAM + 0..63
    Code (Text):
    1.         call    InitLCD         ; initialize LCD subsystem        |B0
    2. ;
    3. ;  load "up arrow" and "down arrow" custom characters
    4. ;
    5.         PutLCD  cmd,cgram+0     ; cgram addr + 0..63              |B0
    6.         PutLCD  dat,b'00100'    ; upload char 0 "Up Arrow"        |B0
    7.         PutLCD  dat,b'01110'    ;                                 |B0
    8.         PutLCD  dat,b'11111'    ;                                 |B0
    9.         PutLCD  dat,b'00100'    ;                                 |B0
    10.         PutLCD  dat,b'00100'    ;                                 |B0
    11.         PutLCD  dat,b'00100'    ;                                 |B0
    12.         PutLCD  dat,b'00100'    ;                                 |B0
    13.         PutLCD  dat,b'00000'    ;                                 |B0
    14.         PutLCD  dat,b'00100'    ; upload char 1 "Dn Arrow"        |B0
    15.         PutLCD  dat,b'00100'    ;                                 |B0
    16.         PutLCD  dat,b'00100'    ;                                 |B0
    17.         PutLCD  dat,b'00100'    ;                                 |B0
    18.         PutLCD  dat,b'11111'    ;                                 |B0
    19.         PutLCD  dat,b'01110'    ;                                 |B0
    20.         PutLCD  dat,b'00100'    ;                                 |B0
    21.         PutLCD  dat,b'00000'    ;                                 |B0
    22. ;
    23. ;  paint the LCD screen
    24. ;
    25.         PutLCD  cmd,line1+0     ; ddram addr line 1, tab 0        |B0
    26.         PutLCD  dat,0           ; display <up arrow> char         |B0
    27.         PutLCD  cmd,line1+3     ; ddram addr line 1, tab 3        |B0
    28.         PutLCD  str,"K8LH Klock"
    29.  
    30.  
     
    Last edited: Apr 9, 2017
    djsfantasi likes this.
  14. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,953
    1,826
    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.
     
  15. MMcLaren

    Distinguished Member

    Feb 14, 2010
    838
    158
    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: Apr 9, 2017
    joeyd999 likes this.
  16. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,953
    1,826
  17. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    3,543
    1,288
    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.
     
  18. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,953
    1,826
    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.
     
  19. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    3,543
    1,288
    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.
     
  20. MMcLaren

    Distinguished Member

    Feb 14, 2010
    838
    158
    I'm sorry, Ernie. Perhaps I misunderstood?
    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.
     
Loading...