Shop OBEX P1 Docs P2 Docs Learn Events
LCD Problem — Parallax Forums

LCD Problem

idbruceidbruce Posts: 6,197
edited 2011-02-15 13:29 in Propeller 1
Hello

When I reboot the Propeller chip, the top row of my 2 X 20 LCD displays 20 black boxes instead of the intended text. If I start the Propeller chip normally, the LCD works just fine. I am using the LCD_16x2_4bit object, which is attached below. I have tried clearing the LCD before the reboot, and I have also tried a WAITCNT before reboot, with no success. I am using the following code:
IF MonitorStartButton == TRUE
 
    LCD.Clear
 
  ELSE
    LCD.Clear
    WAITCNT(CLKFREQ + CNT)
    REBOOT

Thanks

Bruce

Comments

  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-02-09 07:19
    Are you just pressing the RESET button or power cycling the board? If it is just powering up you may need to add a small delay to allow the LCD to startup. I ran into something similar a while ago with some LCD displays. May not be the exact problem you're running into but it is worth checking.

    Robert
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 07:24
    RobotWorkshop

    I am simply calling reboot with no power cycling as shown above. Additionally, there is 3 second WAITCNT following the call to the Start method to the LCD object.

    Bruce
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 08:36
    I can confirm that. Had the same problem with this driver. I guess there is a problem in the initialization routine. But I have to admit, that I did not debug the code. First I simply took the other driver available at that time, and then I wrote my own driver, which has some nice features - for example support for menus and blinking characters for status icons.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 08:38
    Andreas

    I still have your object tucked safely away. If I can't resolve this, I will definitely be trying yours. However, it would now be quite time consuming.

    Bruce
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 08:43
    What functions of the current driver do you use? Maybe I should provide a high level and comfortable to use interface for my driver. Then you'd simply replace the object and your're done.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 08:55
    Andreas

    There really isn't a whole lot of PUB methods with this driver, but I don't need anything complicated. I am only using the following public methods.
    • Start
    • Clear
    • Move
    • Dec
    • Str
    I appreciate the offer, however I wouldn't want you to go through that just for me. I don't really need to reboot, it was just an easy option for reinitializing my variables and going back to the beginning of program execution. I think I could write the code to eliminate the reboot, but as you know, stuff like that takes time. Since it is my project, I think it would be better if I used my time, instead of wasting yours.

    Bruce
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 10:37
    Ok, Bruce,

    here's the deal: I wrote it, you test it ;o)

    It's hacked together from the driver you have and from the demo-code of my driver and it's totally untested, I only checked that it compiles.
    obj
      LCD: "BenkyLCDdriver"
    
    pub start( pinBase )
      LCD.start( pinBase, 0 )
    
    PUB CLEAR
      LCD.exec( LCD#CMD_INSTR, %00000001 )
    
    PUB MOVE (X,Y) | ADR
      ' X : Horizontal Position : 1 to 16
      ' Y : Line Number         : 1 or 2
      ADR := (Y-1) * 64
      ADR += (X-1)
      LCD.exec( LCD#CMD_INSTR, %10000000 + ADR)
    
    PUB STR (STRINGPTR)
      LCD.exec( LCD#CMD_PRINT, STRINGPTR )   
    
    PUB HEX (VALUE, DIGITS)
    
      VALUE <<= (8 - DIGITS) << 2
      REPEAT DIGITS
        LCD.exec( LCD#CMD_WRITE, LOOKUPZ((VALUE <-= 4) & $F : "0".."9", "A".."F"))
    
    PUB DEC( val ) | i
      IF (val < 0)
        -val
        LCD.exec( LCD#CMD_WRITE, "-")
    
      i:=10
      if val>0
        repeat while val<>0
          i--
          num[i]:="0"+val//10
          val:=val/10
      else
        LCD.exec( LCD#CMD_WRITE, "0" )
    
      LCD.exec( LCD#CMD_PRINT, @num+i )
      
    dat
    num byte 0[11]  
        
    PUB BIN (VALUE, DIGITS)
    
      VALUE <<= 32 - DIGITS
      REPEAT DIGITS
        LCD.exec( LCD#CMD_WRITE, (VALUE <-= 1) & 1 + "0" )
    

    I have to leave soon, so if you find bugs I can fix them in 1 or 2 hours.


    PS: The only thing you have to change in your code is to call start with the base of the used pins.
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-02-09 11:24
    This is not a problem but a very common misconception.
    Standard Hitachi compatible LCD initialize on power up.
    When initialized it will display the first row as observed.
    ( This is the time you adjust your back-light )
    This is all internal initialization and uses various time delay to accomplish this.

    Your initialization software needs to wait for this power up initialization.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 12:17
    I don't think so!

    The problem occurs when the propeller is resetted by a software reset. The LCD should not do a power up in this case.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-09 12:25
    Maybe a pullup resistor on the LCD Rx line will help. On reset, all the Prop's I/O pins will float, which may be generating spurious characters into the LCD. There might be a combnation of spurious characters that is causing the LCD to act funny.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 12:43
    Nope, I still think it's the initialization!
    With my driver everything is fine and there the PINs are also floating during reboot.

    The INIT is done in a way that only works if the display is in 8 bit mode, which is the default after power-up.

    @bruce:
    I tested my code now and it works as posted above. I also tried the reboot instructions and I don't have a problem with my display.
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-02-09 13:02
    Here are a few links I found that discuss the initalization of LCD display's. Perhaps there is something in there that will help:

    http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html

    http://ecee.colorado.edu/~ecen2120/Manual/LCD/lcd-doc.html
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-02-09 13:03
    Dave Hein wrote: »
    Maybe a pullup resistor on the LCD Rx line will help. On reset, all the Prop's I/O pins will float, which may be generating spurious characters into the LCD. There might be a combnation of spurious characters that is causing the LCD to act funny.

    In my LCD projects I always put a pull-down on the E line as this is what allows transfer to/from the LCD. The other lines can be allowed to float on reset, but not this one.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 13:09
    Sorry Guys

    I was gone for a bit. I will answer some of this in a moment.

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 13:18
    Pertaining to the hook-up, the LCD is wired according to Jon's demonstration in LCD & Things, with the exception of the switching transistor for the backlight. I trust Jons hook-up.

    @vaclav_sal - There is at least 12 seconds between LCD initialization and first output, that should be an ample waiting time. Like I said there is no problem when started normally, just during reboot.

    @MagIO2 - I have not checked it out yet, but I will be looking into that now.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 13:37
    Andreas

    I was thinking I could just add your sample within your object as PUB methods, that way it is all in one place. Do you foresee any problem with that?

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 13:42
    Andreas

    It appears to me that I need consecutive pins for you object, and if I remember correctly, that is why I opted for the other one.

    Here is my pin assigments for the LCD:
    ' Pin assignment
      RS = 17                   
      RW = 18                    
      E  = 19
      DB4 = 20
      DB7 = 23
    

    These are consecutive, but unsure of correct order.

    EDITED: Pin order looks correct
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 13:58
    RobotWorkshop

    Those were some nice references, thanks for the links.

    Bruce
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-09 14:01
    Yep, I checked it, the order is the same as in the driver you attached in your initial post.
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 14:03
    Andreas

    Yea I just checked it also. Okay I am now going to add your test code as PUB methods to the original object and give it a try. Thanks for your time and effort on this. I truly appreciate it.

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-02-09 14:31
    Andreas

    That worked perfectly! Problem eliminated!

    Thanks a lot Andreas. I appreciate your time and effort.

    Bruce
  • mparkmpark Posts: 1,305
    edited 2011-02-15 12:29
    MagIO2 wrote: »
    It's hacked together from the driver you have and from the demo-code of my driver and it's totally untested, I only checked that it compiles.
    obj
      LCD: "BenkyLCDdriver"
    ...
    

    Where is BenkyLCDdriver?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-15 13:29
Sign In or Register to comment.