Research on Intelligent Control System of Thermal Print Head Based on FPGA

Thermal print head heating realtime temperature fluctuations are too large, often causing damage to the print head heating point, resulting in poor print quality and unsatisfactory print results. Therefore, in order to improve the stability of the thermal print head during printing, and at the same time solve the inefficiency of the traditional single chip microcomputer control of the thermal print head heating method, a field programmable gate array (FPGA) based thermal print head heating control method is proposed. In order to control the core, the intelligent fuzzy PID control algorithm is used to ensure that the temperature of the print head can be stabilized quickly. Through simulation and experimental verification, it is shown that the intelligent fuzzy PID control algorithm greatly improves the temperature stabilization effect, and the time required to reach stability short, not only improve the printing accuracy, but also extend the life of the print head.

With the maturity of mobile Internet, Internet of Things, cloud computing and big data technologies, the manufacturing field will have advanced capabilities to collect, transmit and process big data, which will enable the manufacturing industry to form an industrial Internet and drive the subversion and reconstruction of traditional manufacturing.A new round of industrial revolution has hit.Industry 4.0 in Germany refers to the use of the Internet of Things information system in the production of supply, manufacturing, and sales of information data and intelligence, and finally to achieve rapid, effective, and personalized product supply.The concept of "Made in China 2025" was immediately put forward.
With the support of "Made in China 2025", industrial technology has also continued to develop and innovate, and the industry has become more and more intelligent.Faced with more and more detailed work divisions and products, industrial label printers are entering at an unprecedented speed.In our work, we will become an indispensable helper now and even in the future.The so-called industrial label printer means that it does not need to be connected to a computer.The printer itself carries an input keyboard or smart touch screen operation.It has built-in certain fonts, character libraries and a considerable number of label template formats.It can be directly based on your needs through the LCD screen of the body It is a printer for industrial use that inputs, edits, and typesets label content, and then directly prints out at high speed.
But the core part of the industrial label printer is the control of the print head.The traditional label printer is mainly controlled by a microprocessor.By heating the dots on the print head, the carbon ink on the ribbon is attached to the label to form a text image, can only meet simple attribute labeling, classification, identification, etc., and ensure the requirements of cleanliness, simplicity, efficiency and flexibility, but do not have the conditions for industrial use.If ordinary label printers print for a long time, they will cause various problems.There are more and more print quality problems, such as: the printed text is skewed, the printed handwriting is blurred when it is clear, the damage of the print head, the shift of the ribbon label, etc., will affect the actual use experience 错误！未找到引用源。 .With the improvement of industrial level, the continuous development of science and technology, the industry is becoming more and more intelligent, and the use of intelligent PID controllers is more and more widely used.In the face of more and more detailed work division and products, industrial label printers can complete to classify and identify products, traditional label printers mainly use ARM as the control core, and mostly use software to implement PID control algorithms.Printing speed and accuracy are limited, which can't effectively solve the technical problems of real-time and synchronization in highspeed data transmission [2] , can't meet the rapid and largescale and continuous output of the industry.
Compared with ARM, FPGA has an extremely important position in the field of data processing.FPGA has the advantages of high clock frequency, small internal delay, pure hardware parallel control, fast operation speed, flexible programming configuration, short development cycle, strong anti-interference ability, and rich internal resources.It is very suitable for real-time high-speed data transmission and processing [3] .
In response to the above problems, this paper proposes an FPGAbased intelligent control PID algorithm for heating the print head control system.The fuzzy PID controller is implemented by FPGA, and the data processing is completed by the hardware circuit running in parallel.The data flow is reasonably controlled and coordinated in each module.In order to achieve the purpose of real-time and high-speed driving of the thermal print head, it can be better used in industrial label printers to ensure the stability, reliability and efficiency of industrial label printers.
Through the simulation experiment of fuzzy PID control algorithm, compared with the traditional PID control thermal print head, it is found that fuzzy PID algorithm shortens the control time and reduces the overshoot, and the system is more stable.The fuzzy PID data obtained by MATLAB simulation is realized by FPGA, and the correct simulation data is obtained.The first chapter of this article is a brief introduction to the research background and the work done, the second chapter is an introduction to the thermal print head, the third chapter is the system hardware control scheme design, the fourth chapter is the fuzzy PID controller design, and the fifth chapter is FPGA implementation of fuzzy PID control algorithm, Chapter 6 is experimental waveform simulation, Chapter 7 is a summary of the full text.

