Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Best way for "servo" from motor & potentiometer? (http://www.chiefdelphi.com/forums/showthread.php?t=80499)

NinJA999 18-01-2010 13:54

Best way for "servo" from motor & potentiometer?
 
This year one of our structures on the robot will need precise control over a motor's positioning. We'd like to hook up a potentiometer to the motor and use it like a really high powered servo (an encoder would be another option; however that offers relative rather than absolute positioning). What would the best way to code this be? Should I create a new class which uses a Jaguar and an AnalogChannel and does some fancy PID routines to provide accurate positioning? Am I missing a something in the library which already does this or something similar? (I'm not talking about the built in Servo class -- that's meant for servos connected to the digital sidecar) Any ideas/input would be helpful! Thanks!

Jared Russell 18-01-2010 14:12

Re: Best way for "servo" from motor & potentiometer?
 
Probably the easiest thing to do would be to make a PIDController object with the PIDSource set to the analog input corresponding to the potentiometer, and the PIDOutput set to the Jaguar/Victor controlling the arm.

Look at the documentation for PIDController to see exactly how to do this.

NinJA999 18-01-2010 14:50

Re: Best way for "servo" from motor & potentiometer?
 
Do I need to have a tightly controlled time loop to use the PIDController? What's the best way to do that?

Jared Russell 18-01-2010 14:54

Re: Best way for "servo" from motor & potentiometer?
 
The WPILib implementation of PIDController actually does all of its processing in a separate thread in the background - you just tell it to start (and stop), and where to go to, and it does the rest.

NinJA999 18-01-2010 16:14

Re: Best way for "servo" from motor & potentiometer?
 
Nice, thanks so much for your help!


All times are GMT -5. The time now is 09:40.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi