Fix #34: Broken PID derivate term calculation. Sign error fixed
This commit is contained in:
		@@ -85,7 +85,7 @@ float pid_sample(struct pid_controller *pid, float deviation)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Calculate derivative part */
 | 
						/* Calculate derivative part */
 | 
				
			||||||
	pid->derivate = pid->k_deriv_t * (deviation - pid->last_in) -  pid->k_inv_deriv_t * pid->derivate;
 | 
						pid->derivate = pid->k_deriv_t * (deviation - pid->last_in) + pid->k_inv_deriv_t * pid->derivate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	output += pid->derivate;
 | 
						output += pid->derivate;
 | 
				
			||||||
	output += pid->integral;
 | 
						output += pid->integral;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user