LCD BARgraphs


Closed Thread
Results 1 to 40 of 233

Thread: LCD BARgraphs

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    define OSC 20
    CLEAR

    INCLUDE "LCDbar_INC.bas" ' Include the BARgraph routines

    ' Define LCD connections
    DEFINE LCD_DREG PORTB ' LCD Data Port
    DEFINE LCD_DBIT 0 ' Starting Data Bit
    DEFINE LCD_RSREG PORTB ' Register Select Port
    DEFINE LCD_RSBIT 4 ' Register Select Bit
    DEFINE LCD_EREG PORTB ' Enable Port
    DEFINE LCD_EBIT 5 ' Enable Bit
    DEFINE LCD_BITS 4 ' Data Bus Size
    DEFINE LCD_LINES 2 ' Number of Lines on LCD

    DEFINE ADC_BITS 8 ' Number of bits in ADCIN result
    ADCON1.7 = 1 ' Right Justify AD result

    Value VAR WORD ' Must be a WORD even though AD is 8bit

    LCDOUT $FE, 1 ' Clear Screen
    PAUSE 200

    Loop1:
    ADCIN 0, Value
    LCDOUT $FE,2,"Value = ",DEC Value," "
    ; syntax- BARgraph Value, Row, Col, Width, Range, Style
    @ BARgraph _Value, 2, 0, 16, 255, lines

    Goto Loop1

    END

    I use PIC16F877 @ 20MHz(I use 8 MHz,too) I delete the frist line because there is an error in compiling

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Hopefully someone smarter than me can figure this out. Darrel, this program is awesome by the way!

    I'm using an OLED screen and Darrel's anypin LCD program. The OLED screen works perfectly with the data displayed but not with bargraph program. Anyhow, have a for-next loop counting to 512. It runs perfectly up until 32 or so and then displays strange stuff until it hits 99 then it's good again until about 155 then bad again until about 222 then good again until 272 then bad until about 342 then good until about 388 then bad until about 462 and then it goes to 512 and loops back around. The program looks like this:

    Code:
    DEFINE OSC 48
    
    include "LCDBAR_INC.PBP"
     '===============================================================================
    '                    OLED CHANGE
    '===============================================================================
    '===============================ENABLE FOR CAR PROGRAM=========================='
    LCD_DB4    VAR PORTE.0
    LCD_DB5    VAR PORTE.1
    LCD_DB6    VAR PORTE.2 
    LCD_DB7    VAR PORTA.4
    LCD_RS     VAR PORTB.6 
    LCD_E      VAR PORTB.7
    '================================================================================
    
    LCD_Lines  CON 2 ' # of Lines on LCD, 1 or 2 (Note: use 2 for 4 lines) 
    LCD_DATAUS CON 50 ' Data delay time in us 
    LCD_COMMANDUS CON 2000 ' Command delay time in us 
    INCLUDE "LCD_AnyPin.PBP" ; *** Include MUST be AFTER LCD Pin assignments ****
    
    ' ==============================================================================
    '                        CONFIGS
    '===============================================================================
    
    @ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    @ __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_3_2L & _VREGEN_ON_2L
    @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_32768_2H 
    @ __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    @ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_ON_4L & _XINST_OFF_4L
    
    '==============================================================================
    '                 SETTINGS
    ' ==============================================================================
               '76543210          '76543210
     TRISA   = %00100110: PORTA = %00000000 
     TRISB   = %00010001: PORTB = %00010000   
     TRISC   = %00000000: PORTC = %00000001
     TRISD   = %11011100: PORTD = %00000000
     TRISE   = %00010000: PORTE = %00010000
     ADCON0  = %00000001
    
     CMCON   = 7
     SSPSTAT = %01100100      
     SSPCON1 = %00100001 
     BAUDCON = %00001111 
     ADCON1=15
    
     CCP2CON = %00011100 'changed on 11/16/12
     CCP1CON = %00011100 'changed on 11/16/12
     
     X  VAR WORD
    
    
    
    MainLoop:
    FOR X=1 TO 512
    PAUSE 100
    
    LCDOUT $FE,148,DEC X,"    "
                        
    '@   BARgraph   Value, Row, Col, Width, Range, Style 
                        @         BARgraph  _X,   1,   0, 20,   512,  lines
    NEXT X
    GOTO MAINLOOP
    Name:  Good.JPG
