Paradox between power control accuracy and time delay accuracy of zero-crossing switch
[Copy link]
This post was last edited by shipeng on 2020-7-22 11:04
I have been using PID temperature control for almost 4 years, and there is a problem that has been bothering me until now. I used to think that this problem was a paradox and that I could only find a delicate balance of gains and losses without any solution, but I was wrong. Not long ago, I suddenly found the answer in my dream in the early morning. The specific problem is: "There is an adjustable temperature control device (actually a hot air desoldering station) with a temperature range of 100~500 degrees Celsius, and the temperature control accuracy is required to be within ±1℃."
According to the above problem description, since the only way to control the temperature is to control the average heating power P within the unit time T, assuming that the power supply voltage remains unchanged, the size of the heating duty cycle D determines the temperature value of the constant temperature. This can be obtained that the temperature and the heating duty cycle D are in a one-to-one correspondence. 100~500 degrees requires at least 1/400 of the power control accuracy, but in fact, since the frequency of the mains is only 50Hz and zero-crossing switching is required, the minimum power control accuracy is half of the mains cycle th=10ms. According to "P=D*heating wire saturation power/400", the 1/400 accuracy corresponds to the duty cycle: 400*10ms=4 seconds, which is simply intolerable for controlling hot air, a medium with a small specific heat. You will find that no matter how you adjust the PID parameters, you can never achieve constant temperature. Of course, if the AD resolution of the collected temperature is high enough, you don't need such a high power resolution. You can make power compensation in advance when the temperature is still changing within 1 degree so that the temperature always fluctuates within 1 degree, which can also meet the requirements. After experimenting, I found that the power accuracy can be reduced to 1/50 at the lowest. At this time, the heating cycle T=50*10ms=0.5 seconds, but the naked eye can still clearly see the red and dark alternation of the heating wire. It may be due to the hysteresis of the temperature-collecting thermocouple that the actual AD is stable. If the temperature is measured by a thermocouple thermometer, it is also stable. The above is my solution four years ago, but the problem of the red and dark alternation of the heating wire made me uncomfortable.
Until I saw a hot air temperature control product made by a large manufacturer, the red and dark alternation of the heating wire was almost invisible to the naked eye under the premise of ensuring temperature control accuracy. I knew there was another way out of this problem, so I began to seek this ultimate solution and had the moment of inspiration mentioned above. This idea is simple: as shown in the figure below, if the duty cycle period T is 10 half cycles of the mains power, and the duty cycle D=5, the usual control idea is as follows:
Each time it is turned on for 5 and a half cycles, it will be turned off for 5 and a half cycles. If the power control accuracy is 1/50, it will be: 250ms to turn on the heating, and 250ms to turn off the heating. This will of course cause short-term fluctuations in the hot air temperature. The ultimate solution is this: break up the ON and OFF in the above figure and let them mix fully to get the effect of you in me and me in you:
The overall effect is that the power supply is turned on for 5 half cycles and off for 5 half cycles, that is, the duty cycle is still 5/10. Of course, 5/10 is a special case. What should be done if the power accuracy of 1/50 has a duty cycle of 27/50? It can be understood as 27 turns on and 23 turns off. 27/23 is equal to 1 with a remainder of 4, that is, the turn on and turn off are 1:1 with a remainder of 4, that is, after one turn on, there is one turn off, but after 23 switching cycles, there are still 4 turns on and not turned on. What should be done? The solution is to disperse these 4 turns on into the 23 switching cycles: that is, 23/4=5 with a remainder of 3. Now the remainder can be ignored. The final output result is to insert one more ON every 5 ONOFF cycles, so that the maximum dispersed duty cycle of 27/50 can be obtained. Of course, words are not enough. In order to intuitively verify this solution, a good method for verifying the algorithm is introduced: use Microsoft Visual Studio to verify and print out the experimental results:
Experiment code:
Achieve decentralized duty cycle control effect with 1/100 power resolution:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main(void)
{
for (uint8_t heat_duty = 0; heat_duty <= 100; heat_duty++)
{
uint8_t i, j, k, l, m, sub_t, pos_nag,on_cycles=0,off_cycles=0; _Bool HEAT1ON_A;
i = heat_duty;
if (i > 50) { j = 100 - i; pos_nag = 1; }
else { j = i; i = 100 - j; pos_nag = 0; }
sub_t = i == 0 || j == 0 ? 100 : i / j + 1;
l = j != 0 ? i % j : 1; if (l == 0)l = 1;
for (uint8_t period = 0; period < 100; period++)
{
k = period; m = k / (j / l * sub_t + 1);
m = j==0 ? 0 : m > l ? k - l : k - m;
HEAT1ON_A = m % sub_t == sub_t >> 1 ? !pos_nag : pos_nag;//k < j* sub_t && k % sub_t == sub_t >> 1 ? !pos_nag : pos_nag;//
if (HEAT1ON_A)on_cycles++;
else off_cycles++;
printf(HEAT1ON_A!=0?"*":"-");
}
if (heat_duty!=on_cycles || on_cycles+off_cycles!=100)printf("%d,%d/%d\n", heat_duty,on_cycles,off_cycles);
else printf("\n");
}
return 0;
}
Operation result: ('*' means on, '-' means off)
Duty cycle 0~50
Duty cycle 51-100
After the above verification, it is found that there is no problem in logic and the decentralized hybrid switch effect of any duty cycle within 0-100 can be achieved, but the actual temperature control effect is not satisfactory, and the temperature is not as stable as the original non-dispersed one. This face slap really caught people off guard. With a rigorous attitude of seeking knowledge, we are still slapped in the face by reality. Which expert can come to explain where the problem lies? Here I also give my explanation: It may be because my duty cycle control is updated in real time. I will not wait until the entire duty cycle is over before updating the duty cycle value. Instead, I will recalculate the duty cycle according to the current temperature AD value every time it crosses zero. I think this is the only way to ensure fast response capability, otherwise the load change during heating cannot be responded to in time. However, in the decentralized switch duty cycle control, since the opening and closing are staggered, the adjacent jitter of the duty cycle in a duty cycle cycle may have unexpected effects: the original reduction of heating power will get higher power, which will lead to temperature instability.
|