Instrument automatic calibration method, electronic device and storage medium

By generating calibration instruction chains and automating calibration processes, the problem of poor instrument calibration efficiency has been solved, realizing an efficient and configurable instrument calibration method and improving the repeatability and consistency of calibration results.

CN123175333APending Publication Date: 2026-11-27SHENZHEN XJCSENSOR TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611674468.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing instrument calibration methods are inefficient, rely on manual operation experience, and the results are not easily reproduced. The calibration process for multi-channel instruments is cumbersome and the data is difficult to retain.

Method used

By generating a calibration instruction chain, the instrument is automatically calibrated using configuration data. A communication link is established, standard meter measurements are collected, calibration instructions are executed according to the instruction type, register correction values ​​are automatically determined, and the process continues until the measured value falls into the allowable range or the number of iterations reaches the preset number of cycles, and a judgment conclusion is output.

Benefits of technology

It improves the efficiency and consistency of instrument calibration, shortens the model adaptation cycle, reduces manual intervention, and ensures the repeatability and accuracy of calibration results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123175333A_ABST
    Figure CN123175333A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of industrial instrument automation detection, and discloses an instrument automatic calibration method, an electronic device and a storage medium, which comprise the following steps: generating a calibration instruction chain arranged according to step numbers according to configuration data, wherein the configuration data comprises a communication port and protocol parameters; establishing a communication link with a calibrated instrument according to the communication port and the protocol parameters bound by the instruction, and collecting a measurement value of a standard table; taking out the instruction in sequence according to the step numbers and executing according to types, wherein the types comprise analog quantity closed-loop calibration; in response to the analog quantity closed-loop calibration, determining a register correction value according to the measurement value and a current value of a register, writing the register correction value into the register, re-measuring, and obtaining a determination result of a calibration point until the measurement value falls into an allowed interval or the number of iterations reaches a preset cycle number; and summarizing the determination results and outputting a determination conclusion. Therefore, the calibration process is driven by the configuration data, and the register correction value is automatically determined according to the measurement value and the current value of the register, so that the efficiency of instrument calibration is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial instrument automated testing technology, specifically to an automatic instrument calibration method, electronic equipment, and storage medium. Background Technology

[0002] Industrial instruments such as pressure transmitters, temperature transmitters, level transmitters, flow transmitters, and various secondary instruments require zero-point and full-scale calibration before leaving the factory and during their service life. This involves measuring the instrument's actual output using a standard meter and adjusting the internal register values ​​to ensure the output falls within the allowable error range. With the increasing diversity of instrument types and communication protocols, the degree of automation in calibration directly determines the verification efficiency and metrological consistency of the production line. Currently, the mainstream practices in the industry fall into two categories: one is the dedicated calibration software provided by the instrument manufacturer, and the other is the use of general protocol debugging or configuration software in conjunction with scripts.

[0003] However, dedicated software typically embeds communication commands, register addresses, and function codes into the program. Each time a new instrument model is adapted, the program needs to be modified and recompiled, resulting in a lengthy adaptation cycle. Furthermore, register correction values ​​rely on operators manually reading standard tables and estimating based on experience. Even after writing the values, manual observation of the output is still required, making calibration results dependent on operational experience. Results obtained by different personnel at different times are difficult to reproduce. Moreover, even with proportional correction, the correction amount remains large when the measured value is close to the allowable range, and the register value tends to fluctuate repeatedly around the target value, making convergence difficult. In addition, multi-channel instruments require manual wiring and startup of each channel individually, and process data and intermediate values ​​are difficult to retain. Therefore, instrument calibration efficiency is poor. Summary of the Invention

[0004] In view of the above problems, this application provides an automatic instrument calibration method, electronic device and storage medium to solve the problem of poor instrument calibration efficiency.

[0005] The first aspect of this application provides an automatic instrument calibration method, comprising: generating a calibration command chain based on configuration data; wherein the configuration data includes a communication port and protocol parameters, and the calibration command chain includes multiple commands arranged in step numbers; establishing a communication link with the instrument under calibration based on the communication port and protocol parameters bound to the commands, and acquiring the measured values ​​of a standard meter; retrieving commands from the calibration command chain in step number order, and executing the commands according to their types; wherein the types include analog closed-loop calibration; in response to the command type being analog closed-loop calibration, determining a register correction value based on the measured value and the current value of the register, writing it into the register and retesting until the measured value falls into the allowable range or the number of iterations reaches a preset number of cycles, to obtain the determination result of the calibration point corresponding to the analog closed-loop calibration; acquiring each The calibration point determination result is output, and the determination conclusion of the calibrated instrument is output. In response to the instruction type of analog closed-loop calibration, the register correction value is determined according to the measured value and the current value of the register of the calibrated instrument. The register correction value is written into the register of the calibrated instrument and retested, including: in response to the instruction type of analog closed-loop calibration, the register of the calibrated instrument is written back to the preset reference value; wherein, the preset reference value is the value of the previous successful calibration or the original value of the register; the measured value of the standard meter is read. If the measured value does not fall into the allowable range, the correction direction and correction amount are determined according to the current value of the register, the measured value, the calibration endpoint value and the full scale code value, and the register correction value is obtained and written into the register; the measured value is retested. If the retested measured value falls into the allowable range, the calibration point is determined to be qualified.

