System and method for automatically calibrating sampling circuit in circuit board
Technical Field
The invention relates to the field of automatic calibration of a sampling circuit in a circuit board, in particular to a system and a method for automatically calibrating the sampling circuit in the circuit board.
Background
Power consumption is a key parameter for power supply design and even board level circuit design, and is usually calculated indirectly by calculating current using power sensing of a single power rail in the circuit, i.e. voltage measurement across a sampling resistor. These voltage measurements are made using an on-board micro control unit and analog-to-digital conversion circuitry. The sampling circuit in the calibrated circuit board includes a sampling resistor and a circuit connected to an MCU (Micro Control Unit), where usually, two ends of the sampling resistor in the circuit are connected to a differential operational amplifier circuit or an ADC (Analog-Digital Converter), and the differential operational amplifier circuit or the Analog-Digital Converter (ADC) converts the voltage Analog signals at two ends of the sampling resistor into Digital signals and sends the Digital signals to the MCU. By digitizing the voltage across the sampling resistor, the voltage and current of the power rail on which the sampling resistor is located can be calculated, and the power consumption of the power supply can be calculated. However, the measured and calculated value of the sampling circuit is often different from the actual value, and there is still a system scheme for automatically calibrating the circuit applying the sampling resistor in the actual circuit board.
Most of the retrieved patent applications use a special calibration circuit in the whole circuit to realize error compensation, and are specific to each specific application, the calibration circuits in the patent applications are complex in realization, various in types, without universality, increase in material cost, and possibly bring new errors, so that the calibration circuits are not suitable for being applied to sampling circuits of circuit boards of a plurality of power supply tree networks.
According to the scheme, a power supply is a constant current power supply of 1 ampere, the deviation condition of the resistance value of the tested sampling resistor is judged through the indication of an LED lamp, the sampling circuit in the circuit board is not tested and calibrated under different voltage and current, and the program upgrading of the sampling circuit cannot be carried out, so that the measurement accuracy of the voltage and current power consumption in the circuit is improved.
In the other scheme, calibration parameters are obtained only through data of two points and by adopting a linear function of y-kx + b, data processing is not accurate enough, and the correlation and the fitting degree can not meet the requirement of accurate measurement of voltage, current and power consumption values of different power supply circuits in different power supply tree networks on a circuit board under specific loads.
The selected measuring point data in the existing automatic calibration method is few, only calibration parameters can be simply calculated, and other circuits formed by attached components are generally adopted for calibrating the sampling circuit in the existing circuit board to carry out error compensation, so that the calibration accuracy of the sampling circuit in the circuit board is difficult to meet.
Disclosure of Invention
The present invention is directed to overcome the above drawbacks of the prior art, and provides a system and a method for automatically calibrating a sampling circuit in a circuit board, which can quickly and accurately complete the calibration and upgrade of the sampling circuit in the circuit board, and improve the calibration accuracy of the sampling circuit in the circuit board.
The invention provides a system for automatically calibrating a sampling circuit, wherein the sampling circuit in a circuit board comprises a Micro Control Unit (MCU) and a sampling resistor, the system comprises an upper computer control terminal, a program-controlled direct-current power supply, a voltage acquisition device and a direct-current electronic load, the voltage acquisition device is connected to two ends of the sampling resistor of the sampling circuit, and measurement data are transmitted to the upper computer control terminal in real time; the upper computer control terminal controls the calibration process in a centralized manner, data acquisition is completed according to preset data acquisition times, data analysis is performed according to a specified algorithm, a report form of error compensation is automatically generated, program upgrading is performed on an MCU of the sampling circuit in the circuit board, and calibration of the sampling circuit is completed.
On the basis of the technical scheme, the upper computer control terminal sends parameters of the program-controlled direct-current power supply, the voltage acquisition device and the direct-current electronic load at a specified time, triggers the measurement equipment and starts a calibration action; and the MCU of the sampling circuit in each measuring device and the circuit board transmits the measured data back to the upper computer control terminal in real time.
On the basis of the technical scheme, the upper computer control terminal collects and records data of each calibration action, selects a proper calibration strategy, performs error analysis and compensation, and updates the result into the program of the MCU of the sampling circuit in the circuit board.
On the basis of the technical scheme, the upper computer control terminal is unified and coordinated, the output of the program-controlled direct-current power supply and the load of the direct-current electronic load are set, and the voltage at two ends of the sampling resistor is measured; after the one-time wiring is finished, the upper computer control terminal performs data acquisition for multiple times according to presetting, after all data acquisition is finished, the upper computer control terminal provides multiple algorithms for data analysis, data reports containing voltage current values, power values and error compensation values in multiple formats are generated by one key, the MCU program of the sampling circuit in the circuit board is upgraded, and the calibration of the sampling circuit is completed.
On the basis of the technical scheme, the algorithm provided by the upper computer control terminal comprises a linear, quadratic polynomial, an exponential function and a moving average fitting algorithm, the upper computer control terminal carries out calibration curve and error compensation, a least square method is used as a basic criterion, the correlation coefficient and the mean square error of each algorithm are calculated, the fitting degrees of different algorithms are compared, and the most accurate fitting algorithm for the sampling circuit is selected.
The invention also provides a method for automatically calibrating the sampling circuit in the circuit board based on the system, which comprises the following steps:
connecting a host computer control terminal, a program-controlled direct-current power supply, a voltage acquisition device and a direct-current electronic load by using a system bus, connecting two ends of a sampling resistor in a sampling circuit of a circuit board with the voltage acquisition device, connecting one end of a cable with the program-controlled direct-current power supply, and connecting the other end of the cable with the direct-current electronic load;
starting each instrument, starting a control terminal of an upper computer, and setting related parameters;
the upper computer control terminal centrally controls the calibration process, calculates the power consumption value after completing data acquisition according to the preset data acquisition times, performs data analysis according to the specified algorithm, automatically generates an error compensation report, performs program upgrade on the MCU of the sampling circuit in the circuit board, and completes the calibration of the sampling circuit.
On the basis of the technical scheme, the process of completing data acquisition comprises the following steps:
the upper computer control terminal controls the output voltage of the program-controlled direct-current power supply and the load current of the direct-current electronic load, acquires a voltage value, a current value and a power consumption value from the MCU of the sampling circuit according to the preset data acquisition times, reads the voltage value from the voltage acquisition device and reads the current value from the program-controlled direct-current power supply.
On the basis of the technical scheme, when data analysis is carried out according to a specified algorithm, the algorithm provided by the upper computer control terminal comprises a linear first-order polynomial, a second-order polynomial, an exponential function and a moving average fitting algorithm, the upper computer control terminal carries out calibration curve and error compensation, a least square method is used as a basic criterion, the correlation coefficient and the mean square error of each algorithm are calculated, the fitting degrees of different algorithms are compared, and the most accurate fitting algorithm for the sampling circuit is selected.
On the basis of the technical scheme, the method further comprises the following steps: when the upper computer control terminal is started, the upper computer control terminal carries out system self-check, sends an instruction to each instrument device connected to the system bus, receives information returned by each instrument device, detects system connectivity and judges whether the whole system is ready to finish.
On the basis of the technical scheme, when the upper computer control terminal is started, the following relevant parameters are set: measuring range, resolution, testing step length, up-down stroke selection and cycle number.
Compared with the prior art, the invention has the following advantages:
the upper computer control terminal of the invention combines all instruments and devices with the sampling circuit in the circuit board to be calibrated to form a specific loop through a system bus, the specific loop is started and operated by one key, the data collection in the calibration process is realized, a proper algorithm is selected, the calibration curve and error compensation data are obtained according to the requirements of the sampling circuit in the actual circuit board, a report is generated, the error analysis and compensation are carried out, the corresponding error compensation data table in the report is extracted, the error compensation data table is downloaded to a micro control unit MCU of the sampling circuit through the upper computer control terminal for program upgrading, the upgrading and calibration work of the sampling circuit in the circuit board is rapidly and accurately completed, compared with the error compensation of other circuits which are usually formed by accessory components and parts in the calibration of the sampling circuit in the existing circuit board, the invention is beneficial to realizing the precise measurement of parameters such as current, the accuracy of the calibration of the sampling circuit in the circuit board can be improved.
Drawings
Fig. 1 is a block diagram of a system for automatically calibrating a sampling circuit in a circuit board according to an embodiment of the present invention.
Fig. 2 is a schematic connection diagram for calibrating a sampling circuit in a circuit board according to an embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the figures and the embodiments.
Example 1
Referring to fig. 1, an embodiment of the present invention provides a system for automatically calibrating a sampling circuit in a circuit board, where the sampling circuit in the circuit board includes a Micro Control Unit (MCU), an Analog-to-Digital Converter (ADC), and a sampling resistor, which are connected in sequence, the system includes an upper computer Control terminal, a program-controlled dc power supply, a voltage acquisition device, and a dc electronic load, a system loop is connected and networked by an RS232 or GPIB bus, and the voltage acquisition device is a voltmeter or a data acquisition card, and is connected to two ends of the sampling resistor of the sampling circuit, and sends measurement data to the upper computer Control terminal in real time.
The upper computer control terminal centrally controls the calibration process, each time data acquisition is sent by the upper computer control terminal, the program-controlled direct-current power supply provides proper current and voltage, the electronic load provides proper load pulling, and the voltmeter or the data acquisition card sends the measurement data to the upper computer control terminal in real time.
And after the upper computer control terminal finishes data acquisition according to the preset data acquisition times, performing data analysis according to a specified algorithm, automatically generating an error compensation report, and performing program upgrading on the MCU of the sampling circuit in the circuit board to finish the calibration of the sampling circuit.
The upper computer control terminal forms a specific loop with all instrument equipment and sampling circuits in a circuit board to be calibrated through a system bus, the specific loop is connected, one-key starting and operation are performed, data collection in the calibration process is achieved, a proper algorithm is selected, calibration curves and error compensation data are obtained according to the requirements of the sampling circuits in the actual circuit board, a report is generated, error analysis and compensation are performed, a corresponding error compensation data table in the report is extracted, the error compensation data table is downloaded to a Micro Control Unit (MCU) of the sampling circuits through the upper computer control terminal, program upgrading is performed, and upgrading and calibration work of the sampling circuits in the circuit board is completed quickly and accurately.
Compared with the prior art that the calibration of the sampling circuit in the circuit board usually adopts other circuits composed of auxiliary components for error compensation, the embodiment of the invention is beneficial to realizing the precise measurement of parameters such as current, power and the like, and can improve the calibration accuracy of the sampling circuit in the circuit board.
Example 2
In addition to embodiment 1, the upper computer control terminal can be developed on a PC by C language, LabVIEW (virtual instrument development environment), or the like. The upper computer control terminal sends parameters of the program-controlled direct-current power supply, the data acquisition card and the electronic load at a specified time, and triggers the devices to start a calibration action; each measuring device and the MCU transmit measured data back to the upper computer control terminal in real time through a communication network (such as RS232, USB, TCP/IP and the like). The most important function of the upper computer control terminal is to collect and record data of each calibration action, select a proper calibration strategy (such as various fitting algorithms) to carry out error analysis and compensation, and update the result into the program of the MCU. For example, after the relevant equipment is connected, the corresponding option of the software is clicked to test the connectivity, the corresponding tab is observed, and the test strategy is selected.
The programmable dc power supply is selected according to the requirements of the actual circuit, and generally a power supply with a suitable voltage and current supply capability is selected, for example: agilent E3634A (0-25V, 7A/0-50V, 4A). Before each system calibration action is started, the upper computer control terminal is required to send an instruction to the power supply setting determination value. For example, when the test is performed in the through-current 1A, 1A needs to be clicked or input in a corresponding space in the software power tab, or an automatic test is clicked, the through-current step length is set, and the program automatically sets the output size of the program-controlled dc power supply.
Selecting a digital voltmeter or a data acquisition card with proper voltage measurement capability according to the requirements of an actual circuit, for example: agilent 34970A/34902A modules (16channels) has the precision of more than 6 bits and can simultaneously transmit multiple paths of measurement data to a host computer control terminal.
According to the requirements of the actual circuit, selecting a direct current electronic load with proper voltage and current extraction capacity, such as: chroma 63640-5E-load or Faith FT6301A (120V, 30A, 150W) to simulate real workloads to calibrate the sampling circuits in the circuit board.
Common measuring instruments support RS232 or GPIB (General-Purpose Interface Bus) protocols, are provided with interfaces of two buses in a rear-mounted mode, and are also provided with development routines when leaving factories. The upper computer control terminal can be conveniently bridged with the test instrument through system buses such as a USB Hub (USB interface Hub), a USB-to-RS 232 cable, a USB-to-GPIB cable and the like. The control software develops a driver based on RS232 and GPIB, and can be compatible with the system bus to complete the control and data collection of the instrument and equipment.
Example 3
On the basis of the embodiment 1, the upper computer control terminal is unified and coordinated, the output of the program-controlled direct-current power supply and the load of the electronic load can be set at one time, and the voltage at two ends of the sampling resistor is measured; after once wiring is completed, the upper computer control terminal can simultaneously carry out a plurality of data acquisition processes according to presetting, thereby reducing the error probability and improving the working efficiency.
After all data are collected, the upper computer control terminal provides a plurality of algorithms for a user to select for data analysis, the algorithms provided by the upper computer control terminal comprise a linear polynomial, a second-order polynomial, an exponential function and a moving average fitting algorithm, the upper computer control terminal carries out calibration curve and error compensation, a least square method is used as a basic criterion, a correlation coefficient and a mean square error of each algorithm are calculated, fitting degrees of different algorithms are compared, and the most accurate fitting algorithm for a sampling circuit is selected.
The upper computer control terminal generates data report tables with various formats, including voltage current values, power values, error compensation values and the like, by one key, a user can directly extract data, upgrade the program of a micro control unit in the system and finish the calibration of the sampling circuit. Compared with the prior art that the calibration of the sampling circuit in the circuit board usually adopts other circuits composed of auxiliary components for error compensation, the embodiment of the invention is beneficial to realizing the precise measurement of parameters such as current, power and the like, and can improve the calibration accuracy of the sampling circuit in the circuit board.
Example 4
The embodiment of the invention provides a method for automatically calibrating a sampling circuit in a circuit board based on the system in the embodiment 1, which comprises the following steps:
referring to fig. 2, a system bus is used to connect an upper computer control terminal, a program-controlled dc power supply, a voltage acquisition device and a dc electronic load, two ends of a sampling resistor in a sampling circuit of a circuit board are connected to the voltage acquisition device, one end of a cable is connected to the program-controlled dc power supply, and the other end of the cable is connected to the dc electronic load;
starting each instrument, starting an upper computer control terminal, and setting the following relevant parameters: measuring range, resolution, testing step length, up-down stroke selection and cycle number;
the upper computer control terminal centrally controls the calibration process, calculates the power consumption value after completing data acquisition according to the preset data acquisition times, performs data analysis according to the specified algorithm, automatically generates an error compensation report, performs program upgrade on the MCU of the sampling circuit in the circuit board, and completes the calibration of the sampling circuit.
The upper computer control terminal forms a specific loop by all the instrument devices and the sampling circuit in the circuit board to be calibrated through a system bus, and the specific loop is connected, started and operated by one key, so that the collection of data in the calibration process is realized, a proper algorithm is selected, and aiming at the requirement of the sampling circuit in the actual circuit board, obtaining a calibration curve and error compensation data, generating a report, carrying out error analysis and compensation, extracting a corresponding error compensation data table in the report, the program is upgraded by downloading the program to a micro control unit MCU of the sampling circuit through a control terminal of an upper computer, the upgrading and calibration work of the sampling circuit in the circuit board is rapidly and accurately completed, compared with the prior art that the calibration of the sampling circuit in the circuit board usually adopts other circuits composed of auxiliary components for error compensation, the embodiment of the invention is beneficial to realizing the precise measurement of parameters such as current, power and the like, and can improve the calibration accuracy of the sampling circuit in the circuit board.
Example 5
On the basis of embodiment 4, when the upper computer control terminal is started, the upper computer control terminal performs system self-check, sends an instruction to each instrument device connected to the system bus, receives information returned by each instrument device, detects system connectivity, and determines whether the whole system is ready to be completed.
The process of finishing data acquisition by the upper computer control terminal comprises the following steps:
the upper computer control terminal controls the output voltage of the program-controlled direct-current power supply and the load current of the direct-current electronic load, acquires a voltage value, a current value and a power consumption value from the MCU of the sampling circuit according to the preset data acquisition times, reads the voltage value from the voltage acquisition device and reads the current value from the program-controlled direct-current power supply.
When the upper computer control terminal analyzes data according to a specified algorithm, the algorithm provided by the upper computer control terminal comprises a linear, a second-order polynomial, an exponential function and a moving average fitting algorithm, the upper computer control terminal makes a calibration curve and error compensation, a least square method is used as a basic criterion, a correlation coefficient and a mean square error of each algorithm are calculated, fitting degrees of different algorithms are compared, and the most accurate fitting algorithm for a sampling circuit is selected.
Example 6
The embodiment of the invention provides a method for automatically calibrating a sampling circuit in a circuit board based on the system in the embodiment 1, which comprises the following steps:
1) in actual operation, the required equipment is prepared according to the mode shown in fig. 2, a GPIB bus is connected to an upper computer control terminal, a program-controlled dc power supply, a data acquisition card and a dc electronic load, two ends of a sampling resistor in a sampling circuit on a circuit board are connected to the data acquisition card, one end of a cable is connected to the program-controlled dc power supply, and the other end of the cable is connected to the dc electronic load; and after preheating each instrument for five minutes, starting a control terminal of the upper computer, clicking the system for self-checking, sending an instruction to each instrument connected to the bus by the program, receiving information returned by each instrument, detecting the connectivity of the system, and judging whether the whole calibration system is ready to be finished. The apparatus in fig. 2 needs to have performance under specific conditions to meet the test requirements.
2) Opening an upper computer control terminal, and setting related parameters: measuring range, resolution, testing step length, up-down stroke selection, cycle number and the like; for example: when calibrating a power sampling circuit with normal working voltage V and maximum working current I, the voltage measurement range can be set to 0.9V-1.1V, the voltage test step length can be set to 0.1V, the current test range can be set to 0-1.2I, the current test step length can be set to 0.2A, the upstroke (namely, the voltage is supplied from low to high and the current is supplied from small to large) is selected, and the cycle number is set to 2.
3) The upper computer control terminal starts to control the output voltage of the program-controlled direct-current power supply to be 0.9V, sends an instruction to enable the load current of the direct-current electronic load to be 0, obtains a voltage value A11, a current value B11 and a power consumption value C11 from an MCU of the sampling circuit, and simultaneously reads a voltage value X11, a current value Y11 and a power consumption value Z11 from the data acquisition card.
4) According to the test of the up stroke, the upper computer control terminal respectively sends commands to enable the direct current electronic load to be in a load current range of 0.2I, 0.4I, 0.6I, 0.8I, 1.0I and 1.2I, respectively obtains voltage values A12, … and A17, current values B12, … and B17 and power consumption values C12, … and C17 from the sampling circuit MCU, reads voltage values X12, … and X17 from the data acquisition card, reads current values Y12, … and Y17 from the program control direct current power supply, and calculates power consumption values Z12, … and Z17.
5) The upper computer control terminal controls the program-controlled direct current power supply to output 1.0V and 1.1V according to the test of the upper stroke, and respectively sends instructions to enable the load current of the direct current electronic load to be 0.2I, 0.4I, 0.6I, 0.8I, 1.0I and 1.2I, and respectively obtains a voltage value, a current value and a power consumption value from a sampling circuit MCU of the circuit board, as shown in the following table:
TABLE 1 Voltage, Current, Power consumption values obtained from the sampling Circuit MCU of the Circuit Board
The upper computer control terminal respectively obtains a voltage value, a current value and a power consumption value from the data acquisition card and the program-controlled direct-current power supply as shown in the following table:
TABLE 2 obtaining voltage, current and power consumption values from the data acquisition card
6) After data acquisition is finished, the upper computer control terminal selects different algorithms, such as: linear first order, polynomial second order, exponential function, moving average fitting and other algorithms,making calibration curve and error compensation, and calculating correlation coefficient (R) of each algorithm by using least square method as basic criterion2) And the mean square error (RMSE) is used as an index, the fitting degrees of different algorithms are compared, and the most accurate fitting algorithm for the power supply sampling circuit is selected, so that the power consumption of the ground voltage and the current can be accurately calculated at the later stage.
For example: recording the data obtained in step 5, taking the voltage value calibration as an example, according to a linear function relation of X ═ kA + d, where X represents the voltage value obtained from the data acquisition card, k represents the coefficient of the first term of the voltage value calibration, a represents the voltage value obtained from the sampling circuit MCU of the circuit board, and d is the constant term of the voltage value calibration, substituting two groups of data (a11, …, a17), (X11, …, X17) at 0.9V voltage into operation, and calculating parameters k and b according to the rule of least squares method, thereby obtaining (X11 ', …, X17') according to the relation of X '═ kA + d, and X' is the voltage value obtained according to the linear algorithm calibration, and obtaining (X11 ', …, X17') according to the correlation coefficient R2And calculating R obtained by fitting a linear algorithm by using a calculation formula of a mean square error (RMSE)1 2Sum mean square error RMSE1:
Where i represents the number of measurements.
7) The upper computer control terminal sets lA according to the second-order polynomial function relation2+ mA + n, X represents the voltage value obtained from the data acquisition card, l represents the quadratic term coefficient of the voltage value calibration, A represents the voltage value obtained from the sampling circuit MCU of the circuit board, m represents the first order coefficient of the voltage value calibration, n is the constant term of the voltage value calibration, two groups of data (A11, …, A17), (X11, …, X17) under the voltage of 0.9V are substituted into the operation, parameters l, m and n are calculated according to the criterion of the least square method, and the relation X is lA ″2+ mA + n yields the voltage values (X11 ', …, X17') calibrated according to a second order polynomial functional relation algorithm, according to the correlation coefficient R2And a calculation formula of mean square error RMSE, and calculating a correlation coefficient R obtained by selecting a second-order polynomial function to fit2 2Sum mean square error RMSE2。
Where i represents the number of measurements.
If R is2 2Greater than R1 2,RMSE2Less than RMSE1Then, the algorithm of the second-order polynomial function relation is selected to be used as the fitting of the 0.9V voltage more accurately, and the sampling circuit is closer to the true value after the algorithm is adopted for error compensation.
8) And according to the step 6 and the step 7, the upper computer control terminal respectively adopts different algorithms to compare to obtain a fitting algorithm and error compensation data which are most suitable for the current value and the power consumption value of the power supply under the voltage of 0.9V.
9) And (3) automatically calculating all fitting algorithm parameters and error compensation data of the power supply under 1.0V and 1.1V according to the setting of the step (2) by a program established by the upper computer control terminal.
10) Because the working voltage and the working current of different power supply circuits on the circuit board are different, the parameter setting of the step 2 is needed in the calibration process of each power supply sampling circuit, so that the calibration process of the sampling circuit can cover the actual power supply working condition, and the sampling accuracy of the calibrated sampling circuit is realized. Meanwhile, a software interface of the upper computer control terminal provides recommended set values of different voltages of different power supply circuits.
11) After all the test works are completed, the required report formats, such as txt, xls, pdf and the like, are selected in the report option card, and the positions for storing the reports can be selected. The upper computer control terminal records the time, the specific test data, the error compensation data and the like of all test items, and the generated report structure is as follows:
TABLE 3 time, specific test data and error compensation data for all test items
12) And extracting the corresponding error compensation data table in the report, downloading the error compensation data table to a Micro Control Unit (MCU) through an upper computer control terminal, and upgrading the program to finish the calibration work.
Compared with the prior method for calibrating the sampling circuit in the circuit board by adopting other circuits formed by auxiliary components for error compensation, the method provided by the embodiment of the invention can quickly and accurately finish the upgrading and calibrating work of the sampling circuit in the circuit board, can obviously improve the working efficiency, increases the accuracy of calculating and measuring parameters such as current, power consumption and the like, and improves the accuracy of calibrating the sampling circuit in the circuit board.
Various modifications and variations of the embodiments of the present invention may be made by those skilled in the art, and they are also within the scope of the present invention, provided they are within the scope of the claims of the present invention and their equivalents.
What is not described in detail in the specification is prior art that is well known to those skilled in the art.