Tuning a DC Motor Speed Loop with PID
A motor speed loop reads speed from an encoder and drives the motor with a PWM duty. It is fast, so it needs a short, steady sample time, often a few milliseconds. Speed is found by counting encoder pulses in each sample. At low speed only a few pulses arrive, so the reading jumps in coarse steps. That step noise looks like a noisy sensor, and it makes D useless here. PI is usually enough. Filter the speed a little, or count over a longer window, and retune for the lag it adds. Start with a step test in manual: step the duty and read the speed gain, dead time and time constant. Then tune P and I. Add feedforward from the speed command. Divide the speed you ask for by the process gain to get a base duty, and let the PI fix the rest. Then the PI only works on load changes and model error. The usual disturbance is load, such as a hand on the shaft or a heavier belt. Test with one and read how far the speed dips and how fast it comes back. A motor drive often has a current limit, and when it hits that limit the output saturates. Turn on anti-windup so the speed does not overshoot after a hard start. A cycle near one speed may come from slack in gears, not the gains. Keep hands and loose items clear of the shaft. After this Concept you can tune a PI speed loop with feedforward and check it with a load test.