Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deadband #126

Open
mrx23dot opened this issue Nov 2, 2022 · 1 comment
Open

Add deadband #126

mrx23dot opened this issue Nov 2, 2022 · 1 comment

Comments

@mrx23dot
Copy link

mrx23dot commented Nov 2, 2022

Create a dual-sided deadband around the desired setpoint to prevent noisy feedback from producing control jitters
This is disabled by setting deadband to zero, something like:

if (Math.Abs(error) <= DEADBAND)
{
  error = 0;
  if (target == 0)
    output = 0;
} 
else
  output = ((Kp * error) + (Ki * integral))/Ko;
 

could be inserted somewhere here

bool PID::Compute()
{
  const bool outofDeadband = (error > deadband) || (error < -deadband);

   if(!inAuto || !outDeadband) return false;
@drf5n
Copy link

drf5n commented Mar 11, 2023

Other solutions are that you could filter the noise out of your sensor, tune your parameters to be less sensitive to noise, or you could even apply this procedure in user space before your compute step:

if (Math.Abs(SetPoint - Input) <= DEADBAND){
   Input = Setpoint;
}
myPID.Compute();

... and then it wouldn't add the compute costs into the calculations for others.

I do think this filter would interfere with the ability of the integral term being able to adjust the process to within DEADBAND of the Setpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants