Skip to content

Conversation

@madacol
Copy link

@madacol madacol commented Oct 17, 2018

Merged this two ifs:
if(!pOnE) outputSum-= kp * dInput;

if(pOnE) output = kp * error;
else output = 0;

into this one:

if(pOnE) output = kp * error;
else { outputSum -= kp * dInput; output = 0; }

I expect a performance improvement by the if reduction, or am I missing something?

I also separated the derivative computing from the ouputSum merging to add comments to indicate where each parameter is being computed.

Changed this:

      /*Compute Rest of PID Output*/
      output += outputSum - kd * dInput;

into this:

      /*Compute derivative*/
      output -= kd * dInput;
      /*Merge*/
      output += outputSum;

I believe it will compile the same, whether is separated or not. But if you don't like this part I'll remake the PR to remove this.

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

Successfully merging this pull request may close these issues.

1 participant