lastTime again...

174 views
Skip to first unread message

Denis Lafourcade

unread,
Dec 31, 2020, 10:44:31 AM12/31/20
to DIY PID Control
Hello Brett,
In your PID lib, the compute function executes only if the delay since last call is greater than sampleTime. For that, you use a variable called lastTime, which is private and initialized in the constructor to (now-sampleTime). The problem is that sampleTime is set to 100ms at that time. If sampleTime is then set by the user with the SetSampleTime function at a greater value, the compute function will wait during quite an entire sampleTime before starting.
I think that sampleTime should be defined by user at construction time (overload ::PID), and lastime should also be updated in the SetSampleTime function.
Just my two cents,
Denis
Reply all
Reply to author
Forward
0 new messages