Electronic – PID control at small PWM values for a DC motor

dc motorpid controllerpwm

I've set up a PID controller to control the shaft position of a brushed DC motor that I control via PWM and an optical encoder. I'm basically reconstructing an RC servo.

Now that I think I've found the correct tuning parameters (all three parameters non-zero), I'm facing with another problem: the shaft arrives at the desired angle with some approximation (look at the black stick at https://www.instagram.com/p/BTg25HngIDo/), then stops moving further. I hear a "buzzing crescendo" from the motor, that ends after some seconds with it moving a little further, but now too much. So there's another buzzing crescendo, and so on. It almost never reaches the target angle exactly.

By looking at the output/error output, I see that during the buzzing the controller is sending small PWM values, too small to start the motor (as I could experiment by myself, see https://www.instagram.com/p/BQYBZsShq9x/). I guess this is some kind of non-linearity, while a PID can only work with linear processes. Because the motor is stopped at a nearby position, the error accumulates in the I branch and so does the output, until a threshold is reached.

What is the usual approach to solve this issue? I'm thinking about linearizing the output as suggested in this answer (i.e. implementing a "dead zone" function so that the motor never receives small PWM values), but I'm worried that the linearizer will add more independent variables in the system.

Best Answer

You have backlash in the gear train which is like electrical hysteresis. That is causing "hunting". You can minimize the backlash by preloading as in anti-backlash gears. You can adopt a simpler control scheme such as P (perhaps with some control deadband) or P+D. The integral term, if present, will integrate any remaining error until motion occurs (unless the I term has deliberate or accidental deadband itself - say due to low ADC resolution).

You might want to read this paper by Tim Wescott. Tim does a lot of work with precision electromechanical systems used in military and similar applications.