Go to Post Things go wrong; it happens to the best of us. You learn from it and move on. - Waynep [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 22 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 22-02-2011, 07:38
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Java CANJaguar PID Issues

We are trying to do position control with a CANJaguar and a potentiometer. If we enable the motor with PID control, and try to set the PIDs to 0.0, 0.0, 0.0, they don't change. A .getP() returns the last higher value etc.

More problematic, if we setup and enable the PID loop in init(), then select teleop or autonomous and enable then the motor will move. Always. If we do not enable the motor in init(), don't define it yet, but do so in teleop, then the motor does not move the first time. But if we disable, then reenable teleop the motor moves. Similarly if we then go to auto the motor moves. Since we want to enable and use the position control in auto, we run the risk of the motors moving when we go from auto to teleop.

We have not found a method to disable the motor once initialized such that we may go into teleop or autonomous without the motor moving. Its as if enabling teleop or auto gives the motor an enable which starts it moving prior to the PID loop taking over.

Disabling (.disable() ) the motor doesn't work as the motor moves when we enable. We have also tried .enable(initialPosition).

Setting the PID values to 0.0, 0.0, 0.0, doesn't take. We print them out and they didn't change. No error generated. The CANJaguar appears to like our initial settings so much it won't let us overwrite them with zeros. Must think we don't know what we're doing.

Any help or ideas would be appreciated. Thanks.
Reply With Quote
  #2   Spotlight this post!  
Unread 22-02-2011, 09:31
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: Java CANJaguar PID Issues

The PID constants being zero will make the motor never move. It will make the output to the motor = error * P + intergral(error) * I + derivative of error * D. If P,I, and D are zero, then the output will also be zero. Try P = .01 and I = .001 or something similar, and see of you get any output.
Reply With Quote
  #3   Spotlight this post!  
Unread 22-02-2011, 18:23
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Java CANJaguar PID Issues

Setting PID to 0.01, 0.001, 0.0 does not work. The motor moves when going into Teleop and into Autonomous.

Coming out of Teleop does not run code that we can find so trying to turn motors off while in teleop before teleop is disabled doesn't work.
Reply With Quote
  #4   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
  #5   Spotlight this post!  
Unread 01-03-2011, 21:15
ksanger's Avatar
ksanger ksanger is offline
Registered User
FRC #0211 (MaK)
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Rochester NY
Posts: 62
ksanger is on a distinguished road
Re: Java CANJaguar PID Issues

We would really rather stay in position control and not deal with velocity mode at all. However when we "enable" teleop mode the motors move. When we "enable" autonomous mode the motors move. It appears that the CANJaguars have a glitch such that once initialized during robotInit() as PID position control using a potentiometer; then when one goes to auto or tele mode they are instructed to start up, yet the PID loop is either not initialized or worse yet they start as velocity devices until further initialization is performed. Note we are not starting with a potentiometer position of zero as that is close to the dead zone. Rather we are starting with an input voltage near 0.145 V.

Even this isn't clear though as sometimes the motors move to a greater voltage direction and other times they move to a lower voltage direction. The main common theme is that the speed is the same. Its as if the starting position we give the CANJaguars during init becomes a speed when teleop or autonomous is enabled. Until the CANJaguar realizes that it was programmed as a position device and then it stops moving.

Basically we have been unable to successfully program a CANJaguar as a position device prior to calling teleop or autonomous.

For competition we decided to control the CANJaguar limit inputs using digital I/O such that we may disable the CANJaguars prior to calling Teleop and Autonomous. We have successfully performed this by hardwiring the inputs, however we have not successfully done this programatically. ie the motors still run. There may be a race condition between the motors running and the digital output disabling the CANJaguars by going high.

Our contingency plan is that the hardware will run against a hard stop and crash into itself so it can't go backwards. Hopefully the forward motion won't kill us while crashing backwards into hardware for a short period doesn't burn out the motors or put the potentiometers passed their zero voltage output. (Once the pots go less than zero they read as greater than 0.90 volts and then a position command runs backwards through more hardware to get to the 0.145 volt starting position. Not.)

There must be a reason that a CANJaguar that is programmed for position control with PID inputs of -1400, 500, 0, start to run a motor whenever teleop or autonomous is enabled from the driver station. The pots are not slipping. They are Cherry AN8 360º encoders monitoring a magnetic pickup screwed into a shaft. Repeated moves to two voltage positions (0.145 and 0.5 V) replicate fabulously over and over many times regardless of enabling and disabling. And yet enabling teleop causes the motor to move. Our starting position is 0.145 V. We .disable() the CANJaguar, set the mode to PID position mode, set PID to -1400, 500, 0; set the potentiometer to a 1 turn pot, set the position to 0.145 using .set( 0.145). We don't enable until we get to Teleop. When teleop is called the motors move a while at a slow speed in a random direction then stop. Eventually after enabling the CANJaguars in Teleop and commanding them to 0.145 they go to 0.145 where a .get() returns 0.145.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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