View Single Post
  #6   Spotlight this post!  
Unread 09-02-2016, 12:38
geniusadam69 geniusadam69 is offline
Registered User
FRC #5923
 
Join Date: Feb 2016
Location: Houston, TX
Posts: 5
geniusadam69 is an unknown quantity at this point
Re: Running Two Simultaneous PID Loops

Quote:
Originally Posted by Tominator368 View Post
  1. Create a PIDController object, handing it the proper P,I, and D values, as well as instances of the following two classes:
  2. Create a class extending PIDSource and hand it the value of the controller in PIDget()
  3. Create a class extending PIDOutput and have it change some value inside of PIDWrite()
  4. Use the output of the controllers as needed
I just want to address items 2 and 3 of this. If you do decide to go your own route. The PIDSource and PIDoutput are small classes that need to be extended. The controller will send the output to the PIDOutput. It will call the PIDWrite(), and so you would presumably use this to write to the motors.

The PIDSource is a bit trickier. The pidGet() method should just return the sensor data. All in all they're both just wrappers of data that allow the PIDController class a fixed class to interact with. You may also want to just consider anonymous classes. They simplify your overall project structure.
Reply With Quote