[0006] In some specific embodiments, generating a calibration instruction chain based on configuration data includes: storing configuration data in a configuration table in a database; wherein the configuration table includes at least one of a test plan table, an execution step details table, an analog quantity table, a port table, and a protocol table; generating a calibration instruction chain based on the configuration table, and classifying the instructions according to their type as read register instructions, write register instructions, analog quantity closed-loop calibration instructions, and delay wait instructions.

[0007] In some specific embodiments, a communication link is established between the instrument under test and the communication port and protocol parameters bound to the instruction, and the measurement values ​​of the instrument under test by the standard meter are collected at a preset period. This includes: opening a serial port or establishing a TCP connection according to the communication port and protocol parameters, and setting the baud rate, parity bit, data bits and stop bits according to the protocol parameters; starting a background task independent of the communication link, which sends query instructions to the standard meter at a fixed period, and parsing the measurement value after determining that a frame of message has been completely received based on the change in the byte length of the receiving buffer.

[0008] In some specific embodiments, the instruction is executed according to the type of instruction, including: in response to the retrieved instruction being a write register instruction, the instruction is framed according to the protocol parameters, a checksum is appended, and the data is written to the register of the instrument being calibrated, and the response frame is verified; in response to the retrieved instruction being a read register instruction, the instruction is framed according to the protocol, a checksum is appended, and the data is sent; the expected number of response bytes is calculated according to the protocol, the receive buffer is polled, the function code field and the byte number field of the response frame are double-checked, and after the checksum is passed, the response frame is restored to the parameter value; in response to the retrieved instruction being a delay wait instruction, the instruction is suspended for the time set by the delay wait instruction, and after the suspension ends, the delay wait instruction is removed and the next instruction is retrieved.

[0009] In some specific embodiments, after obtaining the register correction value, the process includes: if the deviation between the measured value and the allowable range falls within a preset fine-tuning range value, adjusting the register correction value stepwise according to a preset fine-tuning step size; if the register correction values ​​determined in two consecutive tests are the same and the retested measured value does not fall within the allowable range, forcibly offsetting the original value of the register by a preset offset and then redetermining the register correction value.

[0010] In some specific embodiments, this method further includes: distinguishing the communication, control communication and channel switching of the instrument being calibrated according to the instrument communication address field in the instruction through the same communication link; and switching to the next channel under test in response to the instrument communication address field in the instruction being the channel switching address, so as to calibrate multiple channels sequentially in a single calibration process.

[0011] In some specific embodiments, this method further includes: outputting a judgment conclusion indicating qualification when all calibration points are qualified, and outputting a judgment conclusion indicating non-qualification when any calibration point is unqualified; and writing the execution messages of the calibration process, the error list, the intermediate values ​​of the register correction values, and the final values ​​of the registers into the database and the hierarchical log to trace the calibration process.

[0012] A second aspect of this application provides an electronic device, comprising: a processor; and a memory for storing a computer program, wherein the computer program, when executed by the processor, implements the instrument automatic calibration method described above.

[0013] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the instrument automatic calibration method as described above.

[0014] The present application possesses at least the following beneficial technical effects: Based on the instrument automatic calibration method, electronic device, and storage medium provided in this application, the process includes: generating a calibration instruction chain based on configuration data; wherein the configuration data includes communication ports and protocol parameters, and the calibration instruction chain includes multiple instructions arranged according to step numbers; establishing a communication link with the instrument under calibration based on the communication ports and protocol parameters bound to the instructions, and collecting the measured values ​​of the standard meter; retrieving instructions from the calibration instruction chain in step number order, and executing the instructions according to their types; wherein the types include analog closed-loop calibration; responding to the instruction type being analog closed-loop calibration, determining the register correction value based on the measured value and the current register value, writing it into the register, and retesting until the measured value falls into the allowable range or the number of iterations reaches the preset number of cycles, to obtain the judgment result of the calibration point corresponding to the analog closed-loop calibration; obtaining the judgment result of each calibration point, and outputting the judgment conclusion of the instrument under calibration. Therefore, the calibration process is driven by configuration data, and the register correction value is automatically determined by the measured value and the current register value, thereby improving the efficiency of instrument calibration.

[0015] The above description is merely an overview of the technical solutions of the embodiments of this application. In order to better understand the technical means of the embodiments of this application and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of this application more obvious and understandable, specific implementation methods of this application are described below. Attached Figure Description

[0016] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0017] Figure 1 This is a schematic flowchart of an embodiment of the automatic instrument calibration method provided in this application;

[0018] Figure 2 This is a schematic flowchart of another embodiment of the automatic instrument calibration method provided in this application;

[0019] Figure 3 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0020] Figure 4 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0021] Figure 5 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0022] Figure 6 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0023] Figure 7 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0024] Figure 8 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application;

[0025] Figure 9 This is a schematic diagram of the structural framework of an embodiment of the electronic device provided in this application. Detailed Implementation

[0026] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited to the embodiments set forth herein. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without inventive effort are within the scope of protection of the present application.

[0027] If the embodiments of this application involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, if the word "and / or" appears throughout the text, it means including three parallel solutions. For example, "A and / or B" includes solution A, solution B, or a solution that simultaneously satisfies A and B. Additionally, the technical solutions of various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.

