View Single Post
  #8   Spotlight this post!  
Unread 15-01-2016, 12:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,042
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Application of PID in code/real world

Quote:
Originally Posted by Justin Buist View Post
Here's the crux of simple PID calculation code:
Code:
double error = target-current;
double errorChange = error-lastError;
double correction = Kp*error + Ki*errorSum + Kd*errorChange;
lastError = error;
return correction;
There's a line of code missing: errorSum += error


Reply With Quote