1. Heating Principle of the T12 Soldering Iron Tip
The T12 soldering iron tip has fast heating speed and accurate temperature control. The very front of the heating core is the temperature measurement part. Its design is quite ingenious. The heating wire is made of one material, while the middle wire is another MATERIAL. The junction is the thermocouple, which is also the temperature measurement point. The heating wire itself serves as both the heating element and the working of the thermocouple.
during practical use, we can apply PWM voltage to the two ends of the soldering iron. In this project, an STC8H1K17 single-chip microcomputer generates a PWM wave with a certain frequency and duty cycle, which is output as a signal to a triode. The triode functions as a switch. When the T12-PWM is at a positive voltage, VBUS and T12-OUTPUT are conducted, and a voltage of (5 - 20V) can be output to the soldering iron tip. The frequency and duty cycle of the output voltage are the same as those of T12-PWM. The (5 - 20V) output voltage is provided by a PD charger.
2. Temperature Measurement Principle of the T12 Soldering Iron Tip
A thermocouple is a temperature-sensing element. It measures the temperature and converts the temperature signal into a thermoelectromotive force signal, which is then converted into the temperature of the measured medium by an electrical instrument. The basic principle of thermocouple temperature measurement is that a closed loop is formed by two conductors of different compositions. When there is a temperature gradient at both ends, a current will flow through the loop, and there will be an electromotive force - the thermoelectromotive force between the two ends. This is the so-called Seebeck effect. The two homogeneous conductors of different compositions are the thermoelectrodes, with the higher temperature end being the working end and the lower temperature end being the free end.
Through analysis, we can see that the heating wire itself is both the heating element and the working end of the thermocouple. Therefore, the T12-OUTPUT end connected to the positive pole of the soldering iron is also the thermocouple end. By collecting the voltage at the T12-OUTPUT end, the temperature of the soldering iron tip can be calculated. At this point, someone may ask: Isn't the voltage at the T12-OUTPUT end (5 - 20V)? How could it be a thermoelectromotive force? Indeed, but don't forget that the voltage at the T12-OUTPUT end is a PWM wave. Theoretically, when the PWM voltage of the single-chip microcomputer is 0 V, the voltage at the T12-OUTPUT end should also be 0. However, due to the thermoelectromotive force, there will be a weak voltage, which is the voltage we need for temperature measurement. This voltage is too small to be measured by the ADC function of the single-chip microcomputer, so an operational amplifier is required for amplification.
3. Temperature Control Principle of the T12 Soldering Iron Tip
PID (Proportional-Integral-Derivative) control is a classic control algorithm, often used in industrial control systems, including temperature control. The following is a detailed explanation of the PID temperature control principle:
• Proportional Control: Proportional control is a method of adjusting the heating power according to the difference between the current temperature and the set temperature. The controller outputs a control quantity proportional to the error (the difference between the actual temperature and the set temperature). If the error is large, the output control quantity is large, and the heating power increases accordingly; if the error is small, the output control quantity is small, and the heating power decreases accordingly. The advantage of proportional control is its fast response speed, but it may cause relatively large temperature fluctuations.
• Integral Control: Integral control is introduced to solve the problem of static deviation that may be caused by proportional control. The integral controller outputs a control quantity according to the accumulation of the error over time, which can gradually eliminate the static error. When the temperature continuously deviates from the set value for a period of time, the integral control will increase the control quantity to reduce the deviation. The advantage of integral control is that it can eliminate static errors, but its response speed is slow and may cause system overshoot or oscillation.
• Derivative Control: Derivative control is introduced to improve the dynamic response of the system. The derivative controller outputs a control quantity according to the rate of change of the error, so that it can predict the trend of temperature change and adjust the heating power. When the rate of temperature change is large, the derivative controller will increase the control quantity to slow down the temperature change rate. The advantage of derivative control is that it can improve the dynamic response of the system, but it may increase the system's sensitivity to noise.
Combining the functions of the proportional, integral, and derivative parts, the output control quantity of the PID controller can be expressed as:
Among them, u(t) is the output control quantity, e(t) is the current error, and K_p, K_i, and K_d are the proportional, integral, and differential coefficients respectively. The PID controller calculates the output control quantity based on the current error, the integral of the error, and the rate of change of the error, thus achieving precise temperature control.
In the T12 soldering iron tip, the PID control algorithm monitors the output of the temperature sensor, calculates the difference between the current temperature and the set temperature, and adjusts the heating power according to this difference to achieve precise control of the soldering iron tip temperature.
4. Main Programs and Functions
• Temperature Measurement Programs
• Temperature Fitting Function temp_fitting: Through a fourth-order polynomial fitting of the voltage output by the ADC, it converts the voltage output by the thermocouple into the corresponding temperature value. It returns the fitted temperature value.
• Filtering Function: This function realizes the filtering of the ADC sampling values of the thermocouple output. Filtering method: Filter Num times, remove b maximum and minimum values, and then calculate the average of the remaining values. It returns the amplified thermoelectromotive force value of the filtered thermocouple.
• Heating Program
Each time a Timer0 interrupt occurs, this function is executed. By controlling the PWM_Duty variable, the PWM output is controlled, thus controlling the heating intensity of the heater. The heating control operation is executed once every 200 ms. According to the difference between the actual temperature and the desired temperature, as well as some threshold conditions, the PWM duty cycle is adjusted to control the heating behavior of the heater. If the actual temperature exceeds a certain threshold (470) or exceeds the desired temperature, the PWM duty cycle is set to 0. If the temperature deviation is greater than 50, the PWM duty cycle is directly set to 80. If the temperature deviation is between 30 and 50, the PID function is called for heating control, and the parameters of the PID control are adjusted according to the size of the temperature deviation. If the temperature deviation is less than or equal to 30, the PID function is called for heating control without parameter adjustment.
• Another Temperature Measurement Program
K_p, Ti, T, Td: PID control parameters, representing the proportional parameter, integral time, sampling time, and differential time respectively. Ek_1, Ek_2: The previous and the previous previous deviation values. uk: The current output value. actual\_temp: The current temperature. expect\_temp: The desired temperature value. Parameter E: The current temperature value, parameter K: The desired temperature value, parameter mode: Mode selection, 1 represents the aggressive mode, and 0 represents the standard mode. Return value Output: The adjusted PWM duty cycle. Calculate the current deviation Ek = E - K. Use different PID parameters according to the mode selection, calculate the increment duk. Update the uk value and perform saturation processing. Update the deviation values Ek_1 and Ek_2. Calculate the output value Output and return it.
Summary: This code implements a heating control system based on the PID control algorithm, which can dynamically adjust the heating intensity of the heater according to the difference between the actual temperature and the desired temperature, so as to achieve stable temperature control.