[0028] The first aspect of this application provides an automatic instrument calibration method, which can be applied to the verification and calibration process of industrial instruments. Specifically, pressure transmitters, temperature transmitters, level transmitters, flow transmitters, and various secondary instruments need to undergo zero-point and full-scale calibration before leaving the factory and during their service life. This process is typically located at the verification station on the production line, where a standard instrument provides the measurement reference, and the host computer software communicates with the instrument being calibrated and rewrites its internal registers. Since the same station often needs to handle instruments from multiple manufacturers and using multiple communication protocols, and multi-channel instruments need to be switched channel by channel, this process requires high configurability of the calibration process and high repeatability of the calibration results. The embodiments of this application address this process by providing an automatic instrument calibration method driven by configuration data and automatically converging based on the measurement values ​​of a standard instrument.

[0029] In this method, the executing entity can be a host computer deployed at the calibration station. The host computer can communicate with the calibrated instrument and the standard meter used as a reference, read register values ​​from the calibrated instrument and write register values ​​back to it, collect the measurement values ​​of the calibrated instrument from the standard meter, and output the judgment conclusion of the calibrated instrument after executing this method, for use by personnel at the calibration station or the production line management system. In other embodiments, the host computer can also be a server deployed in the production line room or in the cloud, and the data from the calibrated instrument and the standard meter can be collected at the station and uploaded via the network. It should be understood that the specific form of the executing entity is not limited in the embodiments of this application. In some application scenarios, the method provided in the embodiments of this application can also be applied to other scenarios that require repeated adjustment of the parameters of the controlled object based on an external reference until they fall within the allowable range, such as batch calibration of sensors, stroke calibration of actuators, or zero-point calibration of testing equipment.

[0030] Figure 1 This is a schematic flowchart of an embodiment of the automatic instrument calibration method provided in this application. (In conjunction with...) Figure 1 This method includes the following steps:

[0031] S101: Generate a calibration instruction chain based on the configuration data.

[0032] The configuration data includes communication port and protocol parameters, while the calibration command chain consists of multiple commands arranged by step number. Configuration data describes the calibration task and includes at least the communication port to which the instrument being calibrated is connected and the protocol parameters followed by the instrument. Protocol parameters are those required for establishing communication and parsing messages, such as baud rate, parity bit, data bits, or stop bits. The calibration command chain is an ordered set of multiple calibration steps, where each command corresponds to a calibration step and has its own step number.

[0033] It should be understood that this step separates the calibration process from the program code, replacing it with a description of configuration data. When calibrating a new model of instrument or changing the calibration sequence, only the corresponding configuration data needs to be rewritten and the calibration instruction chain regenerated, without needing to modify the host computer program and recompile. Therefore, the adaptation work for the calibration process is moved from the development stage to the configuration stage, thus shortening the adaptation cycle. For the specific organization of the configuration data, please refer to the following embodiment.

[0034] For example, in the calibration instruction chain generated by a calibration task, each instruction is in sequence to read the zero-point register, perform analog closed-loop calibration on the zero point, read the full-scale register, perform analog closed-loop calibration on the full scale, and output the judgment conclusion.

[0035] S102: Establish a communication link with the instrument under calibration according to the communication port and protocol parameters bound to the instruction, and collect the measurement values ​​of the instrument under calibration from the standard meter at a preset period.

[0036] Here, the communication port refers to the physical or logical port to which the instrument being calibrated is connected, such as a serial communication port or a network port. Protocol parameters refer to the parameters followed by the instrument during communication, such as baud rate, parity bit, data bits, and stop bits. The communication link refers to the path used for transmitting commands and responses between the host computer and the instrument being calibrated. The measured value refers to the measurement result output by the standard meter to the instrument being calibrated.

[0037] It should be understood that the parameters of the communication link are derived from the configuration bound to the instruction itself. Therefore, the same calibration instruction chain can be adapted to instruments connected to different ports or following different protocols, and the host computer does not need to write a separate set of communication code for each type of instrument. In addition, the measured values ​​of the standard instrument are continuously collected according to a preset period, enabling the host computer to obtain the latest measured values ​​at any time during subsequent closed-loop calibration, without having to initiate a read every time it is needed.

[0038] For example, the measurement value on the standard meter can be collected every two hundred milliseconds, and the latest measurement value is cached in the host computer for direct reading by the closed-loop calibration judgment link.

[0039] S103: Retrieve instructions from the calibration instruction chain in step number order and execute the instructions according to their type.

[0040] The types include analog closed-loop calibration, and the step number refers to the order of each instruction in the calibration instruction chain. The instruction type refers to the action category corresponding to the instruction; different types of instructions are assigned to different processing branches by the host computer for execution. Analog closed-loop calibration refers to the instruction that repeatedly corrects the register value based on the measured value of the standard table for the calibration point of the analog quantity until the measured value is qualified.

[0041] It should be understood that the instruction chain is fetched and executed sequentially according to step numbers, ensuring that the entire calibration process proceeds in the order described in the configuration data. Users only need to adjust the step numbers of the relevant instructions in the configuration data to adjust the order of the calibration process, without having to modify the program logic. Furthermore, typed instructions mean that adding a new type of calibration action only requires adding one type and its processing branch; existing instruction types remain unaffected. For example, after the register read instruction at the beginning of the instruction chain is executed, the analog closed-loop calibration instruction that follows is fetched and executed by the processing branch corresponding to that type.

