Sampling value switching method and sampling circuit for variable threshold
Technical Field
The invention belongs to the technical field of power grids, and particularly relates to a sampling value switching method and a sampling circuit for a variable threshold.
Background
Electronic transformers are increasingly applied to alternating current and direct current transmission systems, and particularly are widely used in ultra-high voltage direct current and flexible direct current transmission projects in China in recent years and used for measuring high current and high voltage of a direct current field. For the active direct current electronic transformer, a primary sensor converts a measured direct current or voltage into an analog small voltage signal which is linearly related to the measured direct current or voltage, the analog small voltage signal is converted into a digital quantity through the processing of an on-site acquisition module, the acquisition module sends the processed data to a merging unit, and finally the merging unit merges a plurality of measuring points and outputs the merged data.
The measurement accuracy is a key index of the direct current electronic transformer, the direct current system has higher requirements on the measurement accuracy, for example, the current measurement accuracy should reach 0.2 level within a range of at least 6 times, the voltage measurement accuracy should reach 0.2 level within a range of at least 1.5 times, and the direct current system has higher accuracy requirements on low points. In the sampling link, the above requirements are generally difficult to meet by adopting a single-path AD, and the current common practice is to connect the tested signal into a plurality of sampling channels (not less than 2) with different amplification factors, respectively convert the signals by the multiple paths AD, and output the final sampling value after switching, so as to consider the wide range and the low point precision.
The application with publication number of CN102323498A discloses a multistage sectional data sampling method, 5-stage sectional is carried out on an input electric quantity signal, 5 paths of channels respectively have different amplification factors, amplification on different stages of the sampled signal is realized by switching analog switches corresponding to the channels, and finally, 5-stage sectional sampled data is output for switching, so that the sampling precision is improved. But this application has the following problems: the switching fixed value is a fixed threshold, and the method is suitable for the occasion that the output signal of the sensor is fixed and accurate, and when the front-end sensor changes the specification or adjusts the output transformation ratio, the measuring range of the AD is fixed, so that the problem that frequent switching or full code switching cannot be caused. For example, if the rated output of the sensor is smaller than the rated output by 20%, if the sensor is still switched between the original 120% and 80%, the sensor is frequently switched at a lower measuring point, so that sampling value fluctuation is caused; if the nominal output of the sensor is 20% greater than before, if it is still switching at the original 120% point, AD saturation may not switch normally due to the signal becoming large.
The rated primary current and rated primary voltage of the direct current electronic transformer are not completely standardized, different engineering parameters are different, the primary sensors with different specifications cannot ensure that the direct current electronic transformer has completely consistent output, for example, high-voltage arms of 800kV, 660kV and 75kV direct current voltage dividers are respectively connected in series by 8 sections, 6 sections and 1 section of 100MΩ resistor cylinders, the parameters of a low-voltage arm and a secondary voltage dividing unit are fixed, the rated secondary output of the low-voltage arm and the secondary voltage dividing unit is respectively 0.66V, 0.726V and 0.495V, when the low-voltage arm and the secondary voltage dividing unit are matched with the primary sensors with different specifications in the actual engineering, the rated input quantity of a sampling circuit is different, the selection of a fixed switching threshold is difficult, the problem exists in overlarge or overlarge, the advantage of multi-range switching is difficult to be completely and effectively exerted, the engineering adaptability is poor, and even different hardware needs to be developed.
Disclosure of Invention
The invention aims to provide a sampling value switching method of a variable threshold, which can adaptively calculate a reasonable sampling switching threshold when being matched with sensors with different specifications, maximally exert the switching function of a multi-channel AD measurement value and improve the measurement accuracy and engineering design adaptability.
In order to achieve the aim of the invention, the technical scheme adopted by the application is as follows:
as a first aspect of the present application, a method for switching sampling values of a variable threshold is provided, including:
the method comprises the steps that an original analog sampling value signal output by a sensor is processed by a first operational amplifier circuit with the amplification factor of K1 and a second operational amplifier circuit with the amplification factor of K2 to obtain a first analog sampling value signal and a second analog sampling value signal, wherein K1 is larger than K2;
the first analog sampling value signal is subjected to analog-to-digital conversion through a first AD module to obtain a first digital sampling value signal, and the second analog sampling value signal is subjected to analog-to-digital conversion through a second AD module to obtain a second digital sampling value signal;
the DSP receives the first digital sampling value signal and the second digital sampling value signal output by the first AD module and the second AD module, and respectively obtains a first sampling value signal V1 and a second sampling value signal V2 after the first digital sampling value signal and the second digital sampling value signal are calibrated and normalized; the switching processing of the first sampling value signal V1 and the second sampling value signal V2 is performed to obtain a final sampling value V, which specifically includes:
the value of the first sampling value switching threshold X1 is calculated according to the sensor calibration coefficient K: x1=kx1n;
the output value of the first AD module under the rated signal is V1N, and the value of X1N is 1.05X V1N and the value between the full code value of the first AD module;
a second sampling value switching threshold x2=mxx1, m being a constant smaller than 1;
when V1 is less than or equal to X1, the final sampling value takes V1 data; when V1> X1, switching to output V2 data; once switched to V2 data, V1 data is switched back only when V2< X2 is satisfied.
Preferably, the sensor calibration coefficient K is related to the sensor, and is obtained through actual testing; when the sensor output is an ideal value, the calibration coefficient K is 1; when the actual output value of the sensor is larger than the ideal value, the calibration coefficient K is smaller than 1; when the actual output value of the sensor is smaller than the ideal value, the calibration coefficient K is larger than 1.
Preferably, the calibration processing mode is as follows: the sampled value signal received from the AD module is multiplied by a calibration coefficient K.
Preferably, the normalization is performed by normalizing the second digital sample value signal to the first digital sample value signal.
Preferably, a switching mark f is introduced, f is 0 when the last final sampling value is output as V1 data, f is 1 when the last final sampling value is output as V2 data, and the initialization state f is 0; when V1> X1, switching to V2 data, i.e. outputting v=v2, while switching flag f to set 1, otherwise v=v1, f to set 0; when the data is switched to the V2 data, the switching return judgment condition is V2< X2, if the judgment condition is satisfied, the data is switched to v=v1 and f is set to 0, otherwise, the data is switched to v=v2 and f is set to 1.
As a second aspect of the present application, a variable threshold sampling circuit is provided, including:
the first operational amplifier circuit is used for receiving the original analog sampling value signal output by the sensor, amplifying the original analog sampling value signal by K1 times and then outputting a first analog sampling value signal;
the second operational amplifier circuit is used for receiving the original analog sampling value signal output by the sensor, amplifying the original analog sampling value signal by K2 times and then outputting a second analog sampling value signal; wherein K1 > K2;
the first AD module is used for receiving the first analog sampling value signal and obtaining a first digital sampling value signal through analog-to-digital conversion;
the second AD module is used for receiving the second analog sampling value signal and obtaining a second digital sampling value signal through analog-to-digital conversion;
the DSP is used for receiving the first digital sampling value signal and the second digital sampling value signal output by the first AD module and the second AD module, and respectively obtaining a first sampling value signal V1 and a second sampling value signal V2 after calibrating and normalizing the first digital sampling value signal and the second digital sampling value signal; the switching processing of the first sampling value signal V1 and the second sampling value signal V2 is performed to obtain a final sampling value V, which specifically includes:
the value of the first sampling value switching threshold X1 is calculated according to the sensor calibration coefficient K: x1=kx1n;
the output value of the first AD module under the rated signal is V1N, and the value of X1N is 1.05X V1N and the value between the full code value of the first AD module;
a second sampling value switching threshold x2=mxx1, m being a constant smaller than 1;
when V1 is less than or equal to X1, the final sampling value takes V1 data; when V1> X1, switching to output V2 data; once switched to V2 data, V1 data is switched back only when V2< X2 is satisfied.
Preferably, the sensor calibration coefficient K is related to the sensor, and is obtained through actual testing; when the sensor output is an ideal value, the calibration coefficient K is 1; when the actual output value of the sensor is larger than the ideal value, the calibration coefficient K is smaller than 1; when the actual output value of the sensor is smaller than the ideal value, the calibration coefficient K is larger than 1.
Preferably, the calibration processing mode is as follows: the sampled value signal received from the AD module is multiplied by a calibration coefficient K.
Preferably, the normalization is performed by normalizing the second digital sample value signal to the first digital sample value signal.
Preferably, the DSP introduces a switching flag f in the switching process, where f is 0 when the last final sampling value is output as V1 data, f is 1 when the last final sampling value is output as V2 data, and the initialization state f is 0; when V1> X1, switching to V2 data, i.e. outputting v=v2, while switching flag f to set 1, otherwise v=v1, f to set 0; when the data is switched to the V2 data, the switching return judgment condition is V2< X2, if the judgment condition is satisfied, the data is switched to v=v1 and f is set to 0, otherwise, the data is switched to v=v2 and f is set to 1.
The invention has the beneficial effects that: according to the method, the analog signals are converted in a digital mode through two paths of sampling channels with different amplification factors, normalization processing and coefficient calibration of the two paths of data are completed through software, a reasonable sampling value switching threshold is determined according to calculation of calibration coefficients, and finally the sampling data after multi-channel switching are output. The multi-channel sampling value switching technology is improved, a reasonable sampling switching threshold can be calculated and determined in a self-adaptive mode, the problem that the traditional sampling value switching fixed threshold is difficult to select is solved, the multi-channel AD measurement value switching function is exerted to the maximum extent, and the measurement accuracy and engineering design adaptability are improved.
Drawings
Fig. 1 is a schematic diagram of a variable threshold sampling circuit according to an embodiment of the present application.
Fig. 2 is a flowchart of a variable threshold sampling value switching method according to an embodiment of the present application.
Fig. 3 is another switching flowchart of an embodiment of the present application.
Detailed Description
The following detailed description of specific embodiments of the invention is provided in connection with the accompanying drawings and examples in order to provide a better understanding of the invention and its various aspects and advantages. However, the following description of specific embodiments and examples is for illustrative purposes only and is not intended to be limiting of the invention.
Fig. 1 shows a variable threshold sampling circuit according to an embodiment of the present application, including: the first operational amplifier circuit, the second operational amplifier circuit, the first AD module, the second AD module and the DSP, wherein:
the first operational amplifier circuit is used for receiving the original analog sampling value signal output by the sensor, amplifying the original analog sampling value signal by K1 times and then outputting a first analog sampling value signal.
The second operational amplifier circuit is used for receiving the original analog sampling value signal output by the sensor, amplifying the original analog sampling value signal by K2 times and then outputting a second analog sampling value signal; wherein K1 > K2.
And the first AD module is used for receiving the first analog sampling value signal and obtaining a first digital sampling value signal through analog-to-digital conversion.
And the second AD module is used for receiving the second analog sampling value signal and obtaining a second digital sampling value signal through analog-to-digital conversion.
In the sampling circuit of the application, sampling channels with two paths of different amplification factors are included, a first operational amplifier circuit and a first AD module are the first path of sampling channels, and a second operational amplifier circuit and a second AD module are the second path of sampling channels. The amplification factor of the first path of sampling channel is larger, so that the first path of sampling channel has a smaller measuring range; the second path of sampling channel has smaller magnification, so the second path of sampling channel has larger measuring range. The two paths of sampling values are in a fixed proportion relation.
The DSP is used for receiving the first digital sampling value signal and the second digital sampling value signal output by the first AD module and the second AD module, and respectively obtaining a first sampling value signal V1 and a second sampling value signal V2 after calibrating and normalizing the first digital sampling value signal and the second digital sampling value signal; the first sampling value signal V1 and the second sampling value signal V2 are subjected to switching processing to obtain a final sampling value V.
Because the calibration coefficient reflects the degree of deviation of the sensor from an ideal value, such as the coefficient K >1, the actual output of the sensor is smaller, and the original sampling value of the AD is smaller and the distance is saturated with a larger margin, so that in order to fully utilize the advantage of the first AD module that the accuracy of the first AD module is higher in the measurable range, the switching value X1 can be made larger, otherwise, the AD saturation problem needs to be considered, and the switching value X1 should be made smaller.
Based on the above considerations, in this embodiment, the obtaining the final sampling value V after the switching processing of the first sampling value signal V1 and the second sampling value signal V2 specifically includes:
the value of the first sampling value switching threshold X1 is calculated according to the sensor calibration coefficient K: x1=kx1n;
the output value of the first AD module under the rated signal is V1N, and the value of X1N is 1.05X V1N and the value between the full code value of the first AD module;
a second sampling value switching threshold x2=mxx1, m being a constant smaller than 1;
when V1 is less than or equal to X1, the final sampling value takes V1 data; when V1> X1, switching to output V2 data; once switched to V2 data, V1 data is switched back only when V2< X2 is satisfied.
Based on the sampling circuit shown in fig. 1, a sampling switching method of a variable threshold of the present application is shown in fig. 2, and includes the following steps:
s1: the method comprises the steps that an original analog sampling value signal output by a sensor is processed by a first operational amplifier circuit with the amplification factor of K1 and a second operational amplifier circuit with the amplification factor of K2 to obtain a first analog sampling value signal and a second analog sampling value signal, wherein K1 is larger than K2.
S2: the first analog sampling value signal is subjected to analog-to-digital conversion through a first AD module to obtain a first digital sampling value signal, and the second analog sampling value signal is subjected to analog-to-digital conversion through a second AD module to obtain a second digital sampling value signal.
S3, the DSP receives the first digital sampling value signal and the second digital sampling value signal output by the first AD module and the second AD module, and respectively obtains a first sampling value signal V1 and a second sampling value signal V2 after the first digital sampling value signal and the second digital sampling value signal are calibrated and normalized; the switching processing of the first sampling value signal V1 and the second sampling value signal V2 is performed to obtain a final sampling value V, which specifically includes:
the value of the first sampling value switching threshold X1 is calculated according to the sensor calibration coefficient K: x1=kx1n;
the output value of the first AD module under the rated signal is V1N, and the value of X1N is 1.05X V1N and the value between the full code value of the first AD module;
a second sampling value switching threshold x2=mxx1, m being a constant smaller than 1;
when V1 is less than or equal to X1, the final sampling value takes V1 data; when V1> X1, switching to output V2 data; once switched to V2 data, V1 data is switched back only when V2< X2 is satisfied.
Because the sensor has different specifications or the sensor has error influence, the actual output has deviation from the ideal output, so the sensor calibration coefficient K is obtained through testing, and the DSP performs coefficient compensation. The sensor calibration coefficient K is related to the sensor and is obtained through actual testing; when the sensor output is an ideal value, the calibration coefficient K is 1; when the actual output value of the sensor is larger than the ideal value, the calibration coefficient K is smaller than 1; when the actual output value of the sensor is smaller than the ideal value, the calibration coefficient K is larger than 1. The processing mode of the calibration is as follows: the sampled value signal received from the AD module is multiplied by a calibration coefficient K.
Because the two paths of sampling values are in a fixed proportion relationship, the comparison needs to be performed by normalizing the AD sampling value with a larger measuring range to the AD sampling value with a smaller measuring range, namely normalizing the second digital quantity sampling value signal to the first digital quantity sampling value signal.
In some embodiments, when performing the handover process, the processing manner shown in fig. 3 is adopted: introducing a switching mark f, wherein f is 0 when the last final sampling value is output as V1 data, f is 1 when the last final sampling value is output as V2 data, and the initialization state f is 0; when V1> X1, switching to V2 data, i.e. outputting v=v2, while switching flag f to set 1, otherwise v=v1, f to set 0; when the data is switched to the V2 data, the switching return judgment condition is V2< X2, if the judgment condition is satisfied, the data is switched to v=v1 and f is set to 0, otherwise, the data is switched to v=v2 and f is set to 1.
The switching scheme of the present application will be specifically described below by taking the aforementioned 800kV, 660kV, 75kV dc voltage dividers as examples. The rated secondary outputs of the sensors of the 800kV, 660kV and 75kV direct current voltage divider are respectively 0.66V, 0.726V and 0.495V, different design parameters, errors and other factors are considered in practice, the rated secondary outputs are in a certain range, the range of 0.4V to 0.8V can be considered, a sampling circuit is designed according to the ideal output of 0.66V, the original sampling code values after 2 paths of 16-bit AD (AD 1 and AD 2) conversion are respectively designed into 20000 and 5000, at the moment, K=1, the switching threshold value can be selected to be 20000 multiplied by 120% =24000, the switching threshold value is between 20000 multiplied by 1.05 and the full code value 32767, and higher measurement accuracy can be ensured, and the AD is unsaturated at the maximum of 0.8V. For 660kV and 75kV direct current voltage dividers, rated secondary output of the sensor is 0.726V and 0.495V respectively, at the moment, original sampling code values after AD1 conversion are 22000 and 15000 respectively, sensor correction coefficients K are 0.9091 and 1.3333 respectively, and the aspects of improving measurement accuracy, avoiding that AD is not switched yet and avoiding frequent switching at a rated point and below when AD is saturated are considered in selection of a switching value X1, so 24000K is more reasonable, namely sampling switching values X1 of the sampling values of the 660kV and 75kV direct current voltage dividers after coefficient calibration and normalization are 21818 and 32000 respectively. The sampling switch value X2 is mainly to avoid frequent switching, and should take a smaller value than X1, where x2=mx1, where m is preferably a constant between 0.9 and 1, such as m=0.95, and the value of X2 can be determined.
After sampling is started, original sampling values are read, and the sampling values AD1 and AD2 are normalized and calibrated, wherein the normalization is specifically to normalize the sampling value AD2 with a larger measuring range to the sampling value AD1 with a smaller measuring range, and the calibration is that two paths of sampling values are multiplied by a calibration coefficient K, and then two paths of sampling values V1 and V2 are obtained respectively.
Based on the method, the method for judging and selecting the final sampling output comprises the following steps: a switching flag f is introduced, f is 0 when the previous output is V1, f is 1 when the previous output is V2, and the initialization state f is 0. When V1> X1, switching to V2 data, i.e. outputting v=v2, while switching flag f to 1, otherwise v=v1, f to 0. When the data is switched to the V2 data, the switching return judgment condition is V2< X2, if the judgment condition is satisfied, the data is switched to v=v1 and f is set to 0, otherwise, the data is switched to v=v2 and f is set to 1.
And after switching judgment, outputting a final sampling value V. In practical application, the sampling system collects, processes and transmits the sampling value at a certain frequency.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.