Subject:
|
Re: 3T
|
Newsgroups:
|
lugnet.org.us.laflrc
|
Date:
|
Fri, 3 Mar 2006 18:29:53 GMT
|
Viewed:
|
1847 times
|
| |
| |
In lugnet.org.us.laflrc, Brian Davis wrote:
<snip>
> Warning: I don't know Minscript. Still, since when has that stopped me :) ?
>
> The first thing I don't understand is why you seem to be watching the event
> ("scancomplete") in a tight wait loop ("wait until scancomplete"). In NQC (and
> the basic firmware), there's a special way of monitoring an event that gives
> very prompt (immediate) response. I'm not sure if you are invoking this ability.
I don't know if I'm using the most efficient method either, but from what I have
found... Tasks are run in parallel. If I start a task (the scan task) my main
code will continue to run at the same time. Therefore I have the wait until
scancomplete event to wait until the scan task has finished before moving on.
Events are continuously monitored, so as soon as the condition scandone =1
condition is met, the scancomplete event is fired. I'm not sure if the stop
task command is necessary but it seemed to be a good idea. From the examples I
found in the help, this is the recommended method. Subroutines are not allowed
in programming the rcx in Mindscript.
>
> > Here's my workaround... insert a 1/2 second wait command just
> > before the if B = 0 statement.
>
> But that means for every cell scanned, you've added a 1/2 sec pause. I wish I
> knew the answer to your original question, but at least put the 1/2 sec wait
> after the "set scandone = 1" within the "If A = 1" statement. That way it only
> executes the (time-wasting) pause if it has found a block.
Hmm, this is a great idea, wish I had thought of it.
>
> > when it returns home, the CurX and CurY values have
> > already been reassigned to the location of B (1,2)
>
> Now I'm really confused. In the code fragment you posted, CurX & CurY are
> *immediately* both set to zero if a block is found. Are you talking about some
> other variables?
Yeah, me too, that's why I posted :) Nope, same variables, thus my problem.
About the 3rd line into the if B = 0 portion of the code, the CurX and CurY
variables are set to the NEW coords for area B (I label the 9 areas A through
I). This is the timeline I'm seeing happening.
1. Set CurX and CurY to A position (1,1)
2. Scan area A for block
3. Block is found in A
4. Return to home (0,0) position
5. Set CurX and CurY to home position (0,0)
6. Scandone set to 1-- should fire scancomplete event immediately and scan task
should stop BUT....
7. Scan task continues and starts to do calculations to move to area B and scan
it
8. CurX and CurY are set to new position (1,2) but nothing has moved yet
9. At this point the scan task is ended by the scancomplete event. There was
just enough of a time lag after step 6 and before the scan task was stopped for
the incorrect locations of CurX and CurY to be set for area B.
If I insert this step
6b. wait 1/2 second
Everything works because apparently that is enough time for the code to
recognize the scancomplete event has fired and to quit the scan task before the
process of scanning area B has started.
Make sense? Nope it doesn't to me either ;)
John
|
|
Message is in Reply To:
| | Re: 3T
|
| (...) I ran mine last night at a "family science night" for a school. Big hit, although I *absolutely* need error checking in my code (playing against a robot is easy - playing against a 5-year-old, with a couple of 4-year-olds constantly hitting (...) (19 years ago, 3-Mar-06, to lugnet.org.us.laflrc)
|
9 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|