To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 20107
20106  |  20108
Subject: 
Re: Newbie NQC Spybot problems
Newsgroups: 
lugnet.robotics, lugnet.robotics.rcx.nqc
Followup-To: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 21 Jan 2003 18:46:47 GMT
Viewed: 
4889 times
  
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



Message has 1 Reply:
  Re: Newbie NQC Spybot problems
 
"John Hansen" <JohnBinder@aol.com> wrote in message news:H92uu0.Bxz@lugnet.com... (...) codes (...) ordinary (...) in (...) do (...) applies (...) John Many thanks for the quick response. The 'repeat' problem realy had me stumped. Last time I (...) (22 years ago, 21-Jan-03, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Newbie NQC Spybot problems
 
I'm a total newbie so please excuse stupidity! Trying to learn NQC with a Spybot and have problems. Using Bcc 3.3.3.7.1 with NQC 2.5a4 with a Lego Spybot on a Windows XP PC. The following does not obey the repeat for number of times command, the (...) (22 years ago, 21-Jan-03, to lugnet.robotics)

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
    
Active threads in Robotics

 
Contact Recovery Nerd for Speedy USDT / BTC Recovery
22 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR