Hello everyone, I am trying to program PID algorithm in c++ first.It is like this: output(i)=Kp*error(i)+Ki*delT*(summation from 1 to i)error(i)+Kd/delT*(e(i)-e(i-1)) This is what I wrote: #include<iostream> using namespace std; int main(){ float error,Paction,Daction,Iaction,lastError,delT; float Kp,Ki,Kd,setPoint; float measurement=0,output=0; int i; cout<<"Enter the value of Kp,Ki,Kd,delT:"; cin>>Kp>>Ki>>Kd>>delT; cout<<"Enter the Value of Set Point:"; cin>>setPoint; Iaction=0; lastError=0; for(i=0;i<4;i++){ error=setPoint-measurement; Paction=error*Kp; Iaction+=Ki*delT*error; Daction=Kd*(error-lastError)/delT; output=Paction+Iaction+Daction; lastError=error; measurement=output; } cout<<"Output:"<<output<<endl; return 0; } I am confused.Is it ok? Thanks
Hi, What is PID? Rgds Raj
more info here.... http://arri.uta.edu/acs/ee4314/lectures/RootLocus/pidLL.pdf