Shop OBEX P1 Docs P2 Docs Learn Events
Serial LCD not updating... — Parallax Forums

Serial LCD not updating...

tenslowtenslow Posts: 6
edited 2015-07-30 18:29 in Propeller 1
I'm using Parallax's 4 x 20 LCD, and a hall-effect flow meter to measure flow rate, calculate total volume pumped, and mix a little salt into the mixture.
The display worked great, until I added my "NaCl" function- which uses the "total volume pumped" variable to calculate how long a small pump will turn on. Now it doesn't update- it'll display the flow rate and volume for a few seconds, but then it won't update! The Simple IDE terminal still updates and shows the correct information, but the LCD won't- it even overflows sometimes, after doing nothing.
I'm new to the propeller, so I'm wondering if I broke some rules with the way I used my global variables, or my cogs.
I did my best to comment my code (see attached), so I hope I just performed a rookie mistake.
Any suggestions would be greatly appreciated.
Thank you,Tony

Comments

  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-07-30 13:22
    My first recommendation is to wait much longer before turning on your LCD. I had the weirdest problems writing my own driver (for a parallel LCD, not serial) until I increased the initial delay time (for power up) to 250ms. It seems like an eternity, but a lot of weird problems went away after that.
    I'm specifically referring to the second line of StartLCD: "pause(5);"
  • My first recommendation is to wait much longer before turning on your LCD... I'm specifically referring to the second line of StartLCD: "pause(5);"

    Thanks SwimDude0614,
    Tried your advice and changed pause(5) to pause(250): the LCD only updated for ~90 seconds, then it overflowed by displaying a few odd characters in the un-used positions. I even tried pause(500), but then the LCD didn't update at all...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Tony,
    I'm not a C programmer, but if I had to guess I would say that at some point the display is getting data it doesn't understand. Does the time it stops working correspond to any specific event? If so that can help you nail down the problem in the code. Also, when you clear the display are you waiting the required 5 ms before sending more data?
  • Hi Chris,
    Thanks for your comment!
    I'm incredibly embarrassed to admit that I found my problem:
    I used the same PIN twice...
    Every PIN I use is supposed to be declared as a constant, so I don't make this exact mistake; however, I must've been in a hurry when I wrote the LCD initialization function and just declared it in there, not as a global constant, and re-used the same PIN for my button I/O.
    I only found it when I went to plug in my button. 
    Thanks for the feedback- I'm going to cry alone now, because I'm a stupid idiot :)
    Best,Tony 
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Mistakes happen. If you've learned something from it and lost no magic blue smoke you're in good shape. I would save the tears for when you damage a part the day before your project is due and haven't got time to get a replacement. ;)
  • Thanks, Chris :)
  • Every PIN I use is supposed to be declared as a constant, so I don't make this exact mistake; however, I must've been in a hurry when I wrote the LCD initialization function and just declared it in there, not as a global constant, and re-used the same PIN for my button I/O.
    My friends sometimes shake their heads when I warn them about "magic numbers" in code -- they will sneak up and bite you hard. 
Sign In or Register to comment.