II.THERMAL PRINT HEAD
The main control thermal print head is abbreviated as TPH (Thermal Print Head), which is mainly composed of heat sink, ceramic substrate, driver IC, and flexible circuit interface board.The ceramic substrate contains printed dots, and epoxy resin glue fixes the circuit board to the ceramic substrate and is combined with the printed dots.The flexible circuit interface board is the external circuit interface of the thermal print head  The basic principle is that the resistance of the heating element is formed into a plurality of heating points in a linear configuration on an insulating substrate, and the heating points are selectively energized and heated according to the printed information.When the dielectric coating encounters these components, in a very short time the temperature will rise, and the dielectric coating will undergo a chemical reaction, showing color, thus forming the desired text [4] .

A.THE OVERALL STRUCTURE OF THE SYSTEM
The overall structure of the FPGA-based thermal print head control system is shown in Figure 2 below.The ARM processor is the main control core and sends data to the FPGA through the EIM bus.The EIM bus is a parallel data bus interface and is mainly used to perform data with peripheral memory.
Transmission, asynchronous communication with the peripheral FPGA can be realized through the EIM bus.The EIM module inside the FPGA is the interface sent from the ARM end to control the sending and receiving of data; the clock module is used to synchronize the system clock; the fuzzy controller formulates fuzzy control rules and performs fuzzy inference, and adjusts the PID parameters; the PID control module then The STB strobe signal that controls the heating of the thermal print head, and then controls the heating time, so that the print temperature of the thermal print head is stabilized within the rated range.The data is distributed to the FPGA through ARM, and the thermal print head is controlled by the FPGA, which can ensure the real-time performance of the print data.Compared with the direct control of the thermal print head through ARM, its high-precision printing resolution cannot be met, and the dynamic response time of the print head will also be extended, which does not meet the printing requirements of industrial label printers.

B.FPGA CONTROL THERMAL PRINT HEAD HARDWARE CIRCUIT
The main circuit for FPGA heating control of the thermal print head is shown in Fig 3 below.The main control chip uses Xilinx's Spartan-7 series XC7S6 chip, which has low power consumption, with 6000 to 10200 logic units, flexible LUT configurable logic, distributed RAM or shift register.It is connected with the highspeed CMOS device 74HCT245, which is an eightway transceiver with an in-phase threestate bus, and is compatible output in both sending and receiving directions.And has easy to cascade output enable input (OE) and send/receive input (DIR) for direction control.OE control output can effectively isolate the bus.The print head model is Toshiba G5141F, the number of heating element points is 1248 points, the dot density is 11.8 points/mm, the printing width is 105.7mm, the STB1 and STB2 control 1248 point strobe signal, and DATA_IN1-5 controls each point of the print head data input.
The working principle of print head heating is as follows.First, there is a shift register inside the thermal print head, which can store 1248 bits of data.Under the control of the clock signal, the data is shifted into the shift register bit by bit.When all the data in a row is shifted in, latch is the lock Save the signal, latch the data, and then start the heating, strobe is the strobe signal, and low is the strobe time for opening the print data.At this time, the heating logic is controlled according to the input data_in data is 1 or 0, and the print is generated.a little row of data.

