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 / 26948
26947  |  26949
Subject: 
Re: TachoSpeed.nqc
Newsgroups: 
lugnet.robotics
Date: 
Mon, 12 Mar 2007 00:26:15 GMT
Original-From: 
linmix <linmix@gmail.STOPSPAMcom>
Viewed: 
3755 times
  

The problem is almost certainly that your program only runs for about 2 tenths
of a second.  If you want the program to run forward continuously and execute a
special behavior if at some point during the execution of the program the
TachoSpeed of either the left or right motor drops below a certain threshold
then you want the main body of your program to be an infinite while loop which
frequently examines the tachometer speed of the motors and reacts accordingly.

Just wrap your existing code in a while (true) { } loop.

John Hansen

I 've done just that, but the problem I describe persists:
When the TachoSpeed reported by watching the brick is around 57, the
brick doesn't do anything if the response value is set to 62. It does at
66 or 67 but that also makes it impossible to negotiate a slope because
the inclinations also makes the TachoCount value drop and the brick
turns around

The code now looks like this:

//tachospeed.nqc
//
// simple routine which uses the TachoSPeed variable
// in stead of touch sensors to see if the CyberMaster
// has run into anything


#define threshold 62          // change to make more/less sensitive
#define reverse(t) OnRev(OUT_L+OUT_R); Wait(t);
#define clockwise(t) OnRev(OUT_L);OnFwd(OUT_R); Wait(t);
#define c_clockwise(t) OnRev(OUT_R);OnFwd(OUT_L); Wait(t);

task main()
     {
     while (true)
          {
          OnFwd (OUT_L+OUT_R);
          Wait (20);
          if (TachoSpeed(OUT_R) < threshold) //default behaviour
             {
             reverse (50);
             clockwise (30);
             OnFwd (OUT_L+OUT_R);
             }
          if (TachoSpeed(OUT_L) < threshold) // alternate behaviour
             {
             reverse (50);
             c_clockwise (30);
             OnFwd (OUT_L+OUT_R);
             }
          }
     }

Am I right in thinking that if both Tachospeed (OUT_L) and  Tachospeed
(OUT_R) drop below the threshold value the first 'if ' is more likely to
be executed?

regadrs
linmix



Message has 2 Replies:
  Re: TachoSpeed.nqc
 
Doesn't this make more sense. (...) The way it was written you hardly ever checked the TachoSpeed because most of the time was spent in the Wait(20). I assume the Wait is in there to allow the robot to get up to speed before you start checking for a (...) (18 years ago, 12-Mar-07, to lugnet.robotics)
  Re: TachoSpeed.nqc
 
(...) I don't really understand what you mean when you say "the brick doesn't do anything". Can you be more specific? (...) They will both be executed in sequence if at the time the second if statement reads the TachoSpeed setting on OUT_L it (...) (18 years ago, 12-Mar-07, to lugnet.robotics)

Message is in Reply To:
  Re: TachoSpeed.nqc
 
(...) The problem is almost certainly that your program only runs for about 2 tenths of a second. If you want the program to run forward continuously and execute a special behavior if at some point during the execution of the program the TachoSpeed (...) (18 years ago, 11-Mar-07, to lugnet.robotics)

13 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
    

Custom Search

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