Pid learning controller, gains adapted as function of previous error