Views: 2287
Size:  142.8 KB
    Name:  Bad.JPG
Views: 2148
Size:  155.6 KB

    I've tried a bunch of stuff (changing the parameters on the @ bargraph line but nothing seemed to help. This is the OLED screen I'm using:

    http://www.newhavendisplay.com/specs...420DZW-AY5.pdf

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Everytime I hear Newhaven, I cringe.

    Here's your program running on a 4550 at 48Mhz in the simulator.
    So I don't think it's a programming issue.



    It could be an R-M-W problem.
    Is the LCD connected via a ribbon cable? If so how long?
    Have you tried running the CPU at 20Mhz without the PLL?

    Or it could be just another Newhaven issue.
    Have you tried a normal LCD?
    DT

  4. #4
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    I did a lot of testing last night and it does appear to be the OLED screen that has issues. I have two OLED screens mounted on two different pieces of equipment and with the code above they do the same thing. I then put a standard LCD screen (2X16) through the same tests and it worked perfectly. I now have more questions than answers.

    Everytime I hear Newhaven, I cringe.
    Why? They work perfectly with displaying letters and numbers and the OLED screen is so much better than an LCD screen. I'm guessing you've had problems with them in the past?
    Here's your program running on a 4550 at 48Mhz in the simulator.
    That thing is pretty cool. Where can I get it?

    After some testing, here is some information that may be useful.........or may not be. With the following line of code:
    Code:
    @         BARgraph  _X,   0,   0, 20,   512,  lines
    The software will work perfectly from 0 to 33. If I use a For/Next routine for 0-33, it will run with no problems for hours on end (I know it will, trust me!) When I put 0-34, it flakes out when it gets to 34 and only 34. When it rolls back around, the same thing happens. 0-33 works good and then 34 won't, up until 98 or so. I don't get that.

    By changing to the following code:
    Code:
    @         BARgraph  _X,   0,   1, 20,   512,  lines
    Now 0-110 works perfectly. The only thing I did was move the column from 0 to 1! Riddle me that one!

    Also, if I just change to this code
    @ BARgraph _X, 0, 1, 20, 10000, lines
    Now it will count much higher without a problem.
    Last edited by Christopher4187; - 21st November 2012 at 11:24.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Wow, is that thing slowwwwwwww. 600uS. for just about any of the control instructions? I really think you need to check your command and data delay settings. If I was using it I would also operate it in 8 bit mode. Twice as fast..... I also suggest reading the busy flag because if you are not then you are probably sending it instructions while it is executing the last instruction.
    Last edited by Dave; - 21st November 2012 at 12:52.
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Quote Originally Posted by Dave View Post
    Wow, is that thing slowwwwwwww. 600uS. for just about any of the control instructions? I really think you need to check your command and data delay settings. If I was using it I would also operate it in 8 bit mode. Twice as fast..... I also suggest reading the busy flag because if you are not then you are probably sending it instructions while it is executing the last instruction.
    If the command and data delay settings are wrong or the device is too slow, why does it work perfectly with displaying letters and numbers? In addition, I could put a for/next loop from 0 to 33 and the bargraph routine runs perfectly hours on end. More testing reveals this:

    Range.... Number where the bargraph is not displayed correctly
    64 .... 4
    128 .... 8
    256 .... 16
    512 .... 34
    1024 .... 66
    2048 .... 132

    This means something, just not sure what. The one common thing I can see is that when one box (three vertical "l"'s) fills up, the next time the bargraph routine attempts to write to the next box, it will fail. If I adjust the column from 0 to 1, it will now allow me to successfully write four boxes instead of one.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    why does it work perfectly with displaying letters and numbers?
    Maybe that is all it is good for?
    Dave
    Always wear safety glasses while programming.

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 : 2

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