A calibration method and device for detecting temperature of a thermal printer print head and a thermal printer
By training a BP neural network to generate a calibration neural network model, the problem of low accuracy of thermistors in thermal printers is solved, achieving high-precision temperature detection and improving print quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-23
- Publication Date
- 2026-04-07
AI Technical Summary
In existing thermal printers, thermistors have low precision and low linearity, resulting in inaccurate temperature detection and an inability to meet the requirements for high-quality printing, especially when printing grayscale images, where the print quality is poor and the grayscale level cannot be accurately controlled.
By establishing a BP neural network and using the correspondence between the resistance value of the thermistor and temperature for model training, a calibration neural network model is generated. Software algorithms are then used to calibrate the thermistor, thereby improving the accuracy of temperature detection.
Without increasing hardware costs, the accuracy of temperature detection by the thermistors has been significantly improved, ensuring thermal printing results and meeting the demand for high-quality printing.
Smart Images

Figure CN113673682B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of thermal printing technology, specifically to a calibration method, apparatus, and thermal printer for detecting the temperature of a thermal printer printhead. Background Technology
[0002] Thermal printing technology is increasingly widely used across various industries, including cash registers, restaurants, banks, and express delivery, for printing various documents. In recent years, its applications have expanded from commercial to consumer products, such as student error correction printers and children's cameras, leading to a growing home market. A thermal printer is a device that uses a heating element in the print head to contact thermal paper, causing it to develop color and print the corresponding image.
[0003] Thermal printers all require temperature sensors to detect abnormal temperatures and prevent overheating during continuous printing, which could damage the print head or cause personal injury. With the emergence of products like student error correction printers and children's cameras, the demands for print quality have increased. Therefore, the role of temperature sensors extends beyond protection; they are also used to control print density. Typically, printing on a cold printer results in a lighter print, while continuous printing at higher temperatures produces a darker print. Temperature sensors can be used during printing to obtain the current temperature and compensate for this by adjusting the heating control accordingly, ensuring optimal print quality.
[0004] Currently, thermal printers generally use thermistors for temperature sensors. Thermistors have low accuracy, low linearity, and low cost. They are sufficient for applications with low print quality requirements. However, when high print quality is required, especially for grayscale image printing, the thermistor's accuracy limitations prevent it from accurately capturing the current temperature. Inaccurate or unstable temperature compensation leads to poor print quality and inaccurate control of grayscale levels.
[0005] To obtain accurate temperature, there are generally two methods:
[0006] 1. Replace the temperature sensor in the thermal printer. Common temperature sensing technologies include IC sensors, thermistors, RTDs, and thermocouples. Except for thermistors, the detection accuracy of the other temperature sensing technologies is better than that of thermistors, but their cost is also higher.
[0007] 2. Calibrate the thermistor. Thermistor calibration can be achieved by modifying the hardware circuitry to alter some of its characteristics.
[0008] However, all of the above solutions increase costs to some extent. While it's commonly believed that thermistors have poor accuracy, the actual accuracy of a thermistor depends on calibration.
[0009] In view of this, the present invention is hereby proposed. Summary of the Invention
[0010] To address the aforementioned technical problems, this invention provides a calibration method, apparatus, and thermal printer for detecting the temperature of a thermal printer printhead. The specific technical solution is as follows:
[0011] This invention proposes a calibration method for detecting the temperature of a thermal printer printhead, the calibration method comprising:
[0012] Obtain the resistance value of the thermistor of the temperature sensor at various temperatures, and obtain the corresponding relationship between the resistance value of the thermistor and the temperature.
[0013] A BP neural network is established, and the model is trained using the correspondence between the resistance value and temperature of the thermistor to obtain a calibration neural network model for the thermistor.
[0014] The obtained resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature.
[0015] As an optional embodiment of the present invention, the establishment of the BP neural network includes:
[0016] Define a network structure including an input layer, a hidden layer, and an output layer. The input layer includes at least three input terminals with an input resistance value R. The hidden layer includes at least three neurons, each neuron having a hidden layer input terminal corresponding to the number of input terminals. Each hidden layer input terminal of each neuron is connected to an input terminal of the input layer in a one-to-one correspondence. The output layer includes a neuron that outputs a temperature T.
[0017] As an optional embodiment of the present invention, the establishment of the BP neural network includes:
[0018] Define the activation function f′(x)=y(1-y);
[0019] Forward signal propagation, input layer neurons: input value x i =R, output value y i =x i Hidden layer neurons: input values Output value Output layer neurons: Input values Output value
[0020] The error signal propagates backward, and the output neuron error E,dk The true and correct result is represented by the temperature T in the training data, and the neuron error. weight w kj error amount weight w ji error amount
[0021] Add learning rate η represents the learning rate, which is a number between 0 and 1.
[0022] As an optional embodiment of the present invention, the step of using the correspondence between the resistance value of the thermistor and temperature to train the model and obtain a calibration neural network model of the thermistor includes:
[0023] Parameter initialization: Set the neuron's weight values, error precision e, and training iterations N;
[0024] Import training samples: Import training samples showing the relationship between the resistance value of the thermistor and the temperature into the BP neural network;
[0025] Normalization: Normalize the training sample data;
[0026] Calculation output: According to the forward propagation of the signal from the BP neural network, the normalized data y is calculated. u The data is fed into the neural network as input to calculate the output y of the neurons in the hidden layer. j and the output y of neurons in the output layer k ;
[0027] Calculate the neuron error: Calculate the error Δw of the weight values by backpropagating the error signal of the BP neural network. kj and Δw ji ;
[0028] Update weight values: Based on the error of the calculated weight values, update the weight values w of the hidden layer and the output layer. kj =w kj +Δw kj w ji =w ji +Δw ji ;
[0029] Error accuracy assessment: Determine whether the current error accuracy meets the requirements. If the accuracy requirement is met, training ends. If the accuracy requirement is not met, further determine whether the number of training iterations N has been reached. If the number of training iterations N has been reached, training ends. If the number of training iterations N has not been reached, return to the calculation output and continue training.
[0030] As an optional embodiment of the present invention, the normalization process includes:
[0031] The resistance values of the thermistors input to the input layer are normalized:
[0032] Normalization processing function Where R represents the input resistance data, R min R represents the minimum value among the input resistance data. max This represents the maximum value in the input resistance data, y. u This represents the normalized data;
[0033] The temperature data of the thermistors from the input to the output layer are normalized:
[0034] Normalization processing function Where T represents the input temperature data, T min T represents the minimum value in the input data. max T represents the maximum value in the input data. u This represents the normalized data.
[0035] As an optional embodiment of the present invention, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detected temperature, including:
[0036] The measured resistance value R of the thermistor is fed into the calibration neural network model;
[0037] The input resistance value R is normalized, and the output y of the neurons in the output layer is calculated according to the forward propagation of the calibrated neural network model. k ;
[0038] For output y k The data is restored to obtain the calibrated actual temperature value T.
[0039] As an optional embodiment of the present invention, the step of targeting the output y k The actual temperature value T obtained after data restoration includes:
[0040] Using the data restoration function T = y k ×(T max -T min )+T min For output y k Perform data restoration calculations, where T min and T max The minimum and maximum temperature values are used to train and calibrate the neural network model.
[0041] As an optional embodiment of the present invention, the calibration method for detecting temperature in a thermal printer printhead further includes accuracy verification of the calibration neural network model:
[0042] Using the formula for calculating thermistor Generate the correspondence data between temperature and resistance values within a set temperature range and at a set temperature interval. Input the correspondence data into the calibration neural network model for training to generate a fitting curve. Compare the degree of overlap between the fitting curve and the RT characteristic curve corresponding to the correspondence data between temperature and resistance values to verify the accuracy of the calibration neural network model.
[0043] This invention also provides a calibration device for detecting the temperature of a thermal printer printhead, comprising:
[0044] The data acquisition module measures and acquires the resistance value of the thermistor of the temperature sensor at various temperatures, and obtains the corresponding relationship between the resistance value of the thermistor and the temperature.
[0045] The network model training module establishes a BP neural network and uses the correspondence between the resistance value and temperature of the thermistor to train the model, thereby obtaining a calibration neural network model of the thermistor.
[0046] In the calibration module, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature.
[0047] The present invention also provides a thermal printer, including a temperature sensor and a control system. When the temperature sensor detects the temperature, it inputs the resistance value of the thermistor to a calibration neural network model to output the calibrated detection temperature.
[0048] The calibration neural network model is trained in the following way:
[0049] The resistance value of the thermistor of the temperature sensor is measured at various temperatures to obtain the corresponding relationship between the resistance value of the thermistor and the temperature.
[0050] A backpropagation (BP) neural network is established, and the model is trained using the relationship between the resistance value of the thermistor and temperature to obtain a calibration neural network model for the thermistor.
[0051] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0052] In the temperature calibration method for thermal printer printhead detection of the present invention, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature. This provides a method for calibrating the thermistor through software algorithm, which does not require additional hardware costs and can greatly improve the accuracy of thermistor temperature detection, thereby ensuring thermal printing effect. Attached image description:
[0053] Figure 1 Structure diagram of the BP neural network in this embodiment of the invention;
[0054] Figure 2 The activation function image of the BP neural network in this embodiment of the invention;
[0055] Figure 3 A flowchart illustrating the learning and training process of the BP neural network in an embodiment of the present invention;
[0056] Figure 4 Flowchart of the calibration neural network model in this embodiment of the invention;
[0057] Figure 5 In this embodiment of the invention, a calibration neural network model is used to compare the overlap of calibration error verification curves. Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0059] Therefore, the following detailed description of embodiments of the present invention is not intended to limit the scope of the claimed invention, but merely illustrates some embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0060] It should be noted that, unless otherwise specified, the embodiments and features and technical solutions in the present invention can be combined with each other.
[0061] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0062] In the description of this invention, it should be noted that the terms "upper," "lower," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. These terms are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0063] See Figure 1 As shown, this embodiment provides a calibration method for detecting the temperature of a thermal printer printhead. The thermal printer includes a temperature sensor, and the calibration method includes:
[0064] The resistance value of the thermistor of the temperature sensor is measured at various temperatures to obtain the corresponding relationship between the resistance value of the thermistor and the temperature.
[0065] A BP neural network is established, and the model is trained using the correspondence between the resistance value and temperature of the thermistor to obtain a calibration neural network model for the thermistor.
[0066] When the temperature sensor detects temperature, it inputs the resistance value of the thermistor into the calibration neural network model to output the calibrated detection temperature.
[0067] In the calibration method for temperature detection of the thermal printer printhead in this embodiment, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature. This provides a method for calibrating thermistors through software algorithms, which does not require additional hardware costs and can greatly improve the accuracy of thermistor temperature detection.
[0068] Additionally, it should be noted that a thermistor is a type of sensor resistor whose resistance changes with temperature. Temperature sensors detect temperature based on this physical characteristic of thermistors, calculating the temperature value corresponding to the measured resistance. However, the relationship between thermistor resistance and temperature is not a simple linear one. Therefore, to ensure the accuracy of temperature detection, the measured resistance value should be calibrated to obtain the detected temperature. This embodiment utilizes this physical characteristic of the thermistor in the temperature sensor, training a backpropagation (BP) neural network through numerous temperature-resistance value correspondences until the error accuracy meets the requirements. The resulting calibrated neural network model has higher calibration accuracy for thermistor resistance values, resulting in more precise temperature detection.
[0069] The calibration neural network model in this embodiment is obtained by training a backpropagation (BP) neural network. A BP neural network is a multilayer feedforward network trained using the backpropagation algorithm and is one of the most widely used neural network models. BP networks can learn and store a large number of input-output pattern mappings without needing to reveal the mathematical equations describing these mappings beforehand. Its learning rule uses the steepest descent method, continuously adjusting the network's weights and thresholds through backpropagation to minimize the sum of squared errors.
[0070] The basic idea of a BP neural network is that the learning process consists of two processes: forward propagation of the signal and backward propagation of the error.
[0071] During forward propagation, the input sample is introduced from the input layer, processed layer by layer by the hidden layers, and then transmitted to the output layer. If the actual output of the output layer does not match the expected output (teacher signal), the process then proceeds to the backpropagation stage of the error.
[0072] During backpropagation, the output is propagated back to the input layer layer by layer through the hidden layer in a certain form, and the error is distributed to all units in each layer, thereby obtaining the error signal of each unit. This error signal is used as the basis for correcting the weights of each unit.
[0073] The thermal printer printhead temperature calibration method in this embodiment utilizes a BP neural network to train and generate a calibration neural network model, achieving software algorithm calibration of the temperature sensor's detected temperature values. This method achieves high calibration accuracy without altering the underlying hardware. As an optional implementation of this embodiment, the measurement of the thermistor's resistance value at various temperatures to obtain the correspondence between the thermistor's resistance value and temperature includes:
[0074] Measure the resistance of the thermistor at various temperatures beforehand; the more temperature ranges measured, the better. For thermal printers, a temperature range of -20℃ to 75℃ is suitable. Generally, intervals of 5℃ or 10℃ can be selected, depending on the specific situation. Measuring at intervals of 1℃ or even smaller will yield better results.
[0075] For example, the following table is a sample table:
[0076] Temperature ℃ resistance kΩ 0 100.861811 5 77.773687 10 60.523731 15 47.511443 20 37.605977 25 30.000000 30 24.111422 35 19.516593 40 15.904401 45 13.044411 50 10.764548 55 8.935308 60 7.458494 65 6.259116 70 5.279511
[0077] It should be noted that the temperature-resistance relationship data varies depending on the model of the thermistor in this embodiment. Therefore, this embodiment needs to obtain the temperature-resistance relationship data according to the model of the thermistor, and use this data to train the BP neural network to obtain the calibration neural network model for each model of thermistor.
[0078] As an optional implementation method in this embodiment, see Figure 1 As shown, the establishment of the BP neural network in this embodiment includes:
[0079] Define a network structure including an input layer, a hidden layer, and an output layer. The input layer includes at least three input terminals with an input resistance value R. The hidden layer includes at least three neurons, each neuron having a hidden layer input terminal corresponding to the number of input terminals. Each hidden layer input terminal of each neuron is connected to an input terminal of the input layer. The output layer includes a neuron that outputs a temperature T. The output terminals of all neurons in the hidden layer are connected to neurons in the output layer.
[0080] In this embodiment, to calibrate the temperature detected by the temperature sensor, the BP neural network defines the input layer of the BP neural network as inputting various resistance values R, and the output layer as inputting various temperatures T.
[0081] See details Figure 1 As shown, the BP neural network designed here has three input terminals, each receiving a resistor R. It contains one hidden layer with three neurons, each with three input ports. The output layer contains one output terminal, which outputs the temperature T.
[0082] In a backpropagation (BP) neural network, x represents the input data, y represents the output data, i represents the input layer, j represents the hidden layer, k represents the output layer, and w represents the output layer. ji w represents the hidden layer weights. kj x represents the weights of the output layer. i x is the input value of the input layer. j x is the input value of the hidden layer. k y is the input value of the output layer. i The output value of the input layer, y j y is the output value of the hidden layer. k The output value of the output layer, y k This is the neuron activation function.
[0083] Further, see Figure 2 As shown, the establishment of the BP neural network in this embodiment includes:
[0084] Defining the activation function: Since the data will be normalized later, the sigmoid function will be used as the activation function. f′(x)=y(1-y);
[0085] Forward signal propagation, input layer neurons: input value x i =R, output value y i =x i Hidden layer neurons: input values Output value Output layer neurons: Input values Output value
[0086] The error signal propagates backward, and the output neuron error E,d k The true and correct result is represented by the temperature T in the training data, and the neuron error. weight w kj error amount weight w ji error amount
[0087] Add learning rate η represents the learning rate, which is a number between 0 and 1. The specific value needs to be determined through experimentation based on experience. The learning rate is a configurable hyperparameter used in neural network training. It has a small positive value. For example, a learning rate of 0.1 (the traditionally common default value) means that the weights in the network are updated by 0.1 * (estimated weight error) or 10% of the estimated weight error each time the weights are updated.
[0088] In extreme cases, an excessively large learning rate will cause the weights to be updated too much, and the model's performance (e.g., its loss on the training dataset) will oscillate during the training epoch. This oscillating performance is said to be caused by diverging (spreading) weights. A learning rate that is too small may never converge or may get stuck in a suboptimal solution.
[0089] A high learning rate accelerates learning in the early stages of algorithm optimization, making the model more likely to approach a local or global optimum. However, it can lead to significant fluctuations in later stages, with the loss function hovering around its minimum value, making it difficult to reach the optimal solution. Therefore, the concept of learning rate decay is introduced. Simply put, a large learning rate is used for model optimization in the early stages of training, and then gradually decreased as the number of iterations increases. This ensures that the model does not fluctuate too much in the later stages of training, thus getting closer to the optimal solution.
[0090] We cannot analytically calculate the optimal learning rate for a given model on a given dataset. Instead, a good (or sufficiently good) learning rate must be found through trial and error. The range of learning rates to consider is less than 1.0 and greater than 10^-6.
[0091] The learning rate interacts with many other aspects of the optimization process, and these interactions can be non-linear. However, in general, a smaller learning rate will require more training epochs. Conversely, a larger learning rate will require less training time. Furthermore, considering the noisy estimation of the error gradient, a smaller batch size is more suitable for a smaller learning rate. The traditional default value for the learning rate is 0.1 or 0.01, which may be the starting point for training.
[0092] Based on experience, you can start by experimenting with the following values for η: 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1, ... The initial value of η is 0.001. If it does not meet expectations, multiply it by 3 and replace it with 0.003. If it still does not meet expectations, replace it with 0.01. Repeat this process until you find the most suitable η.
[0093] See Figure 3 As shown in the figure, the calibration neural network model of the thermistor obtained by training the model using the correspondence between the resistance value and temperature of the thermistor in this embodiment includes:
[0094] Parameter initialization: Set the neuron's weight values, error precision e, and training iterations N;
[0095] Import training samples: Import training samples showing the relationship between the resistance value of the thermistor and temperature into the BP neural network;
[0096] Normalization: Normalize the training sample data;
[0097] Calculation output: According to the forward propagation of the signal from the BP neural network, the normalized data y is calculated. u The data is fed into the neural network as input to calculate the output y of the neurons in the hidden layer. j and the output y of neurons in the output layer k ;
[0098] Calculate the neuron error: Calculate the error Δw of the weight values by backpropagating the error signal of the BP neural network. kj and Δw ji ;
[0099] Update weight values: Based on the error of the calculated weight values, update the weight values w of the hidden layer and the output layer. kj =w kj +Δw kj w ji =w ji +Δw ji ;
[0100] Error accuracy assessment: Determine whether the current error accuracy meets the requirements. If the accuracy requirement is met, training ends. If the accuracy requirement is not met, further determine whether the number of training iterations N has been reached. If the number of training iterations N has been reached, training ends. If the number of training iterations N has not been reached, return to the calculation output and continue training.
[0101] This embodiment focuses on the learning and training process of the BP neural network:
[0102] Parameter initialization: First, initialize the weight values of the neurons. Based on experience, they are generally selected between -2.4 / F and 2.4 / F. Our neural network has 3 input terminals, so F = 3, and the weight values are between -0.8 and 0.8.
[0103] Set all weight values to random numbers between -0.8 and 0.8.
[0104] Next, set the output error precision e, which is generally set to 0.01.
[0105] Then set the number of training iterations N to 10,000 to avoid the training not reaching the required accuracy.
[0106] Normalization: First, the data is normalized. The output of the neuron is very sensitive to data between 0 and 1, which can increase the convergence speed.
[0107] The resistance values of the thermistors input to the input layer are normalized using the normalization function. Where R represents the input resistance data, R min R represents the minimum value among the input resistance data. max This represents the maximum value in the input resistance data, y. u This represents the normalized data.
[0108] The temperature data from the thermistors at the input to the output layer is normalized using the normalization function. Where T represents the input temperature data, T min T represents the minimum value in the input data. max T represents the maximum value in the input data. u This represents the normalized data.
[0109] After normalization, the input value of the input layer neurons in the BP neural network design becomes x. i =y u The correct temperature result d is used to represent the output. k =T u .
[0110] See Figure 4As shown in the embodiment, in the calibration method for temperature detection of a thermal printer printhead, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detected temperature, including:
[0111] The measured resistance value R of the thermistor is fed into the calibration neural network model;
[0112] The input resistance value R is normalized, and the output y of the neurons in the output layer is calculated according to the forward propagation of the calibrated neural network model. k ;
[0113] For output y k The data is restored to obtain the calibrated actual temperature value T.
[0114] In this embodiment, parameter initialization is required before using the calibration neural network model. The weights of the neurons are initialized before using the model. After the BP neural network is trained, we obtain the hidden layer weights w. ji Output layer weights w kj .
[0115] In this embodiment, the input data is normalized when using the calibration neural network model. Where R... min and R max These are the minimum and maximum resistance values obtained during previous learning and training. R represents the input data, y u This represents the normalized data; the normalization function is...
[0116] In this embodiment, when using the calibration neural network model, the step of targeting the output y... k The actual temperature value T obtained after data restoration includes:
[0117] Using the data restoration function T = y k ×(T max -T min )+T min For output y k Perform data restoration calculations, where T min and T max The minimum and maximum temperature values are used to train and calibrate the neural network model.
[0118] The calibration method for detecting temperature in a thermal printer printhead described in this embodiment also includes accuracy verification of the calibration neural network model:
[0119] Using the formula for calculating thermistor Generate the correspondence data between temperature and resistance values within a set temperature range and at a set temperature interval. Input the correspondence data into the calibration neural network model for training to generate a fitting curve. Compare the degree of overlap between the fitting curve and the RT characteristic curve corresponding to the correspondence data between temperature and resistance values to verify the accuracy of the calibration neural network model.
[0120] See Figure 5 As shown, the fitted curve is basically consistent with the RT characteristic curve, and the overall calculation error is less than 1%, which is very good.
[0121] This embodiment also provides a calibration device for detecting the temperature of a thermal printer printhead, including:
[0122] The data acquisition module measures and acquires the resistance value of the thermistor of the temperature sensor at various temperatures, and obtains the corresponding relationship between the resistance value of the thermistor and the temperature.
[0123] The network model training module establishes a BP neural network and uses the correspondence between the resistance value and temperature of the thermistor to train the model, thereby obtaining a calibration neural network model of the thermistor.
[0124] In the calibration module, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature.
[0125] This embodiment also provides a thermal printer, including a temperature sensor and a control system. When the temperature sensor detects the temperature, it inputs the resistance value of the thermistor into a calibration neural network model to output the calibrated detection temperature.
[0126] The calibration neural network model is trained in the following way:
[0127] The resistance value of the thermistor of the temperature sensor is measured at various temperatures to obtain the corresponding relationship between the resistance value of the thermistor and the temperature.
[0128] A backpropagation (BP) neural network was established, and the model was trained using the correspondence between the resistance value and temperature of the thermistor to obtain a calibration neural network model for the thermistor.
[0129] This embodiment of the thermal printer provides a method for calibrating thermistors through software algorithms by inputting the resistance value of the acquired thermistor into a calibration neural network model to output the calibrated detection temperature. This method does not require additional hardware costs and can significantly improve the accuracy of thermistor temperature detection, thereby ensuring the thermal printing effect.
[0130] In this embodiment, the control system of the thermal printer is configured with a corresponding calibration neural network based on the specific model of the thermistor, and the parameters of the calibration neural network are initialized. Specifically, the range of resistance values input to the calibration neural network needs to be set. Only when the resistance value of the temperature sensor is within the range will it be input to the calibration neural network for calibration and output of the corresponding temperature value. When the resistance value of the temperature sensor is not within the range, the thermal printer will display a warning message such as "Current printing temperature is too low" or "Current printing temperature is too high," requiring inspection and maintenance of the thermal printer.
[0131] The thermal printer in this embodiment has higher temperature detection accuracy, meeting users' printing needs and improving printing results.
[0132] This embodiment also provides a storage medium storing a computer-executable program, which, when executed, implements the aforementioned calibration method for detecting temperature in a thermal printer printhead.
[0133] The storage medium described in this embodiment may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0134] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer-executable program, and when the computer program is executed by the processor, the processor executes the aforementioned calibration method for detecting temperature of a thermal printer printhead.
[0135] The electronic device is manifested in the form of a general-purpose computing device. It may contain one or more processors that work collaboratively. This invention also does not preclude distributed processing, meaning that processors may be distributed across different physical devices. The electronic device of this invention is not limited to a single entity, but may also be the sum of multiple physical devices.
[0136] The memory stores a computer-executable program, typically machine-readable code. The computer-readable program can be executed by the processor to enable the electronic device to perform the method of the present invention, or at least some steps of the method.
[0137] The memory includes volatile memory, such as random access memory (RAM) and / or cache memory, and may also be non-volatile memory, such as read-only memory (ROM).
[0138] It should be understood that the electronic device of the present invention may also include elements or components not shown in the examples above. For example, some electronic devices also include display units such as a display screen, and some electronic devices also include human-computer interaction elements such as buttons and keyboards. Any electronic device capable of executing a computer-readable program in its memory to implement the method of the present invention or at least some steps of the method can be considered as an electronic device covered by the present invention.
[0139] From the above description of the embodiments, those skilled in the art will readily understand that the present invention can be implemented by hardware capable of executing specific computer programs, such as the system of the present invention, and the electronic processing unit, server, client, mobile phone, control unit, processor, etc. included in the system. The present invention can also be implemented by computer software that executes the methods of the present invention, for example, by control software executed by a microprocessor, electronic control unit, client, server, etc. However, it should be noted that the computer software executing the methods of the present invention is not limited to execution in one or a specific set of hardware entities; it can also be implemented in a distributed manner by unspecified hardware. For computer software, the software product can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or distributed across a network, as long as it enables electronic devices to execute the methods according to the present invention.
[0140] The above embodiments are only used to illustrate the present invention and are not intended to limit the technical solutions described herein. Although the present invention has been described in detail with reference to the above embodiments, the present invention is not limited to the specific embodiments described above. Therefore, any modifications or equivalent substitutions to the present invention, as well as all technical solutions and improvements that do not depart from the spirit and scope of the invention, are covered within the scope of the claims of the present invention.
Claims
1. A calibration method for detecting temperature in the printhead of a thermal printer, characterized in that, The calibration method includes: Obtain the resistance value of the thermistor of the temperature sensor at various temperatures, and obtain the corresponding relationship between the resistance value of the thermistor and the temperature. A BP neural network is established, and the model is trained using the correspondence between the resistance value and temperature of the thermistor to obtain a calibration neural network model for the thermistor. The obtained resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature; Configure the corresponding calibration neural network according to the specific model of the thermistor, and initialize the parameters of the calibration neural network. Set the range of resistance values input to the calibration neural network. When the resistance value of the temperature sensor is within the range, it is input to the calibration neural network for calibration and output of the corresponding temperature value. When the resistance value of the temperature sensor is not within the range, the thermal printer will issue a reminder. When the temperature sensor detects temperature, the resistance value of the thermistor is input into the calibration neural network model, and the output calibrated detected temperature includes: The measured resistance value R of the thermistor is fed into the calibration neural network model; The input resistance value R is normalized, and the output y of the neurons in the output layer is calculated according to the forward propagation of the calibrated neural network model. k ; For output y k The data is restored to obtain the calibrated actual temperature value T; The output y k The actual temperature value T obtained after data restoration includes: Using the data restoration function T = y k ×(T max -T min )+T min For output y k Perform data restoration calculations, where T min and T max The minimum and maximum temperature values are used to train and calibrate the neural network model. The aforementioned calibration method for detecting temperature in a thermal printer printhead further includes accuracy verification of the calibration neural network model. Using the formula for calculating thermistor Generate the correspondence data between temperature and resistance values within a set temperature range and at a set temperature interval. Input the correspondence data into the calibration neural network model for training to generate a fitting curve. Compare the degree of overlap between the fitting curve and the RT characteristic curve corresponding to the correspondence data between temperature and resistance values to verify the accuracy of the calibration neural network model. The establishment of the BP neural network includes: Define a network structure including an input layer, a hidden layer, and an output layer. The input layer includes at least three input terminals with an input resistance value R. The hidden layer includes at least three neurons, each neuron having a hidden layer input terminal corresponding to the number of input terminals. Each hidden layer input terminal of each neuron is connected to an input terminal of the input layer. The output layer includes a neuron that outputs a temperature T. The establishment of the BP neural network includes: Define the activation function f′(x)=y(1-y); Forward signal propagation, input layer neurons: input value x i =R, output value y i =x i Hidden layer neurons: input values Output value Output layer neurons: Input values Output value The error signal propagates backward, and the output neuron error E,d k The true and correct result is represented by the temperature T in the training data, and the neuron error. weight w kj error amount weight w ji error amount Add learning rate η represents the learning rate, which is a number between 0 and 1; The step of training a calibration neural network model for the thermistor using the relationship between its resistance and temperature includes: Parameter initialization: Set the neuron's weight values, error precision e, and training iterations N; Import training samples: Import training samples showing the relationship between the resistance value of the thermistor and the temperature into the BP neural network; Normalization: Normalize the training sample data; Calculation output: According to the forward propagation of the signal from the BP neural network, the normalized data y is calculated. u The data is fed into the neural network as input to calculate the output y of the neurons in the hidden layer. j and the output y of neurons in the output layer k ; Calculate the neuron error: Calculate the error Δw of the weight values by backpropagating the error signal of the BP neural network. kj and Δw ji ; Update weight values: Based on the error of the calculated weight values, update the weight values w of the hidden layer and the output layer. kj =w kj +Δw kj w ji =w ji +Δw ji ; Error accuracy assessment: Determine whether the current error accuracy meets the requirements. If the accuracy requirement is met, training ends. If the accuracy requirement is not met, further determine whether the number of training iterations N has been reached. If the number of training iterations N has been reached, training ends. If the number of training iterations N has not been reached, return to the calculation output and continue training.
2. The calibration method for detecting temperature in a thermal printer printhead according to claim 1, characterized in that, The normalization process includes: The resistance values of the thermistors input to the input layer are normalized: Normalization processing function Where R represents the input resistance data, R min R represents the minimum value among the input resistance data. max This represents the maximum value in the input resistance data, y. u This represents the normalized data; The temperature data of the thermistors from the input to the output layer are normalized: Normalization processing function Where T represents the input temperature data, T min T represents the minimum value in the input data. max T represents the maximum value in the input data. u This represents the normalized data.
3. A calibration device for detecting the temperature of a thermal printer printhead, characterized in that, include: The data acquisition module measures and acquires the resistance value of the thermistor of the temperature sensor at various temperatures, and obtains the corresponding relationship between the resistance value of the thermistor and the temperature. The network model training module establishes a BP neural network and uses the correspondence between the resistance value and temperature of the thermistor to train the model, thereby obtaining a calibration neural network model of the thermistor. In the calibration module, when the temperature sensor detects the temperature, the resistance value of the thermistor is input into the calibration neural network model to output the calibrated detection temperature. When the temperature sensor detects temperature, the resistance value of the thermistor is input into the calibration neural network model, and the output calibrated detected temperature includes: The measured resistance value R of the thermistor is fed into the calibration neural network model; The input resistance value R is normalized, and the output y of the neurons in the output layer is calculated according to the forward propagation of the calibrated neural network model. k ; For output y k The data is restored to obtain the calibrated actual temperature value T; The output y k The actual temperature value T obtained after data restoration includes: Using the data restoration function T = y k ×(T max -T min )+T min For output y k Perform data restoration calculations, where T min and T max The minimum and maximum temperature values are used to train and calibrate the neural network model. This also includes accuracy verification for the calibration neural network model: Using the formula for calculating thermistor Generate the correspondence data between temperature and resistance values within a set temperature range and at a set temperature interval. Input the correspondence data into the calibration neural network model for training to generate a fitting curve. Compare the degree of overlap between the fitting curve and the RT characteristic curve corresponding to the correspondence data between temperature and resistance values to verify the accuracy of the calibration neural network model. The establishment of the BP neural network includes: Define a network structure including an input layer, a hidden layer, and an output layer. The input layer includes at least three input terminals with an input resistance value R. The hidden layer includes at least three neurons, each neuron having a hidden layer input terminal corresponding to the number of input terminals. Each hidden layer input terminal of each neuron is connected to an input terminal of the input layer. The output layer includes a neuron that outputs a temperature T. The establishment of the BP neural network includes: Define the activation function f′(x)=y(1-y); Forward signal propagation, input layer neurons: input value x i =R, output value y i =x i Hidden layer neurons: input values Output value Output layer neurons: Input values Output value The error signal propagates backward, and the output neuron error E,d k The true and correct result is represented by the temperature T in the training data, and the neuron error. weight w kj error amount weight w ji error amount Add learning rate η represents the learning rate, which is a number between 0 and 1; The step of training a calibration neural network model for the thermistor using the relationship between its resistance and temperature includes: Parameter initialization: Set the neuron's weight values, error precision e, and training iterations N; Import training samples: Import training samples showing the relationship between the resistance value of the thermistor and the temperature into the BP neural network; Normalization: Normalize the training sample data; Calculation output: According to the forward propagation of the signal from the BP neural network, the normalized data y is calculated. u The data is fed into the neural network as input to calculate the output y of the neurons in the hidden layer. j and the output y of neurons in the output layer k ; Calculate the neuron error: Calculate the error Δw of the weight values by backpropagating the error signal of the BP neural network. kj and Δw ji ; Update weight values: Based on the error of the calculated weight values, update the weight values w of the hidden layer and the output layer. kj =w kj +Δw kj w ji =w ji +Δw ji ; Error accuracy assessment: Determine whether the current error accuracy meets the requirements. If the accuracy requirement is met, training ends. If the accuracy requirement is not met, further determine whether the number of training iterations N has been reached. If the number of training iterations N has been reached, training ends. If the number of training iterations N has not been reached, return to the calculation output and continue training.
4. A thermal printer, characterized in that, It includes a temperature sensor and a control system. When the temperature sensor detects the temperature, it inputs the resistance value of the thermistor into a calibration neural network model to output the calibrated detection temperature. The calibration neural network model is trained in the following way: The resistance value of the thermistor of the temperature sensor is measured at various temperatures to obtain the corresponding relationship between the resistance value of the thermistor and the temperature. A BP neural network is established, and the model is trained using the correspondence between the resistance value and temperature of the thermistor to obtain a calibration neural network model for the thermistor. When the temperature sensor detects temperature, the resistance value of the thermistor is input into the calibration neural network model, and the output calibrated detected temperature includes: The measured resistance value R of the thermistor is fed into the calibration neural network model; The input resistance value R is normalized, and the output y of the neurons in the output layer is calculated according to the forward propagation of the calibrated neural network model. k ; For output y k The data is restored to obtain the calibrated actual temperature value T; The output y k The actual temperature value T obtained after data restoration includes: Using the data restoration function T = y k ×(T max -T min )+T min For output y k Perform data restoration calculations, where T min and T max The minimum and maximum temperature values are used to train and calibrate the neural network model. This also includes accuracy verification for the calibration neural network model: Using the formula for calculating thermistor Generate the correspondence data between temperature and resistance values within a set temperature range and at a set temperature interval. Input the correspondence data into the calibration neural network model for training to generate a fitting curve. Compare the degree of overlap between the fitting curve and the RT characteristic curve corresponding to the correspondence data between temperature and resistance values to verify the accuracy of the calibration neural network model. The establishment of the BP neural network includes: Define a network structure including an input layer, a hidden layer, and an output layer. The input layer includes at least three input terminals with an input resistance value R. The hidden layer includes at least three neurons, each neuron having a hidden layer input terminal corresponding to the number of input terminals. Each hidden layer input terminal of each neuron is connected to an input terminal of the input layer. The output layer includes a neuron that outputs a temperature T. The establishment of the BP neural network includes: Define the activation function f′(x)=y(1-y); Forward signal propagation, input layer neurons: input value x i =R, output value y i =x i Hidden layer neurons: input values Output value Output layer neurons: Input values Output value The error signal propagates backward, and the output neuron error E,d k The true and correct result is represented by the temperature T in the training data, and the neuron error. weight w kj error amount weight w ji error amount Add learning rate η represents the learning rate, which is a number between 0 and 1; The step of training a calibration neural network model for the thermistor using the relationship between its resistance and temperature includes: Parameter initialization: Set the neuron's weight values, error precision e, and training iterations N; Import training samples: Import training samples showing the relationship between the resistance value of the thermistor and the temperature into the BP neural network; Normalization: Normalize the training sample data; Calculation output: According to the forward propagation of the signal from the BP neural network, the normalized data y is calculated. u The data is fed into the neural network as input to calculate the output y of the neurons in the hidden layer. j and the output y of neurons in the output layer k ; Calculate the neuron error: Calculate the error Δw of the weight values by backpropagating the error signal of the BP neural network. kj and Δw ji ; Update weight values: Based on the error of the calculated weight values, update the weight values w of the hidden layer and the output layer. kj =w kj +Δw kj w ji =w ji +Δw ji ; Error accuracy assessment: Determine whether the current error accuracy meets the requirements. If the accuracy requirement is met, training ends. If the accuracy requirement is not met, further determine whether the number of training iterations N has been reached. If the number of training iterations N has been reached, training ends. If the number of training iterations N has not been reached, return to the calculation output and continue training.