# Given drive rotation angle, controlling torque, how do I maintain movement speed with varied load?

I'm working on design of a 3D movement drive (for 3D printers/CNC mills etc) using DC motors and helical drive.

A DC motor drives the leadscrew actuator which supports the working elements (head, table or head bridge).

The current of the motor shaft -> position of the driven element is read with optical encoder. (I can derive speed, acceleration, momentum etc from that.) I can read the current (voltage across a fixed low resistance in series with the motor), and the voltage across the motor terminals, resulting in measurement of the power -> torque.

I can drive the power supplied to the motor through PWM.

For optimal drive, I should maintain movement speed as close as possible to given (right for the used machining parameters), and as I'm machining material, the resistance of the material against the tool will change in more or less unexpected pattern.

This is pretty simple with stepper motors where we just assume the output directly follows the input. In case of DC motor though, the control must be much more reactive, increasing power as torque rises.

What control algorithm would allow me to maintain movement speed closest to preset - meeting the additional condition: restricting or rapidly minimizing exceeding the preset speed; rapidly reduced load as the head exits material could result in speed increase and drive the head into a neighbour element, damaging the work piece.

(please note, this is one of the questions that take long rather than short answers; control algorithms in automatics is a subject of good several semesters of study, and choosing and explaining the control algorithm meeting specified criteria is bound to require some work.)

• Why do you think the resistance against the tool will change unexpectedly? To properly machine parts, you should have an accurate description of the part before machining in addition to knowing what you want it to look like after. Cutting blindly really sounds like a recipe for disaster. Commented Jan 23, 2015 at 14:46
• Do you understand that with DC motors, speed is proportional to voltage, and torque is proportional to current? In other words, as long as the motor isn't overloaded, if you keep the voltage constant, the speed will pretty much stay constant, and the motor will simply draw more current as the load torque increases. You only need to add a feedback control circuit if you need tighter speed control than what the motor provides inherently. Commented Jan 23, 2015 at 15:21
• @DaveTweed: I do - the inductance of the motor will delay the voltage feedback while the excess torque creates a spike of speed. That's why position(->speed) feedback is essential. Maintaining voltage through a simple (even just proportional) control would be sufficient otherwise (say, with more loose timing constraints or large error tolerances).
– SF.
Commented Jan 23, 2015 at 16:16
• Do you understand the concept of a flywheel? I'm not trying to be obnoxious, it's just that you've told us absolutely nothing about your education and/or experience in this field in your profile, and the wording of your question offers few clues about that or about what it is you're actually trying to accomplish. Commented Jan 23, 2015 at 16:53
• @DaveTweed: Engineering degree in informatics applied in control automatics; unfortunately good several years ago and I barely remember the details of automatics theory - probably some 10 years ago I could have answered this myself. What I want to accomplish is a drive for CNC that is faster than ones using stepper motors.
– SF.
Commented Jan 23, 2015 at 18:53

## 1 Answer

This is typically done with a PID (Proportional, Integral, Derivative) control algorithm. There are heaps of literature about designing and optimizing PID controllers, so there's not much sense going into a more specific detail here.

Typically you use the PID controller to regulate speed. Assuming your stopping point is also critical, there will be some trade-off between accuracy of position and accuracy of deceleration at the end point. With relatively low inertia systems and reasonable deceleration values this is not usually a very big issue.

Wikipedia has a very in depth article on the design of PID controllers at https://en.wikipedia.org/wiki/PID_controller . There are a number of sample and open source implementations available as well, depending on what platform you are working on. If you have already done this basic research and have a more specific question, please clarify.

• First, normal PID will react to exceeding speed the same as to reduction; in this case the asymmetry is important - I can afford the speed to drop even significantly, but excess will result in damage of the work piece. And the second problem: while describing how PID works takes a simple Wikipedia article, the methods of finding the right work parameters take quite a few rather large books.
– SF.
Commented Jan 23, 2015 at 14:22
• (specifically, probably in case of exceeding the speed the controller should react quickly and strongly, possibly applying negative force, which is bound to bring the speed "under the line" as we don't have time to bring it to the right value asymptotically. Now in the opposite case - speed too low - asymptotic rise is preferable to overshooting. I believe plain PID doesn't provide such asymmetry of control behavior.
– SF.
Commented Jan 23, 2015 at 14:25
• You're absolutely correct - tuning of PID loops is pretty complicated and is the topic of entire books. The point I'm trying to make is that without much more information, we can't help you with the tuning. There are many optimizations and additional filters that get applied to PID loops which I think will work for your application. Specifically in terms of asymmetrical response, it's possible for a PID loop to have a different D coefficient for rising and falling error rates, although it makes it harder to maintain stability. Commented Jan 23, 2015 at 14:37
• If any information is missing, I'm open for questions and willing to provide it. We can assume motor parameters are known; many others (like inertia of the mechanism) can be measured and should be parameters to the equation. Friction of the mechanism should be included as a part of the load, too many variables to take it for a separate given. There are parts not defined (like time allowances for the speed on the rising side) and these should be taken as free variables - things that can be sacrificed for reducing complexity etc.
– SF.
Commented Jan 23, 2015 at 14:44
• In actual industry, there are two common ways this would be solved. Either build one, implement a basic PID loop, and experiment with tuning and additions until it works. Feedback can be qualitative from a human observer, or quantitative from sensors. Alternatively, bring in a controls expert to model your whole system in detail to establish starting values 'blind.' This is only done, as far as I know, on very large systems, and still requires tuning in the field. Commented Jan 23, 2015 at 14:55