elevator project
Mark_B
Posts: 9
I have finally succeeded in writing my first program in Pbasic...or any other basic for that matter.· It will generate random car calls to test elevators I am working on.· The program seems to work fine, but here is the problem I am having. When I close the debug terminal or close the editor,·the program stops running.· If I hit the reset button it will not start up again.· I emailed tech support and they suggested that maybe the battery I was using was bad, but I am using a 7vdc wall wart rated at 300ma.· Any ideas why the program won't run with the editor closed?·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
' {$STAMP BS2}
' {$PBASIC 2.5}
RandVal VAR Word
OutVal VAR Byte
OutValOld VAR Byte
n VAR Word
n = 500
DIRS = %1111111111111111
'RandVal = 11000···························· 'initialize RandVal
DO
· redo:
· RANDOM RandVal··························· 'generate random number between 0-65535
· DEBUG DEC RandVal, CR···················· 'Print RandVal
· 'PAUSE 2000······························ 'Pause 2 sec
· OutVal = RandVal / 4096·················· 'generate random number between 0-15
· IF OutVal = OutValOld THEN GOTO redo····· 'If old and new random values are the same, try again
· OutValOld = OutVal······················· 'Set old equal to new in this pass
· DEBUG DEC OutVal, CR
· 'PAUSE 2000
· BRANCH OutVal, [noparse][[/noparse]Zero, one, two, three,
· four, five, six, seven, eight, nine,
· ten, eleven, twelve, thirteen, fourteen,
· fifteen]
· zero:
· HIGH 0
· PAUSE n
· LOW 0
· GOTO waitime
· one:
· HIGH 1
· PAUSE n
· LOW 1
· GOTO WaiTime
· two:
· HIGH 2
· PAUSE n
· LOW 2
· GOTO waitime
· three:
· HIGH 3
· PAUSE n
· LOW 3
· GOTO waitime
· four:
· HIGH 4
· PAUSE n
· LOW 4
· GOTO waitime
· five:
· HIGH 5
· PAUSE n
· LOW 5
· GOTO waitime
· six:
· HIGH 6
· PAUSE n
· LOW 6
· GOTO waitime
· seven:
· HIGH 7
· PAUSE n
· LOW 7
· GOTO waitime
· eight:
· HIGH 8
· PAUSE n
· LOW 8
· GOTO waitime
· nine:
· HIGH 9
· PAUSE n
· LOW 9
· GOTO waitime
· ten:
· HIGH 10
· PAUSE n
· LOW 10
· GOTO waitime
· eleven:
· HIGH 11
· PAUSE n
· LOW 11
· GOTO waitime
· twelve:
· HIGH 12
· PAUSE n
· LOW 12
· GOTO waitime
· thirteen:
· HIGH 13
· PAUSE n
· LOW 13
· GOTO waitime
· fourteen:
· HIGH 14
· PAUSE n
· LOW 14
· GOTO waitime
· fifteen:
· HIGH 15
· PAUSE n
· LOW 15
· GOTO waitime
· waitime:
· PAUSE 1000
LOOP
·· Tech Support searched for your e-mail, and we don't seem to have one addressing your problem.· However, the most likely cause of your problem is that you're using a Dell or Gateway Laptop.· These computers take over the port after the Stamp Editor releases it, causing the Stamp Module to be held in a reset state.· You can test this by unplugging the cable form the port and see if the Stamp will respond then.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I am not familiar with programming Stamps on a laptop but after reading your code a suggestion comes to mind. In my own code, if I find myself typing nearly the same thing more than three times the optimize light goes off in my head. You could also save a few calusses if you look at your nearly identical series of branches.
Consider the following:
HIGH outval
PAUSE n
LOW outval
Pause 1000
LOOP
Hope this helps a bit.
Lee