[0042] S104: In response to the instruction type of analog closed-loop calibration, determine the register correction value based on the measured value and the current value of the register of the instrument under calibration, write the register correction value into the register of the instrument under calibration and retest until the measured value falls into the allowable range or the number of iterations reaches the preset number of cycles, so as to obtain the determination result of the calibration point corresponding to the analog closed-loop calibration.

[0043] It should be noted that the current register value refers to the current value of the register in the instrument being calibrated corresponding to the calibration point. The register correction value is the target value used to rewrite the register, calculated based on the measured value and the current register value. The allowable range refers to the range of measured values ​​allowed for this calibration point, and the preset number of iterations refers to the maximum number of iterations allowed for this calibration point. The calibration point refers to a measurement position on the instrument being calibrated that needs to be calibrated, such as zero point or full scale point. The judgment result refers to the conclusion of whether the calibration point is ultimately qualified.

[0044] It should be understood that this step is the core of the entire calibration process, determining the calibration result. The measured value is provided by the standard table, reflecting the current output deviation of the instrument being calibrated, while the current value of the register reflects the current internal calibration state of the instrument. Combining these two values ​​determines how the register should be adjusted. Therefore, the correction process no longer relies on the operator's experience-based estimation but becomes a data-driven calculation. Furthermore, this process is repeatedly executed by writing, retesting, and correcting until the measured value falls within the allowable range, or the number of iterations reaches the preset number of cycles, thus ensuring a chance to converge to the acceptable level without indefinitely repeating the write operation. The specific method for determining the register correction value can be found in the following embodiment.

[0045] For example, the initial register value of a calibration point is 10000, the measured value obtained by the standard meter is 101.20, and the calculated register correction value is 9881. The host computer writes this value into the register and then collects the measured value again. If the measured value still does not fall within the allowable range, the next round of correction will continue.

[0046] S105: Obtain the judgment results of each calibration point and output the judgment conclusion of the instrument being calibrated.

[0047] Specifically, the judgment conclusion refers to the final conclusion made on the instrument being calibrated, which is obtained by summarizing the judgment results of the instrument at all calibration points.

[0048] It should be understood that this step aggregates the judgment results scattered across various calibration points into a single conclusion for the entire instrument, allowing operators to determine whether the instrument has passed calibration without having to interpret each result individually. Since the judgment results from each calibration point originate from the same automated process, the conclusion formation process also does not rely on manual judgment. For example, a four-channel pressure transmitter may generate eight judgment results across four channels and two calibration points per channel; the host computer will then aggregate these results and output the final judgment conclusion for the instrument.

[0049] In summary, the automatic instrument calibration method provided in the above embodiments generates a calibration instruction chain from configuration data, establishes a communication link according to the communication port and protocol parameters bound to the instructions and collects the measured values ​​of the standard meter, executes various types of instructions in sequence according to the step number, and determines the register correction value by using the measured value and the current value of the register of the instrument being calibrated in the analog closed-loop calibration, writes it and retests until it falls into the allowable range or reaches the preset number of cycles. This makes the calibration process configurable and the correction process does not require manual guessing. Therefore, it not only shortens the instrument model adaptation cycle, but also makes the calibration results consistent, thereby effectively solving the problem of poor instrument calibration efficiency.

[0050] Figure 2 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0051] Combination Figure 2 In some specific embodiments, a calibration instruction chain is generated based on configuration data, including:

[0052] S201: Store configuration data in a configuration table in the database.

[0053] It should be noted that the configuration table includes at least one of the following: a test plan table, an execution step details table, an analog quantity table, a port table, and a protocol table. The test plan table records the plan used in this calibration task, such as the model of the instrument being calibrated and the number of calibration points. The execution step details table records the order and type of each calibration step under the plan. The analog quantity table records the standard values ​​and allowable ranges of the analog quantity calibration points. The port table records the parameters of each communication port, and the protocol table records the frame format and parameters corresponding to each protocol.

[0054] It should be understood that by distributing the configuration data across the aforementioned configuration tables, the calibration schemes, procedures, calibration points, ports, and protocols are independent yet interconnected. Therefore, when only the port to which the instrument is connected is changed, only the corresponding record in the port table needs to be modified; other configurations remain unaffected. In this approach, the scope of configuration data maintenance is limited to the tables that have actually changed.

[0055] For example, in the configuration used for a calibration task, the test plan table records that the transmitter is a four-channel pressure transmitter, the port table records that it is connected to a third serial port, and the protocol table records that it follows the corresponding serial communication protocol.

[0056] S202: Generate a calibration instruction chain based on the configuration table, and classify the instructions according to their type as read register instructions, write register instructions, analog closed-loop calibration instructions, and delay wait instructions.

[0057] Here, the read register instruction is used to read the value of the register from the instrument being calibrated, the write register instruction is used to write the value of the register to the instrument being calibrated, the analog closed-loop calibration instruction is used to perform the above closed-loop correction on the analog calibration point, and the delay wait instruction is used to suspend the process for a set time.

