Merge a30df926fd
into 9b4ca0e5b6
This commit is contained in:
commit
01cdd6434c
@ -130,6 +130,8 @@ void PID::SetTunings(double Kp, double Ki, double Kd){
|
|||||||
|
|
||||||
/* SetSampleTime(...) *********************************************************
|
/* SetSampleTime(...) *********************************************************
|
||||||
* sets the period, in Milliseconds, at which the calculation is performed
|
* sets the period, in Milliseconds, at which the calculation is performed
|
||||||
|
* 15 May 2021 gfp - a value of zero will force Compute() to generate a new output every time it is called
|
||||||
|
* but avoids the 'divide-by-zero' problem
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
void PID::SetSampleTime(int NewSampleTime)
|
void PID::SetSampleTime(int NewSampleTime)
|
||||||
{
|
{
|
||||||
@ -139,7 +141,11 @@ void PID::SetSampleTime(int NewSampleTime)
|
|||||||
/ (double)SampleTime;
|
/ (double)SampleTime;
|
||||||
ki *= ratio;
|
ki *= ratio;
|
||||||
kd /= ratio;
|
kd /= ratio;
|
||||||
SampleTime = (unsigned long)NewSampleTime;
|
//SampleTime = (unsigned long)NewSampleTime;
|
||||||
|
}
|
||||||
|
else if (NewSampleTime == 0)
|
||||||
|
{
|
||||||
|
SampleTime = (unsigned long)NewSampleTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,3 +9,7 @@
|
|||||||
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
|
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
|
||||||
|
|
||||||
- For function documentation see: http://playground.arduino.cc/Code/PIDLibrary
|
- For function documentation see: http://playground.arduino.cc/Code/PIDLibrary
|
||||||
|
|
||||||
|
- To synchronize PID::Compute with an external timing source such as a TIMER ISR,
|
||||||
|
call SetSampleTime() with an argument of zero. This will force Compute to generate a
|
||||||
|
new output value each time it is called.
|
||||||
|
Loading…
Reference in New Issue
Block a user