![]() |
Oscillating Motor - PID Subsystem
Hello CD,
Yet another PID help thread, I apologize, but my team and I were having troubles with implementation of the PID Subsystem to properly work with our elevator lift. Originally we had the lift just stop once it went over a certain setpoint(which worked to some degree) but we now wanted a more accurate and elegant solution. Setup: We have two standard CIM motors as the output, and one encoder as the input. There is no CAN, just PWM and regular victors being used. Issue: -The implementation of the PID Subsystem results in the motor reaching the desired setpoint; however, oscillates when it reaches it. -When the Robot is disabled quickly after the fear that the oscillation will break the elevator, when it is re-enabled it continues the PID command right when enabled without any buttons pressed. When the robot code is re-deployed or reset, this does not happen. Attempted Solutions: -Followed the GearBots Example, seems to have had some success, except for the oscillation. -Lower P constant (I and D have remained at 0). Seems to not work, it has went as low as 0.02. -Change the isFinished() method within the command to instead of detect for onTarget() method to a custom method that implemented our old code of the lift stopping after a certain setpoint. Did not work as well. -Changed Absolute Tolerance and even tried Percent Tolerance, these were set to 200 ticks for the former and 30% for the latter. Still oscillation. The Code: Subsystem Code:
package org.usfirst.frc.team4716.robot.subsystems;Command Code:
package org.usfirst.frc.team4716.robot.commands;Sorry if the post is a bit lengthy, I just wanted to give as much information as possible to reduce the amount of replies to clarify information. |
Re: Oscillating Motor - PID Subsystem
I haven't looked at your details yet, but in general a larger magnitude for D (that is, derivative of the error, or velocity for a mechanical system going for a position) will act like a dashpot/shock absorber and dampen your system.
|
Re: Oscillating Motor - PID Subsystem
Quote:
How would the tuning work if the system has an issue with just a P-closed loop essentially? Would that not continue having error in the sense of a continued oscillation? |
Re: Oscillating Motor - PID Subsystem
Quote:
Quote:
|
Re: Oscillating Motor - PID Subsystem
Quote:
|
Re: Oscillating Motor - PID Subsystem
Quote:
--Gus |
Re: Oscillating Motor - PID Subsystem
Regarding the command continuing to run between the robot being enabled/disabled:
Your command will only finish if the onTarget method returns true. Code:
protected boolean isFinished() {Add something like: Code:
Scheduler.getInstance().removeAll(); |
Re: Oscillating Motor - PID Subsystem
In that case, Gus' suggestion, as well as James worked!
So my solution was as followed: -Added the D value, set it to 1.0 and eventually lowered this value to 0.1 due to the lift "skipping". -Absolute Tolerance was adjusted from 200 to 20, which it finally remained at 50 to keep the lift moving smoothly. -P value was adjusted to 0.05 -Added Robot.elevator.disable(); at end of command Doing all this, I was able to get the lift to stop at a set point, or have it skip once and get to the set point. I'm most likely going to learn common tuning practices;however, I've mostly seen people use the "guess and check" method. |
| All times are GMT -5. The time now is 10:16. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi