Hi Everyone,
I need some help and guide from you about the QTR sensor’s using on 3PI.
Now I’m running the PID follower by 3PI hardware. I can now smooth running by an good enviroment light condition so that we could set the PWM speed even more than 160.
But when I turn to an worse light condition, 3PI can not work correctly any more although I had already use the standard calibration routing.
The appearance is that all the sensor’s value jump from max to min very frequently so that the position will also accordingly not stable any more(sometime 0,sometime 4000)!!!
My question is why it will happen? Because 3PI’s QTR has their own IR emitter,why still will be influence by enviroment light?
Then which I had an investigation on the routing of “PololuQTRSensors::readLine” ,found that it had already include some on/off line condition,can I improve this or how can I improve my 3PI car on poor light condition?
unsigned int PololuQTRSensors::readLine(unsigned int *sensor_values,
unsigned char readMode, unsigned char white_line)
{
unsigned char i, on_line = 0;
unsigned long avg; // this is for the weighted total, which is long
// before division
unsigned int sum; // this is for the denominator which is <= 64000
static int last_value=0; // assume initially that the line is left.
readCalibrated(sensor_values, readMode);
avg = 0;
sum = 0;
for(i=0;i<_numSensors;i++) {
int value = sensor_values[i];
if(white_line)
value = 1000-value;
// keep track of whether we see the line at all
if(value > 200) {
on_line = 1;
}
// only average in values that are above a noise threshold
if(value > 50) {
avg += (long)(value) * (i * 1000);
sum += value;
}
}
if(!on_line)
{
// If it last read to the left of center, return 0.
if(last_value < (_numSensors-1)*1000/2)
return 0;
// If it last read to the right of center, return the max.
else
return (_numSensors-1)*1000;
}
last_value = avg/sum;
return last_value;
}