View unanswered posts | View active topics It is currently Mon Sep 01, 2014 10:06 pm






Reply to topic  [ 2 posts ] 
Line Following.. 
Author Message
Rookie

Joined: Wed Mar 09, 2011 7:35 pm
Posts: 6
Post Line Following..
Code:
task main()
{
#pragma config(Sensor, in1,    lineFollowerRIGHT,   sensorLineFollower)
#pragma config(Sensor, in2,    lineFollowerCENTER,  sensorLineFollower)
#pragma config(Sensor, in3,    lineFollowerLEFT,    sensorLineFollower)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)


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

  int threshold = 505;      /* found by taking a reading on both DARK and LIGHT    */
                            /* surfaces, adding them together, then dividing by 2. */
  while(true)
  {
   
    // RIGHT sensor sees dark:
    if(SensorValue(lineFollowerRIGHT) > threshold)
    {
      // counter-steer right:
      motor[leftMotor]  = 63;
      motor[rightMotor] = 0;
    }
    // CENTER sensor sees dark:
    if(SensorValue(lineFollowerCENTER) > threshold)
    {
      // go straight
      motor[leftMotor]  = 63;
      motor[rightMotor] = 63;
    }
    // LEFT sensor sees dark:
    if(SensorValue(lineFollowerLEFT) > threshold)
    {
      // counter-steer left:
      motor[leftMotor]  = 0;
      motor[rightMotor] = 63;
    }
  }

I tried using this samle code on the robot, it didn't work, it just went forward, and a slight turn here and there, can anyone help me? I'm using a black line on white paper. My only guess is that the sensors aren't low enough.

Thanks in advance.

_________________
Kyle Johnson
Booker T. Washington's BEST Robotics team.
Tuskegee, Alabama


Fri Mar 11, 2011 2:21 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: Line Following..
Hi Kyle,

The problem may be that the threshold (the value that the robot uses to decide if it's over the black line or the white surface) used in the sample program may not be correct for your lighting environment. Have you calculated your own threshold, using the values from your sensors?

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Mon Mar 21, 2011 8:41 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.