0 Members and 1 Guest are viewing this topic.
void interrupt(){ if(PIR1.TMR1IF==1){ // every 0.52 seconds the PID O/P is calculated ERR_P1 = ERR_P2; // get previous position error ERR_P2 = SET_P - POS; // calculate present position error ERR_AC = ERR_AC + ERR_P2; // calculate accumilated error PID_P = (float)Kp*ERR_P2 + (float)Ki*ERR_AC*0.52 + (float)Kd*(ERR_P2-ERR_P1)/(0.52); PIR1.TMR1IF = 0; }}