[0058] It should be understood that the above four types cover all the basic actions in the calibration process. The register read instruction is used when the instrument status needs to be observed; the register write instruction is used when calibration parameters need to be modified; the analog closed-loop calibration instruction is used when repeated approximation based on a standard table is required; and the delay instruction is used when waiting for the instrument to stabilize between two actions. After categorizing the instructions, the execution branches of each instruction are independent, and existing branches do not need to be modified when adding new action types. For example, a complete instruction chain can sequentially include the register read instruction, the analog closed-loop calibration instruction, the delay instruction, and the register write instruction.

[0059] Figure 3 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0060] Combination Figure 3 In some specific embodiments, a communication link is established between the instrument being calibrated and the communication port and protocol parameters bound to the instruction, and the measurement values ​​of the instrument being calibrated by the standard meter are collected at preset intervals, including:

[0061] S301: Opens the serial port or establishes a TCP connection according to the communication port and protocol parameters, and sets the baud rate, parity bit, data bits and stop bits according to the protocol parameters.

[0062] Specifically, a serial port refers to a serial communication port, and a TCP connection refers to a network connection based on the Transmission Control Protocol. Baud rate refers to the number of symbols transmitted per second in serial communication, parity bits refer to the error detection method used to check for transmission errors, and data bits and stop bits refer to the number of data bits and stop bits in each frame, respectively.

[0063] It should be understood that instruments from different manufacturers often differ in the type of communication port and the parameters mentioned above. Therefore, these parameters need to be specified item by item by the configuration data bound to the command, and the host computer uses this to complete the link initialization. In this way, the same program can be adapted to various instruments connected to serial ports or networks.

[0064] For example, when a calibrated instrument is connected to a serial communication port with a baud rate of 115200, a parity mode of no parity, eight data bits, and one stop bit, the host computer opens the port and completes the parameter settings accordingly. When another calibrated instrument is connected via a network, a TCP connection is established and send and receive timeouts are set.

[0065] S302: Start a background task independent of the communication link. The background task sends query instructions to the standard table at fixed intervals and parses out the measurement value after determining that a frame of message has been completely received based on the change in the byte length of the receive buffer.

[0066] It should be noted that background tasks refer to data acquisition tasks that operate independently of the communication with the instrument being calibrated, and the receive buffer refers to the buffer used to temporarily store data returned by the standard meter. A change in byte length indicates a change in the number of bytes of data received in the buffer, suggesting that data is still arriving from the standard meter.

[0067] It should be understood that the standard meter readings need to be continuously refreshed. If the communication with the instrument being calibrated shares a processing flow, the standard meter readings will stop updating during the execution of calibration commands, and the measured values ​​obtained during closed-loop calibration will lag behind the actual output. By placing the acquisition of standard meter data in a separate background task, the refresh of measured values ​​is not affected by the execution of calibration commands. Furthermore, using the change in the byte length of the buffer to determine whether a message frame has been completely received allows the host computer to correctly delineate message boundaries without needing to know the fixed length of the message in advance.

[0068] For example, the background task sends a query command to the standard table every 200 milliseconds, then monitors the receive buffer. When the buffer stops growing for a period of time, it determines that a frame of data has been received completely and parses out the measurement value.

[0069] Figure 4 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0070] Combination Figure 4 In some specific embodiments, instructions are executed according to their type, including:

[0071] S401: In response to the fetched instruction being a write register instruction, the instrument assembles a frame according to the protocol parameters, appends a checksum, writes it to the register of the instrument being calibrated, and verifies the response frame.

[0072] Here, framing refers to organizing the function code, register address, and data into a single message frame according to the field order specified in the protocol. A checksum is an additional field calculated based on the message content and used to verify whether an error occurred during transmission. An acknowledgment frame is a message returned by the calibrated instrument in response to a received command frame.

[0073] It should be understood that the write operation directly changes the calibration parameters of the instrument being calibrated; therefore, it is necessary to confirm that the operation is indeed received by the instrument. Verifying the response frame after the write operation can promptly detect communication anomalies or write failures, preventing the continuation of subsequent steps if the write operation has not taken effect.

[0074] For example, the write register instruction is sent after framing the data according to the corresponding protocol and appending a checksum to the end of the frame. The host computer then reads the response frame. If the response frame fails to be checked or is not received within a timeout period, a communication error is recorded.

[0075] S402: In response to the fetched instruction being a register read instruction, the system frames the data according to the protocol, appends a checksum, and sends the data. It calculates the expected number of response bytes according to the protocol and polls the receive buffer. It performs double verification on the function code field and byte number field of the response frame. After the verification passes, the response frame is restored to the parameter value.

[0076] Specifically, the expected response byte count refers to the number of bytes that a response frame should have, calculated according to the response frame format specified in the protocol. The function code field indicates the type of operation corresponding to the response frame, and the byte number field indicates the number of bytes of data carried in the response frame. Reverting to parameter values ​​means converting the data fields in the response frame into actual parameter values ​​according to the encoding method agreed upon in the protocol.

[0077] It should be understood that the data obtained from the read operation will be used to calculate the register correction value. If the parsed message is not a response to the current request, the calculation result will be inaccurate. By calculating the expected number of response bytes according to the protocol and performing double verification on the function code field and the byte number field, it can be confirmed before parsing that the frame is indeed a response to the current request and that its length is correct, thereby avoiding the misparsing of erroneous frames.

[0078] For example, after a register read instruction is issued, the host computer calculates that the expected response byte count is seven bytes, polls the buffer until a message of that length is received, then verifies its function code and byte count. After the verification is successful, the data fields are restored to floating-point numbers.

