Identifying common periodic waveforms (square, sine, sawtooth, …)

前端 未结 7 2236
盖世英雄少女心
盖世英雄少女心 2021-02-09 10:31

Without any user interaction, how would a program identify what type of waveform is present in a recording from an ADC?

For the sake of this question: triangle, square

相关标签:
7条回答
  • 2021-02-09 10:55

    You definitely want to start by taking an autocorrelation to find the fundamental.

    With that, take one period (approximately) of the waveform.

    Now take a DFT of that signal, and immediately compensate for the phase shift of the first bin (the first bin being the fundamental, your task will be simpler if all phases are relative). Now normalise all the bins so that the fundamental has unity gain.

    Now compare and contrast the rest of the bins (representing the harmonics) against a set of pre-stored waveshapes that you're interested in testing for. Accept the closest, and reject overall if it fails to meet some threshold for accuracy determined by measurements of the noisefloor.

    0 讨论(0)
  • 2021-02-09 11:00

    I think that all of these answers so far are quite bad (including my own previous...) after having thought the problem through a bit more I would suggest the following:

    1) take a 1 second sample of the input signal (doesn't need to be so big, but it simplifies a few things)

    2) over the entire second, count the zero-crossings. at this point you have the cps (cycles per second) and know the frequency of the oscillator. (in case that's something you wanted to know)

    3) now take a smaller segment of the sample to work with: take precisely 7 zero-crossings worth. (so your work buffer should now, if visualized, look like one of the graphical representations you posted with the original question.) use this small work buffer to perform the following tests. (normalizing the work buffer at this point could make life easier)

    4) test for square-wave: zero crossings for a square wave are always very large differences, look for a large signal delta followed by little to no movement until the next zero crossing.

    5) test for saw-wave: similar to square-wave, but a large signal delta will be followed by a linear constant signal delta.

    6) test for triangle-wave: linear constant (small) signal deltas. find the peaks, divide by the distance between them and calculate what the triangle wave should look like (ideally) now test the actual signal for deviance. set a deviance tolerance threshold and you can determine whether you are looking at a triangle or a sine (or something parabolic).

    0 讨论(0)
  • 2021-02-09 11:05

    First find the base frequency and the phase. You can do that with FFT. Normalize the sample. Then subtract each sample with the sample of the waveform you want to test (same frequency and same phase). Square the result add it all up and divide it by the number of samples. The smallest number is the waveform you seek.

    0 讨论(0)
  • 2021-02-09 11:08

    arm yourself with more information...

    I am assuming that you already know that a theoretically perfect sine wave has no harmonic partials (ie only a fundamental)... but since you are going through an ADC you can throw the idea of a theoretically perfect sine wave out the window... you have to fight against aliasing and determining what are "real" partials and what are artifacts... good luck.

    the following information comes from this link about csound.

    (*) A sawtooth wave contains (theoretically) an infinite number of harmonic partials, each in the ratio of the reciprocal of the partial number. Thus, the fundamental (1) has an amplitude of 1, the second partial 1/2, the third 1/3, and the nth 1/n.

    (**) A square wave contains (theoretically) an infinite number of harmonic partials, but only odd-numbered harmonics (1,3,5,7,...) The amplitudes are in the ratio of the reciprocal of the partial number, just as sawtooth waves. Thus, the fundamental (1) has an amplitude of 1, the third partial 1/3, the fifth 1/5, and the nth 1/n.

    0 讨论(0)
  • Perform an autocorrelation to find the fundamental frequency, measure the RMS level, find the first zero-crossing, and then try subtracting common waveforms at that frequency, phase, and level. Whichever cancels out the best (and more than some threshold) wins.

    0 讨论(0)
  • 2021-02-09 11:19

    Do an FFT, find the odd and even harmonic peaks, and compare the rate at which they decrease to a library of common waveform.. peak... ratios.

    0 讨论(0)
提交回复
热议问题