Skip to content

Commit

Permalink
Fix PID issue, proportional band dissociated from setpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
colinl committed Oct 17, 2019
1 parent 59ee1c8 commit 94aa315
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/ProcessControl/PID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ double PID::tick( unsigned long nowSecs ) {
}
} else {
m_integral = m_integral + error * delta_t/m_t_integral;
// clamp to +- 0.5 prop band widths so that it cannot push the zero power point outside the pb
if ( m_integral < -pbo2 ) {
m_integral = -pbo2;
} else if (m_integral > pbo2) {
m_integral = pbo2;
}
}
}
// clamp to +- 0.5 prop band widths so that it cannot push the zero power point outside the pb
// do this here rather than when integral is updated to allow for the fact that the pb may change dynamically
if ( m_integral < -pbo2 ) {
m_integral = -pbo2;
} else if (m_integral > pbo2) {
m_integral = pbo2;
}
}

} else {
Expand Down

0 comments on commit 94aa315

Please sign in to comment.