How to understand P and I of incremental PID (3)

The Glory of the New Overlord Chapter

Application of P and I understanding of incremental PID

If incremental PID looks like this, how do we use it well?
In one sentence: How large P needs to be is determined according to the formula - PWM limiting value == increasing domain * P coefficient + initial PWM when turning on the motor.
In fact, most of the motors we control are in a situation where the initial PWM = the current speed of the wheel. After all, the situation where the initial PWM ≠ the current speed of the wheel only occurs under special circumstances (first turn on the microcontroller to calculate the PID, and then turn on the motor after a while) , the normal state is: various frequent speed changes of the motor occur under PWM = wheel speed. That is, the wheel speed changes from 200 to 300, which is a situation where the domain is increased by 100 and the initial PWM is 200. At this time, the best P coefficient should be based on the formula 8×100+200=999, and P should be 8. The wheel turns from 0 to 100, 10×100+0=999, and the most perfect P is 10. Please look at the picture below to prove my statement (where the green line is the set value of 100, and the pink line is the actual value measured by the encoder.):

  • When P: 10, I: 0.15, and increment domain: 100 , the picture is as follows:

Initial PWM = initial speed of wheel = 0 (initial PWM is 0, initial speed of wheel is 0).
P: 10, I: 0.15, domain increase: 100

  • P: 10, I: 0.15, domain increase: 100

Initial PWM = initial speed of wheel = 200.
This time the wheel starts to rotate from 200, the green line is the set value changing from 200 to 300, the pink line is the actual speed, the tracking situation is as shown below. According to the formula, it can be seen that now it is 10×100+200=1200>999, which is limited, and the responsiveness is indeed lower than the above picture. So what happens when P is changed to 8? After all, 8×100+200=1000, which is closer to the limiting value of 999.
Insert image description here

  • P: 8, I: 0.15, domain increase: 100

Initial PWM = initial speed of wheel = 200. This time the wheel also starts to rotate from 200, with initial PWM. This time the responsiveness is higher than the picture above. The only change is that P is 8.
Insert image description here

The reason for understanding P and I of incremental PID

At this point, you are indeed able to use incremental PID. The incremental PID parameter adjustment is even more impressive, and you also understand the mechanism (metaphysical problems are caused by limiting).

However, why does P and I of incremental PID have such a situation?
What is the reason for this mechanism?
Is there a bigger " boss " behind the mechanism?
I feel that my research is not deep enough. Let us sacrifice all the brain cells and fall into a deeper abyss (brain cells in the frontal lobe, brain cells in the parietal lobe, brain cells in the cerebellum...), stretch out your right hand and pull you Contribute your life)! ! !
Why can the limiting value cause this problem? ? ?
————Not much bb————Above picture: Chart of pure P control (pure P means: I parameter and D parameter are always 0, I only give P parameter)

P Figure (initial PWM is 0) describe
0.01 The set value is 200, which is the green line in the picture, and the actual value is always 0 The wheel doesn't turn
0.05 The wheel doesn't turn
0.1 P is too small and the wheel does not rotate
0.5 Insert image description here The wheel finally turns, the setting value is 200, and the wheel is turning at a speed of 20
1 Insert image description here The wheel is spinning at a speed of 80, and the increase in P makes the control stronger and stronger.
3 Insert image description here The wheel speed reaches 140
4 Insert image description here 160
5 Insert image description here Still 160
7 Insert image description here It actually dropped to 110
10 Insert image description here This time the speed is only 80, and we can be 100% sure: when P is very large, the speed is decreasing. The peak value is the same as P=1, which is 80, but the obvious difference is that the adjustment time becomes shorter.
15 Insert image description here The green line above is the set value, and now the pink line is the set value, because this is a picture added later, the rotation speed is 60, this time the wheel is very noisy
20 Insert image description here The rotational speed is roughly 50, but it is more shaking. Should I call this constant amplitude oscillation? Or is the static difference too large?
30 Insert image description here When P reaches 30, this is a ghost picture. The wheel rotates forward and reverse, so the naked eye can see that the wheel is stuck, not rotating at all, and it is still visible to the naked eye.

see it? Although it is unbelievable, it is true. The responsiveness will become lower and lower when P is very small (0.1) and very large (10). When P is 4~5, the responsiveness is the highest. In other words, P is actually a quadratic function. Can you believe this? But, it's true.

Then we do another experiment, a chart controlled by pure I:

I Picture (the same with/without initial PWM) describe
0.01 Insert image description here The overshoot is very serious, the set value is 200, the peak value can reach 850, and the final steady-state final value is 150, and the static difference reaches 50
0.05 Insert image description here This time the peak value is 680. It seems that the overshoot has been reduced, and the final steady-state value is 200. This time the static difference has been eliminated.
0.1 Insert image description here The peak value is 550, and the static difference is still very small, but now the adjustment time is getting longer and longer.
0.3 Insert image description here The peak value is 450. When I was 0.01, it only oscillated once. Now it oscillates many times before becoming stable. The overshoot is decreasing and the adjustment time is increasing.
0.5 Insert image description here The overshoot is decreasing and the adjustment time is increasing
1 Insert image description here Constant amplitude oscillation is no longer stable.
3 Insert image description here It still oscillates with the same amplitude, but the oscillation peak value is decreasing and the oscillation frequency is increasing.

