Shop OBEX P1 Docs P2 Docs Learn Events
Is there anyway to display text on serial display while running servo? — Parallax Forums

Is there anyway to display text on serial display while running servo?

hmillerhmiller Posts: 17
edited 2011-07-09 20:38 in BASIC Stamp
Hi,

I want to know if there is any way to display text on a backlit display (#27977), while running a servo. When I go to run my servo the display goes out and then the display comes back on after the servo is done rotating its cycle. I want it so that my lcd displays text while the servo is running.

Here's my code:


' {$STAMP BS2}
' {$PBASIC 2.5}

DEBUG ? IN1

counter VAR Word


IF IN1 = 0 THEN


DEBUG "Vending...", CR

FOR counter = 1 TO 150
PULSOUT 2, 1000
PAUSE 20
NEXT

SEROUT 15, 84, [17, 22]
SEROUT 15, 84, ["vending..."]
SEROUT 15, 84, [12]

SEROUT 15,84, ["Thank you!"]
DEBUG "Thank you!", CR

SEROUT 15, 84, [12]

ENDIF

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-08 20:53
    As shown on page 3 of the LCD documentation, you should put a HIGH 15 in your initialization code. Most important, remember that transmitting the 12 to the display will clear it (read the documentation for the various control codes).

    In the code you've posted, it only executes once. Is that what you want? There's nothing written to the LCD before you do the servo movement. You'll get the servo movement, then the "vending.." message, the display will clear, then "Thank you!", then the display will clear again and the Stamp will stop.
  • hmillerhmiller Posts: 17
    edited 2011-07-08 21:27
    ok, but what does the HIGH 15 command do and is there a way to center the text on the display?
  • ercoerco Posts: 20,256
    edited 2011-07-09 16:15
    Sending text to the LCD using serout is a very quick operation compared to driving a servo. You may want to display "vending" before driving your servo, then pause a second or two before sending "thank you". With your current program, you'll probably never see "vending" displayed before it gets cleared and overwritten by "thank you".
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-09 17:08
    The HIGH 15 sets the output pin used for the SEROUT to be at a default high (1) level. That's the normal resting (idle) state of a serial line.

    The LCD documentation shows how to position the cursor to a specific position. You'll have to center data by yourself by figuring out how many characters you plan to display on a line, subtracting that from the size of the LCD and dividing that in half to get the starting column number.
  • hmillerhmiller Posts: 17
    edited 2011-07-09 20:03
    and another question... what does the 84 after my pin number mean ( I only put it in there because the example book put it in all of theirs) and I can't find the code on the display code sheet I printed out.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-07-09 20:36
    84 is the Baud rate.
    '
    Take a look in the Basic Stamp Syntax manual for the different Baud rates.The values very from one Stamp family to another.
    '
    http://www.parallax.com/Store/Books/BASICStamp/tabid/168/CategoryID/42/List/0/SortField/0/Level/a/ProductID/143/Default.aspx
    '
    A free download (pdf)
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2011-07-09 20:38
    The 84 is baudmode. This number detemines the serial timing and configuration and varies for different stamps.
    Check the table 5.107 on page 419 of the basic stamp manual.

    An 84 is the baud mode for 9600 bps, 8 bit, no parity, True (non-inverted) configuration for a BS2.
Sign In or Register to comment.