Pages: [1]   Go Down
Author Topic: QTR 8RC White line detection  (Read 808 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using a qtr8-rc sensor array on a line following robot, When I use it on a black line on a white surface it works but when i try to use it on a black surface with white line i can't get correct results, i have extracted the following code from my robot to test it separately but no matter what i do i can not get it to detect white line on a black surface...

Code:
#include "PololuQTRSensors.h"

PololuQTRSensorsRC qtr;

void setup(){
  Serial.begin(9600);
  qtr.init((unsigned char[]) {2,3,4,5,6,7,9}, 7);

  int i;  
  for (i = 0; i < 250; i++){  // make the calibration take about 5 seconds  
    qtr.calibrate(QTR_EMITTERS_ON);
    delay(20);
  }
}

void loop(){

  unsigned int val[7];
  qtr.readCalibrated(val);
  int line = qtr.readLine(val,QTR_EMITTERS_ON,true);

  Serial.print(line);
  Serial.print(" R< ");
  Serial.print(val[0]); Serial.print(" ");
  Serial.print(val[1]); Serial.print(" ");
  Serial.print(val[2]); Serial.print(" ");
  Serial.print(val[3]); Serial.print(" ");
  Serial.print(val[4]); Serial.print(" ");
  Serial.print(val[5]); Serial.print(" ");
  Serial.print(val[6]); Serial.print(" ");
  Serial.print(val[7]); Serial.print(" ");
  Serial.println(" >L ");

}

Some sample reading I am getting,

Code:
3200 R< 553 473 397 113 120 533 304 104  >L
3432 R< 567 514 474 113 120 393 82 104  >L
3494 R< 572 625 544 94 100 487 69 104  >L
3418 R< 543 421 506 88 93 305 64 104  >L
3407 R< 529 403 487 69 73 290 50 104  >L
3403 R< 524 397 480 62 67 284 46 104  >L
3506 R< 538 561 474 37 40 264 27 104  >L
3503 R< 538 543 455 18 20 248 13 104  >L
3519 R< 558 567 474 44 46 269 32 104  >L
3537 R< 577 590 500 69 73 290 50 104  >L
3545 R< 577 614 532 94 100 310 69 104  >L
3466 R< 611 497 397 94 100 310 69 104  >L
3534 R< 572 584 500 62 67 284 46 104  >L
3534 R< 572 584 500 62 67 284 46 104  >L

All numbers are way too close so readLine does not return a correct position.  One of the pins on my arduino does not work so I skipped connecting one of the sensors(sensor 7)
Logged

Pages: [1]   Go Up
Jump to: