View Single Post
  #1   Spotlight this post!  
Unread Yesterday, 09:12
bmfrc bmfrc is offline
Registered User
FRC #5554
 
Join Date: Feb 2017
Location: Israel
Posts: 11
bmfrc is an unknown quantity at this point
Re: PIDController - control speed vs distance - SetSetpoint

Quote:
Originally Posted by gerthworm View Post
In general, a PID algorithm requires that your setpoint ("desired") and actual values be of the same units. If you want to control your motor-powered mechanism to a certain position, use distance for both. If you want to have it rotate at a constant speed, use speed for both.

In Java, this is accomplished by two methods - setSetpoint(), which you already mentioned, and returnPIDInput().

setSetpoint gets called by other classes in your code, when they want to change the operation of the controlled system (ex: set a new speed to the shooter).

The PID class requires that you define the contents of returnPIDInput(). As long as the PID subsystem is running, it will periodically call returnPIDInput() to figure out where it's actually at, and compare that to the most recent value given via setSetpoint().

tl;dr - setSetpoint = Desired, returnPIDInput = Actual, must be same units.

Note that depending on whether you choose to control to a speed or position, the tuning philosophies do tend to change... but that's a broader discussion on the nature of the controlled system...
Thanks for the help!
But how/where do i set the returnPIDInput so when i want to control the speed it will return the rate and when I want to control the distance it will return the distance?
Reply With Quote