Quote:
Originally Posted by tomy
The sensor value being returned is between 495-497. What do you mean the sensor value is not within 0.5? I thought the tolerance of the setpoint was set by pid.SetTolerance(); and that pid.SetOutPutRange(); was the maximum and minimum speed that you wanted the motor to move.
|
IIRC, SetTolerance defines the allowable "plus-or-minus" for onTarget to return true. If your sensor is returning a value smaller than (or perhaps <=) 496.9, onTarget will continue to report false. Expand your tolerance to 2.0 or a bit higher, and this should let you move on.
Edit, I see that Tolerance is a percentage, so your answer must be above 496.5031 to have onTarget return true.
Re-edit: the percentage is a fraction of the range defined in SetInputRange(), which you have never called, so it defaults to zero. I suggest using SetAbsoluteTolerance() with a value of 2.0 or greater.