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 / 23082
23081  |  23083
Subject: 
Re: why doesn't this work?
Newsgroups: 
lugnet.robotics
Date: 
Tue, 30 Nov 2004 22:03:26 GMT
Viewed: 
1058 times
  
In lugnet.robotics, Steve Hassenplug wrote:

What is the value of inc when you're done?

2000

And, is SENSOR_1 defined as a rotation sensor?  (and active?)

Yes (it shows up fine on the watch graph)

Steve

here's the whole program

#define TRUE 1
#define FALSE 0

int Vvariable;
int Aforward=1;
int speed;
int maxspeed=0;

int timeout=0;
int array[27];

task main()
{

//start speedcontrol;

SetSensor(SENSOR_1, SENSOR_ROTATION); ClearSensor(SENSOR_1);
SelectDisplay(DISPLAY_SENSOR_1);

SetDirection(OUT_A, OUT_REV);
// SetPower(OUT_LOW);
SetOutput(OUT_A, OUT_ON);
Wait(150);
Float(OUT_A);
// SetPower(OUT_FULL);
//cut down speed limit
init();
/* start speedlimiter;

while(true)
{
basic();
} */

    //StopAllTasks();
    }

  void init()
       {
       OnFwd(OUT_A);
       Wait(150);
       Float(OUT_A);
       int oldsensor=SENSOR_1;
       int temp;

       int inc=0;
       while(timeout<2000)
          {
          temp =  SENSOR_1;
          if(temp != oldsensor)
             {
             if(inc<27){array[inc] = timeout;
             }
             timeout=0;
             inc=inc+1;
             oldsensor=temp;
             }
          else
             {timeout++;}
          }
          start checkvar;
       }

  void move(int pvar)
       {

       }


  task speedcontrol()
        {
        int safetyspeed;
        while(TRUE){
        int oldvar=SENSOR_1;
        Wait(1);
        if(Aforward)
           {safetyspeed=SENSOR_1-oldvar;}
        else
           {safetyspeed=oldvar-SENSOR_1;}
        speed=safetyspeed;
        if(speed > maxspeed){maxspeed=speed;}
        SetUserDisplay(speed,0);
        }
        }

    task speedlimiter()
         {
         while(TRUE){
         if(speed > maxspeed/6)
            {
            Float(OUT_A);
            Wait(1);
            SetOutput(OUT_A, OUT_ON);

            }        }
         }



task checkvar()
     {
     int temp=0;
     while(true)
     {
     Vvariable = array[temp];
     Wait(25);
     temp++;
     if(temp<27)temp=0;
     }
     }

void basic()
     {
      int target;
      target = Random(300);
      move(target);
      Wait(500);
     }



Message has 1 Reply:
  Re: why doesn't this work?
 
(...) I think that means for the first 27 times through the loop, the value for SENSOR_1 changes every time. So all the values would be 0 or 1. Instead of storing the timeout, try creating a seperate counter that's incromented each time through the (...) (20 years ago, 30-Nov-04, to lugnet.robotics)

Message is in Reply To:
  Re: why doesn't this work?
 
(...) What is the value of inc when you're done? And, is SENSOR_1 defined as a rotation sensor? (and active?) Steve (20 years ago, 30-Nov-04, to lugnet.robotics)

9 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
19 hours ago
Custom Search

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