14 Replies Latest reply on Aug 24, 2016 9:53 PM by Saravanan_ECE_Ait

    Problems getting LCD to work with Galileo

    Clayton Hofrock

      I have been trying to get my Galileo board to work with an LCD display.

       

      I have connected the display to an Arduino board, and it works perfectly. I connected it as described on this page: http://www.instructables.com/id/Connecting-an-LCD-to-the-Arduino/

      When I connected it to the Galileo board, it did not work. I saw on some post in some thread in here that it should work if I do not use pin 12 and instead substitute pin 10.

       

      I changed the wire, changed the sketch and connected it back to the Ardunio board, and again it worked fine. So, I connected it to the Galileo board and it did not work. It did seem to clear the display (which it was not doing when connected to Pin 12) but it did not write any characters.

       

      Has anyone gotten this to work with the Galileo?

        • 1. Re: Problems getting LCD to work with Galileo
          arduino_4_life

          Hi,

               The LCDs should work, however right now there seems to be a bug in the GPIO code

          (the file is /hardware/arduino/x86/cores/arduino/wiring_digital.c, if you feel like debugging!)

          This will be fixed in an upcoming release.

           

          Erik.

          1 of 1 people found this helpful
          • 2. Re: Problems getting LCD to work with Galileo
            ek

            Try this:

            Include following statement in setup(), before issueing any other lcd statement.

              lcd.init(1,12,255,11,5,4,3,2,0,0,0,0);

             

            A friend of mine gave me above solution and my LCD (HD44780-compatible. 4-bit data connection. similar to yours) started working fine.

             

            Hope it solves the problem.

            Eiichi

            • 3. Re: Problems getting LCD to work with Galileo
              Kerney

              That didn't work for mine. I traced the calls through the LiquidCrystal.cpp on a standard Arduino Duemilanove which works and it uses init(1,8,255,9,4,5,6,7,0,0,0,0) on mine anyway.

              Checked with the Galileo shipped libraries and it uses the same numbers.

              Mine is an LCD keypad shield from BangGood.

              http://www.banggood.com/Keypad-Shield-Blue-Backlight-For-Arduino-Robot-LCD-1602-Board-p-79326.html

              Keypad buttons work fine.

              Can you elaborate on the bug? Not sure where to start looking.

              • 4. Re: Problems getting LCD to work with Galileo
                flummer

                Using the extra lcd.init(...) line, I have also gotten my LCD to work, but it runs very slowly (the letters in the first line of the hello world example is shown very slowly one at a time), but I have text on the display which I did not have before I added the extra line.

                 

                I have also looked a bit in the underlaying code, and to me it looks like this exact same call is made during the initialization, which makes me wonder what's going wrong. Is it an issue with the constructor being executed too early in the process before the pin control is fully operational?

                 

                /Thomas

                • 5. Re: Problems getting LCD to work with Galileo
                  ek

                  Kerney, I don't have a clue. You are doing just fine.

                  Thomas, mine works very slowly as well. It's probably more than 10x slower than UNO... As you pointed out, the lcd.init(...) line is redundant. Same thing is done in the constructor of lcd object.

                   

                  Below is my friend's guess of what's happening:

                  When lcd object is created, Galileo IDE calls the constructor, but soon it forgets what it did in the constructor. Due to the bug, lcd object is not initialized inside setup() routine. Calling the lcd.init(...) again in setup() will initialize the object to correct state.

                   

                  I'm not sure if above guess is correct. I hope that Galileo team can figure out the root cause and fix it.

                  /Eiichi

                  • 6. Re: Problems getting LCD to work with Galileo
                    Clayton Hofrock

                    I finally was able to build the 0.8 firmware and the init statement is still needed in order to get my LCD to work.

                     

                    Also in the Linux console window, when the sketch starts I see LOTS of "trace error 9" messages being printed out.

                     

                    The error also occurs with the 0.7.5 firmware.

                    • 7. Re: Problems getting LCD to work with Galileo
                      Bryan

                      The solution of calling lcd.init() once again in the setup function worked for me. But since I am new to LCD displays, I will clarify something I learned.

                       

                      The lcd.init() arguments correspond to the connected pins on the Arduino. Look them up in LiquidCrystal.cpp.

                       

                      If you set up your lcd like this => LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

                       

                      Then call this in your setup function => lcd.init(1,7,255,8,9,10,11,12,0,0,0,0);

                      • 8. Re: Problems getting LCD to work with Galileo
                        Mikal.Hart

                        I believe the problem is that the LiquidCrystal constructor relies on digitalWrite, which is not immediately available when a C++ sketch begins.  If you declare a LiquidCrystal object with global scope, the constructor is executed before your program proper begins, indeed, before digitalWrite is available.

                         

                        Testing this theory, I moved my declaration inside setup(), and this "solved" the problem:

                         

                        void setup()

                        {

                          LiquidCrystal lcd(LCD_RS, LCD_RW, LCD_Enable, LCD_DB4, LCD_DB5, LCD_DB6, LCD_DB7);

                          lcd.begin(8, 2);

                          lcd.print("Hello");

                          lcd.setCursor(0, 1);

                          lcd.print("World!");

                        }

                         

                        ... although of course an object declared like this is not available outside setup().

                         

                        Also, the very slow display updates are caused by the fact that for each character written to the display, digitalWrite is called at least 9 times @ 4-5 ms per call, and pinMode is called at least 8 times @ 16-17ms for a grand total of more than 2 seconds for "Hello, World!".

                        • 9. Re: Problems getting LCD to work with Galileo
                          Mikal.Hart

                          BTW, A cleaner workaround to the constructor problem is to simply reinitialize the object with the constructor, instead of coming up with the unwieldy call to init().

                           

                          For example, if your object is declared globally as

                           

                          LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

                           

                          simply do this when you begin:

                           

                          void setup()

                          {

                             ...

                             lcd = LiquidCrystal(7, 8, 9, 10, 11, 12); // reinitialize

                             lcd.begin(8, 2);  // assuming 8x2 screen; adjust as needed.

                             lcd.print("Hello");

                             lcd.setCursor(0, 1); // move cursor to beginning of second row

                             lcd.print("World!");

                             ...

                          }

                          1 of 1 people found this helpful
                          • 10. Re: Problems getting LCD to work with Galileo
                            Mikal.Hart

                            For a still-better solution to the initialization problem--a library fix that actually removes the need for a workaround--see this thread: Galileo LiquidCrystal Library Fixes

                            • 11. Re: Problems getting LCD to work with Galileo
                              pranchand

                              hi guys ,there is no init function in my  lcd library in arduino 1.5.3,i am not able to get any output ,please help me

                              • 12. Re: Problems getting LCD to work with Galileo
                                pranchand

                                hi , can u just share with me the Lcd  u all use ,which gives output. i am using lcd JHD162A, do you think its compatible,please reply.

                                • 13. Re: Problems getting LCD to work with Galileo
                                  Saravanan_ECE_Ait

                                  hi,

                                       iam using LCD 16*2 with Intel galileo gen2 Board,The lcd not working

                                  please help me to clear the error

                                  my code:

                                   

                                   

                                  #include <LiquidCrystal.h>

                                  LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

                                  void setup()
                                  {
                                       lcd = LiquidCrystal(2, 3, 4, 5, 11, 12); // reinitialize
                                    lcd.begin(16, 2);
                                    lcd.print("hello, world!");
                                  }

                                  void loop() {
                                    lcd.setCursor(0, 1);
                                    lcd.print(millis() / 1000);
                                  }

                                  • 14. Re: Problems getting LCD to work with Galileo
                                    Saravanan_ECE_Ait

                                    #include <LiquidCrystal.h>

                                    LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

                                    void setup()
                                    {
                                         lcd = LiquidCrystal(2, 3, 4, 5, 11, 12); // reinitialize
                                      lcd.begin(16, 2);
                                      lcd.print("hello, world!");
                                    }

                                    void loop() {
                                      lcd.setCursor(0, 1);
                                      lcd.print(millis() / 1000);
                                    }

                                     

                                    send to email :  saravananeceait1@gmail.com