It appears that the equation for the derivative error (line 62) uses the wrong operator to convert from milliseconds to seconds. The integral error (line 60) uses Seconds (_dT / 1000) as the time unit, but the derivative error uses Microseconds (_dT * 1000).
I think the correct formula would include a pair of brackets as follows in order to keep the units consistent with the integral error:
double _dError = (_error - _previousError) / (_dT / 1000.0); //derivative
In order to use multiplication instead of division, the formula could be rewritten as follows:
double _dError = (_error - _previousError) * 1000.0 / _dT; //derivative
It appears that the equation for the derivative error (line 62) uses the wrong operator to convert from milliseconds to seconds. The integral error (line 60) uses Seconds (_dT / 1000) as the time unit, but the derivative error uses Microseconds (_dT * 1000).
I think the correct formula would include a pair of brackets as follows in order to keep the units consistent with the integral error:
In order to use multiplication instead of division, the formula could be rewritten as follows: