control dc motor using pid processing and arduino

hi forum
I done code for pid to control dc motor speed but the output value gives 0 or constant value 250 and the set point is still same 100.Hereby I attach the PID code.

mchait11 months ago

No matter I did not see your code, you are experiencing an oscillation, that is in one sampling period speed goes to max (255) and in the next, it goes to 0.

this is normal in a PID controller with too high proportional constant Kp. According to the tuning method proposed by Ziegler-Nichols, diminish Kp untill oscillation stops. Go back to the minimun value of Kp that begins oscillating. That is Kc (critical gain).

Finally define Kp as 0.6Kc