AD segmented calculation method, computer equipment and medium
By adding more parameters to the segmented node data table for fine deviation compensation, the problem of large deviation of physical magnitude values in resistive sensors in traditional methods is solved, and the accuracy of calculations and real-time processing capabilities are improved.
Patent Information
- Application Number
- CN202411276552.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-13
AI Technical Summary
When the traditional segmented linear method calculates physical quantities in a resistive sensor, the calculated value deviates greatly in the middle of the segment, which affects real-time rapid processing.
By adding more parameters to the segmented node data table, fine deviation compensation, including bidirectional deviation and unidirectional deviation processing, different compensation formulas are used to determine the compensation value of the initial value of the physical quantity based on the sampled AD value, improving the calculation accuracy.
The deviation of physical magnitude values is reduced, and the accuracy of calculations and real-time processing capabilities are improved.
Smart Images

Figure CN119135178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic technology, and in particular to an AD segmentation calculation method, computer equipment and medium. Background Art
[0002] In the application of resistive sensors, voltage divider circuits are often used to sample through A / D. The corresponding relationship between resistance value and physical quantity is usually described by a formula, but the calculation amount of this formula is very large, such as exponential and logarithmic calculations. If it is implemented using embedded microprocessor code, the code volume is large and the operation time is long, which is not conducive to embedded real-time and fast processing. Therefore, the more reasonable method is to segmentally linearize the formula. When the embedded code is used for calculation, the operation time is short and the code volume is small.
[0003] The traditional piecewise linear method extracts only a few nodes, and each node only includes the AD value and the corresponding physical quantity parameter to form a linear conversion parameter table. When the embedded code calculates the sensor physical quantity according to the linear conversion parameter table after collecting the AD value, each segment has only one slope, and the calculated physical quantity value often has a large deviation in the middle of the segment, such as Figure 1 shown.
[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present invention is to provide an AD segment calculation method, a computer device and a medium, aiming to solve the above-mentioned problems in the prior art.
[0006] To achieve the above object, the present invention provides an AD segmentation calculation method, the AD segmentation calculation method comprising:
[0007] Get the sampled AD value;
[0008] Traversing the nodes in the pre-established segment node data table in sequence until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node;
[0009] Taking the current node and the next node as a linear segment, calculating the initial value of the physical quantity corresponding to the sampled AD value;
[0010] Determine whether the node segment data of the node corresponding to the sampled AD value is a bidirectional deviation;
[0011] When the first judgment result is yes, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the zero-crossing AD value position;
[0012] When the first judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, the first deviation position being the position where the maximum deviation value of the physical quantity of the node segment is located;
[0013] According to the determined compensation value, the initial value of the physical quantity corresponding to the sampled AD value is compensated.
[0014] Preferably, in the AD segmented calculation method, when the first judgment result is yes, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the zero-crossing AD value position includes:
[0015] When the first judgment result is yes, judging whether the sampled AD value is greater than the zero-crossing AD value position;
[0016] When the second judgment result is no, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment;
[0017] When the second judgment result is yes, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment;
[0018] The first deviation position and the second deviation position are located on both sides of the node of the zero-crossing AD value position on the node segment and are the maximum deviation positions of the physical quantity on the current side.
[0019] Preferably, in the AD segment calculation method, when the second judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, includes:
[0020] When the second judgment result is no, judging whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment;
[0021] When the third judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((zero-crossing AD value position-sampling AD value) / (zero-crossing AD value position-AD value position of the first deviation position)*π / 2)*physical quantity value corresponding to the first deviation position;
[0022] When the third judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-zero-crossing AD value position) / (AD value position of the first deviation position-zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the first deviation position.
[0023] Preferably, in the AD segment calculation method, when the second judgment result is yes, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment, includes:
[0024] When the second judgment result is yes, judging whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment;
[0025] When the fourth judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((next node AD value-sampling AD value) / (next node AD value-second deviation position AD value position)*π / 2)*physical quantity value corresponding to the second deviation position;
[0026] When the fourth judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-zero-crossing AD value position) / (AD value position of the second deviation position-zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the second deviation position.
[0027] Preferably, in the AD segment calculation method, when the first judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, includes:
[0028] When the first judgment result is no, judging whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment;
[0029] When the fifth judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((next node AD value-sampling AD value) / (next node AD value-AD value position of the first deviation position)*π / 2)*physical quantity value corresponding to the first deviation position;
[0030] When the fifth judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-next node AD value) / (AD value position of the first deviation position-next node AD value)*π / 2)*physical quantity value corresponding to the first deviation position.
[0031] Preferably, in the AD segment calculation method, compensating the initial value of the physical quantity corresponding to the sampled AD value according to the determined compensation value includes:
[0032] The physical quantity value corresponding to the sampled AD value=the initial value of the physical quantity corresponding to the sampled AD value+the compensation value.
[0033] Preferably, in the AD segmentation calculation method, sequentially traversing the nodes in the pre-established segmentation node data table until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node includes:
[0034] Obtain a node from the pre-established segment node data table one by one;
[0035] Determine whether the sampled AD value is greater than or equal to the AD value position corresponding to the current node;
[0036] When the sixth judgment result is no, continue to take the next node for judgment until the sixth judgment result is yes.
[0037] Preferably, the method for establishing the segment node data table includes:
[0038] S1: Obtain a first data group from a pre-established valid relational database, and add its AD value position to a first segment, wherein the valid relational database includes a plurality of data groups, each data group includes an AD value and a corresponding physical quantity, and the plurality of data groups are arranged in order of AD values;
[0039] S2: step to the next data group;
[0040] Determine whether the linear deviation values of all data in the current segment are less than the preset control deviation value;
[0041] When the seventh judgment result is yes, the next data group is added to the current segment;
[0042] When the seventh judgment result is no, the current data group is removed from the current segment and the data group is traversed back to the previous data group, and the zero-crossing point of the physical quantity and its AD value position, the positive and negative maximum deviation values and their AD value positions in the current segment are searched, and they are stored in the corresponding node segment data table respectively;
[0043] Determine whether there are both positive and negative deviation values in the current segment;
[0044] When the eighth judgment result is yes, a first deviation flag is marked on the data in the current segment and stored in the corresponding node segment data table;
[0045] When the eighth judgment result is no, marking the data in the current segment with a second deviation identifier and storing it in the corresponding node segment data table;
[0046] S3: Determine whether the last data group has been traversed;
[0047] When the ninth judgment result is no, enter the next segment and jump to S2;
[0048] When the ninth judgment result is yes, the last data group is recorded as the final node and all node segment data tables are output.
[0049] Preferably, before the step of sequentially traversing the data groups in the pre-established valid relational database, the method further comprises:
[0050] Build an effective relational database.
[0051] Preferably, the establishing of a valid relational database comprises:
[0052] According to the AD full-scale value, calculate the voltage list of the corresponding voltage divider circuit;
[0053] According to the voltage list, calculate a corresponding sensor resistance value list;
[0054] According to the relationship function between the physical quantity and the resistance of the sensor, a list of physical quantity data corresponding to the list of sensor resistance values is calculated, and a corresponding table between AD values and physical quantities is formed;
[0055] The valid relationship database is determined according to the formed correspondence table between AD values and physical quantities and the upper and lower limit values of the physical quantities of the sensor.
[0056] Preferably, the resistance sensor is a temperature sensor;
[0057] Correspondingly, according to the relationship function between the physical quantity and resistance of the sensor, a physical quantity data list corresponding to the sensor resistance value list is calculated, and a corresponding table between AD value and physical quantity is formed. The relationship function between the physical quantity and resistance of the sensor is:
[0058] R2=EXP(B*(1 / T2-1 / T1)+LN(R1));
[0059] in,
[0060] R2 is the resistance value corresponding to T2;
[0061] R1 is the reference resistance value corresponding to the sensor;
[0062] T1 is the reference temperature value corresponding to the sensor;
[0063] B is the variation coefficient value corresponding to the sensor;
[0064] T2 is the temperature value to be calculated.
[0065] In order to achieve the above object, the present invention further provides an AD segment calculation device, the AD segment calculation device comprising:
[0066] An acquisition unit, used for acquiring a sampled AD value;
[0067] A loop traversal unit, used to sequentially traverse the nodes in the pre-established segment node data table until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node;
[0068] A calculation unit, used to calculate the initial value of the physical quantity corresponding to the sampled AD value by taking the current node and the next node as a linear segment;
[0069] A judging unit, used to judge whether the node segment data where the node corresponding to the sampled AD value is located is a bidirectional deviation;
[0070] A first determining unit, configured to determine a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than a zero-crossing AD value position when the first judgment result is yes;
[0071] A second determination unit is used to determine, when the first judgment result is no, a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of a first deviation position of the node segment, where the first deviation position is a position where the maximum deviation value of the physical quantity of the node segment is located;
[0072] The compensation unit is used to compensate the initial value of the physical quantity corresponding to the sampled AD value according to the determined compensation value.
[0073] In order to achieve the above object, the present invention further provides a computer device, comprising:
[0074] at least one processor; and,
[0075] a memory communicatively connected to the at least one processor; wherein,
[0076] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the AD segmentation calculation method according to any one of claims 1 to 7.
[0077] In order to achieve the above object, the present invention further provides a computer-readable storage medium storing a computer program, and the computer program is the above AD segmentation calculation method when executed by a processor.
[0078] The present invention has at least the following beneficial effects:
[0079] The present invention improves the traditional piecewise linear algorithm by adding more parameters to the piecewise linear table. The added parameters are used to perform fine deviation compensation after preliminary piecewise calculation, so that the deviation of the calculated physical value is small.
[0080] Furthermore, in the segment node data table, for each node in the segment with bidirectional deviation, the AD value, the corresponding physical quantity value, the segment data deviation mark, the first maximum deviation value of the segment and its corresponding AD value, the second maximum deviation value of the segment and its corresponding AD value, and the AD value corresponding to the node of the physical quantity zero crossing point in the segment; for each node in the segment with only unidirectional deviation, the AD value, the corresponding physical quantity value, the segment data deviation mark, the first maximum deviation value of the segment and its corresponding AD value are included. In this way, the calculated physical quantity value can be compensated more precisely, and the accuracy of the calculation can be improved.
[0081] Furthermore, different compensation methods are proposed for different situations, so that compensation can be performed more accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] Figure 1 It is a data deviation diagram solved by a traditional piecewise linear table in the prior art;
[0083] Figure 2 A comparison chart of deviation values between the algorithm of the present invention and the traditional algorithm;
[0084] Figure 3 A schematic diagram of the AD segmentation calculation method of the present invention;
[0085] Figure 4 It is a flow chart of the method for generating AD segmentation parameters of the resistance sensor of the present invention;
[0086] Figure 5 is a schematic diagram of a computer device of the present invention;
[0087] Figure 6 This is a comparison table of deviation values between the algorithm of the present invention and the traditional algorithm.
[0088] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0089] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0090] In the embodiments of the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0091] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0092] In the embodiments of the present invention, the term "plurality" refers to two or more than two, and other quantifiers are similar.
[0093] In the present invention, unless otherwise specified, the directional words used, such as "up, down, top, bottom", usually refer to the directions shown in the drawings, or to the components themselves in the vertical, perpendicular or gravity directions; similarly, for ease of understanding and description, "inside and outside" refer to the inside and outside relative to the outline of each component itself, but the above-mentioned directional words are not used to limit the present invention.
[0094] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it can be understood by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present invention. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present invention can also be implemented. The division of the following embodiments is for the convenience of description and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other under the premise of no contradiction.
[0095] The present invention provides an AD segmentation calculation method. Figure 3 The schematic diagram of the AD segmented calculation method is shown. The AD segmented calculation method is used for a resistance sensor, wherein the resistance sensor can be, but is not limited to, a temperature sensor, a humidity sensor, or a resistive pressure sensor. In other embodiments, the corresponding sensor type can be set as required. When the resistance sensor is a temperature sensor, the corresponding physical quantity is temperature; when the resistance sensor is a humidity sensor, the corresponding physical quantity is humidity.
[0096] At step 201, a sampled AD value is obtained.
[0097] At step 202 to step 204, the nodes in the pre-established segment node data table are traversed in sequence until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node. The segment node data table includes multiple nodes, such as node 1 (node_index=0), node 2 (node_index=1), .... The data associated when there is a bidirectional deviation in the segment where the node is located includes: the corresponding AD value position, the corresponding physical quantity value, the segment data deviation identifier, the first maximum deviation value of the segment and its corresponding AD value position, the second maximum deviation value of the segment and its corresponding AD value position, and the AD value position corresponding to the node of the physical quantity zero crossing point in the segment; the data associated with the node during the period when there is no bidirectional deviation in the segment where the node is located includes: the corresponding AD value position, the corresponding physical quantity value, the segment data deviation identifier, the first maximum deviation value of the segment and its corresponding AD value position.
[0098] Specifically, a node is obtained from the pre-established segment node data table in turn; whether the sampled AD value is greater than or equal to the AD value position corresponding to the current node is determined; when the determination result is no, the next node is continued to be determined until the sixth determination result is yes.
[0099] At step 205, the current node and the next node are used as a linear segment to calculate the initial value of the physical quantity corresponding to the sampled AD value. For example, if the sampled AD value is between the AD values corresponding to the node k and the node k+1, then the node k and the node k+1 are used as a linear segment to calculate the initial value of the physical quantity corresponding to the sampled AD value. Figure 1 Taking the data in as an example, the initial value of the physical quantity corresponding to the calculated sampled AD value is the temperature value determined by the traditional calculation method. The present invention first determines the initial value of the physical quantity corresponding to the sampled AD value by the traditional calculation method, and then compensates the initial value of the physical quantity to obtain the compensated physical quantity value.
[0100] At step 206, it is determined whether the node segment data where the node corresponding to the sampled AD value is located is a bidirectional deviation. Bidirectional deviation means that the node segment has both positive deviation and negative deviation, which can also be understood as the existence of positive and negative maximum deviations. The positive and negative maximum deviation value is the absolute value of the actual physical quantity in the segment - the physical quantity calculated by traditional calculation. When the actual physical quantity in the segment - the physical quantity calculated by traditional calculation is greater than 0, it is a negative deviation; when the actual physical quantity in the segment - the physical quantity calculated by traditional calculation is less than 0, it is a positive deviation. There are only negative deviations in the first segment, and there is a node with the largest negative deviation in the first segment. There are only negative deviations in the second segment, and there is a node with the largest negative deviation in the second segment. There are both negative deviations and positive deviations in the third segment. Then, in the third segment, the deviation value is 0, which is the node of the physical quantity zero crossing point, and the zero crossing AD value position is the AD value corresponding to the node of the physical quantity zero crossing point.
[0101] It should be understood that the segment data deviation flag indicates whether there is a bidirectional deviation in each segment. If there is a bidirectional deviation in the segment, the segment data is marked as the second deviation flag, or the segment data deviation flag of the segment can be set to 1; if there is no bidirectional deviation in the segment, the segment data is marked as the first deviation flag, or the segment data deviation flag of the segment can be set to 0. The specific flag used to mark whether there is a bidirectional deviation in each segment can also be indicated according to specific needs.
[0102] by Figure 2 Taking the first section as an example, using the traditional algorithm, there is only a negative deviation in the first section, only a negative deviation in the second section, and both negative and positive deviations in the third section.
[0103] At step 207, it is determined whether the sampled AD value is greater than the zero-crossing AD value position. When the node segment data of the node corresponding to the sampled AD value is a bidirectional deviation, the compensation value for the initial value of the physical quantity is determined according to whether the sampled AD value is greater than the zero-crossing AD value position. When the sampled AD value is greater than the zero-crossing AD value position, step 211 is executed; if the sampled AD value is not greater than the zero-crossing AD value position, step 208 is executed.
[0104] At step 208, when the sampled AD value is not greater than the zero-crossing AD value position, it is determined whether the sampled AD value is greater than the AD value position of the first deviation position. When the sampled AD value is greater than the AD value position of the first deviation position, step 209 is executed; when the sampled AD value is not greater than the AD value position of the first deviation position, step 210 is executed.
[0105] At step 209, the compensation value=sin((zero-crossing AD value position-sampled AD value) / (zero-crossing AD value position-AD value position of the first deviation position)*π / 2)*physical quantity value corresponding to the first deviation position.
[0106] At step 210, the compensation value=sin((sampled AD value-zero-crossing AD value position) / (AD value position of the first deviation position-zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the first deviation position.
[0107] At step 211, when the sampled AD value is greater than the zero-crossing AD value position, it is determined whether the sampled AD value is greater than the AD value position of the second deviation position. If the determination result at step 211 is yes, step 212 is executed, otherwise step 213 is executed.
[0108] At step 212, the compensation value = sin((the AD value of the next node - the sampled AD value) / (the AD value of the next node - the AD value position of the second deviation position)*π / 2)*the physical quantity value corresponding to the second deviation position.
[0109] At step 213, the compensation value = sin((sampled AD value - zero-crossing AD value position) / (AD value position of the second deviation position - zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the second deviation position.
[0110] It should be noted that when the data of the segment where the current node is located is a two-way deviation, that is, there are positive deviations and negative deviations in the segment where the current node is located. At this time, the first deviation position and the second deviation position are on both sides of the node of the zero-crossing AD value position on the node segment where they are located and are the maximum deviation positions of the current side physical quantity. When there is a positive maximum deviation on one side of the zero-crossing AD value position (the side where the AD value is smaller than the zero-crossing AD value position), the first deviation position is the node position where the positive maximum deviation value is located, and the corresponding AD value is the first deviation value; the second deviation position is the node position where the negative maximum deviation value is located, and the corresponding AD value is the second deviation value. Similarly, when there is a negative maximum deviation on one side of the zero-crossing AD value position (the side where the AD value is smaller than the zero-crossing AD value position), the first deviation position is the node position where the negative maximum deviation value is located, and the second deviation position is the node position where the positive maximum deviation value is located.
[0111] When the data of the segment where the current node is located is not a bidirectional deviation, then the segment where the current node is located either has only positive deviation or only negative deviation. At this time, whether there is only positive deviation or only negative deviation, the maximum positive and negative deviation positions are both the first deviation positions, and the corresponding AD value is the first deviation value.
[0112] like Figure 2 As shown, there is a zero-crossing point (node_index=k) in the third segment, then the position of the maximum negative deviation to the left of the zero-crossing point (node_index=k) in the third segment is the first deviation position, and the position of the maximum positive deviation to the right of the zero-crossing point (node_index=k) in the third segment is the second deviation position.
[0113] At step 214, it is determined whether the sampled AD value is greater than the AD value position of the first deviation position. When the node segment data where the node corresponding to the sampled AD value is located is not a bidirectional deviation, the compensation value for the initial value of the physical quantity is determined based on whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment where the sampled AD value is located, and the first deviation position is the position where the maximum deviation value of the physical quantity of the node segment is located. At this time, when the sampled AD value is greater than the AD value position of the first deviation position, step 215 is executed; otherwise, step 216 is executed.
[0114] At step 215, the compensation value=sin((the AD value of the next node-the sampled AD value) / (the AD value of the next node-the AD value position of the first deviation position)*π / 2)*the physical quantity value corresponding to the first deviation position.
[0115] At step 216, the compensation value = sin((sampled AD value - next node AD value) / (AD value position of the first deviation position - next node AD value)*π / 2)*physical quantity value corresponding to the first deviation position.
[0116] At step 218, the initial value of the physical quantity corresponding to the sampled AD value is compensated according to the determined compensation value. Specifically, the physical quantity value corresponding to the sampled AD value = the initial value of the physical quantity corresponding to the sampled AD value + the compensation value.
[0117] In addition, the method for generating data in the segment node data table is as follows: Figure 4 shown.
[0118] See also Figure 4 At step 101, according to the AD full-scale value, the voltage list of the corresponding voltage divider circuit is calculated. Taking the AD full-scale of 1024 as an example, it is necessary to calculate the voltage list of the corresponding voltage divider circuit between 0-1023. The specific calculation method can be a conventional calculation method. If the full-scale is 1024, then 1024 voltage values of the corresponding voltage divider circuit will be generated.
[0119] At step 102, a corresponding sensor resistance value list is calculated based on the voltage list. Taking the AD full scale of 1024 as an example, 1024 voltage values can be calculated accordingly. Similarly, each voltage value has a corresponding resistance value, so the corresponding 1024 resistance values can be calculated. Each voltage value corresponds to its resistance value.
[0120] At step 103, according to the relationship function between the physical quantity and resistance of the sensor, a list of physical quantity data corresponding to the list of sensor resistance values is calculated, and a corresponding table between AD values and physical quantities is formed. It should be noted that the sensor can be a humidity sensor, a temperature sensor, or a resistive pressure sensor. When the sensor is a humidity sensor, the physical quantity of the sensor corresponds to the humidity value; when the sensor is a temperature sensor, the physical quantity of the sensor corresponds to the temperature value. Taking the AD full scale as 1024 and the physical quantity as the temperature value as an example, the temperature value corresponding to each resistance value can be calculated, and a table of the relationship between the AD value and the physical quantity can be formed.
[0121] The function of the relationship between the physical quantity of the sensor and the resistance may be different for different sensors. For example, the function of the relationship between the physical quantity of the sensor and the resistance is: R2 = EXP (B * (1 / T2-1 / T1) + LN (R1));
[0122] in,
[0123] R2 is the resistance value corresponding to T2;
[0124] R1 is the reference resistance value corresponding to the sensor;
[0125] T1 is the reference temperature value corresponding to the sensor;
[0126] B is the variation coefficient value corresponding to the sensor;
[0127] T2 is the temperature value to be calculated.
[0128] For different sensors, R1 and T1 may be different. For example, in this embodiment, R1 is 5000 ohms and T1 is 25°C.
[0129] At step 104, the effective relationship database is determined based on the formed correspondence table between AD values and physical quantities and the upper and lower limits of the physical quantities of the sensor. According to the upper and lower limits of the physical quantities of the sensor, the correspondence between the AD values and the physical quantities formed in step 103 can be obtained by taking the data within the upper and lower limits of the physical quantities of the sensor. In this way, an effective relationship database can be formed. In the effective relationship data, each data group corresponds to an AD value and a physical quantity value corresponding to the AD value. In the effective relationship database, each data group is sorted according to the order of the AD value. For example, in the effective relationship database, the first data group T_AD_LIST[0] stores the AD value and the corresponding physical quantity value in the first data group, the second data group T_AD_LIST[1] stores the AD value and the corresponding physical quantity value in the second data group, and so on.
[0130] In step 105, the first data group of T_AD_LIST[0] is taken as the first segment node, and its corresponding AD value and physical quantity value. Specifically, the first data group is obtained from a pre-established valid relational database, and its AD value position is added to the first segment, wherein the valid relational database includes multiple data groups, each data group includes an AD value and a corresponding physical quantity, and the multiple data groups are arranged in the order of AD values. Figure 2 As shown, there are 6 segments in total (the 6th segment is not marked). In step 105, the first data group in the valid relational database is taken and added to the first segment.
[0131] In step 106, the AD value position of the data group is incremented by 1, and the next data group is obtained. The sequence number of each data group is incremented by 1. For example, if the data group obtained last time is T_AD_LIST[0], then the data group obtained this time is T_AD_LIST[1], and the data group obtained next time will be T_AD_LIST[2], and so on. Assuming that the AD value in the data group T_AD_LIST[0] is 25, then the AD value of T_AD_LIST[1] is 26, and so on.
[0132] like Figure 5As shown, Figure 5 It includes 16 data groups, a row of data with AD value of 25 is the first data group T_AD_LIST[0], a row of data with AD value of 26 is the second data group T_AD_LIST[1], and so on.
[0133] In step 107, it is determined whether the linear deviation values of all data in the current segment are less than the preset control deviation value. If the first judgment result is yes, the next data group is added to the current segment and the judgment is continued. Assuming that the current segment is still in the first segment, it is determined whether the deviation values of the physical quantities corresponding to all data groups in the first segment and the actual physical quantities are less than the preset control deviation value. Figure 2 As shown, the deviation between the actual physical quantity corresponding to each data group in the first section and the physical quantity calculated by the traditional method is the linear deviation value of each data group data, that is, the absolute value of the deviation between the actual physical quantity of each data group in the first section and the physical quantity calculated by the traditional method. The preset control deviation value is set according to the requirements.
[0134] Assuming that the linear deviation values of all data in the current segment are less than the preset control deviation value, then continue to take the next data group, and continue to judge whether the linear deviation values of all data after the current segment is added to the next data group are less than the preset control deviation value. If the condition is still met, continue to take the next data group; if the condition is not met, the currently taken data group is not used as the data in the current segment, and step 108 is executed to return to the previous data group. The previous data group is the end position of the current segment and also the starting position of the next segment.
[0135] For example, after taking T_AD_LIST[0], continue to take T_AD_LIST[1]. T_AD_LIST[0] and T_AD_LIST[1] are both data in the first segment. At this time, determine whether the linear deviation values of all data in the first segment are less than the preset control deviation value. If the linear deviation values of all data in the first segment are less than the preset control deviation value, continue to take T_AD_LIST[2] and add it to the first segment; continue to determine whether the linear deviation values of all data in the first segment are less than the preset control deviation value. If the determination result is no, move T_AD_LIST[2] out of the first segment. At this time, T_AD_LIST[1] is used as the current traversed data, and T_AD_LIST[1] is used as the end position of the first segment and the starting position of the second segment; continue to take T_AD_LIST[2]. At this time, T_AD_LIST[1] and T_AD_LIST[2] are the data of the second segment. Determine whether the linear deviation values of all data in the second segment are less than the preset control deviation value, and so on.
[0136] In step 109, the current data group removes the current segment, searches for the zero-crossing point of the physical quantity in the current segment and its AD value position, the positive and negative maximum deviation values and their AD value positions, and stores them in the corresponding node segment data table. At this time, the judgment result of step 107 is no. It should be noted that the zero-crossing point of the physical quantity in the current segment is a data group with a positive and negative deviation value of 0, and the actual physical quantity in this data group - the physical quantity calculated by the traditional method is 0. Figure 2 As shown, there is no zero point of physical quantity in the first segment, the second segment, the fourth segment, the fifth segment, and the sixth segment, while there is a data group with a zero point of physical quantity in the third segment. The maximum positive and negative deviation value is the absolute value of the deviation value between the actual physical quantity and the traditionally calculated physical quantity in the segment. When the deviation value between the actual physical quantity and the traditionally calculated physical quantity in the segment is greater than 0, it is a negative deviation; when the deviation value between the actual physical quantity and the traditionally calculated physical quantity in the segment is less than 0, it is a positive deviation. The maximum deviation of the first segment is a negative deviation, and there is a data group with the largest negative deviation in the first segment. The maximum deviation of the second segment is also a negative deviation, and there is a data group with the largest negative deviation in the second segment. The third segment has both negative and positive deviations, so the deviation value of 0 in the third segment is the data group with the zero point of physical quantity.
[0137] At step 110, it is determined whether there are both positive and negative deviation values in the current segment. Figure 1 For example, the first segment only has negative deviations, the second segment only has negative deviations, and the third segment has both negative deviations and positive deviations. When there are both positive and negative deviations in the current segment, step 112 is executed, and all data in the current segment need to be marked with the second deviation mark and stored in the corresponding node segment data table. When there are not both positive and negative deviations in the current segment, step 111 is executed, and all data in the current segment need to be marked with the first deviation mark and stored in the corresponding node segment data table. When there is a two-way deviation in the segment, each node in the segment in the node segment data table includes the following data: AD value, corresponding physical quantity value, segment data deviation mark, the first maximum deviation value of the segment and its corresponding AD value, the second maximum deviation value of the segment and its corresponding AD value, and the AD value corresponding to the data group of the physical quantity zero crossing point in the segment; when there is no two-way deviation in the segment, each node in the segment in the node segment data table includes the following data: AD value, corresponding physical quantity value, segment data deviation mark, the first maximum deviation value of the segment and its corresponding AD value.
[0138] It should be understood that the segment data deviation flag indicates whether there is a bidirectional deviation in each segment. If there is a bidirectional deviation in the segment, the segment data is marked as the second deviation flag, or the segment data deviation flag of the segment can be set to 1; if there is no bidirectional deviation in the segment, the segment data is marked as the first deviation flag, or the segment data deviation flag of the segment can be set to 0. The specific flag used to mark whether there is a bidirectional deviation in each segment can also be indicated according to specific needs.
[0139] Among them, when the segment where the data group is located only has the maximum positive deviation, the segment data deviation mark is represented as the first deviation mark; when the segment where the data group is located only has the maximum negative deviation, the segment data deviation mark is represented as the first deviation mark; when the segment where the data group is located has both the maximum positive deviation and the maximum negative deviation, the segment data deviation mark is represented as the second deviation mark. That is, when the segment where the data group is located has a unidirectional deviation (that is, there is only a positive deviation or only a negative deviation in the segment), the segment data deviation mark is represented as the first deviation mark; when the segment where the data group is located has a bidirectional deviation, the segment data deviation mark is represented as the second deviation mark.
[0140] When there is only one-way deviation, the first maximum deviation value is the maximum deviation value in the one-way deviation. When there is a two-way deviation, the first maximum deviation value is one deviation value in the two-way deviation, and the second maximum deviation value is another deviation value in the two-way deviation.
[0141] For the sake of convenience, the AD value corresponding to the first maximum deviation value is the first deviation position, and the AD value corresponding to the second maximum deviation value is the second deviation position.
[0142] Further, when the data in the segment where the current data group is located is a bidirectional deviation, that is, there are positive deviations and negative deviations in the segment where the current data group is located. At this time, the first deviation position and the second deviation position are on both sides of the data group of the zero-crossing AD value in the data group segment where they are located and are the maximum deviation positions of the physical quantity on the current side. When there is a positive maximum deviation on one side of the zero-crossing AD value (the side where the AD value is smaller than the zero-crossing AD value), the first deviation position is the data group position where the positive maximum deviation value is located, and the corresponding AD value is the first deviation value; the second deviation position is the data group position where the negative maximum deviation value is located, and the corresponding AD value is the second deviation value. Similarly, when there is a negative maximum deviation on one side of the zero-crossing AD value (the side where the AD value is smaller than the zero-crossing AD value), the first deviation position is the data group position where the negative maximum deviation value is located, and the second deviation position is the data group position where the positive maximum deviation value is located.
[0143] When the data in the segment where the current data group is located is not a bidirectional deviation, then the segment where the current data group is located either has only positive deviation or only negative deviation. At this time, whether there is only positive deviation or only negative deviation, the maximum positive and negative deviation positions are both the first deviation positions, and the corresponding AD value is the first deviation value.
[0144] At step 113, it is determined whether the last data group has been traversed. It is determined whether all data groups have been traversed. If the current data group is not the last data group, it proceeds to the next segment and continues to execute step 106. If the current data group is the last data group, it records the last data group as the final node and outputs all node segment data tables.
[0145] In order to achieve the above object, the present invention also provides a computer device, such as Figure 5 As shown, the cleaning base station includes at least one processor 501; and a memory 502 that is communicatively connected to the at least one processor 501; wherein the memory 502 stores instructions that can be executed by the at least one processor 501, and the instructions are executed by the at least one processor 501 so that the at least one processor 501 can execute the above-mentioned AD segmentation calculation method.
[0146] The memory 502 and the processor 501 are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors 501 and the memory 502 together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor 501 is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor 501.
[0147] The processor 501 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 502 can be used to store data used by the processor 501 when performing operations.
[0148] In order to achieve the above object, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above AD segmentation calculation method when executed by a processor.
[0149] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned implementation method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each implementation of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0150] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, ordinary technicians in this field can make other different forms of changes or modifications without creative work, which should fall within the scope of protection of the present invention.
Claims
1. An AD segmentation calculation method, characterized in that: include: Get the sampled AD value; Traversing the nodes in the pre-established segment node data table in sequence until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node; Taking the current node and the next node as a linear segment, calculating the initial value of the physical quantity corresponding to the sampled AD value; Determine whether the node segment data of the node corresponding to the sampled AD value is a bidirectional deviation; When the first judgment result is yes, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the zero-crossing AD value position; When the first judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, the first deviation position being the position where the maximum deviation value of the physical quantity of the node segment is located; According to the determined compensation value, the initial value of the physical quantity corresponding to the sampled AD value is compensated.
2. The AD segment calculation method according to claim 1, characterized in that: When the first judgment result is yes, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the zero-crossing AD value position includes: When the first judgment result is yes, judging whether the sampled AD value is greater than the zero-crossing AD value position; When the second judgment result is no, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment; When the second judgment result is yes, determining a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment; The first deviation position and the second deviation position are located on both sides of the node of the zero-crossing AD value position on the node segment and are the maximum deviation positions of the physical quantity on the current side.
3. The AD segment calculation method according to claim 2, characterized in that: When the second judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, includes: When the second judgment result is no, judging whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment; When the third judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((zero-crossing AD value position-sampling AD value) / (zero-crossing AD value position-AD value position of the first deviation position)*π / 2)*physical quantity value corresponding to the first deviation position; When the third judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-zero-crossing AD value position) / (AD value position of the first deviation position-zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the first deviation position.
4. The AD segment calculation method according to claim 2, characterized in that: When the second judgment result is yes, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment, includes: When the second judgment result is yes, judging whether the sampled AD value is greater than the AD value position of the second deviation position of the node segment; When the fourth judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((next node AD value-sampling AD value) / (next node AD value-second deviation position AD value position)*π / 2)*physical quantity value corresponding to the second deviation position; When the fourth judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-zero-crossing AD value position) / (AD value position of the second deviation position-zero-crossing AD value position)*π / 2)*physical quantity value corresponding to the second deviation position.
5. The AD segment calculation method according to claim 1, characterized in that: When the first judgment result is no, determining the compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment, includes: When the first judgment result is no, judging whether the sampled AD value is greater than the AD value position of the first deviation position of the node segment; When the fifth judgment result is yes, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((next node AD value-sampling AD value) / (next node AD value-AD value position of the first deviation position)*π / 2)*physical quantity value corresponding to the first deviation position; When the fifth judgment result is no, the calculation formula for the compensation value of the initial value of the physical quantity is: compensation value = sin((sampling AD value-next node AD value) / (AD value position of the first deviation position-next node AD value)*π / 2)*physical quantity value corresponding to the first deviation position.
6. The AD segment calculation method according to claim 1, characterized in that: The step of compensating the initial value of the physical quantity corresponding to the sampled AD value according to the determined compensation value includes: The physical quantity value corresponding to the sampled AD value=the initial value of the physical quantity corresponding to the sampled AD value+the compensation value.
7. The AD segment calculation method according to claim 1, characterized in that: The step of sequentially traversing the nodes in the pre-established segment node data table until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node includes: Obtain a node from the pre-established segment node data table one by one; Determine whether the sampled AD value is greater than or equal to the AD value position corresponding to the current node; When the sixth judgment result is no, continue to take the next node for judgment until the sixth judgment result is yes.
8. An AD segment calculation device, characterized in that: include: An acquisition unit, used for acquiring a sampled AD value; A loop traversal unit, used to sequentially traverse the nodes in the pre-established segment node data table until the sampled AD value is greater than or equal to the AD value position corresponding to the current node and less than the AD value position corresponding to the next node; A calculation unit, used to calculate the initial value of the physical quantity corresponding to the sampled AD value by taking the current node and the next node as a linear segment; A judging unit, used to judge whether the node segment data where the node corresponding to the sampled AD value is located is a bidirectional deviation; A first determining unit, configured to determine a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than a zero-crossing AD value position when the first judgment result is yes; A second determination unit is used to determine, when the first judgment result is no, a compensation value for the initial value of the physical quantity according to whether the sampled AD value is greater than the AD value position of a first deviation position of the node segment, where the first deviation position is a position where the maximum deviation value of the physical quantity of the node segment is located; The compensation unit is used to compensate the initial value of the physical quantity corresponding to the sampled AD value according to the determined compensation value.
9. A computer device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the AD segmentation calculation method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the AD segmentation calculation method according to any one of claims 1 to 7 is implemented.
