Author Topic: PID regulator for speed  (Read 2633 times)

0 Members and 1 Guest are viewing this topic.

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
PID regulator for speed
« on: June 25, 2019, 09:38:54 am »
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.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 15156
  • Country: de
Re: PID regulator for speed
« Reply #1 on: June 25, 2019, 09:49:52 am »
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.
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: PID regulator for speed
« Reply #2 on: June 25, 2019, 10:21:12 am »
@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.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: PID regulator for speed
« Reply #3 on: June 25, 2019, 10:26:24 am »
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.
« Last Edit: June 25, 2019, 10:28:33 am by Yansi »
 
The following users thanked this post: nForce

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: PID regulator for speed
« Reply #4 on: June 25, 2019, 02:42:06 pm »
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.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: PID regulator for speed
« Reply #5 on: June 25, 2019, 03:12:41 pm »
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))
« Last Edit: June 25, 2019, 03:14:26 pm by Yansi »
 
The following users thanked this post: nForce

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: PID regulator for speed
« Reply #6 on: June 25, 2019, 04:53:53 pm »
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.

There 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.
« Last Edit: June 25, 2019, 04:56:12 pm by pwlps »
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3930
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: PID regulator for speed
« Reply #7 on: June 26, 2019, 06:42:46 am »
pwlps I 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.
 

Offline pwlps

  • Frequent Contributor
  • **
  • Posts: 372
  • Country: fr
Re: PID regulator for speed
« Reply #8 on: June 26, 2019, 09:08:34 am »
pwlps I 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.


Yes 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  :)
 

Offline nForceTopic starter

  • Frequent Contributor
  • **
  • Posts: 393
  • Country: ee
Re: PID regulator for speed
« Reply #9 on: June 26, 2019, 06:59:54 pm »
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.
 

Offline awallin

  • Frequent Contributor
  • **
  • Posts: 694
Re: PID regulator for speed
« Reply #10 on: June 26, 2019, 07:40:43 pm »
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/
and
http://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!
 

Offline PsychoBoy

  • Contributor
  • Posts: 12
  • Country: pl
Re: PID regulator for speed
« Reply #11 on: June 26, 2019, 11:23:02 pm »
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.

Are 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/Input
What 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*s

Set 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=SystemModeling

As you see, DC motor consists of electrical part and mechanical part.
Quote
In general, the torque generated by a DC motor is proportional to the armature current and the strength of the magnetic field. In this example we will assume that the magnetic field is constant and, therefore, that the motor torque is proportional to only the armature current i by a constant factor Kt as shown in the equation below. This is referred to as an armature-controlled motor.

Personally 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:
Quote
In summary, we can highlight the two main variables which affect the speed of the motor in our final equation:

    Input Voltage:  For a fixed load, the speed of the motor is affected by applied voltage. Increase in voltage = increase in speed
    Load Torque: For a fixed voltage, the speed of the motor is inversely affected by the load. Increase in load torque = decrease in speed

Now 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 know :)

Also 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:



« Last Edit: June 26, 2019, 11:30:32 pm by PsychoBoy »
 

Offline ArthurWozniak

  • Newbie
  • Posts: 6
  • Country: br
Re: PID regulator for speed
« Reply #12 on: June 29, 2019, 12:57:35 am »

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.

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.

How do you plan to measure torque?

Best regards,
 

Offline L_Euler

  • Regular Contributor
  • *
  • Posts: 86
  • Country: us
Re: PID regulator for speed
« Reply #13 on: June 29, 2019, 01:11:22 pm »
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.
 
There's no point to getting old if you don't have stories.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf