Need explanation on Pixy2 for Zumo PID Loop algorithm please

Good day community!

I am trying to understanding how the pixy2 for zumo robot’s PIDloop.h in the pixy2 Library work.

in the code: link
line 60: pid = (errorm_pgain + ((m_integralm_igain)>>4) + (error - m_prevError)*m_dgain)>>10;

in the PID control algorithm, what are the >>4 and >>10 mean?

Thank you so much in advance for your help!

Hello @goodbyehollywood,

Those are shifts to the right. You can find more information about this here:

thank you for the reply, I am just wondering why they put the right shift">>4" & “>>10” in the PID controller loop algorithm. I have never seen this way before… little confused here…

my understand to the PID control still very beginner level… bear with me if I am sounds stupid…

Hello again!

You don’t sound stupid at all, to be honest I’m not sure what the shifts are doing there either. Shifting 4 to the right means dividing by 2^4=16 and shifting 10 would be dividing by 1024. Why do they do that? Not sure. All I know is that they are scaling down the integral and derivative components.

I found this which might be related:

I hope that helps!

thank you so much for the explanations! I learned a lot from those links! just got more gadgets from RobotShop over the weekend! can’t wait for them to arrive.
I am sure will be bugging you on the forums again soon…

1 Like