[0079] S403: In response to the retrieved instruction being a delayed wait instruction, the instruction is suspended for the time set by the delayed wait instruction. After the suspension ends, the delayed wait instruction is removed and the next instruction is retrieved.

[0080] It should be noted that suspending means paused execution of the current process without consuming processing resources. The time set in the delay wait instruction refers to the wait duration configured for that instruction.

[0081] It should be understood that after the register of the instrument being calibrated is rewritten, its output often needs a period of time to stabilize. If the measurement value of the standard meter is read immediately afterward, the resulting reading may still reflect the state before the rewrite. After setting the delay wait instruction, the calibration process can allow the required stabilization time between writing and reading. Removing the instruction after the suspension is completed is to prevent the instruction from being executed repeatedly, and the process then proceeds to the next instruction.

[0082] For example, if a delay instruction is set to wait for two seconds, the host computer will suspend the instruction for two seconds, remove the instruction, and retrieve the following register read instruction to continue execution.

[0083] Figure 5 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0084] Combination Figure 5 In some specific embodiments, in response to an instruction of analog closed-loop calibration, a register correction value is determined based on the measured value and the current value of the register of the instrument being calibrated, the register correction value is written into the register of the instrument being calibrated, and a retest is performed, including:

[0085] S501: In response to the command type of analog closed-loop calibration, the register of the instrument to be calibrated is written back to the preset reference value.

[0086] Here, the preset reference value is either the value of the last successful calibration or the original value of the register. The value of the last successful calibration refers to the register value recorded when the instrument was deemed qualified in a previous calibration. The original value of the register refers to the value of the register before the start of this calibration.

[0087] It should be understood that a known reference value is written back before each closed-loop calibration to ensure the starting state of the calibration is determined. If the starting state depends on the residual results of the previous round, instruments of the same model may converge from different starting points at different workstations or in different batches, resulting in inconsistent iterations and register values. Writing back the reference value ensures the reproducibility of the calibration process.

[0088] For example, before starting closed-loop correction at a certain calibration point, the value of the register at that point is written back to the value of the previous successful calibration. If the table has not recorded a successful value, the original value of the register is written back.

[0089] S502: Read the measured value from the standard table. If the measured value does not fall within the allowable range, determine the correction direction and correction amount based on the current value of the register, the measured value, the calibration endpoint value, and the full-scale code value, obtain the register correction value, and write it into the register.

[0090] Specifically, the calibration endpoint value refers to the nominal value of the measured quantity corresponding to the calibration point, such as the nominal value of the full-scale point. The full-scale code value refers to the code value that the register should obtain at full scale. The correction direction refers to whether the register value should be increased or decreased, and the correction amount refers to the amount by which the value should be changed.

[0091] It should be understood that the output of the instrument being calibrated is approximately proportional to the register value near the calibration endpoint. Therefore, based on the ratio between the measured value and the nominal value obtained from the standard meter, the position to which the register value should be adjusted can be calculated without trial and error. First, determine if the measured value falls within the allowable range. If the measured value is already acceptable, it can be directly deemed acceptable and the correction can be skipped, reducing unnecessary writes. Furthermore, the correction value is determined based on the current register value, the measured value, the calibration endpoint value, and the full-scale code value, ensuring that the calculation is compatible with the instrument's encoding method. For example, if the current register value at a certain full-scale point is 10000, the calibration endpoint value is 100.00, and the measured value obtained from the standard meter is 101.20, then the proportionally calculated register correction value is approximately 9881.

[0092] S503: The calibration point is deemed qualified if the retested measurement value falls within the allowable range.

[0093] It should be noted that retesting refers to reading the measurement value of the standard table again after writing the correction value to the register, and determining that the calibration point is qualified means confirming that the measurement value of the calibration point has fallen within the allowable range.

[0094] It should be understood that a remeasurement is necessary after writing the value, because the relationship between the register value and the actual output may be affected by the instrument's nonlinearity and hysteresis. The result calculated before writing may not be acceptable on the first attempt. The remeasurement result serves as the basis for determining whether the correction round is effective and whether to continue correction or end the calibration at that point. For example, if the remeasurement value obtained after writing the register correction value 9881 is 100.05, which still does not fall within the allowable range of 99.98 to 100.02, then the next round of correction should continue.

[0095] Figure 6 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0096] Combination Figure 6 In some specific embodiments, after obtaining the register correction value, the process includes:

[0097] S601: When the deviation between the measured value and the allowable range falls within the preset fine-tuning range, the register correction value is adjusted step by step according to the preset fine-tuning step size.

[0098] Here, the deviation between the measured value and the allowable interval refers to the amount by which the measured value exceeds the boundary of the allowable interval. The preset fine-tuning interval value is a boundary used to determine that the measured value is close to the allowable interval. The preset fine-tuning step size is the number of times the register value is changed each time during fine-tuning.

[0099] It should be understood that the closer the measured value is to the allowable range, the smaller the absolute amount of the correction calculated proportionally tends to be. However, in cases where the instrument being calibrated exhibits nonlinearity and hysteresis, this correction amount may still be too large relative to the actual required adjustment. After being written, the measured value may exceed the allowable range and appear on the other side, thus repeatedly jumping between the two sides of the allowable range and making convergence difficult. When the deviation falls into the fine-tuning range, a fixed step size is adopted to limit the adjustment amplitude when approaching the target, thereby suppressing such reciprocating oscillations.

