Stamp Standalone Terminal Program
Robomaster
Posts: 8
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
using windows have Hyper Terminal program. I am attaching the current code. Does anyone have any
ideas.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tim J Lewis
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
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