LCD BARgraphs


Closed Thread
Results 1 to 40 of 233

Thread: LCD BARgraphs

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    I'm not smart enough to figure out why this is happening but the problem has been identified. Whenever the program sends "Threebars," it goes wacky. If I modify the code from this:
    Code:
    SELECT CASE BARtemp
                CASE IS > BARloop
                         LCDOUT ThreeBARS              ; send 3 bars    |||
                CASE IS < BARloop
    to this:
    Code:
    SELECT CASE BARtemp
                CASE IS > BARloop
                    
                CASE IS < BARloop
    it will run fine. Of course only two bars will be displayed but something with the code is causing a problem in the display.

    I made a bargraph routine and it works just fine so the problem is a conflict between the lcdbar inlcude file and the OLED screen. There isn't enough experience in my brain to figure out why so maybe someone else can. It was a good experience for me because I never used bargraphs before and I learned a lot from DT's program. The only thing I don't like about the program below is that it keeps writing over the previous graph, even if the data doesn't change, so if the bargraph stays at 100% or a high amount, you can see the bargraph flicker a little bit. I'm guessing that a routine is needed whereby nothing is written unless the number changes.

    Code:
    C0     VAR     BYTE
     C1     VAR     BYTE
     C2     VAR     BYTE
     C3     VAR     BYTE
     C4     VAR     BYTE
     C5     VAR     BYTE
     C6     VAR     BYTE
     C7     VAR     BYTE
    
    C0  = $40
    C1  = $48
    C2  = $50
    C3  = $58
    C4  = $60
    C5  = $68
    C6  = $70
    C7  = $78
    
    lcdout 254,C0,REP 16\8
    lcdout 254,C1,REP 24\8  
    lcdout 254,C2,REP 28\8
    lcdout 254,C3,REP 30\8
    lcdout 254,C4,REP 31\8
    BOX     VAR     WORD
    LINE    VAR     WORD
    
    FRICT_PAD_TQ_BAR    VAR    WORD
    LINE_DISPLAY        VAR     BYTE
    BOX_DISPLAY         VAR     BYTE
    FRICT_PAD_TQ        VAR    WORD
    
    
    MAIN: 
     
    FRICT_PAD_TQ_BAR=(FRICT_PAD_TQ-12)/5
    BOX_DISPLAY=127
    LINE_DISPLAY=0
    FOR LINE = 0 TO FRICT_PAD_TQ_BAR
        LCDOUT $FE, BOX_DISPLAY,LINE_DISPLAY
        LINE_DISPLAY=LINE_DISPLAY+1
            IF LINE_DISPLAY=5 THEN
                BOX_DISPLAY=BOX_DISPLAY+1
                LINE_DISPLAY=0
            ENDIF
        LCDOUT $FE,212, DEC FRICT_PAD_TQ_BAR
    NEXT LINE
    BOX_DISPLAY=0
    LINE_DISPLAY=0
    GOTO MAIN

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


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Chris, Have you written code to look at the BUSY bit? I think you would be a bit supprised to find out just how long it takes some SPOOLED commands to execute. I have had this problem before with some NewHaven displays and with there lack of documentation you just have to figure out things on your own. What I would do is, write a routine to first set an output bit and connect a scope, then look at the busy bit after you send a command string to the display. re-check the busy bit to be clear, reset the output bit when the bit is clear and you would be supprised. Why do you think they make it available? You as the programmer are supposed to knowlegable enough to use the BUSY bit. Otherwise, don't complain about someone elses routines not working unless you know what the problem is....... Happy Thanksgiving......
    Last edited by Dave; - 23rd November 2012 at 00:26.
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Otherwise, don't complain about someone elses routines not working unless you know what the problem is
    It wasn't a complaint, Yoda. I said there was a conflict between DT's program and the OLED screen. That's a factual statement. In fact, I'm very appreciate of the information Darrel posts on here. Exhibit A:
    Darrel, this program is awesome by the way!

    I learned a lot from DT's program.
    I've been using the OLED screens for over a year now. I know people have had problems with the displays but I really like them and never had a problem. If you know of a better OLED screen, by all means a better suggestion is always welcomed. Do you think people on here use Newhaven LCD/OLED screens? I'd be inclined to say yes. Given that fact, someone along the way is going to run into this same problem.

    If there's a simple solution or a new line of code can be inserted to make it work correctly, why not do it? The main intent of the post was to elicit substantive discussion regarding the Newhaven OLED screen and DT's program. It doesn't work "off the shelf," which is perfectly fine. However, if Darrel or anyone else can provide a solution to make the program work, that would be great, but everyone on here understands there are no obligations. I don't have enough programming knowledge to contribute a lot here, so maybe this is a chance for me to do so if nobody else has the time to do it.

    Personally, a lot of time has been spent on this and I'm really learning a lot. Even if I don't find a solution, it's time well spent.

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


    Did you find this post helpful? Yes | No

    Default Re: LCD BARgraphs

    Chris, Just use the busy bit to confirm the display is ready for the next command.... As I said in the my first return post, the commands are processed by the display far too slowly and I see no delays in your code after any of the cursor control commands and you are probably running it in 4 bit mode as opposed to 8 bit mode which now allows for even more data to be lost. looking at the timing constraints in the data sheet, I'm supprised the thing is working at all. The processor onboard the display is probably doing far more work than your code is. If you are commited to using this type of display with it's down falls because it looks good then you MUST you it as it was intended to be used it you expect it to relay the information correctly. No more to say...
    Dave Purola,
    N8NTA
    EN82fn

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


    Did you find this post helpful? Yes | No

    Default Success!

    looking at the timing constraints in the data sheet, I'm supprised the thing is working at all. ....If you are commited to using this type of display with it's down falls because it looks good then you MUST you it as it was intended to be used it you expect it to relay the information correctly. No more to say...


    Anyhow, for anyone who is using a Newhaven OLED display and wants to use Darrel's bargraph routine, you only have to modify a few things, which only takes about 30 seconds to do so. Here is what you need to do:

    Make this portion of the code:
    Code:
        LCDOut $FE,$40,REP $15\8                  ; Custom char 0 - 3 lines  |||
        LCDOut $FE,$48,REP $14\8                  ; Custom char 1 - 2 lines  ||
        LCDOut $FE,$50,REP $10\8                  ; Custom char 2 - 1 line   |
    To make it look like this:
    Code:
        LCDOut $FE,$48,REP $15\8                  ; Custom char 0 - 3 lines  |||
        LCDOut $FE,$50,REP $14\8                  ; Custom char 1 - 2 lines  ||
        LCDOut $FE,$58,REP $10\8                  ; Custom char 2 - 1 line   |
    You have change the numbers in the other two character sets if you use blocks and boxes.

    You also have to modify this code:
    Code:
    ThreeBARS CON 0                                ; Identify the Custom Characters
    TwoBARS   CON 1
    OneBAR    CON 2
    To this:
    Code:
    ThreeBARS CON 1                                ; Identify the Custom Characters
    TwoBARS   CON 2
    OneBAR    CON 3
    By modifying the lines of code above, the bargraph will display correctly on your OLED screen. I tested the bargraph a few different ways and it worked 100% of the time. I hope this is able to help someone.

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Exclamation Re: Success!

    THE CHANGES IN THE ABOVE POST ARE INCOMPLETE!!!

    If you make those modifications, you need to change all of the custom character declarations. Otherwise, the other styles will not work properly. Here are the other modifications (shown with the first set for context):

    Code:
    ; --- lines Style custom chars ----
    CharsetLines:
        LCDOut $FE,$48,REP $15\8                  ; Custom char 0 - 3 lines  |||
        LCDOut $FE,$50,REP $14\8                  ; Custom char 1 - 2 lines  ||
        LCDOut $FE,$58,REP $10\8                  ; Custom char 2 - 1 line   |
    RETURN
    
    ; --- boxed Style custom chars ----
    CharsetBoxed:
        LCDOut $FE,$48,$1F,REP $15\6,$1F          ; III
        LCDOut $FE,$50,$1C,REP $14\6,$1C          ; II
        LCDOut $FE,$58,REP $10\8                  ; I
    RETURN
    
    ; --- blocks Style custom chars ----
    CharsetBlocks:
        LCDOut $FE,$48,REP $1F\8
        LCDOut $FE,$50,REP $1C\8
        LCDOut $FE,$58,REP $10\8
    RETURN

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


    Did you find this post helpful? Yes | No

    Default Re: Success!

    So, what you're saying is that if you use Custom Character 0 on those displays, everything goes crazy?
    Displaying the wrong characters on the wrong lines.

    And by just not using Cust. Char 0, everythings AOK?
    On both of your dispays?

    That's a new one ... but it sounds typical for Newhaven.
    DT

  8. #8
    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 SteveB View Post
    THE CHANGES IN THE ABOVE POST ARE INCOMPLETE!!!

    If you make those modifications, you need to change all of the custom character declarations. Otherwise, the other styles will not work properly. Here are the other modifications (shown with the first set for context):
    No kidding. Did you read my post?
    You have change the numbers in the other two character sets if you use blocks and boxes.

    Quote Originally Posted by Darrel Taylor View Post
    So, what you're saying is that if you use Custom Character 0 on those displays, everything goes crazy?
    Displaying the wrong characters on the wrong lines.

    And by just not using Cust. Char 0, everythings AOK?
    On both of your dispays?

    That's a new one ... but it sounds typical for Newhaven.
    Yup. I tried this on both displays with different programs. Whenever a 0 is used, the display gets all wacky. It will not only display the characters on the wrong line, the entire OLED displays wacky stuff. (I took two crappy cell phone pics of the differences). You also have to change the LCDOUT commands too. If you don't, it will still work but the box won't be filled out completely.

    I tested it a bunch of different ways and I couldn't make it fail. Perhaps I didn't test every single mode but what I did test (what I normally use) worked perfectly!Name:  IMAG0306.jpg
Views: 2253
Size:  47.4 KBName:  IMAG0307.jpg
Views: 2249
Size:  80.5 KB

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