Simulation Software source code location in: http://download.csdn.net/detail/dijkstar/5565111,http://www.pudn.com/downloads552/sourcecode/windows/other/detail2276765.html
1 Principle
Assuming a sampling system, the ad part can obtain the number, and the corresponding physical quantity is voltage (or other );
① If an ad Value Point xmin is calibrated at "zero" and an ad Value Point xmax is calibrated at "maximum", based on the principle that "Two Points form a straight line, we can get a straight line that is connected by the zero point and the maximum point. The slope k of this line is easy to obtain, and then the linear equation is used to solve each vertex x (AD sample value ), the physical quantity (voltage value) corresponding to the ad value can be obtained ):
Slope k in:
K = (Ymax-ymin)/(xmax-xmin)
(Because the first point is "zero", the above ymin = 0)
Therefore, the physical quantity corresponding to any point of ad value:
Y = K × (XAD-xmin) + 0
② AboveAlgorithmOnly calibration is made between the "zero point" and "maximum point". If the ad sample value in the middle is used, it will bring a large error in the corresponding physical quantity, the solution is to insert more calibration points.
For example, four calibration points (x1, Y1), (X2, Y2), (X3, Y3), and (X4, Y4) are inserted respectively:
In this way, it will not be a straight line, but a "discount" (equivalent to segment Processing). If you want to solve the voltage value corresponding to the XAD value between X1 and X2:
Y = k x (XAD-X1) + Y1
As shown above, the more "calibration points" inserted in the middle, the higher the "precision" of the obtained physical value.
2. Simulation Software
According to the above idea, a linear calibration simulation software is realized, which includes:
A. Management of the "calibration points" set (adding, deleting, saving, and reading );
B calculates the physical quantity corresponding to a new ad value.
The Simulation Software reads the "calibration point" set every time it starts initialization (stored in "configuration. INI); when a new calibration point is added, insert it to the corresponding position in order; input the voltage corresponding to the ad value to be solved, the ad value finds the appropriate location in the "calibration point" set and calculates the physical quantity corresponding to the ad based on the linear equation.
The software must be used with the "configuration. ini" file. All the implementations of calibration are in ACQ. h and ACQ. cpp.