cancel
Showing results for 
Search instead for 
Did you mean: 

Speed Loop PID Tuning in ESC001V1

tej_sri_02
Associate II

For PID tuning, from documentation, I understood how to calculate gains for current loop. But how to calculate them for speed loop? How Motor control workbench is auto calculating the gains for speed regulator? Please provide documentation or formulas related to it. 

1 ACCEPTED SOLUTION

Accepted Solutions
Gael A
ST Employee

 

Hello tej_sri_02,

I apologise for the delay in my answer. The computations are a bit fastidious, but I will try to sum them the best I can.

 

The mechanical model of the motor taken into account by the MCSDK is the following : Te = J.dw/dt + Fw
Te : Torque
J : Inertia
F : Friction
w : Speed

This gives the following transfer function : 1/(J.s + F)

The target of the PI controller is to stabilise the model by getting a pure integral loop : wb/s
wb : Bandwidth of the system [rad/s]

Then, given the transfer function of the PI control (s.Kp + Ki)/s, the following values of Kp and Ki would work :
Kp = J.wb ; Ki = F.wb

 

Now that the equations are laid, let's see how the WB computes them.
First, the bandwidth is computed as such wb = 0.5 x 30 / Tau ; (Tau = J/F) it is fixed to simplify the user flow, but this comes at the cost of flexibility of course. J/F is the time constant of the system, and the 0.5 x 30 factor comes from a reference motor with a low inertia. (Tauref = 0.5s ; wbref = 30 rad/s)

Now let's also mention that the input of the speed controller in the code is in 01Hz (see User Manual for speed unit), so we will have to divide the calculation by 10 to convert the speed to Hz. The computations are done in rad/s, so a multiplication by 2.pi will also appear.
Inertia is in microN.m.s^2, so J needs to be divided by 1000000.

Now the torque output of the PI controller also needs to be converted into Iq since the speed controller is cascaded with the current controller. Torque equation can be set as the following : Te = (3/2) x PolePair x Flux x Iq, (Cross product simplified) so Iq = Te / (3/2) x PolePair x Flux. Let's call Kt such as Iq = Te / Kt.
Flux being represented by Ke[Vrms/krpm], it also needs to be converted :
RMS to peak : sqrt(2)
Line to Line to Phase : 1/sqrt(3)
Mechanical to Electrical : 1/PolePair
1/krpm to 1/rad/s : 60/(1000 x 2.pi)

Which gives Kt = (3/2) x sqrt(2/3) x 60 x Ke / (1000 x 2.pi)

Last point, current values in-code are in s16A format (see User Manual for more info), which means that the current needs to be multiplied by k = 65536.Rshunt.Gaop/3.3

 

In the end we get : Kp = J/1000000 x k x wb x 2.pi / (10 x Kt)

Ki encompasses the same conversion calculations, using friction instead of inertia, which can be summarised by Kp/Tau. We only need to multiply by the Speed Regulator Execution Rate (converted to seconds) for the error integration.

This gives Ki = Kp x ExecRate / (1000 x Tau)

Now there is a last thing that needs an extra explanation.
There currently is an error in our Kp / Ki computations : it is multiplied by PolePair value. This comes from the fact the calculated Inertia and Friction are done with electrical speeds in the Profiler. However, any displayed value of Inertia and Friction should make reference of mechanical Friction and Inertias. This is not a problem when using MotorProfiler's data (since they are made with electrical values, and thus should be multiplied by PolePair to get the actual Inertia and Friction), but is confusing for users that want to input their own Inertia and Friction values.
We apologise for this and we will work on fixing it, both on MotorProfiler and Kp / Ki

 

I hope that my explanations were clear. If you have any question, I will be happy to get back to you.

I reckon that it would be beneficial for us to make these computations figure in our documentation, and we will work on that topic to improve it further.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

View solution in original post

5 REPLIES 5
xiaohong
Associate

I want to know also. tks

tej_sri_02
Associate II

Anyone at ST?? Please Help

tej_sri_02
Associate II

hello?

Gael A
ST Employee

 

Hello tej_sri_02,

I apologise for the delay in my answer. The computations are a bit fastidious, but I will try to sum them the best I can.

 

The mechanical model of the motor taken into account by the MCSDK is the following : Te = J.dw/dt + Fw
Te : Torque
J : Inertia
F : Friction
w : Speed

This gives the following transfer function : 1/(J.s + F)

The target of the PI controller is to stabilise the model by getting a pure integral loop : wb/s
wb : Bandwidth of the system [rad/s]

Then, given the transfer function of the PI control (s.Kp + Ki)/s, the following values of Kp and Ki would work :
Kp = J.wb ; Ki = F.wb

 

Now that the equations are laid, let's see how the WB computes them.
First, the bandwidth is computed as such wb = 0.5 x 30 / Tau ; (Tau = J/F) it is fixed to simplify the user flow, but this comes at the cost of flexibility of course. J/F is the time constant of the system, and the 0.5 x 30 factor comes from a reference motor with a low inertia. (Tauref = 0.5s ; wbref = 30 rad/s)

Now let's also mention that the input of the speed controller in the code is in 01Hz (see User Manual for speed unit), so we will have to divide the calculation by 10 to convert the speed to Hz. The computations are done in rad/s, so a multiplication by 2.pi will also appear.
Inertia is in microN.m.s^2, so J needs to be divided by 1000000.

Now the torque output of the PI controller also needs to be converted into Iq since the speed controller is cascaded with the current controller. Torque equation can be set as the following : Te = (3/2) x PolePair x Flux x Iq, (Cross product simplified) so Iq = Te / (3/2) x PolePair x Flux. Let's call Kt such as Iq = Te / Kt.
Flux being represented by Ke[Vrms/krpm], it also needs to be converted :
RMS to peak : sqrt(2)
Line to Line to Phase : 1/sqrt(3)
Mechanical to Electrical : 1/PolePair
1/krpm to 1/rad/s : 60/(1000 x 2.pi)

Which gives Kt = (3/2) x sqrt(2/3) x 60 x Ke / (1000 x 2.pi)

Last point, current values in-code are in s16A format (see User Manual for more info), which means that the current needs to be multiplied by k = 65536.Rshunt.Gaop/3.3

 

In the end we get : Kp = J/1000000 x k x wb x 2.pi / (10 x Kt)

Ki encompasses the same conversion calculations, using friction instead of inertia, which can be summarised by Kp/Tau. We only need to multiply by the Speed Regulator Execution Rate (converted to seconds) for the error integration.

This gives Ki = Kp x ExecRate / (1000 x Tau)

Now there is a last thing that needs an extra explanation.
There currently is an error in our Kp / Ki computations : it is multiplied by PolePair value. This comes from the fact the calculated Inertia and Friction are done with electrical speeds in the Profiler. However, any displayed value of Inertia and Friction should make reference of mechanical Friction and Inertias. This is not a problem when using MotorProfiler's data (since they are made with electrical values, and thus should be multiplied by PolePair to get the actual Inertia and Friction), but is confusing for users that want to input their own Inertia and Friction values.
We apologise for this and we will work on fixing it, both on MotorProfiler and Kp / Ki

 

I hope that my explanations were clear. If you have any question, I will be happy to get back to you.

I reckon that it would be beneficial for us to make these computations figure in our documentation, and we will work on that topic to improve it further.

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.

Hope this will help,
Gaël A.

Thanks a lot @Gael A for explaining.