PID regulator for speed - Page 1
Forum section: electronics / beginners

author: nForce
author_rank: Frequent Contributor
timestamp: June 25, 2019, 09:38:54 am
content: Hello,I would like to create a PID regulator where the input is speed and the output is torque. I know how a PID regulator looks like, I just want to know what kind of block (physical relation) I add such that I adequate convert from speed to torque.Thank you.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 25, 2019, 09:49:52 am
content: Depending on the system driven with the torque, the system could be more integrating (if the kinetic energy is important) or more proportional if in a a more friction dominated range.

author: nForce
author_rank: Frequent Contributor
timestamp: June 25, 2019, 10:21:12 am
content: @Kleinstein are you talking about tuning the PID regulator?Now I have a PID regulator where we have input speed and at the end we sum the speed signals which come from P, I and D. But I can't just connect this sum with the output where we have torque. The relation from physics is P = T*RPM. But power is changing.

author: Yansi
author_rank: Super Contributor
timestamp: June 25, 2019, 10:26:24 am
content: Connect it together and stop inventing why it can't be done!And btw, the output of the speed regulator is not torque, but CURRENT instead. You can't regulate torque directly.

author: nForce
author_rank: Frequent Contributor
timestamp: June 25, 2019, 02:42:06 pm
content: Yansi, this is great but I want to know what is inside "Rw" block? How do we get from w_ref to I_ref?Thanks, again.

author: Yansi
author_rank: Super Contributor
timestamp: June 25, 2019, 03:12:41 pm
content: Inside that block is just the PI regulator.Plain stupid G(s) = U(s) / E(s) = Kp + Ki/s, where U(s) is the Iref output, E(s) is the error input, the Wref minus Wmeasured.Nothing more, nothing less.(Just a practical sidenote: Forget the derivative component on both current and speed regulators, it is of not much use for practical application there. Also the speed should be measured using an observer (PLL loop))

author: pwlps
author_rank: Frequent Contributor
timestamp: June 25, 2019, 04:53:53 pm
content: Quote from: nForce on June 25, 2019, 10:21:12 amThere is a subtle point regarding the control parameter. The motor speed is proportional to the applied voltage (because of back EMF), and the motor acceleration to the current (because the torque is proportional to the current. Consider two cases: 1) you control by voltage i.e. by speed, and the integral component of the PID is the integral of the speed error - this is ok; 2) you control by current i.e. by acceleration, then since the speed is the integral of the acceleration your I component of the PID contains a double integration which may cause instability (Nyquist criterion). In such case you should rather use the phase error as the input signal. A similar problem arises when we want to lock the motor phase to an external signal: then if the control signal is the speed we shouldn't use any integral component in the PID because we already have an integration in the loop.

author: Yansi
author_rank: Super Contributor
timestamp: June 26, 2019, 06:42:46 am
content: pwlpsI do not understand what are you trying to say.Should he control the motor directly using voltage? Absolutely wrong. Every beginner gets that wrong and then is surprised, when red hod bakelite flies mach 2 round his head, from the blown mosfets.Should he use just P regulators just because "a couple of integrators in a loop might be unstable"? Also wrong nonsense. Do you have any slight idea, how much integrators in a loop are in an average servo controller?Yes, two and more integrators in a loop may be unstable. Thats why a control theory and stability is studied.

author: pwlps
author_rank: Frequent Contributor
timestamp: June 26, 2019, 09:08:34 am
content: Quote from: Yansi on June 26, 2019, 06:42:46 amYes you are right, we already have two integrations. Actually my recollection was having instability problems when trying to control both speed and phase. Instabilities ocurred when integrating the phase error and disappeared when using the phase error in the proportional term only. But integrating phase with a current-controlled motor is already a triple integral

author: nForce
author_rank: Frequent Contributor
timestamp: June 26, 2019, 06:59:54 pm
content: Yansi, if I understand you correctly. We get the error by "w - w_ref", then we apply integral multiplied with constant for Integral part, and for the proportional part we multiply just with a constant. Then we sum the signals, and connect directly with output which is I_ref?How do we know that we get electrical current (I) or torque (T) on the output? This part I don't understand, on the output we can get any physical quantity.

author: awallin
author_rank: Frequent Contributor
timestamp: June 26, 2019, 07:40:43 pm
content: FWIW I played around with EMC (now LinuxCNC) in 2008 with DC-servos that had encoders (position feedback) and simple PWM-input servodrives (e.g. voltage control/mode).In LinuxCNC it's quite easy to set up different control schemes and play around with the gains etc - if that is what you want to do.Some notes from a long time ago...http://www.anderswallin.net/2008/04/pid-tunig/andhttp://www.anderswallin.net/2008/04/x-axis-test/IIRC there were (at least) two lessons- the mechanical bandwidth of anything (like a cnc machine) with a bit of mass is quite low, probably much below 100 Hz- various forms of feed-forward really help - the cnc trajectory-controller knows where we want to go and at what speed/acceleration, so make use of that!

author: PsychoBoy
author_rank: Contributor
timestamp: June 26, 2019, 11:23:02 pm
content: Quote from: nForce on June 26, 2019, 06:59:54 pmAre you talking about motor or PID controller? If about PID controller then you are the one who sets the relationship between the input and output variable.You already have definied what is the input variable, it's an error of the variable you are controlling, and you know the output, this is what you want to control.So let's say you want to control DC motor speed, so the input is speed error and the output is motor supply voltage.The transfer function is T = Output/InputWhat is the input? Speed error, let's say in RPM.What is the output? Motor supply voltage, in Volts.Now you construct your PID controller which units of transfer function are in Volts per RPM.Any transfer function is: T = Output/Input (in Laplace domain)Specifically, transfer function of one of variants of (there are several, check on wikipedia) PID controller is: T = Kp + Ki/s + Kd*sSet it side by side: Kp + Ki/s + Kd*s = Output/Input = Voltage/Speed [V/RPM]So by tuning PID controller (Kp, Ki, Kd gains in PID controller equation) you basically telling PID controller how many volts it has to put per 1 RPM of error signal.Example:Let's say that you set Ki = 0, Kd = 0, and Kp = 2, so you have only Proportional controller. Equation is now: Voltage = Kp*Speed = 2*Speed.So if you have 10 RPM error at some instant, then you will output 20 volts to motor.Now, if you are asking about plant/process, in this example DC motor, how do we know what is it's transfer function, what is the input and how it is coupled to output, everything comes from analysis.Check this out:http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&section=SystemModelingAs you see, DC motor consists of electrical part and mechanical part.QuotePersonally I dunno much about motors but take a look at this analysis:https://www.precisionmicrodrives.com/content/dc-motor-speed-voltage-and-torque-relationships/It states that:QuoteNow you asked about speed control, @Yansi showed earlier a cascade PI controller which controls both, speed and torque.Perhaps it is possible to ignore torque part and just construct one PI controller in case if you want to control speed for fixed load?I think that cascade control shown by @Yansi is the universal, common way of doing it in servomechanisms?From what I recall from control theory classes cascaded PID doesn't guarantee stability right (you mentioned earlier the problem with double integrators etc)Yet they still are cascade PID's without a problem? Or modern servos and drives use modern control theory? Please answer if you knowAlso keep in mind practical issues: Integral windup and physical limitations. Found a series of videos shining some light about PID theory, DC motor model, controlling it and practical considerations:

author: ArthurWozniak
author_rank: Newbie
timestamp: June 29, 2019, 12:57:35 am
content: As PsychoBoy said, windup is a thing to consider. I from my point of view, dead-time too.Maybe your system cannot be control by a simple PID or just one PID. I run to this problem once, I used a "cascate" PID.Quote from: nForce on June 25, 2019, 09:38:54 amHow do you plan to measure torque?Best regards,

author: L_Euler
author_rank: Regular Contributor
timestamp: June 29, 2019, 01:11:22 pm
content: I understand your question, but don't understand the application. Speed is generally never maintained by torque but by feedback from an encoder or other possibly back emf. I have done torque (current) control in applications where multiple drives are implemented to share load, such as long automotive assembly conveyors or baggage claim carousels, but never in single drive applications. Single motor speed cannot be maintained in changing load conditions by torque control. Typically, for multi-drive systems, there would be a master drive with speed control and one or more drives sharing load through torque control.