View Single Post
  #3   Spotlight this post!  
Unread 23-02-2011, 23:02
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Java CANJaguar PID Issues

It sounds like you're wanting to use position control only in autonomous mode, and use percent voltage mode for teleop. If this is correct, make sure that you set the control mode back to percent voltage after you disable position control. When you change back to position control mode, you'll have to reset the PID constants as well. Disabling the PID control of the Jaguar does not take it out of position control mode -- it only disables the output. That is, calling set() or setX() on the Jaguar will still be interpreted as a position command and not a percent voltage command.

At the start of autonomous:
Code:
// Switch to Position control mode
jag.changeControlMode(CANJaguar.ControlMode.kPosition);

// Use the potentiometer as the position reference
jag.setPositionReference(CANJaguar.PositionReference.kPotentiometer);

// Set PID gains
jag.setPID(pValue, iValue, dValue);
During autonomous, you can then set a setpoint with setX() and call enableControl() to turn on PID control.

At the beginning of teleop:
Code:
// Switch to percent voltage mode.
jag.changeControlMode(CANJaguar.ControlMode.kPercentVbus);
You can than use setX() to set a percent voltage output in the range of -1.0 to 1.0.

Hope this helps.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote