Shop OBEX P1 Docs P2 Docs Learn Events
Code Reset Question SOLVED — Parallax Forums

Code Reset Question SOLVED

ArchiverArchiver Posts: 46,084
edited 2003-10-01 15:46 in General Discussion
Thank you all for your responses.

I've solved my problem for now by making the button Active Low.
I'll use your suggestions at a later time to debug why Active High
wasn't working.

Have a great day!

Scott

--- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
wrote:
> 7 volts is awfully close to the Stamp
> regulation drop-out voltage. Try 7.5 volts,
> or 9 volts.
>
>
> --- In basicstamps@yahoogroups.com, "lcg30339" <smwilkinson@e...>
> wrote:
> > Richard,
> >
> > Great suggestion. My sense and sensibility tells me you are
> > correct. Unfortunately, I'm so new to this I have no idea how
to
> > set it up correctly and therefore prove your hypothesis. Still,
I
> > believe more evidence that you are on to something is probably
the
> > fact that I changed the code to:
> >
> > INIT:
> > INPUT 4
> > LOW 4
> > DEBUG "Start", CR
> >
> > MAIN:
> > PAUSE 100
> > GOSUB CHECK_BUTTON
> > GOTO MAIN
> >
> > CHECK_BUTTON:
> > DEBUG ? IN4
> > RETURN
> >
> > When the button is released INIT: is still re-executed.
> >
> > I'm using the Stamp Stack on a breadboard with a BS2SX chip.
I'm
> > feeding in 7 Volts (From a RadioShack 1.5 - 12 Volt variable
power
> > source) unregulated except via the Stamp Stacks voltage
regulation.
> >
> > Don't laugh. Except for the occasional shock do to mishandling
an
> > extension cord I'm very new to this electrical stuff.
> >
> > Thanks for your feedback. I'll do some research to discover the
> > meaning of what you said and therefore, most likely, the answer
to
> > my problem.
> >
> > Have a great day!
> >
> > Scott
> >
> >
> > --- In basicstamps@yahoogroups.com, "Richard Skinner"
> > <rwskinner@w...> wrote:
> > > Not sure of your hardware setup, but rem out the Goto Unlock
and
> > see if it
> > > works. If it does, then check the circuitry of your output
> > circuit. Are
> > > you drawing too much current, causing the stamp to reset?
Don't
> > know if
> > > this is the case or not, but I did have a problem in the past
> > where I set an
> > > output, pulled too much current and dropped the voltage below
the
> > brownout
> > > setting. Can't remember the specifics, it may have been on a
> > pick. However
> > > if anyone can mess up a hardware project it be me!
> > >
> > >
> > >
Original Message
> > > From: "lcg30339" <smwilkinson@e...>
> > > To: <basicstamps@yahoogroups.com>
> > > Sent: Tuesday, September 30, 2003 7:06 PM
> > > Subject: [noparse][[/noparse]basicstamps] Re: Code Reset Question
> > >
> > >
> > > > Al,
> > > >
> > > > Thanks for the suggestions. I changed all PIN = 0s to PIN <
1s.
> > > > Changed GOTO to RETURN and made it so the conditional
statements
> > > > (IF...) just skipped the body of the current sub instead of
> > > > executing a GOTO. I even commented out the beeper code so
that
> > the
> > > > only pin doing anything special is the button pin. I can't
> > imagine
> > > > that would cause a brown-out. INIT: still gets re-executed
when
> > the
> > > > button is released.
> > > >
> > > > Can you think of anything else I can try?
> > > >
> > > > Thanks again!
> > > >
> > > > Scott
> > > >
> > > > Changed Code Below:
> > > >
> > > > '{$STAMP BS2sx}
> > > > INIT:
> > > > NUMBEEPS VAR Byte
> > > > NUMBEEPS = 0
> > > > LOCK VAR Bit
> > > > LOCK = 0
> > > > INPUT 4
> > > > LOW 4
> > > > DEBUG "Start",CR
> > > > BtnWrk VAR Byte
> > > >
> > > > MAIN:
> > > > PAUSE 100
> > > > GOSUB CHECK_BUTTON
> > > > GOTO MAIN
> > > >
> > > > CHECK_BUTTON:
> > > > DEBUG ? IN4
> > > > '----IF(IN4 = 0) THEN DO_UNLOCK
> > > > IF(IN4 < 1) THEN DO_UNLOCK 'Added to try and prevent
reset
> > > > '----IF(IN4 = 1) THEN DO_BEEP
> > > > IF(IN4 = 1 AND LOCK = 0) THEN DO_BEEP
> > > > RETURN
> > > >
> > > > DO_BEEP:
> > > > DEBUG ? NUMBEEPS, CR
> > > > '----IF(LOCK = 1) THEN MAIN
> > > > IF(LOCK = 1) THEN Skip_Beep 'Added to try and prevent reset
> > > > LOCK = 1
> > > > NUMBEEPS = NUMBEEPS + 1
> > > > I VAR Byte
> > > > FOR I = 1 TO NUMBEEPS
> > > > '----FREQOUT 2,1500,2500
> > > > NEXT
> > > > Skip_Beep:'Added to try and prevent reset
> > > > '----GOTO DO_BEEP
> > > > RETURN 'Added to try and prevent reset
> > > >
> > > > DO_UNLOCK:
> > > > LOCK = 0
> > > > '----GOTO MAIN
> > > > RETURN 'Added to try and prevent reset
> > > >
> > > > --- In basicstamps@yahoogroups.com, "Al Williams" <alw@a...>
> > wrote:
> > > > > Just from a quick glance. You do a GOSUB CHECK_BUTTON.
> However,
> > > > in4 must = 1
> > > > > or 0 (there is a tiny chance you would exactly hit a
> transition
> > > > and miss
> > > > > both tests, but it is a very tiny chance). So you wind up
at
> > > > DO_UNLOCK or
> > > > > DO_BEEP.
> > > > >
> > > > > The problem seems that both of these routines end with
GOTO
> > MAIN
> > > > (or THEN
> > > > > MAIN, in the case of DO_BEEP). So the call stack is just
> > rolling
> > > > over and
> > > > > over. Seems like you should just end with RETURN.
> > > > >
> > > > > However, that may not be your problem. You mention that
your
> > INIT
> > > > code is
> > > > > called again. This could be because of a stack underflow
(but
> I
> > > > think you
> > > > > are overflowing). Or it could be that you are driving
> something
> > > > (the
> > > > > speaker/buzzer maybe?) that is causing the Stamp to "brown
> > out" or
> > > > reset.
> > > > > With motors, for example, it is often necessary to put a
large
> > > > capacitor
> > > > > across the power supply to keep it from browning out. Noise
> > > > coupled to the
> > > > > ATN line can do this too. There are a few articles about
this
> > at
> > > > > http://www.wd5gnr.com/stampfaq.htm.
> > > > >
> > > > > Hope some of that helps.
> > > > >
> > > > > Al Williams
> > > > > AWC
> > > > > *New kits: http://www.al-williams.com/kits.htm
> > > > >
> > > > >
> > > > > >
Original Message
> > > > > > From: Scott Wilkinson [noparse][[/noparse]mailto:smwilkinson@e...]
> > > > > > Sent: Tuesday, September 30, 2003 9:43 AM
> > > > > > To: basicstamps@yahoogroups.com
> > > > > > Subject: [noparse][[/noparse]basicstamps] Code Reset Question
> > > > > >
> > > > > >
> > > > > > Hey Guys,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I'm new to Basic Stamp programming and new to this group
so
> > > > > > please excuse any newbie questions or comments. Rest
> > > > > > assured, I've search the archives for answers before
asking.
> > > > > >
> > > > > >
> > > > > >
> > > > > > I've got a simple test program (Code Below) that detects
a
> > > > > > button press but only one button press per press. What
I'm
> > > > > > trying to do is count the number of times the button is
> > > > > > pressed and store the number in a variable. However,
when
> my
> > > > > > Active High switch is released, following a button
press,
> the
> > > > > > code gets re-initialized (i.e. the INIT: code runs
again)
> and
> > > > > > resets the counter
> > > > > > (NUMBEEPS) to 0. I've tried using the BUTTON command
but
> the
> > > > > > code was reset upon button release using that method as
> well.
> > > > > >
> > > > > >
> > > > > >
> > > > > > THE MEAT OF THE PROBLEM:
> > > > > >
> > > > > > I have an application (with buttons) that will be
displaying
> > > > > > information on an LCD. I don't want to re-initialize
the
> LCD
> > > > > > after each button press.
> > > > > >
> > > > > >
> > > > > >
> > > > > > How can I capture button presses without re-initializing
the
> > > > > > code after the button is released?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Thanks so much for your help!
> > > > > >
> > > > > >
> > > > > >
> > > > > > Scott
> > > > > >
> > > > > >
> > > > > >
> > > > > > '{$STAMP BS2sx}
> > > > > >
> > > > > >
> > > > > >
> > > > > > INIT:
> > > > > >
> > > > > > NUMBEEPS VAR Byte
> > > > > >
> > > > > > NUMBEEPS = 0
> > > > > >
> > > > > > LOCK VAR Bit
> > > > > >
> > > > > > LOCK = 0
> > > > > >
> > > > > > INPUT 4
> > > > > >
> > > > > > LOW 4
> > > > > >
> > > > > > DEBUG "Start",CR
> > > > > >
> > > > > > BtnWrk VAR Byte
> > > > > >
> > > > > >
> > > > > >
> > > > > > MAIN:
> > > > > >
> > > > > > PAUSE 100
> > > > > >
> > > > > > GOSUB CHECK_BUTTON
> > > > > >
> > > > > > '---commented out---BUTTON 3,0,255,255,BtnWrk,1,DO_BEEP
> > > > >
> 'pin,downstate,delay,rate,bytevariable,targetstate,address
> > > > > >
> > > > > > GOTO MAIN
> > > > > >
> > > > > >
> > > > > >
> > > > > > CHECK_BUTTON:
> > > > > >
> > > > > > DEBUG ? IN4
> > > > > >
> > > > > > IF(IN4 = 0) THEN DO_UNLOCK
> > > > > >
> > > > > > IF(IN4 = 1) THEN DO_BEEP
> > > > > >
> > > > > > RETURN
> > > > > >
> > > > > >
> > > > > >
> > > > > > DO_BEEP:
> > > > > >
> > > > > > DEBUG ? NUMBEEPS, CR
> > > > > >
> > > > > > IF(LOCK = 1) THEN MAIN
> > > > > >
> > > > > > LOCK = 1
> > > > > >
> > > > > > NUMBEEPS = NUMBEEPS + 1
> > > > > >
> > > > > > I VAR Byte
> > > > > >
> > > > > > FOR I = 1 TO NUMBEEPS
> > > > > >
> > > > > > FREQOUT 2,1500,2500
> > > > > >
> > > > > > NEXT
> > > > > >
> > > > > > GOTO DO_BEEP
> > > > > >
> > > > > >
> > > > > >
> > > > > > DO_UNLOCK:
> > > > > >
> > > > > > LOCK = 0
> > > > > >
> > > > > > GOTO MAIN
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > [noparse][[/noparse]Non-text portions of this message have been removed]
> > > > > >
> > > > > >
> > > > > >
> > > > > > 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/
> > > >
> > > >
> > > > 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/
> > > >
> > > >
Sign In or Register to comment.