Menu

LCD HC-44780 garbage characters at some startups / re-boots

Help
vmatthews
2014-03-04
2014-12-22
1 2 > >> (Page 1 of 2)
  • vmatthews

    vmatthews - 2014-03-04

    At times in different projects, I get garaged characters when I fire-up the PIC with an LCD. And generally is true in any of the different PIC chips and code.
    I have it wired to power up the same as the pic with a switch. I am using the standard code suggested by the help files & using the LCD_NO_RW for the r/w pin that is tied to ground.

    I have D4~D7 with 4.7k to Vdd the R/W pin to Vss.
    the Enable and RS are straight-thru to PIC. Vdd Vss are on the 5v power rail with PIC
    I have a .1uf cap on breadboard to capture noise. and have tried 4 different power source including batteries to see if that made a difference.

    Sometimes it works great, sometimes gets garbage till I power PIC & LCD several times.
    And I believe always works right when a PICKit3 is on the PIC
    What is a suggested way to deal with it, should I power with the PIC port?
    Utilize a Capacitor somewhere ? AN Additional resistor?
    Thought I would ask the pro's for the best solution.
    Thanks for the support!

    vic

     

    Last edit: vmatthews 2014-03-04
    • Chuck Hellebuyck

      Have you tried adding a delay (250 msec) at the beginning of the program?
      The PIC powers up and initializes much faster than the LCD. The LCD routine has a delay, I believe, but for some LCDs it may need to be increased.

      The PICkit 3 control circuitry probably adds power-up delay so that is why it works but direct power doesn't.

       
      • vmatthews

        vmatthews - 2014-03-05

        I applied varies program delays from 50ms, 250 ms, 1 s, up to 5 secs..
        then I wired the LCD to be powered by PIC (16F877a) with varies delays, and still has garbage, worse now after I Power-up with PIC. even the PICkit3 can't no longer clear up the LCD. So, I'll back to shared power rails
        Thanks.. vic

         
  • Chuck Hellebuyck

    Post the code. Maybe we'll see something.

     
    • vmatthews

      vmatthews - 2014-03-05
       

      Last edit: vmatthews 2014-03-05
  • vmatthews

    vmatthews - 2014-03-05

    here's the code.....
    But remember the LCD issue extends to most of my other projects as well. I posted the schematics earlier. are the resistors currently defined with the LCD ok, is there other values I should use?

     

    Last edit: vmatthews 2014-03-05
  • Anobium

    Anobium - 2014-03-05

    @Vic. I have just tried to compile the code. Does not compile. I have a few errors of unspecified ports and a unspecified goto statement.

    *** makeHEX.bat ***
    
    Great Cow BASIC (0.9 17/2/2014)
    
    Compiling D:\MicroChip\Projects\Great Cow Basic\Support\LCD Garbarge\LCD Garbarge 001.gcb ...
    
    Errors have been found:
    
    LCD Garbarge 001.gcb (38): Error: TRIGLED1 is not a valid I/O pin or port
    LCD Garbarge 001.gcb (193): Error: Incorrect parameters in Set, expected: 
    Set variable.bit status
    LCD Garbarge 001.gcb (243): Error: Incorrect parameters in Set, expected: 
    Set variable.bit status
    LCD Garbarge 001.gcb (347): Error: Incorrect parameters in Set, expected: 
    Set variable.bit status
    LCD Garbarge 001.gcb (366): Error: Incorrect parameters in Set, expected: 
    Set variable.bit status
    LCD Garbarge 001.gcb (486): Error: Incorrect parameters in Set, expected: 
    Set variable.bit status
    
    The message has been logged to the file Errors.txt.
    

    What are you using to compile the code?
    What version of GCB?
    Or, do you have code that does compile and this was posted in error?

    Anobium

    @Chuck - I am really busy this week but I did find time to try and compile. Chuck over to you now. :-)

     

    Last edit: Anobium 2014-03-05
    • vmatthews

      vmatthews - 2014-03-05

      I write this code in GC Version 1.0 21/9/2013 copy/paste this off the "about" screen.
      and use Microchip IDE 'see attachment', and all compiles fine.

      I write and compile it with GC and then use the IDE to write to PIC !
      All my projects with LCD run fine, just when I remove the PICkit3 does the issue with garbage characters occur. and in most cases I can reboot the PIC & LCD and finally get it looking right.

      Any clue as to what I must be doing wrong?

       
      • Anobium

        Anobium - 2014-03-05

        I don't understand. the code you posted has two errors.

        TrigLED1 is not 'define'd and there is no lable to support the 'goto Reset_Sw' statement.

        Are you able to post your GCB compiler error log?

         
        • vmatthews

          vmatthews - 2014-03-06

          SORRY about that.. the missing TrigLED1 & Reset_Sw. I was rushing up the code to the BBS last night and didn't compile it first (which would have Yelled at me) cause I had an early morning Alarm calling. And the Reset_Sw was added to provide a software trigger for the LCD trying to see if that would fix LCD. (That idea was removed)
          And trying different 'Wait' events with various delays and in different places in the code to see if a delay in code or in LCD power-up would make a difference... and NO -None of these attempts worked. So Reset_sw is canned and just add the 'define TrigLED1 PortC.0' and remove delared Reset_sw.

          A weird thing.. I was using tabs and some spacebar spaces to form the code in groupings rows, and this happened a couple times... when I would jump out the text view and to the Icon View, and then go to Text View again, it would remove the spaces, and at times the code behind it, which, of course, then failed to compile, and after it did it twice to me, I stopped using single spaces and just a hard TAB to space. Anybody else have that happen??

          I can send up the corrected code if you wish.
          I am having more success using the hard wired R/W to PIC. and most the garbage characters at startup are minimal - So, Thanks for those links and tips. It sure is alot better!

           
  • Anobium

    Anobium - 2014-03-05

    and, see https://sourceforge.net/p/gcbasic/discussion/629990/thread/db57ea15/#e830

    I do not use LCD's so I cannot test but this looks like it resolves the issue, also, hunting thru the forum seems to show that calling InitLCD after a delay may resolve the issue.

    So, try calling InitLCD after your delay then another small delay and then the rest of your code, or, try the code shown in https://sourceforge.net/p/gcbasic/discussion/629990/thread/db57ea15/#e830

     
    • vmatthews

      vmatthews - 2014-03-05

      Thanks;
      I will try tapping the R/W pin to a port and let you know.
      vic

       
    • vmatthews

      vmatthews - 2014-03-06

      I am having more success using the hard wired R/W to PIC. and most the garbage characters at startup are minimal - So, Thanks for those links and tips. It sure is alot better!

      Odd that I am having these problems with NO_RW, but I'll take the hard wire.

      I never saw any other msg. about anyone else having this issue. I was hoping some-one had addressed this. Just curious now. But the R/W hardwire works majority of the time. AND with this solution I have the option to 'Read' the LCD.

      Thanks!

       
  • Anobium

    Anobium - 2014-03-06

    Keep at it. You should have no errors.

    Check 0v connection, check your clock etc.

    Let us know how you get on.

     
  • Chuck Hellebuyck

    I had to add two lines to get the code to build:

    #define ReSet_Sw AN0 
    and 
    #define TrigLED1 PortC.0 
    

    The I ran it in the PIC Simulator and it ran fine so must be something in the hardware connections.

    LCD displayed:
    Trigger & LED: 1

     
  • vmatthews

    vmatthews - 2014-03-07

    Yea, That's the section that will test the trigger(s) and associated LEDs for each team.
    Cool looking program you got! Didn't know that was out there.

    I even built another circuit on a different breadboard to see if that would make a difference, and it didn't. I didn't think it would, since I have that (NOW minor) problem with other boards/circuits also. I still have to kick it on/off at times, but better. Used a different Power supply (5.05v) and the circuit only draws 18ma. So I'll keep eating at that..

    But another Question:
    the compiler is giving an error..
    Error in Main at 153: Cannot store SysArrayTemp1 in the string variable MID
    .....................
    Dim AlarmSign As String '__display_of_#'s showing enabled
    Dim AlarmRange(4) As Array 'stores_the_Distance_to_trigger_Alarm
    Dim AlarmARMed(4) as Array '_Stores_the
    #_if_Enabled
    Dim NumTmp as Byte '_Temp number
    .....................
    AlarmSign=" " '_Padded_space_Holder_4spcs_to_print_later
    For Numtmp=1 to 4

    Mid(AlarmSign,NumTmp,1)=AlarmARMed(NumTmp)
    *(also tried)* LET Mid(AlarmSign,NumTmp,1)=AlarmARMed(NumTmp)
    
    Next
    

    .........................
    basically.. Padded a string (ALARMSIGN) with 4 spaces, then I was trying to write char- from AlarmARMed into ALARMSIGN using the MID statement.
    The sample given in the HELP is using it to display a portion of the defined string. I was assuming(!?) that this would be a valid call as it is in VB/etc but I guess that is not the case. So if anyone can provide me with a work-around. I would appreciate that.

    I would send the code up, but It is no-where of being finished, so I thought I would put this out there and work on other sections.

    Thanks, Ya'll
    vic

     

    Last edit: vmatthews 2014-03-07
  • Anobium

    Anobium - 2014-03-07

    MID is a function as does not work as you are using.

    I am not sure what you trying to achieve but try you can
    AlarmSign(NumTmp) = AlarmARMed(NumTmp).

    Note: Strings are arrays of characters so you can address a string as an array.

     
    • vmatthews

      vmatthews - 2014-03-07

      Thanks for the reply..

      I did try your code the first time thru this:
      AlarmSign(NumTmp) = AlarmARMed(NumTmp).
      Got the same error..
      and then I put up this next code after this also failed.
      Mid(AlarmSign,NumTmp,1)=AlarmARMed(NumTmp)

      The reference I used as a guide to the issue is
      http://gcbasic.sourceforge.net/help/
      'Fill a string with a message
      Dim TestData As String
      TestData = "The cat sat on the mat"

      'Extract "cat". The c is at position 5, and 3 letters are needed
      HSerPrint "The animal is a "
      HSerPrint Mid(TestData, 5, 3) << This line

      'Extract the action. "sat" starts at position 9.
      HSerPrint "The animal "
      HSerPrint Mid(TestData, 9) also this one
      HSerPrintCRLF

      Obvious I am confused, since these arrays are strings (holding string characters). I get from the HELP that this is READING the string as oppose to writing to a string. I was assuming it would work both ways, and I think your telling me it works only as a READ function (is Funtion the right word?). Is that correct? Just for READing?

      As alawys, Thanks for your help,
      Vic

       
  • Anobium

    Anobium - 2014-03-07

    Please post/attach your code. I think the error is in defining variables or something.

     
    • vmatthews

      vmatthews - 2014-03-07

      UGH!!! Now that I ran the R/W direct to PIC, Now I'm getting garb aged characters when the PICkit3 is connected, and not so much when PICkit3 is Not on the PIC.. Tried different LCDs (1602) also.
      I think I have a solution, might need the use of my sledgehammer...

      But back to the code....
      Dim SR04_EchoRange as Integer
      Dim AlarmSign As string 'display_of_#'s showing enabled_
      Dim AlarmRange(4) 'holds the (number) alarm range for alarms
      Dim AlarmARM1 as string
      Dim AlarmARM2 as string
      Dim AlarmARM3 as string
      Dim AlarmARM4 as string
      Dim NumTmp As byte 'temp number_

      ..................................
      AlarmSign=" " ' 4 spaces to fill with AlarmArmX characters
      Mid(AlarmSign,1)=AlarmARM1 'ArmX is a single character
      Mid(AlarmSign,2)=AlarmARM2
      Mid(AlarmSign,3)=AlarmARM3
      Mid(AlarmSign,4)=AlarmARM4
      '__LCD_print
      CLS
      Print AlarmSign
      ..................................
      If I REM out the 4 MID statements the error goes away..

      Thanks for all the input!

      Vic

       
      • Chuck Hellebuyck

        I just remember that I've seen that type of LCD behavior before and it was related to how fast the PIC was running. What speed are you running at?

        In PICBASIC PRO compiler you can set the delay between commands. But I don't see how to do that easily in GCB. So if you are running fast, then it may be sending data too fast for the LCD to read properly.

         
        • vmatthews

          vmatthews - 2014-03-08

          I am running 8mhz crystal with 22pf caps on a 16F877a...
          should I try slower 4mhz??

           

          Last edit: vmatthews 2014-03-08
          • Chuck Hellebuyck

            8 MHz doesn't seem that fast but I would try 4 MHz to see if it improves.

             
  • Chuck Hellebuyck

    Don't post the whole thing.
    Just post a small section that reproduces the issue.
    I find this helps debug a lot by first reproducing it in a simple program and then its easier to share and also load in MPLAB for debugging.

     
    • vmatthews

      vmatthews - 2014-03-08

      posted..

      thanks, vic

       

      Last edit: vmatthews 2014-03-08
1 2 > >> (Page 1 of 2)

Log in to post a comment.