Open ewok2 opened 1 month ago
it depends on which initial values you want to set: you can set the gains to initial values before beginning time-step iterations, or if you want to set an initial value for the control signal you are sending to some device or process plant then you can use BasicPid in iterative mode (instead of integrative mode) and handle the time-step integrations manually in a loop see some examples in RTD for BasicPid for more @ https://basic-pid.readthedocs.io/en/latest/examples.html
I just had to change the pid.py file to achieve my goal :-) I just add the folowing function :
def setInit(self,initial):
# set initial value
# keeps gains intact
self._P = 0
self._I = 0
self._D = 0
self._e_prev = 0 # previous error (t-1)
self._e_prev_prev = 0 # prev-previous error (t-2)
self._pid_out = initial
self._pid_out_prev = initial
just befor the reset function, and it works
I just have to call "pid.setInit(initalvalue)" befor the loop
yep, you got it! just jump start the 1st iteration with initial PID evaluation (output) values. Did you then just run PID in integrate mode? I designed & coded BasicPID to be clean & logical so can be relatively easy to modify & customize. I was going to put in an interface function for setting initial values but left it for the first stable release. I will put it in for the next. thanks for asking about this. any feedback is welcome.
The only feedback is : wonderful job The code is clear and it was easy to add a new input point. Wonderful if you add this functionality in next release. I will pug on it when avalaible
Many Thanks
Hello I use the pid to filter a temperature and wich a the first iteration to start with initial value. Is it possible to set the PID so that the first iteration is not zero but the initial value? => doesit have any sens? Maybe by setting
to a intila value?