Hardware:
1。 A 200W heating wire, controlled by SCR, heats an iron block, collects the temperature with K-type thermocouple, and converts the temperature with MAX6675, which can reach 0. The accuracy is 25 degrees, the periphery is very simple, and it is easy to connect with CPU. Read the current temperature value by SPI communication.
2。 The zero-crossing detection circuit controls the NPN tube with the waveform obtained by full-wave rectification of AC signal, shapes the signal and connects it to the external interrupt pin of CPU to provide reference time for the system, so the interrupt frequency of CPU is 100HZ.
Experimental objectives:
The temperature can be kept constant at any set temperature from 100 to 200 degrees, and the accuracy should be +/- 1 degree at first.
Basic control implementation method:
Because it controls the temperature of the heated iron, it belongs to the lag effect system, so the sampling period is set to 5 seconds (here refers to the period of PID calculation, pay attention to my temperature sampling), so the number of external interrupts of the CPU is 500 times, and the corresponding PID calculation result output is 0~500, that is to say, these 5 seconds are divided into 500 equal parts, according to the calculation result, how many equal parts should be heated in these 5 seconds.
Software:
Adopting PID control mode, I first adopt position output mode, and the prototype of the formula is: u (t) = KP * e (t)+ki * [e (1)+e (2)+...+e (t)]+KD * [e (t)-e (t-6544) In order to improve the heating speed, I will start PID temperature control 20 degrees in advance.
The following is the process and data of adjusting parameters:
Referring to some methods on the Internet, we first determine Kp, that is, Ki and Kd=0, and get a stable oscillation parameter that is closer to the control target through proportional adjustment, and then calculate Ti and Td according to this Kp and oscillation period.
From the data point of view, the oscillation period is basically 48~43 points, each point is 5 seconds, so the oscillation period is 225 seconds.
Next, calculate the table according to the following typical parameters:
Ziegler-Nichols parameter
Controller kptititd
P 0.50*Kc / /
PD 0.65*Kc / 0. 12*Pc
PI 0.45*Kc 0.85*Pc /
PID 0.65*Kc 0.5*Pc 0. 12*Pc
I'll do PD experiment first:
According to the critical gain KC=9.2, oscillation period Pc=225 seconds, Kp=5.98, Td=27 seconds, and the formula Kd=Kp*Td/T=5.98*27/5=32.392.
Looking forward to the experimental results. . .
From the analysis of image data, the final stable temperature is: 109 degrees, with a fluctuation of 0. 5 degrees, and my target temperature is 1 10, which means that a stability error of 2 degrees is introduced here.
An integral regulator is needed to eliminate this steady-state error.
Calculate Ti= 1 12.5 seconds, according to the formula: ki = KP * t/ti = 5.98 * 5/12.5 = 0.265.