|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Fighting PID
I'm actually in the process of doing that, and just found a strange problem...
I found this in the PIDController class in WPILibJ: Code:
if (((m_totalError + m_error) * m_I < m_maximumOutput)
&& ((m_totalError + m_error) * m_I > m_minimumOutput))
{
m_totalError += m_error;
}
m_result = (m_P * m_error + m_I * m_totalError + m_D * (m_error - m_prevError));
m_prevError = m_error;
|
|
#2
|
||||
|
||||
|
Re: Fighting PID
Quote:
In terms of your original question, even if you used WPI's implementation, your output doesn't have to feed straight into a motor. If you have them as separate outputs, then decide yourself how to feed them into the speed controllers, there shouldn't be any problem. |
|
#3
|
||||
|
||||
|
Re: Fighting PID
We've always written our own PID loops. I have never used the PIDs given to us, I find that if you make you're own you can customize it to what you need. It's not that difficult, I use Labview though.
|
|
#4
|
|||
|
|||
|
Re: Fighting PID
I must say, I'm having a bit of trouble understanding what WPILibJ is doing. I'm trying to use it as a reference, but it's contradicting itself. Another example of something that doesn't make much sense:
Code:
if (m_continuous)
{
if (Math.abs(m_error) > (m_maximumInput - m_minimumInput) / 2)
{
if (m_error > 0)
{
m_error = m_error - m_maximumInput + m_minimumInput;
}
else
{
m_error = m_error + m_maximumInput - m_minimumInput;
}
}
}
Maybe I shouldn't use this as a reference... |
|
#5
|
|||
|
|||
|
Re: Fighting PID
Continuous mode still uses the min and max values, but not as limits--instead, it assumes that the shortest route to the setpoint can be achieved by going past the max back to the min and vice/versa. At least, if the comment on the SetContinuous method is to be believed..
|
|
#6
|
|||
|
|||
|
Re: Fighting PID
Wow, just wrote a lot of code (with no testing in between... this'll end poorly).
Thanks, that makes sense. Since I don't have that, I'm not supporting that feature. It all works out now. |
|
#7
|
||||
|
||||
|
Re: Fighting PID
Quote:
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|