hekike / liquid-pid

PID Controller in NodeJS for liquids (water, beer, etc.). Simulator, Plots and Tests are included.
MIT License
18 stars 5 forks source link

Don't think the Proportional band will ever work correctly #1

Open macinna opened 9 years ago

macinna commented 9 years ago

Upon exiting the code below, this._P will always be set to this._MaxP for non-zero values of this._P. This doesn't make any sense.

this._e = this._Tref - actualTemperature; // Calculate the actual error

// Calculate the P this._P = this._Kp * this._e;

if (this._P) { // <------------------------------ this will always be true for non-zero values of this._P this._P = this._MaxP; } else if (this._P < (-1 * this._MaxP)) { this._P = -1 * this._MaxP; }

hekike commented 9 years ago

Thanks, good catch I think it should be:

if (!this._P) {
this._P = this._MaxP;
}

right?