PowerBroker2 / ArduPID

PID library for Arduinos with greater accuracy than the legacy Arduino PID library
MIT License
85 stars 23 forks source link

setWindUpLimits Problem with Negative min #5

Open RLR-NDH opened 1 year ago

RLR-NDH commented 1 year ago

I am using setOutputLimits(-128, 127), setBias(0.0) and setWindUpLimits(-100.0, 100.0). My integral tern was being limited to 0.0 and 100.0 until I changed your code to:

double iMax = constrain(outputMax - outTemp, 0, outputMax); // Maximum allowed integral term before saturating output double iMin = constrain(outputMin + outTemp, outputMin, 0); // Minimum allowed integral term before saturating output

which appears to function properly for my case. I also added a debug print of the error term which I find useful.

PowerBroker2 commented 1 year ago

Thanks! Could you open a PR for an easy fix?