I've modified a previous PI controller of a design team on that is working on high speed motor applications to include the D, which didn't solve this issue. The PID loop takes actual speed, and adjusts PWM to meet a target speed. My team wants to keep things are as under wraps as possible, so I'll hold off on giving away too much information and provide additional details if that helps you clarify your answer.

It follows a pretty standard PID algorithm, similar to what can be found here: PI Loop Pseudocode

What happens is, no matter how large of a battery we use (which can affect how much effort it takes for the motor to reach a speed, i.e. a small battery will need a higher PWM to achieve the same speed than what a larger battery would need) the motor makes a horrible, inconsistent grinding sound at a very specific PWM range. We haven't been able to pinpoint where exactly it comes from, as there are a few gears between the motor and the final output, since it is a sealed off system.

From our output analysis, we've found that when the motor grinds, the PWM duty cycle varies significantly more vs. at non grinding PWM duty cycles, and the actual speed seems to constantly miss the target speed by larger margins, which makes the PID loop overcorrect each time so we're in a constant cycle of missing the target speed, which could potentially be causing the noise.

Does anyone have any thoughts on things I can potentially look at to see if it changes/fixes this behavior? We've ruled out resonance as the grinding happens at a specific PWM range rather than a certain speed.

  • 3
    \$\begingroup\$ What kind of motor is it? Have you seen a clear image of PWM waveform (both from the controller as well as at the motor input)? Have you actually separated the PID controller from the PWM to ensure it's the PWM range that matters? \$\endgroup\$
    – horta
    Jun 22, 2021 at 17:05
  • 3
    \$\begingroup\$ What sounds just like grinding is often just step-loss. I wouldn't be so quick to rule out resonance, just because it happens at a certain PWM range, and not motor speed. Have you tried running your PWM at a different frequency? If so, does that change where in the range this happens? \$\endgroup\$ Jun 22, 2021 at 17:18
  • 2
    \$\begingroup\$ The pulse width and f should be give for the critical issue to understand how to help. Right now the system is ill defined, so the problem cannot be analyzed. \$\endgroup\$ Jun 22, 2021 at 17:45
  • 1
    \$\begingroup\$ I know this sounds onerous, but edit your question with a bullet list of all the points so far -- control problems can get complicated, and on the practical side the devil is in the details, and on the local culture side, Stackexchange likes all the important points in the body of the question itself. \$\endgroup\$
    – TimWescott
    Jun 22, 2021 at 20:45
  • 1
    \$\begingroup\$ What kind of motor is it? Stepper motors have a band of frequencies where torque goes down severely, and they can't be used at very high frequencies either. This is a critical issue when using steppers and is a reason servos are used in industrial CNC machines. \$\endgroup\$
    – Kate Moon
    Jun 23, 2021 at 1:09

2 Answers 2


The "grinding" is likely bad timing between the rotor position and the motor phase current. This can often happen when operating a closed loop controller near the "natural" speed where it would run without any PWM.

The problem is often in the PID loop, which generates an error signal that changes the PWM frequency. What does your loop error do at the high end? The lack of headroom combined with the motor's back EMF waveform can mean that your PID constants no longer match the motor response, causing the motor's speed response to lag. The error term continues to build up and overshoot can occur. The loop then demands a too-large decrease in PWM, and in this range, the motor's "slow-down" response happens quickly and undershoot occurs. Then the loop starts to "hunt." While this is going on, the motor current (and torque) fluctuates, causing the audible "grinding" which is really rattling of the gears and couplings. You will lose efficiency as the rotor is accelerated and decelerated, which will wind up as heat in your stator.

For straightforward, six-step PWM speed control, if tight motor speed control is needed with varying loads, we usually design so that we never get into the highest range of PWM. If you can stand it, you might consider loosening up your speed control at the high end and allowing the motor to slow down and speed up slightly as the load changes. You will have this effect anyway when you get to 100%, so you are just allowing it a little earlier.

Good luck!

Answering your question below:

You use the PWM to increase the current in the motor winding, which in turn increases the torque and the additional torque will increase the motor speed. To increase the current, you increase the voltage on the winding. For current to flow into the motor phase, the voltage must be higher than the back EMF voltage of the motor at that speed. But your maximum voltage is limited by your battery voltage.

When your motor is running more slowly, your battery voltage is always higher than the back EMF and everything behaves itself. But The back EMF of the motor is not a constant DC value, and as the motor speed increases, the back EMF voltage can approach or exceed the battery voltage during portions of the waveform. During this time, it is possible that current will be flowing back into the battery when your PWM switch is "on," rather than flowing the other way, so you can see that the response to a change in PWM would be different near the "top end" than it would in other regions.

What I meant is that you could find a loose set of PID constants (or fixed PWM values) for highest speeds. This would mean that your motor would not adjust the speed quickly for changes in load. When you get near the high end, you could switch to the new "sloppier" constants or fixed PWM values, and then switch back when the speed drops (with hysteresis).

  • \$\begingroup\$ Got too long-winded so I edited the post. \$\endgroup\$ Jun 22, 2021 at 20:50

When there's a slight load (aka there's something like a blade mounted), that's when the noise happens. Under actual load, you can't really hear anything.

If it's not the problem that John Birkhead is suggesting, there's a good chance that under light load there's a nonlinear resonance that develops because the motor is bouncing around inside the geartrain backlash. This would make the geartrain act like a flywheel coupled to the motor through a spring -- where when it is uncoupled it acts like nothing at all, and when the thing is driving a load it acts like a flywheel coupled with a shaft, or something else with a good high spring rate.

Basically, backlash is something that all linkages have -- it's the characteristic that you can move the input shaft through a certain angle before the output shaft moves. This is because the gears require some clearance to run. When the motor is driving against a good load, then all through the gearbox the gears are fully engaged, with each gear pressing on the "drive" side of the following gear. When the motor is driving against a light load, if the motor slows down the output shaft won't immediately slow down to match -- instead those gears will relax into their intermediate state, where they are neither driving nor being driven. The motor will see no load at that point. If the motor then catches up, the gears will take up slack, and the motor will see a load again.

Backlash is a nonlinear phenomenon, and a fairly nasty one to try to describe mathematically -- so if possible, we reduce it to a linear phenomenon. In this case, because the motor "sees" a load that goes from zero to high to zero again, we say that the load "looks like" a spring connected to the gearbox's effective inertia.

If that springiness combined with the various moments of inertia fall inside of your loop bandwidth, it'd excite a resonance. If you're unlucky (do a web search on "Tacoma Narrows Bridge Disaster") the resonance frequency -- being the result of a nonlinear phenomenon -- will find its own worst operating point.

  • \$\begingroup\$ Can you put the first paragraph into dumb people terms? I'm an electrical engineering student, so I don't understand mechanical concepts very well, however I'd love to know them better. \$\endgroup\$
    – GoofsRUs
    Jun 22, 2021 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.