Page 1 of 1

How to write a Time Out, if a wait sensor just keeps waiting

Posted: 22 Sep 2011, 14:52
by terrycary
NXT-G

Flag pole climb and I don't want it getting stuck at the top if the touch sensor misses the cap.

How would you use a timer to change the execution path, or work around it. Any suggestions.
Thanks,
TC

Re: How to write a Time Out, if a wait sensor just keeps waiting

Posted: 22 Sep 2011, 21:36
by ronmcrae
terrycary wrote:How would you use a timer to change the execution path, or work around it.
Have you looked into logic variables in NXT-G? One option would be to define a logic variable. Set it to false at the start, and then make the loop that waits for the end condition exit once that variable becomes true.

You'd then need two separate rungs in your program. One would wait for the touch sensor and, when pressed, set the logic variable to true. The other rung could simply do a long (timeout style) wait and when that completes set the variable to true.

Once either rung sets the variable to true the robot can climb back down the pole (or whatever).

Re: How to write a Time Out, if a wait sensor just keeps waiting

Posted: 23 Sep 2011, 01:02
by terrycary
That works. Thanks. New to this and it's conceptually a little different than anything I've programmed in.
TC

Re: How to write a Time Out, if a wait sensor just keeps waiting

Posted: 23 Sep 2011, 16:16
by ronmcrae
terrycary wrote:New to this and it's conceptually a little different than anything I've programmed in.
So are you being required to use NXT-G for your project? There are a good number of language options and compilers for the NXT brick. This table gives a decent overview of the main programming options, though some entries are a bit out of date these days.