BS1 and a BUTTON problem.
Archiver
Posts: 46,084
Hey there. I'm fairly new to the BS world, but I've run into a
problem I can't solve.
I am using a BS1 to control a relay. At the beginning of my program,
I have the user determine how long the relay should stay open, and
how often it should open up. I have (2) buttons (switches) used for
input. And and LED to let the user know what's going on.
My problem is that when the program begins, the BS runs through my
1st BUTTON command and it's corresponding NOPRESS, skipping input
from the user. But then it gets to the 2nd set of BUTTON/NOPRESS and
waits for user input???? The code is almost identical, and the
hardware the code is using is exactly the same hardware it used on
the 1st BUTTON command. My code is below, help I'm lost.
Thanks in advance,
John
'{STAMP bs1}
Main:
symbol BtnWrk= B1 'Workspace for button #1
symbol BtnWrk1= B2 'Workspace for button #2
symbol UserIn= W1 'User input for desired delay
symbol UserIn2= W4 'User input for desired ontime
symbol Passes= B3 'Number of passes (through RunDrip)
symbol Delay= W2 'The delay between drips
symbol OnTime= W3 'Amount of time to leave solenoid open
'Go get the delay the user wants between drips
GOTO GetDelay
GetDelay:
debug "Entering GetDelay",cr
'Watch sw 1, if you don't get anything, check sw 2
button 2,0,255,250,BtnWrk,0,NoPress ' Go to NoPress unless P0 = 0
UserIn = UserIn + 1
debug UserIn, cr
debug "SW1 Hit (GD)",cr
gosub Blink
NoPress: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress2 ' Go to NoPress2 unless P0 = 0
debug "SW2 Hit (GD)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO GetOnTime
NoPress2: 'We didn't get anything on switch 2 either, back to the top
GOTO GetDelay
GetOnTime:
debug "Entering GetOnTime",cr
button 2,0,255,250,BtnWrk,0,NoPress3 ' Go to NoPress3 unless P0 = 0
UserIn2 = UserIn2 + 1
debug UserIn2, cr
debug "SW1 Hit (gOt)",cr
gosub Blink
NoPress3: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress4 ' Go to NoPress4 unless P0 = 0
debug "SW2 Hit (gOt)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO RunDrip
NoPress4: 'We didn't get anything on switch 2 either, back to the top
GOTO GetOnTime
RunDrip:
debug "Entering Run Drip",cr
'UserIn is the # of presses on SW1 during delay input
'14,400 seconds = 4 hours, this is the smallest interval of delay
'7,200 seconds = 2 hours
'3,600 seconds = 1 hour
'1,800 seconds = 1/2 hour
'UserIn2 is the # of presses on SW1 during OnTime input
Delay = UserIn * 1800
OnTime = UserIn2 * 1000
debug Delay
debug OnTime
Loop:
Passes = Passes + 1
debug Passes
high 4
pause OnTime
low 4
sleep Delay
goto Loop
Blink: 'This sub blinks a LED on pin0 with a short pause at the end
high 0
pause 50
low 0
pause 250
return
problem I can't solve.
I am using a BS1 to control a relay. At the beginning of my program,
I have the user determine how long the relay should stay open, and
how often it should open up. I have (2) buttons (switches) used for
input. And and LED to let the user know what's going on.
My problem is that when the program begins, the BS runs through my
1st BUTTON command and it's corresponding NOPRESS, skipping input
from the user. But then it gets to the 2nd set of BUTTON/NOPRESS and
waits for user input???? The code is almost identical, and the
hardware the code is using is exactly the same hardware it used on
the 1st BUTTON command. My code is below, help I'm lost.
Thanks in advance,
John
'{STAMP bs1}
Main:
symbol BtnWrk= B1 'Workspace for button #1
symbol BtnWrk1= B2 'Workspace for button #2
symbol UserIn= W1 'User input for desired delay
symbol UserIn2= W4 'User input for desired ontime
symbol Passes= B3 'Number of passes (through RunDrip)
symbol Delay= W2 'The delay between drips
symbol OnTime= W3 'Amount of time to leave solenoid open
'Go get the delay the user wants between drips
GOTO GetDelay
GetDelay:
debug "Entering GetDelay",cr
'Watch sw 1, if you don't get anything, check sw 2
button 2,0,255,250,BtnWrk,0,NoPress ' Go to NoPress unless P0 = 0
UserIn = UserIn + 1
debug UserIn, cr
debug "SW1 Hit (GD)",cr
gosub Blink
NoPress: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress2 ' Go to NoPress2 unless P0 = 0
debug "SW2 Hit (GD)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO GetOnTime
NoPress2: 'We didn't get anything on switch 2 either, back to the top
GOTO GetDelay
GetOnTime:
debug "Entering GetOnTime",cr
button 2,0,255,250,BtnWrk,0,NoPress3 ' Go to NoPress3 unless P0 = 0
UserIn2 = UserIn2 + 1
debug UserIn2, cr
debug "SW1 Hit (gOt)",cr
gosub Blink
NoPress3: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress4 ' Go to NoPress4 unless P0 = 0
debug "SW2 Hit (gOt)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO RunDrip
NoPress4: 'We didn't get anything on switch 2 either, back to the top
GOTO GetOnTime
RunDrip:
debug "Entering Run Drip",cr
'UserIn is the # of presses on SW1 during delay input
'14,400 seconds = 4 hours, this is the smallest interval of delay
'7,200 seconds = 2 hours
'3,600 seconds = 1 hour
'1,800 seconds = 1/2 hour
'UserIn2 is the # of presses on SW1 during OnTime input
Delay = UserIn * 1800
OnTime = UserIn2 * 1000
debug Delay
debug OnTime
Loop:
Passes = Passes + 1
debug Passes
high 4
pause OnTime
low 4
sleep Delay
goto Loop
Blink: 'This sub blinks a LED on pin0 with a short pause at the end
high 0
pause 50
low 0
pause 250
return
Comments
in fact the problem was that the Stamp was holding the output high. When
you run program you could try getting a logic reading from pin3 and see if
somehow it is really being held high. You never know it might even be
that the switch is dodgy.
Justin
Original Message
From:
sentto-1327227-14328-999564909-justin=krass.com@returns.onelist.com
[noparse][[/noparse]mailto:sentto-1327227-14328-999564909-justin=krass.com@r....
com]On Behalf Of john@l...
Sent: 04 September 2001 01:55
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] BS1 and a BUTTON problem.
Hey there. I'm fairly new to the BS world, but I've run into a
problem I can't solve.
I am using a BS1 to control a relay. At the beginning of my program,
I have the user determine how long the relay should stay open, and
how often it should open up. I have (2) buttons (switches) used for
input. And and LED to let the user know what's going on.
My problem is that when the program begins, the BS runs through my
1st BUTTON command and it's corresponding NOPRESS, skipping input
from the user. But then it gets to the 2nd set of BUTTON/NOPRESS and
waits for user input???? The code is almost identical, and the
hardware the code is using is exactly the same hardware it used on
the 1st BUTTON command. My code is below, help I'm lost.
Thanks in advance,
John
'{STAMP bs1}
Main:
symbol BtnWrk= B1 'Workspace for button #1
symbol BtnWrk1= B2 'Workspace for button #2
symbol UserIn= W1 'User input for desired delay
symbol UserIn2= W4 'User input for desired ontime
symbol Passes= B3 'Number of passes (through RunDrip)
symbol Delay= W2 'The delay between drips
symbol OnTime= W3 'Amount of time to leave solenoid open
'Go get the delay the user wants between drips
GOTO GetDelay
GetDelay:
debug "Entering GetDelay",cr
'Watch sw 1, if you don't get anything, check sw 2
button 2,0,255,250,BtnWrk,0,NoPress ' Go to NoPress unless P0 = 0
UserIn = UserIn + 1
debug UserIn, cr
debug "SW1 Hit (GD)",cr
gosub Blink
NoPress: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress2 ' Go to NoPress2 unless P0 = 0
debug "SW2 Hit (GD)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO GetOnTime
NoPress2: 'We didn't get anything on switch 2 either, back to the top
GOTO GetDelay
GetOnTime:
debug "Entering GetOnTime",cr
button 2,0,255,250,BtnWrk,0,NoPress3 ' Go to NoPress3 unless P0 = 0
UserIn2 = UserIn2 + 1
debug UserIn2, cr
debug "SW1 Hit (gOt)",cr
gosub Blink
NoPress3: 'We didn't get anything on sw 1, how about sw 2?
button 3,0,255,250,BtnWrk1,0,NoPress4 ' Go to NoPress4 unless P0 = 0
debug "SW2 Hit (gOt)",cr
gosub Blink
gosub Blink
gosub Blink
GOTO RunDrip
NoPress4: 'We didn't get anything on switch 2 either, back to the top
GOTO GetOnTime
RunDrip:
debug "Entering Run Drip",cr
'UserIn is the # of presses on SW1 during delay input
'14,400 seconds = 4 hours, this is the smallest interval of delay
'7,200 seconds = 2 hours
'3,600 seconds = 1 hour
'1,800 seconds = 1/2 hour
'UserIn2 is the # of presses on SW1 during OnTime input
Delay = UserIn * 1800
OnTime = UserIn2 * 1000
debug Delay
debug OnTime
Loop:
Passes = Passes + 1
debug Passes
high 4
pause OnTime
low 4
sleep Delay
goto Loop
Blink: 'This sub blinks a LED on pin0 with a short pause at the end
high 0
pause 50
low 0
pause 250
return
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>Hey there. I'm fairly new to the BS world, but I've run into a
>problem I can't solve.
>
>I am using a BS1 to control a relay. At the beginning of my program,
>I have the user determine how long the relay should stay open, and
>how often it should open up. I have (2) buttons (switches) used for
>input. And and LED to let the user know what's going on.
>
>My problem is that when the program begins, the BS runs through my
>1st BUTTON command and it's corresponding NOPRESS, skipping input
>from the user. But then it gets to the 2nd set of BUTTON/NOPRESS and
>waits for user input???? The code is almost identical, and the
>hardware the code is using is exactly the same hardware it used on
>the 1st BUTTON command. My code is below, help I'm lost.
>
>
>Thanks in advance,
>
>John
Hi John -
BtnWrk and BtnWrk1 need to be cleared to zero before each use.
Hope that gets you going again.
Regards,
Bruce Bates