PID control of DC motor with minimum speed - Page 1
Forum section: electronics / general

author: Infraviolet
author_rank: Super Contributor
timestamp: April 10, 2022, 09:28:07 pm
content: I'm trying to do PID control of a DC motor so it can act as an accurate servo. I have an encoder on the backshaft and my aim is to get it to be able to move to exactly the correct number of encoder pulses then stop right there. As it stands with a very simle proportional only controller I can get it close to the desired position, but not quite there. I can also create circumstances where I overshoot and oscillate. I've written a PID controller, based on various samples of code online which all seem to be well regarded, so I'm confident in my PID code itself. The trouble, I think, is due to the way DC motors have a minimum speed below which they just sing to the frequency of the PWM wave but don't move at all. Online I cannot find anything about tuning PID parameters when in a situation where there is a minimum speed below which the thing one is trying to control won't actually change position. I thought the integral part would help, but again it is either something which can be used to cause big oscillations about the ideal point, or can produce low enough PID outputs to cause low PWM and "singing".Any tips on what to do in this situation where the PID has a minimum output below which any movement it commands does nothing?Thanks

author: RoGeorge
author_rank: Super Contributor
timestamp: April 11, 2022, 10:06:42 am
content: My naive approach would be to remap the output voltage (in software), so to skip all those values around zero that doesn't produce any move. For example, if output values between [-3 +3] doesn't turn the motor, then when the PID produces a +1, I'll remap it to +4. If the PID output is -2, remap it to -5. That is for the motor only, the PID is kept unaware of the remapping.No idea if that would work in practice, but it's very easy to try.

author: Infraviolet
author_rank: Super Contributor
timestamp: April 11, 2022, 08:57:55 pm
content: It doesn't. The issue is it comes to a halt from the initial motion somewhere a few steps either side of the exact position it should reach, then when you try to run at increased speed like that it runs far enugh to skip over the position it should reach. effectively this just makes it oscillate about the right position rather than stop at it.

author: IanB
author_rank: Super Contributor
timestamp: April 11, 2022, 09:07:05 pm
content: Given that you have overshoot and oscillation, you might want to try adding some derivative action. Derivative action has a kind of "look ahead" behavior, so it might help to slow down the motor faster before it overshoots.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 12, 2022, 07:19:46 am
content: Quote from: Infraviolet on April 11, 2022, 08:57:55 pmLooks like the instability is caused by stiction. Search for 'PID stiction' and see what can be applied to your system.http://wescottdesign.com/articles/Friction/friction.pdfTry dithering the motor to break the stiction and make it turn at very low RPMs (pulsing the motor with a bigger voltage instead of just applying that small voltage that doesn't make the motor turn).

author: Doctorandus_P
author_rank: Super Contributor
timestamp: April 28, 2022, 02:10:53 am
content: There is a lot of quality difference between both encoders and DC motors.The cheapest DC motors only have 3 contacts on the commutator, and this results in a very noticable torque ripple during a rotation (and thus variation in motor characteristics.On top of that motor encoders vary between maybe 4 pulses per revolution upto 100.000 or mor pulses per revolution (Zettlex makes nice ones).Also, if you are trying to get accurate to a single pulse, you do not have decent data anymore to do the PID algorithm. It's just lacking resolution.As long as the load on the motor does not change, you usually can get quite close though.

author: MarkF
author_rank: Super Contributor
timestamp: April 28, 2022, 10:18:05 am
content: In addition to what everyone else has said, I use PWM (no PID control however) for my model railroad for slow speed response. Somethings I have noticed are that the PWM pulse voltage and PWM frequency give varying results. For example, some of my locomotives show a similar stalling depending on the frequency. I've noticed some locomotives will stall with a PWM frequency of 70 Hz. The sweet spot for me is at 80 Hz where I don't see the stalling behavior and the hum is tolerable. For the 12VDC locomotive motors, I have tried voltages from 4V to 8V and frequencies of 20 to 400Hz.So, try several different PWM frequencies and voltages. Also, you may want to vary how often you get PID feedback samples and how often you execute your PID loop.

author: IconicPCB
author_rank: Super Contributor
timestamp: April 28, 2022, 12:16:02 pm
content: Try FEED FORWARD control.that is to say in addition to PID elements take a portion of set point signal and add it ti PID motor drive signal.to tune set PID coefficients to zero adjust FF to be close to where you need to be. then increase P term gain followed by D term gain and garnish everything with some I gain but be careful it may bring on oscillations.Alternatively investigate TAKE BACK A HALF algorithm...all the benefits uf I term but no instability.Ohh are you trying to implement a velocity or positional control?

author: Picuino
author_rank: Super Contributor
timestamp: April 28, 2022, 01:43:18 pm
content: If you want to control a DC motor at very slow speed, you need an internal loop that measures the motor current and compensates the supply voltage with that current to eliminate the effect of the motor's internal resistance.For example, a motor with an internal resistance of 2 ohms. If a current of 1 ampere flows through the motor, you need to increase the supply voltage by 2 volts.This way the motor will behave as if it has no internal resistance and has a very "hard" response to the input voltage.Edit:With this current control, if you set the voltage reference to 0 volts (0 speed) and try to move the shaft, you will encounter great resistance from the motor to move in any direction. The motor will be "locked" in position electrically.On top of the inner loop you can add an outer loop that controls the speed with encoder feedback.And you can do that with a high resolution encoder even if the motor has "low resolution".

author: Benta
author_rank: Super Contributor
timestamp: April 28, 2022, 08:33:56 pm
content: A very basic observation:A normal DC motor will only come to rest (and can be electrically locked) in one of three positions. Let's call them 0, 120 and 240 degrees. This also goes for BLDC motors with Hall sensors. Caveat: there are DC motors with more poles, but this still applies, just "finer grained".You can PID and PWM and angular sense that until you're blue in the face. It won't help.It's certainly possible to build a servo with higher position/angle resolution using a gearbox, this is often done with a worm gear. But the three (or more) fixed armature positions stay.A possibility would be to "nudge" the motor to the 0 degrees (or 120 or 240) position, if that's the one you want. That's it.A better option would be using a PMSM with FOC (field-oriented control).