Subject:
|
Re: Newbie NQC Spybot problems
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Tue, 21 Jan 2003 20:30:59 GMT
|
Viewed:
|
5029 times
|
| |
| |
"John Hansen" <JohnBinder@aol.com> wrote in message
news:H92uu0.Bxz@lugnet.com...
> In lugnet.robotics, Philip Thompson writes:
> > The following does not obey the repeat for number of times command, the
> > action in the repeat loop just carries on forever.
>
> This is interesting. When compiled with RCX2 as the target it yields:
>
> 000 pwr ABC, 7 13 07 02 07
> 004 dir ABC, Fwd e1 87
> 006 setv var[47], 3 14 2f 02 03 00
> 011 decvjnl var[47], 30 f3 2f 11 00
> 015 out A, On 21 81
> 017 wait 200 43 02 c8 00
> 021 out A, Off 21 41
> 023 wait 200 43 02 c8 00
> 027 jmpl 11 72 91 00
>
> However, when you compile with Spybot as the target it yields:
>
> 000 pwr ABC, 7 13 07 02 07
> 004 dir ABC, Fwd e1 87
> 006 loops 3 82 02 03
> 009 loopcl 27 92 11 00
> 012 out A, On 21 81
> 014 wait 200 43 02 c8 00
> 018 out A, Off 21 41
> 020 wait 200 43 02 c8 00
> 024 jmpl 9 72 90 00
>
> The byte codes "loops" and "loopcl" are not listed as valid LASM byte codes
> in the Spybot LASM documentation. They are listed in the RCX2 LASM byte
> code documentation, but the documentation says:
>
> "It is recommended not to use this command at all since it relies on
> internal state information which may become corrupted if the program
> flow-of-control changes due to firmware generated events or access control
> revocations. Instead use the DecVarJumpLTZero commands as they use ordinary
> variables that can be manipulated in many other ways for controlled loop
> termination."
>
> It looks like this is a compiler bug (since loops and loopcl are not
> supported by the Spybot and are deprecated for all programmable bricks).
>
> > SetSensor(SENSOR_2,SENSOR_LIGHT);
>
> SetSensor is not supported for the Spybot target. You should use
>
> SetSensorMode(SENSOR_2, SENSOR_MODE_PERCENT);
>
> instead. But for the Spybot the light sensor (SENSOR_2) is preconfigured in
> percent mode anyway so you don't need to set its mode. SENSOR_LIGHT is a
> configuration macro that combines setting a sensor type (which you cannot do
> with the Spybot) and a sensor mode in one operation. The same thing applies
> for SENSOR_TOUCH. See the NQC Guide for details about all this (section
> 3.1). (http://www.baumfamily.org/nqc/beta/NQC_Guide.pdf)
>
> > Am I wrong in thinking that I can use these progs with a Spybot?
> > or am I missing something obvious.
>
> You can use modified versions of these programs with the Spybot. Here's
> something that works with the RCX and Spybot (the Scout light sensor works
> differently so this program would not work with it as written):
>
> #define THRESHOLD 40
>
> task main()
> {
> #if defined(__RCX)
> SetSensor(SENSOR_2,SENSOR_LIGHT);
> #endif
>
> OnFwd(OUT_A+OUT_B);
> while (true)
> {
> if (SENSOR_2 > THRESHOLD)
> {
> OnRev(OUT_B);
> Wait(10);
> until (SENSOR_2 <= THRESHOLD);
> OnFwd(OUT_A+OUT_B);
> }
> }
> }
>
> Hope this helps.
>
> John Hansen
John
Many thanks for the quick response.
The 'repeat' problem realy had me stumped.
Last time I played with robotics was many years back when I had a two
stepper motor trundler umbilicaly connected to an Acorn BBC Model B user
port.
I have a lot of catching up to do.
Have just been trying ScriptEd with Mindscript and
that works fine with the Sybot although I find NQC easier to read and
understand.
Thanks again
Regards
Philip
|
|
Message has 1 Reply: | | Re: Newbie NQC Spybot problems
|
| (...) I highly recommend using BricxCC instead of ScriptEd. The editor will syntax highlight your code. It provides a full-featured editor with undo/redo, keystroke macros, code completion, parameter completion, procedure lists, code explorer, and (...) (22 years ago, 22-Jan-03, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Re: Newbie NQC Spybot problems
|
| (...) This is interesting. When compiled with RCX2 as the target it yields: 000 pwr ABC, 7 13 07 02 07 004 dir ABC, Fwd e1 87 006 setv var[47], 3 14 2f 02 03 00 011 decvjnl var[47], 30 f3 2f 11 00 015 out A, On 21 81 017 wait 200 43 02 c8 00 021 out (...) (22 years ago, 21-Jan-03, to lugnet.robotics, lugnet.robotics.rcx.nqc)
|
4 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|