[0100] For example, if the measured value after a certain round of correction is 100.05, the deviation from the upper limit of the allowable interval of 100.02 is 0.03, which is less than the preset fine-tuning interval value of 0.10, then the register correction value is changed to be decreased step by step, for example, from 9881 to 9876.

[0101] S602: If the register correction value is the same in two consecutive determinations and the measured value of the retest does not fall within the allowable range, the register correction value is redetermined after being forcibly offset according to the preset offset based on the original value of the register.

[0102] Specifically, "two consecutive register correction values ​​being the same" means that the correction values ​​calculated in two adjacent rounds are completely identical. "Forced offset based on the original value of the register according to a preset offset" means adding an offset to the register value before the start of this calibration, as the starting point for the new round of correction.

[0103] It should be understood that if two consecutive rounds of calculated correction values ​​are exactly the same, but the measured value is still not qualified, it means that the correction process has reached a balance point. The same correction value corresponds to the same write result, and subsequent rounds will repeat this result without progressing. At this point, forcibly offsetting from the original value can break this balance point, allowing the next round to start calculating from a new starting point. For example, if the register correction value calculated in two rounds is both 9900, but the measured value consistently exceeds the allowable range, then the calculation should abandon starting from the current value and instead recalculate the correction value after offsetting from the original value by a preset amount.

[0104] Figure 7 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0105] Combination Figure 7 In some specific embodiments, this method further includes:

[0106] S701: Through the same communication link, the communication, control communication and channel switching of the instrument being calibrated are distinguished according to the instrument communication address field in the instruction.

[0107] It should be noted that the instrument communication address field refers to the address field carried in the command, used to distinguish the communication object. Communication between the instrument being calibrated and the instrument being calibrated refers to the reading and writing of parameters, while control communication refers to the communication with the channel switching or signal switching device. Channel switching refers to switching the measurement loop to the next channel being measured.

[0108] It should be understood that all three types of communication use the same communication link, and their distinction is based on the address field in each instruction, not on their respective independent physical links. Therefore, the host computer does not need to add a separate communication interface for channel switching; channel switching can be configured as an instruction in the instruction chain, just like any other action. For example, an address field of 1 points to the instrument being calibrated, 2 points to the control device, and 3 points to the channel switching device.

[0109] S702: In response to the instrument communication address field in the command being a channel switching address, switch to the next channel under test to calibrate multiple channels sequentially in a single calibration cycle.

[0110] Here, the channel switching address refers to the address value that is conventionally designated to point to the channel switching action. A single-round calibration process refers to the complete process that is executed continuously from the start of a single operation until the end of the instruction chain.

[0111] It should be understood that after incorporating channel switching into the command chain, the calibration of each channel of a multi-channel instrument no longer requires manual wiring and startup. The host computer can complete the calibration of all channels sequentially after a single startup, and the timing and order of channel switching are determined by the configuration data. For example, in the command chain of a four-channel pressure transmitter, after completing the two calibration points of the first channel, a channel switching command is inserted, and the process immediately proceeds to the calibration of the second channel.

[0112] Figure 8 This is a flowchart illustrating another embodiment of the automatic instrument calibration method provided in this application.

[0113] Combination Figure 8 In some specific embodiments, this method further includes:

[0114] S801: If all calibration points are qualified, output a qualified conclusion; if any calibration point is unqualified, output an unqualified conclusion.

[0115] Specifically, a qualified conclusion means that all calibration points of the instrument under test have passed the verification, while a unqualified conclusion means that there are calibration points of the instrument under test that have failed the verification.

[0116] It should be understood that the instrument being calibrated typically has multiple calibration points, and its overall qualification depends on all calibration points. If any calibration point fails to meet the requirements, the instrument's calibration status does not meet the metrological requirements, and therefore the overall result should be deemed unqualified, rather than relying on the pass / fail ratio of individual points.

[0117] S802: Writes the calibration process execution messages, error list, intermediate values ​​of register correction values, and final values ​​of registers to the database and hierarchical log to trace the calibration process.

[0118] It should be noted that execution messages refer to various status information recorded during the calibration process, error lists refer to records of communication anomalies or calibration failures that occur during the process, intermediate values ​​of register correction values ​​refer to correction values ​​calculated in each iteration, and hierarchical logs refer to logs recorded according to their importance.

[0119] It should be understood that if the calibration results are questioned in subsequent use, the original calibration process needs to be reproduced to determine the problem. By retaining the execution messages, error list, intermediate values ​​of each correction round, and the final values ​​of the registers, every step of the calibration can be verified. Therefore, this method achieves automation while preserving process data, balancing calibration efficiency and result reliability.

[0120] A second aspect of this application provides an electronic device, comprising: a processor; and a memory for storing a computer program, wherein the computer program, when executed by the processor, implements the instrument automatic calibration method described above.

[0121] Figure 9 This is a schematic diagram of the structural framework of an embodiment of the electronic device 600 provided in this application.

