|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Off Season Programming Question: Switch Statements
Have you checked what value is being returned from the sensor? Perhaps it's close enough to the actual value that the applied drive speed is within the deadband of the controller, but the sensor value is not within 0.5.
|
|
#2
|
|||
|
|||
|
Re: Off Season Programming Question: Switch Statements
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.
|
|
#3
|
|||||
|
|||||
|
Re: Off Season Programming Question: Switch Statements
Quote:
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. Last edited by GeeTwo : 11-25-2015 at 03:47 PM. |
|
#4
|
|||
|
|||
|
Re: Off Season Programming Question: Switch Statements
That fixed it! Thanks for the help one last question. Shouldn't the input to .SetAbsoluteTolerance() be something like .4 instead of 4? I thought in the code it converted it to a percentage.
|
|
#5
|
|||||
|
|||||
|
Re: Off Season Programming Question: Switch Statements
SetAbsoluteTolerance() bypasses the percentage calculation, so that you specify the tolerance directly in terms of sensor output. SetTolerance() and SetPercentTolerance() are functionally equivalent and set the tolerance to a percentage of the range specified in the latest call to SetOutputRange(). Since you never called SetOutputRange, my reading of the source code makes me believe that these default to zero, so SetTolerance() will always produce a zero tolerance if SetOutputRange() has not been called.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|