Threshold setting for A/D high-speed acquisition of analog signals[Copy link]
Source: Single-chip microcomputer and embedded system application Author: Li Daguo and Zhang Qingming, Beijing Institute of Technology The A/D conversion interface circuit is a link in the forward channel of the data acquisition system. Its function is to convert analog signals into digital signals that can be processed by computers. It is one of the indispensable links in general control systems. Sometimes people need to set a threshold value for the A/D conversion data as a basis for judgment and processing, such as setting a threshold value and comparing 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 a basis for judging whether to start or end a certain operation. However, if the threshold value is set unreasonably, problems will arise.
Figure 1 is a partial graph depicted by the data obtained after A/D conversion of the analog signal generated by the sensor in a certain project. According to the needs of the project, the maximum value of each peak and the number of waveforms are obtained.
The initial solution is to first determine a threshold value (such as O.2). The determination of this value should ensure that all possible peak values are greater than this value. Read the data collected by the A/D and compare it with the determined threshold value. When there is a value greater than the threshold value, it indicates the arrival of a waveform, and the maximum value is obtained through continuous comparison. Then determine 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 entire waveform and increase the number of waveforms.
Practice has proved that this method does not solve the problem very well. Although the maximum value of the peak and the number of waveforms can be accurately obtained in most cases, occasionally the number of waveforms obtained is more than the actual waveform. I once subjectively thought that this was due to interference. But later, after analyzing the waveform data, it was found that the maximum peaks of the extra waveforms were all concentrated near the threshold. After changing different thresholds, similar situations occurred, so it can be concluded that there is a certain connection 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 relationships, but by the sampling accuracy of A/D and the signal itself in actual work. The following analyzes the causes of the above problems from these two aspects. 1.1 Signal Influence From the graph depicted by the collected digital signal (Figure 1), it can be seen that there is a lot of white noise. Even if the signal before A/D conversion is filtered to a certain extent, the converted signal will have more or less noise. The intersection of the waveform and the threshold line in Figure 1 (here taking the falling edge as an example) is enlarged and displayed, as shown in Figure 2.
Due to the existence of high-frequency noise, the situation depicted in Figure 2 is likely to occur, that is, when the waveform drops below the threshold line during the falling process, there is a situation where it returns to above the threshold line. The 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 from below the threshold line to exceed the threshold line, it is considered to be the beginning of a waveform. Therefore, during the falling process of the waveform, this fluctuation near the threshold line is recorded as a new waveform. Since this waveform is caused by white noise, the change amplitude is very small, and generally slightly higher than the threshold line, so the maximum value of the extra waveform will be concentrated near the threshold, which is consistent with the actual situation. 1.2 Influence of A/D conversion accuracy Although some A/D products have a nominal unadjustable error of ≤1LSB, it is difficult to achieve the above accuracy in actual engineering applications due to the influence of factors such as power supply voltage and interference. This means that even if the A/D conversion is performed for an ideal constant signal, the converted value actually fluctuates around the constant signal value. In this example, when the signal drops to near the threshold (assuming the signal is pure and does not contain any clutter), due to the influence of A/D conversion accuracy, the acquired data may also fluctuate near the threshold, resulting in multiple recorded waveform data. Of course, in this case, the maximum value of the multi-recorded waveform is affected by the A/D conversion accuracy and 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 to solve it. 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 level.
There is a very simple way to solve the above problem: set different thresholds.
First, determine a discrimination threshold for the rising edge to distinguish the beginning of the waveform. Then, set another discrimination threshold for the falling edge of the waveform to distinguish the end of a waveform. There is a difference between the two, and ensure that the difference between the rising threshold and the falling threshold is greater than the maximum value of the noise and A/D fluctuation (in actual work, the difference is as large as possible). In this way, even if fluctuations occur near the falling threshold (regardless of the cause), since 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 actual engineering, it is proved that this method is simple and effective, and it solves the problem of waveform misjudgment very well.