View unanswered posts | View active topics It is currently Wed Jul 23, 2014 12:47 pm






Reply to topic  [ 2 posts ] 
threshold values 
Author Message
Rookie

Joined: Thu Jun 27, 2013 9:25 pm
Posts: 4
Post threshold values
What are the threshold values for the curriculum companion virtual world? I've looked in the sample programs and can't find it.


Sun Jul 07, 2013 3:40 pm
Profile
Moderator
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 170
Post Re: threshold values
Here you go. This is the Line Track for Distance sample program. The threshold is 45

Code:
#pragma config(Sensor, S1,     touchSensor,              sensorTouch)
#pragma config(Sensor, S2,     compassSensor,            sensorVirtualCompass)
#pragma config(Sensor, S3,     lightSensor,              sensorLightActive)
#pragma config(Sensor, S4,     sonarSensor,              sensorSONAR)
#pragma config(Motor,  motorA,          gripperMotor,       tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorB,          rightMotor,         tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  motorC,          leftMotor,          tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Line Track for Distance
This program uses 1 NXT Line Follower Sensor to track a black line on a light(er) surface
for 5 rotations of the encoders. There is a two second pause at the beginning of the program.

The threshold variable defined in this program may need to be changed for the line/surface your
robot is tracking and the lighting conditions.

Robot Model(s): NXT REMBOT

[I/O Port]          [Name]              [Type]                [Description]
Motor Port 2        rightMotor          NXT Motor             Right side motor
Motor Port 3        leftMotor           NXT Motor             Left side motor
Sensor Port S3      lightSensor         NXT Line Follower     Front-center, facing down

----------------------------------------------------------------------------------------------------*/

//+++++++++++++++++++++++++++++++++++++++++++++| MAIN |+++++++++++++++++++++++++++++++++++++++++++++++
task main()
{
  wait1Msec(2000);          // The program waits for 2000 milliseconds before continuing.

  int threshold = 45;       /* found by taking a reading on both DARK and LIGHT    */
                            /* surfaces, adding them together, then dividing by 2. */

  nMotorEncoder[rightMotor] = 0;  // Reset the right motor encoder to 0.

  //Line Track for 5 rotations...
  while(nMotorEncoder(rightMotor) < 1800)
  {
    // sensor sees light:
    if(SensorValue(lightSensor) < threshold)
    {
      // counter-steer left:
      motor[leftMotor]  = 55;
      motor[rightMotor] = 25;
    }
    // sensor sees dark:
    else
    {
      // counter-steer right:
      motor[leftMotor]  = 25;
      motor[rightMotor] = 55;
    }
  }
}


Sun Jul 07, 2013 3:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.