A / D conversion interface circuit is a link in the forward channel of data acquisition system. Its function is to convert analog signals into digital signals that can be processed by computer. It is one of the indispensable links in general control system. People sometimes need to set a threshold value for the data of a / D conversion as the basis for judgment and processing. For example, set a threshold value and compare it with the result of a / D conversion. When the data result of a / D conversion is greater than or less than the threshold value, it is used as the basis for judging the start or end of an operation. However, if this threshold setting is unreasonable, it will lead to problems.

Fig. 1 is a partial graph drawn by the data obtained from the analog signal generated by the sensor after a / D conversion in a project. The maximum value of each peak and the number of waveforms are obtained according to the needs of the project.

The initial solution is to first determine a threshold (such as O.2), which should ensure that all possible peak values are greater than this value. The data collected by reading a / D is compared with the determined threshold. When a value is greater than the threshold, it indicates the arrival of a waveform, and the maximum value is obtained through comparison. Then judge whether the A / D conversion value is less than the threshold again. If it is less than the threshold again, it indicates that the waveform is about to end. Save the maximum value as the maximum value of the whole waveform and increase the number of one waveform.

Practice has proved that this method does not solve the problem well. Although the maximum value of wave crest and the number of waveforms can be obtained accurately in most cases, the number of waveforms obtained is more than the actual waveform occasionally. Once subjectively thought it was due to interference. However, after analyzing the waveform data, it is found that the maximum peak of the extra waveform is all concentrated near the threshold, and a similar situation occurs after changing different thresholds, so it can be concluded that there is a certain relationship between the generation of the problem and the setting of the threshold. 1. Cause analysis

Through analysis, it is found that the above problems are not caused by logical relationship, but by the sampling accuracy of a / D and the signal itself in practical work. The reasons for the above problems are analyzed from these two aspects.

1.1 influence of signal

From the graph depicted by the collected digital signal (Fig. 1), it can be seen that there is a large amount of white noise. Even if the signal before a / D conversion is filtered, the transformed signal will have more or less noise. The intersection of the waveform and the threshold line in Fig. 1 (here the falling edge is taken as an example) is enlarged and displayed, as shown in Fig. 2. Due to the existence of high-frequency noise, it is likely to produce the situation depicted in Fig. 2, that is, when the waveform falls below the threshold line in the falling process, it returns above the threshold line. A / D performs high-speed sampling and records this situation. According to the logic of the original design scheme, when the waveform drops below the threshold line, it is judged as the end of a waveform; When the waveform rises below the threshold line and exceeds the threshold line, it is considered to be the beginning of a waveform. Therefore, during the decline of the waveform, the fluctuation near the threshold line is recorded as a new waveform. Because this waveform is caused by white noise and the change amplitude is very small, it is generally slightly higher than the threshold line, so the maximum value of the excess waveform will be concentrated near the threshold, which is consistent with the actual situation.

1.2 influence of a / D conversion accuracy

Although the nominal non adjustable error of some a / D products is ≤ 1lsb, it is difficult to achieve the above accuracy in practical engineering application due to the influence of power supply voltage, interference and other factors. That is to say, even for the ideal constant signal, the conversion value obtained by a / D conversion actually fluctuates up and down around the constant signal value. In this example, when the signal drops near the threshold (assuming that the signal is pure and does not contain any clutter components), the collected data may also fluctuate near the threshold due to the influence of a / D conversion accuracy, resulting in the result of multi recording waveform data. Of course, in this case, the maximum value of the multi recorded waveform is affected by the A / D conversion accuracy, which is generally closer to the threshold than the maximum value of the waveform caused by the signal itself.

2 solution

Through the above analysis, although the problem can be solved manually by reducing signal noise and improving a / D conversion accuracy, it will be quite troublesome, especially when the accuracy and other factors can meet the actual needs, it is quite undesirable to carry out the above processing, because it is very difficult to improve the accuracy when the accuracy reaches a certain degree.

There is a very simple way to solve the above problems: set different thresholds.

Firstly, a discrimination threshold is determined for the rising edge to distinguish the beginning of the waveform. Then, set another discrimination threshold on the falling edge of the waveform to judge the end of a waveform. There is a difference between the two, and ensure that the difference between the rising threshold minus the falling threshold is greater than the maximum value of noise and a / D fluctuation (try to make the difference as large as possible in practical work). In this way, even if there is a fluctuation near the falling threshold (caused by any reason), because its peak value cannot be greater than the rising discrimination threshold, it will not be mistaken for the beginning of a new waveform, and the possibility of misjudging the waveform will not be increased. In practical engineering, it is proved that this method is simple and effective, and solves the problem of waveform misjudgment.

Editor in charge: GT