[0122] Combination Figure 9In some specific embodiments, the electronic device 600 includes a central processing unit (CPU) 601 and a read-only memory (ROM) 602. The CPU 601 is a processor, and the ROM 602 is a memory. The CPU 601 can perform various appropriate actions and processes according to a program stored in the ROM 602 or a program loaded from the storage portion 608 into the random access memory (RAM) 603, such as executing the instrument automatic calibration method in the above embodiments. The RAM 603 also stores various programs and data required for system operation. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0123] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0124] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit 601, it performs various functions defined in the system of this application.

[0125] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the instrument automatic calibration method as described in any of the above embodiments.

[0126] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0127] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.

Claims

1. An automatic instrument calibration method, characterized in that, include: A calibration instruction chain is generated based on configuration data; wherein the configuration data includes communication port and protocol parameters, and the calibration instruction chain includes multiple instructions arranged in step number; A communication link is established between the instrument under calibration and the communication port bound to the instruction and the protocol parameters, and the measurement values ​​of the instrument under calibration by the standard meter are collected at a preset period. The instructions are retrieved from the calibration instruction chain in the order of the step numbers, and the instructions are executed according to their types; wherein, the types include analog closed-loop calibration; In response to the instruction being of type analog closed-loop calibration, a register correction value is determined based on the measured value and the current value of the register of the instrument under calibration. The register correction value is written into the register of the instrument under calibration and the measurement is repeated until the measured value falls into the allowable range or the number of iterations reaches the preset number of cycles, so as to obtain the determination result of the calibration point corresponding to the analog closed-loop calibration. Obtain the judgment results of each calibration point and output the judgment conclusion of the instrument being calibrated; The response to the instruction of type analog closed-loop calibration involves determining a register correction value based on the measured value and the current value of the register of the instrument under calibration, writing the register correction value into the register of the instrument under calibration, and retesting, including: In response to the instruction being of type analog closed-loop calibration, the register of the instrument being calibrated is written back to a preset reference value; wherein the preset reference value is the value of the previous successful calibration or the original value of the register; Read the measured value from the standard table. If the measured value does not fall within the allowed range, determine the correction direction and correction amount based on the current value of the register, the measured value, the calibration endpoint value, and the full-scale code value. Obtain the register correction value and write it into the register. The measured value is retested, and the calibration point is deemed qualified if the retested measured value falls within the allowable range.

2. The automatic instrument calibration method according to claim 1, characterized in that, The step of generating a calibration instruction chain based on configuration data includes: The configuration data is stored in a configuration table in the database; wherein the configuration table includes at least one of a test plan table, an execution step details table, a simulation table, a port table, and a protocol table; The calibration instruction chain is generated according to the configuration table, and the instructions are classified into read register instructions, write register instructions, analog closed-loop calibration instructions, and delay wait instructions according to their types.

3. The automatic instrument calibration method according to claim 1, characterized in that, The step of establishing a communication link with the instrument under calibration according to the communication port bound by the instruction and the protocol parameters, and collecting the measurement values ​​of the instrument under calibration from the standard meter at a preset period, includes: Open a serial port or establish a TCP connection according to the communication port and the protocol parameters, and set the baud rate, parity bit, data bits and stop bits according to the protocol parameters; A background task independent of the communication link is initiated. The background task sends query instructions to the standard table at fixed intervals and parses the measurement value after determining that a frame of message has been completely received based on the byte length change of the receive buffer.

4. The automatic instrument calibration method according to claim 1, characterized in that, The execution of the instruction according to the type of the instruction includes: In response to the retrieved instruction being a write register instruction, the instrument is framed according to the protocol parameters, a checksum is appended, and the frame is written to the register of the instrument being calibrated, and the response frame is verified. In response to the retrieved instruction being a register read instruction, the frame is assembled according to the protocol and the checksum is appended before being sent. The expected number of response bytes is calculated according to the protocol and the receive buffer is polled. The function code field and byte number field of the response frame are double-checked. After the check passes, the response frame is restored to the parameter value. In response to the retrieved instruction being a delayed waiting instruction, the system suspends the instruction for the time set by the delayed waiting instruction. After the suspension ends, the delayed waiting instruction is removed and the next instruction is retrieved.

5. The automatic instrument calibration method according to claim 1, characterized in that, After obtaining the register correction value, the process includes: If the deviation between the measured value and the allowable range falls within the preset fine-tuning range value, the register correction value is adjusted in steps according to the preset fine-tuning step size; If the register correction value is the same in two consecutive determinations and the measured value of the retest does not fall within the allowed range, the register correction value is redetermined after being forcibly offset by a preset offset based on the original value of the register.

6. The automatic instrument calibration method according to claim 1, characterized in that, The method further includes: Through the same communication link, the communication, control communication and channel switching of the instrument being calibrated are distinguished according to the instrument communication address field in the instruction; In response to the instrument communication address field in the instruction being a channel switching address, the system switches to the next channel under test to calibrate multiple channels sequentially in a single calibration cycle.

7. The automatic instrument calibration method according to claim 1, characterized in that, The method further includes: If all the calibration points are qualified, output the qualification conclusion indicating qualification; if any calibration point is unqualified, output the qualification conclusion indicating unqualified. The calibration process execution messages, error list, intermediate values ​​of the register correction values, and final values ​​of the registers are written to the database and hierarchical logs to trace the calibration process.

8. An electronic device, characterized in that, include: processor; A memory for storing a computer program that, when executed by the processor, implements the instrument automatic calibration method as described in any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the instrument automatic calibration method as described in any one of claims 1 to 7.