fix out-of-scope issue with the D variable in PIDs
This commit is contained in:
4
main.lua
4
main.lua
@@ -868,7 +868,9 @@ function CreatePID(kp, ki, kd)
|
||||
local error = setpoint - pv
|
||||
|
||||
local P = self.kp * error
|
||||
if dt > 0 then local D = self.kd * ((error - self.lastError) / dt) else D = 0 end
|
||||
|
||||
local D = 0
|
||||
if dt > 0 then D = self.kd * ((error - self.lastError) / dt) else D = 0 end
|
||||
|
||||
local potential_i = self.integral + (self.ki * error * dt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user