The I parameter is indeed the same as what we know. Increasing I can reduce the static difference, and the control strength increases with I, which is indeed what the book says. As I increases, the overshoot decreases and the adjustment time increases, which is a proper linear function relationship.

I wonder if you have noticed? The diagram in my pure P diagram is intentionally explained in parentheses: the initial PWM is 0. When the formula P*increase=limiting value is satisfied, the peak value of the curve reaches the highest value, and P is 5 at this time. After all, 5×200=999. The above pure P control without initial PWM does not rotate the wheel when P is very small, so I made the assumption that the curve of pure P control with initial PWM state will have a large overshoot when P is very small.

————Not much bb————Above picture: Chart 2 of pure P control

P Figure (initially 600) describe
0.01 Insert image description here The set value is 200, which is the green line. Can you believe it? This time P0.01, the motor can rotate, and there is overshoot.
0.05 Insert image description here It’s almost the same as the peak value in the graph above
0.1 Insert image description here The peak value has become lower, this time it is less than 700, while the two pictures above are above 700
0.3 Insert image description here The peak is low again, less than 600
0.5 Insert image description here The peak is low again, less than 500
1 Insert image description here The peak is low again, less than 400
3 Insert image description here

really! PWM is the fundamental core of the entire problem and the initiator of all these strange and bizarre phenomena!

Why can PWM cause this problem? Aren't you curious?

I think: We need to tear up the incremental PID formula. Now go back and take a closer look at the formula of incremental PI:

motor.speed_last_error_R = motor.speed_current_error_R;        //更新每次的差值
motor.speed_current_error_R = (int16)(motor.speed_set_R-motor.speed_R);   //速度当前差值
motor.speed_duty_output_R = motor.speed_duty_output_R+(int16)(motor.speed_P*(motor.speed_current_error_R-motor.speed_last_error_R)+motor.speed_I*motor.speed_current_error_R);

Insert image description here

(A cumulative thing) + (P coefficient × difference of deviations + I coefficient × current deviation) It consists of these two parts.

Now let’s take a look at why the curve of P=0.1, I=0.02, and initial PWM=999 is as ghost as the following:

Insert image description here
If you are not talented, you will be nicknamed: Human MCU! ! !
Now, the first moment the microcontroller executes this code,

  • With K=1,
    define the variable name: motor.speed_last_error_R, in the code we do not assign an initial value, so the initial value of the variable is set to 0 by default motor.speed_last_error_Rin C language ; the wheel does not rotate initially, so the initial value of the wheel speed is 0; set value Give: 200; if the initial PWM is 999, the initial value of the variable is 999; when the microcontroller executes this code for the first time, =0, =200-0=200, =999+0.1×(200-0)+0.02 ×200=999+20+4, it is >999, we have limited amplitude, so =999.motor.speed_last_error_R


    motor.speed_duty_output_R

    motor.speed_last_error_R
    motor.speed_current_error_R
    motor.speed_duty_output_Rmotor.speed_duty_output_R


  • The second moment of K=2
    motor.speed_last_error_R microcontroller =200,
    motor.speed_current_error_R=200-999=-799,
    motor.speed_duty_output_R=999+0.1×(-799-200)+0.02×(-799)=999-99.9-15.98=883.12


  • The third moment of K=3
    motor.speed_last_error_R microcontroller =-799,
    motor.speed_current_error_R=200-883.12=-683.12,
    motor.speed_duty_output_R=883.12+0.1×(-683.12+799)+0.02×(-683.12)=883.12+11.588-13.6624=881.0456

  • ...
    Count 8 moving. According to the current calculation trend, if nothing unexpected happens, the speed of the wheel should eventually converge to the set speed of 200, which is indeed consistent with the curve and consistent with the actual situation. From the beginning of the wheel Turn violently, and then the wheel speed stabilizes at 200. Everything makes sense!

Now, we set the initial PWM to 0, the initial wheel speed to 0, and the increment range to 200.
Friends who still have enough brain cells can personally calculate the PWM of the first moment, the second moment and the third moment of the microcontroller when the initial PWM is 0. Here I have already overloaded my pig brain and will not count it. I will just say it briefly. one time:

We know that when the microcontroller executes this code for the first time, motor.speed_duty_output_Rthe initial value is 0, motor.speed_last_error_Rwhich is the default value of 0 and motor.speed_current_error_Rthe set value - the real value is 200. Then motor.speed_P*(motor.speed_current_error_R-motor.speed_last_error_R)the value of this sentence is: when P is 2, it is 400 , when P is 5, it is 999, when P is 10, it is still limited to 999. Therefore, the microcontroller motor.speed_duty_output_Rwill be assigned a value of 400 at the first moment (I take P as 2 as an example), so we see that when P is 5 (That is, PWM is 999), the curve responsiveness is higher than when P is 2, and when P is 10, the curve responsiveness is lower than when P is 5 (because the original 2000 was cut to 999). I is multiplied by 200 motor.speed_current_error_Rfor the first time motor.speed_current_error_R, and the value of the deviation will become smaller and smaller later motor.speed_current_error_R. If the I parameter is relatively large, then the intensity of each adjustment will be relatively large, so we see that the static difference becomes larger. The I parameter changes from small to medium. The larger I can reduce the static difference, the I parameter changes from medium to large. The larger I is, the larger the static difference will be. Finally, the static difference will be large enough to oscillate.
…To Be Continued…

Guess you like

Origin blog.csdn.net/fangchenglia/article/details/109550178