LCD + bar graph


Results 1 to 14 of 14

Thread: LCD + bar graph

Threaded View

  1. #6
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Bargraph 128 levels using 16 char LCD

    This bargraph is not near as slick as the one by Darrel.
    My graph displays 128 levels using 16 character LCD
    This bargraph uses 8 user defined characters that are downloaded first.
    There are 16 characters each subdivided into 1/8. 16X8=128
    I needed to display an 8 bit value but I could not so I divided the value by 2 and displayed a 7 bit number.
    Here are the working parts:
    Attached is the entire project but below is the working parts for the graph.
    rons.
    *******************************
    'hardware
    'microChip used 16F873
    ' 4k ROM
    '192 RAM
    '128 EEPROM


    DEFINE LCD_DREG PORTB 'LCD data port
    DEFINE LCD_BITS 8 '8 bit mode

    DEFINE LCD_RSREG PORTC 'RS port
    DEFINE LCD_RSBIT 2 'RS bit

    DEFINE LCD_EREG PORTC 'E port
    DEFINE LCD_EBIT 0 'E bit

    DEFINE LCD_RWREG PORTC 'R/W port
    DEFINE LCD_RWBIT 1 'R/W bit

    DEFINE LCD_LINES 2 'lines

    LCD_rs var portc.1

    'EEPROM tables graphic downloaded to LCD

    DATA @ 0 , %00000000
    DATA @ 1 , %00000000
    DATA @ 2 , %00000000
    DATA @ 3 , %00000000
    DATA @ 4 , %00000000
    DATA @ 5 , %00000000
    DATA @ 6 , %00000000
    DATA @ 7 , %00000000

    DATA @ 8 , %00000000
    DATA @ 9 , %00000000
    DATA @10 , %00000000
    DATA @11 , %00010000
    DATA @12 , %00010000
    DATA @13 , %00010000
    DATA @14 , %00010000
    DATA @15 , %00010000

    DATA @16 , %00010000
    DATA @17 , %00010000
    DATA @18 , %00010000
    DATA @19 , %00010000
    DATA @20 , %00010000
    DATA @21 , %00010000
    DATA @22 , %00010000
    DATA @23 , %00010000

    DATA @24 , %00010000
    DATA @25 , %00011000
    DATA @26 , %00011000
    DATA @27 , %00011000
    DATA @28 , %00011000
    DATA @29 , %00011000
    DATA @30 , %00011000
    DATA @31 , %00011000

    DATA @32 , %00011000
    DATA @33 , %00011000
    DATA @34 , %00011000
    DATA @35 , %00011000
    DATA @36 , %00011100
    DATA @37 , %00011100
    DATA @38 , %00011100
    DATA @39 , %00011100

    DATA @40 , %00011100
    DATA @41 , %00011100
    DATA @42 , %00011100
    DATA @43 , %00011100
    DATA @44 , %00011100
    DATA @45 , %00011100
    DATA @46 , %00011100
    DATA @47 , %00011110

    DATA @48 , %00011100
    DATA @49 , %00011100
    DATA @50 , %00011110
    DATA @51 , %00011110
    DATA @52 , %00011110
    DATA @53 , %00011110
    DATA @54 , %00011110
    DATA @55 , %00011110

    DATA @56 , %00011110
    DATA @57 , %00011110
    DATA @58 , %00011110
    DATA @59 , %00011110
    DATA @60 , %00011110
    DATA @61 , %00011111
    DATA @62 , %00011111
    DATA @63 , %00011111

    LCD_rs=0
    ADCON1 = 7 'PIC16F87X PORTa ANALOG OFF DIGITAL ON

    start: pause 500 'wait for LCD to startup

    lcdout $fe, $40 'set CG address to 0
    for i = 0 to 63 'down load CGtable
    read i,j
    lcdout j
    next i

    lcdout $fe,1 'clear LCD screen
    pause 100

    error1:
    lcdout $fe,$10,$fe,$10,hex DATA_ 'hex data
    'LCD has only 8 user defignable char. so: 1/2
    lcdout $fe,2 'home LCD
    DATA_ = Data_ / 2 ' 1/2 make 8 bit value 7 bit value
    j = DATA_ & $07 'ger 3 bits
    for i = 8 to 128 step 8
    if DATA_ >= i then 'bargraph
    lcdout $ff 'Write black characters to make bar
    else
    lcdout j 'output one of 8 downloaded characters
    j = " " 'next pass output blank characters
    endif
    next i
    GOTO loop
    *******************************
    Quote Originally Posted by DynamoBen
    Anyone done a bargraph on a character LCD? I want to represent a value in text and bargraph and was looking for the best method to accomplish it.
    Attached Files Attached Files

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, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 0

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