Shop OBEX P1 Docs P2 Docs Learn Events
PICAXE CONTROL OF SERIAL LCD - PAUSE COMMAND — Parallax Forums

PICAXE CONTROL OF SERIAL LCD - PAUSE COMMAND

Hello. I purchased a 4 X 20 Parallax LCD serial display for a project. I have no problem sending a serout command to place some text onto the LCD. But if I place a pause command any longer than 2 seconds between additional serout commands, the LCD seems to freeze up. I've tried sending another "high" command to the LCD but to no effect.

Example: HIGH C.3
PAUSE 10
SEROUT C.3, T9600_8, ("SENSORS ON LINE")
PAUSE 2000
SEROUT C.3, T9600_8, (12,22)
PAUSE 75
SEROUT C.3, T9600_8, ("HELLO DAVE")

I'm sending a "high" command on pin c.3 to get this going and it works fine. But if I increase the pause command to 3000 (3 seconds), all I get is the first line (SENSORS ON LINE) followed with a backslash (\). The screen then freezes up.

I should add that I'm sending this data over a 150' line using MAX485 chips. If I hook up the LCD directly to the Picaxe, it works fine.

Any help would be appreciated. Thanks.

Comments

  • It's not the LCD display. It may have something to do with the way you're using the MAX485s or something about the PICAXE's PAUSE or SEROUT statements. We'd need to see a schematic of your setup to advise you on the MAX485s, but we can't help you with the PICAXE stuff.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2017-10-28 17:39
    I'd be inclined to add a pull-up to the receive line on the LCD end. That said, I'm with Mike: let's see the schematic.
  • Thanks guys. I'll first try the pull-up resistor although the receiving MAX485 calls for a pull-down resistor. But I'll add a pull-up on the LCD pin. All other communications (Picaxe to Picaxe) are working fine.
  • Well, tried the pull-up resistor with no change in behavior. I can get several serout commands to work as long as the pause commands are very short. And with a "goto main" command (start over), the lcd again freezes up.
  • There must be some kind of interaction between the PAUSE generated code and the SEROUT generated code when the time is long. What happens when you always use a variable for the PAUSE like:

    temp = 10
    PAUSE temp

    or

    temp = 2000
    PAUSE temp

    where temp is declared as a 16-bit word
  • Thanks, Mike. No luck messing with a pause variable. But I'll keep messing with it...
  • sailgene wrote: »
    Thanks guys. I'll first try the pull-up resistor although the receiving MAX485 calls for a pull-down resistor. But I'll add a pull-up on the LCD pin. All other communications (Picaxe to Picaxe) are working fine.

    Sorry for asking obvious questions:

    Picaxe side:
    -- DE and RE\ tied together and pulled down?
    -- 120-ohm terminator across twisted pair?

    LCD side:
    -- DE and RE\ tied together and pulled up?
    -- pull-up on RO (to LCD)?
    -- 120-ohm terminator across twisted pair?


  • Have you tried adding another PAUSE and then an 'END' or GOTO MAIN after the last 'SEROUT' in the code snippet you posted? Also, have you tried a different (higher or lower) Baud rate with the Serial LCD?

    Looking at other Picaxe serial LCD examples, it seems that typically an 'init' is use dto wait for the LCD to initialize before checking the LCD

    EX:

    INIT: PAUSE 500
    Example: HIGH C.3
    PAUSE 10
    .
    .
    .

    Have you tried pulling out the MAX485 chips and communicating with the LCD directly?

    Could this possibly be a clock or watchdog timer issue with the Picaxe where the Picaxe has gone into some sort of sleep state?

    Sorry, just spit balling.

  • Thanks JonM. Yes, my code includes a 1 second pause for initialization of the LCD, a "Main" procedure to perform the various code instructions and I've tried both an "end" and "goto main" instructions as well as a "do" "loop" attempt. I've also tried all three baud rates.

    The max 485 chips perform fine in my other serial communication such as turning a pin on "high" or even pwm functions. It's just the LCD.

    In another forum, I was asked if the Parallax LCD's interface had some sort of a built-in timeout function? So that if there was a delay in receiving data, the display would simply stop accepting new data. However, it still works great when tied directly to the Picaxe chip.

    So it seems something is being lost in the transmission - perhaps some delay in receiving the first byte, etc.

    But thanks for spit-balling.
  • The only delays required by the LCD are the initialization one on power up (maybe 100mS) and a 5mS delay after a Form Feed ($0C). There's no other timeout.

    Have you tried the RS485 line drivers with a shorter line ... maybe just a few inches?
  • sailgene wrote: »
    In another forum, I was asked if the Parallax LCD's interface had some sort of a built-in timeout function?
    As in the Picaxe forum you posted in, more info regarding the circuit and code would be helpful. If you had a logic analyzer that you can use to observe the signal to the LCD at the end of the line might provide some useful data.

    You also want to ensure the end of the signal path is properly terminated.

    You might already have this info, but here are a couple of links with connect info for the RS485:
    https://maximintegrated.com/en/app-notes/index.mvp/id/3884

    forum.arduino.cc/index.php?topic=363197.0
  • Thanks guys. I'm going to try shortening all of the pause commands. Here is some current code that includes a counter. The counter will stop running anywhere from 2 to 5. And again, with a direct connection to the LCD, it works fine.

    INIT:
    PAUSE 1000 'ALLOW SPLASH SCREEN TO CLEAR
    DISCONNECT
    SETFREQ M8 'IF PROBLEM, CONSIDER CALIBFREQ 2 TO 4

    PAUSE 10
    HIGH C.3 'HIGH TO START ACTION??
    PAUSE 10
    SEROUT C.3, T9600_8, (22) 'CLEAR SCREEN, CURSOR AND TURN ON BACKLIGHT
    PAUSE 75 'ALLOW MINIMUM 5MS AFTER CLEAR SCREEN COMMAND
    SEROUT C.3, T9600_8, (12)
    PAUSE 75
    SEROUT C.3, T9600_8, (17) 'CLEAR SCREEN, CURSOR AND TURN ON BACKLIGHT
    PAUSE 75
    SEROUT C.3, T9600_8, ("SENSORS")
    SEROUT C.3, T9600_8, (" ON")
    SEROUT C.3, T9600_8, (" LINE")
    PAUSE 1000

    MAIN:
    FOR B1 = 1 TO 25
    SEROUT C.3, T9600_8, (12,22)
    PAUSE 75
    SEROUT C.3, T9600_8, ("BATTERY = ")
    PAUSE 75
    SEROUT C.3, T9600_8, ( #B1)
    PAUSE 75
    SEROUT C.3, T9600_8, (13) 'CLEAR SCREEN, CURSOR AND TURN ON BACKLIGHT
    PAUSE 5
    SEROUT C.3, T9600_8, ("HOW")
    SEROUT C.3, T9600_8, (" DO")
    SEROUT C.3, T9600_8, (" YOU")
    SEROUT C.3, T9600_8, (" DO")
    PAUSE 2000
    NEXT B1
    END
  • Just an observation, commands '13', '22', and '17' do not clear the screen. Command '12' will clear the screen and return the cursor to position 0,0.

    Have you tried using the custom character options with the LCD to store items just as "BATTERY =" and such?

    Do you need to turn the display on for each iteration of the MAIN loop?
    "SEROUT C.3, T9600_8, (12,22)"

    LCD Commands are listed in:
    https://parallax.com/sites/default/files/downloads/27979-Parallax-Serial-LCDs-Product-Guide-v3.1.pdf
  • Sorry about the remarks. Too much coping without checking what comments I've made. So the intital 12, 17 and 22 are to clear the screen, clear the cursor and turn on the backlight. With each loop, I had a 12 and 22 when I probably only need the 12. Since then, I've tried it without the 22 but no help. And the 13 is just a carriage return to place the "How do you do" onto the next line. And no, I have not tried using the custom characters yet.

    It seems that if I instruct the Picaxe to do anything but send constant text messages, the LCD seems to time out and stop receiving updates. I've run a "counter" program with the variable showing as it incremented from 1 to 25. It would typically stop around 3 or 4 but then jump to 12 or more as if it stopped reading the incoming data and then restarted reading it.

    So that's the latest. And thanks so much for trying to help me out. Are there any examples of code out there that involve RS232 or RS485 communication along with additional program commands besides text?
  • The only way I can think of to make the display ignore input for a time (other than disabling the RS485 driver) would be the "display off" code (21). A Form Feed (12) only turns off the display for 5mS at most. You do have one of those followed by a "display on" code (22). See what happens if you put a 10mS delay after the Form Feed in the MAIN: loop.
  • Thanks, Mike. I think we're getting somewhere. If I put a "display off" code in after data has been displayed, the LCD seems to work much better. It's still crashing but not as quickly. I understand that turning off the display does not actually clear any text but does it clear any other RAM in the interface that might otherwise be getting overwhelmed?

    If not, I'll keep messing with the pause timing to see if longer "off" cycles improves anything.

    Thanks again. I'm developing a slight case of "hope".
  • Hi

    150 feet!
    How are you getting power to the LCD? ie are you feeding 5v 150 feet? if so maybe you are suffering from IR drop.
    Just a thought.

    Dave
  • Mike GreenMike Green Posts: 23,101
    edited 2017-10-30 18:15
    My understanding is that "display off" just turns off the display itself. The serial interface continues to function normally with any incoming characters or control codes acting normally on the display buffer. When you enable the display with one of the "display on" codes, the display turns on and shows the current buffer contents. Since you're frequently clearing and rewriting the display, only the last data (since the last Form Feed or other display rewrite) actually shows.

    It may be that your Form Feed keeps the display interface busy for 5mS and the "display on" code gets ignored or partially ignored so the following characters' timing is off. Eventually a "display on" code is seen and processed and the display turns on.

    You may have problems with line noise or reflections if you don't have proper termination resistors or if your 5V supply for the RS485 receiver is noisy.
  • Dave, the LCD is separately powered by its own 5 volts at the other end of the RS 485 bus.

    Mike, is there any around the "form feed" command or is 5 ms the minimum amount of time I can use for that function?

    Gene
  • JonnyMacJonnyMac Posts: 9,104
    edited 2017-10-30 21:38
    Mike, is there any around the "form feed" command or is 5 ms the minimum amount of time I can use for that function?
    The "form feed" translates to the LCD's clear command which takes on the order of 1.64ms to complete per standard LCD specifications. With a serial display you should probably give it a little extra time.
  • Well, short of trying the idea of using special characters, I'm about ready to chuck this Parallax LCD. It works fine when connected directly to the chip and I know through experimentation that the Picaxe is running fine. Using the same RS 485 communication, I have great control of all Picaxe functions remotely. It's just the LCD that doesn't want to work.

    But perhaps the LCD is very sensitive to line noise or transmission timing - I don't know. But I'm about out of patience. A few more tries and then I'm purchasing a competitors model and writing a less-than-positive review on this LCD.

    But thanks to everyone for trying to help me out.

    Gene
  • I've used the same LCD before and the 2 x 16 version with the same controller and have never had any problems with it connected to a Basic Stamp. You may just have a bad unit.
  • DrPopDrPop Posts: 227
    edited 2017-11-01 07:37
    sailgene wrote: »
    ...A few more tries and then I'm purchasing a competitors model and writing a less-than-positive review on this LCD...

    Edit:
    Hi Gene, I just re-read your first post where you state:
    "I'm sending this data over a 150' line ... the LCD directly to the Picaxe works fine."

    So if you take out the 150' run, it functions like it should? If that's the case, then it doesn't sound like the LCD itself is at fault like I first thought. Either the picaxe can't push the signal that far, or the noise threshold is too high for the signal to get through.

    As a real world example, even something like HDMI needs a signal booster in the line after a 50 ft. run.

    Definitely try slowing the baud rate as low as it can go like Tom suggests below. We used to have to do that on modems in Alaska when I was a teen because the line noise was so bad. Maybe it will work for this.
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2017-11-01 00:45
    One last thing to try: lower the baud rate. 4x20 goes all the way down to 2400.
    Edit: Not so much As a fix as to get a data point.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2017-11-01 02:34
    This statement...
    It works fine when connected directly to the chip...
    ...suggests that your RS-485 arrangement -- which you seem really hesitant to share -- is the problem. Which makes this statement...
    A few more tries and then I'm purchasing a competitors model and writing a less-than-positive review on this LCD
    ...ridiculous.
    But perhaps the LCD is very sensitive to line noise or transmission timing...
    It's a serial device for crying out loud. If there is line noise, or a problem with the bits going from point A to point B, it's your fault for the junk transmission line between that controller and the display.
  • JonnyMac,

    You are cracking me up, I just blew milk out of my nose while reading your last post on this thread.
  • SOLVED! Hello Gang. It's been awhile but I just wanted to let you know the problem turned out to be a poor soldering job. Pins DE and RE were supposed to be pulled high with a 10K resistor. My circuit board was correctly set up BUT my soldering job missed one of the two pins. Needed a magnifying glass to see the error. So after the fix, communication is working like a charm.

    The crazy part was that I'd get some information which, after locating the fault, is totally surprising. Would have simply expected nothing or at the best, garbled data.

    So anyway, thanks to all of you for trying to help me out.

    BOTTOM%20SIDE%20SCHEMATIC.jpg
    1139 x 497 - 199K
  • ercoerco Posts: 20,256
    edited 2018-02-11 22:55
    sailgene wrote: »
    ... BUT my soldering job missed one of the two pins. Needed a magnifying glass to see the error.

    Welcome to my world! I use (need) reading glasses to solder now, and I keep a 10X loupe handy to check all connections before powerup.

    Recommended for all ages! For just 78 cents, order several, since they do walk off.

    https://www.ebay.com/itm/142581615197

    BTW, glad to hear you solved your problem. It takes a big man to loop back and admit he made the mistake.

    I may try it sometime. :)





  • Thanks for the support. As far as being a "big" man, if I could just lose some weight...
Sign In or Register to comment.