PID motor control

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys
codes below control the motor speed with PID but I have a problem.If I change the speed like rpm=1000 and then rpm= 100.PID calculation produce very big negative value and this is why I cant set motor speed.How can I do it.


rpm = bldcObj->func.Get_RPM(bldcObj);
      //rpm = kalman1Dobj->func.Calculate(kalman1Dobj,rpm);
      err = setRpm - rpm;
      pwm = (int16_t)pidObj->func.Calculate(pidObj,err);

      if(pwm>3000) pwm=3000;
      else if(pwm<0) pwm=0;
      
      
      bldcObj->func.Set_Duty_Cycle(bldcObj,pwm);

 

Last Edited: Wed. Nov 6, 2019 - 02:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

Last Edited: Wed. Nov 6, 2019 - 02:51 PM
Topic locked