News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Data types of Kp and Ki parameters for PI Control

Started by TY, July 14, 2020, 03:30:43 AM

Previous topic - Next topic

TY

Hello,

I'd like to ask a few questons about data types of Kp and Ki parameters for PI Control.

1.
I think the Kp and Ki have been specified to have fixed point format of Q16.16 and those registers are 32-bit.
I saw FocDevice.cpp file (from line 157) describes TORQUE_KP_REG, TORQUE_KP_REG, etc., as below.
add_parameter_value(config->init, parameterRegisters, TORQUE_KP_REG, 5000);      // Torque Kp = 1.0
add_parameter_value(config->init, parameterRegisters, TORQUE_KI_REG, 0);      // Torque Ki = 0
add_parameter_value(config->init, parameterRegisters, RPM_KP_REG, -200);      // Speed Kp = 2.88
add_parameter_value(config->init, parameterRegisters, RPM_KI_REG, -5);         // Speed Ki


Could you tell me why "TORQUE_KP_REG, 5000" is "Torque Kp = 1.0" and "RPM_KP_REG, -200" is "Speed Kp = 2.88"?

For RPM_KI_REG, TORQUE_KP_REG and TORQUE_KI_REG, what do the -5, -20000 and -5000 represent?
add_parameter_value(config->torque, parameterRegisters, TORQUE_KP_REG, -20000);
add_parameter_value(config->torque, parameterRegisters, TORQUE_KI_REG, -5000);

2.
PI_Control function specifies int16_t Kp and int16_t Ki, but above registers are 32-bit.
How does the PI_Control function in foc.cpp calculate above the fixed point format of Q16.16?

Thanks

Andrei Errapart

I am sorry for the delay in answer.

You are right in your observations. The documentation should read Q8.8 for the proportional setpoint and Q0.16 for the integral setpoint.

The comments require updates as follows:
// Torque Kp (Q8.8 ): register contents 5000 for the value of 19.53.
// Speed Kp (Q8.8 ): register contents -200 for the value of -0.78
// Speed Ki (Q0.16): registers contents -5 for the value of -0.000076


If there are any further questions, don't hesitate to ask.

TY

Hi Andrei,

Thanks for your help. I would like to ask you some more questions.

1.
Is fixed point format of TORQUE_KI_REG also Q0.16?

2.
Unit of TORQUE_SP_REG and FLUX_SP_REG is describes in foc.h (line 91 and 108) and the unit is Resolution of the current ADC-s.
I confirmed that "focserver.conf" file defines "adc2A" as 0.00039.
How did you calculate the value of "0.00039" ?

Thanks

Andrei Errapart

1. Yes, TORQUE_KI_REG  is also Q0.16

2. This can be calculated from the component datasheets. I think I must have had a prototype board with different components, because now I arrive at another value. Please find attached the spreadsheet with the new calculations; the number you are searching for is highlighted in the block "ADC", on the last line, "Sensitivity".

TY

Hi Andrei,

Thank you for your prompt reply and kind explanation!  It's clear now.

Thanks