|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#3
|
|||||
|
|||||
|
Re: PIDController, Counter Class, Speed Controls
There is one common pitfall associated with switching from distance to rate/speed as the process variable.
Consider a position control loop as implemented by WPIlib: Code:
Motor Voltage = Kp*error + Ki*error_sum + Kd*(error-error_last) Now consider what would happen if you implemented the same loop, but switch the "error" units from distance to speed. When you have zero error in a velocity control loop, you do NOT want to command a zero motor speed. That would slow the motor and result in MORE error. Your best bet is probably to command the motor to keep going whatever speed it was at last! There are two ways you can get your velocity controller behaving in this situation: (1) You need to treat P and I as if they were actually D and P, respectively! This makes sense; you are basically taking the time-derivative of position, which is speed, but are still commanding the same quantity (voltage). Hence the meaning of your gains changes to reflect the derivative of the input. (2) You can make a slight tweak to the way the PID output is used. Instead of Code:
Output = ... Code:
Output = Output + ... |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|