<< return to Pixycam.com

PID Loop algorithm in the PIDloop.h question

Hello, sorry to bugging you again Edward, in the PIDloop.h
line 60: pid = (errorm_pgain + ((m_integralm_igain)>>4) + (error - m_prevError)*m_dgain)>>10

for the PID control. what does >>4, and >>10 mean?

I have find out >>4 means “right shift to power 4”.

but why is 4??

Hello,

4 is an efficient way to divide by 16. The gain values are just simple multipliers and the shift values are simple dividers. The numbers aren’t all that important – they just need to result in decent control of servos in this case.

Edward

got it! thank you very much for the explanation! I’ve learned a lot from pixy project!