IV.INTELLIGENT MATHEMATICAL MODEL OF THERMAL PRINT HEAD TEMPERATURE CONTROL SYSTEM
By referring to the thermal print head data sheet, the print head temperature has the following relationship with the thermistor: Among them, R is the thermistor; R is the resistance at room temperature25℃, 30 ; B is a constant, the range is 3970 ± 80; T is the temperature required when the print head is heated.
Therefore, combined with the change rule of the thermal print head and the thermistor, the temperature change curve of the thermal print head is shown in Fig 4 below.From the perspective of its curve shape, the curve is similar to the "S" shape [5] .It can be judged that the mathematical model of the thermal print head temperature control system can be approximated by the combination of the firstorder inertial link and the delay link.The expression is as follows: The values of K, T and τ can be calculated by the following formula: Among them, (∞) is the stable value of the system step response, is the input value, t and are the selected two moments.Thus we can get K=0.7,T=60, τ=5.
Therefore, the temperature control system model of the thermal print head is: (4)

A.PARAMETER DESIGN OF CONVENTIONAL PID CONTROLLER
The conventional PID controller has a clear structure, convenient parameter adjustment, and strong robustness.At this stage, PID controller parameter tuning methods are mainly theoretical calculation tuning and engineering tuning.Engineering tuning methods include Ziegler-Nichols tuning method, critical ratio method, attenuation curve method, etc In this paper, the Ziegler-Nichols tuning method is used to calculate the PID parameters of the thermal print head temperature control system.According to the empirical tuning formula, the PID initial parameters can be obtained as Kp=20.5,Ki=0.26,Kd=2.

B.DESIGN OF FUZZY PID CONTROLLER
Fuzzy PID control algorithm is an intelligent control algorithm combining fuzzy controller and traditional PID Fuzzy PID control thermal print head heating control system is shown in  The conventional PID controller has a clear structure, convenient parameter adjustment, and strong robustness.At this stage, PID controller parameter tuning methods are ering tuning.Nichols tuning method, critical ratio method, attenuation curve method, etc [6] .
Nichols tuning method is used to calculate the PID parameters of the thermal print head erature control system.According to the empirical tuning formula, the PID initial parameters can be obtained as , Kd=2.5.Then build a simulation model of the system through the visual simulation tool in MATLAB.
The simulation results are shown in Fig 6 below.From the curve, it can be seen that the overshoot is as high as 50% and s.Obviously, this parameter cannot meet the temperature control requirements of the thermal print head of the industrial label printer.Therefore, a fuzzy controller is introduced to adjust the PID control.

ation diagram of conventional PID control.
Fuzzy PID control algorithm is an intelligent control algorithm combining fuzzy controller and traditional PID [7] .Fuzzy PID control thermal print head heating control system is shown in  Then, 49 control rules are established to perform real detection and calculation on the output signal of the control system to obtain a fuzzy set of output.For example: "If the temperature of the print head is much lower than the set value, and the temperature rises faster, the heating is faster, that is, the duty cycle of the control signal is increased."The relationship between the control rule table is "if E is NB and EC is PS, then Kp is PS, Ki is NS, Kd is NS".Afterwards, new conclusions are inferred from the known fuzzy rules through the Mamdani fuzzy inference method.control rules corresponding to Kp, Ki, Kd are shown in Tables 1, 2, and 3:  Then, 49 control rules are established to perform realtime detection and calculation on the output signal of the control system to obtain a fuzzy set of output.For example: "If the temperature of the print head is much lower than the set value, and the temperature rises faster, the heating is faster, , the duty cycle of the control signal is increased."The relationship between the control rule table is "if E is NB and is NS".Afterwards, new conclusions are inferred from the known fuzzy rules uzzy inference method.The fuzzy control rules corresponding to Kp, Ki, Kd are shown in Finally, deblurring the fuzzy value.The function of defuzzification is to convert the fuzzy quantity into an accurate quantity.It is to clarify the fuzzy control quantity obtained through fuzzy inference and transform it into an accurate quantity that can be used in the controlled system.Accurate scale conversion.It becomes the actual control amount.The conversion from blur to sharpness can use the center of gravity method, the weighted average method, the maximum degree of membership method, etc.
The method used in this paper is the center of gravity method, which calculates the weighted average of each element in the fuzzy output and its corresponding membership degree, and transforms into control variable acting on the control object by a proportional factor.Theoretically, the center of gravity of continuous points within the range should be calculated [8] , and the calculation formula is: But it actually calculates the center of gravity of all sampling points in the output range, which is equivalent to discretizing the above formula.In this way, the amount of calculation can be saved, namely: In the formula, is the exact value of the fuzzy variable.Similarly, we can draw: The design of fuzzy PID controller is carried out in MATLAB, and the thermal print head control system model is built by Simulink for algorithm simulation and verification.The simulation model is shown in   Analyzing the simulation results of Figure 6 and Figure 10, the results are shown in Table 4 below: From the above conclusions, it can be seen that the overshoot of fuzzy PID control is small, the control is more sensitive, the speed of stabilization is faster, and the control effect is more ideal.Therefore, the fuzzy PID control algorithm applied to the thermal print head has a better performance improvement.From the above conclusions, it can be seen that the overshoot of fuzzy PID control is small, the control is more sensitive, the speed of stabilization is faster, and the control effect is more ideal.Therefore, the fuzzy PID control algorithm applied to the thermal print head has a better

