Shop OBEX P1 Docs P2 Docs Learn Events
Stamp Standalone Terminal Program — Parallax Forums

Stamp Standalone Terminal Program

RobomasterRobomaster Posts: 8
edited 2009-04-03 22:13 in BASIC Stamp
I am trying to make a simple stamp standalone terminal program. I am using the stamp to control a serial I/O board that allows me to have 16 input or outputs and also allows me to read an a 8-bit A/D chip. I am going to use the same serial port that is used for programming to using HyperTerminal to send and receive commands to the stamp.
I have set up a simple command structure using debugin and debug commands.
·
The problem I an have is no matter which command I select it always goes to the first command I have
set up and once I am in it I am unable to exit form it.
Can anyone see what I did wrong?
·
·



' {$STAMP BS2}
' {$PBASIC 2.5}
' Terminal-1.BS2

N96N·· CON $4054···· ' Set 9600 baud, inverted, no parity.
N24N·· CON $418d···· ' Set 2400 baud, inverted, no parity.
Heart· CON· 15······ ' Heart Beat LED on Pin 15
ADCValue VAR Byte···· ' Store ADC result in this byte.
count1· VAR Byte
Maxtime CON 1······ ' Allow this many milliseconds for reply.
comPin CON 0······· ' Connect this pin of BS2 to Stretcher "S" pin.
count1 = 1
pntr = 0 ' reset
addr VAR Word
char VAR Byte

'
[noparse][[/noparse] Constants ]
Yes CON 1
No CON 0
'
[noparse][[/noparse] Variables ]
pntr VAR Byte ' table pointer
pattern VAR Byte ' pattern from table
done VAR pattern.BIT7 ' done marker bit
delay VAR Word ' for timing
addr = Table
command VAR·· Nib
dummyvar VAR· Bit
error1 VAR Nib
mycount VAR Word
SEROUT comPin,N96N,[noparse][[/noparse]"***"]··· ' Reset the Stretcher.
SEROUT comPin,N96N,[noparse][[/noparse]"DB",%11111111,%11111111]··· ' Set all Pins to Output.
SEROUT comPin,N96N,[noparse][[/noparse]"WL",0]··· ' Counter1 output to Lower Port.
SEROUT comPin,N96N,[noparse][[/noparse]"WH",0]··· ' Counter1 output to Lower Port.
'
[noparse][[/noparse] Version Start Up
version:
DEBUG " Version 0,01 beta",CR
DEBUG " Board 1 I /O System",CR
DEBUG " Welcome to· Input Output System",CR
'

'
[noparse][[/noparse] Commands ]
commands:
DEBUG "=====================================================",CR
DEBUG "1 - Make Ports Cycle",CR
DEBUG "2 - Read A/D Port",CR
DEBUG "3 - Help ",CR
DEBUG "4 - Clear Screen",CR
'
[noparse][[/noparse]Execute or Process Commands]
CMD:
DEBUGIN command
IF command = "1" THEN counter:
IF command = "2" THEN AD:
IF command = "3" THEN help:
IF command = "4" THEN clear:
'
again:

counter:
DEBUG CLS
lp: GOSUB Pat
GOSUB out
GOTO lp
Pat:
· LOOP1: READ addr, char
IF char = 9 THEN EXIT1
PAUSE 100
SEROUT comPin,N96N,[noparse][[/noparse]"WL",char]
SEROUT comPin,N96N,[noparse][[/noparse]"WH",char]
addr = addr + 1
·PAUSE 100
·GOTO LOOP1
out:
DEBUGIN command
TOGGLE Heart
PAUSE 100
IF command = "5" THEN commands
PAUSE 100
TOGGLE Heart
RETURN
·EXIT1:
·addr =0
·GOTO again
AD:
PAUSE 60
DEBUG " This is A/D Progam Section"
PAUSE 60
GOTO CMD
help:
RETURN
clear:
RETURN
error:········································· ' Serin timeout occurred: show error
DEBUG "Timeout",CR······················ ' Display "Timeout" on PC debug screen.
GOTO again
'

[noparse][[/noparse] DATA Data ]
·Table DATA 1,2,4,8,16,32,64,128·· ' UP
·DATA 128,64,32,16,8,4,2,1,0,0,9····' DOWN

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tim J Lewis

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-04-01 21:33
    You need to use GOSUB if you expect to return to your main loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • RobomasterRobomaster Posts: 8
    edited 2009-04-02 17:46
    I have updated the code to work using HyperTerminal program, but I am having some problem with it. It is echoing the command number on the screen and I have the echoing turned off. Most of the commands work, but the cycle the pins command only cycles once and the returns to the command menu. I have code in there to make do it from 1 to 100 but it seems it is not getting this part of the code. I don’t see what I am doing wrong.
    Below is a snippet of the code.
    ·
    ·
    Cycle: DEBUG CLS
    ·DEBUG " Making The Pins Cycle ",CR
    ·PAUSE 2000
    ·TOGGLE Heart
    ·GOSUB cyclepin
    ·PAUSE 2000
    ·DEBUG "Cycling Pins Done "
    ·TOGGLE Heart
    ·GOTO commands
    ·
    The Subroutines
    ·
    cyclepin:
    L1: TOGGLE Heart
    ·FOR count1 = 1 TO 100
    ·GOSUB Pat:
    ·NEXT
    ·GOTO L1:
    ·RETURN
    ·
    Pat:
    · LOOP1: READ addr, char
    IF char = 9 THEN EXIT1
    PAUSE 60
    SEROUT comPin,N96N,[noparse][[/noparse]"WL",char]
    SEROUT comPin,N96N,[noparse][[/noparse]"WH",char]
    addr = addr + 1
    GOTO LOOP1
    RETURN
    ·
    ·
    ·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tim J Lewis
  • FranklinFranklin Posts: 4,747
    edited 2009-04-03 01:22
    I'm not sure you can have a goto inside a gosub and have it return correctly, I could be wrong though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • RobomasterRobomaster Posts: 8
    edited 2009-04-03 03:16
    I got the code working using the editor terminal window, but I can't get it to except any input when
    using windows have Hyper Terminal program. I am attaching the current code. Does anyone have any
    ideas.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tim J Lewis
  • RobomasterRobomaster Posts: 8
    edited 2009-04-03 04:58
    I found the problem I had my Hyperterminal settings setup wrong. It now works with Hyperterminal .

    I am still seeing the command variable being displayed on the screen. Is there any way to stop this from being seen on the screen?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tim J Lewis
  • Craig EidCraig Eid Posts: 106
    edited 2009-04-03 22:13
    Tim,

    The DEBUG command utilizes the BASIC Stamp onboard line driver for serial communication and echoes the commands because the Tx and Rx lines share the same pin. You can·eliminate the echo by using SERIN and SEROUT and trapping the echoed commands in your Windows-based software application·or by using two I/O pins and an·RS232 line driver. Click on the link below to view a thread on RS232 interface circuits - http://forums.parallax.com/showthread.php?p=640507.





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ························ Craig Eid


    ··········· Triad Research and Development
    Electical Engineering Design and Consulting Services

    ··················· www.TriadRD.com

    Post Edited (Craig Eid) : 4/3/2009 10:23:15 PM GMT
Sign In or Register to comment.