Problems with Arduino and LCD Button shield

Discussion in 'General Engine Discussion' started by chucketn, Mar 13, 2015.

Help Support HMEM by donating:

  1. Mar 13, 2015 #1

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I am experiencing issues with the Sainsmart LCD button shield. I had problems with it in the shop, cutting gears. I brought it in to my computer to reload the code. I then tried to set it for 52 divisions and it locked at 10 on the input. I had to reset twice to get the 52 divisions entered. Is this a sign that the buttons are failing?
    I have the larger 5 button module on order, and a spare LCD to wire it to.

    Chuck
     
  2. Mar 13, 2015 #2

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    any possibility of a little static discharge while using it? I've found that processor chips are vulnerable in open pcb boards and often freeze during operation due to slightest provocation. enclosures required for long term reliability
     
  3. Mar 13, 2015 #3

    canadianhorsepower

    canadianhorsepower

    canadianhorsepower

    Well-Known Member HMEM Supporter

    Joined:
    Oct 22, 2011
    Messages:
    1,671
    Likes Received:
    320
    Hi Chuck
    do you have an electrolitic capacitor between your +and - onyour bread board

    If you don't you need one 10micro and up will do

    cheers
    Luc
     
  4. Mar 13, 2015 #4

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    No enclosure yet, and no capacitor. I just had the Arduino screwed to a 1/4" ply board, with the LCD Button shield on top, TB6065 stepper board next to it, also screwed down.
    I duplicated the problem after bringing the whole setup inside and reloading it. I also tried it with another Arduino and got same results.
    I have 2 Arduino Uno clones, one real Arduino Uno, and an Arduino Mega. Haven't used the Mega yet.
    I hope it works better with the 5 button module.
    With the local Radio Shack stores closed, where is a hopefully local source for contact/tuner cleaner? Maybe the LCD switches need cleaning.

    Chuck
     
  5. Mar 13, 2015 #5

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,138
    Likes Received:
    335
    Reloading the code will make no difference. Just hit the reset button. These things are designed for bulletproof embedded applications.

    Chuck F's sketch does not do much in the way of debouncing key strokes and the code he uses to read the keyboard analog voltage is pretty basic. It is possible that your LCD shield has slightly different values to what is expected so I would write a sketch that displayed the value returned from the analog read of the keyboard port on a button press and check these values against Chuck's sketch.

    Remember, these things are not just plug and play. If you want a keyboard, you have to build it from the ground up!

    Having said that, I think the buttons on these keyboards are very low quality. I've had one die completely.
     
  6. Mar 14, 2015 #6

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    I have two things to offer that might help. In ChuckF's I changed the debounce part of the code that solved that part of the problem for me. Go back to his Posts and you will find what I changed. Just comment out the old code and paste in what I posted. If it doesn't work just uncomment and cut out my idea. I have had LOTS of problems with those dam switches on the LCD shields. How about turning the shield over and solder wires to the switch points and use real NO push buttons. You can leave the old buttons there. Carl
     
  7. Mar 14, 2015 #7

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    cwebs, I went back to Chuck F's thread and got your debounce code. I commented out the old code and added yours. Now I get an error on compiling in the segment following your code.

    Chuck
     
    Last edited: Mar 14, 2015
  8. Mar 14, 2015 #8

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,138
    Likes Received:
    335
    Sounds like you left a brace "{" or "}" out so it keeps looking for the ending brace. The Arduino IDE will match braces so go though it carefully and watch that everything matches off
     
  9. Mar 14, 2015 #9

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    Here's just such a sketch I used to verify the values of analog read...

    // Example 25.1

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

    int a=0;

    void setup()
    {
    lcd.begin(20, 4);
    pinMode(A5, INPUT_PULLUP);
    }

    void loop()
    {
    a = analogRead(0);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(" analogRead() ");
    lcd.setCursor(0,1);
    lcd.print(" value is :");
    lcd.print(a);
    delay(250);
    }

    Since you're using sainsmart I expect your keypad matches Chucks values almost perfectly but its fast way to eliminate a possible cause
     
  10. Mar 14, 2015 #10

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
     
  11. Mar 14, 2015 #11

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,138
    Likes Received:
    335
    Theres only 2 things which I've seen that causes random stuff happening.
    1. Faulty LCD buttons that trigger randomly
    2. The 2 k of dynamic RAM has overflowed because the program stack grows and overwrites your data at run time.

    Chuck F's code is very basic and simple, use little memory, has been proven to work so I would say its your buttons.
    Do you get random stuff happening with TorontoBuilder's simple testing sketch?
    There are no checks for stack overflow in the Arduino memory management, you just tend to work it out when funny stuff happens.

    You could try using my controller software. Its a lot bigger and needs about 950 bytes of free global memory (reported at run time) or strange things happen. I see stack overflow as corrupt data entry routines, generally in the setup menu where memory useage is at the maximum (eg. The stack is at its biggest).
     
  12. Mar 14, 2015 #12

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Rod, no insult intended, but I have had problems with your code from the first version. I now don't know if it's the buttons, me, my other hardware, or what!.
    The button reading code worked with no problems. My buttons returned 716, 474, 130, 302, and zero with no weirdness. Tomorrow I will run to Lowes and get a aerosol can of contact cleaner and try cleaning my buttons on the LCD shield. If that doesn't work, I'm done until the big button board comes in.
    I have a lot of time and frustration invested in this project just to get where I'm at. I have seen what it can do when it works, and that is fantastic!

    Chuck
     
  13. Mar 15, 2015 #13

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,138
    Likes Received:
    335
    Chuck, no insult taken. But if you've had problems with two Arduino sketches that others have got working, it points to a problem with your hardware given we are all using the same compiler to create the software.

    The arduino has become enormously popular and everybody today expects a plug and play development environment but it simply isn't. It's a clever little development board that packages the Atmel RISC based Mega CPU's that have been around since the 1980s. You design the hardware the CPU controls, you write the software using the free Atmel compiler or the simpler Arduino IDE. Sticking a LCD display on it was never originally envisaged. You do need some electonics experience and some coding skills..If it ain't working, its something you did wrong!
     
  14. Mar 15, 2015 #14

    cwebs

    cwebs

    cwebs

    Well-Known Member

    Joined:
    Sep 12, 2012
    Messages:
    54
    Likes Received:
    13
    If the sketch compilied it not the problem.


    You have nothen to loose by turning the shield over and solder wires to the switch points and use real NO push buttons. Try one on the worst switch. Trouble shoot it by trying every thing you can think of. It is alwas something simple. You can leave the old buttons there. Carl
     
  15. Mar 17, 2015 #15

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,303
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I received the 5 button module yesterday. I got it hooked up with one of my Uno clones, a plain LCD and have gotten TorontoBuilders key reader sketch to work with it. I read the buttons as:
    None pressed 1023
    Left 0
    Up 141
    Down 328
    Right 505
    Select 743
    I added 50 to each of these values and put them in Chuck F's original code. The code is the version with one Ratio value and starts with "Use Up/Down Btns to set Divisions".
    When I hit the Up button the display changes, but the # of divisions doesn't change. No further button presses cause any change(not connected to Stepper at this time).
    I have substituted analogRead for LCD_Buttons in the sketch. What am I missing?

    Chuck
     
  16. Mar 18, 2015 #16

    rodw

    rodw

    rodw

    Well-Known Member

    Joined:
    Dec 3, 2012
    Messages:
    1,138
    Likes Received:
    335
    Chuck, study this code
    http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VQlIXo7LdcQ

    You'll see that they are looking for a number within +- 10 of the values expected. If you can't see that you need to study up on C coding until you do. Edit the script to put in you values. Once you understand the code, then consider inserting this code into Chucks sketch.

    As I said these devices are NOT plug and play. f you want a button, YOU have to code it from scratch.

    Note that this example does not properly debounce the returned code so search on the Arduino site to learn how to do this.

    EDIT.: stop and think about what you've done and then think what might be the result if you add 25 to the numbers instead. Draw a number line so you can visualise it. YOU are in control.
     

Draft saved Draft deleted

Share This Page