VI.TEST IMPLEMENTATION OF FUZZY PID CONTROLLER FPGA
Two methods can be used to implement fuzzy PID control in FPGA: one is to directly implement the fuzzy PID algorithm through hardware.This method is complex in design and consumes too much hardware resources.The other is to use MATLAB simulation design to obtain the fuzzy rule control table, and then The fuzzy PID control is realized through the table lookup method.In order to save hardware resources, this article uses the second method to achieve.Therefore, the control system is mainly composed of a de module, a fuzzy quantization module, a fuzzy lookup table, a fuzzy inference module, and a PID module, and completes the corresponding functions in the form of pipeline.

A. DEVIATION GENERATION MODULE
The formula of the incremental PID cont is: ( ) = ( − 1) + ( ) + ( − Incremental PID control algorithm only needs to calculate the increment, there is no accumulation item, and the output control increment is only related to the last three sampling values.When there is a calculation error or the accuracy is not enough, its influence on the calculation of the control quantity is small.Therefore, this article uses incremental PID control algorithm to calculate the deviation. The error generation module generates three deviation values e(k), e(k-1), e(k-2).It is obtained by subtracting the actual output value from the temperature setting value of the thermal print head, e is the deviation value, ec is the deviation rate, and e0, e1, and e2 correspond to the above deviation values, respectively.

B. FUZZY QUANTIZATION MODULE
The thermal print head temperature deviation and the deviation amount is an accurate amount, and the fuzzy inference system needs to fuzzify the accurate amount,

IMPLEMENTATION OF FUZZY PID
Two methods can be used to implement fuzzy PID control in FPGA: one is to directly implement the fuzzy PID algorithm through hardware.This method is complex in design and consumes too much hardware resources.The other is to use o obtain the fuzzy rule control table, and then The fuzzy PID control is realized through the table lookup method.In order to save hardware resources, this article uses the second method to achieve.Therefore, the control system is mainly composed of a deviation generation module, a fuzzy quantization module, a fuzzy lookup table, a fuzzy inference module, and a PID module, and completes the corresponding functions in the form of pipeline.

EVIATION GENERATION MODULE
The formula of the incremental PID control algorithm ( − 1) + ( − 2).Incremental PID control algorithm only needs to calculate the increment, there is no accumulation item, and the output control increment is only related to the last three sampling is a calculation error or the accuracy is not enough, its influence on the calculation of the control quantity is small.Therefore, this article uses incremental PID control algorithm to calculate the deviation.
The error generation module generates three adjacent 2).It is obtained by subtracting the actual output value from the temperature setting value of the thermal print head, e is the deviation value, ec is the deviation rate, and e0, e1, and e2 correspond ove deviation values, respectively.
The thermal print head temperature deviation and the deviation amount is an accurate amount, and the fuzzy inference system needs to fuzzify the accurate amount, The division here is just to generate the following address codes to facilitate the design and use of subsequent memory.

