Tuning a PID loop URGENT

I know how to tune a loop via traditional methods. However I have made a design change and I am having to retune. When I am graphing my results there is a lot of oscillating, but I’m not sure if it’s loop oscillation or just oscillation jitter due to external factors. I have reduced any mechanical play as much as possible.
I have attached some graphs of what I mean.
It is really hard to tell where a constant should be. With the P constant I can vary it around 20-80 without much difference in graphs. It has started loop oscillation somewhere in there (after 80 the loop oscillation is really obvious).

I should add I tried to average every 3 velocity values and graph them it smoothed it out, but too much.
I am running my calculate speed function and PID function as two separate tasks in autonomous and driver.
The wait time in both loops is 20ms.
I (obviously need to tune this loop) any tips, help?

start small, not sure what measurements you are using, but 20-80 sounds really high to me. what you need to do, Is find the lowes value for the proportional constant that causes an ocilation, then, start increasing Kd until that ocilation goes away. next increase kp until the ocilation begins again, then increase Kd until it goes away once more. repeat this until you get a value for Kp where no matter how high you make Kd the ocilation wont go away. once you reach this point, set Kp and Kd to the last set of values that worked and you are good to goZ

That is the method i use. i go up in increments of 0.5.
i’ve changed a few things and got it so it’s between 10-20. power that the motor’s supply oscillates a lot, so much so that it’s audible.
but the velocity oscillations have decreased.

I would work in increments no larger than .05, my Kp is about .55
also with the PID loop there will be some audible oscillations, as long as they are fast and small it shouldn’t cause problems

Can you post your PID code?

I spent an abnormally large amount of time doing that and graphing from debug stream to excel but there is so much oscillation all the time i have no idea where the actual loop oscillation starts. I went up in 0.05.

Then maybe there is an error in the code?

I’ve private messaged my PID code to you.

Could I binary search it? That is, I know 100 causes oscillation and 0 doesn’t, that’s only 14 checks with binary search in increments of .01.

I’m not entirely sure what you mean by binary search.

Binary, you mean half/half to a resolved answer, yes. But, be careful with this. The reason is aliasing. It can happen in loop tuning too. So I would go from the bottom up.

If the answer is 35 in a range of 0-100, I would guess 50 (halfway b/w 0 and 100), then 25 (halfway between 0 and 50), then 37.5 (halfway between 25 and 50), then 31.25 (halfway between 25 and 37.5), and so on until I narrowed it down to 35.00.

I don’t know what aliasing is.