Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT sytax for displaying a VAR? — Parallax Forums

SEROUT sytax for displaying a VAR?

CismontguyCismontguy Posts: 10
edited 2014-11-16 14:35 in BASIC Stamp
Hello,

I am trying to get my Scott Edwards LCD Backpack display to work with my Basic Stamp 2 program, below . The display is connected to P1 and is working fine. I just do not know how to make it display my counter in the code I have been working on, below. I want the counter of Seconds to be displayed like it does in the debug window of the Stamp programing software. Right now there is a series of ????????????? for where I need help.

'- Relay Controller-subroutine-3-LCD.bs2
'10 minute on 3 minute off timer.

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

DEBUG "Indicates that the program is running"


minutes VAR Word
Seconds VAR Word


FREQOUT 4, 2000, 3000 ' signals that the program is running.

' LCD Serial Backpack (R) for the BASIC Stamp II. It assumes
' Backpack is connected to I/O pin P1 of the Stamp, and
' that it is set for 9600 bps.
' Start by defining constants for the Backpack.

N9600 CON $4054 ' Baudmode-9600 bps inverted.
I CON 254 ' Instruction prefix value.
CLR CON 1 ' LCD clear-screen instruction.
LINE2 CON 192 ' Address of 1st char of 2nd line.
L1_C7 CON 135 ' Address of line 1, character 7.


PAUSE 1000 'pause to give Backpack time to initilize the LCD after power up.
SEROUT 1,n9600,[I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 1,n9600,["BSA Eng. & Design"] ' Print message.
PAUSE 1000
SEROUT 1,n9600,[I,CLR] ' clears screen.
SEROUT 1,n9600,["Power ON"] ' Print message.

DO 'start forever loop
LOW 10 'relay on
HIGH 12 ' Green LED on
LOW 13 'red LED off
DEBUG "Power ON"
FOR minutes = 1 TO 1
FOR seconds = 1 TO 60
DEBUG ? seconds


SEROUT 1,n9600, ???????????????????? 'I want it to display the counter here.


PAUSE 1000 ' pause 1 sec
NEXT
DEBUG ? minutes
NEXT

SEROUT 1,n9600,[I,CLR] ' clears screen.
SEROUT 1,n9600,["Power OFF"] ' Print message.

HIGH 10 'relay on
LOW 12 ' Gren LED on
HIGH 13 'Red LED on
DEBUG "Power OFF"
FOR minutes = 1 TO 1
FOR seconds = 1 TO 60
DEBUG ? seconds
PAUSE 1000 ' pause 1 sec
NEXT
DEBUG ? Minutes
NEXT

LOOP 'repeat forever

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2014-11-09 12:51
    SEROUT 1,n9600,[I, LINE2, "cnt=", DEC2 seconds] 'I want it to display the counter here.
  • CismontguyCismontguy Posts: 10
    edited 2014-11-09 13:46
    Hello Tracy,

    Thanks for the answer.

    I am reading the section SEROUT in the Basic Stamp Manual 2.2 right now. Can you "decipher" for me parts of the command? I want to better understand them.

    SEROUT 1 goes to pin one, OK
    n9600 is the baud rate, OK
    [I, LINE2, "cnt=", DEC2 seconds] I am not sure?

    Cismontguy
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2014-11-09 22:53
    > [I, LINE2, "cnt=", DEC2 seconds] I am not sure?
    Per explanation in the version 2.2 manual, the part inside the square brackets is the outputlist. It can hold the many things that you want to send in sequence over the serial line.
    I is the command prefix, you defined as the constant I CON 254.
    LINE2 is the command to start printing on the second line, CON 192
    "cnt2=" causes the text cnt= to be printed
    DEC2 seconds causes the value of seconds to be printed out with 2 decimal digits, from 00 to 59

    You didn't ask for it to be printed on line 2, but the program does have to tell it where to print.

    Check out resources at Scott Edward's page for the backpack, http://seetron.com/bpk000.html Especially all the app notes available under the "more info" tab.
  • CismontguyCismontguy Posts: 10
    edited 2014-11-10 04:14
    Thanks for the details. I have looked on Scott's web page but my LCD display is from 1998 so I do not think he carries it any more? I will check out the link you posted, just in case.

    Cismontguy
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2014-11-10 08:31
    Regardless, the app notes are pure gold:thumb:.
  • CismontguyCismontguy Posts: 10
    edited 2014-11-16 14:35
    Well I got a little time this afternoon to work on my SEROUT to the Scott Edwards 2 line LCD display. I have the company name displayed on one line and the counter of seconds on the other line of the display. So far so good. Now I need the time to combine this code with the code for my relay timer... Thanks for everyone's help. Cismontguy



    ' {$STAMP BS2}
    ' Program: BPKDEMS2.BS2
    ' This program demonstrates fundamental techniques of driving
    ' BPI-216 serial LCDs in BASIC from the BASIC Stamp II. It assumes
    ' that the BPI-216 is connected to I/O pin P1 of the Stamp, and
    ' that it is set for 9600 bps.
    ' Start by defining some useful constants for the Backpack.

    N9600 CON $4054 ' Baudmode-9600 bps inverted.
    I CON 254 ' Instruction prefix value.
    CLR CON 1 ' LCD clear-screen instruction.

    LINE2 CON 205 ' Assign "LINE2 to 1st position on line 2

    L2_C7 CON 199 ' Address of line 2, character 14


    ' Clear screen in case there's text left from a previous
    ' program. 1-second PAUSE prior to sending any DATA TO the Backpack.
    ' This gives the Backpack time to initialize the LCD after power up.

    PAUSE 1000

    SEROUT 1,n9600,[I,CLR] ' Clear the LCD screen.
    PAUSE 1
    SEROUT 1,n9600,[" BSA Eng. & Design"] ' Prints message.

    ' Positioning the cursor requires sending the instruction prefix (ASCII
    ' 254, assigned the symbol "I") followed by an address.
    ' SEROUT 1,n9600,[I,LINE2,"Count:"] ' Moves to line 2 and prints.
    ' Next printing a label on the
    ' screen and updating some data by positioning the cursor.

    PAUSE 2000 ' Wait 2 secs.
    SEROUT 1,n9600,[I,CLR] ' Clear the LCD screen.
    PAUSE 1
    SEROUT 1,n9600,[" BSA Eng. & Design"] ' Print message.
    SEROUT 1,n9600,[I, L2_C7,"Count:"] ' Prints the label count on line 2 at at position 192.
    Again:
    SEROUT 1,n9600,[I,L2_C7] ' Move to line 2, character 7.
    SEROUT 1,n9600,[I,LINE2, DEC B2," "] ' Print value of b2 followed by 2 spaces.
    B2 = B2+1 ' Increment b2.
    PAUSE 1000 ' Slow the loop down.
    GOTO Again ' Repeat endlessly.
Sign In or Register to comment.