C. FUZZY LOOKUP TABLE
Encode the divided discourse domain to generate the address of the lookup table.In this study, the discourse domain is divided into 13 segments, using 4bit binary coding, E and EC form an 8bit address, the first four bits of the address are E, address The last four digits are EC, the quantified E and EC, the fuzzy input domain is discrete, and the number is limited.The model of fuzzy logic function established in MATLAB is input to the fuzzy for different E and EC combinations.The corresponding Kp, Ki, Kd are found in the inference module.The following table 5 shows the quantized value corresponding to the input:  The simulation diagram of the deviation generation module is shown in Figure 11 above, where rt is the system setting value and yt is the actual output value of the system.Observing the waveform shows that the module meets the design requirements.
According to the division of the universe of discourse segments and the corresponding quantized values shown in Table 5, when the input deviation E is 30, the corresponding domain of discourse is [27, 30], and the corresponding quantization value is 1100; It is 25, the corresponding domain segment is [22, 27], the corresponding quantization value is 1011, and the combined output address is 11001011.From the simulation diagram in Figure 12, it can be seen that the program design is correct and the correct fuzzy quantization is achieved and combined address function From the simulation result of the fuzzy inference module in Figure 13, it can be seen that the appropriate output can be output in time for the input E and EC.When the input E is 30 and EC is 25, the three parameters of Kp, Ki, and Kd are 60, 15, and 10.The corresponding quantized value and address are also correct, which meets the design requirements of the fuzzy controller.
From the simulation results shown in Figure 14 above, it can be seen that the output u_out follows the five input changes of Ki, Kp, Kd, rt, and yt.According to the previous analysis, the output results are analyzed and verified, and the output is controlled according to the incremental PID.The algorithm formula can be calculated: u = 15 × 40 − 20 × 40 + 15 × 40 = 400 u = 5 × 37 − 10 × 37 + 10 × 37 = 185 The above-mentioned calculated data is consistent with the FPGA simulation result, so the realization procedure of the designed fuzzy PID control algorithm is correct.

VIII.CONCLUSION
The thermal print head is the most critical part of the printer.Various websites and literatures have very few control designs for the thermal print head, especially the FPGA to control the thermal print head, but in real society, the control of the thermal print head must maintain a high degree of realtime and highprecision control.Therefore, this paper introduces the research of FPGAbased thermal print head control system in detail in combination with the actual industrial label printer.By using the fuzzy PID control algorithm, the temperature control of the thermal print head is effectively improved, which has a high reference value.
5. Then build a simulation model of the system through the visual simulation tool in MATLAB.The simulation model is shown in Fig 5 below:

FIGURE 5 .
FIGURE 5. Conventional PID control simulation model

FIGURE 6 .
FIGURE 6. Simulation diagram of conventional PID control.
Fig 7 below.The establishment of fuzzy PID controller includes 4 steps: fuzzy processing of input signal, establishment of fuzzy controller rules, fuzzy reasoning and defuzzification operation of output signal.
EC of the thermal print head are two inputs of the fuzzy controller.The deviation amount can be derived from the set input value and the actual value, and then the deviation change rate can be calculated according to the two deviation amounts.The output of the fuzzy controller is the three parameters Kp, Ki, Secondly, according to the fuzzy control expert experience method, formulate corresponding fuzzy rules, fuzzify E, EC, Kp, Ki, Kd, and take the domain of the input quantity[-6, 6]; set the output control quantity Kp according to experience, 0.3, 0.3],[-6, 6]; the fuzzy sets of input and output variables are recorded as {NB, NM, NS, ZO, PS,PM, PB}, E, EC use triangular membership on, Kp, Ki, Kd are Gaussian membership functions.As Fig 9 below:

FIGURE 2. The overall structure of the system.
This article has been accepted for publication in a future issue of this journal, but it is not yet the definitive version.Content may undergo additional typesetting and review before the final publication., Matthew Haner, Research on Intelligent Control System of Thermal Print Head Based on FPGA and Technology(2021), DOI: https://doi.org/10.37965/jait.2020.0044 Research on Intelligent Control System of Thermal Print Head Based on FPGA,

TABLE Ⅴ
THE QUANTIZED VALUE CORRESPONDING TO THE INPUT